diff --git a/src/server/routes/vehicles.ts b/src/server/routes/vehicles.ts index 7935116..034a78f 100644 --- a/src/server/routes/vehicles.ts +++ b/src/server/routes/vehicles.ts @@ -112,11 +112,12 @@ function mapInventoryRegion(region: string): string { // Map rental status to frontend status // Actual DB values: 在库(0), 自营(1), 租赁(2), 待交车(7), 挂靠(8), 异动(12) -function mapStatus(rentStatus: string | null): 'Operating' | 'Inventory' | 'Abnormal' { +function mapStatus(rentStatus: string | null): 'Operating' | 'Inventory' | 'Pending' | 'Abnormal' { if (!rentStatus) return 'Inventory'; const s = rentStatus.trim(); if (s === '租赁' || s === '自营' || s === '挂靠') return 'Operating'; - if (s === '在库' || s === '待交车') return 'Inventory'; + if (s === '在库') return 'Inventory'; + if (s === '待交车') return 'Pending'; if (s === '异动') return 'Abnormal'; return 'Inventory'; } @@ -324,7 +325,7 @@ function getStats(list: Vehicle[], weeklyIds?: WeeklyTruckIds) { list.filter((v) => v.status === 'Inventory'), REGIONS, ), - pending: weeklyIds ? strIds.filter((id) => weeklyIds.pending.has(id)).length : 0, + pending: list.filter((v) => v.status === 'Pending').length, operating: list.filter((v) => v.status === 'Operating').length, weeklyDelivered: weeklyIds ? strIds.filter((id) => weeklyIds.delivered.has(id)).length : 0, weeklyReturned: weeklyIds ? strIds.filter((id) => weeklyIds.returned.has(id)).length : 0, @@ -457,11 +458,16 @@ app.get('/summary', async (c) => { hanging: vehicles.filter((v) => v.status === 'Operating' && v.ownership === 'Hanging').length, }, inventory: { - total: vehicles.filter((v) => v.status === 'Inventory').length, + total: vehicles.filter((v) => v.status === 'Inventory' || v.status === 'Abnormal').length, inStock: vehicles.filter((v) => v.status === 'Inventory').length, abnormal: vehicles.filter((v) => v.status === 'Abnormal').length, }, - ...weekly, + pendingDelivery: vehicles.filter((v) => v.status === 'Pending').length, + weeklyNew: weekly.weeklyNew, + weeklyRemoved: weekly.weeklyRemoved, + weeklyDelivered: weekly.weeklyDelivered, + weeklyReturned: weekly.weeklyReturned, + weeklyReplaced: weekly.weeklyReplaced, }; return c.json(summary); }); diff --git a/src/server/types.ts b/src/server/types.ts index 9bc1a32..2920cc1 100644 --- a/src/server/types.ts +++ b/src/server/types.ts @@ -36,7 +36,7 @@ export interface Vehicle { color: string; location: string; region: string; - status: 'Operating' | 'Inventory' | 'Abnormal'; + status: 'Operating' | 'Inventory' | 'Pending' | 'Abnormal'; ownership: string; rentCompany: string; contractNo: string | null;