fix(miniprogram): 统一状态色映射,对齐设计系统色板
Some checks failed
CI / frontend-build (push) Has been cancelled
CI / security-audit (push) Has been cancelled
CI / rust-check (push) Has been cancelled
CI / rust-test (push) Has been cancelled

- 创建 utils/statusTag.ts 共享状态色工具(对齐 variables.scss)
- doctor/consultation: 使用共享状态色替代 Tailwind 硬编码
- doctor/followup: 使用共享状态色替代 Tailwind 硬编码
- doctor/action-inbox: SCSS 状态点替换为设计系统变量
- doctor/index: SCSS 告警/搜索区替换为设计系统变量
- pkg-health/alerts: SCSS 严重度标签替换为设计系统变量
This commit is contained in:
iven
2026-05-06 10:59:13 +08:00
parent 36275eb307
commit 4a95a83d6b
7 changed files with 134 additions and 44 deletions

View File

@@ -0,0 +1,107 @@
/**
* 共享状态色映射 — 对齐设计系统 variables.scss
*
* 使用方式:
* import { getStatusStyle } from '@/utils/statusTag';
* <View style={getStatusStyle('pending')}>待确认</View>
*/
// 设计系统色板 (与 variables.scss 对齐)
const COLORS = {
pri: '#C4623A',
priLight: '#F0DDD4',
acc: '#5B7A5E',
accLight: '#E8F0E8',
wrn: '#C4873A',
wrnLight: '#FFF3E0',
dan: '#B54A4A',
danLight: '#FDEAEA',
tx3: '#78716C',
neutralBg: '#F1F5F9',
} as const;
export interface StatusStyle {
background: string;
color: string;
}
// 统一状态色映射
const STATUS_COLORS: Record<string, StatusStyle> = {
// 预约
pending: { background: COLORS.wrnLight, color: COLORS.wrn },
confirmed: { background: COLORS.priLight, color: COLORS.pri },
completed: { background: COLORS.accLight, color: COLORS.acc },
cancelled: { background: COLORS.neutralBg, color: COLORS.tx3 },
no_show: { background: COLORS.danLight, color: COLORS.dan },
// 随访
overdue: { background: COLORS.danLight, color: COLORS.dan },
in_progress: { background: COLORS.priLight, color: COLORS.pri },
// 咨询
waiting: { background: COLORS.wrnLight, color: COLORS.wrn },
active: { background: COLORS.accLight, color: COLORS.acc },
closed: { background: COLORS.neutralBg, color: COLORS.tx3 },
// 告警严重度
info: { background: COLORS.neutralBg, color: COLORS.tx3 },
warning: { background: COLORS.wrnLight, color: COLORS.wrn },
medium: { background: COLORS.wrnLight, color: COLORS.wrn },
critical: { background: COLORS.danLight, color: COLORS.dan },
high: { background: COLORS.danLight, color: COLORS.dan },
urgent: { background: COLORS.danLight, color: COLORS.dan },
// 告警状态
acknowledged: { background: COLORS.priLight, color: COLORS.pri },
resolved: { background: COLORS.accLight, color: COLORS.acc },
dismissed: { background: COLORS.neutralBg, color: COLORS.tx3 },
// 设备
online: { background: COLORS.accLight, color: COLORS.acc },
offline: { background: COLORS.neutralBg, color: COLORS.tx3 },
paired: { background: COLORS.priLight, color: COLORS.pri },
error: { background: COLORS.danLight, color: COLORS.dan },
// 通用
verified: { background: COLORS.accLight, color: COLORS.acc },
inactive: { background: COLORS.neutralBg, color: COLORS.tx3 },
deceased: { background: COLORS.neutralBg, color: COLORS.tx3 },
rejected: { background: COLORS.danLight, color: COLORS.dan },
};
const DEFAULT_STYLE: StatusStyle = { background: COLORS.neutralBg, color: COLORS.tx3 };
/** 获取状态对应的样式(背景色+文字色) */
export function getStatusStyle(status: string): StatusStyle {
return STATUS_COLORS[status] || DEFAULT_STYLE;
}
/** 获取带透明度的状态背景(用于行内 style */
export function getStatusInlineStyle(status: string): { background: string; color: string; borderRadius: string; padding: string; fontSize: string } {
const s = getStatusStyle(status);
return {
background: s.background,
color: s.color,
borderRadius: '6px',
padding: '2px 8px',
fontSize: '24px', // 小程序最小字号
};
}
// 统一状态标签文案
const STATUS_LABELS: Record<string, string> = {
pending: '待确认', confirmed: '已确认', completed: '已完成',
cancelled: '已取消', no_show: '未到诊', overdue: '逾期',
in_progress: '进行中', waiting: '等待中', active: '进行中',
closed: '已关闭', info: '提示', warning: '警告',
medium: '中等', critical: '严重', high: '严重', urgent: '紧急',
acknowledged: '已确认', resolved: '已恢复', dismissed: '已忽略',
online: '在线', offline: '离线', paired: '已配对', error: '异常',
verified: '已认证', inactive: '停用', deceased: '已故',
rejected: '已拒绝',
};
/** 获取状态的中文标签 */
export function getStatusLabel(status: string): string {
return STATUS_LABELS[status] || status;
}