index.vue 32 KB

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