longz
2026-07-08 700f9d0da314a4ea701fe9f68d305b67d72ec5fb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
export const FIELD_CODES = {
  VISITOR_NAME: 'visitor_name',
  MOBILE: 'mobile',
  COMPANY: 'company',
  ID_CARD: 'idCard',
  GENDER: 'gender',
} as const
 
export type VisitorFieldCode = (typeof FIELD_CODES)[keyof typeof FIELD_CODES]
 
export const FIELD_CODE_LABELS: Record<string, string> = {
  [FIELD_CODES.VISITOR_NAME]: '来访人姓名',
  [FIELD_CODES.MOBILE]: '联系电话',
  [FIELD_CODES.COMPANY]: '所属公司',
  [FIELD_CODES.ID_CARD]: '身份证号',
  [FIELD_CODES.GENDER]: '性别',
}
 
export function formatVisitorFieldLabels(
  codes?: Array<string | null | undefined>,
  fieldConfigs: Array<{ fieldCode: string, fieldName?: string | null }> = [],
) {
  return (codes || [])
    .map((code) => {
      const normalizedCode = String(code || '').trim()
      if (!normalizedCode) {
        return ''
      }
      const configName = fieldConfigs.find(item => item.fieldCode === normalizedCode)?.fieldName?.trim()
      return configName || FIELD_CODE_LABELS[normalizedCode] || normalizedCode
    })
    .filter(Boolean)
    .join('、')
}