import { Descriptions, Tag, Typography, Space, Button, Popconfirm, Tooltip } from 'antd'; import { CheckOutlined, StopOutlined, SafetyCertificateOutlined, ClockCircleOutlined, ExclamationCircleOutlined, } from '@ant-design/icons'; import type { Alert } from '../../../api/health/alerts'; const SEVERITY_CONFIG: Record = { info: { color: 'default', label: '提示', icon: }, warning: { color: 'orange', label: '警告', icon: }, critical: { color: 'red', label: '严重', icon: }, urgent: { color: 'magenta', label: '紧急', icon: }, }; const STATUS_CONFIG: Record = { pending: { color: 'orange', label: '待处理' }, acknowledged: { color: 'blue', label: '已确认' }, resolved: { color: 'green', label: '已恢复' }, dismissed: { color: 'default', label: '已忽略' }, }; interface AlertDetailPanelProps { alert: Alert; onAcknowledge?: (id: string, version: number) => Promise; onDismiss?: (id: string, version: number) => Promise; onResolve?: (id: string, version: number) => Promise; loading?: boolean; } /** * 告警详情面板 — 展示告警完整信息及操作按钮。 */ export function AlertDetailPanel({ alert, onAcknowledge, onDismiss, onResolve, loading = false, }: AlertDetailPanelProps) { const severity = SEVERITY_CONFIG[alert.severity] ?? SEVERITY_CONFIG.info; const status = STATUS_CONFIG[alert.status] ?? STATUS_CONFIG.pending; const isPending = alert.status === 'pending'; const isAcknowledged = alert.status === 'acknowledged'; return (
{/* 顶部摘要 */}
{severity.label} {status.label} {new Date(alert.created_at).toLocaleString('zh-CN')}
{/* 详情 */} {alert.id} {alert.patient_id} {alert.rule_id} {severity.label} {status.label} {alert.acknowledged_by && ( {alert.acknowledged_by} )} {alert.acknowledged_at && ( {new Date(alert.acknowledged_at).toLocaleString('zh-CN')} )} {alert.resolved_at && ( {new Date(alert.resolved_at).toLocaleString('zh-CN')} )} {/* 告警详情 JSON */} {alert.detail && (
告警详情:
            {JSON.stringify(alert.detail, null, 2)}
          
)} {/* 操作按钮 */}
{isPending && onAcknowledge && ( onAcknowledge(alert.id, alert.version)} > )} {isPending && onDismiss && ( onDismiss(alert.id, alert.version)} > )} {(isPending || isAcknowledged) && onResolve && ( onResolve(alert.id, alert.version)} > )}
); }