门诊医生站患者病历打不开 不显示数据问题

This commit is contained in:
2025-12-16 17:12:21 +08:00
parent 3188ca5752
commit 633cf2c17f
5 changed files with 288 additions and 186 deletions

View File

@@ -219,6 +219,7 @@ const templateName = ref('');
// 事件
const emits = defineEmits(['save']);
const { proxy } = getCurrentInstance();
console.log('EMR组件初始化proxy:', proxy);
// 监听表单变化
watch(
@@ -325,18 +326,109 @@ function cancel() {
// 暴露方法给父组件
defineExpose({
getDetail(encounterId) {
getEmrDetail(encounterId).then((res) => {
if (res.data) {
console.log('开始获取病历详情encounterId:', encounterId);
// 立即初始化form.value为空对象确保页面有内容显示
form.value = {};
// 检查API函数是否存在
if (typeof getEmrDetail !== 'function') {
console.error('getEmrDetail函数未定义');
if (proxy) {
proxy.$modal.msgError('获取病历详情失败API函数未定义');
}
return;
}
// 添加超时处理,防止请求一直挂起
const timeoutPromise = new Promise((_, reject) => {
setTimeout(() => {
reject(new Error('获取病历详情请求超时'));
}, 10000); // 10秒超时
});
// 使用Promise.race处理正常请求和超时
Promise.race([getEmrDetail(encounterId), timeoutPromise])
.then((res) => {
console.log('获取病历详情成功,返回完整数据:', JSON.stringify(res, null, 2));
// 检查响应是否有效
if (!res) {
console.error('API返回结果为空');
if (proxy) {
proxy.$modal.msgError('获取病历详情失败API返回结果为空');
}
return;
}
console.log('res存在类型:', typeof res);
console.log('res的属性:', Object.keys(res));
// 检查响应码
if (res.code !== 200) {
console.error('API返回错误代码:', res.code);
if (proxy) {
proxy.$modal.msgError('获取病历详情失败:' + (res.msg || '未知错误'));
}
return;
}
// 检查数据是否存在
if (!res.data) {
console.log('res.data为空使用默认值');
return;
}
console.log('res.data存在类型:', typeof res.data);
console.log('res.data的属性:', Object.keys(res.data));
// 处理contextJson
try {
form.value = JSON.parse(res.data.contextJson) || {};
if (res.data.contextJson) {
console.log('contextJson存在值:', res.data.contextJson);
console.log('contextJson类型:', typeof res.data.contextJson);
// 检查contextJson类型
if (typeof res.data.contextJson === 'string') {
// 尝试解析JSON字符串
const parsedData = JSON.parse(res.data.contextJson);
// 确保解析结果是对象
if (typeof parsedData === 'object' && parsedData !== null) {
form.value = parsedData;
console.log('解析后的病历数据:', JSON.stringify(form.value, null, 2));
} else {
form.value = {};
console.error('contextJson解析结果不是有效对象:', parsedData);
}
} else if (typeof res.data.contextJson === 'object') {
// 如果已经是对象,直接使用
form.value = res.data.contextJson;
console.log('直接使用contextJson作为对象:', JSON.stringify(form.value, null, 2));
} else {
form.value = {};
console.error('contextJson类型无效:', typeof res.data.contextJson);
}
} else {
console.log('contextJson为空使用默认值');
}
} catch (e) {
form.value = {};
console.error('病历数据解析失败:', e);
console.error('解析失败的contextJson值:', res.data.contextJson);
if (proxy) {
proxy.$modal.msgError('病历数据解析失败');
}
}
emits('save', true);
} else {
form.value = {};
}
});
})
.catch((error) => {
// 处理API调用失败或超时的情况
console.error('获取病历详情失败:', error);
if (proxy) {
proxy.$modal.msgError('获取病历详情失败:' + (error.message || '未知错误'));
}
});
},
addEmr
});

View File

@@ -1493,6 +1493,7 @@ const { proxy } = getCurrentInstance();
const inputRefs = ref({}); // 存储输入框实例,格式: { rowIndex: { fieldName: el } }
const requiredProps = ref([]); // 存储必填项 prop 顺序
const totalAmount = ref(0);
const groupMarkers = ref([]); // 存储分组标记,用于显示层级关系
const { method_code, unit_code, rate_code, distribution_category_code, drord_doctor_type } = proxy.useDict(
'method_code',
'unit_code',

View File

@@ -20,16 +20,16 @@
<el-icon
class="delete-icon"
title="删除处方单"
@click="handleDeletePrescriptionClick(index)"
:class="{ 'disabled-icon': isPrescriptionDeletable(index) !== true }"
@click="handleDeletePrescriptionClick(pIndex)"
:class="{ 'disabled-icon': isPrescriptionDeletable(pIndex) !== true }"
style="font-size: 20px !important; margin-left: 10px; color: #f56c6c"
>
<minus />
</el-icon>
</div>
<div class="summary">
<span class="summary-item">药品数: {{ getPrescriptionMedicineCount(index) }}</span>
<span class="summary-item">总价: ¥ {{ getPrescriptionTotalPrice(index) }}</span>
<span class="summary-item">药品数: {{ getPrescriptionMedicineCount(pIndex) }}</span>
<span class="summary-item">总价: ¥ {{ getPrescriptionTotalPrice(pIndex) }}</span>
</div>
</div>
<div>
@@ -570,7 +570,10 @@ function getList() {
}
function getListInfo(addNewRow) {
isAdding.value = false;
// 确保isAdding变量存在
if (typeof isAdding !== 'undefined') {
isAdding.value = false;
}
// 确保有患者信息
if (!props.patientInfo || !props.patientInfo.encounterId) {
@@ -650,7 +653,7 @@ function getDiagnosisInfo() {
});
});
}
// 默认选择第一个诊断
// 默认选择第一个诊断
if (diagnosisList.value.length > 0) {
const firstDiagnosis = diagnosisList.value[0];
tcmPrescriptionList.value.forEach((prescription) => {