优化手机号显示

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 { import type {
CustomerAppointmentInfo, CustomerAppointmentInfo,
@@ -8,7 +8,6 @@ import type {
} from '../../api'; } from '../../api';
import { editCustomerDetail } from '../../api'; import { editCustomerDetail } from '../../api';
import type { ExamClient } from '../../data/mockData'; import type { ExamClient } from '../../data/mockData';
import { Button, Input } from '../ui';
interface ExamDetailPanelProps { interface ExamDetailPanelProps {
client: ExamClient; client: ExamClient;
@@ -49,15 +48,43 @@ export const ExamDetailPanel = ({
const [editLoading, setEditLoading] = useState(false); const [editLoading, setEditLoading] = useState(false);
const [editMessage, setEditMessage] = useState<string | null>(null); 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 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 familyDoctor = loading
const bookingTime = appointmentInfo?.appointment_time || (client['bookingTime' as keyof ExamClient] || '—'); ? ''
const signTime = appointmentInfo?.sign_in_time || (client['signTime' as keyof ExamClient] || '—'); : (customerInfo?.family_doctor_name || (client['familyDoctor' as keyof ExamClient] as string | undefined) || '—');
const addonSummary = const groupTag = loading
addItemInfoList && addItemInfoList.length > 0 ? ''
: (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('、') ? addItemInfoList.map((i) => `${i.dept_name ?? ''} ${i.combination_name ?? ''}`.trim()).join('、')
: client['addonSummary' as keyof ExamClient] || '—'; : client['addonSummary' as keyof ExamClient] || '—');
const handleSavePhone = async () => { const handleSavePhone = async () => {
if (!phone || phone.trim() === '' || phone === '—') { if (!phone || phone.trim() === '' || phone === '—') {
@@ -174,7 +201,7 @@ export const ExamDetailPanel = ({
</div> </div>
</div> </div>
<div> <div>
<span className='text-gray-900'>{customerInfo?.id_no || '—'}</span> <span className='text-gray-900'>{loading ? '' : (customerInfo?.id_no || '—')}</span>
</div> </div>
<div className='flex items-center'> <div className='flex items-center'>
<span></span> <span></span>