index.vue 26 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016
  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. },
  105. // 引单
  106. source: [
  107. {
  108. title: '订单任务',
  109. search: {
  110. attr: {
  111. size: 'medium',
  112. },
  113. columns: [
  114. [
  115. {
  116. span: 6,
  117. label: '单据编号',
  118. prop: 'orderNumber',
  119. component: 'by-input',
  120. compConfig: {
  121. attr: {
  122. placeholder: '请输入单据编号',
  123. clearable: true
  124. }
  125. }
  126. },
  127. {
  128. span: 6,
  129. label: '机构名称',
  130. prop: 'organizationName',
  131. component: 'by-input',
  132. compConfig: {
  133. attr: {
  134. placeholder: '请输入机构名称',
  135. clearable: true
  136. },
  137. },
  138. },
  139. {
  140. span: 6,
  141. label: '交货时间',
  142. prop: 'deliveryData',
  143. component: 'by-date-picker',
  144. compConfig: {
  145. attr: {
  146. format: 'yyyy-MM-dd hh:ss:mm',
  147. type: 'datetime',
  148. },
  149. }
  150. },
  151. ],
  152. ]
  153. },
  154. tool: {
  155. tools: {
  156. search: true,
  157. refresh: true
  158. },
  159. customTools: [
  160. {
  161. name: '引单', icon: 'el-icon-bottom', audit: [''], event: {
  162. click: () => {
  163. (this as any).citationOrder()
  164. }
  165. }
  166. },
  167. ]
  168. },
  169. table: {
  170. attr: {
  171. calculateH: '100%',
  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. },
  242. columns: [
  243. [
  244. {
  245. span: 8,
  246. label: '单据编号',
  247. prop: 'orderNumber',
  248. component: 'by-input',
  249. compConfig: {
  250. attr: {
  251. readonly: true,
  252. },
  253. }
  254. },
  255. {
  256. span: 8,
  257. label: '机构名称',
  258. prop: 'organizationName',
  259. component: 'by-input',
  260. compConfig: {
  261. attr: {
  262. readonly: true,
  263. },
  264. }
  265. },
  266. {
  267. span: 8,
  268. label: '联系方式',
  269. prop: 'phone',
  270. component: 'by-input',
  271. compConfig: {
  272. attr: {
  273. readonly: true,
  274. },
  275. }
  276. },
  277. {
  278. span: 8,
  279. label: '收货人',
  280. prop: 'consignee',
  281. component: 'by-input',
  282. compConfig: {
  283. attr: {
  284. readonly: true,
  285. },
  286. }
  287. },
  288. {
  289. span: 8,
  290. label: '计划交货时间',
  291. prop: 'planDeliveryData',
  292. component: 'by-date-picker',
  293. compConfig: {
  294. attr: {
  295. format: 'yyyy-MM-dd hh:ss:mm',
  296. type: 'datetime',
  297. readonly: true,
  298. },
  299. }
  300. },
  301. {
  302. span: 8,
  303. label: '确定交货时间',
  304. prop: 'affirmDeliveryData',
  305. component: 'by-input',
  306. compConfig: {
  307. attr: {
  308. readonly: true,
  309. },
  310. }
  311. },
  312. {
  313. span: 8,
  314. label: '交货地点',
  315. prop: 'address',
  316. component: 'by-input',
  317. compConfig: {
  318. attr: {
  319. readonly: true,
  320. },
  321. }
  322. },
  323. ],
  324. [
  325. {
  326. span: 28,
  327. label: '备注',
  328. slot: true,
  329. prop: 'remark',
  330. component: 'by-input',
  331. compConfig: {
  332. attr: {
  333. size: 'mini',
  334. placeholder: '请输入备注',
  335. type: 'textarea',
  336. readonly: false,
  337. },
  338. }
  339. },
  340. ]
  341. ]
  342. },
  343. tableConfig: [
  344. {
  345. table: {
  346. attr: {
  347. size: 'mini',
  348. calculateH: '100%',
  349. align: 'center',
  350. readonly: true
  351. },
  352. columns:
  353. [{
  354. width: 300,
  355. title: '物料名称',
  356. field: 'materialName',
  357. },
  358. {
  359. width: 150,
  360. title: '单位',
  361. field: 'unit',
  362. },
  363. {
  364. width: 150,
  365. title: '数量',
  366. field: 'number',
  367. },
  368. {
  369. width: 150,
  370. title: '已交付数量',
  371. field: 'outNumber',
  372. },
  373. {
  374. width: 150,
  375. title: '单价',
  376. field: 'unitPrice',
  377. },
  378. {
  379. width: 150,
  380. title: '实际金额',
  381. field: 'realityPrice',
  382. },
  383. {
  384. width: 150,
  385. title: '优惠金额',
  386. field: 'prePrice',
  387. },
  388. {
  389. width: 150,
  390. title: '合计金额',
  391. field: 'totalPrice',
  392. },
  393. ]
  394. }
  395. }
  396. ]
  397. },
  398. // 综合
  399. all: {
  400. search: {
  401. attr: {
  402. size: 'mini',
  403. },
  404. columns: [
  405. [
  406. {
  407. span: 6,
  408. label: '单据编号',
  409. prop: 'orderNumber',
  410. component: 'by-input',
  411. compConfig: {
  412. attr: {
  413. placeholder: '请输入单据编号',
  414. clearable: true
  415. }
  416. }
  417. },
  418. {
  419. span: 6,
  420. label: '机构名称',
  421. prop: 'organizationName',
  422. component: 'by-input',
  423. compConfig: {
  424. attr: {
  425. placeholder: '请输入机构名称',
  426. clearable: true
  427. },
  428. },
  429. },
  430. ],
  431. ]
  432. },
  433. tool: {
  434. tools: {
  435. search: true,
  436. refresh: true
  437. },
  438. customTools: [
  439. {
  440. name: '终止订单', icon: 'el-icon-close', audit: [''], event: {
  441. click: () => {
  442. (this as any).doBackOrder()
  443. }
  444. }
  445. }
  446. ]
  447. },
  448. table: {
  449. attr: {
  450. calculateH: '100%',
  451. size: 'mini',
  452. seq: true,
  453. align: 'left',
  454. radio: true
  455. },
  456. columns: [
  457. {
  458. width: 144,
  459. title: '单据编号',
  460. field: 'orderNumber',
  461. isDetail: true,
  462. },
  463. {
  464. width: 50,
  465. component: OrderType,
  466. },
  467. {
  468. width: 180,
  469. title: '机构名称',
  470. field: 'organizationName',
  471. },
  472. {
  473. width: 90,
  474. title: '收货人',
  475. field: 'consignee',
  476. },
  477. {
  478. width: 120,
  479. title: '联系方式',
  480. field: 'phone',
  481. },
  482. {
  483. width: 150,
  484. title: '计划交货时间',
  485. field: 'planDeliveryData',
  486. },
  487. {
  488. width: 150,
  489. title: '确定交货时间',
  490. field: 'affirmDeliveryData',
  491. },
  492. {
  493. width: 150,
  494. title: '交货地点',
  495. field: 'address',
  496. },
  497. {
  498. width: 150,
  499. title: '状态',
  500. field: 'status',
  501. component: Assembly,
  502. },
  503. {
  504. width: 110,
  505. title: '操作',
  506. action: true,
  507. plugins: [
  508. {
  509. icon: 'el-icon-edit',
  510. name: '查看',
  511. audit: '',
  512. event: {
  513. click: (item : any) => {
  514. (this as any).openEdit(item)
  515. }
  516. }
  517. },
  518. {
  519. name: '拆单',
  520. event: {
  521. show: (item : any) => {
  522. return item.isMaster === 1
  523. },
  524. click: (item : any) => (this as any).orderTaking(item)
  525. }
  526. },
  527. ]
  528. }
  529. ]
  530. }
  531. },
  532. // 终止订单
  533. returnOrder: {
  534. search: {
  535. attr: {
  536. size: 'mini',
  537. },
  538. columns: [
  539. [
  540. {
  541. span: 6,
  542. label: '单据编号',
  543. prop: 'orderNumber',
  544. component: 'by-input',
  545. compConfig: {
  546. attr: {
  547. placeholder: '请输入单据编号',
  548. clearable: true
  549. }
  550. }
  551. },
  552. {
  553. span: 6,
  554. label: '机构名称',
  555. prop: 'organizationName',
  556. component: 'by-input',
  557. compConfig: {
  558. attr: {
  559. placeholder: '请输入机构名称',
  560. clearable: true
  561. },
  562. },
  563. },
  564. ],
  565. ]
  566. },
  567. tool: {
  568. tools: {
  569. search: true,
  570. refresh: true
  571. },
  572. },
  573. table: {
  574. attr: {
  575. calculateH: '100%',
  576. size: 'mini',
  577. seq: true,
  578. align: 'left',
  579. checkbox: true
  580. },
  581. columns: [
  582. {
  583. width: 168,
  584. title: '单据编号',
  585. field: 'orderNumber',
  586. isDetail: true,
  587. fixed: 'left'
  588. },
  589. {
  590. width: 180,
  591. title: '机构名称',
  592. field: 'organizationName',
  593. },
  594. {
  595. width: 90,
  596. title: '收货人',
  597. field: 'consignee',
  598. },
  599. {
  600. width: 120,
  601. title: '联系方式',
  602. field: 'phone',
  603. },
  604. {
  605. width: 150,
  606. title: '计划交货时间',
  607. field: 'planDeliveryData',
  608. },
  609. {
  610. width: 150,
  611. title: '确定交货时间',
  612. field: 'affirmDeliveryData',
  613. },
  614. {
  615. width: 150,
  616. title: '交货地点',
  617. field: 'address',
  618. },
  619. {
  620. width: 150,
  621. title: '状态',
  622. field: 'status',
  623. component: Assembly,
  624. },
  625. {
  626. width: 110,
  627. title: '操作',
  628. action: true,
  629. plugins: [{
  630. icon: 'el-icon-edit',
  631. name: '查看',
  632. audit: '',
  633. event: {
  634. click: (item : any) => {
  635. (this as any).openEdit(item)
  636. }
  637. }
  638. },
  639. ]
  640. }
  641. ]
  642. }
  643. },
  644. }
  645. created() {
  646. this.timer = setInterval(() => {
  647. this.getDataList()
  648. }, 500)
  649. }
  650. // 引单
  651. citationOrder() {
  652. let parentData : any = (this as any).$refs.bill.getSourceTableSelectData(0);
  653. console.log(parentData);
  654. if (parentData.length <= 0) return this.$message.warning('请选择引单数据');
  655. let loading = this.$loading({ target: '.main-container' });
  656. api.single({ id: parentData[0].id }, 'supplyTaskOrder').then((res : any) => {
  657. if (res.code === 200) {
  658. parentData = res.data ? [res.data] : parentData;
  659. parentData = parentData.map((item : any) => {
  660. item.address = item.deliveryAddress
  661. item.consignee = item.delivery
  662. item.phone = item.deliveryPhone
  663. item.planDeliveryData = item.deliveryData
  664. const { ...newData } = item
  665. return newData
  666. });
  667. let billConfig = (this as any).$lodash.cloneDeep(this.config.bill);
  668. billConfig.tool.tools = { order: true };
  669. billConfig.tool.customTools = [];
  670. this.isCitation = true;
  671. (this.$refs.bill as any).showTab = 'bill';
  672. loading.close();
  673. setTimeout(() => {
  674. (this.$refs.bill as any).setBillConfig(billConfig);
  675. (this.$refs.bill as any).setBillFormValue(parentData[0]); // 设置单据表单数据
  676. (this.$refs.bill as any).setBillTableValue(parentData[0].suborderList, 0);// 设置第1张单据表格数据
  677. }, 0)
  678. } else loading.close();
  679. }).catch(() => loading.close());
  680. };
  681. // 接单
  682. onOrder() {
  683. this.$confirm('确定接单吗', '注意', {
  684. confirmButtonText: '确定',
  685. cancelButtonText: '取消',
  686. type: 'warning',
  687. center: true
  688. }).then(() => {
  689. let data = (this.$refs.bill as any).getBillFormValue();
  690. let loading = this.$loading({ target: '.main-container' });
  691. api.ordersaccepting({ ids: data.id }, 'supplyTaskOrder').then((res : any) => {
  692. loading.close();
  693. if (res.code === 200) {
  694. this.getDataList();
  695. this.$message.success('接单成功');
  696. (this.$refs.bill as any).showTab = 'all';
  697. } else this.$message.error(res.msg);
  698. }).catch(() => loading.close());
  699. }).catch(() => this.$message.info('已取消接单'));
  700. }
  701. // 右拆单数据变化
  702. rightChange(e : any) {
  703. if (0 <= e.number && e.number <= this.regularData[e.dataIndex].splitNumber) {
  704. let leftTableData = (this.$refs.leftTable as any).getValue();
  705. leftTableData[e.dataIndex].splitNumber = leftTableData[e.dataIndex].number - e.number;
  706. (this.$refs.leftTable as any).setValue(leftTableData);
  707. } else {
  708. let leftTableData = (this.$refs.leftTable as any).getValue();
  709. let rifhtTableData = (this.$refs.rightTable as any).getValue();
  710. rifhtTableData[e.dataIndex].number = '0';
  711. leftTableData[e.dataIndex].splitNumber = leftTableData[e.dataIndex].number - leftTableData[e.dataIndex].splitOrderNumber;
  712. (this.$refs.leftTable as any).setValue(leftTableData);
  713. (this.$refs.rightTable as any).setValue(rifhtTableData);
  714. this.$message.warning('输入值只能是自然数且不能大于可拆单数量');
  715. }
  716. }
  717. // 打开拆单
  718. orderTaking(item : any) {
  719. let loading = this.$loading({ target: '.main-container' });
  720. api.single({ id: item.id }, 'supplyPurchaseOrder').then((res : any) => {
  721. loading.close();
  722. console.log(res);
  723. if (res.code === 200) {
  724. this.vxeValue = true;
  725. this.baseInfo = res.data;
  726. this.regularData = (this as any).$lodash.cloneDeep(res.data.suborderList);
  727. let rightData = (this as any).$lodash.cloneDeep(res.data.suborderList);
  728. this.regularData.map((v : any) => {
  729. v.splitNumber = v.number - v.splitOrderNumber;
  730. })
  731. rightData.map((v : any, i : any) => {
  732. v.number = '0';
  733. v.dataIndex = i;
  734. v.splitNumber = v.number - v.splitOrderNumber;
  735. });
  736. setTimeout(() => {
  737. (this.$refs.leftTable as any).setValue(this.regularData);
  738. (this.$refs.rightTable as any).setValue(rightData);
  739. }, 0)
  740. }
  741. }).catch(() => loading.close());
  742. }
  743. // 确认拆单
  744. doConfirm() {
  745. let rifhtNewData : any = [];
  746. let rifhtTableData = (this.$refs.rightTable as any).getValue();
  747. rifhtTableData.map((v : any) => {
  748. rifhtNewData.push({
  749. id: v.id,
  750. inSplitOrderNumber: v.number
  751. })
  752. });
  753. let isTrue = rifhtNewData.filter((v : any) => v.inSplitOrderNumber != 0);
  754. let obj : any = {
  755. id: this.baseInfo.id,
  756. splitList: rifhtNewData,
  757. };
  758. if (isTrue.length > 0) {
  759. this.$confirm('确定拆单吗!', '注意', {
  760. confirmButtonText: '确定',
  761. cancelButtonText: '取消',
  762. type: 'warning',
  763. center: true
  764. }).then(() => {
  765. let loading = this.$loading({ target: '.main-container' });
  766. api.splitOrder(obj, 'supplyPurchaseOrder').then((res : any) => {
  767. loading.close();
  768. if (res.code === 200) {
  769. this.$message.success('拆单成功');
  770. this.getPageList({}, 'all'); // 综合数据
  771. this.vxeValue = false;
  772. } else this.$message.error(res.msg);
  773. }).catch(() => loading.close());
  774. }).catch(() => this.$message.info('已取消拆单'));
  775. } else this.$message.warning('请输入拆单销售数据');
  776. }
  777. getDataList() {
  778. if (!this.$refs.bill) {
  779. if (this.timeNum > 5) {
  780. clearInterval(this.timer)
  781. }
  782. this.timeNum++;
  783. return
  784. }
  785. clearInterval(this.timer);
  786. this.getPageList({}, 'all'); // 综合数据
  787. }
  788. // 获取分页数据
  789. getPageList(query : any, type : any) {
  790. let data = (this.$refs.bill as any).getTablePage('all');
  791. query.pageNo = data.pageNo;
  792. query.pageSize = data.pageSize;
  793. let loading = this.$loading({ target: '.main-container' });
  794. api.pageList(query, 'supplyPurchaseOrder').then((res : any) => {
  795. loading.close();
  796. if (res.code === 200) {
  797. (this.$refs.bill as any).setTabTableValue(type, res.data.records);
  798. let page = {
  799. pageNo: res.data.current, //当前页
  800. pageSize: res.data.size, //每页条数
  801. total: res.data.total //总条数
  802. };
  803. (this.$refs.bill as any).setTablePage(type, page)
  804. } else this.$message.error(res.msg);
  805. }).catch(() => loading.close());
  806. }
  807. // 获取引单分页数据
  808. getCitationList(query : any) {
  809. let data = (this.$refs.bill as any).getTablePage('all');
  810. query.pageNo = data.pageNo;
  811. query.pageSize = data.pageSize;
  812. query.submitState = 1; // 已提交
  813. query.status = 0; // 未接单
  814. let loading = this.$loading({ target: '.main-container' });
  815. api.pageList(query, 'supplyTaskOrder').then((res : any) => {
  816. loading.close();
  817. if (res.code === 200) {
  818. (this.$refs.bill as any).setSourceTableData(0, res.data.records);
  819. let page = {
  820. pageNo: res.data.current, //当前页
  821. pageSize: res.data.size, //每页条数
  822. total: res.data.total //总条数
  823. };
  824. (this.$refs.bill as any).setSourcePage(0, page);
  825. } else this.$message.error(res.msg)
  826. }).catch(() => loading.close());
  827. }
  828. // 保存
  829. onSave(){
  830. let query = (this.$refs.bill as any).getBillFormValue(); // 获取单据数据
  831. console.log('保存参数query ==> ', query);
  832. let loading = this.$loading({ target: '.main-container' });
  833. api.updateList(query, 'supplyPurchaseOrder').then((res : any) => {
  834. loading.close();
  835. if (res.code === 200) {
  836. this.$message.success('保存成功');
  837. this.getPageList({}, 'all'); // 综合数据
  838. (this.$refs.bill as any).showTab = 'all';
  839. } else this.$message.error(res.msg);
  840. }).catch(() => loading.close());
  841. }
  842. // 打开编辑
  843. openEdit(e : any) {
  844. e = e.row ? e.row : e;
  845. let loading = this.$loading({ target: '.main-container' });
  846. api.single({ id: e.id }, 'supplyPurchaseOrder').then((res : any) => {
  847. if (res.code === 200) {
  848. let parentData = res.data ? res.data : e;
  849. console.log(parentData);
  850. let billConfig = (this as any).$lodash.cloneDeep(this.config.bill);
  851. if (parentData.status === 2) {
  852. billConfig.tool.customTools = [];
  853. } else {
  854. billConfig.tool.customTools = [
  855. {
  856. name: '终止订单', icon: 'el-icon-close', audit: [''], event: {
  857. click: () => {
  858. (this as any).doBackOrder2(parentData)
  859. }
  860. }
  861. }
  862. ];
  863. // 主单
  864. if (parentData.isMaster === 1) {
  865. billConfig.tool.customTools = [
  866. {
  867. name: '拆单', icon: 'el-icon-minus', audit: [''], event: {
  868. click: () => {
  869. (this as any).orderTaking(parentData)
  870. }
  871. }
  872. },
  873. {
  874. name: '终止订单', icon: 'el-icon-close', audit: [''], event: {
  875. click: () => {
  876. (this as any).doBackOrder2(parentData)
  877. }
  878. }
  879. }
  880. ];
  881. }
  882. };
  883. billConfig.tool.tools = {};
  884. billConfig.form.columns[0].map((v:any) => {
  885. v.compConfig.attr.readonly = true;
  886. })
  887. console.log(billConfig.form.columns[0]);
  888. billConfig.form.columns[1][0].compConfig.attr.readonly = true;
  889. if (parentData.status === 0) {
  890. billConfig.form.columns[0][2].compConfig.attr.readonly = false;
  891. billConfig.form.columns[0][3].compConfig.attr.readonly = false;
  892. billConfig.form.columns[0][4].compConfig.attr.readonly = false;
  893. billConfig.form.columns[0][6].compConfig.attr.readonly = false;
  894. billConfig.form.columns[1][0].compConfig.attr.readonly = false;
  895. billConfig.tool.tools = { save: true };
  896. };
  897. (this.$refs.bill as any).setBillConfig(billConfig);
  898. (this.$refs.bill as any).setBillFormValue(parentData); // 设置单据表单数据
  899. (this.$refs.bill as any).setBillTableValue(parentData.suborderList, 0);// 设置第1张单据表格数据
  900. (this.$refs.bill as any).showTab = 'bill';
  901. loading.close();
  902. } else loading.close();
  903. }).catch(() => loading.close());
  904. }
  905. // 导航切换
  906. clickTab(e : any) {
  907. console.log('导航切换 ==> ', e);
  908. // submitState: 提交状态
  909. if (e === 'source') {
  910. this.getCitationList({});
  911. }
  912. if (e === 'all') this.getDataList();
  913. if (e === 'returnOrder') this.getPageList({ status: 2 }, 'returnOrder');
  914. if (e === 'bill') {
  915. let billConfig = (this as any).$lodash.cloneDeep(this.config.bill);
  916. billConfig.tool.tools = {};
  917. billConfig.tool.customTools = [];
  918. (this.$refs.bill as any).setBillConfig(billConfig);
  919. }
  920. }
  921. // 工具栏终止订单
  922. doBackOrder() {
  923. let selectData = (this as any).$refs.bill.getTableSelectData('all');
  924. // if (selectData.length > 1) return this.$message.warning('只能选择一条终止订单数据');
  925. let ids : any = [];
  926. if (selectData.length > 0) {
  927. selectData.map((v : any) => {
  928. ids.push(v.id);
  929. })
  930. } else return this.$message({ type: 'warning', message: '请选择终止订单数据' })
  931. // console.log(ids);
  932. this.$confirm('确定终止订单吗!', '注意', {
  933. confirmButtonText: '确定',
  934. cancelButtonText: '取消',
  935. type: 'warning',
  936. center: true
  937. }).then(() => {
  938. let loading = this.$loading({ target: '.main-container' });
  939. api.stoporder({ ids: ids }, 'supplyPurchaseOrder').then((res : any) => {
  940. loading.close();
  941. if (res.code === 200) {
  942. this.$message.success('终止订单成功');
  943. this.getDataList();
  944. (this.$refs.bill as any).showTab = 'all';
  945. } else this.$message.error(res.msg)
  946. }).catch(() => loading.close());
  947. }).catch(() => this.$message.info('已取消终止订单'));
  948. }
  949. // 单据操作终止订单
  950. doBackOrder2(e : any) {
  951. this.$confirm('确定终止订单吗!', '注意', {
  952. confirmButtonText: '确定',
  953. cancelButtonText: '取消',
  954. type: 'warning',
  955. center: true
  956. }).then(() => {
  957. let loading = this.$loading({ target: '.main-container' });
  958. api.stoporder({ ids: e.id }, 'supplyPurchaseOrder').then((res : any) => {
  959. loading.close();
  960. if (res.code === 200) {
  961. this.$message.success('终止订单成功');
  962. this.getDataList();
  963. (this.$refs.bill as any).showTab = 'all';
  964. } else this.$message.error(res.msg)
  965. }).catch(() => loading.close());
  966. }).catch(() => this.$message.info('已取消终止订单'));
  967. }
  968. // 分页
  969. pagination(e : any) {
  970. console.log('分页 ==> ', e);
  971. if(e.type==='source_0'){
  972. let query : any = (this as any).$refs.bill.$refs.source_0[0].getSearchValue();
  973. query.pageNo = e.page.pageNum;
  974. query.pageSize = e.page.pageSize;
  975. this.getCitationList(query);
  976. }else{
  977. let query : any = (this as any).$refs.bill.getSearchValue(e.type);
  978. query.pageNo = e.page.pageNum;
  979. query.pageSize = e.page.pageSize;
  980. if (e.type === 'returnOrder') query.status = 2; // 终止订单数据
  981. let loading = this.$loading({ target: '.main-container' });
  982. api.pageList(query, 'supplyPurchaseOrder').then((res : any) => {
  983. loading.close();
  984. if (res.code === 200) {
  985. (this.$refs.bill as any).setTabTableValue(e.type, res.data.records);
  986. } else this.$message.error(res.msg);
  987. }).catch(() => loading.close());
  988. }
  989. }
  990. // 搜索
  991. search(parames : any) {
  992. let query = parames.value
  993. if (parames.type === 'source_0') {
  994. this.getCitationList(query); // 引单数据
  995. } else {
  996. if (query.type === 'returnOrder') query.status = 2; // 终止订单数据
  997. this.getPageList(query, parames.type) // 获取综合分页数据
  998. }
  999. }
  1000. // 刷新/重置
  1001. resert(e : any) {
  1002. let data : any = e.type ? e.type : e;
  1003. console.log('刷新/重置 ==> ', data);
  1004. if (data === 'source_0') {
  1005. (this as any).$refs.bill.$refs.source_0[0].clearSearch();
  1006. this.getCitationList({}); // 引单数据
  1007. } else {
  1008. (this as any).$refs.bill.$refs[data].clearSearch();
  1009. if (data === 'all') this.getPageList({}, 'all'); // 综合数据
  1010. if (data === 'returnOrder') this.getPageList({ status: 2 }, 'returnOrder'); // 终止订单数据
  1011. }
  1012. }
  1013. }
  1014. </script>