From ed6f52936a41f87f46ef685a2ae0ff97c398e86b Mon Sep 17 00:00:00 2001 From: xianyi Date: Tue, 23 Dec 2025 11:50:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=89=8B=E6=9C=BA=E5=8F=B7?= =?UTF-8?q?=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/exam/ExamDetailPanel.tsx | 47 +++++++++++++++++++------ 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/src/components/exam/ExamDetailPanel.tsx b/src/components/exam/ExamDetailPanel.tsx index bdc0a30..edb0de4 100644 --- a/src/components/exam/ExamDetailPanel.tsx +++ b/src/components/exam/ExamDetailPanel.tsx @@ -1,4 +1,4 @@ -import { useMemo, useState } from 'react'; +import { useEffect, useMemo, useState } from 'react'; import type { CustomerAppointmentInfo, @@ -8,7 +8,6 @@ import type { } from '../../api'; import { editCustomerDetail } from '../../api'; import type { ExamClient } from '../../data/mockData'; -import { Button, Input } from '../ui'; interface ExamDetailPanelProps { client: ExamClient; @@ -49,15 +48,43 @@ export const ExamDetailPanel = ({ const [editLoading, setEditLoading] = useState(false); const [editMessage, setEditMessage] = useState(null); + // 当接口返回 customerInfo 后,更新 phone 和 maritalCode + useEffect(() => { + if (customerInfo && !phoneEditing) { + const newPhone = customerInfo.phone || '—'; + setPhone(newPhone); + } + }, [customerInfo, phoneEditing]); + + useEffect(() => { + if (customerInfo && !maritalEditing) { + const newMaritalText = customerInfo.patient_marital_status_name; + if (newMaritalText && newMaritalText !== '—') { + const newMaritalCode = getMaritalCodeFromText(newMaritalText); + setMaritalCode(newMaritalCode); + } + } + }, [customerInfo, maritalEditing]); + const customerChannel = client.customerType === '团客' ? '团体客户' : '散客客户'; - const familyDoctor = customerInfo?.family_doctor_name || (client['familyDoctor' as keyof ExamClient] as string | undefined) || '—'; - const groupTag = client['groupTag' as keyof ExamClient] || (client.customerType === '团客' ? '团检' : '—'); - const bookingTime = appointmentInfo?.appointment_time || (client['bookingTime' as keyof ExamClient] || '—'); - const signTime = appointmentInfo?.sign_in_time || (client['signTime' as keyof ExamClient] || '—'); - const addonSummary = - addItemInfoList && addItemInfoList.length > 0 + // 等待接口返回后再显示,如果接口已返回但数据为空才显示 '—' + const familyDoctor = loading + ? '' + : (customerInfo?.family_doctor_name || (client['familyDoctor' as keyof ExamClient] as string | undefined) || '—'); + const groupTag = loading + ? '' + : (client['groupTag' as keyof ExamClient] || (client.customerType === '团客' ? '团检' : '—')); + const bookingTime = loading + ? '' + : (appointmentInfo?.appointment_time || (client['bookingTime' as keyof ExamClient] || '—')); + const signTime = loading + ? '' + : (appointmentInfo?.sign_in_time || (client['signTime' as keyof ExamClient] || '—')); + const addonSummary = loading + ? '' + : (addItemInfoList && addItemInfoList.length > 0 ? addItemInfoList.map((i) => `${i.dept_name ?? ''} ${i.combination_name ?? ''}`.trim()).join('、') - : client['addonSummary' as keyof ExamClient] || '—'; + : client['addonSummary' as keyof ExamClient] || '—'); const handleSavePhone = async () => { if (!phone || phone.trim() === '' || phone === '—') { @@ -174,7 +201,7 @@ export const ExamDetailPanel = ({
- 证件号:{customerInfo?.id_no || '—'} + 证件号:{loading ? '' : (customerInfo?.id_no || '—')}
手机号: