diff --git a/src/components/exam/ExamDeliveryPanel.tsx b/src/components/exam/ExamDeliveryPanel.tsx index 133e4e7..b6dff45 100644 --- a/src/components/exam/ExamDeliveryPanel.tsx +++ b/src/components/exam/ExamDeliveryPanel.tsx @@ -1,39 +1,110 @@ +import { useEffect, useState } from 'react'; import type { ExamClient } from '../../data/mockData'; +import { getReportSendQRcode } from '../../api'; import { Button, Input } from '../ui'; -export const ExamDeliveryPanel = ({ client }: { client: ExamClient }) => ( -
-
-
报告寄送
-
-
- 收件人姓名 - +export const ExamDeliveryPanel = ({ client }: { client: ExamClient }) => { + const [viewMode, setViewMode] = useState<'form' | 'image'>('form'); + const [qrcodeUrl, setQrcodeUrl] = useState(null); + const [qrcodeLoading, setQrcodeLoading] = useState(false); + + useEffect(() => { + if (viewMode === 'image' && !qrcodeUrl && !qrcodeLoading) { + setQrcodeLoading(true); + // 使用 client.id 作为 appointment_id,如果接口需要其他格式,可以调整 + getReportSendQRcode({ appointment_id: client.id }) + .then((res) => { + if (res.Status === 200 && res.Data?.qrcode_url) { + setQrcodeUrl(res.Data.qrcode_url); + } + }) + .catch((err) => { + console.error('获取报告寄送二维码失败', err); + }) + .finally(() => { + setQrcodeLoading(false); + }); + } + }, [viewMode, client.id, qrcodeUrl, qrcodeLoading]); + + return ( +
+
+
+
报告寄送
+
+ + +
-
- 联系电话 - -
-
- 寄送地址 - -
-
-
-
备注说明
-