diff --git a/src/App.tsx b/src/App.tsx index 395ecd6..a1aeb9f 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -429,14 +429,29 @@ export default function App() { const uniqueCustomerNames = useMemo(() => Array.from(new Set(customerData.map((s) => s.customer).filter(Boolean))), [customerData]); const uniqueCustomerManagers = useMemo(() => Array.from(new Set(customerData.map((s) => s.manager).filter(Boolean))), [customerData]); const customerManagersGroupedByDept = useMemo(() => { + const numMap: Record = { '一': 1, '二': 2, '三': 3, '四': 4, '五': 5, '六': 6, '七': 7, '八': 8, '九': 9, '十': 10 }; + const getDeptOrder = (name: string) => { + if (name === '公务车') return 100; + const m = name.match(/[一二三四五六七八九十]/); + return m ? (numMap[m[0]] || 99) : 99; + }; + // Use deptData order as primary source (already sorted), fallback to customerData const deptMap = new Map>(); + // First add from deptData to get correct dept order and all managers + for (const d of deptData) { + if (!deptMap.has(d.department)) deptMap.set(d.department, new Set()); + for (const m of d.managers) deptMap.get(d.department)!.add(m.manager); + } + // Then add any extra from customerData for (const s of customerData) { if (!s.manager || !s.department) continue; if (!deptMap.has(s.department)) deptMap.set(s.department, new Set()); deptMap.get(s.department)!.add(s.manager); } - return Array.from(deptMap.entries()).map(([dept, mgrs]) => ({ department: dept, managers: Array.from(mgrs) })); - }, [customerData]); + return Array.from(deptMap.entries()) + .sort((a, b) => getDeptOrder(a[0]) - getDeptOrder(b[0])) + .map(([dept, mgrs]) => ({ department: dept, managers: Array.from(mgrs) })); + }, [customerData, deptData]); const uniqueInventoryModels = useMemo(() => Array.from(new Set(inventoryData.map((s) => s.model).filter(Boolean))), [inventoryData]); const uniqueModalPlates = useMemo(() => Array.from(new Set(modalVehicles.map(v => v.plateNumber || v.vin).filter(Boolean))), [modalVehicles]); const uniqueModalModels = useMemo(() => Array.from(new Set(modalVehicles.map(v => v.model).filter(Boolean))), [modalVehicles]);