fix(web): 新增体征数据后趋势图自动刷新
Some checks failed
CI / rust-check (push) Has been cancelled
CI / rust-test (push) Has been cancelled
CI / frontend-build (push) Has been cancelled
CI / security-audit (push) Has been cancelled

VitalSignsChart 增加 refreshKey prop,录入成功后递增触发 useEffect 重新加载趋势数据
This commit is contained in:
iven
2026-04-26 09:46:53 +08:00
parent 1f8fd0465d
commit d245499e34
2 changed files with 9 additions and 7 deletions

View File

@@ -8,13 +8,14 @@ const { Text } = Typography;
interface Props {
patientId: string;
refreshKey?: number;
}
const DEFAULT_INDICATOR = 'systolic_bp_morning';
const UNIT = 'mmHg';
const LABEL = '收缩压(晨)';
export function VitalSignsChart({ patientId }: Props) {
export function VitalSignsChart({ patientId, refreshKey }: Props) {
const [data, setData] = useState<{ date: string; value: number }[]>([]);
const [loading, setLoading] = useState(true);
const [error, setError] = useState(false);
@@ -32,7 +33,7 @@ export function VitalSignsChart({ patientId }: Props) {
})
.catch(() => setError(true))
.finally(() => setLoading(false));
}, [patientId]);
}, [patientId, refreshKey]);
if (loading) {
return (

View File

@@ -68,6 +68,7 @@ const columns = [
export function VitalSignsTab({ patientId }: Props) {
const [modalOpen, setModalOpen] = useState(false);
const [chartRefreshKey, setChartRefreshKey] = useState(0);
const [form] = Form.useForm();
const [submitting, setSubmitting] = useState(false);
@@ -108,7 +109,7 @@ export function VitalSignsTab({ patientId }: Props) {
setModalOpen(false);
form.resetFields();
refresh();
} catch {
setChartRefreshKey((k) => k + 1); } catch {
message.error('录入失败');
} finally {
setSubmitting(false);
@@ -121,8 +122,8 @@ export function VitalSignsTab({ patientId }: Props) {
return (
<div>
{/* 趋势图 */}
<div style={{ marginBottom: 16 }}>
<VitalSignsChart patientId={patientId} />
<div style={{ marginBottom: 12 }}>
<VitalSignsChart patientId={patientId} refreshKey={chartRefreshKey} />
</div>
{/* 最新记录摘要条 */}
@@ -131,13 +132,13 @@ export function VitalSignsTab({ patientId }: Props) {
display: 'flex',
gap: 16,
marginBottom: 12,
padding: '8px 12px',
padding: '6px 12px',
background: 'var(--ant-color-bg-container, #fafafa)',
borderRadius: 8,
border: '1px solid var(--ant-color-border-secondary, #f0f0f0)',
flexWrap: 'wrap',
}}>
<Text type="secondary" style={{ fontSize: 12, lineHeight: '24px' }}>
<Text type="secondary" style={{ fontSize: 12, lineHeight: '20px' }}>
<InfoCircleOutlined style={{ marginRight: 4 }} />
{latest.record_date}
</Text>