| | |
| | | |
| | | } |
| | | |
| | | // 使用一个对象来存储合并后的结果 |
| | | const mergedData = produceList.value.reduce((acc, item) => { |
| | | const processId = item.detail[0].process_id; |
| | | // detail 为空直接跳过 |
| | | const firstDetail = item?.detail?.[0] |
| | | if (!firstDetail) return acc |
| | | |
| | | // 如果该 process_id 尚未在 acc 中,初始化其数组 |
| | | if (!acc[processId]) { |
| | | acc[processId] = { |
| | | const processId = firstDetail.process_id |
| | | const technologyNumber = firstDetail.technologyNumber |
| | | |
| | | const key = company.printReplenishMerge |
| | | ? processId |
| | | : `${processId}_${technologyNumber}` |
| | | |
| | | // 初始化分组 |
| | | if (!acc[key]) { |
| | | acc[key] = { |
| | | processId, |
| | | technologyNumber, |
| | | processList: item.processList, |
| | | detailList: [], |
| | | detail: item.detail |
| | | }; |
| | | } |
| | | } |
| | | |
| | | // 合并 detailList |
| | | acc[processId].detailList = acc[processId].detailList.concat(item.detailList); |
| | | // 合并 detailList |
| | | if (Array.isArray(item.detailList) && item.detailList.length) { |
| | | acc[key].detailList.push(...item.detailList) |
| | | } |
| | | |
| | | return acc; |
| | | }, {}); |
| | | return acc |
| | | }, {}) |
| | | |
| | | // 将合并后的对象转换回数组 |
| | | |
| | | if (company.printReplenishMerge){ |
| | | //if (company.printReplenishMerge){ |
| | | produceList.value = Object.values(mergedData); |
| | | } |
| | | //} |
| | | flowCardCount=produceList.value.length |
| | | |
| | | handleSummary() |