feat(miniprogram): 添加健康记录和诊断记录查看页面
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

- 新建 service: health-record.ts(listHealthRecords + listDiagnoses)
- 新建页面: health-records/index(体检记录列表,分页+下拉刷新)
- 新建页面: diagnoses/index(诊断记录列表,类型/状态标签)
- 路由注册到 pkg-profile 分包
- "我的"页菜单添加健康记录、诊断记录入口
This commit is contained in:
iven
2026-04-30 22:49:44 +08:00
parent f05ca00c75
commit 813843e8cc
7 changed files with 443 additions and 13 deletions

View File

@@ -0,0 +1,71 @@
@import '../../../styles/variables.scss';
.health-records-page {
min-height: 100vh;
background: $bg;
padding: 32px 24px;
padding-bottom: 40px;
}
.page-title {
font-family: 'Georgia', 'Times New Roman', serif;
font-size: 30px;
font-weight: bold;
color: $tx;
margin-bottom: 20px;
display: block;
padding-left: 4px;
}
.record-list {
display: flex;
flex-direction: column;
gap: 16px;
}
.record-card {
background: $card;
border-radius: $r;
padding: 28px;
box-shadow: $shadow-sm;
}
.record-card__header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 8px;
}
.record-card__type {
font-size: 28px;
font-weight: bold;
color: $tx;
}
.record-card__date {
font-size: 24px;
color: $tx2;
font-variant-numeric: tabular-nums;
}
.record-card__assessment {
font-size: 24px;
color: $tx;
display: block;
margin-bottom: 4px;
}
.record-card__source {
font-size: 22px;
color: $tx3;
display: block;
margin-bottom: 4px;
}
.record-card__notes {
font-size: 22px;
color: $tx2;
display: block;
margin-top: 8px;
}

View File

@@ -0,0 +1,90 @@
import React, { useState, useCallback } from 'react';
import { View, Text } from '@tarojs/components';
import Taro, { useDidShow, usePullDownRefresh, useReachBottom } from '@tarojs/taro';
import { listHealthRecords, HealthRecord } from '../../../services/health-record';
import EmptyState from '../../../components/EmptyState';
import Loading from '../../../components/Loading';
import './index.scss';
const TYPE_MAP: Record<string, string> = {
checkup: '体检',
follow_up: '复查',
referral: '转诊',
};
export default function HealthRecords() {
const [records, setRecords] = useState<HealthRecord[]>([]);
const [page, setPage] = useState(1);
const [total, setTotal] = useState(0);
const [loading, setLoading] = useState(false);
const fetchData = useCallback(async (p: number, append = false) => {
const patientId = Taro.getStorageSync('current_patient_id') || '';
if (!patientId) {
setRecords([]);
return;
}
setLoading(true);
try {
const res = await listHealthRecords(patientId, { page: p, page_size: 20 });
const list = res.data || [];
setRecords(append ? (prev) => [...prev, ...list] : list);
setTotal(res.total);
setPage(p);
} catch {
Taro.showToast({ title: '加载失败', icon: 'none' });
} finally {
setLoading(false);
}
}, []);
useDidShow(() => {
fetchData(1);
});
usePullDownRefresh(() => {
fetchData(1).finally(() => {
Taro.stopPullDownRefresh();
});
});
useReachBottom(() => {
if (!loading && records.length < total) {
fetchData(page + 1, true);
}
});
return (
<View className='health-records-page'>
<Text className='page-title'></Text>
<View className='record-list'>
{records.map((r) => (
<View className='record-card' key={r.id}>
<View className='record-card__header'>
<Text className='record-card__type'>
{TYPE_MAP[r.record_type] || r.record_type}
</Text>
<Text className='record-card__date'>{r.record_date}</Text>
</View>
{r.overall_assessment && (
<Text className='record-card__assessment'>{r.overall_assessment}</Text>
)}
{r.source && (
<Text className='record-card__source'>{r.source}</Text>
)}
{r.notes && (
<Text className='record-card__notes'>{r.notes}</Text>
)}
</View>
))}
</View>
{records.length === 0 && !loading && (
<EmptyState text={Taro.getStorageSync('current_patient_id') ? '暂无健康记录' : '请先在就诊人管理中选择就诊人'} />
)}
{loading && <Loading />}
</View>
);
}