import { useEffect, useState } from 'react'; import type { ExamClient, ExamModalTab } from '../../data/mockData'; import type { CustomerAppointmentInfo, CustomerExamAddItem, CustomerInfo, PhysicalExamProgressItem } from '../../api'; import { getCustomerDetail, getPhysicalExamProgress } from '../../api'; import { ExamDetailPanel } from './ExamDetailPanel'; import { ExamAddonPanel } from './ExamAddonPanel'; import { ExamPrintPanel } from './ExamPrintPanel'; import { ExamDeliveryPanel } from './ExamDeliveryPanel'; import { ExamSignPanel } from './ExamSignPanel'; interface ExamModalProps { client: ExamClient; tab: ExamModalTab; onTabChange: (key: ExamModalTab) => void; onClose: () => void; } export const ExamModal = ({ client, tab, onTabChange, onClose }: ExamModalProps) => { const tabs: { key: ExamModalTab; label: string }[] = [ { key: 'detail', label: '详情' }, { key: 'sign', label: '签到' }, { key: 'addon', label: '加项' }, // { key: 'print', label: '打印导检单' }, { key: 'delivery', label: '报告寄送' }, ]; const signDone = ((client as any).is_sign_in === 1) || client.signStatus === '已签到' || client.checkedItems.includes('签到'); const addonDone = (client.addonCount || 0) > 0; const printDone = !!client.guidePrinted; const deliveryDone = !!client.deliveryDone; const tabDone: Record = { detail: false, sign: signDone, addon: addonDone, print: printDone, delivery: deliveryDone, }; const handleDoubleClick = (e: React.MouseEvent) => { e.preventDefault(); e.stopPropagation(); }; const handleTouchStart = (e: React.TouchEvent) => { if (e.touches.length > 1) { e.preventDefault(); } }; const [detailLoading, setDetailLoading] = useState(false); const [customerInfo, setCustomerInfo] = useState(null); const [appointmentInfo, setAppointmentInfo] = useState(null); const [addItemInfoList, setAddItemInfoList] = useState(null); const [progressList, setProgressList] = useState(null); const [signBusy, setSignBusy] = useState(false); useEffect(() => { const physical_exam_id = Number(client.id); if (!physical_exam_id) return; setDetailLoading(true); Promise.all([ getCustomerDetail({ physical_exam_id }), getPhysicalExamProgress({ physical_exam_id }), ]) .then(([detailRes, progressRes]) => { setCustomerInfo(detailRes.Data?.customerInfo ?? null); setAppointmentInfo(detailRes.Data?.appointmentInfo ?? null); setAddItemInfoList(detailRes.Data?.addItemInfoList ?? null); setProgressList(progressRes.Data ?? null); }) .catch((err) => { console.error('获取客户详情/进度失败', err); }) .finally(() => setDetailLoading(false)); }, [client.id]); const refetchDetail = () => { const physical_exam_id = Number(client.id); if (!physical_exam_id) return; getCustomerDetail({ physical_exam_id }).then((detailRes) => { setCustomerInfo(detailRes.Data?.customerInfo ?? null); setAppointmentInfo(detailRes.Data?.appointmentInfo ?? null); setAddItemInfoList(detailRes.Data?.addItemInfoList ?? null); }); }; return (
{client.name} VIP 体检号:{client.id}
{tabs.map((t) => { const isActive = tab === t.key; const isDone = tabDone[t.key]; return ( ); })}
{tab === 'detail' && ( )} {tab === 'sign' && } {tab === 'addon' && onTabChange('sign')} />} {tab === 'print' && } {tab === 'delivery' && }
); };