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

View File

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