index.vue 35 KB

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