index.vue 44 KB

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