优化盘点范围选择数据加载逻辑,将库区和库位的循环查询改为批量查询,新增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

@@ -5,6 +5,7 @@ export interface LocationQueryParams {
keyword?: string;
warehouseId?: string;
zoneId?: string;
zoneIds?: string[];
status?: string;
pageNum?: number;
pageSize?: number;

View File

@@ -31,7 +31,7 @@ export interface InventoryCountParams {
// 获取盘点任务列表
export function listInventoryCounts(params?: InventoryCountQueryParams) {
return newService({
url: '/inventory/count/listInventoryCounts',
url: 'assets/inventory/count/listInventoryCounts',
method: 'get',
params,
});
@@ -40,7 +40,7 @@ export function listInventoryCounts(params?: InventoryCountQueryParams) {
// 获取盘点任务详情
export function getInventoryCount(id: string) {
return newService({
url: '/inventory/count/getInventoryCount',
url: 'assets/inventory/count/getInventoryCount',
method: 'get',
params: { id },
});
@@ -49,7 +49,7 @@ export function getInventoryCount(id: string) {
// 创建盘点任务
export function createInventoryCount(data: InventoryCountParams) {
return newService({
url: '/inventory/count/createInventoryCount',
url: 'assets/inventory/count/createInventoryCount',
method: 'post',
data,
});
@@ -58,7 +58,7 @@ export function createInventoryCount(data: InventoryCountParams) {
// 更新盘点任务
export function updateInventoryCount(data: InventoryCountParams) {
return newService({
url: '/inventory/count/updateInventoryCount',
url: 'assets/inventory/count/updateInventoryCount',
method: 'put',
data,
});
@@ -67,7 +67,7 @@ export function updateInventoryCount(data: InventoryCountParams) {
// 删除盘点任务
export function deleteInventoryCount(id: string) {
return newService({
url: '/inventory/count/deleteInventoryCount',
url: 'assets/inventory/count/deleteInventoryCount',
method: 'delete',
params: { id },
});
@@ -76,7 +76,7 @@ export function deleteInventoryCount(id: string) {
// 完成盘点
export function completeInventoryCount(id: string) {
return newService({
url: '/inventory/count/completeInventoryCount',
url: 'assets/inventory/count/completeInventoryCount',
method: 'post',
data: { id },
});
@@ -85,7 +85,7 @@ export function completeInventoryCount(id: string) {
// 取消盘点
export function cancelInventoryCount(id: string[], reason?: string) {
return newService({
url: '/inventory/count/cancelInventoryCount',
url: 'assets/inventory/count/cancelInventoryCount',
method: 'post',
data: { id, reason },
});
@@ -94,7 +94,7 @@ export function cancelInventoryCount(id: string[], reason?: string) {
// 导出盘点模板
export function exportInventoryCountTemplate() {
return newService({
url: '/inventory/count/exportInventoryCountTemplate',
url: 'assets/inventory/count/exportInventoryCountTemplate',
method: 'get',
responseType: 'blob',
});
@@ -105,7 +105,7 @@ export function importInventoryCount(file: File) {
const formData = new FormData();
formData.append('file', file);
return newService({
url: '/inventory/count/importInventoryCount',
url: 'assets/inventory/count/importInventoryCount',
method: 'post',
data: formData,
headers: {

View File

@@ -4,6 +4,7 @@ import { newService } from '/@/utils/request';
export interface ZoneQueryParams {
keyword?: string;
warehouseId?: string;
warehouseIds?: string[];
status?: string;
pageNum?: number;
pageSize?: number;
@@ -16,7 +17,6 @@ export interface ZoneData {
zoneCode?: string;
zoneType?: string;
warehouseId: string;
capacity?: number;
status?: string;
remark?: string;
}

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;
}
// 恢复选中状态