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:
parent
a39ee76e9a
commit
f0bf4d8c5d
|
|
@ -26,6 +26,7 @@ import type {
|
||||||
AUTHORIZATION_STATUS_LABELS,
|
AUTHORIZATION_STATUS_LABELS,
|
||||||
ASSESSMENT_RESULT_LABELS,
|
ASSESSMENT_RESULT_LABELS,
|
||||||
} from '@/types/userDetail.types';
|
} from '@/types/userDetail.types';
|
||||||
|
import { PROVINCE_CODE_NAMES, CITY_CODE_NAMES } from '@/types';
|
||||||
import styles from './user-detail.module.scss';
|
import styles from './user-detail.module.scss';
|
||||||
|
|
||||||
// Tab 类型
|
// Tab 类型
|
||||||
|
|
@ -101,6 +102,31 @@ const assessmentResultLabels: Record<string, string> = {
|
||||||
BYPASSED: '豁免',
|
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}>{formatNumber(item.treeCount)}</div>
|
||||||
<div className={styles.ledgerTable__cell}>{formatAmount(item.totalAmount)}</div>
|
<div className={styles.ledgerTable__cell}>{formatAmount(item.totalAmount)}</div>
|
||||||
<div className={styles.ledgerTable__cell}>
|
<div className={styles.ledgerTable__cell}>
|
||||||
{item.selectedProvince || '-'} / {item.selectedCity || '-'}
|
{getRegionName(item.selectedProvince)} / {getRegionName(item.selectedCity)}
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.ledgerTable__cell}>{formatDate(item.createdAt)}</div>
|
<div className={styles.ledgerTable__cell}>{formatDate(item.createdAt)}</div>
|
||||||
<div className={styles.ledgerTable__cell}>{formatDate(item.paidAt)}</div>
|
<div className={styles.ledgerTable__cell}>{formatDate(item.paidAt)}</div>
|
||||||
|
|
|
||||||
|
|
@ -508,7 +508,7 @@ export const PROVINCE_CODE_NAMES: Record<string, string> = {
|
||||||
* 城市行政区划代码到城市名称的映射
|
* 城市行政区划代码到城市名称的映射
|
||||||
* 格式:6位区划代码 -> 城市名称
|
* 格式:6位区划代码 -> 城市名称
|
||||||
*/
|
*/
|
||||||
const CITY_CODE_NAMES: Record<string, string> = {
|
export const CITY_CODE_NAMES: Record<string, string> = {
|
||||||
// 北京市
|
// 北京市
|
||||||
'110100': '北京市',
|
'110100': '北京市',
|
||||||
// 天津市
|
// 天津市
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue