Files
hms/apps/web/src/pages/health/StatisticsDashboard/HealthDataCenter.tsx
iven 4d8658ae98 fix(health+web): action-inbox 参数绑定修复 + antd 弃用警告清理
- action_inbox_service: count_sql 补齐 $4/$5 占位符,修复参数绑定数不匹配导致 500
- AiSidebar: Drawer width → size(antd v5 弃用替换)
- 6 个页面 Statistic: valueStyle → styles.content(antd v5 弃用替换)
- RealtimeMonitor: 移除未使用的 _alerts 变量
2026-05-21 08:08:47 +08:00

136 lines
6.6 KiB
TypeScript

import { Row, Col, Card, Statistic, Tag, Typography, Empty } from 'antd';
import type { HealthDataStats, DialysisStatistics } from '../../../api/health/points';
const { Text } = Typography;
interface HealthDataCenterProps {
data: HealthDataStats | null;
dialysisData?: DialysisStatistics | null;
tab?: string;
}
function DialysisPanel({ data }: { data: DialysisStatistics | null | undefined }) {
return (
<Card type="inner" title={<span style={{ fontSize: 14, fontWeight: 600 }}></span>} style={{ borderRadius: 8 }}>
<Row gutter={[12, 12]}>
<Col span={8}><Statistic title="总记录" value={data?.total_records ?? 0} styles={{ content: { fontSize: 20 } }} /></Col>
<Col span={8}><Statistic title="本月新增" value={data?.this_month ?? 0} styles={{ content: { fontSize: 20, color: '#2563eb' } }} /></Col>
<Col span={8}><Statistic title="待审核" value={data?.pending_review ?? 0} styles={{ content: { fontSize: 20, color: '#d97706' } }} /></Col>
</Row>
<Row gutter={[12, 12]} style={{ marginTop: 12 }}>
<Col span={8}><Statistic title="并发症率" value={data?.complication_rate ?? 0} suffix="%" precision={1} styles={{ content: { fontSize: 18 } }} /></Col>
<Col span={8}><Statistic title="平均超滤(ml)" value={data?.avg_ultrafiltration ?? 0} precision={0} styles={{ content: { fontSize: 18 } }} /></Col>
<Col span={8}><Statistic title="平均时长(分)" value={data?.avg_duration ?? 0} precision={0} styles={{ content: { fontSize: 18 } }} /></Col>
</Row>
{(data?.type_distribution ?? []).length > 0 && (
<div style={{ marginTop: 12 }}>
<Text type="secondary" style={{ fontSize: 12 }}>: </Text>
{data!.type_distribution.map((item) => (
<Tag key={item.name} color="blue" style={{ marginTop: 4 }}>{item.name}: {item.value}</Tag>
))}
</div>
)}
</Card>
);
}
function LabPanel({ data }: { data: HealthDataStats | null }) {
return (
<Card type="inner" title={<span style={{ fontSize: 14, fontWeight: 600 }}></span>} style={{ borderRadius: 8 }}>
<Row gutter={[12, 12]}>
<Col span={8}><Statistic title="总报告" value={data?.lab_reports.total_reports ?? 0} styles={{ content: { fontSize: 20 } }} /></Col>
<Col span={8}><Statistic title="本月新增" value={data?.lab_reports.this_month ?? 0} styles={{ content: { fontSize: 20, color: '#2563eb' } }} /></Col>
<Col span={8}><Statistic title="异常项" value={data?.lab_reports.abnormal_items ?? 0} styles={{ content: { fontSize: 20, color: '#dc2626' } }} /></Col>
</Row>
<Row gutter={[12, 12]} style={{ marginTop: 12 }}>
<Col span={8}><Statistic title="待审核" value={data?.lab_reports.pending_review ?? 0} styles={{ content: { fontSize: 18, color: '#d97706' } }} /></Col>
<Col span={8}><Statistic title="已审核" value={data?.lab_reports.reviewed ?? 0} styles={{ content: { fontSize: 18, color: '#059669' } }} /></Col>
</Row>
{(data?.lab_reports.type_distribution ?? []).length > 0 && (
<div style={{ marginTop: 12 }}>
<Text type="secondary" style={{ fontSize: 12 }}>: </Text>
{data!.lab_reports.type_distribution.map((item) => (
<Tag key={item.name} color="green" style={{ marginTop: 4 }}>{item.name}: {item.value}</Tag>
))}
</div>
)}
</Card>
);
}
function AppointmentsPanel({ data }: { data: HealthDataStats | null }) {
return (
<Card type="inner" title={<span style={{ fontSize: 14, fontWeight: 600 }}></span>} style={{ borderRadius: 8 }}>
<Row gutter={[12, 12]}>
<Col span={8}><Statistic title="总预约" value={data?.appointments.total_appointments ?? 0} styles={{ content: { fontSize: 20 } }} /></Col>
<Col span={8}><Statistic title="本月" value={data?.appointments.this_month ?? 0} styles={{ content: { fontSize: 20, color: '#2563eb' } }} /></Col>
<Col span={8}><Statistic title="取消率" value={data?.appointments.cancel_rate ?? 0} suffix="%" precision={1} styles={{ content: { fontSize: 20, color: '#dc2626' } }} /></Col>
</Row>
{(data?.appointments.status_distribution ?? []).length > 0 && (
<div style={{ marginTop: 12 }}>
<Text type="secondary" style={{ fontSize: 12 }}>: </Text>
{data!.appointments.status_distribution.map((item) => (
<Tag key={item.name} color="purple" style={{ marginTop: 4 }}>{item.name}: {item.value}</Tag>
))}
</div>
)}
</Card>
);
}
function VitalSignsPanel({ data }: { data: HealthDataStats | null }) {
return (
<Card type="inner" title={<span style={{ fontSize: 14, fontWeight: 600 }}></span>} style={{ borderRadius: 8 }}>
<Row gutter={[12, 12]}>
<Col span={8}><Statistic title="总患者" value={data?.vital_signs_report_rate.total_patients ?? 0} styles={{ content: { fontSize: 20 } }} /></Col>
<Col span={8}><Statistic title="本月上报" value={data?.vital_signs_report_rate.reported_patients ?? 0} styles={{ content: { fontSize: 20, color: '#059669' } }} /></Col>
<Col span={8}><Statistic title="上报率" value={data?.vital_signs_report_rate.report_rate ?? 0} suffix="%" precision={1} styles={{ content: { fontSize: 20, color: '#7c3aed' } }} /></Col>
</Row>
{(data?.vital_signs_report_rate.daily_trend ?? []).length > 0 && (
<div style={{ marginTop: 12 }}>
<Text type="secondary" style={{ fontSize: 12 }}> 7 : </Text>
<div style={{ display: 'flex', gap: 6, marginTop: 4, flexWrap: 'wrap' }}>
{data!.vital_signs_report_rate.daily_trend.map((d) => (
<Tag key={d.date} color={d.rate >= 50 ? 'green' : d.rate >= 20 ? 'orange' : 'red'}>
{d.date.slice(5)} {d.reported}/{d.total}
</Tag>
))}
</div>
</div>
)}
</Card>
);
}
export default function HealthDataCenter({ data, dialysisData, tab = 'dialysis' }: HealthDataCenterProps) {
if (tab === 'dialysis') {
return (
<Row gutter={[16, 16]}>
<Col span={24}>
<DialysisPanel data={dialysisData} />
</Col>
</Row>
);
}
const PANELS: Record<string, React.FC<{ data: HealthDataStats | null }>> = {
lab: LabPanel,
appointments: AppointmentsPanel,
'vital-signs': VitalSignsPanel,
};
const Panel = PANELS[tab];
if (!Panel) {
return <Empty description="未知数据面板" />;
}
return (
<Row gutter={[16, 16]}>
<Col span={24}>
<Panel data={data} />
</Col>
</Row>
);
}