汇总结果保存逻辑
This commit is contained in:
parent
151622972e
commit
301e4657f7
@ -146,6 +146,7 @@
|
||||
:patient="selectedPatient"
|
||||
:report-data="reportData"
|
||||
:conclusion-data="conclusionData"
|
||||
ref="summaryRef"
|
||||
/>
|
||||
|
||||
<!-- 特殊检查类型 -->
|
||||
@ -1693,6 +1694,11 @@ const handleSaveAllResults = async () => {
|
||||
// 重新加载数据以更新界面
|
||||
await refreshExamData()
|
||||
|
||||
// 如果汇总组件存在,调用其保存方法
|
||||
if (summaryRef.value) {
|
||||
await summaryRef.value.saveSummary()
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
ElMessage.error(`保存失败: ${error.message || '请检查数据是否完整'}`)
|
||||
}
|
||||
|
||||
@ -31,6 +31,7 @@
|
||||
<script setup>
|
||||
import { ref, onMounted, watch } from 'vue'
|
||||
import { PatientitemsApi } from '@/api/inspect/inspectpatientitems'
|
||||
import { PatientApi } from '@/api/inspect/inspectpatient'
|
||||
import { ElLoading, ElMessage } from 'element-plus'
|
||||
import { Refresh } from '@element-plus/icons-vue'
|
||||
|
||||
@ -49,6 +50,9 @@ const props = defineProps({
|
||||
}
|
||||
})
|
||||
|
||||
// 添加emit以便与父组件通信
|
||||
const emit = defineEmits(['save-summary'])
|
||||
|
||||
// 汇总数据
|
||||
const summaryData = ref({
|
||||
general: { summary: '' },
|
||||
@ -307,6 +311,52 @@ const loadPatientItems = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 保存汇总内容到PatientApi的summaryResult字段
|
||||
const saveSummary = async () => {
|
||||
if (!props.patient || !props.patient.medicalSn) {
|
||||
ElMessage.warning('患者信息不完整,无法保存汇总数据')
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
saving.value = true
|
||||
|
||||
// 准备保存的数据
|
||||
const saveData = {
|
||||
medicalSn: props.patient.medicalSn,
|
||||
summaryResult: editableSummary.value
|
||||
}
|
||||
|
||||
console.log('保存汇总数据:', saveData)
|
||||
|
||||
// 调用API保存数据
|
||||
const response = await PatientApi.updateSummaryResult(saveData)
|
||||
|
||||
if (response && response.code === 200) {
|
||||
ElMessage.success('体检汇总保存成功')
|
||||
|
||||
// 触发父组件的保存方法,实现与主页面保存按钮的联动
|
||||
emit('save-summary', editableSummary.value)
|
||||
|
||||
// 尝试调用父窗口的保存方法
|
||||
if (window.parent && typeof window.parent.handleSaveAllResults === 'function') {
|
||||
try {
|
||||
window.parent.handleSaveAllResults()
|
||||
} catch (err) {
|
||||
console.log('调用父窗口保存方法失败:', err)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ElMessage.error('保存失败: ' + (response?.message || '未知错误'))
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('保存汇总数据失败:', error)
|
||||
ElMessage.error('保存汇总数据失败: ' + error.message)
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 移除自动加载的监听器和onMounted钩子
|
||||
// 只有点击刷新按钮时才会调用loadPatientItems函数
|
||||
</script>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user