优化手机号显示

This commit is contained in:
xianyi
2025-12-23 11:50:49 +08:00
parent 8c07b32f0d
commit ed6f52936a

View File

@@ -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<string | null>(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 = ({
</div>
</div>
<div>
<span className='text-gray-900'>{customerInfo?.id_no || '—'}</span>
<span className='text-gray-900'>{loading ? '' : (customerInfo?.id_no || '—')}</span>
</div>
<div className='flex items-center'>
<span></span>