fix(miniprogram): 删除重复页面 report/followup,修复 EmptyState 导入 bug

This commit is contained in:
iven
2026-04-24 12:19:24 +08:00
parent d26a847be2
commit f3716dbdc5
17 changed files with 42 additions and 475 deletions

View File

@@ -1,88 +0,0 @@
@import '../../styles/variables.scss';
.report-page {
min-height: 100vh;
background: $bg;
padding: 24px;
padding-bottom: 40px;
}
.report-list {
display: flex;
flex-direction: column;
gap: 20px;
}
.report-card {
background: $card;
border-radius: $r;
padding: 28px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.report-card-top {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 12px;
}
.report-type {
font-size: 30px;
font-weight: bold;
color: $tx;
}
.report-status {
font-size: 24px;
padding: 4px 16px;
border-radius: 20px;
&.normal {
color: $acc;
background: $acc-l;
}
&.abnormal {
color: $dan;
background: $dan-l;
}
}
.report-date {
font-size: 26px;
color: $tx2;
display: block;
margin-bottom: 8px;
}
.report-note {
font-size: 24px;
color: $tx3;
display: block;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.empty-state {
display: flex;
justify-content: center;
align-items: center;
padding: 120px 0;
}
.empty-text {
font-size: 28px;
color: $tx3;
}
.loading-hint {
text-align: center;
padding: 24px 0;
}
.loading-text {
font-size: 24px;
color: $tx3;
}

View File

@@ -1,94 +0,0 @@
import React, { useState, useCallback } from 'react';
import { View, Text } from '@tarojs/components';
import Taro, { useDidShow, usePullDownRefresh, useReachBottom } from '@tarojs/taro';
import { listReports, LabReport } from '../../services/report';
import EmptyState from '../../components/EmptyState';
import Loading from '../../components/Loading';
import './index.scss';
const PAGE_SIZE = 20;
export default function ReportList() {
const [reports, setReports] = useState<LabReport[]>([]);
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) return;
setLoading(true);
try {
const res = await listReports(patientId, p);
const list = res.data || [];
setReports(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 && reports.length < total) {
fetchData(page + 1, true);
}
});
const goToDetail = (id: string) => {
Taro.navigateTo({ url: `/pages/report/detail/index?id=${id}` });
};
const formatStatus = (report: LabReport) => {
const indicators = report.indicators;
if (!indicators || typeof indicators !== 'object') return '未知';
const vals = Object.values(indicators) as Array<{ status?: string }>;
const hasAbnormal = vals.some((v) => v.status === 'high' || v.status === 'low');
return hasAbnormal ? '异常' : '正常';
};
return (
<View className='report-page'>
<View className='report-list'>
{reports.map((r) => (
<View
className='report-card'
key={r.id}
onClick={() => goToDetail(r.id)}
>
<View className='report-card-top'>
<Text className='report-type'>{r.report_type}</Text>
<Text className={`report-status ${formatStatus(r) === '正常' ? 'normal' : 'abnormal'}`}>
{formatStatus(r)}
</Text>
</View>
<Text className='report-date'>{r.report_date}</Text>
{r.doctor_interpretation && (
<Text className='report-note'>{r.doctor_interpretation}</Text>
)}
</View>
))}
</View>
{reports.length === 0 && !loading && (
<EmptyState text='暂无报告记录' />
)}
{loading && (
<Loading />
)}
</View>
);
}