index.vue 31 KB

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