index.vue 29 KB

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