feat: 医生端Web后台 + SignalR实时问诊

- 新增 doctor_web/ React前端 (dashboard/患者/问诊/报告/随访)
- 后端新增 doctor_endpoints (14个医生API) + ConsultationHub (SignalR)
- Flutter端 SignalR 替换轮询实现实时聊天
This commit is contained in:
MingNian
2026-06-05 17:46:07 +08:00
parent 20a5ce1199
commit d0d7d8428d
41 changed files with 5892 additions and 18 deletions

View File

@@ -0,0 +1,167 @@
import { useEffect, useRef, useState } from 'react';
import { useParams } from 'react-router-dom';
import { api } from '../../services/api-client';
import { getConnection, startConnection } from '../../services/signalr';
import type { ConsultationMessage } from '../../types';
export default function ChatPage() {
const { id } = useParams<{ id: string }>();
const [messages, setMessages] = useState<ConsultationMessage[]>([]);
const [status, setStatus] = useState('');
const [text, setText] = useState('');
const [connected, setConnected] = useState(false);
const bottomRef = useRef<HTMLDivElement>(null);
// 加载历史消息
useEffect(() => {
if (!id) return;
api.get<{ status: string; messages: ConsultationMessage[] }>(`/api/doctor/consultations/${id}/messages`)
.then(data => {
setMessages(data.messages);
setStatus(data.status);
})
.catch(() => {});
}, [id]);
// 建立 SignalR 连接
useEffect(() => {
if (!id) return;
let disposed = false;
(async () => {
try {
const conn = getConnection();
await startConnection();
if (disposed) return;
// 加入问诊房间
await conn.invoke('JoinConsultation', id);
setConnected(true);
// 注册消息接收
const handler = (msg: ConsultationMessage & { consultationId: string }) => {
if (msg.consultationId !== id) return;
setMessages(prev => {
if (prev.some(m => m.id === msg.id)) return prev; // 去重
return [...prev, msg];
});
};
conn.on('ReceiveMessage', handler);
// 重连时重新加入房间
conn.onreconnected(() => {
conn.invoke('JoinConsultation', id);
});
} catch { /* ignore */ }
})();
return () => {
disposed = true;
const conn = getConnection();
if (conn.state === 'Connected') {
conn.invoke('LeaveConsultation', id).catch(() => {});
conn.off('ReceiveMessage');
}
};
}, [id]);
// 自动滚到底部
useEffect(() => {
bottomRef.current?.scrollIntoView({ behavior: 'smooth' });
}, [messages]);
async function sendMessage() {
if (!text.trim() || !id) return;
const content = text.trim();
setText('');
// 通过 HTTP 发送(后端会通过 SignalR 广播)
try {
await api.post(`/api/doctor/consultations/${id}/messages`, { content });
} catch {
// fallback: 直接通过 SignalR 发送
try {
await getConnection().invoke('SendMessage', id, 'Doctor', '医生 · 王建国', content);
} catch { /* ignore */ }
}
}
return (
<div style={{ display: 'flex', flexDirection: 'column', height: '100vh' }}>
{/* 顶栏 */}
<div style={{ background: '#FFF', padding: '16px 24px', borderBottom: '1px solid #EDF0F7', display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
<div>
<div style={{ fontSize: 16, fontWeight: 600 }}></div>
<div style={{ fontSize: 12, color: '#9BA0B4', marginTop: 2 }}>
{status === 'AiTalking' ? 'AI 分身对话中' : status === 'WaitingDoctor' ? '等待医生回复' : status === 'DoctorReplied' ? '医生已回复' : status === 'Closed' ? '已结束' : status}
</div>
</div>
<div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
<div style={{ width: 8, height: 8, borderRadius: 4, background: connected ? '#20C997' : '#EF4444' }} />
<span style={{ fontSize: 12, color: '#9BA0B4' }}>{connected ? '已连接' : '未连接'}</span>
</div>
</div>
{/* 消息列表 */}
<div style={{ flex: 1, overflow: 'auto', padding: '20px 24px' }}>
{messages.map((msg, i) => {
const isDoctor = msg.senderType === 'Doctor';
const isAi = msg.senderType === 'Ai';
return (
<div key={msg.id || i} style={{ display: 'flex', flexDirection: 'column', alignItems: isDoctor ? 'flex-end' : 'flex-start', marginBottom: 16 }}>
{/* 发送者名称 */}
{!isDoctor && msg.senderName && (
<div style={{ fontSize: 11, color: '#9BA0B4', marginBottom: 4, marginLeft: 8 }}>{msg.senderName}</div>
)}
{/* 气泡 */}
<div style={{
maxWidth: '70%',
padding: '12px 18px',
borderRadius: isDoctor ? '18px 4px 18px 18px' : '4px 18px 18px 18px',
background: isDoctor ? '#4F6EF7' : isAi ? '#F5F5F5' : '#FFF',
color: isDoctor ? '#FFF' : '#1A1D28',
border: isDoctor ? 'none' : '1px solid #EDF0F7',
fontSize: 15,
lineHeight: 1.6,
whiteSpace: 'pre-wrap',
wordBreak: 'break-word',
}}>
{msg.content}
</div>
{/* AI 标记 */}
{isAi && (
<div style={{ fontSize: 10, color: '#F9A825', marginTop: 4, marginLeft: 8, background: '#FFF8E1', padding: '2px 8px', borderRadius: 6 }}>
AI
</div>
)}
{/* 时间 */}
<div style={{ fontSize: 11, color: '#CCC', marginTop: 4, marginLeft: 8, marginRight: 8 }}>
{new Date(msg.createdAt).toLocaleTimeString('zh-CN', { hour: '2-digit', minute: '2-digit' })}
</div>
</div>
);
})}
<div ref={bottomRef} />
</div>
{/* 输入栏 */}
<div style={{ background: '#FFF', padding: '14px 24px', borderTop: '1px solid #EDF0F7' }}>
<div style={{ display: 'flex', gap: 12 }}>
<input
value={text}
onChange={e => setText(e.target.value)}
onKeyDown={e => e.key === 'Enter' && sendMessage()}
placeholder="输入回复..."
style={{ flex: 1, padding: '12px 18px', border: '1px solid #E1E5ED', borderRadius: 12, fontSize: 15, outline: 'none' }}
/>
<button
onClick={sendMessage}
disabled={!text.trim()}
style={{ padding: '12px 24px', background: text.trim() ? '#4F6EF7' : '#E1E5ED', color: text.trim() ? '#FFF' : '#9BA0B4', border: 'none', borderRadius: 12, fontSize: 15, fontWeight: 600 }}>
</button>
</div>
</div>
</div>
);
}

View File

@@ -0,0 +1,57 @@
import { useEffect, useState } from 'react';
import { Link } from 'react-router-dom';
import { api } from '../../services/api-client';
import type { Consultation } from '../../types';
const STATUS_MAP: Record<string, { label: string; color: string }> = {
AiTalking: { label: 'AI 对话中', color: '#9BA0B4' },
WaitingDoctor: { label: '等待医生', color: '#F59E0B' },
DoctorReplied: { label: '医生已回复', color: '#20C997' },
Closed: { label: '已结束', color: '#CCC' },
};
export default function ConsultationListPage() {
const [list, setList] = useState<Consultation[]>([]);
useEffect(() => {
api.get<Consultation[]>('/api/doctor/consultations').then(setList).catch(() => {});
}, []);
return (
<div style={{ padding: 32, maxWidth: 1200 }}>
<h1 style={{ fontSize: 24, fontWeight: 700, marginBottom: 24 }}>线</h1>
{list.length === 0 ? (
<div style={{ color: '#9BA0B4', padding: 40, textAlign: 'center' }}></div>
) : (
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
{list.map(c => {
const st = STATUS_MAP[c.status] ?? { label: c.status, color: '#9BA0B4' };
return (
<Link key={c.id} to={`/consultations/${c.id}`}
style={{ background: '#FFF', borderRadius: 14, padding: '18px 20px', boxShadow: '0 1px 8px rgba(0,0,0,0.04)', display: 'flex', alignItems: 'center', gap: 16 }}>
<div style={{ width: 44, height: 44, borderRadius: 12, background: '#EDF0FD', display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: 18, fontWeight: 700, color: '#4F6EF7', flexShrink: 0 }}>
{(c.patientName || '患')[0]}
</div>
<div style={{ flex: 1 }}>
<div style={{ fontWeight: 600, fontSize: 15 }}>{c.patientName || c.patientPhone}</div>
<div style={{ fontSize: 13, color: '#9BA0B4', marginTop: 2 }}>
{c.lastMessage?.content?.slice(0, 40) || '暂无消息'}
</div>
</div>
<div style={{ textAlign: 'right' }}>
<span style={{ padding: '3px 12px', borderRadius: 10, fontSize: 12, fontWeight: 500, background: `${st.color}18`, color: st.color }}>
{st.label}
</span>
<div style={{ fontSize: 11, color: '#CCC', marginTop: 4 }}>
{new Date(c.createdAt).toLocaleDateString('zh-CN')}
</div>
</div>
</Link>
);
})}
</div>
)}
</div>
);
}

View File

@@ -0,0 +1,72 @@
import { useEffect, useState } from 'react';
import { Link } from 'react-router-dom';
import { api } from '../../services/api-client';
import type { DashboardStats } from '../../types';
const CARD_CONFIG = [
{ key: 'totalPatients', label: '患者总数', color: '#4F6EF7', bg: '#EDF0FD' },
{ key: 'activeConsultations', label: '进行中问诊', color: '#20C997', bg: '#E6F9F2' },
{ key: 'pendingReports', label: '待审核报告', color: '#F59E0B', bg: '#FFF8E6' },
{ key: 'todayFollowUps', label: '今日随访', color: '#845EF7', bg: '#F3E8FF' },
];
const QUICK_LINKS = [
{ to: '/patients', label: '患者列表', color: '#4F6EF7' },
{ to: '/consultations', label: '在线问诊', color: '#20C997' },
{ to: '/reports', label: '报告审核', color: '#F59E0B' },
{ to: '/follow-ups', label: '随访管理', color: '#845EF7' },
];
export default function DashboardPage() {
const [stats, setStats] = useState<DashboardStats | null>(null);
useEffect(() => {
api.get<DashboardStats>('/api/doctor/dashboard').then(setStats).catch(() => {});
}, []);
if (!stats) return <div style={{ padding: 40, color: '#9BA0B4' }}>...</div>;
return (
<div style={{ padding: 32, maxWidth: 1200 }}>
{/* 欢迎 */}
<div style={{ marginBottom: 32 }}>
<h1 style={{ fontSize: 24, fontWeight: 700 }}>{stats.doctorName}</h1>
<p style={{ color: '#9BA0B4', marginTop: 4 }}>{stats.doctorTitle} · {stats.doctorDepartment}</p>
</div>
{/* 统计卡片 */}
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(220px, 1fr))', gap: 20, marginBottom: 32 }}>
{CARD_CONFIG.map(c => (
<div key={c.key} style={{ background: '#FFF', borderRadius: 16, padding: '24px 20px', position: 'relative', overflow: 'hidden', boxShadow: '0 2px 12px rgba(0,0,0,0.04)' }}>
<div style={{ position: 'absolute', top: 0, left: 0, width: 4, height: '100%', background: c.color }} />
<div style={{ fontSize: 30, fontWeight: 800, color: c.color }}>{(stats as any)[c.key]}</div>
<div style={{ fontSize: 13, color: '#5A6072', marginTop: 4 }}>{c.label}</div>
</div>
))}
</div>
{/* 快捷操作 */}
<div style={{ display: 'grid', gridTemplateColumns: '2fr 1fr', gap: 20 }}>
<div style={{ background: '#FFF', borderRadius: 16, padding: 24, boxShadow: '0 2px 12px rgba(0,0,0,0.04)' }}>
<h2 style={{ fontSize: 16, fontWeight: 600, marginBottom: 16 }}></h2>
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 12 }}>
{QUICK_LINKS.map(l => (
<Link key={l.to} to={l.to} style={{ padding: '14px 16px', borderRadius: 12, border: `1px solid ${l.color}20`, color: l.color, fontWeight: 500, textAlign: 'center', transition: 'all 0.15s', fontSize: 14 }}>
{l.label}
</Link>
))}
</div>
</div>
<div style={{ background: '#FFF', borderRadius: 16, padding: 24, boxShadow: '0 2px 12px rgba(0,0,0,0.04)' }}>
<h2 style={{ fontSize: 16, fontWeight: 600, marginBottom: 16 }}></h2>
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
<div style={{ fontSize: 14, color: '#5A6072' }}>📋 <b style={{ color: '#F59E0B' }}>{stats.pendingReports}</b> </div>
<div style={{ fontSize: 14, color: '#5A6072' }}>💬 <b style={{ color: '#20C997' }}>{stats.activeConsultations}</b> </div>
<div style={{ fontSize: 14, color: '#5A6072' }}>📅 访 <b style={{ color: '#845EF7' }}>{stats.todayFollowUps}</b> </div>
</div>
</div>
</div>
</div>
);
}

View File

@@ -0,0 +1,105 @@
import { useEffect, useState } from 'react';
import { useParams, useNavigate } from 'react-router-dom';
import { api } from '../../services/api-client';
interface PatientSimple { id: string; name: string; phone: string; }
export default function FollowUpEditPage() {
const { id } = useParams<{ id: string }>();
const nav = useNavigate();
const isEdit = !!id;
const [patients, setPatients] = useState<PatientSimple[]>([]);
const [userId, setUserId] = useState('');
const [title, setTitle] = useState('');
const [scheduledAt, setScheduledAt] = useState('');
const [notes, setNotes] = useState('');
const [saving, setSaving] = useState(false);
useEffect(() => {
// 加载患者列表
api.get<PatientSimple[]>('/api/doctor/patients-simple').then(setPatients).catch(() => {});
// 编辑模式:加载现有随访
if (id) {
api.get<any[]>(`/api/doctor/follow-ups`).then(list => {
const item = list.find(f => f.id === id);
if (item) {
setUserId(item.userId);
setTitle(item.title);
// datetime-local 格式
const d = new Date(item.scheduledAt);
setScheduledAt(d.toISOString().slice(0, 16));
setNotes(item.notes || '');
}
}).catch(() => {});
}
}, [id]);
async function save() {
if (!userId || !title || !scheduledAt) return alert('请填写完整信息');
setSaving(true);
try {
const body = { userId, title, scheduledAt: new Date(scheduledAt).toISOString(), notes };
if (isEdit) {
await api.put(`/api/doctor/follow-ups/${id}`, body);
} else {
await api.post('/api/doctor/follow-ups', body);
}
nav('/follow-ups');
} catch { alert('保存失败'); }
setSaving(false);
}
return (
<div style={{ padding: 32, maxWidth: 600 }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 12, marginBottom: 24 }}>
<button onClick={() => nav(-1)} style={{ color: '#4F6EF7', fontSize: 14, border: 'none', background: 'none' }}> </button>
<h1 style={{ fontSize: 24, fontWeight: 700 }}>{isEdit ? '编辑随访' : '新建随访'}</h1>
</div>
<div style={{ background: '#FFF', borderRadius: 16, padding: 24, boxShadow: '0 2px 12px rgba(0,0,0,0.04)' }}>
{/* 患者选择 */}
<div style={{ marginBottom: 20 }}>
<label style={{ display: 'block', fontSize: 14, fontWeight: 500, marginBottom: 6, color: '#5A6072' }}></label>
<select value={userId} onChange={e => setUserId(e.target.value)}
style={{ width: '100%', padding: '10px 14px', border: '1px solid #E1E5ED', borderRadius: 10, fontSize: 14, outline: 'none' }}>
<option value=""></option>
{patients.map(p => (
<option key={p.id} value={p.id}>{p.name || '未设置'} ({p.phone})</option>
))}
</select>
</div>
{/* 标题 */}
<div style={{ marginBottom: 20 }}>
<label style={{ display: 'block', fontSize: 14, fontWeight: 500, marginBottom: 6, color: '#5A6072' }}>访</label>
<input value={title} onChange={e => setTitle(e.target.value)} placeholder="如PCI术后1个月随访"
style={{ width: '100%', padding: '10px 14px', border: '1px solid #E1E5ED', borderRadius: 10, fontSize: 14, outline: 'none' }} />
</div>
{/* 时间 */}
<div style={{ marginBottom: 20 }}>
<label style={{ display: 'block', fontSize: 14, fontWeight: 500, marginBottom: 6, color: '#5A6072' }}></label>
<input type="datetime-local" value={scheduledAt} onChange={e => setScheduledAt(e.target.value)}
style={{ width: '100%', padding: '10px 14px', border: '1px solid #E1E5ED', borderRadius: 10, fontSize: 14, outline: 'none' }} />
</div>
{/* 备注 */}
<div style={{ marginBottom: 24 }}>
<label style={{ display: 'block', fontSize: 14, fontWeight: 500, marginBottom: 6, color: '#5A6072' }}></label>
<textarea value={notes} onChange={e => setNotes(e.target.value)} placeholder="备注信息..."
rows={3}
style={{ width: '100%', padding: '10px 14px', border: '1px solid #E1E5ED', borderRadius: 10, fontSize: 14, outline: 'none', resize: 'vertical' }} />
</div>
<button onClick={save} disabled={saving}
style={{
width: '100%', padding: '14px', background: saving ? '#E1E5ED' : 'linear-gradient(135deg, #4F6EF7, #6C8AFF)',
color: saving ? '#9BA0B4' : '#FFF', border: 'none', borderRadius: 12, fontSize: 16, fontWeight: 600,
}}>
{saving ? '保存中...' : '保存'}
</button>
</div>
</div>
);
}

View File

@@ -0,0 +1,94 @@
import { useEffect, useState } from 'react';
import { Link, useNavigate } from 'react-router-dom';
import { api } from '../../services/api-client';
import type { FollowUp } from '../../types';
const STATUS_MAP: Record<string, { label: string; color: string }> = {
Upcoming: { label: '即将到来', color: '#4F6EF7' },
Completed: { label: '已完成', color: '#20C997' },
Cancelled: { label: '已取消', color: '#EF4444' },
};
export default function FollowUpListPage() {
const [list, setList] = useState<FollowUp[]>([]);
const [filter, setFilter] = useState('');
const nav = useNavigate();
useEffect(() => { loadList(); }, [filter]);
async function loadList() {
const q = filter ? `?status=${filter}` : '';
try { setList(await api.get<FollowUp[]>(`/api/doctor/follow-ups${q}`)); } catch { setList([]); }
}
async function deleteItem(id: string) {
if (!confirm('确定删除?')) return;
try {
await api.del(`/api/doctor/follow-ups/${id}`);
setList(prev => prev.filter(f => f.id !== id));
} catch { alert('删除失败'); }
}
async function markComplete(id: string) {
try {
await api.put(`/api/doctor/follow-ups/${id}`, { status: 'Completed' });
loadList();
} catch { alert('操作失败'); }
}
return (
<div style={{ padding: 32, maxWidth: 1200 }}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 24 }}>
<h1 style={{ fontSize: 24, fontWeight: 700 }}>访</h1>
<button onClick={() => nav('/follow-ups/new')}
style={{ padding: '10px 24px', background: 'linear-gradient(135deg, #4F6EF7, #6C8AFF)', color: '#FFF', border: 'none', borderRadius: 12, fontSize: 14, fontWeight: 600 }}>
+ 访
</button>
</div>
{/* 筛选 */}
<div style={{ display: 'flex', gap: 8, marginBottom: 20 }}>
{[{ k: '', l: '全部' }, { k: 'Upcoming', l: '即将到来' }, { k: 'Completed', l: '已完成' }, { k: 'Cancelled', l: '已取消' }].map(t => (
<button key={t.k} onClick={() => setFilter(t.k)}
style={{ padding: '6px 18px', borderRadius: 10, border: 'none', fontSize: 13, fontWeight: 500,
background: filter === t.k ? '#4F6EF7' : '#F2F3F7', color: filter === t.k ? '#FFF' : '#5A6072' }}>
{t.l}
</button>
))}
</div>
{list.length === 0 ? (
<div style={{ color: '#9BA0B4', padding: 40, textAlign: 'center' }}>访</div>
) : (
<div style={{ display: 'flex', flexDirection: 'column', gap: 12 }}>
{list.map(f => {
const st = STATUS_MAP[f.status] ?? { label: f.status, color: '#9BA0B4' };
return (
<div key={f.id} style={{ background: '#FFF', borderRadius: 14, padding: '18px 20px', boxShadow: '0 1px 8px rgba(0,0,0,0.04)', display: 'flex', alignItems: 'center', gap: 16 }}>
<span style={{ fontSize: 24 }}>📅</span>
<div style={{ flex: 1 }}>
<div style={{ fontWeight: 600, fontSize: 15 }}>{f.title}</div>
<div style={{ fontSize: 13, color: '#5A6072', marginTop: 2 }}>
{f.patientName || '-'} · {new Date(f.scheduledAt).toLocaleString('zh-CN')}
</div>
{f.notes && <div style={{ fontSize: 12, color: '#9BA0B4', marginTop: 2 }}>{f.notes}</div>}
</div>
<span style={{ padding: '3px 12px', borderRadius: 10, fontSize: 12, fontWeight: 500, background: `${st.color}18`, color: st.color }}>
{st.label}
</span>
{/* 操作按钮 */}
<div style={{ display: 'flex', gap: 6 }}>
{f.status === 'Upcoming' && (
<button onClick={() => markComplete(f.id)} style={{ padding: '4px 12px', borderRadius: 8, border: '1px solid #20C997', background: '#E6F9F2', color: '#20C997', fontSize: 12 }}></button>
)}
<Link to={`/follow-ups/${f.id}/edit`} style={{ padding: '4px 12px', borderRadius: 8, border: '1px solid #E1E5ED', color: '#5A6072', fontSize: 12 }}></Link>
<button onClick={() => deleteItem(f.id)} style={{ padding: '4px 12px', borderRadius: 8, border: '1px solid #FEE2E2', background: '#FFF5F5', color: '#EF4444', fontSize: 12 }}></button>
</div>
</div>
);
})}
</div>
)}
</div>
);
}

View File

@@ -0,0 +1,273 @@
import { useEffect, useState } from 'react';
import { useParams, Link } from 'react-router-dom';
import { api } from '../../services/api-client';
import type { PatientDetail, TrendRecord } from '../../types';
import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, Legend } from 'recharts';
const METRIC_LABELS: Record<string, string> = {
BloodPressure: '血压', HeartRate: '心率', Glucose: '血糖', SpO2: '血氧', Weight: '体重',
};
const METRIC_COLORS: Record<string, string> = {
BloodPressure: '#EF4444', HeartRate: '#F59E0B', Glucose: '#4F6EF7', SpO2: '#20C997', Weight: '#845EF7',
};
const DAY_LABELS = ['日', '一', '二', '三', '四', '五', '六'];
export default function PatientDetailPage() {
const { id } = useParams<{ id: string }>();
const [data, setData] = useState<PatientDetail | null>(null);
const [chartMetric, setChartMetric] = useState<string>('BloodPressure');
useEffect(() => {
if (id) api.get<PatientDetail>(`/api/doctor/patients/${id}`).then(setData).catch(() => {});
}, [id]);
if (!data) return <div style={{ padding: 40, color: '#9BA0B4' }}>...</div>;
const p = data.profile;
const a = data.archive;
// 趋势图数据(用 any 兼容不同指标的数据结构)
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const chartData: any[] = buildChartData(data.trendRecords, chartMetric);
return (
<div style={{ padding: 32, maxWidth: 1200 }}>
{/* 标题 */}
<div style={{ display: 'flex', alignItems: 'center', gap: 12, marginBottom: 24 }}>
<Link to="/patients" style={{ color: '#4F6EF7', fontSize: 14 }}> </Link>
<h1 style={{ fontSize: 24, fontWeight: 700 }}>{p.name || '未设置'} </h1>
</div>
{/* 基本信息卡片 */}
<InfoCard p={p} a={a} />
{/* 健康指标 */}
<Section title="最新健康指标">
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(180px, 1fr))', gap: 16 }}>
{data.latestRecords.map(r => (
<div key={r.id} style={{ background: '#FFF', borderRadius: 14, padding: 20, position: 'relative', overflow: 'hidden', boxShadow: '0 1px 8px rgba(0,0,0,0.04)' }}>
<div style={{ position: 'absolute', top: 0, left: 0, width: 3, height: '100%', background: METRIC_COLORS[r.metricType] || '#9BA0B4' }} />
<div style={{ fontSize: 12, color: '#9BA0B4', marginBottom: 4 }}>{METRIC_LABELS[r.metricType] || r.metricType}</div>
<div style={{ fontSize: 26, fontWeight: 700, color: r.isAbnormal ? '#EF4444' : '#1A1D28' }}>
{r.metricType === 'BloodPressure' ? `${r.systolic}/${r.diastolic}` : r.value}
<span style={{ fontSize: 14, fontWeight: 400, color: '#9BA0B4', marginLeft: 4 }}>{r.unit}</span>
</div>
<div style={{ fontSize: 11, color: '#9BA0B4', marginTop: 4 }}>
{new Date(r.recordedAt).toLocaleDateString('zh-CN')}
</div>
</div>
))}
{data.latestRecords.length === 0 && <Empty text="暂无健康数据" />}
</div>
</Section>
{/* 趋势图 */}
<Section title="健康趋势30天">
<div style={{ display: 'flex', gap: 8, marginBottom: 16 }}>
{Object.keys(METRIC_LABELS).map(m => (
<button key={m} onClick={() => setChartMetric(m)}
style={{
padding: '6px 14px', borderRadius: 8, border: 'none', fontSize: 13, fontWeight: 500,
background: chartMetric === m ? METRIC_COLORS[m] : '#F2F3F7',
color: chartMetric === m ? '#FFF' : '#5A6072',
}}>
{METRIC_LABELS[m]}
</button>
))}
</div>
{chartData.length > 0 ? (
<div style={{ background: '#FFF', borderRadius: 14, padding: 24, boxShadow: '0 1px 8px rgba(0,0,0,0.04)' }}>
<ResponsiveContainer width="100%" height={300}>
<LineChart data={chartData}>
<CartesianGrid strokeDasharray="3 3" stroke="#F0F0F0" />
<XAxis dataKey="date" tick={{ fontSize: 12 }} />
<YAxis tick={{ fontSize: 12 }} />
<Tooltip />
<Legend />
{chartMetric === 'BloodPressure' ? (
<>
<Line type="monotone" dataKey="systolic" stroke="#EF4444" name="收缩压" strokeWidth={2} dot={{ r: 3 }} />
<Line type="monotone" dataKey="diastolic" stroke="#F59E0B" name="舒张压" strokeWidth={2} dot={{ r: 3 }} />
</>
) : (
<Line type="monotone" dataKey="value" stroke={METRIC_COLORS[chartMetric]} name={METRIC_LABELS[chartMetric]} strokeWidth={2} dot={{ r: 4 }} />
)}
</LineChart>
</ResponsiveContainer>
</div>
) : <Empty text="暂无趋势数据" />}
</Section>
{/* 用药 */}
<Section title="当前用药">
{data.medications.length > 0 ? (
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
{data.medications.map(m => (
<div key={m.id} style={{ background: '#FFF', borderRadius: 12, padding: '14px 18px', boxShadow: '0 1px 8px rgba(0,0,0,0.04)', display: 'flex', alignItems: 'center', gap: 12 }}>
<span style={{ fontSize: 20 }}>💊</span>
<div style={{ flex: 1 }}>
<div style={{ fontWeight: 600 }}>{m.name} <span style={{ fontWeight: 400, color: '#5A6072', fontSize: 14 }}>{m.dosage}</span></div>
<div style={{ fontSize: 12, color: '#9BA0B4' }}>{m.frequency} · {m.timeOfDay?.join(', ')}</div>
</div>
</div>
))}
</div>
) : <Empty text="暂无用药" />}
</Section>
{/* 饮食 + 运动 双列 */}
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: 24, marginBottom: 24 }}>
<div>
<div style={{ fontSize: 16, fontWeight: 600, marginBottom: 12 }}>🍽 </div>
{data.dietRecords.length > 0 ? (
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
{data.dietRecords.map(d => (
<div key={d.id} style={{ background: '#FFF', borderRadius: 12, padding: '12px 16px', boxShadow: '0 1px 8px rgba(0,0,0,0.04)' }}>
<div style={{ fontSize: 13, fontWeight: 500 }}>{d.foods.map(f => f.name).join('、')}</div>
<div style={{ fontSize: 12, color: '#9BA0B4', marginTop: 4 }}>
{d.mealType === 'Breakfast' ? '早餐' : d.mealType === 'Lunch' ? '午餐' : d.mealType === 'Dinner' ? '晚餐' : '加餐'}
{' · '}{d.totalCalories}kcal · {d.healthScore}/5
</div>
</div>
))}
</div>
) : <Empty text="暂无饮食记录" />}
</div>
<div>
<div style={{ fontSize: 16, fontWeight: 600, marginBottom: 12 }}>🏃 </div>
{data.exercisePlan ? (
<div style={{ display: 'flex', flexDirection: 'column', gap: 6 }}>
{data.exercisePlan.items.map((item, i) => (
<div key={i} style={{ background: '#FFF', borderRadius: 12, padding: '10px 16px', boxShadow: '0 1px 8px rgba(0,0,0,0.04)', display: 'flex', alignItems: 'center', gap: 10, opacity: item.isRestDay ? 0.5 : 1 }}>
<span style={{ fontSize: 12, color: '#9BA0B4', minWidth: 36 }}>{DAY_LABELS[item.dayOfWeek]}</span>
<span style={{ flex: 1, fontSize: 13 }}>
{item.isRestDay ? '休息' : `${item.exerciseType} ${item.durationMinutes}分钟`}
</span>
{item.isCompleted && <span style={{ color: '#20C997', fontSize: 12, fontWeight: 500 }}> </span>}
</div>
))}
</div>
) : <Empty text="暂无运动计划" />}
</div>
</div>
{/* 报告 */}
<Section title="📋 检查报告">
{data.reports.length > 0 ? (
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
{data.reports.map(r => (
<Link key={r.id} to={`/reports/${r.id}`} style={{ background: '#FFF', borderRadius: 12, padding: '14px 18px', boxShadow: '0 1px 8px rgba(0,0,0,0.04)', display: 'flex', alignItems: 'center', gap: 12 }}>
<span style={{ fontSize: 20 }}>📄</span>
<div style={{ flex: 1 }}>
<div style={{ fontWeight: 500, fontSize: 14 }}>{r.category} </div>
<div style={{ fontSize: 12, color: '#9BA0B4' }}>{new Date(r.createdAt).toLocaleDateString('zh-CN')}</div>
</div>
<StatusBadge status={r.status} map={{ PendingDoctor: ['待审核', '#F59E0B'], DoctorReviewed: ['已审核', '#20C997'] }} />
</Link>
))}
</div>
) : <Empty text="暂无报告" />}
</Section>
{/* 随访 */}
<Section title="📅 复查随访">
{data.followUps.length > 0 ? (
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
{data.followUps.map(f => (
<div key={f.id} style={{ background: '#FFF', borderRadius: 12, padding: '14px 18px', boxShadow: '0 1px 8px rgba(0,0,0,0.04)', display: 'flex', alignItems: 'center', gap: 12 }}>
<span style={{ fontSize: 20 }}>📅</span>
<div style={{ flex: 1 }}>
<div style={{ fontWeight: 500, fontSize: 14 }}>{f.title}</div>
<div style={{ fontSize: 12, color: '#9BA0B4' }}>
{new Date(f.scheduledAt).toLocaleString('zh-CN')}
{f.doctorName ? ` · ${f.doctorName}` : ''}
{f.notes ? ` · ${f.notes}` : ''}
</div>
</div>
<StatusBadge status={f.status} map={{ Upcoming: ['即将到来', '#4F6EF7'], Completed: ['已完成', '#20C997'], Cancelled: ['已取消', '#EF4444'] }} />
</div>
))}
</div>
) : <Empty text="暂无随访安排" />}
</Section>
</div>
);
}
// ===== 子组件 =====
function InfoCard({ p, a }: { p: PatientDetail['profile']; a: PatientDetail['archive'] }) {
return (
<div style={{ background: '#FFF', borderRadius: 16, padding: 24, marginBottom: 24, boxShadow: '0 2px 12px rgba(0,0,0,0.04)' }}>
<div style={{ display: 'flex', gap: 24 }}>
<div style={{ width: 64, height: 64, borderRadius: 16, background: 'linear-gradient(135deg, #4F6EF7, #6C8AFF)', display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#FFF', fontSize: 28, fontWeight: 700, flexShrink: 0 }}>
{p.name?.[0] ?? '?'}
</div>
<div style={{ flex: 1 }}>
<div style={{ fontSize: 20, fontWeight: 700 }}>{p.name || '未设置'}</div>
<div style={{ fontSize: 13, color: '#9BA0B4', marginTop: 2 }}>{p.phone} · {p.gender || '未知'} · {p.birthDate || '未知'}</div>
{a && (
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: '4px 24px', marginTop: 12, fontSize: 13 }}>
<Row label="诊断" value={a.diagnosis} />
<Row label="手术类型" value={a.surgeryType} />
<Row label="手术日期" value={a.surgeryDate} />
<Row label="过敏史" value={a.allergies?.join('、')} />
<Row label="饮食限制" value={a.dietRestrictions?.join('、')} />
<Row label="慢病史" value={a.chronicDiseases?.join('、')} />
<Row label="家族病史" value={a.familyHistory} />
</div>
)}
</div>
</div>
</div>
);
}
function Row({ label, value }: { label: string; value?: string | null }) {
return (
<div>
<span style={{ color: '#9BA0B4' }}>{label}</span>
<span style={{ color: value ? '#1A1D28' : '#CCC' }}>{value || '未填写'}</span>
</div>
);
}
function Section({ title, children }: { title: string; children: React.ReactNode }) {
return (
<div style={{ marginBottom: 24 }}>
<div style={{ fontSize: 16, fontWeight: 600, marginBottom: 12 }}>{title}</div>
{children}
</div>
);
}
function Empty({ text }: { text: string }) {
return <div style={{ color: '#CCC', fontSize: 13, padding: 16, textAlign: 'center' }}>{text}</div>;
}
function StatusBadge({ status, map }: { status: string; map: Record<string, [string, string]> }) {
const [label, color] = map[status] ?? [status, '#9BA0B4'];
return (
<span style={{ padding: '3px 12px', borderRadius: 10, fontSize: 12, fontWeight: 500, background: `${color}18`, color }}>
{label}
</span>
);
}
// 构建趋势图数据
function buildChartData(records: TrendRecord[], metric: string) {
const filtered = records.filter(r => r.metricType === metric);
if (metric === 'BloodPressure') {
return filtered.map(r => ({
date: new Date(r.recordedAt).toLocaleDateString('zh-CN', { month: 'short', day: 'numeric' }),
systolic: r.systolic,
diastolic: r.diastolic,
}));
}
return filtered.map(r => ({
date: new Date(r.recordedAt).toLocaleDateString('zh-CN', { month: 'short', day: 'numeric' }),
value: r.value,
}));
}

View File

@@ -0,0 +1,80 @@
import { useEffect, useState } from 'react';
import { Link } from 'react-router-dom';
import { api } from '../../services/api-client';
import type { Patient } from '../../types';
export default function PatientListPage() {
const [patients, setPatients] = useState<Patient[]>([]);
const [search, setSearch] = useState('');
const [loading, setLoading] = useState(true);
useEffect(() => { loadPatients(); }, []);
async function loadPatients(s?: string) {
setLoading(true);
try {
const q = s !== undefined ? s : search;
const data = await api.get<Patient[]>(`/api/doctor/patients${q ? `?search=${encodeURIComponent(q)}` : ''}`);
setPatients(data);
} catch { setPatients([]); }
setLoading(false);
}
return (
<div style={{ padding: 32, maxWidth: 1200 }}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 24 }}>
<h1 style={{ fontSize: 24, fontWeight: 700 }}></h1>
<div style={{ display: 'flex', gap: 8 }}>
<input
value={search}
onChange={e => setSearch(e.target.value)}
onKeyDown={e => e.key === 'Enter' && loadPatients()}
placeholder="搜索姓名或手机号..."
style={{ padding: '8px 16px', border: '1px solid #E1E5ED', borderRadius: 10, fontSize: 14, outline: 'none', width: 240 }}
/>
<button onClick={() => loadPatients()} style={{ padding: '8px 20px', background: '#4F6EF7', color: '#FFF', border: 'none', borderRadius: 10, fontSize: 14, fontWeight: 500 }}>
</button>
</div>
</div>
{loading ? (
<div style={{ color: '#9BA0B4', padding: 40 }}>...</div>
) : patients.length === 0 ? (
<div style={{ color: '#9BA0B4', padding: 40, textAlign: 'center' }}></div>
) : (
<div style={{ background: '#FFF', borderRadius: 16, overflow: 'hidden', boxShadow: '0 2px 12px rgba(0,0,0,0.04)' }}>
<table style={{ width: '100%', borderCollapse: 'collapse', fontSize: 14 }}>
<thead>
<tr style={{ background: '#FAFBFD', borderBottom: '1px solid #EDF0F7' }}>
{['姓名', '手机号', '性别', '出生日期', '健康档案', '操作'].map(h => (
<th key={h} style={{ padding: '14px 16px', textAlign: 'left', fontWeight: 600, color: '#5A6072', fontSize: 13 }}>{h}</th>
))}
</tr>
</thead>
<tbody>
{patients.map(p => (
<tr key={p.id} style={{ borderBottom: '1px solid #F2F3F7' }}>
<td style={{ padding: '12px 16px', fontWeight: 500 }}>{p.name || '未设置'}</td>
<td style={{ padding: '12px 16px', color: '#5A6072' }}>{p.phone}</td>
<td style={{ padding: '12px 16px', color: '#5A6072' }}>{p.gender || '-'}</td>
<td style={{ padding: '12px 16px', color: '#5A6072' }}>{p.birthDate || '-'}</td>
<td style={{ padding: '12px 16px' }}>
<span style={{ padding: '2px 10px', borderRadius: 10, fontSize: 12, background: p.hasArchive ? '#E6F9F2' : '#FFF3E0', color: p.hasArchive ? '#20C997' : '#F59E0B' }}>
{p.hasArchive ? '已建立' : '未建立'}
</span>
</td>
<td style={{ padding: '12px 16px' }}>
<Link to={`/patients/${p.id}`} style={{ color: '#4F6EF7', fontWeight: 500, fontSize: 13 }}>
</Link>
</td>
</tr>
))}
</tbody>
</table>
</div>
)}
</div>
);
}

View File

@@ -0,0 +1,133 @@
import { useEffect, useState } from 'react';
import { useParams, useNavigate } from 'react-router-dom';
import { api } from '../../services/api-client';
import type { Report } from '../../types';
export default function ReportDetailPage() {
const { id } = useParams<{ id: string }>();
const nav = useNavigate();
const [report, setReport] = useState<Report | null>(null);
const [comment, setComment] = useState('');
const [submitting, setSubmitting] = useState(false);
const [success, setSuccess] = useState(false);
useEffect(() => {
if (id) api.get<Report>(`/api/doctor/reports/${id}`).then(r => { setReport(r); setComment(r.doctorComment || ''); }).catch(() => {});
}, [id]);
async function submitReview() {
if (!id) return;
setSubmitting(true);
try {
await api.post(`/api/doctor/reports/${id}/review`, { comment });
setSuccess(true);
} catch { alert('提交失败'); }
setSubmitting(false);
}
if (!report) return <div style={{ padding: 40, color: '#9BA0B4' }}>...</div>;
// 解析 AI 指标
let indicators: any[] = [];
try { indicators = JSON.parse(report.aiIndicators || '[]'); } catch {}
return (
<div style={{ padding: 32, maxWidth: 900 }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 12, marginBottom: 24 }}>
<button onClick={() => nav(-1)} style={{ color: '#4F6EF7', fontSize: 14, border: 'none', background: 'none', cursor: 'pointer' }}> </button>
<h1 style={{ fontSize: 24, fontWeight: 700 }}></h1>
</div>
{/* 基本信息 */}
<div style={{ background: '#FFF', borderRadius: 16, padding: 24, marginBottom: 20, boxShadow: '0 2px 12px rgba(0,0,0,0.04)' }}>
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: '8px 24px', fontSize: 14 }}>
<div><span style={{ color: '#9BA0B4' }}></span>{report.patientName || '-'}</div>
<div><span style={{ color: '#9BA0B4' }}></span>{report.category}</div>
<div><span style={{ color: '#9BA0B4' }}></span>{new Date(report.createdAt).toLocaleString('zh-CN')}</div>
<div>
<span style={{ color: '#9BA0B4' }}></span>
<span style={{ padding: '2px 10px', borderRadius: 10, fontSize: 12, background: report.status === 'PendingDoctor' ? '#FFF8E6' : '#E6F9F2', color: report.status === 'PendingDoctor' ? '#F59E0B' : '#20C997' }}>
{report.status === 'PendingDoctor' ? '待审核' : '已审核'}
</span>
</div>
</div>
{report.fileUrl && (
<div style={{ marginTop: 16 }}>
<a href={`http://localhost:5000${report.fileUrl}`} target="_blank" rel="noopener noreferrer"
style={{ color: '#4F6EF7', fontSize: 13, textDecoration: 'underline' }}>
📎
</a>
</div>
)}
</div>
{/* AI 预解读 */}
<div style={{ background: '#FFF', borderRadius: 16, padding: 24, marginBottom: 20, boxShadow: '0 2px 12px rgba(0,0,0,0.04)' }}>
<h2 style={{ fontSize: 16, fontWeight: 600, marginBottom: 16 }}>🤖 AI </h2>
{report.aiSummary && (
<div style={{ fontSize: 14, lineHeight: 1.7, color: '#5A6072', marginBottom: 16, padding: '12px 16px', background: '#FAFBFD', borderRadius: 10 }}>
{report.aiSummary}
</div>
)}
{indicators.length > 0 && (
<table style={{ width: '100%', borderCollapse: 'collapse', fontSize: 13 }}>
<thead>
<tr style={{ borderBottom: '2px solid #EDF0F7' }}>
{['指标', '结果', '单位', '参考范围', '状态'].map(h => (
<th key={h} style={{ padding: '8px 12px', textAlign: 'left', color: '#9BA0B4', fontWeight: 500 }}>{h}</th>
))}
</tr>
</thead>
<tbody>
{indicators.map((ind: any, i: number) => {
const abnormal = ind.status === 'high' || ind.status === 'abnormal';
const low = ind.status === 'low';
return (
<tr key={i} style={{ borderBottom: '1px solid #F2F3F7' }}>
<td style={{ padding: '8px 12px' }}>{ind.name}</td>
<td style={{ padding: '8px 12px', fontWeight: 500, color: abnormal ? '#EF4444' : low ? '#F59E0B' : '#20C997' }}>{ind.value}</td>
<td style={{ padding: '8px 12px', color: '#5A6072' }}>{ind.unit || '-'}</td>
<td style={{ padding: '8px 12px', color: '#5A6072' }}>{ind.range || '-'}</td>
<td style={{ padding: '8px 12px' }}>
<span style={{ padding: '2px 8px', borderRadius: 8, fontSize: 11, background: abnormal ? '#FEE2E2' : low ? '#FFF8E6' : '#E6F9F2', color: abnormal ? '#EF4444' : low ? '#F59E0B' : '#20C997' }}>
{abnormal ? '偏高' : low ? '偏低' : '正常'}
</span>
</td>
</tr>
);
})}
</tbody>
</table>
)}
</div>
{/* 医生审核 */}
<div style={{ background: '#FFF', borderRadius: 16, padding: 24, boxShadow: '0 2px 12px rgba(0,0,0,0.04)' }}>
<h2 style={{ fontSize: 16, fontWeight: 600, marginBottom: 16 }}>👨 </h2>
{success && (
<div style={{ marginBottom: 16, padding: '12px 18px', background: '#E6F9F2', borderRadius: 10, color: '#20C997', fontWeight: 500, fontSize: 14 }}>
</div>
)}
<textarea
value={comment}
onChange={e => setComment(e.target.value)}
placeholder="请输入您的专业解读意见..."
rows={5}
style={{ width: '100%', padding: 14, border: '1px solid #E1E5ED', borderRadius: 12, fontSize: 14, outline: 'none', resize: 'vertical' }}
/>
<div style={{ marginTop: 16, display: 'flex', justifyContent: 'flex-end' }}>
<button onClick={submitReview} disabled={submitting || !comment.trim()}
style={{
padding: '12px 32px',
background: submitting || !comment.trim() ? '#E1E5ED' : 'linear-gradient(135deg, #4F6EF7, #6C8AFF)',
color: submitting || !comment.trim() ? '#9BA0B4' : '#FFF',
border: 'none', borderRadius: 12, fontSize: 15, fontWeight: 600,
}}>
{submitting ? '提交中...' : '提交审核意见'}
</button>
</div>
</div>
</div>
);
}

View File

@@ -0,0 +1,75 @@
import { useEffect, useState } from 'react';
import { Link } from 'react-router-dom';
import { api } from '../../services/api-client';
import type { Report } from '../../types';
const STATUS_MAP: Record<string, { label: string; color: string }> = {
PendingDoctor: { label: '待审核', color: '#F59E0B' },
DoctorReviewed: { label: '已审核', color: '#20C997' },
};
export default function ReportListPage() {
const [reports, setReports] = useState<Report[]>([]);
const [filter, setFilter] = useState('');
useEffect(() => {
const q = filter ? `?status=${filter}` : '';
api.get<Report[]>(`/api/doctor/reports${q}`).then(setReports).catch(() => {});
}, [filter]);
return (
<div style={{ padding: 32, maxWidth: 1200 }}>
<h1 style={{ fontSize: 24, fontWeight: 700, marginBottom: 24 }}></h1>
{/* 筛选标签 */}
<div style={{ display: 'flex', gap: 8, marginBottom: 20 }}>
{[{ k: '', l: '全部' }, { k: 'PendingDoctor', l: '待审核' }, { k: 'DoctorReviewed', l: '已审核' }].map(t => (
<button key={t.k} onClick={() => setFilter(t.k)}
style={{ padding: '6px 18px', borderRadius: 10, border: 'none', fontSize: 13, fontWeight: 500,
background: filter === t.k ? '#4F6EF7' : '#F2F3F7', color: filter === t.k ? '#FFF' : '#5A6072' }}>
{t.l}
</button>
))}
</div>
{reports.length === 0 ? (
<div style={{ color: '#9BA0B4', padding: 40, textAlign: 'center' }}></div>
) : (
<div style={{ background: '#FFF', borderRadius: 16, overflow: 'hidden', boxShadow: '0 2px 12px rgba(0,0,0,0.04)' }}>
<table style={{ width: '100%', borderCollapse: 'collapse', fontSize: 14 }}>
<thead>
<tr style={{ background: '#FAFBFD', borderBottom: '1px solid #EDF0F7' }}>
{['患者', '类型', '状态', 'AI 摘要', '上传时间', '操作'].map(h => (
<th key={h} style={{ padding: '14px 16px', textAlign: 'left', fontWeight: 600, color: '#5A6072', fontSize: 13 }}>{h}</th>
))}
</tr>
</thead>
<tbody>
{reports.map(r => {
const st = STATUS_MAP[r.status] ?? { label: r.status, color: '#9BA0B4' };
return (
<tr key={r.id} style={{ borderBottom: '1px solid #F2F3F7' }}>
<td style={{ padding: '12px 16px', fontWeight: 500 }}>{r.patientName || '-'}</td>
<td style={{ padding: '12px 16px', color: '#5A6072' }}>{r.category}</td>
<td style={{ padding: '12px 16px' }}>
<span style={{ padding: '3px 12px', borderRadius: 10, fontSize: 12, fontWeight: 500, background: `${st.color}18`, color: st.color }}>{st.label}</span>
</td>
<td style={{ padding: '12px 16px', color: '#5A6072', maxWidth: 240, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
{r.aiSummary?.slice(0, 40) || '-'}
</td>
<td style={{ padding: '12px 16px', color: '#9BA0B4', fontSize: 13 }}>{new Date(r.createdAt).toLocaleDateString('zh-CN')}</td>
<td style={{ padding: '12px 16px' }}>
<Link to={`/reports/${r.id}`} style={{ color: '#4F6EF7', fontWeight: 500, fontSize: 13 }}>
{r.status === 'PendingDoctor' ? '审核 →' : '查看 →'}
</Link>
</td>
</tr>
);
})}
</tbody>
</table>
</div>
)}
</div>
);
}