/** 工号规则:IDE + 至少 3 位数字,如 IDE001、IDE012、IDE1000 */ const EMPLOYEE_NO_PATTERN = /^IDE(\d{3,})$/i export function generateEmployeeNo( existing: Array<{ employeeNo?: string | null; EmployeeNo?: string | null }>, ): string { let max = 0 for (const row of existing) { const raw = String(row.employeeNo ?? row.EmployeeNo ?? '').trim() const match = raw.match(EMPLOYEE_NO_PATTERN) if (match) { max = Math.max(max, Number.parseInt(match[1], 10)) } } const next = max + 1 return `IDE${String(next).padStart(3, '0')}` }