index.vue 26 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019
  1. <template>
  2. <div>
  3. <by-bill ref="bill" :propConfig="config" @search="search" @onAdd="onAdd" @onDelete="onDelete" @onRefresh="resert"
  4. @resert="resert" @detail="openEdit" @onSave="onSave" @clickTab="clickTab" @onChangeRow="onChangeRow"
  5. @pagination="pagination" @getSupplierModal="getSupplierModal" @getbusinessType="getbusinessType">
  6. </by-bill>
  7. <!-- 选择物料 -->
  8. <productModal ref="product" :mulit="true" @confirm="confirmProduct" />
  9. </div>
  10. </template>
  11. <script lang="ts">
  12. import { Component, Prop, Vue, Watch } from "vue-property-decorator";
  13. import api from "@/api/order";
  14. import productModal from "../orderTask/components/productModal.vue";
  15. import Focus from "../orderTask/components/focus.vue";
  16. import towInOne from "./components/towInOne.vue";
  17. import BusinessType from "./components/businessType.vue";
  18. @Component({ components: { productModal } })
  19. export default class OrderTask extends Vue {
  20. // 左边
  21. tabType : any = 'all';
  22. isAdd : any = false
  23. // 右边
  24. supplierInfo : any = {} // 机构信息
  25. businessType : any = '' // 业务类型
  26. tableData : any = []
  27. mergeObj : any = []
  28. setStatusData : any = ''
  29. timeNum = 0;
  30. timer : any = null
  31. config : any = {
  32. attr: {
  33. activeName: 'all'
  34. },
  35. // 单据
  36. bill: {
  37. tool: {
  38. tools: {
  39. save: true,
  40. }
  41. },
  42. form: {
  43. attr: {
  44. size: 'small',
  45. readonly: false,
  46. },
  47. columns: [
  48. [
  49. {
  50. span: 8,
  51. label: '单据编号',
  52. prop: 'orderNumber',
  53. component: 'by-input',
  54. compConfig: {
  55. attr: {
  56. readonly: true
  57. },
  58. }
  59. },
  60. {
  61. span: 8,
  62. label: '机构名称',
  63. prop: 'organizationName',
  64. component: Focus,
  65. },
  66. {
  67. span: 8,
  68. label: '经办人',
  69. prop: 'operator',
  70. component: 'by-input',
  71. },
  72. {
  73. span: 8,
  74. label: '业务类型',
  75. prop: 'businessType',
  76. component: BusinessType,
  77. },
  78. {
  79. span: 8,
  80. label: '财务系统单据',
  81. prop: 'financeOrderId',
  82. component: 'by-input',
  83. },
  84. {
  85. span: 8,
  86. label: 'WMS编码',
  87. prop: 'wmsId',
  88. component: 'by-input',
  89. },
  90. ],
  91. [
  92. {
  93. span: 28,
  94. label: '备注',
  95. slot: true,
  96. prop: 'remark',
  97. component: 'by-input',
  98. compConfig: {
  99. attr: {
  100. size: 'mini',
  101. placeholder: '请输入备注',
  102. type: 'textarea'
  103. },
  104. }
  105. },
  106. ]
  107. ]
  108. },
  109. tableConfig: [
  110. {
  111. tool: {
  112. tools: {
  113. add: true
  114. }
  115. },
  116. table: {
  117. attr: {
  118. size: 'mini',
  119. height: 500,
  120. align: 'center',
  121. readonly: true
  122. },
  123. columns:
  124. [
  125. {
  126. width: 300,
  127. title: '物料名称',
  128. field: 'materialName',
  129. },
  130. {
  131. width: 200,
  132. title: '仓库,仓位',
  133. field: 'towInOne',
  134. component: towInOne,
  135. compConfig: {
  136. isSelect: true
  137. }
  138. },
  139. {
  140. width: 110,
  141. title: '单位',
  142. field: 'unit',
  143. },
  144. {
  145. width: 110,
  146. title: '数量',
  147. field: 'number',
  148. component: 'by-input',
  149. compConfig: {
  150. attr: {
  151. size: 'mini',
  152. type: 'integer',
  153. defaultValue: 1,
  154. },
  155. }
  156. },
  157. {
  158. width: 110,
  159. title: '已交付数量',
  160. field: 'deliveryNumber',
  161. },
  162. {
  163. width: 110,
  164. title: '单价',
  165. field: 'unitPrice',
  166. component: 'by-input',
  167. compConfig: {
  168. attr: {
  169. size: 'mini',
  170. type: 'number',
  171. },
  172. }
  173. },
  174. {
  175. width: 110,
  176. title: '合计金额',
  177. field: 'totalPrice',
  178. },
  179. {
  180. width: 90,
  181. title: '操作',
  182. action: true,
  183. plugins: [{
  184. icon: 'el-icon-delete',
  185. name: '删除',
  186. audit: '',
  187. event: {
  188. click: (item : any) => {
  189. (this as any).changeTable(item)
  190. }
  191. }
  192. }]
  193. },
  194. ]
  195. }
  196. }
  197. ]
  198. },
  199. // 已提交
  200. smt: {
  201. search: {
  202. attr: {
  203. size: 'mini',
  204. },
  205. columns: [
  206. [
  207. {
  208. span: 6,
  209. label: '单据编号',
  210. prop: 'orderNumber',
  211. component: 'by-input',
  212. compConfig: {
  213. attr: {
  214. placeholder: '请输入单据编号',
  215. clearable: true
  216. }
  217. }
  218. },
  219. {
  220. span: 6,
  221. label: '机构名称',
  222. prop: 'organizationName',
  223. component: 'by-input',
  224. compConfig: {
  225. attr: {
  226. placeholder: '请输入机构名称',
  227. clearable: true
  228. },
  229. },
  230. },
  231. {
  232. span: 6,
  233. label: '财务系统单据',
  234. prop: 'financeOrderId',
  235. component: 'by-input',
  236. compConfig: {
  237. attr: {
  238. placeholder: '请输入财务系统单据',
  239. clearable: true
  240. },
  241. },
  242. },
  243. ],
  244. ]
  245. },
  246. tool: {
  247. tools: {
  248. delete: true,
  249. search: true,
  250. refresh: true
  251. }
  252. },
  253. table: {
  254. attr: {
  255. height: 620,
  256. size: 'mini',
  257. seq: true,
  258. align: 'left',
  259. checkbox: true
  260. },
  261. columns: [
  262. {
  263. width: 200,
  264. title: '单据编号',
  265. field: 'orderNumber',
  266. isDetail: true,
  267. fixed: 'left'
  268. },
  269. {
  270. width: 200,
  271. title: '机构名称',
  272. field: 'organizationName',
  273. },
  274. {
  275. width: 200,
  276. title: '财务系统单据',
  277. field: 'financeOrderId',
  278. },
  279. {
  280. width: 200,
  281. title: 'WMS编号',
  282. field: 'wmsId',
  283. },
  284. {
  285. width: 120,
  286. title: '经办人',
  287. field: 'operator',
  288. },
  289. {
  290. width: 250,
  291. title: '备注',
  292. field: 'remark',
  293. },
  294. {
  295. width: 110,
  296. title: '操作',
  297. action: true,
  298. plugins: [{
  299. icon: 'el-icon-edit',
  300. name: '编辑',
  301. audit: '',
  302. event: {
  303. click: (e : any) => {
  304. (this as any).setReadonly(e)
  305. }
  306. }
  307. }, {
  308. name: '删除',
  309. event: {
  310. click: (item : any) => (this as any).doDelete2(item)
  311. }
  312. }]
  313. }
  314. ]
  315. }
  316. },
  317. // 草稿箱
  318. draftsBox: {
  319. search: {
  320. attr: {
  321. size: 'mini',
  322. },
  323. columns: [
  324. [
  325. {
  326. span: 6,
  327. label: '单据编号',
  328. prop: 'orderNumber',
  329. component: 'by-input',
  330. compConfig: {
  331. attr: {
  332. placeholder: '请输入单据编号',
  333. clearable: true
  334. }
  335. }
  336. },
  337. {
  338. span: 6,
  339. label: '机构名称',
  340. prop: 'organizationName',
  341. component: 'by-input',
  342. compConfig: {
  343. attr: {
  344. placeholder: '请输入机构名称',
  345. clearable: true
  346. },
  347. },
  348. },
  349. {
  350. span: 6,
  351. label: '财务系统单据',
  352. prop: 'financeOrderId',
  353. component: 'by-input',
  354. compConfig: {
  355. attr: {
  356. placeholder: '请输入财务系统单据',
  357. clearable: true
  358. },
  359. },
  360. },
  361. ],
  362. ]
  363. },
  364. tool: {
  365. tools: {
  366. smt: true,
  367. delete: true,
  368. search: true,
  369. refresh: true
  370. }
  371. },
  372. table: {
  373. attr: {
  374. height: 620,
  375. size: 'mini',
  376. seq: true,
  377. align: 'left',
  378. checkbox: true
  379. },
  380. columns: [
  381. {
  382. width: 200,
  383. title: '单据编号',
  384. field: 'orderNumber',
  385. isDetail: true,
  386. fixed: 'left'
  387. },
  388. {
  389. width: 200,
  390. title: '机构名称',
  391. field: 'organizationName',
  392. },
  393. {
  394. width: 200,
  395. title: '财务系统单据',
  396. field: 'financeOrderId',
  397. },
  398. {
  399. width: 200,
  400. title: 'WMS编号',
  401. field: 'wmsId',
  402. },
  403. {
  404. width: 120,
  405. title: '经办人',
  406. field: 'operator',
  407. },
  408. {
  409. width: 250,
  410. title: '备注',
  411. field: 'remark',
  412. },
  413. {
  414. width: 110,
  415. title: '操作',
  416. action: true,
  417. plugins: [{
  418. icon: 'el-icon-edit',
  419. name: '编辑',
  420. audit: '',
  421. event: {
  422. click: (e : any) => {
  423. (this as any).openEdit(e)
  424. }
  425. }
  426. }, {
  427. name: '删除',
  428. event: {
  429. click: (item : any) => (this as any).doDelete2(item)
  430. }
  431. }]
  432. }
  433. ]
  434. }
  435. },
  436. // 综合
  437. all: {
  438. search: {
  439. attr: {
  440. size: 'mini',
  441. },
  442. columns: [
  443. [
  444. {
  445. span: 6,
  446. label: '单据编号',
  447. prop: 'orderNumber',
  448. component: 'by-input',
  449. compConfig: {
  450. attr: {
  451. placeholder: '请输入单据编号',
  452. clearable: true
  453. }
  454. }
  455. },
  456. {
  457. span: 6,
  458. label: '机构名称',
  459. prop: 'organizationName',
  460. component: 'by-input',
  461. compConfig: {
  462. attr: {
  463. placeholder: '请输入机构名称',
  464. clearable: true
  465. },
  466. },
  467. },
  468. {
  469. span: 6,
  470. label: '财务系统单据',
  471. prop: 'financeOrderId',
  472. component: 'by-input',
  473. compConfig: {
  474. attr: {
  475. placeholder: '请输入财务系统单据',
  476. clearable: true
  477. },
  478. },
  479. },
  480. ],
  481. ]
  482. },
  483. tool: {
  484. tools: {
  485. add: true,
  486. delete: true,
  487. search: true,
  488. refresh: true
  489. }
  490. },
  491. table: {
  492. attr: {
  493. height: 620,
  494. size: 'mini',
  495. seq: true,
  496. align: 'left',
  497. checkbox: true
  498. },
  499. columns: [
  500. {
  501. width: 200,
  502. title: '单据编号',
  503. field: 'orderNumber',
  504. isDetail: true,
  505. fixed: 'left'
  506. },
  507. {
  508. width: 200,
  509. title: '机构名称',
  510. field: 'organizationName',
  511. },
  512. {
  513. width: 200,
  514. title: '财务系统单据',
  515. field: 'financeOrderId',
  516. },
  517. {
  518. width: 200,
  519. title: 'WMS编号',
  520. field: 'wmsId',
  521. },
  522. {
  523. width: 120,
  524. title: '经办人',
  525. field: 'operator',
  526. },
  527. {
  528. width: 250,
  529. title: '备注',
  530. field: 'remark',
  531. },
  532. {
  533. width: 120,
  534. title: '操作',
  535. action: true,
  536. plugins: [{
  537. icon: 'el-icon-edit',
  538. name: '编辑',
  539. audit: '',
  540. event: {
  541. click: (e : any) => {
  542. (this as any).openEdit(e)
  543. }
  544. }
  545. }, {
  546. name: '删除',
  547. event: {
  548. click: (item : any) => (this as any).doDelete2(item)
  549. }
  550. }]
  551. }
  552. ]
  553. }
  554. },
  555. // 回收站
  556. recycleBin: {
  557. search: {
  558. attr: {
  559. size: 'mini',
  560. },
  561. columns: [
  562. [
  563. {
  564. span: 6,
  565. label: '单据编号',
  566. prop: 'orderNumber',
  567. component: 'by-input',
  568. compConfig: {
  569. attr: {
  570. placeholder: '请输入单据编号',
  571. clearable: true
  572. }
  573. }
  574. },
  575. {
  576. span: 6,
  577. label: '机构名称',
  578. prop: 'organizationName',
  579. component: 'by-input',
  580. compConfig: {
  581. attr: {
  582. placeholder: '请输入机构名称',
  583. clearable: true
  584. },
  585. },
  586. },
  587. {
  588. span: 6,
  589. label: '财务系统单据',
  590. prop: 'financeOrderId',
  591. component: 'by-input',
  592. compConfig: {
  593. attr: {
  594. placeholder: '请输入财务系统单据',
  595. clearable: true
  596. },
  597. },
  598. },
  599. ],
  600. ]
  601. },
  602. tool: {
  603. tools: {
  604. search: true,
  605. refresh: true
  606. }
  607. },
  608. table: {
  609. attr: {
  610. height: 620,
  611. size: 'mini',
  612. seq: true,
  613. align: 'left',
  614. checkbox: true
  615. },
  616. columns: [
  617. {
  618. width: 200,
  619. title: '单据编号',
  620. field: 'orderNumber',
  621. isDetail: true,
  622. fixed: 'left'
  623. },
  624. {
  625. width: 200,
  626. title: '机构名称',
  627. field: 'organizationName',
  628. },
  629. {
  630. width: 200,
  631. title: '财务系统单据',
  632. field: 'financeOrderId',
  633. },
  634. {
  635. width: 200,
  636. title: 'WMS编号',
  637. field: 'wmsId',
  638. },
  639. {
  640. width: 120,
  641. title: '经办人',
  642. field: 'operator',
  643. },
  644. {
  645. width: 250,
  646. title: '备注',
  647. field: 'remark',
  648. },
  649. {
  650. width: 110,
  651. title: '操作',
  652. action: true,
  653. plugins: [{
  654. // icon: 'el-icon-edit',
  655. name: '查看',
  656. audit: '',
  657. event: {
  658. click: (e : any) => {
  659. (this as any).setReadonly(e)
  660. }
  661. }
  662. }]
  663. }
  664. ]
  665. }
  666. }
  667. }
  668. created() {
  669. this.timer = setInterval(() => {
  670. this.getDataList()
  671. }, 500)
  672. }
  673. // 获取机构数据
  674. getSupplierModal(e : any) {
  675. this.supplierInfo = e;
  676. }
  677. // 获取业务类型
  678. getbusinessType(e : any) {
  679. console.log(e);
  680. this.businessType = e;
  681. }
  682. // 监听表格数据变化
  683. onChangeRow(e : any) {
  684. e.totalPrice = parseFloat((e.number * e.unitPrice).toFixed(2));
  685. }
  686. // 确定商品新增
  687. confirmProduct(e : any) {
  688. let contents : any = [], goodsData = e, newArr : any = [], obj : any = {};
  689. goodsData = goodsData.map((item : any) => {
  690. item.materialName = item.skuTitle
  691. item.prePrice = 0
  692. // item.materialId = item.materialId
  693. item.unitPrice = item.price
  694. item.materialSku = item.id
  695. const { id, ...newData } = item
  696. // const { skuTitle, price, id, materialId, ...newData } = item
  697. return newData
  698. })
  699. this.tableData = this.tableData.concat(goodsData);
  700. newArr = this.tableData.reduce((prev : any, current : any) => {
  701. // console.log('prev ==> ', prev);
  702. // console.log('current ==> ', current);
  703. obj[current.materialSku] ? contents.push(current.materialName) : (obj[current.materialSku] = true && prev.push(current))
  704. return prev
  705. }, []);
  706. this.tableData = newArr;
  707. this.tableData.map((v : any, i : any) => {
  708. v.dataIndex = i
  709. if (!v.prePrice) v.prePrice = '0';
  710. });
  711. if (contents.length > 0) {
  712. this.$alert('商品 “' + contents + '” 已存在!', '提示', {
  713. confirmButtonText: '确定',
  714. });
  715. };
  716. (this.$refs.bill as any).setBillTableValue(this.tableData, 0);// 设置第1张单据表格数据
  717. }
  718. // 保存
  719. onSave(e : any) {
  720. // console.log('保存 ==>', this.tabType);
  721. (this as any).$refs.bill.$refs.billForm.validate().then(() => {
  722. let query = (this.$refs.bill as any).getBillFormValue(); // 获取单据数据
  723. // 供应商数据
  724. if (!query.organizationName) query.organizationName = this.supplierInfo.name;
  725. if (!query.organizationId) query.organizationId = this.supplierInfo.id;
  726. if (!query.businessType) query.businessType = this.businessType;
  727. if (!query.organizationName) return this.$message.warning('请选择机构名称');
  728. if (!query.businessType) return this.$message.warning('请选择业务类型');
  729. // 子表数据
  730. query.suborderList = this.tableData;
  731. if (query.suborderList.length > 0) {
  732. for (let v of query.suborderList) {
  733. if (!v.number || v.number <= 0) return this.$message.warning('请输入正确物料数量');
  734. if (!v.unitPrice || v.unitPrice <= 0) return this.$message.warning('请输入正确物料单价');
  735. if (v.prePrice.length <= 0 || v.prePrice < 0) return this.$message.warning('请输入正确优惠金额');
  736. if (query.id) v.taskOrderId = query.id;
  737. v.storehouseName = '我是仓库';
  738. v.storehouseId = 2;
  739. v.storingLocationName = '我是仓位';
  740. v.storingLocationId = 4;
  741. }
  742. };
  743. // 表格删除
  744. query.suborderList.map((v : any, i : any) => {
  745. if (v.isDeleted === 1 && !v.id) {
  746. query.suborderList.splice(i, 1)
  747. }
  748. });
  749. console.log('保存参数query ==> ', query);
  750. if (this.isAdd) {
  751. api.saveList(query, 'supplyEntryOrder').then((res : any) => {
  752. if (res.code === 200) {
  753. this.$message.success(res.msg);
  754. this.getDataList();
  755. (this.$refs.bill as any).showTab = 'all';
  756. (this.$refs.bill as any).setBillFormValue({});
  757. } else this.$message.error(res.msg);
  758. })
  759. } else if (this.tabType === 'all' || this.tabType === 'draftsBox') {
  760. if (this.tabType === 'draftsBox') query.submitState = 0;
  761. console.log('保存 ==>', query);
  762. api.updateList(query, 'supplyEntryOrder').then((res : any) => {
  763. if (res.code === 200) {
  764. this.$message.success(res.msg);
  765. this.getDataList();
  766. (this.$refs.bill as any).showTab = 'all';
  767. (this.$refs.bill as any).setBillFormValue({});
  768. } else this.$message.error(res.msg);
  769. })
  770. };
  771. })
  772. }
  773. // 打开新增
  774. onAdd(e : any) {
  775. console.log('新增 ==>', e);
  776. if (e === 'billTable_0') {
  777. (this.$refs.product as any).setShow(true); // 打开sku弹窗
  778. let obj = (this.$refs.bill as any).getBillFormValue();
  779. if (!this.tableData) this.tableData = obj.suborderList;
  780. console.log('this.tableData ==> ', this.tableData);
  781. (this.$refs.bill as any).setBillTableValue(this.tableData, 0);// 设置第1张单据表格数据
  782. } else {
  783. let billConfig = (this as any).$lodash.cloneDeep(this.config.bill);
  784. billConfig.form.attr.readonly = false; // 设置只读
  785. billConfig.tool.tools = { save: true, };
  786. if (e === 'all') {
  787. billConfig.tool.tools = { save: true, smt: true };
  788. this.tableData = [];
  789. (this.$refs.bill as any).setBillTableValue(this.tableData, 0);// 设置第1张单据表格数据
  790. }
  791. billConfig.tableConfig[0].tool.tools = { add: true };
  792. this.isAdd = true;
  793. (this.$refs.bill as any).setBillConfig(billConfig);
  794. (this.$refs.bill as any).setBillFormValue({}); // 设置单据表单数据
  795. };
  796. (this.$refs.bill as any).showTab = 'bill';
  797. }
  798. // 打开编辑
  799. openEdit(e : any) {
  800. console.log('编辑this.tabType ==>', this.tabType);
  801. if (this.tabType === 'all' || this.tabType === 'draftsBox') {
  802. e = e.row ? e.row : e;
  803. console.log('编辑 ==>', e);
  804. if (this.tabType === 'all' && e.submitState === 1) return this.setReadonly(e);
  805. let data = e.suborderList
  806. data.map((v : any, i : any) => {
  807. v.dataIndex = i;
  808. if (!v.prePrice) v.prePrice = '0';
  809. v.towInOne = v.storehouseName + ',' + v.storingLocationName; // 仓库仓位
  810. });
  811. let billConfig = (this as any).$lodash.cloneDeep(this.config.bill);
  812. if (billConfig.tableConfig[0].table.columns.at(-1).title != '操作') {
  813. billConfig.tableConfig[0].table.columns.push({
  814. width: 90,
  815. title: '操作',
  816. action: true,
  817. plugins: [{
  818. icon: 'el-icon-delete',
  819. name: '删除',
  820. audit: '',
  821. event: {
  822. click: (item : any) => {
  823. (this as any).changeTable(item)
  824. }
  825. }
  826. }]
  827. })
  828. };
  829. billConfig.form.attr.readonly = false; // 设置只读
  830. billConfig.tool.tools = { save: true, };
  831. if (this.tabType === 'draftsBox' || e.submitState === 0) billConfig.tool.tools = { save: true, smt: true };
  832. billConfig.tableConfig[0].tool.tools = { add: true };
  833. this.tableData = data;
  834. (this.$refs.bill as any).setBillConfig(billConfig);
  835. (this.$refs.bill as any).setBillFormValue(e);// 设置单据表单数据
  836. (this.$refs.bill as any).setBillTableValue(data, 0);// 设置第1张单据表格数据
  837. this.isAdd = false;
  838. (this.$refs.bill as any).showTab = 'bill';
  839. } else {
  840. this.setReadonly(e.row ? e.row : e);
  841. };
  842. }
  843. // 设置只读
  844. setReadonly(e : any) {
  845. let readonly = (this as any).$lodash.cloneDeep(this.config.bill);
  846. readonly.form.attr.readonly = true; // 设置只读
  847. readonly.tool.tools = {};
  848. readonly.tableConfig[0].table.columns = readonly.tableConfig[0].table.columns.filter((v : any) => v.title != '操作');
  849. readonly.tableConfig[0].tool.tools = {};
  850. console.log(readonly.tableConfig[0].table.columns.slice(0, -1));
  851. let data = e.suborderList;
  852. (this.$refs.bill as any).setBillConfig(readonly);
  853. (this.$refs.bill as any).setBillFormValue(e);// 设置单据表单数据
  854. (this.$refs.bill as any).setBillTableValue(data, 0);// 设置第1张单据表格数据
  855. this.isAdd = false;
  856. (this.$refs.bill as any).showTab = 'bill';
  857. }
  858. // 切换tab栏
  859. clickTab(e : any) {
  860. console.log('切换tab ==> ', e);
  861. this.tabType = e;
  862. // submitState: 提交状态
  863. if (e === 'all') this.getPageList({ pageSize: 10, pageNo: 1 }, 'all'); // 草稿箱数据
  864. if (e === 'draftsBox') this.getPageList({ submitState: 0 }, 'draftsBox'); // 草稿箱数据
  865. if (e === 'smt') this.getPageList({ submitState: 1 }, 'smt'); // 已提交数据
  866. if (e === 'recycleBin') this.getSelectDeleteList({ pageNo: 1, pageSize: 10 }); // 回收站数据
  867. }
  868. // 初始化
  869. getDataList() {
  870. if (!this.$refs.bill) {
  871. if (this.timeNum > 5) {
  872. clearInterval(this.timer)
  873. }
  874. this.timeNum++;
  875. return
  876. }
  877. clearInterval(this.timer)
  878. this.getPageList({ pageSize: 10, pageNo: 1 }, 'all'); // 综合数据
  879. }
  880. // 分页
  881. pagination(e : any) {
  882. console.log('分页 ==> ', e);
  883. let query : any = (this as any).$refs.bill.getSearchValue(e.type);
  884. query.pageNo = e.page.pageNum;
  885. query.pageSize = e.page.pageSize;
  886. let loading = this.$loading({ target: '.main-container' });
  887. if (e.type === 'recycleBin') {
  888. api.selectDeleteList(query, 'supplyEntryOrder').then((res : any) => {
  889. if (res.code === 200) {
  890. (this.$refs.bill as any).setTabTableValue('recycleBin', res.data.records);
  891. loading.close()
  892. } else this.failHandle(res)
  893. });
  894. } else {
  895. api.pageList(query, 'supplyEntryOrder').then((res : any) => {
  896. if (res.code === 200) {
  897. (this.$refs.bill as any).setTabTableValue(e.type, res.data.records);
  898. loading.close()
  899. } else this.failHandle(res)
  900. })
  901. }
  902. }
  903. // 获取分页数据
  904. getPageList(query : any, type : any) {
  905. api.pageList(query, 'supplyEntryOrder').then((res : any) => {
  906. if (res.code === 200) {
  907. (this.$refs.bill as any).setTabTableValue(type, res.data.records);
  908. let page = {
  909. pageNo: res.data.current, //当前页
  910. pageSize: res.data.size, //每页条数
  911. total: res.data.total //总条数
  912. };
  913. (this.$refs.bill as any).setTablePage(type, page)
  914. } else this.failHandle(res)
  915. })
  916. }
  917. // 回收站数据
  918. getSelectDeleteList(query : any) {
  919. api.selectDeleteList(query, 'supplyEntryOrder').then((res : any) => {
  920. if (res.code === 200) {
  921. (this.$refs.bill as any).setTabTableValue('recycleBin', res.data.records);
  922. let page = {
  923. pageNo: res.data.current, //当前页
  924. pageSize: res.data.size, //每页条数
  925. total: res.data.total //总条数
  926. };
  927. (this.$refs.bill as any).setTablePage('recycleBin', page)
  928. } else this.failHandle(res)
  929. });
  930. }
  931. // 搜索
  932. search(parames : any) {
  933. let query = parames.value
  934. if (parames.type === 'draftsBox') query.submitState = 0 // 草稿箱数据
  935. if (parames.type === 'smt') query.submitState = 1 // 已提交数据
  936. console.log('搜索 ==> ', query);
  937. this.getPageList(query, parames.type) // 获取分页数据
  938. }
  939. // 刷新/重置
  940. resert(e : any) {
  941. let data:any = e.type ? e.type : e;
  942. (this as any).$refs.bill.$refs[data].clearSearch();
  943. if (data === 'all') this.getPageList({}, 'all'); // 综合数据
  944. if (data === 'draftsBox') this.getPageList({ submitState: 0 }, 'draftsBox'); // 草稿箱数据
  945. if (data === 'smt') this.getPageList({ submitState: 1 }, 'smt'); // 已提交数据
  946. if (data === 'recycleBin') this.getSelectDeleteList({}) // 回收站数据
  947. }
  948. // 单据表格删除
  949. changeTable(item : any) {
  950. this.$confirm('确定删除吗!', '注意', {
  951. confirmButtonText: '确定',
  952. cancelButtonText: '取消',
  953. type: 'warning',
  954. center: true
  955. }).then(() => {
  956. this.tableData[item.dataIndex].isDeleted = 1;
  957. let newData = this.tableData.filter((res : any) => res.isDeleted === 0);
  958. console.log('原表格数据 ==> ', this.tableData);
  959. console.log('新表格数据 ==> ', newData);
  960. (this.$refs.bill as any).setBillTableValue(newData, 0);// 设置第1张单据表格数据
  961. this.$message.success('删除成功');
  962. }).catch(() => this.$message.info('已取消删除'));
  963. }
  964. // 工具栏删除
  965. onDelete(e : any) {
  966. console.log('工具栏删除 ==> ', e);
  967. let selectData = (this.$refs.bill as any).getTableSelectData(e)
  968. let ids = '';
  969. if (selectData.length > 0) {
  970. selectData.map((v : any) => {
  971. ids += v.id + ','
  972. })
  973. } else return this.$message({ type: 'warning', message: '请选择删除数据' })
  974. ids = ids.slice(0, ids.length - 1);
  975. this.$confirm('确定删除吗,此操作不能撤销!', '注意', {
  976. confirmButtonText: '确定',
  977. cancelButtonText: '取消',
  978. type: 'warning',
  979. center: true
  980. }).then(() => {
  981. api.deleteList({ ids: ids }, 'supplyEntryOrder').then((res : any) => {
  982. if (res.code === 200) {
  983. this.clickTab(this.tabType);
  984. this.$message.success('删除成功!');
  985. } else this.failHandle(res)
  986. })
  987. }).catch(() => this.$message.info('已取消删除'));
  988. }
  989. // 操作删除
  990. doDelete2(item : any) {
  991. this.$confirm('确定删除吗,此操作不能撤销!', '注意', {
  992. confirmButtonText: '确定',
  993. cancelButtonText: '取消',
  994. type: 'warning',
  995. center: true
  996. }).then(() => {
  997. api.deleteList({ ids: item.id }, 'supplyEntryOrder').then((res : any) => {
  998. if (res.code === 200) {
  999. this.clickTab(this.tabType);
  1000. this.$message.success('删除成功!');
  1001. } else this.failHandle(res)
  1002. })
  1003. }).catch(() => this.$message.info('已取消删除'));
  1004. }
  1005. // 运行错误
  1006. failHandle(err : any) {
  1007. let msg = err.msg ? err.msg : '运行错误!';
  1008. this.$message.error(msg)
  1009. }
  1010. }
  1011. </script>