diff --git a/frontend/admin-web/src/app/(dashboard)/users/[id]/page.tsx b/frontend/admin-web/src/app/(dashboard)/users/[id]/page.tsx index 8f422ec8..84e81432 100644 --- a/frontend/admin-web/src/app/(dashboard)/users/[id]/page.tsx +++ b/frontend/admin-web/src/app/(dashboard)/users/[id]/page.tsx @@ -26,6 +26,7 @@ import type { AUTHORIZATION_STATUS_LABELS, ASSESSMENT_RESULT_LABELS, } from '@/types/userDetail.types'; +import { PROVINCE_CODE_NAMES, CITY_CODE_NAMES } from '@/types'; import styles from './user-detail.module.scss'; // Tab 类型 @@ -101,6 +102,31 @@ const assessmentResultLabels: Record = { BYPASSED: '豁免', }; +/** + * 将区域代码转换为名称 + * @param code 区域代码,如 450000(省)或 451200(市) + * @returns 区域名称 + */ +const getRegionName = (code: string | null | undefined): string => { + if (!code) return '-'; + // 先尝试查找城市 + if (CITY_CODE_NAMES[code]) { + return CITY_CODE_NAMES[code]; + } + // 再尝试查找省份 + if (PROVINCE_CODE_NAMES[code]) { + return PROVINCE_CODE_NAMES[code]; + } + // 尝试去掉后4位的0(如 450000 -> 45)查找省份 + if (code.length === 6 && code.endsWith('0000')) { + const shortCode = code.substring(0, 2); + if (PROVINCE_CODE_NAMES[shortCode]) { + return PROVINCE_CODE_NAMES[shortCode]; + } + } + return code; +}; + /** * 用户详情页面 */ @@ -481,7 +507,7 @@ export default function UserDetailPage() {
{formatNumber(item.treeCount)}
{formatAmount(item.totalAmount)}
- {item.selectedProvince || '-'} / {item.selectedCity || '-'} + {getRegionName(item.selectedProvince)} / {getRegionName(item.selectedCity)}
{formatDate(item.createdAt)}
{formatDate(item.paidAt)}
diff --git a/frontend/admin-web/src/types/system-account.types.ts b/frontend/admin-web/src/types/system-account.types.ts index ff5c0869..704fd84a 100644 --- a/frontend/admin-web/src/types/system-account.types.ts +++ b/frontend/admin-web/src/types/system-account.types.ts @@ -508,7 +508,7 @@ export const PROVINCE_CODE_NAMES: Record = { * 城市行政区划代码到城市名称的映射 * 格式:6位区划代码 -> 城市名称 */ -const CITY_CODE_NAMES: Record = { +export const CITY_CODE_NAMES: Record = { // 北京市 '110100': '北京市', // 天津市