656 [门诊医生站-检查申请] 单击已保存记录回显异常:自动跳转页签错误且“检查方法”数据未回显
This commit is contained in:
@@ -88,6 +88,7 @@
|
||||
v-loading="loading"
|
||||
:data="filteredApplicationList"
|
||||
:max-height="200"
|
||||
min-width="865"
|
||||
border
|
||||
size="small"
|
||||
:header-cell-style="{ background: '#f5f5f5', color: '#303133', fontWeight: '600' }"
|
||||
@@ -140,7 +141,7 @@
|
||||
<vxe-column
|
||||
title="收费"
|
||||
field="isCharged"
|
||||
width="50"
|
||||
width="65"
|
||||
align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
@@ -155,7 +156,7 @@
|
||||
<vxe-column
|
||||
title="退费"
|
||||
field="isRefunded"
|
||||
width="50"
|
||||
width="65"
|
||||
align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
@@ -170,7 +171,7 @@
|
||||
<vxe-column
|
||||
title="执行"
|
||||
field="isExecuted"
|
||||
width="50"
|
||||
width="65"
|
||||
align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
@@ -1451,7 +1452,10 @@ const availableMethods = computed(() => {
|
||||
});
|
||||
|
||||
function isStandaloneMethodSelected(method) {
|
||||
return selectedMethods.value.some((m) => String(m.id) === String(method?.id));
|
||||
return selectedMethods.value.some((m) =>
|
||||
String(m.id) === String(method?.id) ||
|
||||
(m.code && method?.code && String(m.code) === String(method.code))
|
||||
);
|
||||
}
|
||||
|
||||
function getDisplayMethodName(method) {
|
||||
@@ -1712,11 +1716,12 @@ watch(() => props.patientInfo, (newVal) => {
|
||||
|
||||
watch(() => props.activeTab, async (val) => {
|
||||
if (val === 'examination') {
|
||||
getList();
|
||||
// 切换到检查页签时,重新获取临床诊断(确保与诊断页签同步)
|
||||
// 进入检查tab时自动初始化表单,确保输入框可编辑且处于干净状态
|
||||
// handleAdd 内部已调用 loadClinicalDiag() 获取临床诊断
|
||||
if (props.patientInfo?.encounterId) {
|
||||
await loadClinicalDiag();
|
||||
handleAdd();
|
||||
}
|
||||
// 父组件 handleClick 中已调用 getList(),此处不再重复调用
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1859,7 +1864,8 @@ function handleSave() {
|
||||
});
|
||||
}
|
||||
|
||||
function handleRowClick(row) {
|
||||
function handleRowClick({ row, column }) {
|
||||
// vxe-table v4 cell-click 事件参数为 { row, column, rowIndex, ... },需解构获取实际行数据
|
||||
Object.assign(form, row);
|
||||
form.selectedMethodDisplay = ''; // Bug #384修复: 先清空,后面根据回充数据更新
|
||||
selectedItems.value = [];
|
||||
@@ -1896,6 +1902,11 @@ function handleRowClick(row) {
|
||||
packageId: null,
|
||||
hasChildren: false // #426修复: 树形表格懒加载展开标记,后续根据packageId动态设置
|
||||
};
|
||||
// Bug #656: 从已保存数据提取检查方法信息(移到 bodyPartCode 外部,确保始终可用)
|
||||
const savedMethodCode = m.examMethodCode || m.checkMethodCode;
|
||||
const savedMethodId = m.checkMethodId;
|
||||
const savedMethodName = m.checkMethodName;
|
||||
|
||||
// 加载该项目的检查方法
|
||||
if (m.bodyPartCode) {
|
||||
try {
|
||||
@@ -1916,49 +1927,74 @@ function handleRowClick(row) {
|
||||
packagePrice: md.packagePrice || null,
|
||||
serviceFee: md.serviceFee || null
|
||||
}));
|
||||
// 回充已保存的检查方法
|
||||
const methodCode = m.examMethodCode || m.checkMethodCode;
|
||||
const methodId = m.checkMethodId;
|
||||
if (methodCode || methodId) {
|
||||
const found = item.methods.find(md =>
|
||||
(methodCode && String(md.code) === String(methodCode)) ||
|
||||
(methodId && String(md.id) === String(methodId))
|
||||
);
|
||||
if (found) {
|
||||
item.selectedMethod = found;
|
||||
} else {
|
||||
item.selectedMethod = {
|
||||
id: methodId || null,
|
||||
name: m.checkMethodName || '',
|
||||
code: methodCode || '',
|
||||
price: 0,
|
||||
packageName: m.checkMethodPackageName || '',
|
||||
packageId: null,
|
||||
packagePrice: null,
|
||||
serviceFee: null
|
||||
};
|
||||
}
|
||||
}
|
||||
if (item.selectedMethod || item.packageId || item.packageName) {
|
||||
item.hasChildren = true;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('加载检查方法失败', err);
|
||||
}
|
||||
}
|
||||
|
||||
// Bug #656修复: 回充已保存的检查方法(始终执行,不依赖 bodyPartCode 或 API 返回)
|
||||
if (savedMethodCode || savedMethodId) {
|
||||
let found = null;
|
||||
// 1. 优先在该项目的检查方法列表中查找
|
||||
found = item.methods.find(md =>
|
||||
(savedMethodCode && String(md.code) === String(savedMethodCode)) ||
|
||||
(savedMethodId && String(md.id) === String(savedMethodId))
|
||||
);
|
||||
// 2. 未找到时,回退到全局 allMethods 中查找(兼容 checkType 不匹配导致方法不在分类结果中的场景)
|
||||
if (!found) {
|
||||
found = allMethods.value.find(m =>
|
||||
(savedMethodCode && String(m.code) === String(savedMethodCode)) ||
|
||||
(savedMethodId && String(m.id) === String(savedMethodId))
|
||||
);
|
||||
}
|
||||
// 3. 设置 selectedMethod
|
||||
if (found) {
|
||||
item.selectedMethod = {
|
||||
id: found.id,
|
||||
name: found.name,
|
||||
code: found.code,
|
||||
price: found.price || 0,
|
||||
packageName: found.packageName || '',
|
||||
packageId: found.packageId || null,
|
||||
packagePrice: found.packagePrice || null,
|
||||
serviceFee: found.serviceFee || null
|
||||
};
|
||||
} else {
|
||||
// 4. 创建降级对象:优先用已保存名称,其次用代码作为显示名
|
||||
item.selectedMethod = {
|
||||
id: savedMethodId || null,
|
||||
name: savedMethodName || savedMethodCode || '',
|
||||
code: savedMethodCode || '',
|
||||
price: 0,
|
||||
packageName: m.checkMethodPackageName || '',
|
||||
packageId: null,
|
||||
packagePrice: null,
|
||||
serviceFee: null
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (item.selectedMethod || item.packageId || item.packageName) {
|
||||
item.hasChildren = true;
|
||||
}
|
||||
return item;
|
||||
}));
|
||||
// Bug #408修复: 确保明细数据正确加载到selectedItems
|
||||
// Bug #656修复: 去重键改为 id || code,避免 id 为 null 时误判为同一方法导致丢失
|
||||
const methodMap = new Map();
|
||||
for (const item of itemsWithMethods) {
|
||||
if (item.selectedMethod && !methodMap.has(String(item.selectedMethod.id))) {
|
||||
methodMap.set(String(item.selectedMethod.id), {
|
||||
...item.selectedMethod,
|
||||
expanded: false,
|
||||
packageLoading: false,
|
||||
packageDetails: []
|
||||
});
|
||||
if (item.selectedMethod) {
|
||||
const dedupKey = item.selectedMethod.id != null
|
||||
? String(item.selectedMethod.id)
|
||||
: (item.selectedMethod.code || `__item_${item.id}`);
|
||||
if (!methodMap.has(dedupKey)) {
|
||||
methodMap.set(dedupKey, {
|
||||
...item.selectedMethod,
|
||||
expanded: false,
|
||||
packageLoading: false,
|
||||
packageDetails: []
|
||||
});
|
||||
}
|
||||
}
|
||||
item.methodPackageDetails = [];
|
||||
}
|
||||
@@ -1988,8 +2024,39 @@ function handleRowClick(row) {
|
||||
syncCategoryChecked();
|
||||
// Bug #384修复: 回充后更新检查方法显示
|
||||
updateMethodDisplay();
|
||||
// Bug #408修复: 加载申请单详情后自动切换到检查明细页签,确保已加载的明细数据可见
|
||||
activeDetailTab.value = 'applyDetail';
|
||||
|
||||
// Bug #656修复: 展开对应检查项目分类节点,使树形结构和检查方法勾选状态正确回显
|
||||
const firstItem = selectedItems.value[0];
|
||||
if (firstItem && firstItem.checkType) {
|
||||
const targetCat = categoryList.value.find(cat =>
|
||||
(cat.typeName && cat.typeName === firstItem.checkType) ||
|
||||
(cat.categoryName && cat.categoryName === firstItem.checkType)
|
||||
);
|
||||
if (targetCat) {
|
||||
// 先确保分类树的方法已加载完成,再展开分类
|
||||
// 注意顺序:先 await handleCategoryExpand,再设置 activeNames,
|
||||
// 避免 handleCollapseChange 中异步加载与后续匹配逻辑的竞态条件
|
||||
await handleCategoryExpand(targetCat);
|
||||
activeNames.value = targetCat.typeId;
|
||||
// 将 selectedMethods 中的降级方法(id/name 为空)按 code 匹配分类树中的方法,补充名称和真实 ID
|
||||
if (targetCat.methods && targetCat.methods.length > 0) {
|
||||
let updated = false;
|
||||
selectedMethods.value = selectedMethods.value.map(m => {
|
||||
if ((!m.name || !m.id) && m.code) {
|
||||
const matched = targetCat.methods.find(cm => String(cm.code) === String(m.code));
|
||||
if (matched) {
|
||||
updated = true;
|
||||
return { ...matched, expanded: false, packageLoading: false, packageDetails: m.packageDetails || [] };
|
||||
}
|
||||
}
|
||||
return m;
|
||||
});
|
||||
if (updated) {
|
||||
updateMethodDisplay();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('加载申请单详情失败', err);
|
||||
ElMessage.error('加载申请单详情失败');
|
||||
@@ -2333,10 +2400,11 @@ function resetCategoryChecked() {
|
||||
|
||||
function syncCategoryChecked() {
|
||||
resetCategoryChecked();
|
||||
const ids = new Set(selectedItems.value.map(s => s.id));
|
||||
// 统一转为 String 比较,避免 Number vs String 类型不匹配
|
||||
const ids = new Set(selectedItems.value.map(s => String(s.id)));
|
||||
for (const cat of categoryList.value)
|
||||
for (const item of cat.items)
|
||||
if (ids.has(item.id)) item.checked = true;
|
||||
if (ids.has(String(item.id))) item.checked = true;
|
||||
}
|
||||
|
||||
defineExpose({ getList });
|
||||
|
||||
@@ -227,7 +227,6 @@
|
||||
<div style="padding: 10px; position: relative">
|
||||
<el-tabs
|
||||
v-model="activeTab"
|
||||
v-loading="loading"
|
||||
type="card"
|
||||
style="width: 100%; height: 100%"
|
||||
@tab-change="handleClick(activeTab)"
|
||||
@@ -546,7 +545,6 @@ const diagnosisRef = ref();
|
||||
const consultationRef = ref();
|
||||
const infectiousReportRef = ref();
|
||||
const waitCount = ref(0);
|
||||
const loading = ref(false);
|
||||
const { proxy } = getCurrentInstance();
|
||||
const visitType = ref('');
|
||||
const firstVisitDate = ref('');
|
||||
@@ -807,7 +805,6 @@ function handleCardClick(item, index) {
|
||||
currentEncounterId.value = item.encounterId;
|
||||
console.log('currentEncounterId.value 设置为:', currentEncounterId.value);
|
||||
|
||||
loading.value = true;
|
||||
patientList.value.forEach((patient) => {
|
||||
patient.active = patient.encounterId === item.encounterId;
|
||||
});
|
||||
@@ -860,9 +857,6 @@ function handleCardClick(item, index) {
|
||||
eprescriptionRef.value.getList();
|
||||
consultationRef.value.fetchConsultationList();
|
||||
// emrRef.value.getDetail(item.encounterId);
|
||||
setTimeout(() => {
|
||||
loading.value = false;
|
||||
}, 200);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user