diff --git a/src/views/Department-entry/All.vue b/src/views/Department-entry/All.vue index 1c55314..66b9b25 100644 --- a/src/views/Department-entry/All.vue +++ b/src/views/Department-entry/All.vue @@ -394,65 +394,6 @@ const loadPatientData = async (patient) => { } } -// 修改检查类型变化的监听器 -watch( - () => props.examType, - async (newType, oldType) => { - console.log(`[All.vue] examType 变化: 从 ${oldType} 到 ${newType}`) - - if (!newType) return - - // 如果新旧类型相同,不执行任何操作 - if (newType === oldType) return - - // 无论如何都清空当前数据 - mediaFiles.value = [] - imageUrls.value = [] - - if (reportData.value.medicalSn) { - // 显示加载中 - const loading = ElLoading.service({ - lock: true, - text: '加载中...', - background: 'rgba(255, 255, 255, 0.7)' - }) - - try { - console.log(`[All.vue] 重新获取 ${newType} 类型的影像数据`) - // 重新获取影像数据 - await getImageUrls() - console.log(`[All.vue] 获取到 ${mediaFiles.value.length} 个媒体文件`) - } finally { - loading.close() - } - } - }, - { immediate: false } -) - -// 修改患者变化的监听器 -watch( - () => props.patient, - (newPatient) => { - console.log(`[All.vue] 患者变化: ${newPatient?.pname}, ID: ${newPatient?.id}`) - - if (newPatient) { - // 保存当前检查类型 - const currentExamType = props.examType - console.log(`[All.vue] 当前检查类型: ${currentExamType}`) - - loadPatientData(newPatient).then(() => { - // 如果有检查类型,确保加载对应类型的影像数据 - if (currentExamType && reportData.value.medicalSn) { - console.log(`[All.vue] 加载 ${currentExamType} 类型的影像数据`) - getImageUrls() - } - }) - } - }, - { immediate: true } -) - // 修改组件挂载时的逻辑 onMounted(async () => { if (props.patient) { @@ -473,6 +414,41 @@ onMounted(async () => { } }) +// 添加 watch 监听 examType 变化 +watch( + () => props.examType, + async (newExamType, oldExamType) => { + if (newExamType !== oldExamType && props.patient && reportData.value.medicalSn) { + // 清空当前数据 + mediaFiles.value = [] + imageUrls.value = [] + + // 重新获取影像数据 + await getImageUrls() + } + } +) + +// 添加 watch 监听 patient 变化 +watch( + () => props.patient, + async (newPatient, oldPatient) => { + if (newPatient && (!oldPatient || newPatient.id !== oldPatient.id)) { + // 清空当前数据 + mediaFiles.value = [] + imageUrls.value = [] + + // 加载患者数据和检查项目 + await loadPatientData(newPatient) + + // 在加载完患者数据后,手动获取影像数据 + if (props.examType && reportData.value.medicalSn) { + await getImageUrls() + } + } + } +) + // 添加获取检查类型标题的方法 const getExamTypeTitle = () => { const typeMap = { diff --git a/src/views/Department-entry/Medical-examination-vehicle.vue b/src/views/Department-entry/Medical-examination-vehicle.vue index 5f6af09..bcc5bd0 100644 --- a/src/views/Department-entry/Medical-examination-vehicle.vue +++ b/src/views/Department-entry/Medical-examination-vehicle.vue @@ -12,6 +12,7 @@ size="small" @click="handleSync" :icon="RefreshRight" + :disabled="isExamCompleted" > 同步 @@ -279,9 +280,28 @@