index.vue 17 KB

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