add.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  1. <template>
  2. <div id="addDivision">
  3. <el-form :model="basicForm" :rules="basicRules" ref="basic" label-width="auto">
  4. <el-row :gutter="10">
  5. <el-col :span="1.5">
  6. <el-form-item label="物料分类编码">
  7. <el-input :disabled="disable" size="small" style="width: 200px" readonly v-model="basicForm.materialClassify">
  8. <el-button slot="append" icon="el-icon-more" @click="chooseFourClass"></el-button>
  9. </el-input>
  10. </el-form-item>
  11. </el-col>
  12. <el-col :span="1.5">
  13. <el-form-item label="物料分类名称">
  14. <el-input
  15. v-model="basicForm.materialClassifyName"
  16. size="small"
  17. disabled
  18. clearable
  19. style="width: 200px"
  20. />
  21. </el-form-item>
  22. </el-col>
  23. <el-col :span="1.5">
  24. <el-form-item label="一级分类编码">
  25. <el-input
  26. v-model="basicForm.materialClassifyOne"
  27. size="small"
  28. disabled
  29. clearable
  30. style="width: 200px"
  31. />
  32. </el-form-item>
  33. </el-col>
  34. <el-col :span="1.5">
  35. <el-form-item label="一级分类名称">
  36. <el-input
  37. v-model="basicForm.materialClassifyOneName"
  38. size="small"
  39. disabled
  40. clearable
  41. style="width: 200px"
  42. />
  43. </el-form-item>
  44. </el-col>
  45. <el-col :span="1.5">
  46. <el-form-item label="二级分类名称">
  47. <el-input
  48. v-model="basicForm.materialClassifyTwoName"
  49. size="small"
  50. disabled
  51. clearable
  52. style="width: 200px"
  53. />
  54. </el-form-item>
  55. </el-col>
  56. <el-col :span="1.5">
  57. <el-form-item label="三级分类名称">
  58. <el-input
  59. v-model="basicForm.materialClassifyThreeName"
  60. size="small"
  61. disabled
  62. clearable
  63. style="width: 200px"
  64. />
  65. </el-form-item>
  66. </el-col>
  67. <el-col :span="1.5">
  68. <el-form-item label="四级分类名称">
  69. <el-input
  70. v-model="basicForm.materialClassifyFourName"
  71. size="small"
  72. disabled
  73. clearable
  74. style="width: 200px"
  75. />
  76. </el-form-item>
  77. </el-col>
  78. <el-col :span="1.5">
  79. <el-form-item label="物料编码">
  80. <el-input :disabled="disable" style="width: 200px" size="small" readonly v-model="basicForm.materialCode">
  81. <el-button slot="append" icon="el-icon-more" @click="test01"></el-button>
  82. </el-input>
  83. <el-input v-show="false" style="width: 200px" size="small" v-model="basicForm.material"></el-input>
  84. </el-form-item>
  85. </el-col>
  86. <el-col :span="1.5">
  87. <el-form-item label="物料名称">
  88. <el-input
  89. v-model="basicForm.materialName"
  90. size="small"
  91. disabled
  92. clearable
  93. style="width: 200px"
  94. />
  95. </el-form-item>
  96. </el-col>
  97. <el-col :span="1.5">
  98. <el-form-item label="生产厂家">
  99. <el-input
  100. v-model="basicForm.manufacturer"
  101. size="small"
  102. :disabled="disable"
  103. clearable
  104. style="width: 200px"
  105. />
  106. </el-form-item>
  107. </el-col>
  108. <el-col :span="1.5">
  109. <el-form-item label="所属组织">
  110. <el-select
  111. ref="organizations"
  112. v-model="basicForm.org"
  113. size="small"
  114. style="width: 200px"
  115. :disabled="disable"
  116. clearable
  117. @focus="chooseRefer('ORG_PARAM', true, '选择所属组织')"
  118. >
  119. <el-option
  120. v-for="item in organizationsOptions"
  121. :key="item.id"
  122. :label="item.name"
  123. :value="item.id"
  124. />
  125. </el-select>
  126. </el-form-item>
  127. </el-col>
  128. <el-col :span="1.5">
  129. <el-form-item label="订单员">
  130. <el-select
  131. ref="staffs"
  132. size="small"
  133. style="width: 200px"
  134. :disabled="disable"
  135. v-model="basicForm.orderPersonal"
  136. clearable
  137. @focus="chooseRefer('CONTACTS_PARAM', true, '订单员')"
  138. >
  139. <el-option
  140. v-for="item in staffOptions"
  141. :key="item.id"
  142. :label="item.name"
  143. :value="item.code"
  144. />
  145. </el-select>
  146. </el-form-item>
  147. </el-col>
  148. <el-col :span="1.5">
  149. <el-form-item label="订单部门">
  150. <el-input
  151. v-model="basicForm.orderDept"
  152. size="small"
  153. disabled
  154. style="width: 200px"
  155. />
  156. </el-form-item>
  157. </el-col>
  158. <el-col :span="1.5">
  159. <el-form-item label="采购员">
  160. <el-select
  161. ref="staffs2"
  162. size="small"
  163. style="width: 200px"
  164. :disabled="disable"
  165. v-model="basicForm.buyer"
  166. clearable
  167. @focus="chooseRefer('CONTACTS_PARAM', true, '采购员')"
  168. >
  169. <el-option
  170. v-for="item in staff2Options"
  171. :key="item.id"
  172. :label="item.name"
  173. :value="item.code"
  174. />
  175. </el-select>
  176. </el-form-item>
  177. </el-col>
  178. <el-col :span="1.5">
  179. <el-form-item label="采购部门">
  180. <el-input
  181. v-model="basicForm.puDept"
  182. size="small"
  183. disabled
  184. style="width: 200px"
  185. />
  186. </el-form-item>
  187. </el-col>
  188. <el-col :span="1.5">
  189. <el-form-item label="同步状态">
  190. <el-input
  191. v-model="basicForm.sendStatus"
  192. size="small"
  193. disabled
  194. style="width: 200px"
  195. />
  196. </el-form-item>
  197. </el-col>
  198. <el-col :span="1.5">
  199. <el-form-item label="备注">
  200. <el-input
  201. v-model="basicForm.remark"
  202. size="small"
  203. :disabled="disable"
  204. clearable
  205. style="width: 200px"
  206. />
  207. </el-form-item>
  208. </el-col>
  209. </el-row>
  210. </el-form>
  211. <div class="btn_group">
  212. <el-col :span="1.5" style="margin: 0 10px;">
  213. <el-button type="primary" size="small" plain @click="save" v-if="pageStu == 'add' || pageStu == 'edit'">保存</el-button>
  214. </el-col>
  215. <!-- <el-col :span="1.5" style="margin: 0 10px;">
  216. <el-button type="primary" size="small" plain @click="submit" v-if="pageStu == 'edit'">提交</el-button>
  217. </el-col> -->
  218. <el-col :span="1.5">
  219. <el-button size="small" plain @click="back">返回</el-button>
  220. </el-col>
  221. </div>
  222. <fourClass
  223. ref="fourClass"
  224. @doSubmit="acceptFourClass"
  225. :single="true"
  226. />
  227. <popDialog
  228. ref="contractSelect"
  229. @doSubmit="selectionsToInput"
  230. :single="true"
  231. />
  232. <Refers ref="refer" @doSubmit="selectionsRefer" :single="true"/>
  233. <staff2
  234. ref="staff2"
  235. @doSubmit="acceptStaff2"
  236. :single="true"
  237. />
  238. </div>
  239. </template>
  240. <script>
  241. import {addDivision, getDivisions, editDivision} from '@/api/purchase/basic.js'
  242. // 物料分类
  243. import fourClass from '@/components/PopDialog/fourClass.vue'
  244. // 调用物料分类详情接口用于数据回显
  245. import { getDetail } from '@/api/classify/basic';
  246. // 物料编码
  247. import popDialog from '@/components/PopDialog/index.vue'
  248. // 公用一个树形(组织部门传值不同)
  249. import Refers from '@/components/Refers/refers.vue'
  250. // 用于回显参照框数据
  251. import { getRefer } from '@/api/purchase/basic.js'
  252. import staff2 from '@/components/PopDialog/staff.vue'
  253. // 所属组织,订单员用于回显
  254. import { getOrgs, getStaff} from '@/api/requisition/basic'
  255. export default {
  256. name: 'addDivision',
  257. components: {
  258. fourClass,
  259. popDialog,
  260. Refers,
  261. staff2
  262. },
  263. props: ['pageStu','row', 'disable'],
  264. model: {
  265. prop: 'isList',
  266. event: 'jugislist'
  267. },
  268. data() {
  269. return {
  270. basicForm: {
  271. materialClassify: '',
  272. materialClassifyName: '',
  273. materialClassifyOne: '',
  274. materialClassifyOneName: '',
  275. materialClassifyTwoName: '',
  276. materialClassifyThreeName: '',
  277. materialClassifyFourName: '',
  278. material: '',
  279. materialCode: '',
  280. materialName: '',
  281. manufacturer: '',
  282. org: '',
  283. orgName: '',
  284. orderPersonal: '',
  285. orderPersonalName: '',
  286. orderDept: '',
  287. orderDeptName: '',
  288. buyer: '',
  289. buyerName: '',
  290. puDept: '',
  291. puDeptName: '',
  292. sendStatus: '',
  293. remark: ''
  294. },
  295. options: [{
  296. value: 0, label: '仓库1'
  297. }],
  298. referCondition: {
  299. type: '',
  300. isPage: true,
  301. title: ''
  302. },
  303. organizationsOptions: [],
  304. staffOptions: [],
  305. staff2Options: [],
  306. basicRules: {}
  307. }
  308. },
  309. mounted() {
  310. if(this.pageStu == 'check') {
  311. console.log('数据', this.row)
  312. this.getDetails(this.row)
  313. } else if(this.pageStu == 'edit') {
  314. this.getDetails(this.row)
  315. }
  316. },
  317. methods: {
  318. save() {
  319. if(this.pageStu == 'add') {
  320. addDivision(this.basicForm).then(res => {
  321. if (res.code === 200) {
  322. this.$modal.msgSuccess("保存成功");
  323. this.back()
  324. }
  325. })
  326. } else if(this.pageStu == 'edit') {
  327. editDivision(this.basicForm).then(res => {
  328. this.$modal.msgSuccess("编辑成功");
  329. this.back()
  330. })
  331. }
  332. },
  333. submit() {},
  334. back() {
  335. this.$emit('jugislist', true)
  336. let queryParams = {
  337. pageNum: 1,
  338. pageSize: 5
  339. }
  340. this.$emit('refresh', queryParams)
  341. },
  342. // 如果需要回显则调用详情接口
  343. getDetails(row) {
  344. getDivisions(row.id).then(res => {
  345. if (res.code === 200) {
  346. this.basicForm = res.data
  347. if (this.basicForm.org) { this.reBackRefer('ORG_PARAM', this.basicForm.org) }
  348. if (this.basicForm.orderPersonal) { this.reBackRefer('CONTACTS_PARAM', this.basicForm.orderPersonal, '订单员') }
  349. if (this.basicForm.buyer) { this.reBackRefer('CONTACTS_PARAM', this.basicForm.buyer, '采购员') }
  350. // this.getOrgDetails(res.data.org)
  351. // this.getStaffDetails(res.data.orderPersonal)
  352. // this.getStaffDetails2(res.data.buyer)
  353. }
  354. })
  355. },
  356. // 选择物料分类
  357. acceptFourClass(selections) {
  358. console.log('收到的四级分类',selections)
  359. this.basicForm.materialClassify = selections.code
  360. this.basicForm.materialClassifyName = selections.materialType
  361. this.getTreeDetails(selections.id)
  362. },
  363. // 物料分类显示列表
  364. chooseFourClass() {
  365. this.$refs.fourClass.init()
  366. },
  367. // 选择物料分类后需要根据id再次查询一下123级分类
  368. getTreeDetails(id) {
  369. getDetail(id).then(res => {
  370. if (res.code === 200) {
  371. this.basicForm.materialClassifyOneName = res.data.oneClass
  372. this.basicForm.materialClassifyTwoName = res.data.twoClass
  373. this.basicForm.materialClassifyThreeName = res.data.threeClass
  374. this.basicForm.materialClassifyFourName = res.data.fourClass
  375. }
  376. })
  377. },
  378. selectionsToInput (selections) {
  379. console.log('父组件拿到的:', selections)
  380. this.selectData = selections
  381. this.basicForm.material = selections[0].id
  382. this.basicForm.materialCode = selections[0].code
  383. this.basicForm.materialName = selections[0].name
  384. },
  385. // 显示物料编码列表
  386. test01() {
  387. console.log('测试点击')
  388. this.$refs.contractSelect.init()
  389. },
  390. // 选择默认采购组织
  391. chooseRefer(type, isPage, title) {
  392. this.referCondition.type = type
  393. this.referCondition.isPage = isPage
  394. this.referCondition.title = title
  395. this.$refs.refer.init(this.referCondition)
  396. },
  397. selectionsRefer(selection) {
  398. if (this.referCondition.title == '选择所属组织') {
  399. this.organizationsOptions = selection
  400. this.basicForm.org = selection[0].id
  401. this.basicForm.orgName = selection[0].name
  402. }
  403. if (this.referCondition.title == '订单员') {
  404. this.staffOptions = selection
  405. this.basicForm.orderPersonal = selection[0].code
  406. this.basicForm.orderPersonalName = selection[0].name
  407. }
  408. if (this.referCondition.title == '采购员') {
  409. this.staff2Options = selection
  410. this.basicForm.buyer = selection[0].code
  411. this.basicForm.buyerName = selection[0].name
  412. }
  413. },
  414. // 回显参照框
  415. reBackRefer(type, id, title) {
  416. getRefer({ type: type, id: id }).then(res => {
  417. if (type == 'ORG_PARAM') {
  418. this.organizationsOptions = res.rows
  419. }
  420. if (type == 'CONTACTS_PARAM' && title == '订单员') {
  421. this.staffOptions = res.rows
  422. }
  423. if (type == 'CONTACTS_PARAM' && title == '采购员') {
  424. this.staff2Options = res.rows
  425. }
  426. })
  427. },
  428. // 选择订单员
  429. // acceptStaff (selections) {
  430. // this.staffOptions = selections
  431. // this.basicForm.orderPersonal = selections[0].code
  432. // this.basicForm.orderPersonalName = selections[0].name
  433. // this.getStaffDetails(selections[0].id)
  434. // },
  435. // // 订单员显示列表
  436. // chooseStaff () {
  437. // this.$refs.staffs.blur()
  438. // this.$refs.staff.init()
  439. // },
  440. // // 订单员回显
  441. // getStaffDetails(id) {
  442. // getStaff({id:id}).then(res => {
  443. // console.log('订单员', res)
  444. // if (res.code === 200 ) {
  445. // this.staffOptions = res.data.tableBody
  446. // }
  447. // })
  448. // },
  449. // 选择采购员
  450. acceptStaff2 (selections) {
  451. this.staff2Options = selections
  452. this.basicForm.buyer = selections[0].code
  453. this.basicForm.buyerName = selections[0].name
  454. this.getStaffDetails2(selections[0].id)
  455. },
  456. // 采购员显示列表
  457. chooseStaff2 () {
  458. this.$refs.staffs2.blur()
  459. this.$refs.staff2.init()
  460. },
  461. // 采购员回显
  462. getStaffDetails2(id) {
  463. getStaff({id:id}).then(res => {
  464. console.log('采购员', res)
  465. if (res.code === 200 ) {
  466. this.staff2Options = res.data.tableBody
  467. }
  468. })
  469. },
  470. }
  471. }
  472. </script>
  473. <style lang="scss" scoped>
  474. .btn_group {
  475. width: 100%;
  476. margin: 20px 0;
  477. display: flex;
  478. justify-content: center;
  479. }
  480. </style>