优化盘点范围选择数据加载逻辑,将库区和库位的循环查询改为批量查询,新增warehouseIds和zoneIds数组参数支持,移除库区容量字段,修正盘点管理API路径前缀为assets
This commit is contained in:
@@ -5,6 +5,7 @@ export interface LocationQueryParams {
|
|||||||
keyword?: string;
|
keyword?: string;
|
||||||
warehouseId?: string;
|
warehouseId?: string;
|
||||||
zoneId?: string;
|
zoneId?: string;
|
||||||
|
zoneIds?: string[];
|
||||||
status?: string;
|
status?: string;
|
||||||
pageNum?: number;
|
pageNum?: number;
|
||||||
pageSize?: number;
|
pageSize?: number;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ export interface InventoryCountParams {
|
|||||||
// 获取盘点任务列表
|
// 获取盘点任务列表
|
||||||
export function listInventoryCounts(params?: InventoryCountQueryParams) {
|
export function listInventoryCounts(params?: InventoryCountQueryParams) {
|
||||||
return newService({
|
return newService({
|
||||||
url: '/inventory/count/listInventoryCounts',
|
url: 'assets/inventory/count/listInventoryCounts',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params,
|
params,
|
||||||
});
|
});
|
||||||
@@ -40,7 +40,7 @@ export function listInventoryCounts(params?: InventoryCountQueryParams) {
|
|||||||
// 获取盘点任务详情
|
// 获取盘点任务详情
|
||||||
export function getInventoryCount(id: string) {
|
export function getInventoryCount(id: string) {
|
||||||
return newService({
|
return newService({
|
||||||
url: '/inventory/count/getInventoryCount',
|
url: 'assets/inventory/count/getInventoryCount',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: { id },
|
params: { id },
|
||||||
});
|
});
|
||||||
@@ -49,7 +49,7 @@ export function getInventoryCount(id: string) {
|
|||||||
// 创建盘点任务
|
// 创建盘点任务
|
||||||
export function createInventoryCount(data: InventoryCountParams) {
|
export function createInventoryCount(data: InventoryCountParams) {
|
||||||
return newService({
|
return newService({
|
||||||
url: '/inventory/count/createInventoryCount',
|
url: 'assets/inventory/count/createInventoryCount',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data,
|
data,
|
||||||
});
|
});
|
||||||
@@ -58,7 +58,7 @@ export function createInventoryCount(data: InventoryCountParams) {
|
|||||||
// 更新盘点任务
|
// 更新盘点任务
|
||||||
export function updateInventoryCount(data: InventoryCountParams) {
|
export function updateInventoryCount(data: InventoryCountParams) {
|
||||||
return newService({
|
return newService({
|
||||||
url: '/inventory/count/updateInventoryCount',
|
url: 'assets/inventory/count/updateInventoryCount',
|
||||||
method: 'put',
|
method: 'put',
|
||||||
data,
|
data,
|
||||||
});
|
});
|
||||||
@@ -67,7 +67,7 @@ export function updateInventoryCount(data: InventoryCountParams) {
|
|||||||
// 删除盘点任务
|
// 删除盘点任务
|
||||||
export function deleteInventoryCount(id: string) {
|
export function deleteInventoryCount(id: string) {
|
||||||
return newService({
|
return newService({
|
||||||
url: '/inventory/count/deleteInventoryCount',
|
url: 'assets/inventory/count/deleteInventoryCount',
|
||||||
method: 'delete',
|
method: 'delete',
|
||||||
params: { id },
|
params: { id },
|
||||||
});
|
});
|
||||||
@@ -76,7 +76,7 @@ export function deleteInventoryCount(id: string) {
|
|||||||
// 完成盘点
|
// 完成盘点
|
||||||
export function completeInventoryCount(id: string) {
|
export function completeInventoryCount(id: string) {
|
||||||
return newService({
|
return newService({
|
||||||
url: '/inventory/count/completeInventoryCount',
|
url: 'assets/inventory/count/completeInventoryCount',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: { id },
|
data: { id },
|
||||||
});
|
});
|
||||||
@@ -85,7 +85,7 @@ export function completeInventoryCount(id: string) {
|
|||||||
// 取消盘点
|
// 取消盘点
|
||||||
export function cancelInventoryCount(id: string[], reason?: string) {
|
export function cancelInventoryCount(id: string[], reason?: string) {
|
||||||
return newService({
|
return newService({
|
||||||
url: '/inventory/count/cancelInventoryCount',
|
url: 'assets/inventory/count/cancelInventoryCount',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: { id, reason },
|
data: { id, reason },
|
||||||
});
|
});
|
||||||
@@ -94,7 +94,7 @@ export function cancelInventoryCount(id: string[], reason?: string) {
|
|||||||
// 导出盘点模板
|
// 导出盘点模板
|
||||||
export function exportInventoryCountTemplate() {
|
export function exportInventoryCountTemplate() {
|
||||||
return newService({
|
return newService({
|
||||||
url: '/inventory/count/exportInventoryCountTemplate',
|
url: 'assets/inventory/count/exportInventoryCountTemplate',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
responseType: 'blob',
|
responseType: 'blob',
|
||||||
});
|
});
|
||||||
@@ -105,7 +105,7 @@ export function importInventoryCount(file: File) {
|
|||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append('file', file);
|
formData.append('file', file);
|
||||||
return newService({
|
return newService({
|
||||||
url: '/inventory/count/importInventoryCount',
|
url: 'assets/inventory/count/importInventoryCount',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: formData,
|
data: formData,
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { newService } from '/@/utils/request';
|
|||||||
export interface ZoneQueryParams {
|
export interface ZoneQueryParams {
|
||||||
keyword?: string;
|
keyword?: string;
|
||||||
warehouseId?: string;
|
warehouseId?: string;
|
||||||
|
warehouseIds?: string[];
|
||||||
status?: string;
|
status?: string;
|
||||||
pageNum?: number;
|
pageNum?: number;
|
||||||
pageSize?: number;
|
pageSize?: number;
|
||||||
@@ -16,7 +17,6 @@ export interface ZoneData {
|
|||||||
zoneCode?: string;
|
zoneCode?: string;
|
||||||
zoneType?: string;
|
zoneType?: string;
|
||||||
warehouseId: string;
|
warehouseId: string;
|
||||||
capacity?: number;
|
|
||||||
status?: string;
|
status?: string;
|
||||||
remark?: string;
|
remark?: string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -165,49 +165,35 @@ const loadData = async () => {
|
|||||||
}));
|
}));
|
||||||
total.value = res.data?.total || 0;
|
total.value = res.data?.total || 0;
|
||||||
} else if (scope.value === 2) {
|
} else if (scope.value === 2) {
|
||||||
// 加载库区
|
// 加载库区 - 使用warehouseIds数组一次性查询
|
||||||
if (parentWarehouseIds.value.length === 0) {
|
if (parentWarehouseIds.value.length === 0) {
|
||||||
tableData.value = [];
|
tableData.value = [];
|
||||||
total.value = 0;
|
total.value = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const allZones: any[] = [];
|
res = await listZones({ ...params, warehouseIds: parentWarehouseIds.value });
|
||||||
let totalCount = 0;
|
const list = res.data?.list || res.data?.items || res.data || [];
|
||||||
for (const warehouseId of parentWarehouseIds.value) {
|
tableData.value = (Array.isArray(list) ? list : []).map((item: any) => ({
|
||||||
res = await listZones({ ...params, warehouseId });
|
id: item.id || item._id,
|
||||||
const list = res.data?.list || res.data?.items || res.data || [];
|
name: item.zoneName || item.name,
|
||||||
const zones = (Array.isArray(list) ? list : []).map((item: any) => ({
|
code: item.zoneCode || item.code,
|
||||||
id: item.id || item._id,
|
}));
|
||||||
name: item.zoneName || item.name,
|
total.value = res.data?.total || tableData.value.length;
|
||||||
code: item.zoneCode || item.code,
|
|
||||||
}));
|
|
||||||
allZones.push(...zones);
|
|
||||||
totalCount += res.data?.total || zones.length;
|
|
||||||
}
|
|
||||||
tableData.value = allZones;
|
|
||||||
total.value = totalCount;
|
|
||||||
} else if (scope.value === 3) {
|
} else if (scope.value === 3) {
|
||||||
// 加载库位
|
// 加载库位 - 使用zoneIds数组一次性查询
|
||||||
if (parentZoneIds.value.length === 0) {
|
if (parentZoneIds.value.length === 0) {
|
||||||
tableData.value = [];
|
tableData.value = [];
|
||||||
total.value = 0;
|
total.value = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const allLocations: any[] = [];
|
res = await listLocations({ ...params, zoneIds: parentZoneIds.value });
|
||||||
let totalCount = 0;
|
const list = res.data?.list || res.data?.items || res.data || [];
|
||||||
for (const zoneId of parentZoneIds.value) {
|
tableData.value = (Array.isArray(list) ? list : []).map((item: any) => ({
|
||||||
res = await listLocations({ ...params, zoneId });
|
id: item.id || item._id,
|
||||||
const list = res.data?.list || res.data?.items || res.data || [];
|
name: item.locationName || item.name,
|
||||||
const locations = (Array.isArray(list) ? list : []).map((item: any) => ({
|
code: item.locationCode || item.code,
|
||||||
id: item.id || item._id,
|
}));
|
||||||
name: item.locationName || item.name,
|
total.value = res.data?.total || tableData.value.length;
|
||||||
code: item.locationCode || item.code,
|
|
||||||
}));
|
|
||||||
allLocations.push(...locations);
|
|
||||||
totalCount += res.data?.total || locations.length;
|
|
||||||
}
|
|
||||||
tableData.value = allLocations;
|
|
||||||
total.value = totalCount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 恢复选中状态
|
// 恢复选中状态
|
||||||
|
|||||||
Reference in New Issue
Block a user