| | |
| | | labelList = a |
| | | |
| | | props.lastList.length = 0; |
| | | for (let i = 0; i < list.value.length; i++) { |
| | | let count = list.value[i].data.length |
| | | for (let j = 0; j < count; j++) { |
| | | for (let k = 0; k < list.value[i].data[j].quantity; k++) { |
| | | props.lastList.push(list.value[i].data[j]) |
| | | // 遍历列表(替换 i 为更语义化的变量名) |
| | | for (const group of list.value) { |
| | | // 遍历每组中的数据(替换 j) |
| | | for (const item of group.data) { |
| | | const { quantity, newList } = item; |
| | | // 跳过 quantity 为 0 或无效的情况 |
| | | if (!quantity || quantity <= 0) continue; |
| | | |
| | | // 处理 newList:确保是数组,不足时用空对象兜底 |
| | | const safeNewList = Array.isArray(newList) ? newList : []; |
| | | |
| | | // 循环 quantity 次,添加数据到 lastList |
| | | for (let k = 0; k < quantity; k++) { |
| | | // 深拷贝 item,避免重复引用(关键!) |
| | | const newItem = JSON.parse(JSON.stringify(item)); |
| | | |
| | | // 若 newList 有对应索引数据,填充字段;否则置空 |
| | | const listItem = safeNewList[k]; |
| | | if (listItem) { |
| | | newItem.heat_layout_sort = listItem.glass_id || ''; // 兜底空字符串 |
| | | newItem.stockPolysId = `${listItem.stock_id || ''}/${listItem.polys_id || ''}`; // 避免 undefined/ |
| | | } else { |
| | | // 无对应数据时,字段置空(避免保留原始值) |
| | | newItem.heat_layout_sort = ''; |
| | | newItem.stockPolysId = ''; |
| | | } |
| | | |
| | | // 添加到目标列表 |
| | | props.lastList.push(newItem); |
| | | } |
| | | } |
| | | } |
| | | console.log(props) |
| | | } else { |
| | | ElMessage.warning(res.msg) |
| | | } |