index.vue 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375
  1. <template>
  2. <div>
  3. <by-bill ref="bill" :propConfig="config" @search="search" @onSmt="onSmt" @onDelete="onDelete" @onRefresh="resert"
  4. @resert="resert" @detail="openEdit" @onSave="onSave" @clickTab="clickTab" @onChangeRow="onChangeRow"
  5. @pagination="pagination" @onReturnSmt="onReturnSmt2" @getSupplierModal="getSupplierModal">
  6. </by-bill>
  7. <!-- 选择物料 -->
  8. <productModal ref="product" :mulit="true" @confirm="confirmProduct" />
  9. </div>
  10. </template>
  11. <script lang="ts">
  12. import { Component, Prop, Vue, Watch } from "vue-property-decorator";
  13. import api from "@/api/order";
  14. import productModal from "../orderTask/components/productModal.vue";
  15. import BusinessType from "../warehousing/components/businessType.vue";
  16. import towInOne from "../warehousing/components/towInOne.vue";
  17. @Component({ components: { productModal } })
  18. export default class OrderTask extends Vue {
  19. // 左边
  20. tabType : any = 'all';
  21. isAdd : any = false;
  22. baseInfo : any = {};
  23. isSubmit : any = false
  24. isChange : any = false
  25. dataId : any = ''
  26. // 右边
  27. supplierInfo : any = {} // 机构信息
  28. businessType : any = '' // 业务类型
  29. tableData : any = []
  30. timeNum = 0;
  31. timer : any = null
  32. config : any = {
  33. attr: {
  34. activeName: 'all'
  35. },
  36. // 引单
  37. source: [
  38. {
  39. title: '销售订单',
  40. search: {
  41. attr: {
  42. size: 'mini',
  43. },
  44. columns: [
  45. [
  46. {
  47. span: 6,
  48. label: '单据编号',
  49. prop: 'orderNumber',
  50. component: 'by-input',
  51. compConfig: {
  52. attr: {
  53. placeholder: '请输入单据编号',
  54. clearable: true
  55. }
  56. }
  57. },
  58. ],
  59. ]
  60. },
  61. tool: {
  62. tools: {
  63. search: true,
  64. refresh: true
  65. },
  66. customTools: [
  67. {
  68. name: '引单', icon: 'el-icon-bottom', audit: [''], event: {
  69. click: () => {
  70. (this as any).citationOrder()
  71. }
  72. }
  73. },
  74. ]
  75. },
  76. table: {
  77. attr: {
  78. height: 600,
  79. size: 'mini',
  80. seq: true,
  81. align: 'left',
  82. radio: true,
  83. triggerRowCheck: 'row'
  84. },
  85. columns: [
  86. {
  87. width: 144,
  88. title: '单据编号',
  89. field: 'orderNumber',
  90. },
  91. {
  92. width: 120,
  93. title: '收货人',
  94. field: 'consignee',
  95. },
  96. {
  97. width: 120,
  98. title: '联系方式',
  99. field: 'phone',
  100. },
  101. {
  102. width: 150,
  103. title: '计划交货时间',
  104. field: 'planDeliveryData',
  105. },
  106. {
  107. width: 150,
  108. title: '确定交货时间',
  109. field: 'affirmDeliveryData',
  110. },
  111. {
  112. width: 150,
  113. title: '交货地点',
  114. field: 'address',
  115. }
  116. ]
  117. }
  118. },
  119. ],
  120. // 单据
  121. bill: {
  122. tool: {
  123. tools: {
  124. save: true,
  125. }
  126. },
  127. log: {
  128. request: {
  129. url: '/supply/supplyOutOrderOperateLog/page',
  130. method: 'GET'
  131. }
  132. },
  133. form: {
  134. attr: {
  135. size: 'medium',
  136. readonly: false,
  137. rules: {
  138. operator: [{
  139. required: true, message: '请输入经办人', trigger: 'blur'
  140. }],
  141. }
  142. },
  143. columns: [
  144. [
  145. {
  146. span: 8,
  147. label: '单据编号',
  148. prop: 'outOrderNo',
  149. component: 'by-input',
  150. compConfig: {
  151. attr: {
  152. readonly: true
  153. },
  154. }
  155. },
  156. {
  157. span: 8,
  158. label: '经办人',
  159. prop: 'operator',
  160. component: 'by-input',
  161. },
  162. {
  163. span: 8,
  164. label: '收货人',
  165. prop: 'receive',
  166. component: 'by-input',
  167. },
  168. {
  169. span: 8,
  170. label: '收获地址',
  171. prop: 'receiveAddress',
  172. component: 'by-input',
  173. },
  174. {
  175. span: 8,
  176. label: '联系方式',
  177. prop: 'receivePhone',
  178. component: 'by-input',
  179. },
  180. {
  181. span: 8,
  182. label: 'WMS编号',
  183. prop: 'wmsId',
  184. component: 'by-input',
  185. },
  186. {
  187. span: 8,
  188. label: '业务类型',
  189. prop: 'businessType',
  190. component: BusinessType,
  191. },
  192. ],
  193. [
  194. {
  195. span: 28,
  196. label: '备注',
  197. slot: true,
  198. prop: 'remark',
  199. component: 'by-input',
  200. compConfig: {
  201. attr: {
  202. placeholder: '请输入备注',
  203. type: 'textarea'
  204. },
  205. }
  206. },
  207. ]
  208. ]
  209. },
  210. tableConfig: [
  211. {
  212. table: {
  213. attr: {
  214. size: 'mini',
  215. height: 500,
  216. align: 'left',
  217. readonly: true,
  218. },
  219. columns:
  220. [{
  221. width: 278,
  222. title: '物料名称',
  223. field: 'materialName',
  224. },
  225. {
  226. width: 200,
  227. title: '仓库,仓位',
  228. field: 'towInOne',
  229. component: towInOne,
  230. compConfig: {
  231. isSelect: true
  232. }
  233. },
  234. {
  235. width: 100,
  236. title: '单位',
  237. field: 'unit',
  238. },
  239. {
  240. width: 100,
  241. title: '库存',
  242. field: 'inventory',
  243. },
  244. {
  245. width: 100,
  246. title: '数量',
  247. field: 'number',
  248. component: 'by-input',
  249. compConfig: {
  250. attr: {
  251. size: 'mini',
  252. type: 'number',
  253. defaultValue: 1,
  254. },
  255. }
  256. },
  257. {
  258. width: 100,
  259. title: '应出数量',
  260. field: 'deliveryNumber',
  261. },
  262. {
  263. width: 110,
  264. title: '出库数量',
  265. field: 'outNumber',
  266. },
  267. {
  268. width: 100,
  269. title: '单价',
  270. field: 'unitPrice',
  271. component: 'by-input',
  272. compConfig: {
  273. attr: {
  274. size: 'mini',
  275. type: 'number',
  276. },
  277. }
  278. },
  279. {
  280. width: 100,
  281. title: '优惠金额',
  282. field: 'prePrice',
  283. },
  284. {
  285. width: 100,
  286. title: '合计金额',
  287. field: 'totalPrice',
  288. },
  289. {
  290. width: 90,
  291. title: '操作',
  292. action: true,
  293. plugins: [{
  294. icon: 'el-icon-delete',
  295. name: '删除',
  296. audit: '',
  297. event: {
  298. click: (item : any) => {
  299. (this as any).changeTable(item)
  300. }
  301. }
  302. }]
  303. },
  304. ]
  305. }
  306. }
  307. ]
  308. },
  309. // 已提交
  310. smt: {
  311. search: {
  312. attr: {
  313. size: 'mini',
  314. },
  315. columns: [
  316. [
  317. {
  318. span: 6,
  319. label: '单据编号',
  320. prop: 'outOrderNo',
  321. component: 'by-input',
  322. compConfig: {
  323. attr: {
  324. placeholder: '请输入单据编号',
  325. clearable: true
  326. }
  327. }
  328. },
  329. {
  330. span: 6,
  331. label: '财务系统单据',
  332. prop: 'financeOrderId',
  333. component: 'by-input',
  334. compConfig: {
  335. attr: {
  336. placeholder: '请输入财务系统单据',
  337. clearable: true
  338. },
  339. },
  340. },
  341. ],
  342. ]
  343. },
  344. tool: {
  345. tools: {
  346. search: true,
  347. refresh: true
  348. }
  349. },
  350. table: {
  351. attr: {
  352. height: 620,
  353. size: 'mini',
  354. seq: true,
  355. align: 'left',
  356. checkbox: true
  357. },
  358. columns: [
  359. {
  360. width: 150,
  361. title: '单据编号',
  362. field: 'outOrderNo',
  363. isDetail: true,
  364. fixed: 'left'
  365. },
  366. {
  367. width: 150,
  368. title: '财务系统单据',
  369. field: 'financeOrderId',
  370. },
  371. {
  372. width: 150,
  373. title: 'WMS编号',
  374. field: 'wmsId',
  375. },
  376. {
  377. width: 120,
  378. title: '经办人',
  379. field: 'operator',
  380. },
  381. {
  382. width: 120,
  383. title: '收货人',
  384. field: 'receive',
  385. },
  386. {
  387. width: 120,
  388. title: '收货地址',
  389. field: 'receiveAddress',
  390. },
  391. {
  392. width: 120,
  393. title: '联系方式',
  394. field: 'receivePhone',
  395. },
  396. {
  397. width: 120,
  398. title: '业务类型',
  399. field: 'businessType',
  400. },
  401. {
  402. width: 110,
  403. title: '操作',
  404. action: true,
  405. plugins: [{
  406. // icon: 'el-icon-edit',
  407. name: '查看',
  408. audit: '',
  409. event: {
  410. click: (e : any) => {
  411. (this as any).setReadonly(e)
  412. }
  413. }
  414. }, {
  415. name: '反提交',
  416. event: {
  417. click: (item : any) => (this as any).onReturnSmt(item)
  418. }
  419. }]
  420. }
  421. ]
  422. }
  423. },
  424. // 草稿箱
  425. draftsBox: {
  426. search: {
  427. attr: {
  428. size: 'mini',
  429. },
  430. columns: [
  431. [
  432. {
  433. span: 6,
  434. label: '单据编号',
  435. prop: 'outOrderNo',
  436. component: 'by-input',
  437. compConfig: {
  438. attr: {
  439. placeholder: '请输入单据编号',
  440. clearable: true
  441. }
  442. }
  443. },
  444. {
  445. span: 6,
  446. label: '财务系统单据',
  447. prop: 'financeOrderId',
  448. component: 'by-input',
  449. compConfig: {
  450. attr: {
  451. placeholder: '请输入财务系统单据',
  452. clearable: true
  453. },
  454. },
  455. },
  456. ],
  457. ]
  458. },
  459. tool: {
  460. tools: {
  461. smt: true,
  462. delete: true,
  463. search: true,
  464. refresh: true
  465. }
  466. },
  467. table: {
  468. attr: {
  469. height: 620,
  470. size: 'mini',
  471. seq: true,
  472. align: 'left',
  473. checkbox: true
  474. },
  475. columns: [
  476. {
  477. width: 150,
  478. title: '单据编号',
  479. field: 'outOrderNo',
  480. isDetail: true,
  481. fixed: 'left'
  482. },
  483. {
  484. width: 150,
  485. title: '财务系统单据',
  486. field: 'financeOrderId',
  487. },
  488. {
  489. width: 150,
  490. title: 'WMS编号',
  491. field: 'wmsId',
  492. },
  493. {
  494. width: 120,
  495. title: '经办人',
  496. field: 'operator',
  497. },
  498. {
  499. width: 120,
  500. title: '收货人',
  501. field: 'receive',
  502. },
  503. {
  504. width: 120,
  505. title: '收货地址',
  506. field: 'receiveAddress',
  507. },
  508. {
  509. width: 120,
  510. title: '联系方式',
  511. field: 'receivePhone',
  512. },
  513. {
  514. width: 120,
  515. title: '业务类型',
  516. field: 'businessType',
  517. },
  518. {
  519. width: 110,
  520. title: '操作',
  521. action: true,
  522. plugins: [{
  523. icon: 'el-icon-edit',
  524. name: '编辑',
  525. audit: '',
  526. event: {
  527. click: (e : any) => {
  528. (this as any).openEdit(e)
  529. }
  530. }
  531. }, {
  532. name: '删除',
  533. event: {
  534. click: (item : any) => (this as any).doDelete2(item)
  535. }
  536. }]
  537. }
  538. ]
  539. }
  540. },
  541. // 综合
  542. all: {
  543. search: {
  544. attr: {
  545. size: 'mini',
  546. },
  547. columns: [
  548. [
  549. {
  550. span: 6,
  551. label: '单据编号',
  552. prop: 'outOrderNo',
  553. component: 'by-input',
  554. compConfig: {
  555. attr: {
  556. placeholder: '请输入单据编号',
  557. clearable: true
  558. }
  559. }
  560. },
  561. {
  562. span: 6,
  563. label: '财务系统单据',
  564. prop: 'financeOrderId',
  565. component: 'by-input',
  566. compConfig: {
  567. attr: {
  568. placeholder: '请输入财务系统单据',
  569. clearable: true
  570. },
  571. },
  572. },
  573. ],
  574. ]
  575. },
  576. tool: {
  577. tools: {
  578. search: true,
  579. refresh: true
  580. },
  581. customTools: [
  582. {
  583. name: '出库', icon: 'el-icon-top', audit: [''], event: {
  584. click: () => {
  585. (this as any).outbound()
  586. }
  587. }
  588. },
  589. {
  590. name: '删除', icon: 'el-icon-delete', audit: [''], event: {
  591. click: () => {
  592. (this as any).onDelete('all')
  593. }
  594. }
  595. }
  596. ]
  597. },
  598. table: {
  599. attr: {
  600. height: 620,
  601. size: 'mini',
  602. seq: true,
  603. align: 'left',
  604. checkbox: true
  605. },
  606. columns: [
  607. {
  608. width: 150,
  609. title: '单据编号',
  610. field: 'outOrderNo',
  611. isDetail: true,
  612. fixed: 'left'
  613. },
  614. {
  615. width: 150,
  616. title: '财务系统单据',
  617. field: 'financeOrderId',
  618. },
  619. {
  620. width: 150,
  621. title: 'WMS编号',
  622. field: 'wmsId',
  623. },
  624. {
  625. width: 120,
  626. title: '经办人',
  627. field: 'operator',
  628. },
  629. {
  630. width: 120,
  631. title: '收货人',
  632. field: 'receive',
  633. },
  634. {
  635. width: 120,
  636. title: '收货地址',
  637. field: 'receiveAddress',
  638. },
  639. {
  640. width: 120,
  641. title: '联系方式',
  642. field: 'receivePhone',
  643. },
  644. {
  645. width: 120,
  646. title: '业务类型',
  647. field: 'businessType',
  648. },
  649. {
  650. width: 120,
  651. title: '操作',
  652. action: true,
  653. plugins: [{
  654. name: '查看',
  655. audit: '',
  656. event: {
  657. click: (e : any) => {
  658. (this as any).openEdit(e)
  659. }
  660. }
  661. }, {
  662. name: '删除',
  663. event: {
  664. click: (item : any) => (this as any).doDelete2(item)
  665. }
  666. }]
  667. }
  668. ]
  669. }
  670. },
  671. // 回收站
  672. recycleBin: {
  673. search: {
  674. attr: {
  675. size: 'mini',
  676. },
  677. columns: [
  678. [
  679. {
  680. span: 6,
  681. label: '单据编号',
  682. prop: 'outOrderNo',
  683. component: 'by-input',
  684. compConfig: {
  685. attr: {
  686. placeholder: '请输入单据编号',
  687. clearable: true
  688. }
  689. }
  690. },
  691. {
  692. span: 6,
  693. label: '财务系统单据',
  694. prop: 'financeOrderId',
  695. component: 'by-input',
  696. compConfig: {
  697. attr: {
  698. placeholder: '请输入财务系统单据',
  699. clearable: true
  700. },
  701. },
  702. },
  703. ],
  704. ]
  705. },
  706. tool: {
  707. tools: {
  708. search: true,
  709. refresh: true
  710. }
  711. },
  712. table: {
  713. attr: {
  714. height: 620,
  715. size: 'mini',
  716. seq: true,
  717. align: 'left',
  718. checkbox: true
  719. },
  720. columns: [
  721. {
  722. width: 150,
  723. title: '单据编号',
  724. field: 'outOrderNo',
  725. isDetail: true,
  726. fixed: 'left'
  727. },
  728. {
  729. width: 150,
  730. title: '财务系统单据',
  731. field: 'financeOrderId',
  732. },
  733. {
  734. width: 150,
  735. title: 'WMS编号',
  736. field: 'wmsId',
  737. },
  738. {
  739. width: 120,
  740. title: '经办人',
  741. field: 'operator',
  742. },
  743. {
  744. width: 120,
  745. title: '收货人',
  746. field: 'receive',
  747. },
  748. {
  749. width: 120,
  750. title: '收货地址',
  751. field: 'receiveAddress',
  752. },
  753. {
  754. width: 120,
  755. title: '联系方式',
  756. field: 'receivePhone',
  757. },
  758. {
  759. width: 120,
  760. title: '业务类型',
  761. field: 'businessType',
  762. },
  763. {
  764. width: 110,
  765. title: '操作',
  766. action: true,
  767. plugins: [{
  768. name: '查看',
  769. audit: '',
  770. event: {
  771. click: (e : any) => {
  772. (this as any).openEdit(e)
  773. }
  774. }
  775. }]
  776. }
  777. ]
  778. }
  779. }
  780. }
  781. created() {
  782. this.timer = setInterval(() => {
  783. this.getDataList()
  784. }, 500)
  785. }
  786. // 引单
  787. citationOrder(e : any) {
  788. let parentData : any = (this as any).$refs.bill.getSourceTableSelectData(0);
  789. if (parentData.length <= 0) return this.$message.warning('请选择引单数据');
  790. let loading = this.$loading({ target: '.main-container' });
  791. api.single({ id: parentData[0].id }, 'supplyPurchaseOrder').then((res : any) => {
  792. if (res.code === 200) {
  793. parentData = res.data ? [res.data] : parentData;
  794. parentData = parentData.map((item : any, i : any) => {
  795. item.receiveAddress = item.address
  796. item.receive = item.consignee
  797. item.receivePhone = item.phone
  798. item.outOrderNo = item.orderNumber
  799. const { ...newData } = item
  800. return newData
  801. })
  802. let billConfig = (this as any).$lodash.cloneDeep(this.config.bill);
  803. parentData[0].suborderList.map((v : any) => {
  804. v.deliveryNumber = v.number - v.outNumber;
  805. if (v.deliveryNumber < v.number) v.number = v.deliveryNumber;
  806. });
  807. this.tableData = parentData[0];
  808. billConfig.tool.tools = { save: true, smt: true };
  809. // console.log('this.tableData ==> ', this.tableData);
  810. // billConfig.tool.tools = { save: true };
  811. this.isAdd = true;
  812. (this.$refs.bill as any).showTab = 'bill';
  813. loading.close();
  814. setTimeout(() => {
  815. (this.$refs.bill as any).setBillConfig(billConfig);
  816. (this.$refs.bill as any).setBillFormValue(parentData[0]); // 设置单据表单数据
  817. (this.$refs.bill as any).setBillTableValue(parentData[0].suborderList, 0);// 设置第1张单据表格数据
  818. }, 0)
  819. }
  820. })
  821. }
  822. // 获取机构数据
  823. getSupplierModal(e : any) {
  824. this.supplierInfo = e;
  825. }
  826. // 监听表格数据变化
  827. onChangeRow(e : any) {
  828. this.isChange = true;
  829. this.isSubmit = false;
  830. e.prePrice = e.prePrice ? e.prePrice : 0;
  831. e.realityPrice = parseFloat((e.number * e.unitPrice).toFixed(2));
  832. e.totalPrice = e.realityPrice - e.prePrice;
  833. }
  834. // 保存
  835. onSave(e : any) {
  836. console.log('保存 ==>', this.tabType);
  837. (this as any).$refs.bill.$refs.billForm.validate().then(() => {
  838. let query = (this.$refs.bill as any).getBillFormValue(); // 获取单据数据
  839. console.log(query);
  840. // 子表数据
  841. // query.suborderList = this.tableData;
  842. query.purchaseOrderId = query.id;
  843. query.suborderList = (this.$refs.bill as any).getBillTableData(0);
  844. if (query.suborderList.length > 0) {
  845. for (let v of query.suborderList) {
  846. if (!v.unitPrice || v.unitPrice <= 0) return this.$message.warning('请输入正确物料单价');
  847. if (v.deliveryNumber < v.number) return this.$message.warning('数量不能大于应出数量');
  848. if (v.number > v.inventory) return this.$message.warning('出库数据不能大于库存数量');
  849. v.taskOrderId = query.id;
  850. v.purchaseSuborderId = v.id;
  851. }
  852. };
  853. // 表格删除
  854. query.suborderList.map((v : any, i : any) => {
  855. if (v.isDeleted === 1 && !v.id) {
  856. query.suborderList.splice(i, 1)
  857. }
  858. });
  859. if (query.deliveryData) query.deliveryData = query.deliveryData + ' 00:00:00';
  860. console.log('出库参数query ==> ', query);
  861. if (this.isAdd) {
  862. query.suborderList.map((v : any) => {
  863. delete v.id;
  864. });
  865. delete query.id;
  866. api.outbound(query, 'supplyOutOrder').then((res : any) => {
  867. if (res.code === 200) {
  868. this.isAdd = false;
  869. this.isChange = false;
  870. this.isSubmit = true;
  871. this.$message.success('保存成功');
  872. this.dataId = res.data;
  873. } else this.$message.error(res.msg);
  874. })
  875. } else if (this.tabType === 'all' || this.tabType === 'draftsBox') {
  876. if (this.tabType === 'draftsBox') query.submitState = 0;
  877. console.log('保存 ==>', query);
  878. api.updateList(query, 'supplyOutOrder').then((res : any) => {
  879. if (res.code === 200) {
  880. this.$message.success('保存成功');
  881. this.isChange = false;
  882. this.isSubmit = true;
  883. } else this.$message.error(res.msg);
  884. })
  885. };
  886. })
  887. }
  888. // 出库打开引单
  889. outbound() {
  890. this.clickTab('source');
  891. (this.$refs.bill as any).showTab = 'source';
  892. }
  893. // 打开编辑
  894. openEdit(e : any) {
  895. console.log('编辑this.tabType ==>', this.tabType);
  896. console.log('编辑 ==>', e);
  897. e = e.row ? e.row : e;
  898. api.single({ id: e.id }, 'supplyOutOrder').then((res : any) => {
  899. if (res.code === 200) {
  900. let parentData = res.data ? res.data : e;
  901. this.baseInfo = parentData;
  902. if (this.tabType === 'all' || this.tabType === 'draftsBox') {
  903. let loading = this.$loading({ target: '.main-container' });
  904. if (parentData.submitState === 1) {
  905. loading.close();
  906. return this.setReadonly(parentData)
  907. }
  908. let billConfig = (this as any).$lodash.cloneDeep(this.config.bill);
  909. if (billConfig.tableConfig[0].table.columns.at(-1).title != '操作') {
  910. billConfig.tableConfig[0].table.columns.push({
  911. width: 90,
  912. title: '操作',
  913. action: true,
  914. plugins: [{
  915. icon: 'el-icon-delete',
  916. name: '删除',
  917. audit: '',
  918. event: {
  919. click: (item : any) => {
  920. (this as any).changeTable(item)
  921. }
  922. }
  923. }]
  924. })
  925. };
  926. billConfig.form.attr.readonly = false; // 设置只读
  927. billConfig.tool.tools = { save: true, };
  928. if (this.tabType === 'draftsBox' || parentData.submitState === 0) billConfig.tool.tools = { save: true, smt: true };
  929. let data : any = parentData.suborderList;
  930. let array : any = [];
  931. data.map((v : any) => {
  932. v.towInOne = v.storehouseName + ',' + v.storingLocationName; // 仓库仓位
  933. array.push({
  934. storidId: v.storingLocationId,
  935. skuid: v.materialSku,
  936. })
  937. });
  938. console.log('array', array);
  939. // 查库存
  940. api.getInventoryByStoridsAndSkuids(array).then((res : any) => {
  941. if (res.code === 200) {
  942. console.log(res);
  943. let newData : any = [];
  944. res.data.map((v : any, i : any) => {
  945. newData.push(Object.assign(data[i], v))
  946. })
  947. console.log('newData', newData);
  948. this.tableData = newData;
  949. (this.$refs.bill as any).setBillConfig(billConfig);
  950. (this.$refs.bill as any).setBillFormValue(parentData);// 设置单据表单数据
  951. (this.$refs.bill as any).setBillTableValue(newData, 0);// 设置第1张单据表格数据
  952. this.isAdd = false;
  953. this.dataId = '';
  954. (this.$refs.bill as any).showTab = 'bill';
  955. loading.close();
  956. }
  957. })
  958. } else {
  959. this.setReadonly(parentData);
  960. };
  961. }
  962. })
  963. }
  964. // 设置只读
  965. setReadonly(e : any) {
  966. let loading = this.$loading({ target: '.main-container' });
  967. let readonly = (this as any).$lodash.cloneDeep(this.config.bill);
  968. readonly.form.attr.readonly = true; // 设置只读
  969. readonly.tool.tools = {};
  970. if (this.tabType != 'recycleBin') {
  971. if (e.submitState === 1) readonly.tool.tools = { returnSmt: true };
  972. }
  973. readonly.tableConfig[0].table.columns = readonly.tableConfig[0].table.columns.filter((v : any) => v.title != '操作');
  974. let data = e.suborderList;
  975. let array : any = [];
  976. data.map((v : any) => {
  977. v.towInOne = v.storehouseName + ',' + v.storingLocationName; // 仓库仓位
  978. array.push({
  979. storidId: v.storingLocationId,
  980. skuid: v.materialSku,
  981. })
  982. });
  983. console.log('array', array);
  984. // 查库存
  985. api.getInventoryByStoridsAndSkuids(array).then((res : any) => {
  986. if (res.code === 200) {
  987. let newData : any = []
  988. res.data.map((v : any, i : any) => {
  989. newData.push(Object.assign(data[i], v))
  990. })
  991. console.log('newData', newData);
  992. this.tableData = newData;
  993. (this.$refs.bill as any).setBillConfig(readonly);
  994. (this.$refs.bill as any).setBillFormValue(e);// 设置单据表单数据
  995. (this.$refs.bill as any).setBillTableValue(newData, 0);// 设置第1张单据表格数据
  996. this.isAdd = false;
  997. (this.$refs.bill as any).showTab = 'bill';
  998. loading.close();
  999. }
  1000. })
  1001. }
  1002. // 工具栏提交
  1003. onSmt(e : any) {
  1004. if (e === 'draftsBox') {
  1005. let selectData = (this.$refs.bill as any).getTableSelectData('draftsBox'); // 获取表格选中数据
  1006. if (selectData.length <= 0) return this.$message.warning('请选择提交数据');
  1007. if (selectData.length > 1) return this.$message.warning('只能提交一条数据');
  1008. this.$confirm('确定提交吗!', '注意', {
  1009. confirmButtonText: '确定',
  1010. cancelButtonText: '取消',
  1011. type: 'warning',
  1012. center: true
  1013. }).then(() => {
  1014. api.submitTo({ id: selectData[0].id }, 'supplyOutOrder').then((res : any) => {
  1015. if (res.code === 200) {
  1016. this.$message.success('提交成功');
  1017. this.clickTab('draftsBox');
  1018. } else this.$message.error(res.msg)
  1019. })
  1020. }).catch(() => this.$message.info('已取消提交'));
  1021. } else {
  1022. if (this.isAdd) return this.$message.warning('新增数据必须先保存才能提交');
  1023. console.log('isChange ==> ', this.isChange);
  1024. console.log('isSubmit ==> ', this.isSubmit);
  1025. if (this.isSubmit) {
  1026. this.$confirm('确定提交吗!', '注意', {
  1027. confirmButtonText: '确定',
  1028. cancelButtonText: '取消',
  1029. type: 'warning',
  1030. center: true
  1031. }).then(() => {
  1032. api.submitTo({ id: this.baseInfo.id }, 'supplyOutOrder').then((res : any) => {
  1033. if (res.code === 200) {
  1034. this.$message.success('提交成功');
  1035. this.clickTab(this.tabType);
  1036. this.isSubmit = false;
  1037. (this.$refs.bill as any).showTab = this.tabType;
  1038. } else this.$message.error(res.msg)
  1039. })
  1040. }).catch(() => this.$message.info('已取消提交'));
  1041. } else {
  1042. // 表单旧数据
  1043. let oldbillForm : any = (this as any).$lodash.cloneDeep(this.baseInfo);
  1044. if (oldbillForm.suborderList) delete oldbillForm.suborderList;
  1045. oldbillForm = JSON.stringify(oldbillForm);
  1046. // 表单新数据
  1047. let newBillForm : any = (this as any).$refs.bill.getBillFormValue();
  1048. if (newBillForm.suborderList) delete newBillForm.suborderList;
  1049. newBillForm = JSON.stringify(newBillForm);
  1050. // 表格旧数据
  1051. this.baseInfo.suborderList.map((v : any) => {
  1052. if (v._X_ROW_KEY) delete v._X_ROW_KEY;
  1053. });
  1054. let oldData : any = JSON.stringify(this.baseInfo.suborderList);
  1055. // 表格新数据
  1056. let newData : any = JSON.stringify((this as any).$refs.bill.getBillTableData(0));
  1057. // 数据有变进保存
  1058. if (this.isChange || oldbillForm != newBillForm || oldData != newData) {
  1059. return this.$message.warning('数据变更必须先保存再提交');
  1060. } else {
  1061. this.$confirm('确定提交吗!', '注意', {
  1062. confirmButtonText: '确定',
  1063. cancelButtonText: '取消',
  1064. type: 'warning',
  1065. center: true
  1066. }).then(() => {
  1067. let id = this.dataId ? this.dataId : this.baseInfo.id;
  1068. api.submitTo({ id: id }, 'supplyOutOrder').then((res : any) => {
  1069. if (res.code === 200) {
  1070. this.$message.success('提交成功');
  1071. this.clickTab(this.tabType);
  1072. this.dataId = '';
  1073. (this.$refs.bill as any).showTab = this.tabType;
  1074. } else this.$message.error(res.msg)
  1075. })
  1076. }).catch(() => this.$message.info('已取消提交'));
  1077. }
  1078. }
  1079. }
  1080. }
  1081. // 操作反提交
  1082. onReturnSmt(e : any) {
  1083. console.log('反提交 ==>', e);
  1084. this.$confirm('确定反提交吗!', '注意', {
  1085. confirmButtonText: '确定',
  1086. cancelButtonText: '取消',
  1087. type: 'warning',
  1088. center: true
  1089. }).then(() => {
  1090. if (this.tabType === 'smt') {
  1091. api.cancelSubmission({ id: e.id }, 'supplyOutOrder').then((res : any) => {
  1092. if (res.code === 200) {
  1093. this.$message.success('反提交成功');
  1094. this.clickTab(this.tabType);
  1095. } else this.$message.error(res.msg)
  1096. })
  1097. }
  1098. }).catch(() => this.$message.info('已取消反提交'));
  1099. }
  1100. // 工具栏反提交
  1101. onReturnSmt2() {
  1102. console.log('工具栏反提交 ==>', this.baseInfo);
  1103. this.$confirm('确定反提交吗!', '注意', {
  1104. confirmButtonText: '确定',
  1105. cancelButtonText: '取消',
  1106. type: 'warning',
  1107. center: true
  1108. }).then(() => {
  1109. if (this.tabType === 'smt') {
  1110. api.cancelSubmission({ id: this.baseInfo.id }, 'supplyOutOrder').then((res : any) => {
  1111. if (res.code === 200) {
  1112. this.$message.success('反提交成功');
  1113. this.clickTab(this.tabType);
  1114. (this.$refs.bill as any).showTab = 'smt';
  1115. } else this.$message.error(res.msg)
  1116. })
  1117. }
  1118. }).catch(() => this.$message.info('已取消反提交'));
  1119. }
  1120. // 切换tab栏
  1121. clickTab(e : any) {
  1122. console.log('切换tab ==> ', e);
  1123. this.tabType = e;
  1124. // submitState: 提交状态
  1125. if (e === 'source') {
  1126. this.getCitationList({});
  1127. }
  1128. if (e === 'all') this.getPageList({}, 'all'); // 草稿箱数据
  1129. if (e === 'draftsBox') this.getPageList({ submitState: 0 }, 'draftsBox'); // 草稿箱数据
  1130. if (e === 'smt') this.getPageList({ submitState: 1 }, 'smt'); // 已提交数据
  1131. if (e === 'recycleBin') this.getSelectDeleteList({}); // 回收站数据
  1132. if (e === 'bill') {
  1133. let billConfig = (this as any).$lodash.cloneDeep(this.config.bill);
  1134. billConfig.tool.tools = {};
  1135. billConfig.tool.customTools = [];
  1136. (this.$refs.bill as any).setBillConfig(billConfig);
  1137. }
  1138. }
  1139. // 初始化
  1140. getDataList() {
  1141. if (!this.$refs.bill) {
  1142. if (this.timeNum > 5) {
  1143. clearInterval(this.timer)
  1144. }
  1145. this.timeNum++;
  1146. return
  1147. }
  1148. clearInterval(this.timer)
  1149. this.getPageList({}, 'all'); // 综合数据
  1150. }
  1151. // 获取引单分页数据
  1152. getCitationList(query : any) {
  1153. let loading = this.$loading({ target: '.main-container' });
  1154. api.pageList(query, 'supplyPurchaseOrder').then((res : any) => {
  1155. if (res.code === 200) {
  1156. (this.$refs.bill as any).setSourceTableData(0, res.data.records);
  1157. let page = {
  1158. pageNo: res.data.current, //当前页
  1159. pageSize: res.data.size, //每页条数
  1160. total: res.data.total //总条数
  1161. };
  1162. loading.close();
  1163. (this.$refs.bill as any).setSourcePage(0, page);
  1164. } else this.failHandle(res)
  1165. })
  1166. }
  1167. // 获取分页数据
  1168. getPageList(query : any, type : any) {
  1169. api.pageList(query, 'supplyOutOrder').then((res : any) => {
  1170. if (res.code === 200) {
  1171. (this.$refs.bill as any).setTabTableValue(type, res.data.records);
  1172. let page = {
  1173. pageNo: res.data.current, //当前页
  1174. pageSize: res.data.size, //每页条数
  1175. total: res.data.total //总条数
  1176. };
  1177. (this.$refs.bill as any).setTablePage(type, page)
  1178. } else this.failHandle(res)
  1179. })
  1180. }
  1181. // 回收站数据
  1182. getSelectDeleteList(query : any) {
  1183. api.selectDeleteList(query, 'supplyOutOrder').then((res : any) => {
  1184. if (res.code === 200) {
  1185. (this.$refs.bill as any).setTabTableValue('recycleBin', res.data.records);
  1186. let page = {
  1187. pageNo: res.data.current, //当前页
  1188. pageSize: res.data.size, //每页条数
  1189. total: res.data.total //总条数
  1190. };
  1191. (this.$refs.bill as any).setTablePage('recycleBin', page)
  1192. } else this.failHandle(res)
  1193. });
  1194. }
  1195. // 分页
  1196. pagination(e : any) {
  1197. console.log('分页 ==> ', e);
  1198. let query : any = (this as any).$refs.bill.getSearchValue(e.type);
  1199. query.pageNo = e.page.pageNum;
  1200. query.pageSize = e.page.pageSize;
  1201. let loading = this.$loading({ target: '.main-container' });
  1202. if (e.type === 'recycleBin') {
  1203. api.selectDeleteList(query, 'supplyOutOrder').then((res : any) => {
  1204. if (res.code === 200) {
  1205. (this.$refs.bill as any).setTabTableValue('recycleBin', res.data.records);
  1206. loading.close()
  1207. } else this.failHandle(res)
  1208. });
  1209. } else {
  1210. api.pageList(query, 'supplyOutOrder').then((res : any) => {
  1211. if (res.code === 200) {
  1212. (this.$refs.bill as any).setTabTableValue(e.type, res.data.records);
  1213. loading.close()
  1214. } else this.failHandle(res)
  1215. })
  1216. }
  1217. }
  1218. // 搜索
  1219. search(parames : any) {
  1220. let loading = this.$loading({ target: '.main-container' });
  1221. console.log('搜索 ==> ', parames);
  1222. let query = parames.value;
  1223. if (parames.type === 'source_0') {
  1224. this.getCitationList(query);
  1225. loading.close();
  1226. } else {
  1227. if (parames.type === 'recycleBin') {
  1228. this.getSelectDeleteList(query); // 回收站分页数据
  1229. loading.close();
  1230. } else {
  1231. if (parames.type === 'draftsBox') query.submitState = 0;// 草稿箱数据
  1232. if (parames.type === 'smt') query.submitState = 1; // 已提交数据
  1233. this.getPageList(query, parames.type) // 获取分页数据
  1234. loading.close();
  1235. }
  1236. }
  1237. }
  1238. // 刷新/重置
  1239. resert(e : any) {
  1240. let data : any = e.type ? e.type : e;
  1241. console.log('刷新/重置 ==> ', data);
  1242. if (data === 'source_0') {
  1243. (this as any).$refs.bill.$refs.source_0[0].clearSearch();
  1244. this.getCitationList({});
  1245. } else {
  1246. (this as any).$refs.bill.$refs[data].clearSearch();
  1247. if (data === 'all') this.getPageList({}, 'all'); // 综合数据
  1248. if (data === 'draftsBox') this.getPageList({ submitState: 0 }, 'draftsBox'); // 草稿箱数据
  1249. if (data === 'smt') this.getPageList({ submitState: 1 }, 'smt'); // 已提交数据
  1250. if (data === 'recycleBin') this.getSelectDeleteList({}) // 回收站数据
  1251. }
  1252. }
  1253. // 确定商品新增
  1254. confirmProduct(e : any) {
  1255. let nowData = (this.$refs.bill as any).getBillTableData(0);
  1256. let names = '';
  1257. if (e.length > 0) {
  1258. for (const item of e) {
  1259. let t = true;
  1260. for (const t_item of nowData) {
  1261. if (item.id == t_item.materialSku) {
  1262. if (!names) {
  1263. names = item.skuTitle
  1264. } else {
  1265. names = names + ',' + item.skuTitle
  1266. }
  1267. t = false;
  1268. break;
  1269. }
  1270. }
  1271. if (t) {
  1272. let obj : any = {};
  1273. obj.materialName = item.skuTitle
  1274. obj.materialId = item.materialId
  1275. obj.prePrice = 0
  1276. obj.unitPrice = item.price
  1277. obj.materialSku = item.id
  1278. obj.unit = item.unit
  1279. obj.prePrice = "0"
  1280. obj.isDeleted = 0
  1281. this.tableData.push(obj);
  1282. nowData.push(obj);
  1283. }
  1284. }
  1285. (this.$refs.bill as any).setBillTableValue(nowData, 0);// 设置第1张单据表格数据
  1286. if (names) {
  1287. this.$alert('商品 “' + names + '”已存在!', '提示', {
  1288. confirmButtonText: '确定',
  1289. });
  1290. }
  1291. }
  1292. }
  1293. // 单据表格删除
  1294. changeTable(item : any) {
  1295. this.$confirm('确定删除吗!', '注意', {
  1296. confirmButtonText: '确定',
  1297. cancelButtonText: '取消',
  1298. type: 'warning',
  1299. center: true
  1300. }).then(() => {
  1301. let data = (this.$refs.bill as any).getBillTableData(0);
  1302. let i = -1;
  1303. let j = -1;
  1304. for (const v of data) {
  1305. i++;
  1306. if (v.materialSku == item.materialSku) {
  1307. break
  1308. }
  1309. };
  1310. for (const v of this.tableData) {
  1311. j++;
  1312. if (v.materialSku == item.materialSku && item.isDeleted === 0) {
  1313. break
  1314. }
  1315. };
  1316. this.tableData[j].isDeleted = 1;
  1317. data.splice(i, 1);
  1318. (this.$refs.bill as any).setBillTableValue(data, 0);// 设置第1张单据表格数据
  1319. this.$message.success('删除成功');
  1320. }).catch(() => this.$message.info('已取消删除'));
  1321. }
  1322. // 工具栏删除
  1323. onDelete(e : any) {
  1324. console.log('工具栏删除 ==> ', e);
  1325. let selectData = (this.$refs.bill as any).getTableSelectData(e)
  1326. let ids = '';
  1327. if (selectData.length > 0) {
  1328. selectData.map((v : any) => {
  1329. ids += v.id + ','
  1330. })
  1331. } else return this.$message({ type: 'warning', message: '请选择删除数据' })
  1332. ids = ids.slice(0, ids.length - 1);
  1333. this.$confirm('确定删除吗,此操作不能撤销!', '注意', {
  1334. confirmButtonText: '确定',
  1335. cancelButtonText: '取消',
  1336. type: 'warning',
  1337. center: true
  1338. }).then(() => {
  1339. api.deleteList({ ids: ids }, 'supplyOutOrder').then((res : any) => {
  1340. if (res.code === 200) {
  1341. this.clickTab(this.tabType);
  1342. this.$message.success('删除成功!');
  1343. } else this.failHandle(res)
  1344. })
  1345. }).catch(() => this.$message.info('已取消删除'));
  1346. }
  1347. // 操作删除
  1348. doDelete2(item : any) {
  1349. this.$confirm('确定删除吗,此操作不能撤销!', '注意', {
  1350. confirmButtonText: '确定',
  1351. cancelButtonText: '取消',
  1352. type: 'warning',
  1353. center: true
  1354. }).then(() => {
  1355. api.deleteList({ ids: item.id }, 'supplyOutOrder').then((res : any) => {
  1356. if (res.code === 200) {
  1357. this.clickTab(this.tabType);
  1358. this.$message.success('删除成功!');
  1359. } else this.failHandle(res)
  1360. })
  1361. }).catch(() => this.$message.info('已取消删除'));
  1362. }
  1363. // 运行错误
  1364. failHandle(err : any) {
  1365. let msg = err.msg ? err.msg : '运行错误!';
  1366. this.$message.error(msg)
  1367. }
  1368. }
  1369. </script>