fix(doctorstation): 修复诊断组件和住院办理功能的数据处理问题

- 修复诊断组件中el-popover模板语法错误,添加template标签
- 优化患者历史数据处理逻辑,确保数组类型安全并正确构建树形结构
- 完善住院办理流程中的组织机构数据获取和筛选逻辑
- 添加详细的控制台日志用于调试住院办理功能
- 修复办理住院按钮的禁用状态计算逻辑
- 优化患者卡片点击事件处理,确保就诊ID正确传递
- 添加诊断信息完整性检查并提供用户引导
- 修复检验申请组件中的监听器和暴露方法逻辑
This commit is contained in:
2026-01-18 00:37:54 +08:00
parent 982ee316f7
commit 2fe6d45ad4
5 changed files with 215 additions and 35 deletions

View File

@@ -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('表单验证失败');
}
});
}