index.vue 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596
  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. billConfig.tableConfig[0].table.columns[7] = {
  1106. width: 120,
  1107. title: '数量',
  1108. field: 'number',
  1109. component: 'by-input',
  1110. compConfig: {
  1111. attr: {
  1112. size: 'mini',
  1113. type: 'number',
  1114. defaultValue: 1,
  1115. },
  1116. }
  1117. };
  1118. billConfig.tableConfig[0].table.columns[10] = {
  1119. width: 90,
  1120. title: '单价',
  1121. field: 'unitPrice',
  1122. component: 'by-input',
  1123. compConfig: {
  1124. attr: {
  1125. size: 'mini',
  1126. type: 'number',
  1127. },
  1128. }
  1129. };
  1130. billConfig.tool.tools = { return: true, save: true, smt: true };
  1131. // 查销售订单数据
  1132. if(e.purchaseOrderId){
  1133. api.single({ id: e.purchaseOrderId }, 'supplyPurchaseOrder').then((val : any) => {
  1134. if (val.code === 200) {
  1135. parentData.suborderList.map((v : any, i : any) => {
  1136. v.outNumber = val.data.suborderList[i].outNumber;
  1137. });
  1138. let data : any = parentData.suborderList;
  1139. let array : any = [];
  1140. data.map((v : any) => {
  1141. v.deliveryNumber = v.number - v.outNumber;
  1142. if (v.deliveryNumber < v.number) v.number = v.deliveryNumber;
  1143. v.towInOne = v.storehouseName + ',' + v.storingLocationName; // 仓库仓位
  1144. array.push({
  1145. storidId: v.storingLocationId,
  1146. skuid: v.materialSku,
  1147. })
  1148. });
  1149. // 查库存
  1150. api.getInventoryByStoridsAndSkuids(array).then((res : any) => {
  1151. if (res.code === 200) {
  1152. let newData : any = [];
  1153. res.data.map((v : any, i : any) => {
  1154. newData.push(Object.assign(data[i], v))
  1155. })
  1156. this.tableData = newData;
  1157. (this.$refs.bill as any).setBillConfig(billConfig);
  1158. (this.$refs.bill as any).setBillFormValue(parentData);// 设置单据表单数据
  1159. (this.$refs.bill as any).setBillTableValue(newData, 0);// 设置第1张单据表格数据
  1160. this.isAdd = false;
  1161. this.dataId = '';
  1162. (this.$refs.bill as any).showTab = 'bill';
  1163. loading.close();
  1164. } else loading.close();
  1165. }).catch(() => loading.close());
  1166. } else loading.close();
  1167. }).catch(() => loading.close());
  1168. }else{
  1169. let data : any = parentData.suborderList;
  1170. let array : any = [];
  1171. data.map((v : any) => {
  1172. v.deliveryNumber = v.number;
  1173. // if (v.deliveryNumber < v.number) v.number = v.deliveryNumber;
  1174. v.towInOne = v.storehouseName + ',' + v.storingLocationName; // 仓库仓位
  1175. array.push({
  1176. storidId: v.storingLocationId,
  1177. skuid: v.materialSku,
  1178. })
  1179. });
  1180. // 查库存
  1181. api.getInventoryByStoridsAndSkuids(array).then((res : any) => {
  1182. if (res.code === 200) {
  1183. let newData : any = [];
  1184. res.data.map((v : any, i : any) => {
  1185. newData.push(Object.assign(data[i], v))
  1186. })
  1187. this.tableData = newData;
  1188. (this.$refs.bill as any).setBillConfig(billConfig);
  1189. (this.$refs.bill as any).setBillFormValue(parentData);// 设置单据表单数据
  1190. (this.$refs.bill as any).setBillTableValue(newData, 0);// 设置第1张单据表格数据
  1191. this.isAdd = false;
  1192. this.dataId = '';
  1193. (this.$refs.bill as any).showTab = 'bill';
  1194. loading.close();
  1195. } else loading.close();
  1196. }).catch(() => loading.close());
  1197. }
  1198. } else {
  1199. loading.close();
  1200. this.setReadonly(parentData);
  1201. };
  1202. }
  1203. }).catch(() => loading.close());
  1204. }
  1205. // 设置只读
  1206. setReadonly(e : any) {
  1207. let parentData : any = e;
  1208. let loading = this.$loading({ target: '.main-container' });
  1209. let readonly = (this as any).$lodash.cloneDeep(this.config.bill);
  1210. readonly.form.attr.readonly = true; // 设置只读
  1211. readonly.tool.tools = { return: true, };
  1212. if (this.tabType != 'recycleBin') {
  1213. if (parentData.submitState === 1) readonly.tool.tools = { return: true, returnSmt: true, print: true };
  1214. }
  1215. readonly.tableConfig[0].table.columns = readonly.tableConfig[0].table.columns.filter((v : any) => v.title != '操作');
  1216. readonly.tableConfig[0].table.columns[7] = {
  1217. width: 120,
  1218. title: '数量',
  1219. field: 'number',
  1220. };
  1221. readonly.tableConfig[0].table.columns[10] = {
  1222. width: 90,
  1223. title: '单价',
  1224. field: 'unitPrice',
  1225. };
  1226. api.single({ id: e.purchaseOrderId }, 'supplyPurchaseOrder').then((val : any) => {
  1227. if (val.code === 200) {
  1228. // parentData.suborderList.map((v : any, i : any) => {
  1229. // v.prePrice = val.data.suborderList[i].prePrice;
  1230. // });
  1231. let data = parentData.suborderList;
  1232. let array : any = [];
  1233. data.map((v : any) => {
  1234. v.towInOne = v.storehouseName + ',' + v.storingLocationName; // 仓库仓位
  1235. array.push({
  1236. storidId: v.storingLocationId,
  1237. skuid: v.materialSku,
  1238. })
  1239. });
  1240. // 查库存
  1241. api.getInventoryByStoridsAndSkuids(array).then((res : any) => {
  1242. if (res.code === 200) {
  1243. let newData : any = []
  1244. res.data.map((v : any, i : any) => {
  1245. newData.push(Object.assign(data[i], v))
  1246. })
  1247. this.tableData = newData;
  1248. (this.$refs.bill as any).setBillConfig(readonly);
  1249. (this.$refs.bill as any).setBillFormValue(parentData);// 设置单据表单数据
  1250. (this.$refs.bill as any).setBillTableValue(newData, 0);// 设置第1张单据表格数据
  1251. this.isAdd = false;
  1252. loading.close();
  1253. (this.$refs.bill as any).showTab = 'bill';
  1254. } else loading.close();
  1255. }).catch(() => loading.close());
  1256. } else loading.close();
  1257. }).catch(() => loading.close());
  1258. }
  1259. // 工具栏提交
  1260. onSmt(e : any) {
  1261. if (e === 'draftsBox') {
  1262. let selectData = (this.$refs.bill as any).getTableSelectData('draftsBox'); // 获取表格选中数据
  1263. if (selectData.length <= 0) return this.$message.warning('请选择提交数据');
  1264. if (selectData.length > 1) return this.$message.warning('只能提交一条数据');
  1265. this.$confirm('确定提交吗!', '注意', {
  1266. confirmButtonText: '确定',
  1267. cancelButtonText: '取消',
  1268. type: 'warning',
  1269. center: true
  1270. }).then(() => {
  1271. let loading = this.$loading({ target: '.main-container' });
  1272. api.submitTo({ id: selectData[0].id }, 'supplyOutOrder').then((res : any) => {
  1273. loading.close();
  1274. if (res.code === 200) {
  1275. this.$message.success('提交成功');
  1276. this.clickTab('draftsBox');
  1277. } else this.$message.error(res.msg)
  1278. }).catch(() => loading.close());
  1279. }).catch(() => this.$message.info('已取消提交'));
  1280. } else {
  1281. if (this.isAdd) return this.$message.warning('新增数据必须先保存才能提交');
  1282. // console.log('isChange ==> ', this.isChange);
  1283. // console.log('isSubmit ==> ', this.isSubmit);
  1284. if (this.isSubmit) {
  1285. this.$confirm('确定提交吗!', '注意', {
  1286. confirmButtonText: '确定',
  1287. cancelButtonText: '取消',
  1288. type: 'warning',
  1289. center: true
  1290. }).then(() => {
  1291. let id = this.dataId ? this.dataId : this.baseInfo.id;
  1292. let loading = this.$loading({ target: '.main-container' });
  1293. api.submitTo({ id: id }, 'supplyOutOrder').then((res : any) => {
  1294. loading.close();
  1295. if (res.code === 200) {
  1296. this.$message.success('提交成功');
  1297. this.isSubmit = false;
  1298. this.clickTab(this.tabType);
  1299. } else this.$message.error(res.msg)
  1300. }).catch(() => loading.close());
  1301. }).catch(() => this.$message.info('已取消提交'));
  1302. } else {
  1303. // 表单旧数据
  1304. let oldbillForm : any = (this as any).$lodash.cloneDeep(this.baseInfo);
  1305. if (oldbillForm.suborderList) delete oldbillForm.suborderList;
  1306. oldbillForm = JSON.stringify(oldbillForm);
  1307. // 表单新数据
  1308. let newBillForm : any = (this as any).$refs.bill.getBillFormValue();
  1309. if (newBillForm.suborderList) delete newBillForm.suborderList;
  1310. newBillForm = JSON.stringify(newBillForm);
  1311. // 表格旧数据
  1312. this.baseInfo.suborderList.map((v : any) => {
  1313. if (v._X_ROW_KEY) delete v._X_ROW_KEY;
  1314. });
  1315. let oldData : any = JSON.stringify(this.baseInfo.suborderList);
  1316. // 表格新数据
  1317. let newData : any = JSON.stringify((this as any).$refs.bill.getBillTableData(0));
  1318. // 数据有变进保存
  1319. if (this.isChange || oldbillForm != newBillForm || oldData != newData) {
  1320. return this.$message.warning('数据变更必须先保存再提交');
  1321. } else {
  1322. this.$confirm('确定提交吗!', '注意', {
  1323. confirmButtonText: '确定',
  1324. cancelButtonText: '取消',
  1325. type: 'warning',
  1326. center: true
  1327. }).then(() => {
  1328. let loading = this.$loading({ target: '.main-container' });
  1329. api.submitTo({ id: this.baseInfo.id }, 'supplyOutOrder').then((res : any) => {
  1330. loading.close();
  1331. if (res.code === 200) {
  1332. this.$message.success('提交成功');
  1333. this.dataId = '';
  1334. this.clickTab(this.tabType);
  1335. } else this.$message.error(res.msg)
  1336. }).catch(() => loading.close());
  1337. }).catch(() => this.$message.info('已取消提交'));
  1338. }
  1339. }
  1340. }
  1341. }
  1342. // 操作反提交
  1343. onReturnSmt(e : any) {
  1344. // console.log('反提交 ==>', e);
  1345. this.$confirm('确定反提交吗!', '注意', {
  1346. confirmButtonText: '确定',
  1347. cancelButtonText: '取消',
  1348. type: 'warning',
  1349. center: true
  1350. }).then(() => {
  1351. let loading = this.$loading({ target: '.main-container' });
  1352. api.cancelSubmission({ id: e.id }, 'supplyOutOrder').then((res : any) => {
  1353. loading.close();
  1354. if (res.code === 200) {
  1355. this.$message.success('反提交成功');
  1356. this.clickTab(this.tabType);
  1357. } else this.$message.error(res.msg)
  1358. }).catch(() => loading.close());
  1359. }).catch(() => this.$message.info('已取消反提交'));
  1360. }
  1361. // 工具栏反提交
  1362. onReturnSmt2() {
  1363. // console.log('工具栏反提交 ==>', this.baseInfo);
  1364. this.$confirm('确定反提交吗!', '注意', {
  1365. confirmButtonText: '确定',
  1366. cancelButtonText: '取消',
  1367. type: 'warning',
  1368. center: true
  1369. }).then(() => {
  1370. let loading = this.$loading({ target: '.main-container' });
  1371. api.cancelSubmission({ id: this.baseInfo.id }, 'supplyOutOrder').then((res : any) => {
  1372. loading.close();
  1373. if (res.code === 200) {
  1374. this.$message.success('反提交成功');
  1375. this.clickTab(this.tabType);
  1376. } else this.$message.error(res.msg)
  1377. }).catch(() => loading.close());
  1378. }).catch(() => this.$message.info('已取消反提交'));
  1379. }
  1380. // 初始化
  1381. getDataList() {
  1382. if (!this.$refs.bill) {
  1383. if (this.timeNum > 5) {
  1384. clearInterval(this.timer)
  1385. }
  1386. this.timeNum++;
  1387. return
  1388. }
  1389. clearInterval(this.timer)
  1390. this.getPageList({}, 'all'); // 综合数据
  1391. }
  1392. // 获取引单分页数据
  1393. getCitationList(query : any) {
  1394. query.status = 0
  1395. let loading = this.$loading({ target: '.main-container' });
  1396. api.pageList(query, 'supplyPurchaseOrder').then((res : any) => {
  1397. loading.close();
  1398. if (res.code === 200) {
  1399. (this.$refs.bill as any).setSourceTableData(0, res.data.records);
  1400. let page = {
  1401. pageNo: res.data.current, //当前页
  1402. pageSize: res.data.size, //每页条数
  1403. total: res.data.total //总条数
  1404. };
  1405. (this.$refs.bill as any).setSourcePage(0, page);
  1406. } else this.$message.error(res.msg)
  1407. }).catch(() => loading.close());
  1408. }
  1409. // 获取分页数据
  1410. getPageList(query : any, type : any) {
  1411. let data = (this.$refs.bill as any).getTablePage(this.tabType);
  1412. query.pageNo = data.pageNo;
  1413. query.pageSize = data.pageSize;
  1414. let loading = this.$loading({ target: '.main-container' });
  1415. api.pageList(query, 'supplyOutOrder').then((res : any) => {
  1416. loading.close();
  1417. if (res.code === 200) {
  1418. (this.$refs.bill as any).setTabTableValue(type, res.data.records);
  1419. let page = {
  1420. pageNo: res.data.current, //当前页
  1421. pageSize: res.data.size, //每页条数
  1422. total: res.data.total //总条数
  1423. };
  1424. (this.$refs.bill as any).setTablePage(type, page);
  1425. } else this.$message.error(res.msg)
  1426. }).catch(() => loading.close());
  1427. }
  1428. // 分页
  1429. pagination(e : any) {
  1430. // console.log('分页 ==> ', e);
  1431. if (e.type === 'source_0') {
  1432. let query : any = (this as any).$refs.bill.$refs.source_0[0].getSearchValue();
  1433. query.pageNo = e.page.pageNum;
  1434. query.pageSize = e.page.pageSize;
  1435. this.getCitationList(query);
  1436. } else {
  1437. let query : any = (this as any).$refs.bill.getSearchValue(e.type);
  1438. query.pageNo = e.page.pageNum;
  1439. query.pageSize = e.page.pageSize;
  1440. let loading = this.$loading({ target: '.main-container' });
  1441. if (e.type === 'recycleBin') {
  1442. api.selectDeleteList(query, 'supplyOutOrder').then((res : any) => {
  1443. loading.close();
  1444. if (res.code === 200) {
  1445. (this.$refs.bill as any).setTabTableValue('recycleBin', res.data.records);
  1446. } else this.$message.error(res.msg)
  1447. }).catch(() => loading.close());
  1448. } else {
  1449. api.pageList(query, 'supplyOutOrder').then((res : any) => {
  1450. loading.close();
  1451. if (res.code === 200) {
  1452. (this.$refs.bill as any).setTabTableValue(e.type, res.data.records);
  1453. } else this.$message.error(res.msg)
  1454. }).catch(() => loading.close());
  1455. }
  1456. }
  1457. }
  1458. // 回收站数据
  1459. getSelectDeleteList(query : any) {
  1460. let data = (this.$refs.bill as any).getTablePage(this.tabType);
  1461. query.pageNo = data.pageNo;
  1462. query.pageSize = data.pageSize;
  1463. let loading = this.$loading({ target: '.main-container' });
  1464. api.selectDeleteList(query, 'supplyOutOrder').then((res : any) => {
  1465. loading.close();
  1466. if (res.code === 200) {
  1467. (this.$refs.bill as any).setTabTableValue('recycleBin', res.data.records);
  1468. let page = {
  1469. pageNo: res.data.current, //当前页
  1470. pageSize: res.data.size, //每页条数
  1471. total: res.data.total //总条数
  1472. };
  1473. (this.$refs.bill as any).setTablePage('recycleBin', page)
  1474. } else this.$message.error(res.msg)
  1475. }).catch(() => loading.close());
  1476. }
  1477. // 返回
  1478. onReturn() {
  1479. this.clickTab(this.tabType);
  1480. }
  1481. // 搜索
  1482. search(parames : any) {
  1483. // console.log('搜索 ==> ', parames);
  1484. let query = parames.value;
  1485. if (parames.type === 'source_0') {
  1486. this.getCitationList(query); // 引单数据
  1487. } else {
  1488. if (parames.type === 'recycleBin') {
  1489. this.getSelectDeleteList(query); // 回收站分页数据
  1490. } else {
  1491. if (parames.type === 'draftsBox') query.submitState = 0;// 草稿箱数据
  1492. if (parames.type === 'smt') query.submitState = 1; // 已提交数据
  1493. this.getPageList(query, parames.type) // 获取分页数据
  1494. }
  1495. }
  1496. }
  1497. // 刷新/重置
  1498. resert(e : any) {
  1499. let data : any = e.type ? e.type : e;
  1500. // console.log('刷新/重置 ==> ', data);
  1501. if (data === 'source_0') {
  1502. (this as any).$refs.bill.$refs.source_0[0].clearSearch();
  1503. this.getCitationList({}); // 引单数据
  1504. } else {
  1505. (this as any).$refs.bill.$refs[data].clearSearch();
  1506. if (data === 'all') this.getPageList({}, 'all'); // 综合数据
  1507. if (data === 'draftsBox') this.getPageList({ submitState: 0 }, 'draftsBox'); // 草稿箱数据
  1508. if (data === 'smt') this.getPageList({ submitState: 1 }, 'smt'); // 已提交数据
  1509. if (data === 'recycleBin') this.getSelectDeleteList({}) // 回收站数据
  1510. }
  1511. }
  1512. // 单据表格删除
  1513. changeTable(item : any) {
  1514. this.$confirm('确定删除吗!', '注意', {
  1515. confirmButtonText: '确定',
  1516. cancelButtonText: '取消',
  1517. type: 'warning',
  1518. center: true
  1519. }).then(() => {
  1520. let data = (this.$refs.bill as any).getBillTableData(0);
  1521. let i = -1;
  1522. let j = -1;
  1523. for (const v of data) {
  1524. i++;
  1525. if (v.materialSku == item.materialSku) {
  1526. break
  1527. }
  1528. };
  1529. // console.log(this.tableData);
  1530. for (const v of this.tableData) {
  1531. j++;
  1532. if (v.materialSku == item.materialSku && item.isDeleted === 0) {
  1533. break
  1534. }
  1535. };
  1536. this.tableData[j].isDeleted = 1;
  1537. data.splice(i, 1);
  1538. (this.$refs.bill as any).setBillTableValue(data, 0);// 设置第1张单据表格数据
  1539. this.$message.success('删除成功');
  1540. }).catch(() => this.$message.info('已取消删除'));
  1541. }
  1542. // 工具栏删除
  1543. onDelete(e : any) {
  1544. let selectData = (this.$refs.bill as any).getTableSelectData(e)
  1545. let ids = '';
  1546. if (selectData.length > 0) {
  1547. selectData.map((v : any) => {
  1548. ids += v.id + ','
  1549. })
  1550. } else return this.$message({ type: 'warning', message: '请选择删除数据' })
  1551. ids = ids.slice(0, ids.length - 1);
  1552. this.$confirm('确定删除吗,此操作不能撤销!', '注意', {
  1553. confirmButtonText: '确定',
  1554. cancelButtonText: '取消',
  1555. type: 'warning',
  1556. center: true
  1557. }).then(() => {
  1558. let loading = this.$loading({ target: '.main-container' });
  1559. api.deleteList({ ids: ids }, 'supplyOutOrder').then((res : any) => {
  1560. loading.close();
  1561. if (res.code === 200) {
  1562. this.$message.success('删除成功');
  1563. this.clickTab(this.tabType);
  1564. } else this.$message.error(res.msg)
  1565. }).catch(() => loading.close());
  1566. }).catch(() => this.$message.info('已取消删除'));
  1567. }
  1568. // 操作删除
  1569. doDelete2(item : any) {
  1570. this.$confirm('确定删除吗,此操作不能撤销!', '注意', {
  1571. confirmButtonText: '确定',
  1572. cancelButtonText: '取消',
  1573. type: 'warning',
  1574. center: true
  1575. }).then(() => {
  1576. let loading = this.$loading({ target: '.main-container' });
  1577. api.deleteList({ ids: item.id }, 'supplyOutOrder').then((res : any) => {
  1578. loading.close();
  1579. if (res.code === 200) {
  1580. this.$message.success('删除成功');
  1581. this.clickTab(this.tabType);
  1582. } else this.$message.error(res.msg)
  1583. }).catch(() => loading.close());
  1584. }).catch(() => this.$message.info('已取消删除'));
  1585. }
  1586. }
  1587. </script>