index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721
  1. <template>
  2. <div>
  3. <byBill :propConfig="config" @search="search" @onSmt="doSave" ref="bill" @resert="getDataList" @detail="openEdit"
  4. @onRefresh="onRefresh" @pagination="pagination" @clickTab="clickTab">
  5. </byBill>
  6. <vxe-modal v-model="vxeValue" width="70%" height="70%" min-width="800" min-height="600" show-zoom resize transfer
  7. show-footer>
  8. <template #title>
  9. <!-- <span>拆单</span> -->
  10. </template>
  11. <template #default>
  12. <div class="fl" style="width: 40%;">
  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: 200px 6% 0 6%;transform: rotate(90deg);"><i
  17. class="el-icon-sort"></i></div>
  18. <div class="fl" style="width: 40%;">
  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. </div>
  30. </template>
  31. <script lang="ts">
  32. import { Component, Prop, Vue, Watch } from "vue-property-decorator";
  33. import api from "@/api/order";
  34. import OrderType from "./components/orderType.vue";
  35. import byBill from "./components/byBill/byBill.vue";
  36. @Component({ components: { byBill } })
  37. export default class OrderTask extends Vue {
  38. vxeValue = 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: 258,
  83. title: '物料名称',
  84. field: 'materialName',
  85. },
  86. {
  87. width: 258,
  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. bill: {
  107. tool: {
  108. customTools: []
  109. },
  110. form: {
  111. attr: {
  112. size: 'medium',
  113. readonly: true,
  114. },
  115. columns: [
  116. [
  117. {
  118. span: 8,
  119. label: '单据编号',
  120. prop: 'orderNumber',
  121. component: 'by-input',
  122. },
  123. {
  124. span: 8,
  125. label: '机构名称',
  126. prop: 'organizationName',
  127. component: 'by-input',
  128. },
  129. {
  130. span: 8,
  131. label: '退单编号',
  132. prop: 'chargebackNo',
  133. component: 'by-input',
  134. },
  135. {
  136. span: 8,
  137. label: '联系方式',
  138. prop: 'deliveryPhone',
  139. component: 'by-input',
  140. },
  141. {
  142. span: 8,
  143. label: '收货人',
  144. prop: 'consignee',
  145. component: 'by-input',
  146. },
  147. {
  148. span: 8,
  149. label: '交货时间',
  150. prop: 'deliveryData',
  151. component: 'by-input',
  152. },
  153. {
  154. span: 8,
  155. label: '交货地点',
  156. prop: 'deliveryAddress',
  157. component: 'by-input',
  158. },
  159. {
  160. span: 8,
  161. label: '交货方式',
  162. prop: 'deliveryWay',
  163. component: 'by-input',
  164. },
  165. ],
  166. [
  167. {
  168. span: 28,
  169. label: '备注',
  170. slot: true,
  171. prop: 'remark',
  172. component: 'by-input',
  173. compConfig: {
  174. attr: {
  175. size: 'mini',
  176. placeholder: '请输入备注',
  177. type: 'textarea'
  178. },
  179. }
  180. },
  181. ]
  182. ]
  183. },
  184. tableConfig: [
  185. {
  186. table: {
  187. attr: {
  188. size: 'mini',
  189. height: 500,
  190. align: 'center',
  191. readonly: true
  192. },
  193. columns:
  194. [{
  195. width: 300,
  196. title: '物料名称',
  197. field: 'materialName',
  198. },
  199. {
  200. width: 150,
  201. title: '单位',
  202. field: 'unit',
  203. },
  204. {
  205. width: 150,
  206. title: '数量',
  207. field: 'number',
  208. },
  209. {
  210. width: 150,
  211. title: '已交付数量',
  212. field: 'deliveryNumber',
  213. },
  214. {
  215. width: 150,
  216. title: '单价',
  217. field: 'unitPrice',
  218. },
  219. {
  220. width: 150,
  221. title: '实际金额',
  222. field: 'realityPrice',
  223. },
  224. {
  225. width: 150,
  226. title: '优惠金额',
  227. field: 'prePrice',
  228. },
  229. {
  230. width: 150,
  231. title: '合计金额',
  232. field: 'totalPrice',
  233. },
  234. ]
  235. }
  236. }
  237. ]
  238. },
  239. // 综合
  240. all: {
  241. search: {
  242. attr: {
  243. size: 'mini',
  244. },
  245. columns: [
  246. [
  247. {
  248. span: 6,
  249. label: '单据编号',
  250. prop: 'orderNumber',
  251. component: 'by-input',
  252. compConfig: {
  253. attr: {
  254. placeholder: '请输入单据编号',
  255. clearable: true
  256. }
  257. }
  258. },
  259. {
  260. span: 6,
  261. label: '机构名称',
  262. prop: 'organizationName',
  263. component: 'by-input',
  264. compConfig: {
  265. attr: {
  266. placeholder: '请输入机构名称',
  267. clearable: true
  268. },
  269. },
  270. },
  271. {
  272. span: 6,
  273. label: '退单编号',
  274. prop: 'chargebackNo',
  275. component: 'by-input',
  276. compConfig: {
  277. attr: {
  278. placeholder: '请输入退单编号',
  279. clearable: true
  280. }
  281. }
  282. },
  283. ],
  284. ]
  285. },
  286. tool: {
  287. tools: {
  288. search: true,
  289. refresh: true
  290. },
  291. customTools: [
  292. {
  293. name: '退单', icon: 'el-icon-top', audit: [''], event: {
  294. click: () => {
  295. (this as any).doBackOrder()
  296. }
  297. }
  298. }
  299. ]
  300. },
  301. table: {
  302. attr: {
  303. height: 600,
  304. size: 'mini',
  305. seq: true,
  306. align: 'left',
  307. checkbox: true
  308. },
  309. columns: [
  310. {
  311. width: 144,
  312. title: '单据编号',
  313. field: 'orderNumber',
  314. // component: OrderType,
  315. isDetail: true,
  316. },
  317. {
  318. width: 50,
  319. component: OrderType,
  320. },
  321. {
  322. width: 180,
  323. title: '机构名称',
  324. field: 'organizationName',
  325. },
  326. {
  327. width: 178,
  328. title: '退单编号',
  329. field: 'chargebackNo',
  330. },
  331. {
  332. width: 90,
  333. title: '收货人',
  334. field: 'consignee',
  335. },
  336. {
  337. width: 120,
  338. title: '联系方式',
  339. field: 'phone',
  340. },
  341. {
  342. width: 150,
  343. title: '计划交货时间',
  344. field: 'planDeliveryData',
  345. },
  346. {
  347. width: 150,
  348. title: '确定交货时间',
  349. field: 'affirmDeliveryData',
  350. },
  351. {
  352. width: 150,
  353. title: '交货地点',
  354. field: 'address',
  355. },
  356. {
  357. width: 110,
  358. title: '操作',
  359. action: true,
  360. plugins: [
  361. {
  362. icon: 'el-icon-edit',
  363. name: '查看',
  364. audit: '',
  365. event: {
  366. click: (item : any) => {
  367. (this as any).openEdit(item)
  368. }
  369. }
  370. },
  371. {
  372. name: '拆单',
  373. event: {
  374. show: (item : any) => {
  375. return item.isMaster === 1
  376. },
  377. click: (item : any) => (this as any).orderTaking(item)
  378. }
  379. },
  380. ]
  381. }
  382. ]
  383. }
  384. },
  385. // 退单
  386. returnOrder: {
  387. search: {
  388. attr: {
  389. size: 'mini',
  390. },
  391. columns: [
  392. [
  393. {
  394. span: 6,
  395. label: '单据编号',
  396. prop: 'orderNumber',
  397. component: 'by-input',
  398. compConfig: {
  399. attr: {
  400. placeholder: '请输入单据编号',
  401. clearable: true
  402. }
  403. }
  404. },
  405. {
  406. span: 6,
  407. label: '机构名称',
  408. prop: 'organizationName',
  409. component: 'by-input',
  410. compConfig: {
  411. attr: {
  412. placeholder: '请输入机构名称',
  413. clearable: true
  414. },
  415. },
  416. },
  417. {
  418. span: 6,
  419. label: '退单编号',
  420. prop: 'chargebackNo',
  421. component: 'by-input',
  422. compConfig: {
  423. attr: {
  424. placeholder: '请输入退单编号',
  425. clearable: true
  426. }
  427. }
  428. },
  429. ],
  430. ]
  431. },
  432. tool: {
  433. tools: {
  434. search: true,
  435. refresh: true
  436. },
  437. },
  438. table: {
  439. attr: {
  440. height: 620,
  441. size: 'mini',
  442. seq: true,
  443. align: 'left',
  444. checkbox: true
  445. },
  446. columns: [
  447. {
  448. width: 168,
  449. title: '单据编号',
  450. field: 'orderNumber',
  451. isDetail: true,
  452. fixed: 'left'
  453. },
  454. {
  455. width: 180,
  456. title: '机构名称',
  457. field: 'organizationName',
  458. },
  459. {
  460. width: 178,
  461. title: '退单编号',
  462. field: 'chargebackNo',
  463. },
  464. {
  465. width: 90,
  466. title: '收货人',
  467. field: 'consignee',
  468. },
  469. {
  470. width: 120,
  471. title: '联系方式',
  472. field: 'phone',
  473. },
  474. {
  475. width: 150,
  476. title: '计划交货时间',
  477. field: 'planDeliveryData',
  478. },
  479. {
  480. width: 150,
  481. title: '确定交货时间',
  482. field: 'affirmDeliveryData',
  483. },
  484. {
  485. width: 150,
  486. title: '交货地点',
  487. field: 'address',
  488. },
  489. {
  490. width: 110,
  491. title: '操作',
  492. action: true,
  493. plugins: [{
  494. icon: 'el-icon-edit',
  495. name: '查看',
  496. audit: '',
  497. event: {
  498. click: (item : any) => {
  499. (this as any).openEdit(item)
  500. }
  501. }
  502. }, {
  503. name: '拆单',
  504. event: {
  505. click: (item : any) => (this as any).orderTaking(item)
  506. }
  507. }]
  508. }
  509. ]
  510. }
  511. },
  512. }
  513. created() {
  514. this.timer = setInterval(() => {
  515. this.getDataList()
  516. }, 500)
  517. }
  518. // 工具栏退单
  519. doBackOrder() {
  520. // console.log((this as any).$refs.bill.getTableSelectData('all'));
  521. let selectData = (this as any).$refs.bill.getTableSelectData('all');
  522. let ids = '';
  523. if (selectData.length > 0) {
  524. selectData.map((v : any) => {
  525. ids += v.id + ','
  526. })
  527. } else return this.$message({ type: 'warning', message: '请选择退单数据' })
  528. ids = ids.slice(0, ids.length - 1);
  529. this.$confirm('确定退单吗!', '注意', {
  530. confirmButtonText: '确定',
  531. cancelButtonText: '取消',
  532. type: 'warning',
  533. center: true
  534. }).then(() => {
  535. api.backOrder({ mid: ids }, 'supplyPurchaseOrder').then((res : any) => {
  536. if (res.code === 200) {
  537. this.$message.success('退单成功!');
  538. this.getDataList();
  539. } else this.$message.error(res.msg)
  540. })
  541. }).catch(() => this.$message.info('已取消退单'));
  542. }
  543. // 右拆单数据变化
  544. rightChange(e : any) {
  545. console.log(e.number);
  546. if (0 <= e.number && e.number <= this.regularData[e.dataIndex].splitNumber) {
  547. let leftTableData = (this.$refs.leftTable as any).getValue();
  548. leftTableData[e.dataIndex].splitNumber = leftTableData[e.dataIndex].number - e.number;
  549. (this.$refs.leftTable as any).setValue(leftTableData);
  550. } else {
  551. let leftTableData = (this.$refs.leftTable as any).getValue();
  552. let rifhtTableData = (this.$refs.rightTable as any).getValue();
  553. rifhtTableData[e.dataIndex].number = '0';
  554. leftTableData[e.dataIndex].splitNumber = leftTableData[e.dataIndex].number - leftTableData[e.dataIndex].splitOrderNumber;
  555. (this.$refs.leftTable as any).setValue(leftTableData);
  556. (this.$refs.rightTable as any).setValue(rifhtTableData);
  557. this.$message.warning('输入值只能是自然数且不能大于可拆单数量');
  558. }
  559. }
  560. // 打开拆单
  561. orderTaking(item : any) {
  562. this.vxeValue = true;
  563. this.baseInfo = item;
  564. this.regularData = (this as any).$lodash.cloneDeep(item.suborderList);
  565. let rightData = (this as any).$lodash.cloneDeep(item.suborderList);
  566. this.regularData.map((v : any) => {
  567. v.splitNumber = v.number - v.splitOrderNumber;
  568. })
  569. rightData.map((v : any, i : any) => {
  570. v.number = '0';
  571. v.dataIndex = i;
  572. v.splitNumber = v.number - v.splitOrderNumber;
  573. });
  574. setTimeout(() => {
  575. (this.$refs.leftTable as any).setValue(this.regularData);
  576. (this.$refs.rightTable as any).setValue(rightData);
  577. }, 0)
  578. }
  579. // 确认拆单
  580. doConfirm() {
  581. let rifhtNewData : any = [];
  582. let rifhtTableData = (this.$refs.rightTable as any).getValue();
  583. rifhtTableData.map((v : any) => {
  584. rifhtNewData.push({
  585. id: v.id,
  586. inSplitOrderNumber: v.number
  587. })
  588. });
  589. let isTrue = rifhtNewData.filter((v : any) => v.inSplitOrderNumber != 0);
  590. let obj : any = {
  591. id: this.baseInfo.id,
  592. splitList: rifhtNewData,
  593. };
  594. if (isTrue.length > 0) {
  595. api.splitOrder(obj, 'supplyPurchaseOrder').then((res : any) => {
  596. if (res.code === 200) {
  597. this.$message.success('拆单成功!');
  598. this.getPageList({ pageSize: 20, pageNo: 1 }, 'all'); // 综合数据
  599. this.vxeValue = false;
  600. } else this.$message.error(res.msg);
  601. })
  602. } else this.$message.warning('请输入拆单销售数据');
  603. }
  604. // 保存新增
  605. doSave() {
  606. // (this.$refs.product as any).setShow(true)
  607. (this as any).$refs.bill.$refs.billForm.validate().then(() => {
  608. let query = (this as any).$refs.bill.$refs.billForm.getValue();
  609. api.saveList(query, 'supplyPurchaseOrder').then((res : any) => {
  610. if (res.code === 200) {
  611. this.$message({
  612. type: 'success',
  613. message: '提交成功!'
  614. });
  615. this.getDataList();
  616. (this.$refs.bill as any).showTab = 'all';
  617. (this.$refs.bill as any).setBillFormValue({});
  618. } else this.$message.error(res.msg);
  619. })
  620. })
  621. }
  622. getDataList() {
  623. if (!this.$refs.bill) {
  624. if (this.timeNum > 5) {
  625. clearInterval(this.timer)
  626. }
  627. this.timeNum++;
  628. return
  629. }
  630. clearInterval(this.timer);
  631. this.getPageList({ pageSize: 20, pageNo: 1 }, 'all'); // 综合数据
  632. }
  633. // 获取分页数据
  634. getPageList(query : any, type : any) {
  635. api.pageList(query, 'supplyPurchaseOrder').then((res : any) => {
  636. if (res.code === 200) {
  637. (this.$refs.bill as any).setTabTableValue(type, res.data.records);
  638. let page = {
  639. pageNo: res.data.current, //当前页
  640. pageSize: res.data.size, //每页条数
  641. total: res.data.total //总条数
  642. };
  643. (this.$refs.bill as any).setTablePage(type, page)
  644. } else this.$message.error(res.msg);
  645. })
  646. }
  647. // 打开编辑
  648. openEdit(e : any) {
  649. e = e.row ? e.row : e;
  650. let billConfig = (this as any).$lodash.cloneDeep(this.config.bill);
  651. if (e.isMaster === 1) {
  652. billConfig.tool.customTools = [
  653. {
  654. name: '拆单', icon: 'el-icon-minus', audit: [''], event: {
  655. click: () => {
  656. (this as any).orderTaking(e)
  657. }
  658. }
  659. },
  660. {
  661. name: '退单', icon: 'el-icon-bottom', audit: [''], event: {
  662. click: () => {
  663. // (this as any)
  664. }
  665. }
  666. }
  667. ];
  668. } else {
  669. billConfig.tool.customTools = [
  670. {
  671. name: '退单', icon: 'el-icon-bottom', audit: [''], event: {
  672. click: () => {
  673. // (this as any)
  674. }
  675. }
  676. }
  677. ];
  678. };
  679. (this.$refs.bill as any).setBillConfig(billConfig);
  680. (this.$refs.bill as any).setBillFormValue(e); // 设置单据表单数据
  681. (this.$refs.bill as any).setBillTableValue(e.suborderList, 0);// 设置第1张单据表格数据
  682. (this.$refs.bill as any).showTab = 'bill';
  683. }
  684. // 导航切换
  685. clickTab(e : any) {
  686. console.log('导航切换 ==> ', e);
  687. if (e === 'all') this.getDataList();
  688. if (e === 'bill') {
  689. let billConfig = (this as any).$lodash.cloneDeep(this.config.bill);
  690. billConfig.tool.customTools = [];
  691. (this.$refs.bill as any).setBillConfig(billConfig);
  692. }
  693. }
  694. // 分页
  695. pagination(e : any) {
  696. let query = {
  697. pageNo: e.page.pageNum,
  698. pageSize: e.page.pageSize,
  699. };
  700. let loading = this.$loading({ target: '.main-container' })
  701. api.pageList(query, 'supplyPurchaseOrder').then((res : any) => {
  702. if (res.code === 200) {
  703. (this.$refs.bill as any).setTabTableValue(e.type, res.data.records);
  704. loading.close()
  705. } else this.$message.error(res.msg);
  706. })
  707. }
  708. // 搜索
  709. search(parames : any) {
  710. let query = parames.value
  711. if (parames.type === 'draftsBox') query.submitState = 0 // 草稿箱数据
  712. if (parames.type === 'smt') query.submitState = 1 // 已提交数据
  713. this.getPageList(query, parames.type) // 获取综合分页数据
  714. }
  715. // 刷新
  716. onRefresh(e : string) {
  717. (this as any).$refs.bill.$refs[e].resert();
  718. }
  719. }
  720. </script>