index.vue 17 KB

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