front/src/utils/user-employee-no.ts
zzh abfca7a21a feat: add H5 customer center, marketing admin, and employee profile UX
Ship customer portal and marketing pages, user edit drawer with employee archive, IDE employee numbers, channel config refactor, and related nginx/route updates.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-26 23:44:02 +08:00

18 lines
573 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/** 工号规则: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')}`
}