refactor(WarehouseInterlaced): 简化仓库位置ID的过滤逻辑

移除冗余的统计和过滤步骤,直接使用去重后的splitIds作为locationIds
This commit is contained in:
砂糖
2025-12-20 15:58:14 +08:00
parent 720e2d514f
commit 517157bcb0

View File

@@ -238,15 +238,16 @@ export default {
if (layer2Warehouses[i]) splitIds.push(layer2Warehouses[i].parentId);
}
// 1. 先统计每个 parentId 出现的次数
const countMap = splitIds.reduce((map, id) => {
map.set(id, (map.get(id) || 0) + 1);
return map;
}, new Map());
// const countMap = splitIds.reduce((map, id) => {
// map.set(id, (map.get(id) || 0) + 1);
// return map;
// }, new Map());
// 2. 过滤出至少出现两次的 parentId再去重map的key本身唯一去重可省略但保留更严谨
payload.locationIds = [...new Set(
splitIds.filter(id => countMap.get(id) >= 2)
)];
// payload.locationIds = [...new Set(
// splitIds.filter(id => countMap.get(id) >= 2)
// )];
payload.locationIds = [...new Set(splitIds)]
console.log(payload)
this.handleMergeWarehouse(payload);
} else if (newLevel === 4) {