优化盘点范围选择数据加载逻辑,将库区和库位的循环查询改为批量查询,新增warehouseIds和zoneIds数组参数支持,移除库区容量字段,修正盘点管理API路径前缀为assets

This commit is contained in:
WUSIJIAN
2026-02-26 17:42:45 +08:00
parent ddae4f9173
commit 6d02a00862
4 changed files with 29 additions and 42 deletions

View File

@@ -165,49 +165,35 @@ const loadData = async () => {
}));
total.value = res.data?.total || 0;
} else if (scope.value === 2) {
// 加载库区
// 加载库区 - 使用warehouseIds数组一次性查询
if (parentWarehouseIds.value.length === 0) {
tableData.value = [];
total.value = 0;
return;
}
const allZones: any[] = [];
let totalCount = 0;
for (const warehouseId of parentWarehouseIds.value) {
res = await listZones({ ...params, warehouseId });
const list = res.data?.list || res.data?.items || res.data || [];
const zones = (Array.isArray(list) ? list : []).map((item: any) => ({
id: item.id || item._id,
name: item.zoneName || item.name,
code: item.zoneCode || item.code,
}));
allZones.push(...zones);
totalCount += res.data?.total || zones.length;
}
tableData.value = allZones;
total.value = totalCount;
res = await listZones({ ...params, warehouseIds: parentWarehouseIds.value });
const list = res.data?.list || res.data?.items || res.data || [];
tableData.value = (Array.isArray(list) ? list : []).map((item: any) => ({
id: item.id || item._id,
name: item.zoneName || item.name,
code: item.zoneCode || item.code,
}));
total.value = res.data?.total || tableData.value.length;
} else if (scope.value === 3) {
// 加载库位
// 加载库位 - 使用zoneIds数组一次性查询
if (parentZoneIds.value.length === 0) {
tableData.value = [];
total.value = 0;
return;
}
const allLocations: any[] = [];
let totalCount = 0;
for (const zoneId of parentZoneIds.value) {
res = await listLocations({ ...params, zoneId });
const list = res.data?.list || res.data?.items || res.data || [];
const locations = (Array.isArray(list) ? list : []).map((item: any) => ({
id: item.id || item._id,
name: item.locationName || item.name,
code: item.locationCode || item.code,
}));
allLocations.push(...locations);
totalCount += res.data?.total || locations.length;
}
tableData.value = allLocations;
total.value = totalCount;
res = await listLocations({ ...params, zoneIds: parentZoneIds.value });
const list = res.data?.list || res.data?.items || res.data || [];
tableData.value = (Array.isArray(list) ? list : []).map((item: any) => ({
id: item.id || item._id,
name: item.locationName || item.name,
code: item.locationCode || item.code,
}));
total.value = res.data?.total || tableData.value.length;
}
// 恢复选中状态