index.vue 36 KB

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