index.vue 29 KB

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