fix: 客户运营统计业务负责人按部门编号排序
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

部门顺序:业务一部→二部→三部→五部→六部→公务车,
与部门Tab排序一致,负责人按deptData顺序排列。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
kkfluous
2026-03-28 23:54:54 +08:00
parent 66ea340a73
commit fd0b94175d

View File

@@ -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<string, number> = { '一': 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<string, Set<string>>();
// 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]);