index.vue 28 KB

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