fix(doctorstation): 修复诊断组件和住院办理功能的数据处理问题
- 修复诊断组件中el-popover模板语法错误,添加template标签 - 优化患者历史数据处理逻辑,确保数组类型安全并正确构建树形结构 - 完善住院办理流程中的组织机构数据获取和筛选逻辑 - 添加详细的控制台日志用于调试住院办理功能 - 修复办理住院按钮的禁用状态计算逻辑 - 优化患者卡片点击事件处理,确保就诊ID正确传递 - 添加诊断信息完整性检查并提供用户引导 - 修复检验申请组件中的监听器和暴露方法逻辑
This commit is contained in:
@@ -107,11 +107,12 @@
|
||||
trigger="manual"
|
||||
:width="800"
|
||||
>
|
||||
|
||||
<diagnosislist
|
||||
:diagnosisSearchkey="diagnosisSearchkey"
|
||||
@selectDiagnosis="handleSelsectDiagnosis"
|
||||
/>
|
||||
<template #default>
|
||||
<diagnosislist
|
||||
:diagnosisSearchkey="diagnosisSearchkey"
|
||||
@selectDiagnosis="handleSelsectDiagnosis"
|
||||
/>
|
||||
</template>
|
||||
<template #reference>
|
||||
<el-input v-model="scope.row.name" placeholder="请选择诊断" @input="handleChange"
|
||||
@focus="handleFocus(scope.row, scope.$index)" @blur="handleBlur(scope.row)" />
|
||||
@@ -374,29 +375,32 @@ function getTree() {
|
||||
const patientId = props.patientInfo?.patientId || '';
|
||||
getConditionDefinitionInfo(patientId).then((res) => {
|
||||
if (res.code == 200) {
|
||||
let list = [];
|
||||
list = res.data.patientHistoryList;
|
||||
list.children = [];
|
||||
// 确保数据结构正确,避免直接修改数组对象
|
||||
const patientHistoryList = Array.isArray(res.data.patientHistoryList) ? res.data.patientHistoryList : [];
|
||||
const doctorCommonUseList = Array.isArray(res.data.doctorCommonUseList) ? res.data.doctorCommonUseList : [];
|
||||
const userPersonalList = Array.isArray(res.data.userPersonalList) ? res.data.userPersonalList : [];
|
||||
const organizationList = Array.isArray(res.data.organizationList) ? res.data.organizationList : [];
|
||||
|
||||
// 手动构造树列表;
|
||||
tree.value[0] = {
|
||||
id: '1',
|
||||
name: '历史',
|
||||
children: list,
|
||||
children: patientHistoryList,
|
||||
};
|
||||
tree.value[1] = {
|
||||
id: '2',
|
||||
name: '常用',
|
||||
children: res.data.doctorCommonUseList,
|
||||
children: doctorCommonUseList,
|
||||
};
|
||||
tree.value[2] = {
|
||||
id: '3',
|
||||
name: '个人',
|
||||
children: res.data.userPersonalList,
|
||||
children: userPersonalList,
|
||||
};
|
||||
tree.value[3] = {
|
||||
id: '4',
|
||||
name: '科室',
|
||||
children: res.data.organizationList,
|
||||
children: organizationList,
|
||||
};
|
||||
console.log(tree.value);
|
||||
}
|
||||
|
||||
@@ -242,26 +242,53 @@ const rules = reactive({
|
||||
});
|
||||
|
||||
function openDialog() {
|
||||
console.log('hospitalizationDialog openDialog 被调用');
|
||||
console.log('props.patientInfo:', props.patientInfo);
|
||||
console.log('props.encounterId:', props.encounterId);
|
||||
console.log('props.patientInfo.encounterId:', props.patientInfo?.encounterId);
|
||||
console.log('orgId==========>', props.patientInfo.orgId);
|
||||
|
||||
getOrgList().then((res) => {
|
||||
console.log('获取组织机构数据:', res);
|
||||
|
||||
// 确保数据结构正确
|
||||
if (res.data && res.data.records && res.data.records.length > 0) {
|
||||
// 获取第一层级的子节点,筛选出类型为科室(typeEnum===2)且类别为住院(classEnum===2)的组织
|
||||
const firstLevelChildren = res.data.records[0]?.children || [];
|
||||
organization.value = firstLevelChildren.filter(
|
||||
(record) => record.typeEnum === 2 && record.classEnum === 2
|
||||
);
|
||||
if (res && res.code === 200 && res.data && res.data.records && Array.isArray(res.data.records)) {
|
||||
// 递归遍历树形结构,获取所有符合条件的节点
|
||||
const flattenTree = (nodes) => {
|
||||
let result = [];
|
||||
nodes.forEach(node => {
|
||||
// 检查当前节点是否符合条件
|
||||
if (node && node.typeEnum === 2 && node.classEnum === 2) {
|
||||
result.push(node);
|
||||
}
|
||||
// 递归处理子节点
|
||||
if (node.children && Array.isArray(node.children)) {
|
||||
result = result.concat(flattenTree(node.children));
|
||||
}
|
||||
});
|
||||
return result;
|
||||
};
|
||||
|
||||
// 从树形结构中提取所有符合条件的组织
|
||||
organization.value = flattenTree(res.data.records);
|
||||
|
||||
console.log('筛选后的组织机构数据:', organization.value);
|
||||
|
||||
// 如果当前患者所属科室在筛选结果中,则默认选中
|
||||
if (props.patientInfo.orgId) {
|
||||
if (props.patientInfo?.orgId) {
|
||||
submitForm.inHospitalOrgId =
|
||||
organization.value.find((item) => item.id === props.patientInfo.orgId)?.id || '';
|
||||
organization.value.find((item) => item?.id === props.patientInfo.orgId)?.id || '';
|
||||
}
|
||||
} else {
|
||||
organization.value = [];
|
||||
console.warn('获取组织机构数据为空或格式不正确:', res);
|
||||
}
|
||||
|
||||
console.log('organization==========>', organization.value);
|
||||
}).catch(error => {
|
||||
console.error('获取组织机构数据失败:', error);
|
||||
organization.value = [];
|
||||
proxy.$modal.msgError('获取组织机构数据失败,请稍后重试');
|
||||
});
|
||||
|
||||
// 获取初始化数据
|
||||
@@ -330,15 +357,22 @@ function handleChange(value) {
|
||||
}
|
||||
|
||||
function submit() {
|
||||
console.log('hospitalizationDialog submit 被调用');
|
||||
console.log('props.patientInfo:', props.patientInfo);
|
||||
console.log('props.encounterId:', props.encounterId);
|
||||
console.log('props.patientInfo.encounterId:', props.patientInfo?.encounterId);
|
||||
|
||||
proxy.$refs['registerRef'].validate((valid) => {
|
||||
if (valid) {
|
||||
// 验证必要字段
|
||||
if (!props.patientInfo.patientId) {
|
||||
console.log('患者信息不完整,缺少 patientId');
|
||||
proxy.$modal.msgError('患者信息不完整,无法办理住院');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!props.encounterId && !props.patientInfo.encounterId) {
|
||||
console.log('就诊信息不完整,缺少 encounterId');
|
||||
proxy.$modal.msgError('就诊信息不完整,无法办理住院');
|
||||
return;
|
||||
}
|
||||
@@ -358,6 +392,7 @@ function submit() {
|
||||
const loading = proxy.$modal.loading('正在办理住院...');
|
||||
|
||||
handleHospitalization(saveData).then((res) => {
|
||||
console.log('住院办理API响应:', res);
|
||||
if (res.code == 200) {
|
||||
proxy.$modal.msgSuccess('办理成功');
|
||||
close();
|
||||
@@ -380,6 +415,8 @@ function submit() {
|
||||
// 关闭加载状态
|
||||
proxy.$modal.closeLoading();
|
||||
});
|
||||
} else {
|
||||
console.log('表单验证失败');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1002,6 +1002,18 @@ watch(() => props.activeTab, (newVal) => {
|
||||
}
|
||||
})
|
||||
|
||||
// 监听patientInfo变化,确保在患者信息更新时也更新检验申请单列表
|
||||
watch(() => props.patientInfo, (newPatientInfo) => {
|
||||
if (newPatientInfo && Object.keys(newPatientInfo).length > 0) {
|
||||
// 更新encounterId
|
||||
queryParams.encounterId = newPatientInfo.encounterId || newPatientInfo.id || newPatientInfo.patientId
|
||||
// 如果有有效的encounterId,则获取检验申请单列表
|
||||
if (queryParams.encounterId && queryParams.encounterId !== 'undefined' && queryParams.encounterId !== 'null' && queryParams.encounterId !== '') {
|
||||
getInspectionList()
|
||||
}
|
||||
}
|
||||
}, { deep: true })
|
||||
|
||||
// 初始化
|
||||
onMounted(() => {
|
||||
initData()
|
||||
@@ -1009,7 +1021,13 @@ onMounted(() => {
|
||||
|
||||
// 暴露方法
|
||||
defineExpose({
|
||||
getList: getInspectionList
|
||||
getList() {
|
||||
// 在调用getList时,先检查是否有有效的patientInfo,如果有则更新encounterId
|
||||
if (props.patientInfo && Object.keys(props.patientInfo).length > 0) {
|
||||
queryParams.encounterId = props.patientInfo.encounterId || props.patientInfo.id || props.patientInfo.patientId;
|
||||
}
|
||||
getInspectionList();
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
@@ -110,10 +110,10 @@
|
||||
<el-button type="primary" plain @click.stop="handleRefund(patientInfo.encounterId)">
|
||||
退费
|
||||
</el-button>
|
||||
<el-button type="primary" plain @click.stop="getEnPrescription(patientInfo.encounterId)">
|
||||
<el-button type="primary" plain class="top-layer-btn" @click.stop="getEnPrescription(patientInfo.encounterId)">
|
||||
处方单
|
||||
</el-button>
|
||||
<el-button type="primary" plain @click.stop="onHospitalization"> 办理住院 </el-button>
|
||||
<el-button type="primary" plain class="top-layer-btn" :disabled="isHospitalizationButtonDisabled" @click.stop="handleHospitalizationClick()" @mouseenter="console.log('办理住院按钮状态:', { patientInfo: patientInfo?.value, hasEncounterId: patientInfo?.value?.encounterId, isDisabled: isHospitalizationButtonDisabled })"> 办理住院 </el-button>
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</div>
|
||||
@@ -174,7 +174,7 @@
|
||||
<ReportQuery :patientInfo="patientInfo" ref="reportQueryRef" />
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
<div class="overlay" v-if="disabled"></div>
|
||||
<div class="overlay" :class="{ 'overlay-disabled': disabled }" v-if="disabled"></div>
|
||||
</div>
|
||||
</div>
|
||||
<el-drawer v-model="drawer" title="患者队列" direction="ltr" @open="handleOpen">
|
||||
@@ -264,6 +264,16 @@ const patientList = ref([]);
|
||||
const patientInfo = ref({});
|
||||
const visitTypeDisabled = ref(false);
|
||||
|
||||
// 计算属性:确定办理住院按钮是否应被禁用
|
||||
const isHospitalizationButtonDisabled = computed(() => {
|
||||
return !patientInfo.value ||
|
||||
typeof patientInfo.value !== 'object' ||
|
||||
!patientInfo.value.encounterId ||
|
||||
patientInfo.value.encounterId === '' ||
|
||||
patientInfo.value.encounterId === null ||
|
||||
patientInfo.value.encounterId === undefined;
|
||||
});
|
||||
|
||||
const prescriptionInfo = ref([]);
|
||||
const registerTime = ref(formatDate(new Date()));
|
||||
const patientDrawerRef = ref();
|
||||
@@ -279,6 +289,8 @@ const { proxy } = getCurrentInstance();
|
||||
const visitType = ref('');
|
||||
const firstVisitDate = ref('');
|
||||
const disabled = computed(() => {
|
||||
// 只有在有患者信息但某些条件不满足时才启用覆盖层
|
||||
// 当前逻辑保持不变,但我们将在按钮级别处理禁用状态
|
||||
return Object.keys(patientInfo.value).length === 0;
|
||||
});
|
||||
const shortcuts = [
|
||||
@@ -461,13 +473,45 @@ function handleOpen() {
|
||||
}
|
||||
|
||||
function handleCardClick(item, index) {
|
||||
currentEncounterId.value = '';
|
||||
console.log('handleCardClick 被调用');
|
||||
console.log('点击的患者项目:', item);
|
||||
console.log('患者项目中的encounterId:', item.encounterId);
|
||||
|
||||
// 设置当前就诊ID,确保住院功能能获取到正确的ID
|
||||
currentEncounterId.value = item.encounterId;
|
||||
console.log('currentEncounterId.value 设置为:', currentEncounterId.value);
|
||||
|
||||
loading.value = true;
|
||||
patientList.value.forEach((patient) => {
|
||||
patient.active = patient.encounterId === item.encounterId;
|
||||
});
|
||||
patientInfo.value = item;
|
||||
// console.log('patientInfo.value.cardNo:', patientInfo.value.cardNo)
|
||||
console.log('patientInfo.value 设置为:', patientInfo.value);
|
||||
console.log('patientInfo.value.encounterId:', patientInfo.value?.encounterId);
|
||||
|
||||
// 确保患者信息包含必要的字段
|
||||
if (!patientInfo.value.encounterId) {
|
||||
console.error('患者信息缺少encounterId字段:', patientInfo.value);
|
||||
// 可能需要从其他字段获取encounterId
|
||||
if (item.id) {
|
||||
patientInfo.value.encounterId = item.id;
|
||||
console.log('使用item.id作为encounterId:', item.id);
|
||||
}
|
||||
}
|
||||
|
||||
// 添加安全检查,确保item不为undefined或null
|
||||
if (!item) {
|
||||
console.error('handleCardClick: 传入的item为null或undefined');
|
||||
return;
|
||||
}
|
||||
|
||||
// 记录patientInfo内容到控制台
|
||||
setTimeout(() => {
|
||||
const patientInfoStr = JSON.stringify(patientInfo.value, null, 2);
|
||||
console.log('当前patientInfo内容:', patientInfo.value);
|
||||
console.log('patientInfo.encounterId值:', patientInfo.value?.encounterId);
|
||||
}, 100);
|
||||
|
||||
// 将患者信息保存到store中,供hospitalizationEmr组件使用
|
||||
updatePatientInfo(item);
|
||||
activeTab.value = 'hospitalizationEmr';
|
||||
@@ -513,6 +557,21 @@ function handleTimeChange(value) {
|
||||
getPatientList();
|
||||
}
|
||||
|
||||
// 处理办理住院点击事件
|
||||
function handleHospitalizationClick() {
|
||||
console.log('handleHospitalizationClick 被调用');
|
||||
console.log('当前patientInfo:', patientInfo.value);
|
||||
console.log('当前patientInfo.encounterId:', patientInfo.value?.encounterId);
|
||||
|
||||
if (!patientInfo.value || !patientInfo.value.encounterId) {
|
||||
console.log('患者信息不完整,无法办理住院');
|
||||
ElMessage.warning('请先选择患者');
|
||||
} else {
|
||||
console.log('调用onHospitalization函数');
|
||||
onHospitalization();
|
||||
}
|
||||
}
|
||||
|
||||
// 接诊回调
|
||||
function handleReceive(row) {
|
||||
handleCardClick(row);
|
||||
@@ -532,8 +591,13 @@ function openDrawer() {
|
||||
}
|
||||
// 判断是否已经入院登记
|
||||
const onHospitalization = async () => {
|
||||
console.log('onHospitalization 被调用');
|
||||
console.log('patientInfo.value:', patientInfo.value);
|
||||
console.log('patientInfo.value.encounterId:', patientInfo.value?.encounterId);
|
||||
|
||||
// 检查是否有有效的就诊ID
|
||||
if (!patientInfo.value?.encounterId) {
|
||||
console.log('缺少有效的就诊ID,无法办理住院');
|
||||
ElMessage({
|
||||
type: 'error',
|
||||
message: '患者就诊信息不完整,无法办理住院!',
|
||||
@@ -542,10 +606,13 @@ const onHospitalization = async () => {
|
||||
}
|
||||
|
||||
try {
|
||||
console.log('开始获取诊断信息,encounterId:', patientInfo.value.encounterId);
|
||||
const diagnosisRes = await getEncounterDiagnosis(patientInfo.value.encounterId);
|
||||
console.log('诊断信息获取结果:', diagnosisRes);
|
||||
|
||||
// 检查API调用是否成功
|
||||
if (diagnosisRes.code !== 200) {
|
||||
console.log('获取诊断信息失败:', diagnosisRes.msg);
|
||||
ElMessage({
|
||||
type: 'error',
|
||||
message: diagnosisRes.msg || '获取诊断信息失败,无法办理住院!',
|
||||
@@ -554,31 +621,67 @@ const onHospitalization = async () => {
|
||||
}
|
||||
|
||||
const hasDiagnosis = diagnosisRes.data?.length > 0;
|
||||
console.log('是否有诊断信息:', hasDiagnosis);
|
||||
if (!hasDiagnosis) {
|
||||
ElMessage({
|
||||
type: 'error',
|
||||
message: '该患者暂无诊断信息,无法办理住院!',
|
||||
console.log('该患者暂无诊断信息');
|
||||
const confirmResult = await ElMessageBox.confirm(
|
||||
'该患者暂无诊断信息,是否前往添加诊断?',
|
||||
'提示',
|
||||
{
|
||||
confirmButtonText: '前往添加',
|
||||
cancelButtonText: '暂不办理',
|
||||
type: 'warning',
|
||||
}
|
||||
).catch(() => {
|
||||
// 用户取消操作
|
||||
console.log('用户取消前往添加诊断');
|
||||
return false;
|
||||
});
|
||||
|
||||
if (confirmResult === true) {
|
||||
// 自动切换到诊断标签页以便用户添加诊断
|
||||
activeTab.value = 'diagnosis';
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const mainDiag = diagnosisRes.data.find((item) => item.maindiseFlag === 1);
|
||||
console.log('主诊断信息:', mainDiag);
|
||||
if (!mainDiag) {
|
||||
ElMessage({
|
||||
type: 'error',
|
||||
message: '该患者暂无主诊断信息,无法办理住院!'
|
||||
console.log('该患者暂无主诊断信息');
|
||||
const confirmResult = await ElMessageBox.confirm(
|
||||
'该患者暂无主诊断信息,是否前往设置主诊断?',
|
||||
'提示',
|
||||
{
|
||||
confirmButtonText: '前往设置',
|
||||
cancelButtonText: '暂不办理',
|
||||
type: 'warning',
|
||||
}
|
||||
).catch(() => {
|
||||
// 用户取消操作
|
||||
console.log('用户取消前往设置主诊断');
|
||||
return false;
|
||||
});
|
||||
|
||||
if (confirmResult === true) {
|
||||
// 自动切换到诊断标签页以便用户设置主诊断
|
||||
activeTab.value = 'diagnosis';
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
mainDiagnosis.value = mainDiag;
|
||||
console.log('主诊断设置成功:', mainDiagnosis.value);
|
||||
|
||||
console.log('检查住院状态,encounterId:', patientInfo.value.encounterId);
|
||||
const res = await isHospitalization({
|
||||
encounterId: patientInfo.value.encounterId,
|
||||
});
|
||||
console.log('住院状态检查结果:', res);
|
||||
|
||||
// 检查API调用是否成功
|
||||
if (res.code !== 200) {
|
||||
console.log('检查住院状态失败:', res.msg);
|
||||
ElMessage({
|
||||
type: 'error',
|
||||
message: res.msg || '检查住院状态失败!',
|
||||
@@ -586,9 +689,17 @@ const onHospitalization = async () => {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('住院状态检查API响应:', res);
|
||||
console.log('res.data值:', res.data);
|
||||
console.log('res.data类型:', typeof res.data);
|
||||
|
||||
if (!res.data) {
|
||||
console.log('患者未办理过住院,打开住院登记对话框');
|
||||
console.log('当前openDialog值:', openDialog.value);
|
||||
openDialog.value = true;
|
||||
console.log('设置openDialog为true后,值为:', openDialog.value);
|
||||
} else {
|
||||
console.log('患者已办理过住院');
|
||||
ElMessage({
|
||||
type: 'error',
|
||||
message: '该患者,已办理入院,不允许重复办理',
|
||||
@@ -792,10 +903,20 @@ const onHospitalization = async () => {
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: calc(100% - 50px);
|
||||
z-index: 999;
|
||||
z-index: 998; /* 降低z-index,避免覆盖按钮 */
|
||||
/* 确保覆盖在内容上方,但不覆盖顶部按钮区域 */
|
||||
cursor: not-allowed;
|
||||
background-color: rgba(255, 255, 255, 0.01);
|
||||
pointer-events: auto;
|
||||
pointer-events: none; /* 默认不捕获鼠标事件,只在真正需要禁用时才启用 */
|
||||
}
|
||||
|
||||
.disabled-wrapper .overlay.overlay-disabled {
|
||||
pointer-events: auto; /* 当需要真正禁用时启用指针事件 */
|
||||
}
|
||||
|
||||
/* 顶层按钮样式,确保按钮始终在最上层 */
|
||||
.top-layer-btn {
|
||||
position: relative !important;
|
||||
z-index: 1000 !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -202,7 +202,7 @@
|
||||
|
||||
<el-form ref="surgeryRef" :model="form" :rules="rules" label-width="120px">
|
||||
<el-form-item label="id" prop="id" v-show="false">
|
||||
<el-input v-model="form.id" />
|
||||
<el-input v-model="form.id" />s
|
||||
</el-form-item>
|
||||
|
||||
<el-row :gutter="20">
|
||||
|
||||
Reference in New Issue
Block a user