import { useEffect, useState } from 'react'; import { Link } from 'react-router-dom'; import { api } from '../../services/api-client'; interface Patient { id: string; name: string; phone: string; gender: string; medicalHistory: string[]; stentDate: string; } export function PatientListPage() { const [patients, setPatients] = useState([]); const [search, setSearch] = useState(''); const [loading, setLoading] = useState(true); useEffect(() => { api.get('/api/patients') .then((r) => setPatients(r.data)) .catch(() => {}) .finally(() => setLoading(false)); }, []); const filtered = patients.filter((p) => !search || p.name.includes(search) || p.phone.includes(search) ); return (

患者管理

共 {patients.length} 位患者

setSearch(e.target.value)} placeholder="搜索姓名或手机号..." style={{ width: 280, padding: '10px 14px', border: '1.5px solid #E1E5ED', borderRadius: 10, fontSize: 13, marginBottom: 18, outline: 'none', boxSizing: 'border-box', transition: 'border-color 0.2s', }} onFocus={(e) => e.currentTarget.style.borderColor = '#4F6EF7'} onBlur={(e) => e.currentTarget.style.borderColor = '#E1E5ED'} /> {loading ?
加载中...
: (
{filtered.map((p) => ( ))} {filtered.length === 0 && ( )}
姓名 手机号 性别 病史 支架日期 操作
{p.name} {p.phone} {p.gender || '-'} {(p.medicalHistory || []).slice(0, 3).join('、') || '-'} {p.stentDate || '-'} 查看详情
暂无患者数据
)}
); }