refactor(web): 统一健康模块静态映射常量到 constants/health.ts

- 收敛 SEVERITY_COLOR/LABEL (5处→1处)
- 收敛 ALERT_STATUS_COLOR/LABEL (3处→1处)
- 收敛 DEVICE_TYPE_OPTIONS/COLOR (3处→1处)
- 收敛 GENDER_LABEL (4处→1处)
- StatusTag 组件改引用 STATUS_TAG_CONFIG
- DoctorDashboard 严重度映射改引用常量
This commit is contained in:
iven
2026-05-02 11:24:34 +08:00
parent 3bc4597041
commit b6e780e649
10 changed files with 133 additions and 201 deletions

View File

@@ -3,20 +3,12 @@ import { Table, Select, Tabs, Card, Typography } from 'antd';
import { deviceReadingApi } from '../../../api/health/deviceReadings';
import type { DeviceReading, HourlyReading } from '../../../api/health/deviceReadings';
import { usePaginatedData } from '../../../hooks/usePaginatedData';
import { DEVICE_TYPE_OPTIONS } from '../../../constants/health';
const { Text } = Typography;
/* ---------- 常量 ---------- */
const DEVICE_TYPE_OPTIONS = [
{ value: 'heart_rate', label: '心率' },
{ value: 'blood_oxygen', label: '血氧' },
{ value: 'blood_pressure', label: '血压' },
{ value: 'blood_glucose', label: '血糖' },
{ value: 'steps', label: '步数' },
{ value: 'temperature', label: '体温' },
] as const;
const TIME_RANGE_OPTIONS = [
{ value: 1, label: '最近 1 小时' },
{ value: 6, label: '最近 6 小时' },

View File

@@ -1,30 +1,11 @@
import { Tag } from 'antd';
const STATUS_CONFIG: Record<string, { color: string; label: string }> = {
// 预约状态
pending: { color: 'gold', label: '待确认' },
confirmed: { color: 'blue', label: '已确认' },
completed: { color: 'green', label: '已完成' },
cancelled: { color: 'default', label: '已取消' },
no_show: { color: 'red', label: '未到诊' },
// 随访状态
overdue: { color: 'red', label: '逾期' },
in_progress: { color: 'processing', label: '进行中' },
// 咨询状态
waiting: { color: 'gold', label: '等待中' },
active: { color: 'green', label: '进行中' },
closed: { color: 'default', label: '已关闭' },
// 患者状态
inactive: { color: 'default', label: '停用' },
deceased: { color: 'default', label: '已故' },
verified: { color: 'green', label: '已认证' },
};
import { STATUS_TAG_CONFIG } from '../../../constants/health';
interface Props {
status: string;
}
export function StatusTag({ status }: Props) {
const cfg = STATUS_CONFIG[status] || { color: 'default' as const, label: status };
const cfg = STATUS_TAG_CONFIG[status] || { color: 'default' as const, label: status };
return <Tag color={cfg.color}>{cfg.label}</Tag>;
}