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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user