From 355c45a2e4cfe79042c3e9a32f975882a984c56e Mon Sep 17 00:00:00 2001 From: kkfluous Date: Wed, 29 Apr 2026 17:21:37 +0800 Subject: [PATCH] =?UTF-8?q?fix(assets):=20=E5=8C=BA=E5=9F=9F=E8=BD=A6?= =?UTF-8?q?=E5=9E=8B=E5=88=86=E8=A7=A3=E6=96=B0=E5=A2=9E=E3=80=8C=E5=BE=85?= =?UTF-8?q?=E4=BA=A4=E8=BD=A6=E3=80=8D=E5=AD=97=E6=AE=B5=EF=BC=8C=E5=B9=B6?= =?UTF-8?q?=E5=90=88=E5=85=A5=E3=80=8C=E5=85=B6=E4=BB=96=E3=80=8D=E8=BD=A6?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - typeBreakdown 之前只产 4.5T/18T/49T 且仅含 inventory 字段, 导致区域级 待交车 与车型级 待:N 不一致、操作中合计 != 区域合计 - 后端 getTypeBreakdown 计算 pending(status==='Pending'), 并把不属 4.5T/18T/49T 的车辆聚合为「其他」类型 - 前端区域 mobile/desktop 视图把「待:」从 inventory 改读 pending - 点击穿透的 category 也由 'Inventory' 改 'Pending' Co-Authored-By: Claude Opus 4.7 (1M context) --- src/modules/assets/AssetsModule.tsx | 6 +++--- src/modules/assets/types.ts | 1 + src/server/routes/vehicles.ts | 20 +++++++++++++++----- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/modules/assets/AssetsModule.tsx b/src/modules/assets/AssetsModule.tsx index f304dcd..2d44df6 100644 --- a/src/modules/assets/AssetsModule.tsx +++ b/src/modules/assets/AssetsModule.tsx @@ -2189,7 +2189,7 @@ export default function AssetsModule() { setShowPlateNumbers({ batch: 'All', model: 'All', location: city.city, vehicleType: tb.type, source: 'region', title: `区域运营统计 - ${city.city} - ${tb.type}` })}>{tb.total} setShowPlateNumbers({ batch: 'All', model: 'All', location: city.city, vehicleType: tb.type, category: 'Operating', source: 'region', title: `区域运营统计 - ${city.city} - ${tb.type} - 正在运营` })}>{tb.operating} - { setShowPlateNumbers({ batch: 'All', model: 'All', location: city.city, vehicleType: tb.type, category: 'Inventory', source: 'region', title: `区域运营统计 - ${city.city} - ${tb.type} - 库存` }); }}>{tb.inventory} + { setShowPlateNumbers({ batch: 'All', model: 'All', location: city.city, vehicleType: tb.type, category: 'Pending', source: 'region', title: `区域运营统计 - ${city.city} - ${tb.type} - 待交车` }); }}>{tb.pending} {tb.customers.slice(0, 2).join(', ')} ))} @@ -2251,9 +2251,9 @@ export default function AssetsModule() { setShowPlateNumbers({ batch: 'All', model: 'All', location: r.region, vehicleType: tb.type, category: 'Inventory', source: 'region', title: `区域运营统计 - ${r.region} - ${tb.type} - 库存` })} + onClick={() => setShowPlateNumbers({ batch: 'All', model: 'All', location: r.region, vehicleType: tb.type, category: 'Pending', source: 'region', title: `区域运营统计 - ${r.region} - ${tb.type} - 待交车` })} > - 待:{tb.inventory} + 待:{tb.pending} diff --git a/src/modules/assets/types.ts b/src/modules/assets/types.ts index 1d679a1..425fec2 100644 --- a/src/modules/assets/types.ts +++ b/src/modules/assets/types.ts @@ -152,6 +152,7 @@ export interface RegionTypeBreakdown { total: number; operating: number; inventory: number; + pending: number; customers: string[]; } diff --git a/src/server/routes/vehicles.ts b/src/server/routes/vehicles.ts index 2836923..8c83895 100644 --- a/src/server/routes/vehicles.ts +++ b/src/server/routes/vehicles.ts @@ -793,11 +793,21 @@ app.get('/region-stats', async (c) => { cityMap.get(city)!.push(v); } - const getTypeBreakdown = (vList: Vehicle[]) => - ['4.5T', '18T', '49T'].map((type) => { - const tv = vList.filter((v) => v.type === type); - return { type, total: tv.length, operating: tv.filter((v) => v.status === 'Operating').length, inventory: tv.filter((v) => v.status === 'Inventory').length, customers: Array.from(new Set(tv.map((v) => v.customerName).filter(Boolean))) as string[] }; - }).filter((t) => t.total > 0); + const getTypeBreakdown = (vList: Vehicle[]) => { + const KNOWN = ['4.5T', '18T', '49T'] as const; + const make = (label: string, tv: Vehicle[]) => ({ + type: label, + total: tv.length, + operating: tv.filter((v) => v.status === 'Operating').length, + inventory: tv.filter((v) => v.status === 'Inventory').length, + pending: tv.filter((v) => v.status === 'Pending').length, + customers: Array.from(new Set(tv.map((v) => v.customerName).filter(Boolean))) as string[], + }); + const known = KNOWN.map((type) => make(type, vList.filter((v) => v.type === type))); + const other = vList.filter((v) => !KNOWN.includes(v.type as typeof KNOWN[number])); + if (other.length > 0) known.push(make('其他', other)); + return known.filter((t) => t.total > 0); + }; const regionOrder = ['华东', '华南', '华北', '华中', '西南', '西北', '其他']; const result = regionOrder