| | |
| | | setTimeout(() => resolve({ code: 200, msg, data }), 120); |
| | | }); |
| | | |
| | | /* ==================== 领用统计 ==================== */ |
| | | |
| | | /** 领用统计行:按产品大类 + 规格型号汇总 */ |
| | | export interface RequisitionStatVO { |
| | | /** 产品大类 */ |
| | | categoryName: string; |
| | | /** 规格型号 */ |
| | | model: string; |
| | | /** 数量(件) */ |
| | | count: number; |
| | | } |
| | | |
| | | /** 从响应里取出统计数组(兼容 data 直接是数组 / 分页对象) */ |
| | | const extractStatRows = (data: any): any[] => { |
| | | if (Array.isArray(data)) return data; |
| | | return data?.records ?? data?.list ?? data?.rows ?? []; |
| | | }; |
| | | |
| | | /** |
| | | * 归一化统计行。 |
| | | * 后端约定:产品大类 categoryName、规格型号 model、数量 count |
| | | * (其余键名为兼容兜底,确认后端字段后可以删掉) |
| | | */ |
| | | const normalizeStatRows = (rows: any[]): RequisitionStatVO[] => |
| | | (rows || []).map((row) => ({ |
| | | categoryName: String(row?.categoryName ?? row?.productCategory ?? ""), |
| | | model: String(row?.model ?? row?.specificationModel ?? ""), |
| | | count: Number(row?.count ?? row?.itemCount ?? 0), |
| | | })); |
| | | |
| | | const mockMaterialCode = (item: any) => |
| | | String(item?.flowCode || item?.batchCode || item?.monofilamentNumber || "").trim(); |
| | | |
| | |
| | | }); |
| | | }, |
| | | |
| | | /** |
| | | * 领用统计:按产品大类 + 规格型号汇总当前已领用数量 |
| | | * POST /timeSensitiveTask/requisitionStats { taskId, materialType } |
| | | */ |
| | | async getRequisitionStats(taskId: number | string, materialType?: string) { |
| | | const res = await request<BaseResult<any>>({ |
| | | url: "/timeSensitiveTask/requisitionStats", |
| | | method: "POST", |
| | | data: { taskId, materialType } as any, |
| | | }); |
| | | return { |
| | | ...res, |
| | | data: normalizeStatRows(extractStatRows(res?.data)), |
| | | } as BaseResult<RequisitionStatVO[]>; |
| | | }, |
| | | |
| | | create(data: TimeSensitiveTaskForm) { |
| | | if (USE_TIME_SENSITIVE_MOCK) { |
| | | const id = Date.now(); |