fix(admin-web): 认种明细省市列显示真实名称

- 导出 CITY_CODE_NAMES 常量供外部使用
- 添加 getRegionName 函数转换区域代码为名称
- 认种分类账明细中省市列使用真实名称替代数字代码
  例如:450000/451200 -> 广西壮族自治区/柳州市

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-01-07 22:09:42 -08:00
parent a39ee76e9a
commit f0bf4d8c5d
2 changed files with 28 additions and 2 deletions

View File

@ -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<string, string> = {
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() {
<div className={styles.ledgerTable__cell}>{formatNumber(item.treeCount)}</div>
<div className={styles.ledgerTable__cell}>{formatAmount(item.totalAmount)}</div>
<div className={styles.ledgerTable__cell}>
{item.selectedProvince || '-'} / {item.selectedCity || '-'}
{getRegionName(item.selectedProvince)} / {getRegionName(item.selectedCity)}
</div>
<div className={styles.ledgerTable__cell}>{formatDate(item.createdAt)}</div>
<div className={styles.ledgerTable__cell}>{formatDate(item.paidAt)}</div>

View File

@ -508,7 +508,7 @@ export const PROVINCE_CODE_NAMES: Record<string, string> = {
*
* 6 ->
*/
const CITY_CODE_NAMES: Record<string, string> = {
export const CITY_CODE_NAMES: Record<string, string> = {
// 北京市
'110100': '北京市',
// 天津市