detailDialog.vue 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297
  1. <template>
  2. <div>
  3. <detailDialog
  4. :businessId="businessId"
  5. :isInterior="true"
  6. ref="detailDialog"
  7. ></detailDialog>
  8. </div>
  9. </template>
  10. <script>
  11. import detailDialog from '@/views/bpm/stockManagement/details.vue';
  12. // import { getInfo } from '@/api/stockManagement';
  13. import elTableInfiniteScroll from 'el-table-infinite-scroll';
  14. import StatusStep from '@/components/StatusStep/common.vue';
  15. // import { fileSystemDownload } from '@/utils';
  16. import outin from '@/api/warehouseManagement/outin';
  17. import fileUpload from '@/components/upload/fileUpload';
  18. import {
  19. allCategoryLevel,
  20. getTreeByPid,
  21. getOutInBySourceBizNo,
  22. getOutInBySourceBizNoOrError,
  23. updateOutInRecord,
  24. updateMaterialById
  25. } from '@/api/classifyManage';
  26. import {
  27. materialType,
  28. warehousingType,
  29. useDict,
  30. useDictLabel,
  31. inputStatus,
  32. emergencyState,
  33. sceneState
  34. } from '@/utils/dict/index';
  35. import { auditStatus } from '@/utils/dict/common';
  36. // import { batchBarPrint } from '@/api/ledgerAssets/booksList';
  37. import { tableHeader } from './common';
  38. import { mapGetters, mapActions } from 'vuex';
  39. export default {
  40. components: { StatusStep, fileUpload, detailDialog },
  41. directives: {
  42. 'el-table-infinite-scroll': elTableInfiniteScroll
  43. },
  44. props: {
  45. businessId: {
  46. default: ''
  47. },
  48. type: {
  49. default: ''
  50. },
  51. taskDefinitionKey: {
  52. default: ''
  53. },
  54. showQualityFile: {
  55. default: true
  56. }
  57. },
  58. data() {
  59. return {
  60. sceneState,
  61. inboundTypeMapping: '',
  62. inboundTypeDocumentsMapping: '',
  63. qualityStatus: {
  64. 0: '未检',
  65. 1: '已检',
  66. 2: '部分检'
  67. }, // 质检状态 0未检 1已检
  68. qualityResults: {
  69. 0: '合格',
  70. 1: '不合格',
  71. 3: '让步接收'
  72. },
  73. qualityFile: '',
  74. saveLoading: false,
  75. metailList: [],
  76. dateTypes: 1,
  77. detailList: [],
  78. pageSize: 20,
  79. wrapPageNum: 1,
  80. materielPageNum: 1,
  81. showMaterialCodeReqList: [],
  82. materialCodeReqList: [],
  83. showResultArray: [],
  84. resultArray: [],
  85. extInfo: {},
  86. codeList: [],
  87. auditStatus,
  88. infoData: {},
  89. warehousingMaterialList: [],
  90. tableData2: [],
  91. activeName: 'a',
  92. num: 1,
  93. openWindows: false, //打印弹窗
  94. barCodeConfig: [],
  95. stepsTitle: '已完成',
  96. stepsStatus: 'success',
  97. active: 0,
  98. // 条码类型枚举
  99. codeTypeObj: {
  100. 生产设备: 'EQUIPMENT',
  101. 舟皿: '',
  102. 周转车: 'TURNOVER_CAR',
  103. 模具: 'MODE',
  104. 库位: 'STORE_LOCAL',
  105. 混合料: 'MIX_MATER',
  106. 混炼料: 'MIXING_MATER',
  107. 破碎料: 'CRUSH_MATER',
  108. 货架: 'GOODS_SHELF',
  109. 返回料: 'RETURN_MATER',
  110. 返工料: 'REWORK_MATER',
  111. 备品备件: 'SPARE_PART',
  112. 车削料: 'LATHE_MATER',
  113. 风管料: 'WIND_PIPE_MATER',
  114. 地面料: 'GROUND_MATER'
  115. }
  116. };
  117. },
  118. watch: {
  119. 'infoData.verifyStatus': {
  120. immediate: true,
  121. handler(val) {
  122. if (val == 0) {
  123. this.active = 1;
  124. this.stepsTitle = '未审核';
  125. this.stepsStatus = 'wait';
  126. } else if (val == 1) {
  127. this.active = 2;
  128. this.stepsTitle = '审核中';
  129. this.stepsStatus = 'process';
  130. } else if (val == 2) {
  131. this.active = 2;
  132. this.stepsTitle = '审核通过';
  133. this.stepsStatus = 'success';
  134. } else if (val == 3) {
  135. this.active = 2;
  136. this.stepsTitle = '驳回';
  137. this.stepsStatus = 'error';
  138. }
  139. }
  140. },
  141. // 解决右侧悬浮操作栏不对称问题
  142. warehousingMaterialList: {
  143. handler() {
  144. this.$nextTick(() => {
  145. this.$refs.warehousingMaterialListTable.doLayout();
  146. });
  147. },
  148. deep: true
  149. },
  150. // 解决右侧悬浮操作栏不对称问题
  151. showMaterialCodeReqList: {
  152. handler() {
  153. this.$nextTick(() => {
  154. this.$refs.detailListTable.doLayout();
  155. });
  156. },
  157. deep: true
  158. },
  159. // 解决右侧悬浮操作栏不对称问题
  160. showResultArray: {
  161. handler() {
  162. this.$nextTick(() => {
  163. this.$refs.metailListTable.doLayout();
  164. });
  165. },
  166. deep: true
  167. }
  168. },
  169. computed: {
  170. ...mapGetters(['getDictValue']),
  171. curDateType() {
  172. if (this.materialCodeReqList) {
  173. return this.materialCodeReqList[0].manufactureTime
  174. ? 'manufactureTime'
  175. : 'procurementTime';
  176. }
  177. },
  178. tableHeader() {
  179. return tableHeader(this.infoData.assetType);
  180. },
  181. emergencyState() {
  182. return useDict(emergencyState)(this.infoData.emergencyState);
  183. }
  184. // 条码信息
  185. // materialCodeReqList() {
  186. // return this.warehousingMaterialList.warehouseLedgerDetails;
  187. // }
  188. },
  189. created() {
  190. // this.requestDict('类型用途');
  191. // this.getInboundTypeMapping();
  192. // this._getInfo();
  193. },
  194. methods: {
  195. wrapHandleScroll() {
  196. console.log('---------wrapHandleScroll------------');
  197. if (
  198. this.showMaterialCodeReqList.length < this.materialCodeReqList.length
  199. ) {
  200. if (this.materialCodeReqList.length > this.pageSize) {
  201. this.wrapPageNum += 1;
  202. }
  203. this.wrapFetchData();
  204. }
  205. },
  206. wrapFetchData() {
  207. const start = (this.wrapPageNum - 1) * this.pageSize;
  208. const end = start + this.pageSize;
  209. this.showMaterialCodeReqList = this.showMaterialCodeReqList.concat(
  210. this.materialCodeReqList.slice(start, end)
  211. );
  212. },
  213. materielHandleScroll() {
  214. console.log('---------materielHandleScroll------------');
  215. if (this.showResultArray.length < this.resultArray.length) {
  216. if (this.resultArray.length > this.pageSize) {
  217. this.materielPageNum += 1;
  218. }
  219. this.materielFetchData();
  220. }
  221. },
  222. materielFetchData() {
  223. const start = (this.materielPageNum - 1) * this.pageSize;
  224. const end = start + this.pageSize;
  225. this.showResultArray = this.showResultArray.concat(
  226. this.resultArray.slice(start, end)
  227. );
  228. },
  229. // 入库类型和单据映射表
  230. async getInboundTypeMapping() {
  231. let obj = {};
  232. let documents = {};
  233. this.sceneState.forEach((item) => {
  234. obj[item.code] = item.label;
  235. documents[item.code] = item.documentsName;
  236. });
  237. this.inboundTypeMapping = obj;
  238. this.inboundTypeDocumentsMapping = documents;
  239. },
  240. // 选择质检结果改变质检状态
  241. changeWrapStatus(resultValue, row) {
  242. switch (resultValue) {
  243. case '':
  244. // 清空质检状态
  245. row.status = '0';
  246. break;
  247. default:
  248. // 默认已检质检状态
  249. row.status = '1';
  250. break;
  251. }
  252. },
  253. //包装结果
  254. packItem(val, row) {
  255. row.status = '1';
  256. },
  257. edit(data) {
  258. this.$set(data, 'isPack', false);
  259. },
  260. //质检物料提交
  261. async packMeta(data) {
  262. if (!data.result) {
  263. return this.$message.error('请选择质检结果!');
  264. }
  265. this.$set(data, 'isPack', true);
  266. // data.status = 1;
  267. // data.result = Number(data.result);
  268. await updateMaterialById(data);
  269. // this._getInfo();
  270. this.detailList.forEach((outItem) => {
  271. let arr = [];
  272. this.metailList.forEach((inneritem) => {
  273. if (inneritem.onlyCode == outItem.code) {
  274. arr.push(inneritem);
  275. }
  276. });
  277. console.log('arr-----------', arr);
  278. // 首先判断是未填/合格不合格
  279. let boolen = arr.every((item) => {
  280. return item.result == '' || item.result == undefined;
  281. });
  282. // 判断只要物料全部质检结果(未填)——>包装质检结果(未填) 状态(未检)
  283. if (boolen) {
  284. this.$set(outItem, 'result', '');
  285. this.$set(outItem, 'status', '0');
  286. } else {
  287. // 判断只要物料有一个质检结果(不合格)——>包装质检结果(不合格) 状态(已检)
  288. let boolen = arr.some((item) => {
  289. return item.result == '1';
  290. });
  291. if (boolen) {
  292. this.$set(outItem, 'result', '1');
  293. this.$set(outItem, 'status', '1');
  294. } else {
  295. // 判断只要物料有一个质检结果(让步接收)——>包装质检结果(让步接收) 状态(已检)
  296. let boolen = arr.some((item) => {
  297. return item.result == '3';
  298. });
  299. if (boolen) {
  300. // 让步接收 已检
  301. this.$set(outItem, 'result', '3');
  302. this.$set(outItem, 'status', '1');
  303. } else {
  304. // 判断只要物料有全部质检结果(合格)——>包装质检结果(合格) 状态(已检)
  305. let boolen = arr.every((item) => {
  306. return item.result == '0';
  307. });
  308. if (boolen) {
  309. // 合格 已检
  310. this.$set(outItem, 'result', '0');
  311. this.$set(outItem, 'status', '1');
  312. } else {
  313. // 合格 部分检
  314. this.$set(outItem, 'result', '0');
  315. this.$set(outItem, 'status', '2');
  316. }
  317. }
  318. }
  319. }
  320. // this.$set(outItem, 'result', boolen ? '1' : '0');
  321. });
  322. },
  323. //质检提交
  324. async packCout(data) {
  325. if (!data.result) {
  326. return this.$message.error('请选择质检结果!');
  327. }
  328. data.status = 1;
  329. await updateOutInRecord(data);
  330. this._getInfo();
  331. },
  332. //获取质检状态
  333. getStatus() {
  334. return this.detailList.filter((item) => item.status == 1);
  335. },
  336. //获取回执附件
  337. getQualityFile() {
  338. return { qualityFile: this.qualityFile, id: this.infoData.id };
  339. },
  340. //包装保存
  341. async packSave(row, index) {
  342. console.log('===', row);
  343. console.log('row.minPackingCount', row.minPackingCount);
  344. console.log(' this.detailList.length', this.detailList.length);
  345. console.log(this.warehousingMaterialList);
  346. let packNo = 0;
  347. this.warehousingMaterialList.forEach((item) => {
  348. if (
  349. item.categoryCode == row.categoryCode &&
  350. item.batchNo == row.batchNo
  351. ) {
  352. if (this.warehousingMaterialList.length != 1) {
  353. packNo = this.warehousingMaterialList.length;
  354. } else {
  355. packNo = item.packingCount;
  356. }
  357. }
  358. });
  359. console.log('packNopackNopackNo', packNo);
  360. if (packNo != this.detailList.length) {
  361. //存当前没改之前包装数量
  362. let count = 0;
  363. for (const item of this.warehousingMaterialList) {
  364. console.log('item', item);
  365. if (item.categoryId == row.categoryId) {
  366. count = item.outInNum;
  367. }
  368. }
  369. console.log(111);
  370. //新增包装更新物料
  371. const arr = [];
  372. console.log('==================', row);
  373. // row.outInDetailRecordVOList.forEach((it) => {
  374. // it.outInDetailRecordMaterialDetailVOList.forEach((item) => {
  375. // arr.push({ ...item });
  376. // });
  377. // });
  378. this.warehousingMaterialList.forEach((item) => {
  379. item.outInDetailRecordVOList.forEach((it) => {
  380. it.outInDetailRecordMaterialDetailVOList.forEach((item) => {
  381. arr.push({ ...item });
  382. });
  383. });
  384. });
  385. if (row.minPackingCount < Number(count)) {
  386. console.log(1);
  387. console.log('arr====arr', arr);
  388. console.log('rrrr', this.metailList.length);
  389. this.metailList = this.metaUpdate(arr, row);
  390. } else {
  391. console.log(2);
  392. this.metailList = this.metaAdd(arr, row);
  393. }
  394. this.$set(row, 'isPack', true);
  395. await updateOutInRecord(row);
  396. this.$message.success('修改成功');
  397. return;
  398. }
  399. this.$set(row, 'isPack', true);
  400. //更新包装明细数据,同步物料明细
  401. for (const i in this.metailList) {
  402. if (this.metailList[i].onlyCode == row.code) {
  403. this.metailList[i].clientCode = row.clientCode; //客户代号
  404. this.metailList[i].materielCode = row.materielCode; //物料代号
  405. this.metailList[i].result = row.result; //质检结果
  406. this.metailList[i].status = row.status; //质检状态
  407. this.metailList[i].weight = row.weight / row.minPackingCount; //重量
  408. }
  409. }
  410. //更新包装明细重量,更新物品重量
  411. const list = this.detailList;
  412. let sum = 0;
  413. for (let i = 0; i < list.length; i++) {
  414. sum += Number(list[i].weight);
  415. }
  416. await updateOutInRecord(row);
  417. this.$message.success('修改成功');
  418. this.warehousingMaterialList.forEach((item) => {
  419. if (
  420. item.categoryCode == row.categoryCode &&
  421. item.categoryCode == row.categoryCode
  422. ) {
  423. item.weight = sum;
  424. }
  425. });
  426. console.log(this.warehousingMaterialList);
  427. },
  428. //更新物料
  429. metaUpdate(arr, row) {
  430. const obj = {
  431. assetCode: row.categoryCode,
  432. assetName: row.name,
  433. manualBatchNo: row.manualBatchNo,
  434. batchNo: row.batchNo,
  435. clientCode: row.clientCode,
  436. createTime: row.createTime,
  437. engrave: '',
  438. id: '',
  439. materielCode: row.materielCode,
  440. measuringUnit: row.measuringUnit,
  441. minPackingCount: 1,
  442. no: '',
  443. onlyCode: row.code,
  444. outInDetailRecordId: '',
  445. pathName: row.position,
  446. result: row.result,
  447. status: row.status,
  448. weight: row.weight / row.minPackingCount,
  449. weightUnit: row.weightUtil,
  450. counts: row.minPackingCount
  451. };
  452. // 生成 no 字段的值
  453. let newArr = [];
  454. for (let i = 1; i <= obj.counts; i++) {
  455. newArr.push({
  456. ...obj,
  457. no: obj.onlyCode + i.toString().padStart(4, '0')
  458. });
  459. }
  460. console.log('新增', newArr);
  461. console.log(arr);
  462. let data = this.metailList.concat(newArr);
  463. const uniqueData = data.reduce((acc, curr) => {
  464. acc[curr.no] = curr;
  465. return acc;
  466. }, {});
  467. const result = Object.values(uniqueData);
  468. return result;
  469. },
  470. //包装编辑
  471. packEdit(row, index) {
  472. console.log('row', row);
  473. console.log('this.detailList', this.detailList);
  474. this.$set(row, 'isPack', false);
  475. this.$set(
  476. row,
  477. 'result',
  478. row.result != null ? row.result.toString() : ''
  479. );
  480. this.$set(
  481. row,
  482. 'status',
  483. row.status != null ? row.status.toString() : ''
  484. );
  485. },
  486. houseData(argum, idx) {
  487. this.$set(this.warehousingMaterialList[idx], 'houseList', argum);
  488. argum.forEach((item) => {
  489. item.position = `${item.warehouseName}-${item.areaName}-${item.shelfCode}-${item.cargoSpaceCode}`;
  490. item.pathIds = `${item.warehouseId},${item.areaId},${item.shelfId},${item.cargoSpaceId}`;
  491. });
  492. console.log(argum);
  493. this.$set(
  494. this.warehousingMaterialList[idx],
  495. 'position',
  496. argum[0].position
  497. );
  498. console.log(
  499. 'this.warehousingMaterialList',
  500. this.warehousingMaterialList
  501. );
  502. },
  503. // 仓库编辑
  504. handleWareHouse(row, idx) {
  505. const a = row.pathIds.split(',');
  506. const b = row.position.split('-');
  507. row.houseList = [
  508. {
  509. warehouseId: a[0],
  510. warehouseNam: b[0] + '-' + b[1],
  511. areaId: a[1],
  512. areaName: b[2],
  513. shelfId: a[2],
  514. shelfCode: b[3],
  515. cargoSpaceId: a[3],
  516. cargoSpaceCode: b[4],
  517. num: row.packingCount
  518. }
  519. ];
  520. this.$refs.wareHouseDailogRef.open(
  521. { ...row, outInNum: row.packingCount, warehouseId: a[0] },
  522. idx
  523. );
  524. },
  525. async handleSave() {
  526. this.saveLoading = true;
  527. if (this.detailList.length != 0) {
  528. let a = this.infoData;
  529. let array1 = this.warehousingMaterialList;
  530. let array2 = this.detailList.map((item) => {
  531. return { ...item, materialDetails: this.metailList };
  532. });
  533. // 遍历数组1
  534. array1.forEach((item1) => {
  535. item1.arr = [];
  536. item1.outInDetailRecordUpdatePOList = [];
  537. // 遍历数组2
  538. array2.forEach((item2) => {
  539. if (
  540. item1.id == item2.outInDetailId &&
  541. item1.batchNo == item2.batchNo &&
  542. item1.categoryCode == item2.categoryCode
  543. ) {
  544. // 判断id、batchNo、categoryId是否相等
  545. // 将数组2对象添加到数组1对象的outInDetailRecordVOList中
  546. item1.arr.push(item2);
  547. } else {
  548. console.log(item2);
  549. item1.outInDetailRecordUpdatePOList.push({ ...item2 });
  550. }
  551. });
  552. });
  553. array1.forEach((ele) => {
  554. if (ele.outInDetailRecordUpdatePOList.length == ele.arr.length) {
  555. delete ele.arr;
  556. } else {
  557. ele.outInDetailRecordUpdatePOList = ele.arr;
  558. delete ele.arr;
  559. }
  560. });
  561. array1.forEach((e) => {
  562. if (e.hasOwnProperty('houseList')) {
  563. e.houseList.forEach((item) => {
  564. e.position = `${item.warehouseName}-${item.areaName}-${item.shelfCode}-${item.cargoSpaceCode}`;
  565. e.pathIds = `${item.warehouseId},${item.areaId},${item.shelfId},${item.cargoSpaceId}`;
  566. });
  567. }
  568. });
  569. delete array1.houseList;
  570. a.outInDetailUpdatePOList = array1;
  571. a.extInfo = this.extInfo;
  572. const obj = this.formatUpdate(a);
  573. console.log('sss===》', obj);
  574. try {
  575. const data = await outin.update(obj);
  576. if (data.code == 0) {
  577. this.$message.success('修改成功!');
  578. // this.$router.push('/warehouseManagement/stockManagement');
  579. }
  580. } catch (error) {
  581. this.saveLoading = false;
  582. }
  583. } else {
  584. this.$message.warning('包装明细为空!');
  585. }
  586. this.saveLoading = false;
  587. },
  588. formatUpdate(a) {
  589. delete a.outInDetailVOList;
  590. console.log(a);
  591. // 删除 outInDetailVOList 数组对象里面的 outInDetailRecordVOList 数组对象里面的 outInDetailRecordMaterialDetailVOList
  592. a.outInDetailUpdatePOList = a.outInDetailUpdatePOList.map((item) => {
  593. const newItem = { ...item };
  594. delete newItem.outInDetailRecordVOList;
  595. return newItem;
  596. });
  597. const newData = {
  598. ...a,
  599. outInDetailUpdatePOList: a.outInDetailUpdatePOList.map((detail) => {
  600. const { outInDetailRecordMaterialDetailVOList, ...rest } = detail;
  601. return {
  602. ...rest,
  603. outInDetailRecordUpdatePOList:
  604. rest.outInDetailRecordUpdatePOList.map((record) => {
  605. const {
  606. outInDetailRecordMaterialDetailVOList,
  607. ...recordRest
  608. } = record;
  609. return { ...recordRest };
  610. })
  611. };
  612. })
  613. };
  614. // 对原始数据进行深拷贝,以避免修改原始数据
  615. const arr = JSON.parse(JSON.stringify(newData));
  616. // 遍历 outInDetailUpdatePOList 数组
  617. arr.outInDetailUpdatePOList.forEach((detail) => {
  618. // 遍历 outInDetailRecordUpdatePOList 数组
  619. detail.outInDetailRecordUpdatePOList.forEach((record) => {
  620. // 筛选出与 code 相等的 materialDetails 项
  621. const matchedDetails = record.materialDetails.filter(
  622. (item) => item.onlyCode === record.code
  623. );
  624. // 将匹配项放入 materialDetails 数组中
  625. record.materialDetails = matchedDetails;
  626. });
  627. });
  628. return arr;
  629. },
  630. packNum(row, value) {
  631. const total = {
  632. packingCount: Number(
  633. row.minPackingCount > 0 ? row.minPackingCount : 0
  634. ),
  635. outInNum: Number(row.outInNum > 0 ? row.outInNum : 0)
  636. };
  637. if (row.measuringUnit == row.weightUnit) {
  638. row.weight = Number(
  639. this.$math.format(
  640. total.packingCount * 1 * total.outInNum.toFixed(2),
  641. 14
  642. )
  643. );
  644. } else {
  645. const totals = Number(
  646. this.$math.format(total.packingCount * total.outInNum, 14)
  647. );
  648. row.weight = Number(
  649. this.$math.format(
  650. totals * (row.netWeight > 0 ? row.netWeight.toFixed(2) : 0),
  651. 14
  652. )
  653. );
  654. }
  655. return (row.outInNum = value.replace(/^(0+)|[^\d]+/g, ''));
  656. },
  657. listEdit(row) {
  658. this.$set(row, 'isSave', false);
  659. //包装
  660. const list = this.detailList;
  661. for (let i = 0; i < list.length; i++) {
  662. if (list[i].categoryCode === row.categoryCode) {
  663. // 删除满足条件的对象
  664. this.detailList.splice(i, 1);
  665. // 因为删除了一个对象,需要将索引减1
  666. i--;
  667. }
  668. }
  669. //物料
  670. const lists = this.metailList;
  671. for (let i = 0; i < lists.length; i++) {
  672. if (lists[i].assetCode === row.categoryCode) {
  673. // 删除满足条件的对象
  674. this.metailList.splice(i, 1);
  675. // 因为删除了一个对象,需要将索引减1
  676. i--;
  677. }
  678. }
  679. },
  680. listSave(row, index) {
  681. console.log(row);
  682. const fileds = [
  683. // `warehousingMaterialList.${index}.batchNo`,
  684. `warehousingMaterialList.${index}.position`
  685. ];
  686. console.log('==1', this.infoData.bizType);
  687. if (this.infoData.bizType != 5) {
  688. fileds.push(
  689. ...[
  690. // `warehousingMaterialList.${index}.packingCount`,
  691. // `warehousingMaterialList.${index}.minPackingCount`
  692. ]
  693. );
  694. } else if (
  695. this.warehousingMaterialList.some(
  696. (i) => !i.outInDetailRecordVOList?.length
  697. )
  698. ) {
  699. this.$message.error('请选择资产编号!');
  700. return;
  701. }
  702. Promise.all(
  703. fileds.map(
  704. (item) =>
  705. new Promise(async (resolve, rej) => {
  706. this.$refs.warehousingMaterialListRef.validateField(
  707. item,
  708. (err) => {
  709. if (err) {
  710. rej(err);
  711. } else {
  712. resolve();
  713. }
  714. }
  715. );
  716. })
  717. )
  718. )
  719. .then((res) => {
  720. this.$set(row, 'isSave', true);
  721. if (this.infoData.bizType != 5) {
  722. this.createMaterialCode(row);
  723. } else {
  724. // 退还
  725. // this.createMaterialCodeReturn(row);
  726. }
  727. })
  728. .catch((err) => {
  729. console.log(err);
  730. this.$message.error('请填入必填项!');
  731. });
  732. },
  733. async createMaterialCode(row) {
  734. console.log('==--', row);
  735. const {
  736. packingCount,
  737. minPackingCount,
  738. weight,
  739. outInDetailRecordVOList
  740. } = row;
  741. // console.log(row);
  742. // if (row.houseList) {
  743. // row.houseList.forEach((item) => {
  744. // position = `${item.warehouseName}-${item.areaName}-${item.shelfCode}-${item.cargoSpaceCode}`;
  745. // pathIds = `${item.warehouseId},${item.areaId},${item.shelfId},${item.cargoSpaceId}`;
  746. // });
  747. // }
  748. const codes = outInDetailRecordVOList[0].code;
  749. const index = outInDetailRecordVOList[0].code.indexOf('636');
  750. const result = codes.slice(-3);
  751. const dataArray = []; // 物品列表
  752. for (let i = 0; i < packingCount; i++) {
  753. const newData = { ...row };
  754. if (outInDetailRecordVOList.length != packingCount) {
  755. newData.minPackingCount = row.minPackingCount;
  756. newData.packingCount = 1;
  757. newData.weight = weight / packingCount;
  758. newData.weightUtil = row.weightUnit;
  759. newData.outInDetailId = row.id;
  760. } else {
  761. newData.minPackingCount = row.minPackingCount;
  762. newData.weight = weight / packingCount;
  763. newData.packingCount = row.packingCount / packingCount;
  764. newData.weightUtil = row.weightUnit;
  765. newData.outInDetailId = row.id;
  766. }
  767. dataArray.push(newData);
  768. }
  769. for (let j = 0; j < dataArray.length; j++) {
  770. const num = Number(result);
  771. const nums = num + j;
  772. const str = nums.toString().padStart(result.length, '0');
  773. dataArray[j].code =
  774. dataArray[j].categoryCode + dataArray[j].batchNo + str;
  775. dataArray[j].isPack = true;
  776. }
  777. const list = JSON.parse(localStorage.getItem('exitList'));
  778. console.log('list', '-------------');
  779. dataArray.forEach((ele, index) => {
  780. if (index < list.length) {
  781. if (ele.code === list[index].code) {
  782. ele.id = list[index].id;
  783. } else {
  784. ele.isPack = false;
  785. ele.id = ''; // 当 code 不匹配时,将 id 设为空字符串
  786. }
  787. } else {
  788. ele.isPack = false;
  789. ele.id = ''; // 如果 index 超出了 list 的范围,将 id 设为空字符串
  790. }
  791. });
  792. console.log('dataArray----', dataArray);
  793. this.detailList = this.pacKUpdate(dataArray);
  794. this.metailList = this.metailUpdate(dataArray);
  795. // this.metailList = this.metaAdd(dataArray);
  796. console.log('====>>>>>1', dataArray);
  797. },
  798. //包装修改
  799. pacKUpdate(arr) {
  800. for (const it of arr) {
  801. for (const ti of it.outInDetailRecordVOList) {
  802. if (ti.id == it.id) {
  803. it.materielCode = ti.materielCode;
  804. it.clientCode = ti.clientCode;
  805. it.result = ti.result;
  806. it.status = ti.status;
  807. }
  808. }
  809. }
  810. return arr;
  811. },
  812. //物料新增
  813. metaAdd(arr) {
  814. const list = arr;
  815. let resultArray = [];
  816. list.forEach((item) => {
  817. for (let i = 1; i <= Number(item.minPackingCount); i++) {
  818. resultArray.push({
  819. onlyCode: item.code,
  820. no: item.code + i.toString().padStart(4, '0'),
  821. assetCode: item.categoryCode,
  822. assetName: item.name,
  823. manualBatchNo: item.manualBatchNo,
  824. batchNo: item.batchNo,
  825. minPackingCount: 1,
  826. measuringUnit: item.measuringUnit,
  827. materielCode: item.materielCode,
  828. clientCode: item.clientCode,
  829. weight: item.weight / Number(item.minPackingCount),
  830. weightUnit: item.weightUnit,
  831. engrave: item.engrave,
  832. result: item.result,
  833. status: item.status
  834. });
  835. }
  836. });
  837. return resultArray;
  838. // console.log('物料', resultArray);
  839. },
  840. // 物料明细保存
  841. materialBtn(row) {
  842. console.log(row);
  843. console.log(this.resultArray);
  844. console.log(this.materialCodeReqList);
  845. // true保存 false编辑
  846. if (!row.isPack) {
  847. row.isPack = true;
  848. // 物料维度修改质检改变包装维度质检(结果和状态)
  849. this.materialCodeReqList.forEach((outItem) => {
  850. let arr = [];
  851. this.resultArray.forEach((inneritem) => {
  852. if (inneritem.onlyCode == outItem.onlyCode) {
  853. arr.push(inneritem);
  854. }
  855. });
  856. console.log(arr);
  857. // 首先判断是未填/合格不合格
  858. let boolen = arr.every((item) => {
  859. return item.result === '' || item.result === undefined;
  860. });
  861. // 判断只要物料全部质检结果(未填)——>包装质检结果(未填) 状态(未检)
  862. if (boolen) {
  863. this.$set(outItem, 'result', '');
  864. this.$set(outItem, 'status', '0');
  865. } else {
  866. // 判断只要物料有一个质检结果(不合格)——>包装质检结果(不合格) 状态(已检)
  867. let boolen = arr.some((item) => {
  868. return item.result === '1';
  869. });
  870. if (boolen) {
  871. this.$set(outItem, 'result', '1');
  872. this.$set(outItem, 'status', '1');
  873. } else {
  874. // 判断只要物料有一个质检结果(让步接收)——>包装质检结果(让步接收) 状态(已检)
  875. let boolen = arr.some((item) => {
  876. return item.result === '3';
  877. });
  878. if (boolen) {
  879. // 让步接收 已检
  880. this.$set(outItem, 'result', '3');
  881. this.$set(outItem, 'status', '1');
  882. } else {
  883. // 判断只要物料有全部质检结果(合格)——>包装质检结果(合格) 状态(已检)
  884. let boolen = arr.every((item) => {
  885. return item.result === '0';
  886. });
  887. if (boolen) {
  888. // 合格 已检
  889. this.$set(outItem, 'result', '0');
  890. this.$set(outItem, 'status', '1');
  891. } else {
  892. // 合格 部分检
  893. this.$set(outItem, 'result', '0');
  894. this.$set(outItem, 'status', '2');
  895. }
  896. }
  897. }
  898. }
  899. // this.$set(outItem, 'result', boolen ? '1' : '0');
  900. });
  901. // 物料维度修改重量改变包装维度重量
  902. let onlyCode = row.onlyCode;
  903. this.materialCodeReqList.forEach((item) => {
  904. if (item.onlyCode === onlyCode) {
  905. let arr = [];
  906. for (const key in this.resultArray) {
  907. if (this.resultArray[key].onlyCode == item.onlyCode) {
  908. arr.push({ ...this.resultArray[key] });
  909. }
  910. }
  911. const count = arr.reduce(
  912. (acc, curr) =>
  913. Number(this.$math.format(+acc + +curr.weight, 14)),
  914. 0
  915. );
  916. this.$set(item, 'weight', count);
  917. }
  918. });
  919. // 包装维度修改重量改变产品信息
  920. this.isWeight = false;
  921. // 批量修改包装明细
  922. this.bulkEditingWrap();
  923. this.$nextTick(() => {
  924. this.isWeight = true;
  925. });
  926. } else {
  927. row.isPack = false;
  928. }
  929. },
  930. //物料修改
  931. metailUpdate(arr) {
  932. console.log('---', arr);
  933. const extractedArray = [];
  934. arr.forEach((item) => {
  935. item.outInDetailRecordVOList.forEach((record) => {
  936. extractedArray.push(
  937. ...record.outInDetailRecordMaterialDetailVOList
  938. );
  939. });
  940. });
  941. // 用于存储已经遇到的ID
  942. let idMap = {};
  943. // 用于存储结果的数组
  944. let uniqueArray = [];
  945. // 遍历原始数据
  946. for (let i = 0; i < extractedArray.length; i++) {
  947. let currentItem = extractedArray[i];
  948. // 检查当前ID是否已经在map中存在
  949. if (!idMap[currentItem.id]) {
  950. // 如果ID不存在,将当前ID添加到map中,并将当前数据添加到结果数组中
  951. idMap[currentItem.id] = true;
  952. uniqueArray.push(currentItem);
  953. }
  954. }
  955. return uniqueArray;
  956. },
  957. //计算金额
  958. calcSumTotal(PackingCount, outInNum, univalence) {
  959. //最小包装单元,包装数量,单价
  960. const total = {
  961. PackingCount: Number(PackingCount),
  962. outInNum: Number(outInNum),
  963. univalence: Number(univalence == undefined ? 0 : univalence)
  964. };
  965. return total.PackingCount * total.outInNum * total.univalence;
  966. },
  967. ...mapActions('dict', ['requestDict']),
  968. getAuditStatus: useDictLabel(auditStatus),
  969. getMaterialType: useDictLabel(materialType),
  970. getInputStatus: useDictLabel(inputStatus),
  971. getSceneState: useDictLabel(sceneState),
  972. handleRowUnit(row) {
  973. return row.measuringUnit;
  974. // if (this.extInfo.assetType == 1) {
  975. // console.log(row);
  976. // return row.weightUnit;
  977. // } else if (this.extInfo.assetType == 4) {
  978. // return row.measuringUnit;
  979. // } else {
  980. // return row.measuringUnit;
  981. // }
  982. },
  983. handleAssetType(r) {
  984. const code = this.codeList.find((item) => item.dictCode == r);
  985. return code?.dictValue;
  986. },
  987. rowClass({ row, column, rowIndex, columnIndex }) {
  988. if (rowIndex === 1) {
  989. return {
  990. display: 'none',
  991. background: '#EEEEEE',
  992. border: 'none'
  993. };
  994. }
  995. return { background: '#EEEEEE', border: 'none' };
  996. },
  997. // 初始化数据
  998. async _getInfo() {
  999. const res =
  1000. this.type == 'sourceBizNo'
  1001. ? await getOutInBySourceBizNo(this.businessId)
  1002. : await outin.getById(this.businessId);
  1003. console.log('===', res);
  1004. if (res) {
  1005. this.infoData = res;
  1006. this.extInfo = res.extInfo;
  1007. // 获取物品维度列表
  1008. this.warehousingMaterialList = res.outInDetailVOList.map((item) => {
  1009. return { ...item, isSave: true };
  1010. });
  1011. const arr = [];
  1012. for (const key in this.warehousingMaterialList) {
  1013. for (const k in this.warehousingMaterialList[key]
  1014. .outInDetailRecordVOList) {
  1015. arr.push({
  1016. ...this.warehousingMaterialList[key].outInDetailRecordVOList[k],
  1017. weightUnit: this.warehousingMaterialList[key].weightUnit
  1018. });
  1019. }
  1020. }
  1021. this.exitList = arr;
  1022. // localStorage.setItem('exitList', JSON.stringify(arr));
  1023. this.dateTypes = arr[0].dateType;
  1024. // 获取包装维度列表
  1025. this.materialCodeReqList = arr.map((item) => {
  1026. return { ...item, isPack: true };
  1027. });
  1028. let iArr = [];
  1029. arr.forEach((item) => {
  1030. item.outInDetailRecordMaterialDetailVOList.forEach((ele) => {
  1031. iArr.push({ ...ele });
  1032. });
  1033. });
  1034. this.resultArray = iArr.map((item) => {
  1035. return {
  1036. ...item,
  1037. isPack: true,
  1038. result:
  1039. item.result == 0
  1040. ? '0'
  1041. : item.result != null
  1042. ? item.result.toString()
  1043. : ''
  1044. };
  1045. });
  1046. this.wrapFetchData();
  1047. this.materielFetchData();
  1048. }
  1049. // const { data } = await getTreeByPid(0);
  1050. const { data } = await allCategoryLevel();
  1051. this.codeList = data.map((item) => {
  1052. return { dictCode: item.id, dictValue: item.name };
  1053. });
  1054. },
  1055. calcSum(a, b, c, row) {
  1056. if (
  1057. (Number.isNaN(+a) && a !== '') ||
  1058. (Number.isNaN(+b) && b !== '') ||
  1059. (Number.isNaN(+c) && c !== '')
  1060. ) {
  1061. return '';
  1062. }
  1063. return a * b * c + { yuan: '元', wanyuan: '万元' }[row.univalenceUnit];
  1064. },
  1065. contentImageDownload(item) {
  1066. fileSystemDownload(item);
  1067. },
  1068. selectActive(num) {
  1069. this.num = num;
  1070. }
  1071. }
  1072. };
  1073. </script>
  1074. <style lang="scss" scoped>
  1075. ::v-deep .page-title {
  1076. border-bottom: none;
  1077. }
  1078. ::v-deep .page-title-div {
  1079. width: 100%;
  1080. }
  1081. .stepsStatus {
  1082. width: 40%;
  1083. margin: 0 auto;
  1084. }
  1085. .el-form-item {
  1086. margin-bottom: 10px;
  1087. }
  1088. .p20 {
  1089. padding: 20px;
  1090. }
  1091. .flex {
  1092. display: flex;
  1093. }
  1094. .title {
  1095. justify-content: space-between;
  1096. border-bottom: 1px solid #ccc;
  1097. padding-bottom: 5px;
  1098. span {
  1099. font-size: 16px;
  1100. }
  1101. .col {
  1102. padding-left: 40px;
  1103. font-size: 14px;
  1104. color: #aaaaaa;
  1105. }
  1106. }
  1107. .degree {
  1108. margin-right: 10px;
  1109. padding: 0px 15px;
  1110. color: #fff;
  1111. font-size: 13px;
  1112. line-height: 23px;
  1113. border-radius: 23px;
  1114. display: flex;
  1115. align-items: center;
  1116. justify-content: space-between;
  1117. span {
  1118. width: 5px;
  1119. height: 5px;
  1120. border-radius: 100%;
  1121. margin-right: 6px;
  1122. background-color: #fff;
  1123. }
  1124. }
  1125. .red {
  1126. background-color: rgb(163, 0, 20);
  1127. }
  1128. .blue {
  1129. background-color: #1989fa;
  1130. }
  1131. .createdInfo {
  1132. justify-content: space-around;
  1133. margin-top: 10px;
  1134. font-size: 14px;
  1135. .col {
  1136. color: #6e6e6e;
  1137. padding-right: 10px;
  1138. }
  1139. }
  1140. .mt40 {
  1141. margin-top: 40px;
  1142. }
  1143. .custSteps {
  1144. margin-top: 20px;
  1145. margin-left: 70px;
  1146. .box {
  1147. width: 158px;
  1148. border: 1px solid #ccc;
  1149. padding: 10px;
  1150. flex-direction: row;
  1151. flex-wrap: wrap;
  1152. // justify-content: space-between;
  1153. font-size: 12px;
  1154. color: #9e9e9e;
  1155. .x {
  1156. width: 20px;
  1157. height: 15px;
  1158. margin-right: 5px;
  1159. }
  1160. .q {
  1161. background-color: #d0e4d5;
  1162. }
  1163. .b {
  1164. background-color: #1989fa;
  1165. }
  1166. .g {
  1167. background-color: #157a2c;
  1168. }
  1169. .r {
  1170. background-color: #a30014;
  1171. }
  1172. .a {
  1173. align-items: center;
  1174. margin-bottom: 10px;
  1175. }
  1176. .mr10 {
  1177. margin-right: 10px;
  1178. }
  1179. .mb0 {
  1180. margin-bottom: 0;
  1181. }
  1182. }
  1183. .stepsInfo {
  1184. // flex: 1;
  1185. width: 483px;
  1186. }
  1187. }
  1188. .mt20 {
  1189. margin-top: 20px;
  1190. }
  1191. .content-detail {
  1192. overflow: hidden;
  1193. }
  1194. .executor {
  1195. font-size: 14px;
  1196. .col {
  1197. color: #6e6e6e;
  1198. padding-right: 10px;
  1199. }
  1200. }
  1201. .result {
  1202. justify-content: space-around;
  1203. }
  1204. .mr20 {
  1205. margin-right: 20px;
  1206. }
  1207. .details {
  1208. font-size: 14px;
  1209. margin-bottom: 10px;
  1210. }
  1211. .customSteps {
  1212. margin-top: 40px;
  1213. font-size: 14px;
  1214. margin-left: 80px;
  1215. .time {
  1216. font-size: 12px;
  1217. color: #6e6e6e;
  1218. margin-right: 20px;
  1219. position: relative;
  1220. &::after {
  1221. content: '';
  1222. width: 1px;
  1223. height: 100%;
  1224. background-color: #157a2c;
  1225. position: absolute;
  1226. right: -26px;
  1227. }
  1228. }
  1229. .flex:last-child {
  1230. .time {
  1231. &::after {
  1232. display: none;
  1233. }
  1234. }
  1235. }
  1236. .round {
  1237. margin-right: 20px;
  1238. width: 10px;
  1239. height: 10px;
  1240. border-radius: 100%;
  1241. background-color: #157a2c;
  1242. position: relative;
  1243. span {
  1244. position: absolute;
  1245. top: 50%;
  1246. left: 50%;
  1247. width: 4px;
  1248. height: 4px;
  1249. background-color: #fff;
  1250. border-radius: 100%;
  1251. transform: translate(-2px, -2px);
  1252. }
  1253. }
  1254. .text {
  1255. .info {
  1256. margin-top: 10px;
  1257. width: 955px;
  1258. background-color: #f0f3f3;
  1259. overflow: hidden;
  1260. padding: 10px;
  1261. margin-bottom: 10px;
  1262. }
  1263. }
  1264. }
  1265. .switch_left li {
  1266. border-right: 1px solid rgba(222, 222, 222, 1);
  1267. border-left: 1px solid rgba(222, 222, 222, 1);
  1268. }
  1269. </style>