汇总保存逻辑修改
This commit is contained in:
parent
c00c53a596
commit
49844130b6
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
<div class="summary-header">
|
||||
<div class="title-with-button">
|
||||
<h3>体检汇总</h3>
|
||||
<el-button
|
||||
<!-- <el-button
|
||||
type="success"
|
||||
circle
|
||||
size="small"
|
||||
@ -11,7 +11,7 @@
|
||||
class="refresh-button"
|
||||
>
|
||||
<el-icon><Refresh /></el-icon>
|
||||
</el-button>
|
||||
</el-button> -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -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 })
|
||||
|
||||
Loading…
Reference in New Issue
Block a user