index.vue 37 KB

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