fix(doctorstation): 解决参数验证和数据获取问题

- 在前端api.js中添加encounterId参数验证,避免无效参数导致的错误
- 在后端服务层添加参数检查,当encounterId为空时返回空数据而非报错
- 修改控制器参数注解,将required设置为false以允许空值传递
- 优化住院办理流程中的错误处理和参数验证
- 改进检验申请单获取时的数据验证和错误提示
- 更新maven编译器插件版本并添加必要的模块参数
- 统一错误处理机制,提供更友好的用户提示信息
This commit is contained in:
2026-01-17 16:07:57 +08:00
parent 64c7db68e8
commit 982ee316f7
18 changed files with 267 additions and 64 deletions

View File

@@ -581,20 +581,35 @@ const getFilteredItems = (categoryKey) => {
function initData() {
console.log('检验组件初始化patientInfo:', props.patientInfo)
if (props.patientInfo) {
queryParams.encounterId = props.patientInfo.encounterId
// 确保 encounterId 存在且有效,优先使用 encounterId其次尝试 id最后尝试 patientId
queryParams.encounterId = props.patientInfo.encounterId || props.patientInfo.id || props.patientInfo.patientId
formData.patientName = props.patientInfo.patientName || ''
formData.cardNo = props.patientInfo.cardNo || ''
formData.departmentName = props.patientInfo.departmentName || ''
formData.doctorName = props.patientInfo.doctorName || ''
}
// 只有在存在 encounterId 时才调用接口
if (queryParams.encounterId) {
// 只有在存在有效的 encounterId 时才调用接口
if (queryParams.encounterId && queryParams.encounterId !== 'undefined' && queryParams.encounterId !== 'null' && queryParams.encounterId !== '') {
getInspectionList()
} else {
console.warn('缺少有效的就诊ID无法获取检验申请单列表')
inspectionList.value = []
total.value = 0
}
}
// 获取检验申请单列表
function getInspectionList() {
// 先检查是否有有效的encounterId
if (!queryParams.encounterId || queryParams.encounterId === 'undefined' || queryParams.encounterId === 'null') {
console.warn('缺少有效的就诊ID无法获取检验申请单列表')
inspectionList.value = []
total.value = 0
loading.value = false
return
}
loading.value = true
// 调用真实的API只传递 encounterId 参数
@@ -605,13 +620,23 @@ function getInspectionList() {
} else {
inspectionList.value = []
total.value = 0
ElMessage.error('获取检验申请单列表失败')
console.error('获取检验申请单列表失败:', res.message || res.msg)
ElMessage.error(res.message || res.msg || '获取检验申请单列表失败')
}
}).catch((error) => {
console.error('获取检验申请单列表异常:', error)
inspectionList.value = []
total.value = 0
ElMessage.error('获取检验申请单列表异常')
// 提供更友好的错误信息
let errorMessage = '获取检验申请单列表异常'
if (error.response) {
errorMessage += ` (${error.response.status}): ${error.response.data.message || error.response.statusText}`
} else if (error.request) {
errorMessage += ': 网络请求失败,请检查网络连接'
} else {
errorMessage += `: ${error.message}`
}
ElMessage.error(errorMessage)
}).finally(() => {
loading.value = false
})