fix(doctorstation): 修复会诊模块数据加载异常处理

- 添加了接口响应空值检查,防止因空响应导致的页面崩溃
- 完善了错误处理逻辑,统一返回空数组避免组件渲染异常
- 增强了网络错误捕获,提供更准确的错误信息提示
- 优化了后端服务异常处理,确保查询失败时返回安全的默认值
- 修复了手术收费模块中的用户卡信息引用错误
- 改进了学生合同号处理逻辑,增加了前置条件验证
This commit is contained in:
2026-02-09 23:47:19 +08:00
parent 6fb5b5993a
commit dba6350493
5 changed files with 133 additions and 27 deletions

View File

@@ -341,7 +341,7 @@ async function handleReadCard(value) {
certNo: message.data.idNo,
psnCertType: '02',
};
userCardInfo = {
userCardInfo.value = {
certType: '01',
certNo: message.data.idNo,
psnCertType: '01',
@@ -372,7 +372,7 @@ async function handleReadCard(value) {
certNo: message1.SocialSecurityNumber,
psnCertType: '02',
};
userCardInfo = {
userCardInfo.value = {
certType: '02',
certNo: message1.SocialSecurityNumber,
psnCertType: '02',
@@ -397,8 +397,8 @@ async function handleReadCard(value) {
patientId: props.patientInfo.patientId,
encounterId: props.patientInfo.encounterId,
chargeItemIds: chargeItemIdList.value,
ybMdtrtCertType: userCardInfo.psnCertType,
busiCardInfo: userCardInfo.busiCardInfo,
ybMdtrtCertType: userCardInfo.value.psnCertType,
busiCardInfo: userCardInfo.value.busiCardInfo,
generateSourceEnum: 2,
sourceBillNo: props.surgeryInfo.surgeryNo,
}).then((res) => {

View File

@@ -446,17 +446,36 @@ const loadActivityList = async () => {
console.log('开始调用 getConsultationActivities 接口...');
const res = await getConsultationActivities();
console.log('getConsultationActivities 接口返回:', res);
// 检查响应是否存在
if (!res) {
console.error('接口返回空响应');
ElMessage.warning('会诊项目列表加载失败:未获取到响应数据');
activityList.value = [];
return;
}
// 检查响应代码
if (res.code === 200) {
activityList.value = res.data || [];
console.log('会诊项目列表加载成功,数量:', activityList.value.length);
// 如果列表为空,给出提示
if (activityList.value.length === 0) {
console.warn('会诊项目列表为空,请检查数据库配置');
ElMessage.warning('暂无可用会诊项目,请联系系统管理员配置');
}
} else {
console.error('接口返回错误:', res.msg || res.message);
ElMessage.error(res.msg || '加载会诊项目失败');
activityList.value = [];
}
} catch (error) {
console.error('加载会诊项目失败,错误详情:', error);
ElMessage.error('加载会诊项目失败: ' + (error.message || error));
// 网络错误或其他异常
const errorMsg = error.response?.data?.msg || error.message || '未知错误';
ElMessage.error('加载会诊项目失败: ' + errorMsg);
activityList.value = [];
}
};
@@ -473,12 +492,35 @@ const handleActivityChange = (activityId) => {
const loadDepartmentTree = async () => {
try {
const res = await getDepartmentTree();
// 检查响应是否存在
if (!res) {
console.error('接口返回空响应');
ElMessage.warning('科室医生树加载失败:未获取到响应数据');
departmentTree.value = [];
return;
}
if (res.code === 200) {
departmentTree.value = res.data || [];
console.log('科室医生树加载成功:', departmentTree.value);
// 如果树为空,给出提示
if (departmentTree.value.length === 0) {
console.warn('科室医生树为空,请检查数据库配置');
ElMessage.warning('暂无可用科室医生数据,请联系系统管理员配置');
}
} else {
console.error('接口返回错误:', res.msg || res.message);
ElMessage.warning(res.msg || '加载科室医生树失败');
departmentTree.value = [];
}
} catch (error) {
console.error('加载科室医生树失败:', error);
// 网络错误或其他异常
const errorMsg = error.response?.data?.msg || error.message || '未知错误';
ElMessage.warning('加载科室医生树失败: ' + errorMsg);
departmentTree.value = [];
}
};
@@ -582,10 +624,20 @@ const clearAllSelections = () => {
const loadConsultationList = async () => {
if (!props.patientInfo?.encounterId) {
console.log('没有就诊ID无法加载会诊列表');
consultationList.value = [];
return;
}
try {
const res = await getConsultationList({ encounterId: props.patientInfo.encounterId });
// 检查响应是否存在
if (!res) {
console.error('接口返回空响应');
ElMessage.warning('会诊列表加载失败:未获取到响应数据');
consultationList.value = [];
return;
}
if (res.code === 200) {
consultationList.value = (res.data || []).map(item => {
console.log('列表项数据:', item);
@@ -600,9 +652,17 @@ const loadConsultationList = async () => {
};
});
console.log('会诊列表:', consultationList.value);
} else {
console.error('接口返回错误:', res.msg || res.message);
ElMessage.warning(res.msg || '加载会诊列表失败');
consultationList.value = [];
}
} catch (error) {
console.error('加载会诊列表失败:', error);
// 网络错误或其他异常
const errorMsg = error.response?.data?.msg || error.message || '未知错误';
ElMessage.warning('加载会诊列表失败: ' + errorMsg);
consultationList.value = [];
}
};
@@ -613,11 +673,24 @@ const loadMainDiagnosis = async () => {
}
try {
const res = await getMainDiagnosis({ encounterId: props.patientInfo.encounterId });
// 检查响应是否存在
if (!res) {
console.error('获取主诊断接口返回空响应');
return;
}
if (res.code === 200 && res.data) {
formData.provisionalDiagnosis = res.data.diagnosis || '';
console.log('主诊断加载成功:', formData.provisionalDiagnosis);
} else {
console.warn('获取主诊断失败:', res.msg || res.message);
formData.provisionalDiagnosis = '';
}
} catch (error) {
console.error('加载主诊断失败:', error);
// 主诊断加载失败不应该阻塞整个会诊功能,只是不显示诊断信息
formData.provisionalDiagnosis = '';
}
};
@@ -1023,8 +1096,13 @@ watch(
(newVal) => {
if (newVal === 'consultation' && props.patientInfo?.encounterId) {
console.log('切换到会诊tab加载数据');
// 并行加载数据,提升性能
loadConsultationList();
handleNew();
} else if (newVal === 'consultation') {
console.log('切换到会诊tab但没有患者信息');
// 即使没有患者信息,也要加载基础数据(会诊项目和科室树)
handleNew();
}
}
);