From 49844130b6bc9f3dbaf85b96ed2b33777e4de76a Mon Sep 17 00:00:00 2001 From: Euni4U <958079825@qq.com> Date: Tue, 18 Mar 2025 17:03:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B1=87=E6=80=BB=E4=BF=9D=E5=AD=98=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Medical-examination-vehicle.vue | 31 +++++++++---------- src/views/Department-entry/summary.vue | 31 ++++++++++--------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/views/Department-entry/Medical-examination-vehicle.vue b/src/views/Department-entry/Medical-examination-vehicle.vue index a5538c0..b10f7d1 100644 --- a/src/views/Department-entry/Medical-examination-vehicle.vue +++ b/src/views/Department-entry/Medical-examination-vehicle.vue @@ -1691,32 +1691,31 @@ const handleSaveAllResults = async () => { } } + // 最后执行汇总保存 + const result = await handleSummarySave() + if (!result) return + ElMessage.success('所有检查结果保存成功') // 重新加载数据以更新界面 await refreshExamData() - - // 如果汇总组件存在,调用其保存方法 - if (summaryRef.value) { - await summaryRef.value.saveSummary() - } - + } catch (error) { ElMessage.error(`保存失败: ${error.message || '请检查数据是否完整'}`) } - // 汇总标签页特殊处理 - const result = await handleSummarySave() - if (!result) return } -// 添加汇总保存方法 +// 修改汇总保存方法 const handleSummarySave = async () => { - // 直接调用汇总组件的保存方法 - if (summaryRef.value) { - await summaryRef.value.saveSummary() - ElMessage.success('汇总数据保存成功') - } else { - throw new Error('未找到汇总组件') + try { + if (summaryRef.value) { + await summaryRef.value.saveSummary() + return true + } + return false + } catch (error) { + ElMessage.error('汇总保存失败: ' + error.message) + return false } } diff --git a/src/views/Department-entry/summary.vue b/src/views/Department-entry/summary.vue index 43637b2..d06fb2d 100644 --- a/src/views/Department-entry/summary.vue +++ b/src/views/Department-entry/summary.vue @@ -3,7 +3,7 @@

体检汇总

- - + -->
@@ -72,9 +72,9 @@ const isReadOnly = ref(false) // 检查患者状态 const checkPatientStatus = () => { - if (props.patient && props.patient.status) { - // 假设状态为2表示已检查完成 - isReadOnly.value = props.patient.status === 2 + if (props.patient?.status) { + // 同时处理字符串和数字类型的状态值 + isReadOnly.value = String(props.patient.status) === '1' console.log('患者状态:', props.patient.status, '只读模式:', isReadOnly.value) } } @@ -303,14 +303,7 @@ const loadPatientItems = async () => { const formattedText = formatSummaryData() console.log('格式化后的文本:', formattedText) editableSummary.value = formattedText - loading.close() - - if (formattedText) { - ElMessage.success('体检汇总数据已刷新') - } else { - ElMessage.warning('未找到可用的体检汇总数据') - } } catch (error) { console.error('加载汇总数据失败:', error) ElMessage.error('加载汇总数据失败: ' + error.message) @@ -321,6 +314,10 @@ const loadPatientItems = async () => { const saving = ref(false) // 保存汇总内容到PatientApi的summaryResult字段 const saveSummary = async () => { + if (isReadOnly.value) { + ElMessage.warning('已检查患者不可修改汇总内容') + return false + } if (!editableSummary.value) { ElMessage.warning('体检汇总内容为空,请检查汇总内容') return false @@ -400,11 +397,15 @@ onMounted(() => { // 监听患者信息变化 watch(() => props.patient, (newVal) => { - if (newVal && newVal.medicalSn) { - loadPatientItems() + if (newVal) { + // 立即检查状态 checkPatientStatus() + // 如果medicalSn变化则重新加载数据 + if (newVal.medicalSn) { + loadPatientItems() + } } -}, { deep: true }) +}, { deep: true, immediate: true }) // 暴露保存汇总方法给父组件调用 defineExpose({ saveSummary })