index.vue 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166
  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:mm:ss',
  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. (this.$refs.bill as any).setBillConfig(billConfig);
  975. (this.$refs.bill as any).setBillFormValue(parentData); // 设置单据表单数据
  976. (this.$refs.bill as any).setBillTableValue(parentData.suborderList, 0);// 设置第1张单据表格数据
  977. (this.$refs.bill as any).showTab = 'bill';
  978. loading.close();
  979. } else loading.close();
  980. }).catch(() => loading.close());
  981. }
  982. // 导航切换
  983. clickTab(e : any) {
  984. // submitState: 提交状态
  985. this.tabType = e;
  986. (this.$refs.bill as any).showTab = e;
  987. if (e === 'source') {
  988. this.getCitationList({});
  989. }
  990. if (e === 'all') this.getDataList();
  991. if (e === 'returnOrder') this.getPageList({ status: 2 }, 'returnOrder');
  992. if (e === 'bill') {
  993. let billConfig = (this as any).$lodash.cloneDeep(this.config.bill);
  994. billConfig.tool.tools = {};
  995. billConfig.tool.customTools = [];
  996. (this.$refs.bill as any).setBillConfig(billConfig);
  997. }
  998. }
  999. // 获取当前时间
  1000. getNowDate() {
  1001. let date = new Date();
  1002. let years : any = date.getFullYear();
  1003. let months : any = date.getMonth() + 1;
  1004. let days : any = date.getDate();
  1005. let hours : any = date.getHours();
  1006. let minutes : any = date.getMinutes();
  1007. let seconds : any = date.getSeconds();
  1008. months = months < 10 ? '0' + months : months;
  1009. days = days < 10 ? '0' + days : days;
  1010. hours = hours < 10 ? '0' + hours : hours;
  1011. minutes = minutes < 10 ? '0' + minutes : minutes;
  1012. seconds = seconds < 10 ? '0' + seconds : seconds;
  1013. return `${years}-${months}-${days} ${hours}:${minutes}:${seconds}`;
  1014. }
  1015. // 同步销售订单到财务系统
  1016. syncSystem() {
  1017. let selectData = (this as any).$refs.bill.getTableSelectData('all');
  1018. if (selectData.length > 0) {
  1019. if (selectData[0].isMaster !== 1 || selectData[0].status !== 0) return this.$message.warning('只能同步未出库的主单');
  1020. if (selectData[0].financeOrderId) return this.$message.warning('此数据已同步到财务系统');
  1021. let planData = selectData[0].planDeliveryData.replaceAll(/[-:\s]/g, '');
  1022. let nowDate = this.getNowDate().replaceAll(/[-:\s]/g, '');
  1023. if (planData < nowDate) return this.$message.warning('计划交货时间小于当前时间,不能同步到财务系统');
  1024. this.$confirm('确定同步订单吗', '注意', {
  1025. confirmButtonText: '确定',
  1026. cancelButtonText: '取消',
  1027. type: 'warning',
  1028. center: true
  1029. }).then(() => {
  1030. let loading = this.$loading({ target: '.main-container' });
  1031. api.addSaleOrder({ ids: selectData[0].id }).then((res : any) => {
  1032. loading.close();
  1033. if (res.code === 200) {
  1034. this.$message.success('同步订单成功');
  1035. this.getDataList();
  1036. (this.$refs.bill as any).showTab = 'all';
  1037. } else this.$message.error(res.msg)
  1038. }).catch(() => loading.close());
  1039. }).catch(() => this.$message.info('已取消同步订单'));
  1040. } else this.$message.warning('请选择同步数据');
  1041. }
  1042. // 单据操作同步
  1043. syncSystem2(e : any) {
  1044. this.$confirm('确定同步订单吗', '注意', {
  1045. confirmButtonText: '确定',
  1046. cancelButtonText: '取消',
  1047. type: 'warning',
  1048. center: true
  1049. }).then(() => {
  1050. if (e.financeOrderId) return this.$message.warning('此数据已同步到财务系统');
  1051. let planData = e.planDeliveryData.replaceAll(/[-:\s]/g, '');
  1052. let nowDate = this.getNowDate().replaceAll(/[-:\s]/g, '');
  1053. if (planData < nowDate) return this.$message.warning('计划交货时间小于当前时间,不能同步到财务系统');
  1054. let loading = this.$loading({ target: '.main-container' });
  1055. api.addSaleOrder({ ids: e.id }).then((res : any) => {
  1056. loading.close();
  1057. if (res.code === 200) {
  1058. this.$message.success('同步订单成功');
  1059. this.getDataList();
  1060. (this.$refs.bill as any).showTab = 'all';
  1061. } else this.$message.error(res.msg)
  1062. }).catch(() => loading.close());
  1063. }).catch(() => this.$message.info('已取消同步订单'));
  1064. }
  1065. // 工具栏终止订单
  1066. doBackOrder() {
  1067. let selectData = (this as any).$refs.bill.getTableSelectData('all');
  1068. // console.log(selectData);
  1069. // if (selectData.length > 1) return this.$message.warning('只能选择一条终止订单数据');
  1070. let ids : any = [];
  1071. if (selectData.length > 0) {
  1072. selectData.map((v : any) => {
  1073. ids.push(v.id);
  1074. })
  1075. } else return this.$message.warning('请选择终止订单数据');
  1076. // console.log(ids);
  1077. this.$confirm('确定终止订单吗!', '注意', {
  1078. confirmButtonText: '确定',
  1079. cancelButtonText: '取消',
  1080. type: 'warning',
  1081. center: true
  1082. }).then(() => {
  1083. let loading = this.$loading({ target: '.main-container' });
  1084. api.stoporder({ ids: ids }, 'supplyPurchaseOrder').then((res : any) => {
  1085. loading.close();
  1086. if (res.code === 200) {
  1087. this.$message.success('终止订单成功');
  1088. this.getDataList();
  1089. (this.$refs.bill as any).showTab = 'all';
  1090. } else this.$message.error(res.msg)
  1091. }).catch(() => loading.close());
  1092. }).catch(() => this.$message.info('已取消终止订单'));
  1093. }
  1094. // 单据操作终止订单
  1095. doBackOrder2(e : any) {
  1096. this.$confirm('确定终止订单吗!', '注意', {
  1097. confirmButtonText: '确定',
  1098. cancelButtonText: '取消',
  1099. type: 'warning',
  1100. center: true
  1101. }).then(() => {
  1102. let loading = this.$loading({ target: '.main-container' });
  1103. api.stoporder({ ids: e.id }, 'supplyPurchaseOrder').then((res : any) => {
  1104. loading.close();
  1105. if (res.code === 200) {
  1106. this.$message.success('终止订单成功');
  1107. this.getDataList();
  1108. (this.$refs.bill as any).showTab = 'all';
  1109. } else this.$message.error(res.msg)
  1110. }).catch(() => loading.close());
  1111. }).catch(() => this.$message.info('已取消终止订单'));
  1112. }
  1113. // 分页
  1114. pagination(e : any) {
  1115. // console.log('分页 ==> ', e);
  1116. if (e.type === 'source_0') {
  1117. let query : any = (this as any).$refs.bill.$refs.source_0[0].getSearchValue();
  1118. query.pageNo = e.page.pageNum;
  1119. query.pageSize = e.page.pageSize;
  1120. this.getCitationList(query);
  1121. } else {
  1122. let query : any = (this as any).$refs.bill.getSearchValue(e.type);
  1123. query.pageNo = e.page.pageNum;
  1124. query.pageSize = e.page.pageSize;
  1125. if (e.type === 'returnOrder') query.status = 2; // 终止订单数据
  1126. let loading = this.$loading({ target: '.main-container' });
  1127. api.pageList(query, 'supplyPurchaseOrder').then((res : any) => {
  1128. loading.close();
  1129. if (res.code === 200) {
  1130. (this.$refs.bill as any).setTabTableValue(e.type, res.data.records);
  1131. } else this.$message.error(res.msg);
  1132. }).catch(() => loading.close());
  1133. }
  1134. }
  1135. // 返回
  1136. onReturn() {
  1137. this.clickTab(this.tabType);
  1138. }
  1139. // 搜索
  1140. search(parames : any) {
  1141. let query = parames.value
  1142. if (parames.type === 'source_0') {
  1143. this.getCitationList(query); // 引单数据
  1144. } else {
  1145. if (query.type === 'returnOrder') query.status = 2; // 终止订单数据
  1146. this.getPageList(query, parames.type) // 获取综合分页数据
  1147. }
  1148. }
  1149. // 刷新/重置
  1150. resert(e : any) {
  1151. let data : any = e.type ? e.type : e;
  1152. // console.log('刷新/重置 ==> ', data);
  1153. if (data === 'source_0') {
  1154. (this as any).$refs.bill.$refs.source_0[0].clearSearch();
  1155. this.getCitationList({}); // 引单数据
  1156. } else {
  1157. (this as any).$refs.bill.$refs[data].clearSearch();
  1158. if (data === 'all') this.getPageList({}, 'all'); // 综合数据
  1159. if (data === 'returnOrder') this.getPageList({ status: 2 }, 'returnOrder'); // 终止订单数据
  1160. }
  1161. }
  1162. }
  1163. </script>