index.vue 35 KB

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