From 01a64431dce375966ad6922e274326423a78e704 Mon Sep 17 00:00:00 2001 From: kkfluous Date: Fri, 27 Mar 2026 18:15:07 +0800 Subject: [PATCH] feat: add frontend types and API client for dept/region/customer stats Co-Authored-By: Claude Opus 4.6 (1M context) --- src/api.ts | 25 +++++++++++++++++++++++++ src/types.ts | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) diff --git a/src/api.ts b/src/api.ts index b02d926..0138ad7 100644 --- a/src/api.ts +++ b/src/api.ts @@ -2,6 +2,9 @@ import type { SummaryData, TypeSummary, VehicleListItem, + DeptGroup, + RegionGroup, + CustomerStats, } from './types'; const BASE = '/api/vehicles'; @@ -26,6 +29,11 @@ export async function fetchVehicleList(params: { location?: string; status?: string; category?: string; + vehicleType?: string; + manager?: string; + customer?: string; + isColdChain?: string; + isTrailer?: string; }): Promise { const query = new URLSearchParams(); if (params.batch) query.set('batch', params.batch); @@ -33,6 +41,11 @@ export async function fetchVehicleList(params: { if (params.location) query.set('location', params.location); if (params.status) query.set('status', params.status); if (params.category) query.set('category', params.category); + if (params.vehicleType) query.set('vehicleType', params.vehicleType); + if (params.manager) query.set('manager', params.manager); + if (params.customer) query.set('customer', params.customer); + if (params.isColdChain) query.set('isColdChain', params.isColdChain); + if (params.isTrailer) query.set('isTrailer', params.isTrailer); return fetchJson(`${BASE}/list?${query.toString()}`); } @@ -44,6 +57,18 @@ export interface WeeklyDetailItem { customer_name: string | null; } +export async function fetchDeptStats(): Promise { + return fetchJson(`${BASE}/dept-stats`); +} + +export async function fetchRegionStats(): Promise { + return fetchJson(`${BASE}/region-stats`); +} + +export async function fetchCustomerStats(): Promise { + return fetchJson(`${BASE}/customer-stats`); +} + export async function fetchWeeklyDetail(type: string): Promise { return fetchJson(`${BASE}/weekly-detail?type=${type}`); } diff --git a/src/types.ts b/src/types.ts index 87d3a70..f1e988f 100644 --- a/src/types.ts +++ b/src/types.ts @@ -109,3 +109,48 @@ export interface VehicleListItem { customerName: string | null; subjectOrg: string | null; } + +export interface ManagerStats { + manager: string; + department: string; + t4_5: number; + t4_5c: number; + t18: number; + t49: number; + trailer: number; + other: number; + total: number; +} + +export interface DeptGroup { + department: string; + totalAssets: number; + operatingCount: number; + idleCount: number; + managers: ManagerStats[]; +} + +export interface RegionGroup { + region: string; + totalAssets: number; + operatingCount: number; + inventoryCount: number; + customers: string[]; + typeBreakdown: { type: string; total: number; operating: number; inventory: number; customers: string[] }[]; +} + +export interface CustomerStats { + customer: string; + manager: string; + brand: string; + department: string; + region: string; + city: string; + t4_5: number; + t4_5c: number; + t18: number; + t49: number; + trailer: number; + other: number; + total: number; +}