diff --git a/apps/web/src/pages/health/AppointmentList.tsx b/apps/web/src/pages/health/AppointmentList.tsx index c4c9a6b..c92fe9e 100644 --- a/apps/web/src/pages/health/AppointmentList.tsx +++ b/apps/web/src/pages/health/AppointmentList.tsx @@ -22,8 +22,6 @@ import { } from '@ant-design/icons'; import type { Dayjs } from 'dayjs'; import { appointmentApi, type Appointment, type CreateAppointmentReq } from '../../api/health/appointments'; -import { patientApi } from '../../api/health/patients'; -import { doctorApi } from '../../api/health/doctors'; import { StatusTag } from './components/StatusTag'; import { PatientSelect } from './components/PatientSelect'; import { DoctorSelect } from './components/DoctorSelect'; @@ -87,7 +85,6 @@ export default function AppointmentList() { // 患者选择状态(受控组件,不挂在 Form.Item 上) const [selectedPatientId, setSelectedPatientId] = useState(undefined); const [selectedDoctorId, setSelectedDoctorId] = useState(undefined); - const [nameCache, setNameCache] = useState>({}); // 排班校验 const [scheduleHint, setScheduleHint] = useState(null); @@ -103,27 +100,7 @@ export default function AppointmentList() { status: statusFilter || undefined, date: dateFilter ? dateFilter.format('YYYY-MM-DD') : undefined, }); - const items = result.data; - // 批量解析患者和医生名称(分别调用对应 API) - const missingPatientIds = new Set(); - const missingDoctorIds = new Set(); - items.forEach((a) => { - if (a.patient_id && !nameCache[a.patient_id]) missingPatientIds.add(a.patient_id); - if (a.doctor_id && !nameCache[a.doctor_id]) missingDoctorIds.add(a.doctor_id); - }); - const newCache: Record = {}; - await Promise.allSettled([ - ...Array.from(missingPatientIds).map(async (id) => { - try { const p = await patientApi.get(id); newCache[id] = p.name; } catch { /* skip */ } - }), - ...Array.from(missingDoctorIds).map(async (id) => { - try { const d = await doctorApi.get(id); newCache[id] = d.name; } catch { /* skip */ } - }), - ]); - if (Object.keys(newCache).length > 0) { - setNameCache((prev) => ({ ...prev, ...newCache })); - } - setData(items); + setData(result.data); setTotal(result.total); } catch { message.error('加载预约列表失败'); @@ -274,16 +251,15 @@ export default function AppointmentList() { key: 'patient_name', width: 100, render: (_: unknown, record: Appointment) => - record.patient_name ?? nameCache[record.patient_id] ?? record.patient_id.slice(0, 8), + record.patient_name ?? record.patient_id.slice(0, 8), }, { title: '医护', dataIndex: 'doctor_name', key: 'doctor_name', width: 100, - render: (_: unknown, record: Appointment) => { - return record.doctor_name || nameCache[record.doctor_id ?? ''] || record.doctor_id?.slice(0, 8) || '-'; - }, + render: (_: unknown, record: Appointment) => + record.doctor_name ?? record.doctor_id?.slice(0, 8) ?? '-', }, { title: '预约类型',