index.vue 31 KB

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