修改逻辑
This commit is contained in:
parent
caeba8c1c3
commit
c00c53a596
@ -103,5 +103,9 @@ export const PatientApi = {
|
||||
//获取体检报告
|
||||
getReportAll: async (medicalSn: string) => {
|
||||
return await request.get({ url: `/inspect/patient/getReportAll?medicalSn=` + medicalSn })
|
||||
},
|
||||
// 保存汇总结果
|
||||
updatemedicalSn: async (data: PatientVO) => {
|
||||
return await request.put({ url: `/inspect/patient/updatesummary`, data })
|
||||
}
|
||||
}
|
||||
|
@ -221,7 +221,7 @@ const openPdfInNewTab = (url) => {
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="${url}"></iframe>
|
||||
<iframe src="${url}+#toolbar=0&navpanes=0&view=Fit"></iframe>
|
||||
</body>
|
||||
</html>
|
||||
`)
|
||||
|
@ -405,7 +405,7 @@ const examTabs = ref([
|
||||
])
|
||||
|
||||
const currentTab = ref('general')
|
||||
|
||||
const summaryRef = ref(null)
|
||||
// 检查结果数据
|
||||
const examItems = ref({})
|
||||
|
||||
@ -1551,9 +1551,11 @@ const validateAllResults = () => {
|
||||
|
||||
// 修改统一保存方法,更新检查医生和检查日期,同时更新患者状态和体检日期
|
||||
const handleSaveAllResults = async () => {
|
||||
|
||||
|
||||
if (!checkEditPermission()) return
|
||||
|
||||
// 验证所有标签页的内容
|
||||
// 验证所有标签页的内容(不包含汇总页)
|
||||
if (!validateAllResults()) return
|
||||
|
||||
// 检查是否选择了医生
|
||||
@ -1702,6 +1704,20 @@ const handleSaveAllResults = async () => {
|
||||
} 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('未找到汇总组件')
|
||||
}
|
||||
}
|
||||
|
||||
// 修改 refreshExamData 函数,确保正确更新检查状态和医生信息
|
||||
|
@ -3,10 +3,10 @@
|
||||
<div class="summary-header">
|
||||
<div class="title-with-button">
|
||||
<h3>体检汇总</h3>
|
||||
<el-button
|
||||
type="success"
|
||||
circle
|
||||
size="small"
|
||||
<el-button
|
||||
type="success"
|
||||
circle
|
||||
size="small"
|
||||
@click="loadPatientItems"
|
||||
class="refresh-button"
|
||||
>
|
||||
@ -14,14 +14,15 @@
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="summary-content">
|
||||
<!-- 始终显示文本框,即使没有数据 -->
|
||||
<div class="summary-textarea-container">
|
||||
<textarea
|
||||
class="summary-textarea"
|
||||
v-model="editableSummary"
|
||||
<textarea
|
||||
class="summary-textarea"
|
||||
v-model="editableSummary"
|
||||
placeholder="请输入体检汇总内容"
|
||||
:readonly="isReadOnly"
|
||||
></textarea>
|
||||
</div>
|
||||
</div>
|
||||
@ -66,71 +67,79 @@ const summaryData = ref({
|
||||
// 可编辑的汇总文本
|
||||
const editableSummary = ref('')
|
||||
|
||||
// 添加患者状态检查
|
||||
const isReadOnly = ref(false)
|
||||
|
||||
// 检查患者状态
|
||||
const checkPatientStatus = () => {
|
||||
if (props.patient && props.patient.status) {
|
||||
// 假设状态为2表示已检查完成
|
||||
isReadOnly.value = props.patient.status === 2
|
||||
console.log('患者状态:', props.patient.status, '只读模式:', isReadOnly.value)
|
||||
}
|
||||
}
|
||||
|
||||
// 格式化汇总数据为文本
|
||||
const formatSummaryData = () => {
|
||||
let result = '';
|
||||
|
||||
let result = ''
|
||||
|
||||
// 一般检查
|
||||
if (summaryData.value.general?.summary) {
|
||||
result += '【一般检查】\n' + summaryData.value.general.summary + '\n\n';
|
||||
result += '【一般检查】\n' + summaryData.value.general.summary + '\n\n'
|
||||
}
|
||||
|
||||
|
||||
// 超声检查
|
||||
if (summaryData.value.ultrasound?.finding || summaryData.value.ultrasound?.diagnosis) {
|
||||
result += '【超声】\n';
|
||||
result += '【超声】\n'
|
||||
if (summaryData.value.ultrasound.finding) {
|
||||
result += '检查所见:' + summaryData.value.ultrasound.finding + '\n';
|
||||
result += '检查所见:' + summaryData.value.ultrasound.finding + '\n'
|
||||
}
|
||||
if (summaryData.value.ultrasound.diagnosis) {
|
||||
result += '检查结果:' + summaryData.value.ultrasound.diagnosis + '\n';
|
||||
result += '检查结果:' + summaryData.value.ultrasound.diagnosis + '\n'
|
||||
}
|
||||
result += '\n';
|
||||
result += '\n'
|
||||
}
|
||||
|
||||
|
||||
// 心电图检查
|
||||
if (summaryData.value.ecg?.finding || summaryData.value.ecg?.diagnosis) {
|
||||
result += '【心电图】\n';
|
||||
result += '【心电图】\n'
|
||||
if (summaryData.value.ecg.finding) {
|
||||
result += '检查所见:' + summaryData.value.ecg.finding + '\n';
|
||||
result += '检查所见:' + summaryData.value.ecg.finding + '\n'
|
||||
}
|
||||
if (summaryData.value.ecg.diagnosis) {
|
||||
result += '检查结果:' + summaryData.value.ecg.diagnosis + '\n';
|
||||
result += '检查结果:' + summaryData.value.ecg.diagnosis + '\n'
|
||||
}
|
||||
result += '\n';
|
||||
result += '\n'
|
||||
}
|
||||
|
||||
|
||||
// 血常规
|
||||
if (summaryData.value.blood?.summary) {
|
||||
result += '【血常规】\n' + summaryData.value.blood.summary + '\n\n';
|
||||
result += '【血常规】\n' + summaryData.value.blood.summary + '\n\n'
|
||||
}
|
||||
|
||||
|
||||
// 尿常规
|
||||
if (summaryData.value.urine?.summary) {
|
||||
result += '【尿常规】\n' + summaryData.value.urine.summary + '\n\n';
|
||||
result += '【尿常规】\n' + summaryData.value.urine.summary + '\n\n'
|
||||
}
|
||||
|
||||
|
||||
// 生化
|
||||
if (summaryData.value.biochemical?.summary) {
|
||||
result += '【生化】\n' + summaryData.value.biochemical.summary + '\n\n';
|
||||
result += '【生化】\n' + summaryData.value.biochemical.summary + '\n\n'
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// 从DOM中获取各个标签页的数据
|
||||
const getDataFromDOM = () => {
|
||||
console.log('尝试从DOM中获取数据...')
|
||||
|
||||
|
||||
try {
|
||||
const parentDoc = window.parent ? window.parent.document : document
|
||||
|
||||
|
||||
// 更新选择器以匹配体检车页面的结构
|
||||
const selectors = {
|
||||
general: [
|
||||
'[data-tab="general"] .summary-textarea',
|
||||
'#体检小结',
|
||||
'[placeholder*="体检小结"]'
|
||||
],
|
||||
general: ['[data-tab="general"] .summary-textarea', '#体检小结', '[placeholder*="体检小结"]'],
|
||||
ultrasoundFinding: [
|
||||
'[data-tab="ultrasound"] .findings-textarea',
|
||||
'[data-tab="ultrasound-finding"]'
|
||||
@ -139,19 +148,13 @@ const getDataFromDOM = () => {
|
||||
'[data-tab="ultrasound"] .diagnosis-textarea',
|
||||
'[data-tab="ultrasound-diagnosis"]'
|
||||
],
|
||||
ecgFinding: [
|
||||
'[data-tab="ecg"] .findings-textarea',
|
||||
'[data-tab="ecg-finding"]'
|
||||
],
|
||||
ecgDiagnosis: [
|
||||
'[data-tab="ecg"] .diagnosis-textarea',
|
||||
'[data-tab="ecg-diagnosis"]'
|
||||
],
|
||||
ecgFinding: ['[data-tab="ecg"] .findings-textarea', '[data-tab="ecg-finding"]'],
|
||||
ecgDiagnosis: ['[data-tab="ecg"] .diagnosis-textarea', '[data-tab="ecg-diagnosis"]'],
|
||||
blood: ['[data-tab="blood"] .summary-textarea'],
|
||||
urine: ['[data-tab="urine"] .summary-textarea'],
|
||||
biochemical: ['[data-tab="biochemical"] .summary-textarea']
|
||||
}
|
||||
|
||||
|
||||
// 尝试使用不同的选择器获取元素
|
||||
const getElementValue = (selectorList) => {
|
||||
for (const selector of selectorList) {
|
||||
@ -163,7 +166,7 @@ const getDataFromDOM = () => {
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
|
||||
// 获取各个标签页的内容
|
||||
const generalSummary = getElementValue(selectors.general)
|
||||
const ultrasoundFinding = getElementValue(selectors.ultrasoundFinding)
|
||||
@ -173,7 +176,7 @@ const getDataFromDOM = () => {
|
||||
const bloodSummary = getElementValue(selectors.blood)
|
||||
const urineSummary = getElementValue(selectors.urine)
|
||||
const biochemicalSummary = getElementValue(selectors.biochemical)
|
||||
|
||||
|
||||
console.log('从DOM获取的数据:')
|
||||
console.log('一般检查小结:', generalSummary)
|
||||
console.log('超声检查所见:', ultrasoundFinding)
|
||||
@ -183,19 +186,20 @@ const getDataFromDOM = () => {
|
||||
console.log('血常规小结:', bloodSummary)
|
||||
console.log('尿常规小结:', urineSummary)
|
||||
console.log('生化小结:', biochemicalSummary)
|
||||
|
||||
|
||||
// 如果没有找到一般检查小结,尝试从体检小结文本框获取
|
||||
if (!generalSummary) {
|
||||
console.log('尝试从体检小结文本框获取数据...')
|
||||
const generalTextarea = parentDoc.querySelector('#体检小结') ||
|
||||
parentDoc.querySelector('.体检小结') ||
|
||||
parentDoc.querySelector('[placeholder*="体检小结"]')
|
||||
|
||||
const generalTextarea =
|
||||
parentDoc.querySelector('#体检小结') ||
|
||||
parentDoc.querySelector('.体检小结') ||
|
||||
parentDoc.querySelector('[placeholder*="体检小结"]')
|
||||
|
||||
if (generalTextarea) {
|
||||
console.log('找到体检小结文本框:', generalTextarea)
|
||||
const generalText = generalTextarea.value || ''
|
||||
console.log('体检小结内容:', generalText)
|
||||
|
||||
|
||||
// 更新汇总数据
|
||||
return {
|
||||
general: { summary: generalText },
|
||||
@ -207,7 +211,7 @@ const getDataFromDOM = () => {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 更新汇总数据
|
||||
return {
|
||||
general: { summary: generalSummary },
|
||||
@ -230,16 +234,19 @@ const loadPatientItems = async () => {
|
||||
ElMessage.warning('患者信息不完整,无法加载汇总数据')
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
const loading = ElLoading.service({
|
||||
lock: true,
|
||||
text: '加载汇总数据中...',
|
||||
background: 'rgba(255, 255, 255, 0.7)'
|
||||
})
|
||||
|
||||
|
||||
console.log('当前患者信息:', props.patient)
|
||||
|
||||
// 检查患者状态
|
||||
checkPatientStatus()
|
||||
|
||||
// 优先使用props中的conclusionData
|
||||
if (props.conclusionData) {
|
||||
console.log('从props获取conclusionData:', props.conclusionData)
|
||||
@ -247,34 +254,34 @@ const loadPatientItems = async () => {
|
||||
} else if (window.parent?.conclusionData) {
|
||||
console.log('父窗口conclusionData:', window.parent.conclusionData)
|
||||
const parentData = window.parent.conclusionData
|
||||
|
||||
|
||||
// 复制父组件的数据到本地
|
||||
summaryData.value = {
|
||||
general: { summary: parentData.general?.summary || '' },
|
||||
ultrasound: {
|
||||
finding: parentData.ultrasound?.finding || '',
|
||||
diagnosis: parentData.ultrasound?.diagnosis || ''
|
||||
ultrasound: {
|
||||
finding: parentData.ultrasound?.finding || '',
|
||||
diagnosis: parentData.ultrasound?.diagnosis || ''
|
||||
},
|
||||
ecg: {
|
||||
finding: parentData.ecg?.finding || '',
|
||||
diagnosis: parentData.ecg?.diagnosis || ''
|
||||
ecg: {
|
||||
finding: parentData.ecg?.finding || '',
|
||||
diagnosis: parentData.ecg?.diagnosis || ''
|
||||
},
|
||||
blood: { summary: parentData.blood?.summary || '' },
|
||||
urine: { summary: parentData.urine?.summary || '' },
|
||||
biochemical: { summary: parentData.biochemical?.summary || '' }
|
||||
}
|
||||
|
||||
|
||||
console.log('从父窗口获取的汇总数据:', summaryData.value)
|
||||
} else {
|
||||
console.warn('父窗口中没有找到conclusionData,尝试从全局变量获取')
|
||||
|
||||
|
||||
// 尝试从全局变量获取
|
||||
if (window.conclusionData) {
|
||||
console.log('从全局变量获取conclusionData:', window.conclusionData)
|
||||
summaryData.value = window.conclusionData
|
||||
} else {
|
||||
console.warn('全局变量中没有找到conclusionData,尝试从props获取')
|
||||
|
||||
|
||||
// 尝试从props中获取数据
|
||||
if (props.reportData && props.reportData.conclusionData) {
|
||||
console.log('从props.reportData中获取数据:', props.reportData.conclusionData)
|
||||
@ -291,14 +298,14 @@ const loadPatientItems = async () => {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 格式化汇总数据并设置为可编辑文本
|
||||
const formattedText = formatSummaryData()
|
||||
console.log('格式化后的文本:', formattedText)
|
||||
editableSummary.value = formattedText
|
||||
|
||||
|
||||
loading.close()
|
||||
|
||||
|
||||
if (formattedText) {
|
||||
ElMessage.success('体检汇总数据已刷新')
|
||||
} else {
|
||||
@ -311,54 +318,96 @@ const loadPatientItems = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
const saving = ref(false)
|
||||
// 保存汇总内容到PatientApi的summaryResult字段
|
||||
const saveSummary = async () => {
|
||||
if (!editableSummary.value) {
|
||||
ElMessage.warning('体检汇总内容为空,请检查汇总内容')
|
||||
return false
|
||||
}
|
||||
if (!props.patient || !props.patient.medicalSn) {
|
||||
ElMessage.warning('患者信息不完整,无法保存汇总数据')
|
||||
return
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
saving.value = true
|
||||
|
||||
|
||||
// 准备保存的数据
|
||||
const saveData = {
|
||||
medicalSn: props.patient.medicalSn,
|
||||
summaryResult: editableSummary.value
|
||||
}
|
||||
|
||||
|
||||
console.log('保存汇总数据:', saveData)
|
||||
|
||||
|
||||
// 调用API保存数据
|
||||
const response = await PatientApi.updateSummaryResult(saveData)
|
||||
|
||||
const response = await PatientApi.updatemedicalSn(saveData)
|
||||
|
||||
if (response && response.code === 200) {
|
||||
ElMessage.success('体检汇总保存成功')
|
||||
|
||||
// 触发父组件的保存方法,实现与主页面保存按钮的联动
|
||||
emit('save-summary', editableSummary.value)
|
||||
// 保存成功后重新查询数据
|
||||
await queryPatientData()
|
||||
|
||||
// 尝试调用父窗口的保存方法
|
||||
if (window.parent && typeof window.parent.handleSaveAllResults === 'function') {
|
||||
try {
|
||||
window.parent.handleSaveAllResults()
|
||||
} catch (err) {
|
||||
console.log('调用父窗口保存方法失败:', err)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ElMessage.error('保存失败: ' + (response?.message || '未知错误'))
|
||||
// 检查患者状态
|
||||
checkPatientStatus()
|
||||
|
||||
return true
|
||||
}
|
||||
return false
|
||||
} catch (error) {
|
||||
console.error('保存汇总数据失败:', error)
|
||||
ElMessage.error('保存汇总数据失败: ' + error.message)
|
||||
return false
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 移除自动加载的监听器和onMounted钩子
|
||||
// 只有点击刷新按钮时才会调用loadPatientItems函数
|
||||
// 查询患者数据
|
||||
const queryPatientData = async () => {
|
||||
if (!props.patient || !props.patient.medicalSn) {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await PatientApi.getByMedicalSn(props.patient.medicalSn)
|
||||
if (response && response.code === 200 && response.data) {
|
||||
console.log('查询到的患者数据:', response.data)
|
||||
|
||||
// 更新患者信息
|
||||
if (response.data.summaryResult) {
|
||||
editableSummary.value = response.data.summaryResult
|
||||
}
|
||||
|
||||
// 如果患者状态已更新,检查是否需要设置只读
|
||||
if (response.data.status) {
|
||||
isReadOnly.value = response.data.status === 2
|
||||
console.log('更新后的患者状态:', response.data.status, '只读模式:', isReadOnly.value)
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('查询患者数据失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
// 组件挂载时加载数据
|
||||
onMounted(() => {
|
||||
loadPatientItems()
|
||||
checkPatientStatus()
|
||||
})
|
||||
|
||||
// 监听患者信息变化
|
||||
watch(() => props.patient, (newVal) => {
|
||||
if (newVal && newVal.medicalSn) {
|
||||
loadPatientItems()
|
||||
checkPatientStatus()
|
||||
}
|
||||
}, { deep: true })
|
||||
|
||||
// 暴露保存汇总方法给父组件调用
|
||||
defineExpose({ saveSummary })
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
@ -428,4 +477,10 @@ const saveSummary = async () => {
|
||||
.refresh-button {
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.summary-textarea[readonly] {
|
||||
background-color: #f5f7fa;
|
||||
cursor: not-allowed;
|
||||
opacity: 0.9;
|
||||
}
|
||||
</style>
|
||||
|
Loading…
Reference in New Issue
Block a user