From f0bf4d8c5d440567e572b5e62a7546cd77301826 Mon Sep 17 00:00:00 2001 From: hailin Date: Wed, 7 Jan 2026 22:09:42 -0800 Subject: [PATCH] =?UTF-8?q?fix(admin-web):=20=E8=AE=A4=E7=A7=8D=E6=98=8E?= =?UTF-8?q?=E7=BB=86=E7=9C=81=E5=B8=82=E5=88=97=E6=98=BE=E7=A4=BA=E7=9C=9F?= =?UTF-8?q?=E5=AE=9E=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 导出 CITY_CODE_NAMES 常量供外部使用 - 添加 getRegionName 函数转换区域代码为名称 - 认种分类账明细中省市列使用真实名称替代数字代码 例如:450000/451200 -> 广西壮族自治区/柳州市 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- .../src/app/(dashboard)/users/[id]/page.tsx | 28 ++++++++++++++++++- .../src/types/system-account.types.ts | 2 +- 2 files changed, 28 insertions(+), 2 deletions(-) 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': '北京市', // 天津市