fix: 库存批次改为车型名称、区域待交车数量始终显示
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
- 库存统计:移除批次筛选(原显示contractNo),batch字段改为model - 区域Tab:待交车和库存数量即使为0也显示数字,移除|| ''和if守卫 - 桌面端和移动端的pendingCount/inventory全部始终显示 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
17
src/App.tsx
17
src/App.tsx
@@ -957,13 +957,6 @@ export default function App() {
|
|||||||
{uniqueInventoryBrands.map(b => <option key={b} value={b}>{b}</option>)}
|
{uniqueInventoryBrands.map(b => <option key={b} value={b}>{b}</option>)}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
|
||||||
<label className="text-[10px] text-slate-400 block mb-1">批次</label>
|
|
||||||
<select value={inventoryFilters.batch} onChange={(e) => setInventoryFilters({...inventoryFilters, batch: e.target.value})} className="w-full text-xs bg-white border border-slate-200 rounded-lg px-2 py-1.5 focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500 transition-all shadow-sm cursor-pointer">
|
|
||||||
<option value="">全部批次</option>
|
|
||||||
{uniqueInventoryBatches.map(b => <option key={b} value={b}>{b}</option>)}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div>
|
<div>
|
||||||
<label className="text-[10px] text-slate-400 block mb-1">车型名称</label>
|
<label className="text-[10px] text-slate-400 block mb-1">车型名称</label>
|
||||||
<div className="relative">
|
<div className="relative">
|
||||||
@@ -1911,7 +1904,7 @@ export default function App() {
|
|||||||
</td>
|
</td>
|
||||||
<td className="p-2 text-center font-bold text-slate-600 cursor-pointer hover:underline" onClick={(e) => { e.stopPropagation(); setShowPlateNumbers({ batch: 'All', model: 'All', location: r.region, source: 'region', title: `区域运营统计 - ${r.region}` }); }}>{r.totalAssets}</td>
|
<td className="p-2 text-center font-bold text-slate-600 cursor-pointer hover:underline" onClick={(e) => { e.stopPropagation(); setShowPlateNumbers({ batch: 'All', model: 'All', location: r.region, source: 'region', title: `区域运营统计 - ${r.region}` }); }}>{r.totalAssets}</td>
|
||||||
<td className="p-2 text-center text-green-600 font-bold cursor-pointer hover:underline" onClick={(e) => { e.stopPropagation(); setShowPlateNumbers({ batch: 'All', model: 'All', location: r.region, category: 'Operating', source: 'region', title: `区域运营统计 - ${r.region} - 正在运营` }); }}>{r.operatingCount}</td>
|
<td className="p-2 text-center text-green-600 font-bold cursor-pointer hover:underline" onClick={(e) => { e.stopPropagation(); setShowPlateNumbers({ batch: 'All', model: 'All', location: r.region, category: 'Operating', source: 'region', title: `区域运营统计 - ${r.region} - 正在运营` }); }}>{r.operatingCount}</td>
|
||||||
<td className="p-2 text-center text-orange-600 font-bold cursor-pointer hover:underline" onClick={(e) => { e.stopPropagation(); if (r.pendingCount) setShowPlateNumbers({ batch: 'All', model: 'All', location: r.region, category: 'Pending', source: 'region', title: `区域运营统计 - ${r.region} - 待交车` }); }}>{r.pendingCount || ''}</td>
|
<td className="p-2 text-center text-orange-600 font-bold cursor-pointer hover:underline" onClick={(e) => { e.stopPropagation(); setShowPlateNumbers({ batch: 'All', model: 'All', location: r.region, category: 'Pending', source: 'region', title: `区域运营统计 - ${r.region} - 待交车` }); }}>{r.pendingCount}</td>
|
||||||
<td className="p-2 text-center text-slate-500 font-medium">{r.customers.slice(0, 2).join(', ')}</td>
|
<td className="p-2 text-center text-slate-500 font-medium">{r.customers.slice(0, 2).join(', ')}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{isExpanded && r.cities.map((city) => {
|
{isExpanded && r.cities.map((city) => {
|
||||||
@@ -1930,7 +1923,7 @@ export default function App() {
|
|||||||
</td>
|
</td>
|
||||||
<td className="p-2 text-center text-slate-600 font-medium cursor-pointer hover:underline" onClick={(e) => { e.stopPropagation(); setShowPlateNumbers({ batch: 'All', model: 'All', location: city.city, source: 'region', title: `区域运营统计 - ${city.city}` }); }}>{city.totalAssets}</td>
|
<td className="p-2 text-center text-slate-600 font-medium cursor-pointer hover:underline" onClick={(e) => { e.stopPropagation(); setShowPlateNumbers({ batch: 'All', model: 'All', location: city.city, source: 'region', title: `区域运营统计 - ${city.city}` }); }}>{city.totalAssets}</td>
|
||||||
<td className="p-2 text-center text-green-600 cursor-pointer hover:underline" onClick={(e) => { e.stopPropagation(); setShowPlateNumbers({ batch: 'All', model: 'All', location: city.city, category: 'Operating', source: 'region', title: `区域运营统计 - ${city.city} - 正在运营` }); }}>{city.operatingCount}</td>
|
<td className="p-2 text-center text-green-600 cursor-pointer hover:underline" onClick={(e) => { e.stopPropagation(); setShowPlateNumbers({ batch: 'All', model: 'All', location: city.city, category: 'Operating', source: 'region', title: `区域运营统计 - ${city.city} - 正在运营` }); }}>{city.operatingCount}</td>
|
||||||
<td className="p-2 text-center text-orange-600 cursor-pointer hover:underline" onClick={(e) => { e.stopPropagation(); if (city.pendingCount) setShowPlateNumbers({ batch: 'All', model: 'All', location: city.city, category: 'Pending', source: 'region', title: `区域运营统计 - ${city.city} - 待交车` }); }}>{city.pendingCount || ''}</td>
|
<td className="p-2 text-center text-orange-600 cursor-pointer hover:underline" onClick={(e) => { e.stopPropagation(); setShowPlateNumbers({ batch: 'All', model: 'All', location: city.city, category: 'Pending', source: 'region', title: `区域运营统计 - ${city.city} - 待交车` }); }}>{city.pendingCount}</td>
|
||||||
<td className="p-2 text-center text-slate-400 text-[10px] italic">{city.customers.slice(0, 2).join(', ')}</td>
|
<td className="p-2 text-center text-slate-400 text-[10px] italic">{city.customers.slice(0, 2).join(', ')}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{isCityExpanded && city.typeBreakdown.map(tb => (
|
{isCityExpanded && city.typeBreakdown.map(tb => (
|
||||||
@@ -1941,7 +1934,7 @@ export default function App() {
|
|||||||
</td>
|
</td>
|
||||||
<td className="p-2 text-center text-gray-500 cursor-pointer hover:underline" onClick={() => setShowPlateNumbers({ batch: 'All', model: 'All', location: city.city, vehicleType: tb.type, source: 'region', title: `区域运营统计 - ${city.city} - ${tb.type}` })}>{tb.total}</td>
|
<td className="p-2 text-center text-gray-500 cursor-pointer hover:underline" onClick={() => setShowPlateNumbers({ batch: 'All', model: 'All', location: city.city, vehicleType: tb.type, source: 'region', title: `区域运营统计 - ${city.city} - ${tb.type}` })}>{tb.total}</td>
|
||||||
<td className="p-2 text-center text-green-500 cursor-pointer hover:underline" onClick={() => setShowPlateNumbers({ batch: 'All', model: 'All', location: city.city, vehicleType: tb.type, category: 'Operating', source: 'region', title: `区域运营统计 - ${city.city} - ${tb.type} - 正在运营` })}>{tb.operating}</td>
|
<td className="p-2 text-center text-green-500 cursor-pointer hover:underline" onClick={() => setShowPlateNumbers({ batch: 'All', model: 'All', location: city.city, vehicleType: tb.type, category: 'Operating', source: 'region', title: `区域运营统计 - ${city.city} - ${tb.type} - 正在运营` })}>{tb.operating}</td>
|
||||||
<td className="p-2 text-center text-orange-500 cursor-pointer hover:underline" onClick={() => { if (tb.inventory) setShowPlateNumbers({ batch: 'All', model: 'All', location: city.city, vehicleType: tb.type, category: 'Inventory', source: 'region', title: `区域运营统计 - ${city.city} - ${tb.type} - 库存` }); }}>{tb.inventory || ''}</td>
|
<td className="p-2 text-center text-orange-500 cursor-pointer hover:underline" onClick={() => { setShowPlateNumbers({ batch: 'All', model: 'All', location: city.city, vehicleType: tb.type, category: 'Inventory', source: 'region', title: `区域运营统计 - ${city.city} - ${tb.type} - 库存` }); }}>{tb.inventory}</td>
|
||||||
<td className="p-2 text-center text-gray-400 text-[10px] italic">{tb.customers.slice(0, 2).join(', ')}</td>
|
<td className="p-2 text-center text-gray-400 text-[10px] italic">{tb.customers.slice(0, 2).join(', ')}</td>
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
))}
|
||||||
@@ -1987,7 +1980,7 @@ export default function App() {
|
|||||||
onClick={() => setShowPlateNumbers({ batch: 'All', model: 'All', location: r.region, category: 'Pending', source: 'region', title: `区域运营统计 - ${r.region} - 待交车` })}
|
onClick={() => setShowPlateNumbers({ batch: 'All', model: 'All', location: r.region, category: 'Pending', source: 'region', title: `区域运营统计 - ${r.region} - 待交车` })}
|
||||||
>
|
>
|
||||||
<div className="text-[9px] text-gray-400 uppercase">待交车</div>
|
<div className="text-[9px] text-gray-400 uppercase">待交车</div>
|
||||||
<div className="text-xs font-bold text-orange-600">{r.pendingCount || ''}</div>
|
<div className="text-xs font-bold text-orange-600">{r.pendingCount}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="px-2 pb-2 space-y-1">
|
<div className="px-2 pb-2 space-y-1">
|
||||||
@@ -2005,7 +1998,7 @@ export default function App() {
|
|||||||
className="font-bold text-orange-600 cursor-pointer"
|
className="font-bold text-orange-600 cursor-pointer"
|
||||||
onClick={() => 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: 'Inventory', source: 'region', title: `区域运营统计 - ${r.region} - ${tb.type} - 库存` })}
|
||||||
>
|
>
|
||||||
待:{tb.inventory || ''}
|
待:{tb.inventory}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -970,15 +970,14 @@ app.get('/inventory-stats', async (c) => {
|
|||||||
const city = resolveCity(v.city, v.province);
|
const city = resolveCity(v.city, v.province);
|
||||||
const brand = v.brandLabel || '未知';
|
const brand = v.brandLabel || '未知';
|
||||||
const model = v.model;
|
const model = v.model;
|
||||||
const batch = v.contractNo || 'N/A';
|
const key = `${region}|${city}|${brand}|${typeName}|${model}`;
|
||||||
const key = `${region}|${city}|${brand}|${typeName}|${model}|${batch}`;
|
|
||||||
groups.set(key, (groups.get(key) || 0) + 1);
|
groups.set(key, (groups.get(key) || 0) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = Array.from(groups.entries())
|
const result = Array.from(groups.entries())
|
||||||
.map(([key, quantity]) => {
|
.map(([key, quantity]) => {
|
||||||
const [region, city, brand, type, model, batch] = key.split('|');
|
const [region, city, brand, type, model] = key.split('|');
|
||||||
return { region, city, brand, type, model, batch, quantity };
|
return { region, city, brand, type, model, batch: model, quantity };
|
||||||
})
|
})
|
||||||
.sort((a, b) => b.quantity - a.quantity);
|
.sort((a, b) => b.quantity - a.quantity);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user