From b6e780e649e224c89355bd89adf72d6b5db7613b Mon Sep 17 00:00:00 2001 From: iven Date: Sat, 2 May 2026 11:24:34 +0800 Subject: [PATCH] =?UTF-8?q?refactor(web):=20=E7=BB=9F=E4=B8=80=E5=81=A5?= =?UTF-8?q?=E5=BA=B7=E6=A8=A1=E5=9D=97=E9=9D=99=E6=80=81=E6=98=A0=E5=B0=84?= =?UTF-8?q?=E5=B8=B8=E9=87=8F=E5=88=B0=20constants/health.ts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 收敛 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 严重度映射改引用常量 --- apps/web/src/constants/health.ts | 109 +++++++++++++++++- apps/web/src/pages/health/AlertDashboard.tsx | 45 +------- apps/web/src/pages/health/AlertList.tsx | 50 +------- apps/web/src/pages/health/AlertRuleList.tsx | 38 +----- apps/web/src/pages/health/DeviceManage.tsx | 19 +-- apps/web/src/pages/health/PatientDetail.tsx | 8 +- .../web/src/pages/health/PatientTagManage.tsx | 17 +-- .../StatisticsDashboard/DoctorDashboard.tsx | 15 +-- .../health/components/DeviceReadingsTab.tsx | 10 +- .../src/pages/health/components/StatusTag.tsx | 23 +--- 10 files changed, 133 insertions(+), 201 deletions(-) diff --git a/apps/web/src/constants/health.ts b/apps/web/src/constants/health.ts index 3325fcf..6b017d2 100644 --- a/apps/web/src/constants/health.ts +++ b/apps/web/src/constants/health.ts @@ -1,16 +1,24 @@ /** * 健康管理模块共享常量 * - * 集中定义性别、血型、患者状态等下拉选项, - * 供 PatientList / PatientDetail 等页面复用。 + * 集中定义性别、血型、患者状态、严重度、告警状态、设备类型等映射, + * 供各健康模块页面复用。避免在组件中重复定义。 */ +// --- 性别 --- export const GENDER_OPTIONS = [ { value: 'male', label: '男' }, { value: 'female', label: '女' }, { value: 'other', label: '其他' }, ]; +export const GENDER_LABEL: Record = { + male: '男', + female: '女', + other: '其他', +}; + +// --- 血型 --- export const BLOOD_TYPE_OPTIONS = [ { value: 'A', label: 'A 型' }, { value: 'B', label: 'B 型' }, @@ -18,9 +26,106 @@ export const BLOOD_TYPE_OPTIONS = [ { value: 'O', label: 'O 型' }, ]; +// --- 患者状态 --- export const STATUS_OPTIONS = [ { value: '', label: '全部状态' }, { value: 'active', label: '活跃' }, { value: 'inactive', label: '停用' }, { value: 'deceased', label: '已故' }, ]; + +// --- 严重度(统一 5 处重复定义: AlertDashboard, AlertList, AlertRuleList, DoctorDashboard) --- +export const SEVERITY_COLOR: Record = { + info: 'default', + warning: 'orange', + critical: 'red', + urgent: 'magenta', +}; + +export const SEVERITY_LABEL: Record = { + info: '提示', + warning: '警告', + critical: '严重', + urgent: '紧急', +}; + +export const SEVERITY_OPTIONS = [ + { value: 'info', label: '提示' }, + { value: 'warning', label: '警告' }, + { value: 'critical', label: '严重' }, + { value: 'urgent', label: '紧急' }, +]; + +// --- 告警状态(统一 3 处: AlertDashboard, AlertList) --- +export const ALERT_STATUS_COLOR: Record = { + pending: 'orange', + acknowledged: 'blue', + resolved: 'green', + dismissed: 'default', +}; + +export const ALERT_STATUS_LABEL: Record = { + pending: '待处理', + acknowledged: '已确认', + resolved: '已恢复', + dismissed: '已忽略', +}; + +export const ALERT_STATUS_OPTIONS = [ + { value: '', label: '全部状态' }, + { value: 'pending', label: '待处理' }, + { value: 'acknowledged', label: '已确认' }, + { value: 'resolved', label: '已恢复' }, + { value: 'dismissed', label: '已忽略' }, +]; + +// --- 设备类型(统一 3 处: DeviceManage, DeviceReadingsTab, AlertRuleList) --- +export const DEVICE_TYPE_OPTIONS = [ + { value: 'blood_pressure', label: '血压' }, + { value: 'blood_glucose', label: '血糖' }, + { value: 'heart_rate', label: '心率' }, + { value: 'blood_oxygen', label: '血氧' }, + { value: 'temperature', label: '体温' }, + { value: 'steps', label: '步数' }, + { value: 'sleep', label: '睡眠' }, + { value: 'stress', label: '压力' }, +]; + +export const DEVICE_TYPE_COLOR: Record = { + blood_pressure: 'red', + blood_glucose: 'purple', + heart_rate: 'volcano', + blood_oxygen: 'blue', + temperature: 'orange', + steps: 'green', + sleep: 'cyan', + stress: 'geekblue', +}; + +// --- 告警规则条件类型 --- +export const CONDITION_TYPE_OPTIONS = [ + { value: 'single_threshold', label: '单次阈值' }, + { value: 'consecutive', label: '连续触发' }, + { value: 'trend', label: '趋势变化' }, +]; + +// --- 通用状态标签(StatusTag 组件统一引用) --- +export const STATUS_TAG_CONFIG: Record = { + // 预约状态 + 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: '已认证' }, +}; diff --git a/apps/web/src/pages/health/AlertDashboard.tsx b/apps/web/src/pages/health/AlertDashboard.tsx index ca6990a..4e78338 100644 --- a/apps/web/src/pages/health/AlertDashboard.tsx +++ b/apps/web/src/pages/health/AlertDashboard.tsx @@ -21,47 +21,12 @@ import { WifiOutlined, } from '@ant-design/icons'; import { alertApi, type Alert } from '../../api/health/alerts'; +import { SEVERITY_COLOR, SEVERITY_LABEL, ALERT_STATUS_COLOR, ALERT_STATUS_LABEL, ALERT_STATUS_OPTIONS } from '../../constants/health'; import { useAlertSSE, type AlertSSEEvent } from '../../hooks/useAlertSSE'; import { AlertDetailPanel } from './components/AlertDetailPanel'; import { PageContainer } from '../../components/PageContainer'; import { EntityName } from '../../components/EntityName'; -const SEVERITY_COLOR: Record = { - info: 'default', - warning: 'orange', - critical: 'red', - urgent: 'magenta', -}; - -const SEVERITY_LABEL: Record = { - info: '提示', - warning: '警告', - critical: '严重', - urgent: '紧急', -}; - -const STATUS_COLOR: Record = { - pending: 'orange', - acknowledged: 'blue', - resolved: 'green', - dismissed: 'default', -}; - -const STATUS_LABEL: Record = { - pending: '待处理', - acknowledged: '已确认', - resolved: '已恢复', - dismissed: '已忽略', -}; - -const STATUS_OPTIONS = [ - { value: '', label: '全部状态' }, - { value: 'pending', label: '待处理' }, - { value: 'acknowledged', label: '已确认' }, - { value: 'resolved', label: '已恢复' }, - { value: 'dismissed', label: '已忽略' }, -]; - /** * 实时告警仪表盘 — 医生端。 * @@ -183,7 +148,7 @@ export default function AlertDashboard() { + +