feat(assets): refine compact inventory drilldowns and exact subtotal scopes
This commit is contained in:
@@ -354,8 +354,16 @@ app.get('/customer-stats', async (c) => {
|
||||
return c.json(result);
|
||||
});
|
||||
|
||||
// GET /api/vehicles/list — flat list with optional filters
|
||||
app.get('/list', async (c) => {
|
||||
// POST uses a JSON scope to avoid URL length limits for inventory subtotal drilldown.
|
||||
app.on(['GET', 'POST'], '/list', async (c) => {
|
||||
let inventoryKeys: Set<string> | undefined;
|
||||
if (c.req.method === 'POST') {
|
||||
const body = await c.req.json().catch(() => null);
|
||||
if (!body || !Array.isArray(body.inventoryKeys) || !body.inventoryKeys.every((key: unknown) => typeof key === 'string')) {
|
||||
return c.json({ error: '库存明细范围无效' }, 400);
|
||||
}
|
||||
inventoryKeys = new Set(body.inventoryKeys);
|
||||
}
|
||||
const vehicles = await getVehiclesForUser(c);
|
||||
const { brand, batch, model, location, status, category, vehicleType, manager, customer, isColdChain, isTrailer, department, attendance } = c.req.query();
|
||||
|
||||
@@ -363,6 +371,10 @@ app.get('/list', async (c) => {
|
||||
? vehicles.filter(v => isOperatingVehicle(v) || isInventoryPending(v))
|
||||
: vehicles;
|
||||
|
||||
if (inventoryKeys) {
|
||||
filtered = filtered.filter(v => isInventoryVehicle(v) && inventoryKeys.has(inventoryKey(inventoryDimensions(v))));
|
||||
}
|
||||
|
||||
// attendance filter: active = day_mileage > 0, idle = day_mileage = 0 (only for Operating vehicles)
|
||||
if (attendance === 'active' || attendance === 'idle') {
|
||||
const realtimeRows = await vehicleRepository.getAttendanceMileageRows();
|
||||
|
||||
Reference in New Issue
Block a user