index.vue 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361
  1. <template>
  2. <div>
  3. <by-bill ref="bill" :propConfig="config" @search="search" @onSmt="onSmt" @onDelete="onDelete" @onRefresh="resert"
  4. @resert="resert" @detail="openEdit" @onSave="onSave" @clickTab="clickTab" @onChangeRow="onChangeRow"
  5. @pagination="pagination" @onReturnSmt="onReturnSmt2" @getSupplierModal="getSupplierModal">
  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 BusinessType from "./components/businessType.vue";
  16. import towInOne from "../warehousing/components/towInOne.vue";
  17. @Component({ components: { productModal } })
  18. export default class OrderTask extends Vue {
  19. // 左边
  20. tabType : any = 'all';
  21. isAdd : any = false;
  22. baseInfo : any = {};
  23. isSubmit : any = false
  24. isChange : any = false
  25. dataId : any = ''
  26. // 右边
  27. supplierInfo : any = {} // 机构信息
  28. businessType : any = '' // 业务类型
  29. tableData : any = []
  30. timeNum = 0;
  31. timer : any = null
  32. config : any = {
  33. attr: {
  34. activeName: 'all',
  35. calculateH: true
  36. },
  37. // 引单
  38. source: [
  39. {
  40. title: '销售订单',
  41. search: {
  42. attr: {
  43. size: 'mini',
  44. },
  45. columns: [
  46. [
  47. {
  48. span: 6,
  49. label: '单据编号',
  50. prop: 'orderNumber',
  51. component: 'by-input',
  52. compConfig: {
  53. attr: {
  54. placeholder: '请输入单据编号',
  55. clearable: true
  56. }
  57. }
  58. },
  59. ],
  60. ]
  61. },
  62. tool: {
  63. tools: {
  64. search: true,
  65. refresh: true
  66. },
  67. customTools: [
  68. {
  69. name: '引单', icon: 'el-icon-bottom', audit: [''], event: {
  70. click: () => {
  71. (this as any).citationOrder()
  72. }
  73. }
  74. },
  75. ]
  76. },
  77. table: {
  78. attr: {
  79. size: 'mini',
  80. seq: true,
  81. align: 'left',
  82. radio: true,
  83. triggerRowCheck: 'row'
  84. },
  85. columns: [
  86. {
  87. width: 144,
  88. title: '单据编号',
  89. field: 'orderNumber',
  90. },
  91. {
  92. width: 120,
  93. title: '收货人',
  94. field: 'consignee',
  95. },
  96. {
  97. width: 144,
  98. title: '财务编号',
  99. field: 'financeOrderId',
  100. },
  101. {
  102. width: 120,
  103. title: '联系方式',
  104. field: 'phone',
  105. },
  106. {
  107. width: 150,
  108. title: '计划交货时间',
  109. field: 'planDeliveryData',
  110. },
  111. {
  112. width: 150,
  113. title: '确定交货时间',
  114. field: 'affirmDeliveryData',
  115. },
  116. {
  117. width: 150,
  118. title: '交货地点',
  119. field: 'address',
  120. }
  121. ]
  122. }
  123. },
  124. ],
  125. // 单据
  126. bill: {
  127. tool: {
  128. tools: {
  129. save: true,
  130. }
  131. },
  132. log: {
  133. request: {
  134. url: '/supply/supplyOutOrderOperateLog/page',
  135. method: 'GET'
  136. }
  137. },
  138. form: {
  139. attr: {
  140. size: 'medium',
  141. readonly: false,
  142. rules: {
  143. operator: [{
  144. required: true, message: '请输入经办人', trigger: 'blur'
  145. }],
  146. businessType: [{
  147. required: true, message: '请选择业务类型', trigger: 'change'
  148. }],
  149. }
  150. },
  151. columns: [
  152. [
  153. {
  154. span: 8,
  155. label: '单据编号',
  156. prop: 'outOrderNo',
  157. component: 'by-input',
  158. compConfig: {
  159. attr: {
  160. readonly: true
  161. },
  162. }
  163. },
  164. {
  165. span: 8,
  166. label: '经办人',
  167. prop: 'operator',
  168. component: 'by-input',
  169. },
  170. {
  171. span: 8,
  172. label: '收货人',
  173. prop: 'receive',
  174. component: 'by-input',
  175. },
  176. {
  177. span: 8,
  178. label: '收货地址',
  179. prop: 'receiveAddress',
  180. component: 'by-input',
  181. },
  182. {
  183. span: 8,
  184. label: '联系方式',
  185. prop: 'receivePhone',
  186. component: 'by-input',
  187. },
  188. {
  189. span: 8,
  190. label: 'WMS编号',
  191. prop: 'wmsId',
  192. component: 'by-input',
  193. compConfig: {
  194. attr: {
  195. readonly: true,
  196. },
  197. }
  198. },
  199. {
  200. span: 8,
  201. label: '业务类型',
  202. prop: 'businessType',
  203. component: BusinessType,
  204. },
  205. ],
  206. [
  207. {
  208. span: 28,
  209. label: '备注',
  210. slot: true,
  211. prop: 'remark',
  212. component: 'by-input',
  213. compConfig: {
  214. attr: {
  215. placeholder: '请输入备注',
  216. type: 'textarea'
  217. },
  218. }
  219. },
  220. ]
  221. ]
  222. },
  223. tableConfig: [
  224. {
  225. table: {
  226. attr: {
  227. size: 'mini',
  228. align: 'left',
  229. readonly: true,
  230. },
  231. columns:
  232. [{
  233. width: 278,
  234. title: '物料名称',
  235. field: 'materialName',
  236. },
  237. {
  238. width: 200,
  239. title: '财务编号',
  240. field: 'financeSuborderId',
  241. },
  242. {
  243. width: 200,
  244. title: '仓库,仓位',
  245. field: 'towInOne',
  246. component: towInOne,
  247. compConfig: {
  248. isSelect: true
  249. }
  250. },
  251. {
  252. width: 100,
  253. title: '单位',
  254. field: 'unit',
  255. },
  256. {
  257. width: 120,
  258. title: '单位编码',
  259. field: 'unitCode',
  260. },
  261. {
  262. width: 100,
  263. title: '库存',
  264. field: 'inventory',
  265. },
  266. {
  267. width: 100,
  268. title: '数量',
  269. field: 'number',
  270. component: 'by-input',
  271. compConfig: {
  272. attr: {
  273. size: 'mini',
  274. type: 'number',
  275. defaultValue: 1,
  276. },
  277. }
  278. },
  279. {
  280. width: 100,
  281. title: '应出数量',
  282. field: 'deliveryNumber',
  283. },
  284. {
  285. width: 110,
  286. title: '出库数量',
  287. field: 'outNumber',
  288. },
  289. {
  290. width: 100,
  291. title: '单价',
  292. field: 'unitPrice',
  293. component: 'by-input',
  294. compConfig: {
  295. attr: {
  296. size: 'mini',
  297. type: 'number',
  298. },
  299. }
  300. },
  301. {
  302. width: 100,
  303. title: '优惠金额',
  304. field: 'prePrice',
  305. },
  306. {
  307. width: 100,
  308. title: '合计金额',
  309. field: 'totalPrice',
  310. },
  311. {
  312. width: 90,
  313. title: '操作',
  314. action: true,
  315. plugins: [{
  316. icon: 'el-icon-delete',
  317. name: '删除',
  318. audit: '',
  319. event: {
  320. click: (item : any) => {
  321. (this as any).changeTable(item)
  322. }
  323. }
  324. }]
  325. },
  326. ]
  327. }
  328. }
  329. ]
  330. },
  331. // 已提交
  332. smt: {
  333. search: {
  334. attr: {
  335. size: 'mini',
  336. },
  337. columns: [
  338. [
  339. {
  340. span: 6,
  341. label: '单据编号',
  342. prop: 'outOrderNo',
  343. component: 'by-input',
  344. compConfig: {
  345. attr: {
  346. placeholder: '请输入单据编号',
  347. clearable: true
  348. }
  349. }
  350. },
  351. ],
  352. ]
  353. },
  354. tool: {
  355. tools: {
  356. search: true,
  357. refresh: true
  358. }
  359. },
  360. table: {
  361. attr: {
  362. size: 'mini',
  363. seq: true,
  364. align: 'left',
  365. checkbox: true
  366. },
  367. columns: [
  368. {
  369. width: 150,
  370. title: '单据编号',
  371. field: 'outOrderNo',
  372. isDetail: true,
  373. fixed: 'left'
  374. },
  375. {
  376. width: 150,
  377. title: '财务编号',
  378. field: 'financeOrderId',
  379. },
  380. {
  381. width: 150,
  382. title: 'WMS编号',
  383. field: 'wmsId',
  384. },
  385. {
  386. width: 120,
  387. title: '经办人',
  388. field: 'operator',
  389. },
  390. {
  391. width: 120,
  392. title: '收货人',
  393. field: 'receive',
  394. },
  395. {
  396. width: 120,
  397. title: '收货地址',
  398. field: 'receiveAddress',
  399. },
  400. {
  401. width: 120,
  402. title: '联系方式',
  403. field: 'receivePhone',
  404. },
  405. {
  406. width: 120,
  407. title: '业务类型',
  408. field: 'businessType',
  409. },
  410. {
  411. width: 110,
  412. title: '操作',
  413. action: true,
  414. plugins: [{
  415. // icon: 'el-icon-edit',
  416. name: '查看',
  417. audit: '',
  418. event: {
  419. click: (e : any) => {
  420. (this as any).setReadonly(e)
  421. }
  422. }
  423. }, {
  424. name: '反提交',
  425. event: {
  426. click: (item : any) => (this as any).onReturnSmt(item)
  427. }
  428. }]
  429. }
  430. ]
  431. }
  432. },
  433. // 草稿箱
  434. draftsBox: {
  435. search: {
  436. attr: {
  437. size: 'mini',
  438. },
  439. columns: [
  440. [
  441. {
  442. span: 6,
  443. label: '单据编号',
  444. prop: 'outOrderNo',
  445. component: 'by-input',
  446. compConfig: {
  447. attr: {
  448. placeholder: '请输入单据编号',
  449. clearable: true
  450. }
  451. }
  452. },
  453. ],
  454. ]
  455. },
  456. tool: {
  457. tools: {
  458. smt: true,
  459. delete: true,
  460. search: true,
  461. refresh: true
  462. }
  463. },
  464. table: {
  465. attr: {
  466. size: 'mini',
  467. seq: true,
  468. align: 'left',
  469. checkbox: true
  470. },
  471. columns: [
  472. {
  473. width: 150,
  474. title: '单据编号',
  475. field: 'outOrderNo',
  476. isDetail: true,
  477. fixed: 'left'
  478. },
  479. {
  480. width: 150,
  481. title: '财务编号',
  482. field: 'financeOrderId',
  483. },
  484. {
  485. width: 150,
  486. title: 'WMS编号',
  487. field: 'wmsId',
  488. },
  489. {
  490. width: 120,
  491. title: '经办人',
  492. field: 'operator',
  493. },
  494. {
  495. width: 120,
  496. title: '收货人',
  497. field: 'receive',
  498. },
  499. {
  500. width: 120,
  501. title: '收货地址',
  502. field: 'receiveAddress',
  503. },
  504. {
  505. width: 120,
  506. title: '联系方式',
  507. field: 'receivePhone',
  508. },
  509. {
  510. width: 120,
  511. title: '业务类型',
  512. field: 'businessType',
  513. },
  514. {
  515. width: 110,
  516. title: '操作',
  517. action: true,
  518. plugins: [{
  519. icon: 'el-icon-edit',
  520. name: '编辑',
  521. audit: '',
  522. event: {
  523. click: (e : any) => {
  524. (this as any).openEdit(e)
  525. }
  526. }
  527. }, {
  528. name: '删除',
  529. event: {
  530. click: (item : any) => (this as any).doDelete2(item)
  531. }
  532. }]
  533. }
  534. ]
  535. }
  536. },
  537. // 综合
  538. all: {
  539. search: {
  540. attr: {
  541. size: 'mini',
  542. },
  543. columns: [
  544. [
  545. {
  546. span: 6,
  547. label: '单据编号',
  548. prop: 'outOrderNo',
  549. component: 'by-input',
  550. compConfig: {
  551. attr: {
  552. placeholder: '请输入单据编号',
  553. clearable: true
  554. }
  555. }
  556. },
  557. ],
  558. ]
  559. },
  560. tool: {
  561. tools: {
  562. search: true,
  563. refresh: true
  564. },
  565. customTools: [
  566. {
  567. name: '出库', icon: 'el-icon-top', audit: [''], event: {
  568. click: () => {
  569. (this as any).outbound()
  570. }
  571. }
  572. },
  573. {
  574. name: '删除', icon: 'el-icon-delete', audit: [''], event: {
  575. click: () => {
  576. (this as any).onDelete('all')
  577. }
  578. }
  579. }
  580. ]
  581. },
  582. table: {
  583. attr: {
  584. size: 'mini',
  585. seq: true,
  586. align: 'left',
  587. checkbox: true
  588. },
  589. columns: [
  590. {
  591. width: 150,
  592. title: '单据编号',
  593. field: 'outOrderNo',
  594. isDetail: true,
  595. fixed: 'left'
  596. },
  597. {
  598. width: 150,
  599. title: '财务编号',
  600. field: 'financeOrderId',
  601. },
  602. {
  603. width: 150,
  604. title: 'WMS编号',
  605. field: 'wmsId',
  606. },
  607. {
  608. width: 120,
  609. title: '经办人',
  610. field: 'operator',
  611. },
  612. {
  613. width: 120,
  614. title: '收货人',
  615. field: 'receive',
  616. },
  617. {
  618. width: 120,
  619. title: '收货地址',
  620. field: 'receiveAddress',
  621. },
  622. {
  623. width: 120,
  624. title: '联系方式',
  625. field: 'receivePhone',
  626. },
  627. {
  628. width: 120,
  629. title: '业务类型',
  630. field: 'businessType',
  631. },
  632. {
  633. width: 120,
  634. title: '操作',
  635. action: true,
  636. plugins: [{
  637. name: '查看',
  638. audit: '',
  639. event: {
  640. click: (e : any) => {
  641. (this as any).openEdit(e)
  642. }
  643. }
  644. }, {
  645. name: '删除',
  646. event: {
  647. click: (item : any) => (this as any).doDelete2(item)
  648. }
  649. }]
  650. }
  651. ]
  652. }
  653. },
  654. // 回收站
  655. recycleBin: {
  656. search: {
  657. attr: {
  658. size: 'mini',
  659. },
  660. columns: [
  661. [
  662. {
  663. span: 6,
  664. label: '单据编号',
  665. prop: 'outOrderNo',
  666. component: 'by-input',
  667. compConfig: {
  668. attr: {
  669. placeholder: '请输入单据编号',
  670. clearable: true
  671. }
  672. }
  673. },
  674. ],
  675. ]
  676. },
  677. tool: {
  678. tools: {
  679. search: true,
  680. refresh: true
  681. }
  682. },
  683. table: {
  684. attr: {
  685. size: 'mini',
  686. seq: true,
  687. align: 'left',
  688. checkbox: true
  689. },
  690. columns: [
  691. {
  692. width: 150,
  693. title: '单据编号',
  694. field: 'outOrderNo',
  695. isDetail: true,
  696. fixed: 'left'
  697. },
  698. {
  699. width: 150,
  700. title: '财务编号',
  701. field: 'financeOrderId',
  702. },
  703. {
  704. width: 150,
  705. title: 'WMS编号',
  706. field: 'wmsId',
  707. },
  708. {
  709. width: 120,
  710. title: '经办人',
  711. field: 'operator',
  712. },
  713. {
  714. width: 120,
  715. title: '收货人',
  716. field: 'receive',
  717. },
  718. {
  719. width: 120,
  720. title: '收货地址',
  721. field: 'receiveAddress',
  722. },
  723. {
  724. width: 120,
  725. title: '联系方式',
  726. field: 'receivePhone',
  727. },
  728. {
  729. width: 120,
  730. title: '业务类型',
  731. field: 'businessType',
  732. },
  733. {
  734. width: 110,
  735. title: '操作',
  736. action: true,
  737. plugins: [{
  738. name: '查看',
  739. audit: '',
  740. event: {
  741. click: (e : any) => {
  742. (this as any).openEdit(e)
  743. }
  744. }
  745. }]
  746. }
  747. ]
  748. }
  749. }
  750. }
  751. created() {
  752. this.timer = setInterval(() => {
  753. this.getDataList()
  754. }, 500)
  755. }
  756. // 引单
  757. citationOrder(e : any) {
  758. let parentData : any = (this as any).$refs.bill.getSourceTableSelectData(0);
  759. if (parentData.length <= 0) return this.$message.warning('请选择引单数据');
  760. let loading = this.$loading({ target: '.main-container' });
  761. api.single({ id: parentData[0].id }, 'supplyPurchaseOrder').then((res : any) => {
  762. if (res.code === 200) {
  763. parentData = res.data ? [res.data] : parentData;
  764. parentData = parentData.map((item : any, i : any) => {
  765. item.receiveAddress = item.address
  766. item.receive = item.consignee
  767. item.receivePhone = item.phone
  768. item.outOrderNo = item.orderNumber
  769. const { ...newData } = item
  770. return newData
  771. })
  772. let billConfig = (this as any).$lodash.cloneDeep(this.config.bill);
  773. parentData[0].suborderList.map((v : any) => {
  774. v.deliveryNumber = v.number - v.outNumber;
  775. if (v.deliveryNumber < v.number) v.number = v.deliveryNumber;
  776. });
  777. this.tableData = parentData[0].suborderList;
  778. billConfig.tool.tools = { save: true, smt: true };
  779. // console.log('this.tableData ==> ', this.tableData);
  780. // billConfig.tool.tools = { save: true };
  781. this.isAdd = true;
  782. (this.$refs.bill as any).showTab = 'bill';
  783. loading.close();
  784. setTimeout(() => {
  785. (this.$refs.bill as any).setBillConfig(billConfig);
  786. (this.$refs.bill as any).setBillFormValue(parentData[0]); // 设置单据表单数据
  787. (this.$refs.bill as any).setBillTableValue(parentData[0].suborderList, 0);// 设置第1张单据表格数据
  788. }, 0)
  789. } else loading.close();
  790. }).catch(() => loading.close());
  791. }
  792. // 获取机构数据
  793. getSupplierModal(e : any) {
  794. this.supplierInfo = e;
  795. }
  796. // 监听表格数据变化
  797. onChangeRow(e : any) {
  798. this.isChange = true;
  799. this.isSubmit = false;
  800. e.prePrice = e.prePrice ? e.prePrice : 0;
  801. e.realityPrice = parseFloat((e.number * e.unitPrice).toFixed(2));
  802. e.totalPrice = e.realityPrice - e.prePrice;
  803. }
  804. // 保存
  805. onSave(e : any) {
  806. console.log('保存 ==>', this.tabType);
  807. (this as any).$refs.bill.$refs.billForm.validate().then(() => {
  808. let query = (this.$refs.bill as any).getBillFormValue(); // 获取单据数据
  809. // 子表数据
  810. // query.suborderList = this.tableData;
  811. query.purchaseOrderId = query.id;
  812. query.suborderList = (this.$refs.bill as any).getBillTableData(0);
  813. if (query.suborderList.length > 0) {
  814. for (let v of query.suborderList) {
  815. if (!v.unitPrice || v.unitPrice <= 0) return this.$message.warning('请输入正确物料单价');
  816. if (v.deliveryNumber < v.number) return this.$message.warning('数量不能大于应出数量');
  817. if (v.number > v.inventory) return this.$message.warning('出库数量不能大于库存数量');
  818. v.taskOrderId = query.id;
  819. v.purchaseSuborderId = v.id;
  820. }
  821. };
  822. // 表格删除
  823. query.suborderList.map((v : any, i : any) => {
  824. if (v.isDeleted === 1 && !v.id) {
  825. query.suborderList.splice(i, 1)
  826. }
  827. });
  828. console.log('出库参数query ==> ', query);
  829. let loading = this.$loading({ target: '.main-container' });
  830. if (this.isAdd) {
  831. query.suborderList.map((v : any) => {
  832. delete v.id;
  833. });
  834. delete query.id;
  835. api.outbound(query, 'supplyOutOrder').then((res : any) => {
  836. loading.close();
  837. if (res.code === 200) {
  838. this.isAdd = false;
  839. this.isChange = false;
  840. this.isSubmit = true;
  841. this.$message.success('保存成功');
  842. this.dataId = res.data;
  843. } else this.$message.error(res.msg);
  844. }).catch(() => loading.close());
  845. } else {
  846. query.submitState = 0;
  847. api.updateList(query, 'supplyOutOrder').then((res : any) => {
  848. loading.close();
  849. if (res.code === 200) {
  850. this.$message.success('保存成功');
  851. this.isChange = false;
  852. this.isSubmit = true;
  853. } else this.$message.error(res.msg);
  854. }).catch(() => loading.close());
  855. };
  856. })
  857. }
  858. // 切换tab栏
  859. clickTab(e : any) {
  860. console.log('切换tab ==> ', e);
  861. this.tabType = e;
  862. (this.$refs.bill as any).showTab = e;
  863. // submitState: 提交状态
  864. if (e === 'source') { this.getCitationList({}) }; // 引单出库
  865. if (e === 'all') this.getPageList({}, 'all'); // 草稿箱数据
  866. if (e === 'draftsBox') this.getPageList({ submitState: 0 }, 'draftsBox'); // 草稿箱数据
  867. if (e === 'smt') this.getPageList({ submitState: 1 }, 'smt'); // 已提交数据
  868. if (e === 'recycleBin') this.getSelectDeleteList({}); // 回收站数据
  869. if (e === 'bill') {
  870. let billConfig = (this as any).$lodash.cloneDeep(this.config.bill);
  871. billConfig.tool.tools = {};
  872. billConfig.tool.customTools = [];
  873. (this.$refs.bill as any).setBillConfig(billConfig);
  874. }
  875. }
  876. // 出库打开引单
  877. outbound() {
  878. this.clickTab('source');
  879. }
  880. // 打开编辑
  881. openEdit(e : any) {
  882. console.log('编辑this.tabType ==>', this.tabType);
  883. console.log('编辑 ==>', e);
  884. e = e.row ? e.row : e;
  885. let loading = this.$loading({ target: '.main-container' });
  886. api.single({ id: e.id }, 'supplyOutOrder').then((res : any) => {
  887. if (res.code === 200) {
  888. let parentData = res.data ? res.data : e;
  889. this.baseInfo = parentData;
  890. if (this.tabType === 'all' || this.tabType === 'draftsBox') {
  891. if (parentData.submitState === 1) {
  892. loading.close();
  893. return this.setReadonly(parentData)
  894. }
  895. let billConfig = (this as any).$lodash.cloneDeep(this.config.bill);
  896. if (billConfig.tableConfig[0].table.columns.at(-1).title != '操作') {
  897. billConfig.tableConfig[0].table.columns.push({
  898. width: 90,
  899. title: '操作',
  900. action: true,
  901. plugins: [{
  902. icon: 'el-icon-delete',
  903. name: '删除',
  904. audit: '',
  905. event: {
  906. click: (item : any) => {
  907. (this as any).changeTable(item)
  908. }
  909. }
  910. }]
  911. })
  912. };
  913. billConfig.form.attr.readonly = false; // 设置只读
  914. billConfig.tool.tools = { save: true, };
  915. if (this.tabType === 'draftsBox' || parentData.submitState === 0) billConfig.tool.tools = { save: true, smt: true };
  916. let data : any = parentData.suborderList;
  917. let array : any = [];
  918. data.map((v : any) => {
  919. v.towInOne = v.storehouseName + ',' + v.storingLocationName; // 仓库仓位
  920. array.push({
  921. storidId: v.storingLocationId,
  922. skuid: v.materialSku,
  923. })
  924. });
  925. console.log('array', array);
  926. // 查库存
  927. api.getInventoryByStoridsAndSkuids(array).then((res : any) => {
  928. if (res.code === 200) {
  929. console.log(res);
  930. let newData : any = [];
  931. res.data.map((v : any, i : any) => {
  932. newData.push(Object.assign(data[i], v))
  933. })
  934. console.log('newData', newData);
  935. this.tableData = newData;
  936. (this.$refs.bill as any).setBillConfig(billConfig);
  937. (this.$refs.bill as any).setBillFormValue(parentData);// 设置单据表单数据
  938. (this.$refs.bill as any).setBillTableValue(newData, 0);// 设置第1张单据表格数据
  939. this.isAdd = false;
  940. this.dataId = '';
  941. (this.$refs.bill as any).showTab = 'bill';
  942. loading.close();
  943. } else loading.close();
  944. }).catch(() => loading.close());
  945. } else {
  946. loading.close();
  947. this.setReadonly(parentData);
  948. };
  949. }
  950. }).catch(() => loading.close());
  951. }
  952. // 设置只读
  953. setReadonly(e : any) {
  954. let loading = this.$loading({ target: '.main-container' });
  955. let readonly = (this as any).$lodash.cloneDeep(this.config.bill);
  956. readonly.form.attr.readonly = true; // 设置只读
  957. readonly.tool.tools = {};
  958. if (this.tabType != 'recycleBin') {
  959. if (e.submitState === 1) readonly.tool.tools = { returnSmt: true };
  960. }
  961. readonly.tableConfig[0].table.columns = readonly.tableConfig[0].table.columns.filter((v : any) => v.title != '操作');
  962. let data = e.suborderList;
  963. let array : any = [];
  964. data.map((v : any) => {
  965. v.towInOne = v.storehouseName + ',' + v.storingLocationName; // 仓库仓位
  966. array.push({
  967. storidId: v.storingLocationId,
  968. skuid: v.materialSku,
  969. })
  970. });
  971. console.log('array', array);
  972. // 查库存
  973. api.getInventoryByStoridsAndSkuids(array).then((res : any) => {
  974. loading.close();
  975. if (res.code === 200) {
  976. let newData : any = []
  977. res.data.map((v : any, i : any) => {
  978. newData.push(Object.assign(data[i], v))
  979. })
  980. console.log('newData', newData);
  981. this.tableData = newData;
  982. (this.$refs.bill as any).setBillConfig(readonly);
  983. (this.$refs.bill as any).setBillFormValue(e);// 设置单据表单数据
  984. (this.$refs.bill as any).setBillTableValue(newData, 0);// 设置第1张单据表格数据
  985. this.isAdd = false;
  986. (this.$refs.bill as any).showTab = 'bill';
  987. }
  988. }).catch(() => loading.close());
  989. }
  990. // 工具栏提交
  991. onSmt(e : any) {
  992. if (e === 'draftsBox') {
  993. let selectData = (this.$refs.bill as any).getTableSelectData('draftsBox'); // 获取表格选中数据
  994. if (selectData.length <= 0) return this.$message.warning('请选择提交数据');
  995. if (selectData.length > 1) return this.$message.warning('只能提交一条数据');
  996. this.$confirm('确定提交吗!', '注意', {
  997. confirmButtonText: '确定',
  998. cancelButtonText: '取消',
  999. type: 'warning',
  1000. center: true
  1001. }).then(() => {
  1002. let loading = this.$loading({ target: '.main-container' });
  1003. api.submitTo({ id: selectData[0].id }, 'supplyOutOrder').then((res : any) => {
  1004. loading.close();
  1005. if (res.code === 200) {
  1006. this.$message.success('提交成功');
  1007. this.clickTab('draftsBox');
  1008. } else this.$message.error(res.msg)
  1009. }).catch(() => loading.close());
  1010. }).catch(() => this.$message.info('已取消提交'));
  1011. } else {
  1012. if (this.isAdd) return this.$message.warning('新增数据必须先保存才能提交');
  1013. console.log('isChange ==> ', this.isChange);
  1014. console.log('isSubmit ==> ', this.isSubmit);
  1015. if (this.isSubmit) {
  1016. this.$confirm('确定提交吗!', '注意', {
  1017. confirmButtonText: '确定',
  1018. cancelButtonText: '取消',
  1019. type: 'warning',
  1020. center: true
  1021. }).then(() => {
  1022. let loading = this.$loading({ target: '.main-container' });
  1023. api.submitTo({ id: this.baseInfo.id }, 'supplyOutOrder').then((res : any) => {
  1024. loading.close();
  1025. if (res.code === 200) {
  1026. this.$message.success('提交成功');
  1027. this.isSubmit = false;
  1028. this.clickTab(this.tabType);
  1029. } else this.$message.error(res.msg)
  1030. }).catch(() => loading.close());
  1031. }).catch(() => this.$message.info('已取消提交'));
  1032. } else {
  1033. // 表单旧数据
  1034. let oldbillForm : any = (this as any).$lodash.cloneDeep(this.baseInfo);
  1035. if (oldbillForm.suborderList) delete oldbillForm.suborderList;
  1036. oldbillForm = JSON.stringify(oldbillForm);
  1037. // 表单新数据
  1038. let newBillForm : any = (this as any).$refs.bill.getBillFormValue();
  1039. if (newBillForm.suborderList) delete newBillForm.suborderList;
  1040. newBillForm = JSON.stringify(newBillForm);
  1041. // 表格旧数据
  1042. this.baseInfo.suborderList.map((v : any) => {
  1043. if (v._X_ROW_KEY) delete v._X_ROW_KEY;
  1044. });
  1045. let oldData : any = JSON.stringify(this.baseInfo.suborderList);
  1046. // 表格新数据
  1047. let newData : any = JSON.stringify((this as any).$refs.bill.getBillTableData(0));
  1048. // 数据有变进保存
  1049. if (this.isChange || oldbillForm != newBillForm || oldData != newData) {
  1050. return this.$message.warning('数据变更必须先保存再提交');
  1051. } else {
  1052. this.$confirm('确定提交吗!', '注意', {
  1053. confirmButtonText: '确定',
  1054. cancelButtonText: '取消',
  1055. type: 'warning',
  1056. center: true
  1057. }).then(() => {
  1058. let id = this.dataId ? this.dataId : this.baseInfo.id;
  1059. let loading = this.$loading({ target: '.main-container' });
  1060. api.submitTo({ id: id }, 'supplyOutOrder').then((res : any) => {
  1061. loading.close();
  1062. if (res.code === 200) {
  1063. this.$message.success('提交成功');
  1064. this.dataId = '';
  1065. this.clickTab(this.tabType);
  1066. } else this.$message.error(res.msg)
  1067. }).catch(() => loading.close());
  1068. }).catch(() => this.$message.info('已取消提交'));
  1069. }
  1070. }
  1071. }
  1072. }
  1073. // 操作反提交
  1074. onReturnSmt(e : any) {
  1075. console.log('反提交 ==>', e);
  1076. this.$confirm('确定反提交吗!', '注意', {
  1077. confirmButtonText: '确定',
  1078. cancelButtonText: '取消',
  1079. type: 'warning',
  1080. center: true
  1081. }).then(() => {
  1082. let loading = this.$loading({ target: '.main-container' });
  1083. api.cancelSubmission({ id: e.id }, 'supplyOutOrder').then((res : any) => {
  1084. loading.close();
  1085. if (res.code === 200) {
  1086. this.$message.success('反提交成功');
  1087. this.clickTab(this.tabType);
  1088. } else this.$message.error(res.msg)
  1089. }).catch(() => loading.close());
  1090. }).catch(() => this.$message.info('已取消反提交'));
  1091. }
  1092. // 工具栏反提交
  1093. onReturnSmt2() {
  1094. console.log('工具栏反提交 ==>', this.baseInfo);
  1095. this.$confirm('确定反提交吗!', '注意', {
  1096. confirmButtonText: '确定',
  1097. cancelButtonText: '取消',
  1098. type: 'warning',
  1099. center: true
  1100. }).then(() => {
  1101. let loading = this.$loading({ target: '.main-container' });
  1102. api.cancelSubmission({ id: this.baseInfo.id }, 'supplyOutOrder').then((res : any) => {
  1103. loading.close();
  1104. if (res.code === 200) {
  1105. this.$message.success('反提交成功');
  1106. this.clickTab(this.tabType);
  1107. } else this.$message.error(res.msg)
  1108. }).catch(() => loading.close());
  1109. }).catch(() => this.$message.info('已取消反提交'));
  1110. }
  1111. // 初始化
  1112. getDataList() {
  1113. if (!this.$refs.bill) {
  1114. if (this.timeNum > 5) {
  1115. clearInterval(this.timer)
  1116. }
  1117. this.timeNum++;
  1118. return
  1119. }
  1120. clearInterval(this.timer)
  1121. this.getPageList({}, 'all'); // 综合数据
  1122. }
  1123. // 获取引单分页数据
  1124. getCitationList(query : any) {
  1125. let loading = this.$loading({ target: '.main-container' });
  1126. api.pageList(query, 'supplyPurchaseOrder').then((res : any) => {
  1127. loading.close();
  1128. if (res.code === 200) {
  1129. (this.$refs.bill as any).setSourceTableData(0, res.data.records);
  1130. let page = {
  1131. pageNo: res.data.current, //当前页
  1132. pageSize: res.data.size, //每页条数
  1133. total: res.data.total //总条数
  1134. };
  1135. (this.$refs.bill as any).setSourcePage(0, page);
  1136. } else this.$message.error(res.msg)
  1137. }).catch(() => loading.close());
  1138. }
  1139. // 获取分页数据
  1140. getPageList(query : any, type : any) {
  1141. let data = (this.$refs.bill as any).getTablePage(this.tabType);
  1142. query.pageNo = data.pageNo;
  1143. query.pageSize = data.pageSize;
  1144. let loading = this.$loading({ target: '.main-container' });
  1145. api.pageList(query, 'supplyOutOrder').then((res : any) => {
  1146. loading.close();
  1147. if (res.code === 200) {
  1148. (this.$refs.bill as any).setTabTableValue(type, res.data.records);
  1149. let page = {
  1150. pageNo: res.data.current, //当前页
  1151. pageSize: res.data.size, //每页条数
  1152. total: res.data.total //总条数
  1153. };
  1154. (this.$refs.bill as any).setTablePage(type, page);
  1155. } else this.$message.error(res.msg)
  1156. }).catch(() => loading.close());
  1157. }
  1158. // 分页
  1159. pagination(e : any) {
  1160. console.log('分页 ==> ', e);
  1161. if (e.type === 'source_0') {
  1162. let query : any = (this as any).$refs.bill.$refs.source_0[0].getSearchValue();
  1163. query.pageNo = e.page.pageNum;
  1164. query.pageSize = e.page.pageSize;
  1165. this.getCitationList(query);
  1166. } else {
  1167. let query : any = (this as any).$refs.bill.getSearchValue(e.type);
  1168. query.pageNo = e.page.pageNum;
  1169. query.pageSize = e.page.pageSize;
  1170. let loading = this.$loading({ target: '.main-container' });
  1171. if (e.type === 'recycleBin') {
  1172. api.selectDeleteList(query, 'supplyOutOrder').then((res : any) => {
  1173. loading.close();
  1174. if (res.code === 200) {
  1175. (this.$refs.bill as any).setTabTableValue('recycleBin', res.data.records);
  1176. } else this.$message.error(res.msg)
  1177. }).catch(() => loading.close());
  1178. } else {
  1179. api.pageList(query, 'supplyOutOrder').then((res : any) => {
  1180. loading.close();
  1181. if (res.code === 200) {
  1182. (this.$refs.bill as any).setTabTableValue(e.type, res.data.records);
  1183. } else this.$message.error(res.msg)
  1184. }).catch(() => loading.close());
  1185. }
  1186. }
  1187. }
  1188. // 回收站数据
  1189. getSelectDeleteList(query : any) {
  1190. let loading = this.$loading({ target: '.main-container' });
  1191. api.selectDeleteList(query, 'supplyOutOrder').then((res : any) => {
  1192. loading.close();
  1193. if (res.code === 200) {
  1194. (this.$refs.bill as any).setTabTableValue('recycleBin', res.data.records);
  1195. let page = {
  1196. pageNo: res.data.current, //当前页
  1197. pageSize: res.data.size, //每页条数
  1198. total: res.data.total //总条数
  1199. };
  1200. (this.$refs.bill as any).setTablePage('recycleBin', page)
  1201. } else this.$message.error(res.msg)
  1202. }).catch(() => loading.close());
  1203. }
  1204. // 搜索
  1205. search(parames : any) {
  1206. console.log('搜索 ==> ', parames);
  1207. let query = parames.value;
  1208. if (parames.type === 'source_0') {
  1209. this.getCitationList(query); // 引单数据
  1210. } else {
  1211. if (parames.type === 'recycleBin') {
  1212. this.getSelectDeleteList(query); // 回收站分页数据
  1213. } else {
  1214. if (parames.type === 'draftsBox') query.submitState = 0;// 草稿箱数据
  1215. if (parames.type === 'smt') query.submitState = 1; // 已提交数据
  1216. this.getPageList(query, parames.type) // 获取分页数据
  1217. }
  1218. }
  1219. }
  1220. // 刷新/重置
  1221. resert(e : any) {
  1222. let data : any = e.type ? e.type : e;
  1223. console.log('刷新/重置 ==> ', data);
  1224. if (data === 'source_0') {
  1225. (this as any).$refs.bill.$refs.source_0[0].clearSearch();
  1226. this.getCitationList({}); // 引单数据
  1227. } else {
  1228. (this as any).$refs.bill.$refs[data].clearSearch();
  1229. if (data === 'all') this.getPageList({}, 'all'); // 综合数据
  1230. if (data === 'draftsBox') this.getPageList({ submitState: 0 }, 'draftsBox'); // 草稿箱数据
  1231. if (data === 'smt') this.getPageList({ submitState: 1 }, 'smt'); // 已提交数据
  1232. if (data === 'recycleBin') this.getSelectDeleteList({}) // 回收站数据
  1233. }
  1234. }
  1235. // 确定商品新增
  1236. confirmProduct(e : any) {
  1237. let nowData = (this.$refs.bill as any).getBillTableData(0);
  1238. let names = '';
  1239. if (e.length > 0) {
  1240. for (const item of e) {
  1241. let t = true;
  1242. for (const t_item of nowData) {
  1243. if (item.id == t_item.materialSku) {
  1244. if (!names) {
  1245. names = item.skuTitle
  1246. } else {
  1247. names = names + ',' + item.skuTitle
  1248. }
  1249. t = false;
  1250. break;
  1251. }
  1252. }
  1253. if (t) {
  1254. let obj : any = {};
  1255. obj.materialName = item.skuTitle
  1256. obj.materialId = item.materialId
  1257. obj.prePrice = 0
  1258. obj.unitPrice = item.price
  1259. obj.materialSku = item.id
  1260. obj.unit = item.unit
  1261. obj.unitCode = item.unitCode
  1262. obj.financeSuborderId = item.financialCode
  1263. obj.prePrice = "0"
  1264. obj.isDeleted = 0
  1265. this.tableData.push(obj);
  1266. nowData.push(obj);
  1267. }
  1268. }
  1269. (this.$refs.bill as any).setBillTableValue(nowData, 0);// 设置第1张单据表格数据
  1270. if (names) {
  1271. this.$alert('商品 “' + names + '”已存在!', '提示', {
  1272. confirmButtonText: '确定',
  1273. });
  1274. }
  1275. }
  1276. }
  1277. // 单据表格删除
  1278. changeTable(item : any) {
  1279. this.$confirm('确定删除吗!', '注意', {
  1280. confirmButtonText: '确定',
  1281. cancelButtonText: '取消',
  1282. type: 'warning',
  1283. center: true
  1284. }).then(() => {
  1285. let data = (this.$refs.bill as any).getBillTableData(0);
  1286. let i = -1;
  1287. let j = -1;
  1288. for (const v of data) {
  1289. i++;
  1290. if (v.materialSku == item.materialSku) {
  1291. break
  1292. }
  1293. };
  1294. console.log(this.tableData);
  1295. for (const v of this.tableData) {
  1296. j++;
  1297. if (v.materialSku == item.materialSku && item.isDeleted === 0) {
  1298. break
  1299. }
  1300. };
  1301. this.tableData[j].isDeleted = 1;
  1302. data.splice(i, 1);
  1303. (this.$refs.bill as any).setBillTableValue(data, 0);// 设置第1张单据表格数据
  1304. this.$message.success('删除成功');
  1305. }).catch(() => this.$message.info('已取消删除'));
  1306. }
  1307. // 工具栏删除
  1308. onDelete(e : any) {
  1309. console.log('工具栏删除 ==> ', e);
  1310. let selectData = (this.$refs.bill as any).getTableSelectData(e)
  1311. let ids = '';
  1312. if (selectData.length > 0) {
  1313. selectData.map((v : any) => {
  1314. ids += v.id + ','
  1315. })
  1316. } else return this.$message({ type: 'warning', message: '请选择删除数据' })
  1317. ids = ids.slice(0, ids.length - 1);
  1318. this.$confirm('确定删除吗,此操作不能撤销!', '注意', {
  1319. confirmButtonText: '确定',
  1320. cancelButtonText: '取消',
  1321. type: 'warning',
  1322. center: true
  1323. }).then(() => {
  1324. let loading = this.$loading({ target: '.main-container' });
  1325. api.deleteList({ ids: ids }, 'supplyOutOrder').then((res : any) => {
  1326. loading.close();
  1327. if (res.code === 200) {
  1328. this.$message.success('删除成功');
  1329. this.clickTab(this.tabType);
  1330. } else this.$message.error(res.msg)
  1331. }).catch(() => loading.close());
  1332. }).catch(() => this.$message.info('已取消删除'));
  1333. }
  1334. // 操作删除
  1335. doDelete2(item : any) {
  1336. this.$confirm('确定删除吗,此操作不能撤销!', '注意', {
  1337. confirmButtonText: '确定',
  1338. cancelButtonText: '取消',
  1339. type: 'warning',
  1340. center: true
  1341. }).then(() => {
  1342. let loading = this.$loading({ target: '.main-container' });
  1343. api.deleteList({ ids: item.id }, 'supplyOutOrder').then((res : any) => {
  1344. loading.close();
  1345. if (res.code === 200) {
  1346. this.$message.success('删除成功');
  1347. this.clickTab(this.tabType);
  1348. } else this.$message.error(res.msg)
  1349. }).catch(() => loading.close());
  1350. }).catch(() => this.$message.info('已取消删除'));
  1351. }
  1352. }
  1353. </script>