From dd01671d9e25ed103605eee47b4a5d72f9d7f6b0 Mon Sep 17 00:00:00 2001 From: kkfluous Date: Sat, 28 Mar 2026 18:28:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=8C=BA=E5=9F=9F=E8=BF=90=E8=90=A5?= =?UTF-8?q?=E7=A7=BB=E5=8A=A8=E7=AB=AF=E6=95=B0=E6=8D=AE=E3=80=81=E4=B8=8B?= =?UTF-8?q?=E9=92=BB=E6=94=AF=E6=8C=81=E5=9F=8E=E5=B8=82/=E8=BD=A6?= =?UTF-8?q?=E5=9E=8B=E3=80=81=E7=BD=91=E9=A1=B5=E6=A0=87=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移动端区域运营改用regionData真实数据(去掉Math.floor模拟) - 区域/城市/车型行数字全部支持点击下钻 - 后端/list支持按车型大类过滤(如4.5T含普货+冷链) - 网页标题改为"羚牛氢能车辆资产" Co-Authored-By: Claude Opus 4.6 (1M context) --- index.html | 2 +- src/App.tsx | 99 ++++++++++++++--------------------- src/server/routes/vehicles.ts | 10 +++- 3 files changed, 49 insertions(+), 62 deletions(-) diff --git a/index.html b/index.html index bf11662..e1b2327 100644 --- a/index.html +++ b/index.html @@ -3,7 +3,7 @@ - 羚牛 BI 报表 + 羚牛氢能车辆资产
diff --git a/src/App.tsx b/src/App.tsx index 7ce8329..01b559b 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -2225,9 +2225,9 @@ export default function App() { {r.region}区域 - {r.totalAssets} - {r.operatingCount} - {r.pendingCount || ''} + { e.stopPropagation(); setShowPlateNumbers({ batch: 'All', model: 'All', location: r.region, category: 'Operating' }); }}>{r.totalAssets} + { e.stopPropagation(); setShowPlateNumbers({ batch: 'All', model: 'All', location: r.region, category: 'Operating' }); }}>{r.operatingCount} + { e.stopPropagation(); if (r.pendingCount) setShowPlateNumbers({ batch: 'All', model: 'All', location: r.region, category: 'Pending' }); }}>{r.pendingCount || ''} {r.customers.slice(0, 2).join(', ')} {isExpanded && r.cities.map((city) => { @@ -2244,9 +2244,9 @@ export default function App() { {city.city} - {city.totalAssets} - {city.operatingCount} - {city.pendingCount || ''} + { e.stopPropagation(); setShowPlateNumbers({ batch: 'All', model: 'All', location: city.city, category: 'Operating' }); }}>{city.totalAssets} + { e.stopPropagation(); setShowPlateNumbers({ batch: 'All', model: 'All', location: city.city, category: 'Operating' }); }}>{city.operatingCount} + { e.stopPropagation(); if (city.pendingCount) setShowPlateNumbers({ batch: 'All', model: 'All', location: city.city, category: 'Pending' }); }}>{city.pendingCount || ''} {city.customers.slice(0, 2).join(', ')} {isCityExpanded && city.typeBreakdown.map(tb => ( @@ -2255,9 +2255,9 @@ export default function App() {
{tb.type} 车型 - {tb.total} - {tb.operating} - {tb.inventory || ''} + setShowPlateNumbers({ batch: 'All', model: 'All', location: city.city, vehicleType: tb.type, category: 'Operating' })}>{tb.total} + setShowPlateNumbers({ batch: 'All', model: 'All', location: city.city, vehicleType: tb.type, category: 'Operating' })}>{tb.operating} + { if (tb.inventory) setShowPlateNumbers({ batch: 'All', model: 'All', location: city.city, vehicleType: tb.type, category: 'Pending' }); }}>{tb.inventory || ''} {tb.customers.slice(0, 2).join(', ')} ))} @@ -2273,78 +2273,59 @@ export default function App() { {/* Mobile View (Region) */}
- {uniqueRegions.filter(r => !regionFilters.region || r === regionFilters.region).map((region) => { - const regionStats = customerData.filter(s => { - const matchRegion = s.region === region; - const matchCity = !regionFilters.city || s.city === regionFilters.city; - const matchCustomer = !regionFilters.customer || s.customer.toLowerCase().includes(regionFilters.customer.toLowerCase()); - return matchRegion && matchCity && matchCustomer; - }); - const totalAssets = regionStats.reduce((acc, s) => acc + s.total, 0); - if (totalAssets === 0) return null; - - const isExpanded = expandedRegions.has(region); - + {regionData.filter(r => !regionFilters.region || r.region === regionFilters.region).map((r) => { + const isExpanded = expandedRegions.has(r.region); return ( -
-
+
toggleRegion(region)} + onClick={() => toggleRegion(r.region)} >
{isExpanded ? : } - {region}区域 + {r.region}区域
-
资产: {totalAssets}
+
资产: {r.totalAssets}
{isExpanded && ( <>
-
setShowPlateNumbers({ batch: 'All', model: 'All', location: 'All', category: 'Operating', source: 'asset' })} + onClick={() => setShowPlateNumbers({ batch: 'All', model: 'All', location: r.region, category: 'Operating', source: 'asset' })} >
运营中
-
{Math.floor(totalAssets * 0.8)}
+
{r.operatingCount}
-
setShowPlateNumbers({ batch: 'All', model: 'All', location: 'All', category: 'Pending', source: 'asset' })} + onClick={() => setShowPlateNumbers({ batch: 'All', model: 'All', location: r.region, category: 'Pending', source: 'asset' })} >
待交车
-
{Math.floor(totalAssets * 0.05)}
+
{r.pendingCount || ''}
- {['4.5T', '18T', '49T'].map(type => { - const typeTotal = regionStats.reduce((acc, s) => { - if (type === '4.5T') return acc + s.t4_5 + s.t4_5c; - if (type === '18T') return acc + s.t18; - if (type === '49T') return acc + s.t49; - return acc; - }, 0); - if (typeTotal === 0) return null; - return ( -
- {type} 车型 -
- setShowPlateNumbers({ batch: 'All', model: 'All', location: 'All', type, category: 'Operating', source: 'asset' })} - > - 运:{Math.floor(typeTotal * 0.8)} - - setShowPlateNumbers({ batch: 'All', model: 'All', location: 'All', type, category: 'Pending', source: 'asset' })} - > - 待:{Math.floor(typeTotal * 0.05)} - -
+ {r.typeBreakdown.map(tb => ( +
+ {tb.type} 车型 +
+ setShowPlateNumbers({ batch: 'All', model: 'All', location: r.region, type: tb.type, category: 'Operating', source: 'asset' })} + > + 运:{tb.operating} + + setShowPlateNumbers({ batch: 'All', model: 'All', location: r.region, type: tb.type, category: 'Pending', source: 'asset' })} + > + 待:{tb.inventory || ''} +
- ); - })} +
+ ))}
)} diff --git a/src/server/routes/vehicles.ts b/src/server/routes/vehicles.ts index 462440a..7df9f80 100644 --- a/src/server/routes/vehicles.ts +++ b/src/server/routes/vehicles.ts @@ -860,8 +860,14 @@ app.get('/list', async (c) => { const { batch, model, location, status, category, vehicleType, manager, customer, isColdChain, isTrailer } = c.req.query(); let filtered = vehicles; - if (vehicleType && VEHICLE_TYPE_FILTERS[vehicleType]) { - filtered = filtered.filter(VEHICLE_TYPE_FILTERS[vehicleType]); + if (vehicleType) { + if (VEHICLE_TYPE_FILTERS[vehicleType]) { + filtered = filtered.filter(VEHICLE_TYPE_FILTERS[vehicleType]); + } else if (vehicleType === '4.5T') { + filtered = filtered.filter((v) => v.type === '4.5T'); + } else { + filtered = filtered.filter((v) => v.type === vehicleType); + } } if (batch && batch !== 'All') { filtered = filtered.filter((v) => (v.contractNo || '未知') === batch);