Compare commits
2 Commits
2d2fa64772
...
77acb9be3e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
77acb9be3e | ||
|
|
3f341749e5 |
@@ -1141,7 +1141,9 @@ function submitForm() {
|
||||
// 保存麻醉方式
|
||||
sessionStorage.setItem('anesthesiaType', form.value.anesthesiaTypeEnum)
|
||||
open.value = false
|
||||
// 由父组件 @saved 事件负责刷新列表(带延迟确保后端事务已提交)
|
||||
// 子组件自身主动刷新列表(立即),确保数据展示不依赖父组件事件
|
||||
getList()
|
||||
// 通知父组件刷新医嘱列表(父组件也会带延迟再次刷新手术列表作为兜底)
|
||||
emit('saved')
|
||||
} else {
|
||||
proxy.$modal.msgError(res.msg || '新增手术失败,请检查表单信息')
|
||||
@@ -1158,6 +1160,8 @@ function submitForm() {
|
||||
// 保存麻醉方式
|
||||
sessionStorage.setItem('anesthesiaType', form.value.anesthesiaTypeEnum)
|
||||
open.value = false
|
||||
// 子组件自身主动刷新列表(立即)
|
||||
getList()
|
||||
// 由父组件 @saved 事件负责刷新列表
|
||||
emit('saved')
|
||||
} else {
|
||||
|
||||
@@ -521,31 +521,28 @@ watch(
|
||||
}
|
||||
);
|
||||
|
||||
// 加载科室选项(支持树形/扁平两种数据结构)
|
||||
// 加载科室选项(递归扁平化树形结构)
|
||||
function loadDepartmentOptions() {
|
||||
getOrgList()
|
||||
.then((res) => {
|
||||
if (res.data) {
|
||||
// 尝试从树形结构中取:records[0].children
|
||||
if (res.data.records && res.data.records.length > 0) {
|
||||
if (res.data.records[0].children && res.data.records[0].children.length > 0) {
|
||||
departmentOptions.value = res.data.records[0].children;
|
||||
return;
|
||||
}
|
||||
// 如果 records[0] 有 id 和 name(非树根节点),直接用所有 records
|
||||
if (res.data.records[0].id) {
|
||||
departmentOptions.value = res.data.records;
|
||||
return;
|
||||
}
|
||||
}
|
||||
// 兜底:如果 records 不存在或为空,尝试直接使用 data 本身
|
||||
if (Array.isArray(res.data)) {
|
||||
departmentOptions.value = res.data;
|
||||
return;
|
||||
}
|
||||
if (!res?.data?.records?.length) {
|
||||
departmentOptions.value = [];
|
||||
return;
|
||||
}
|
||||
// 所有方式都失败,置空
|
||||
departmentOptions.value = [];
|
||||
// 递归扁平化树形结构,提取所有科室节点
|
||||
const flattenTree = (nodes) => {
|
||||
const result = [];
|
||||
for (const node of nodes) {
|
||||
if (node?.id && node?.name) {
|
||||
result.push(node);
|
||||
}
|
||||
if (node?.children?.length) {
|
||||
result.push(...flattenTree(node.children));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
departmentOptions.value = flattenTree(res.data.records);
|
||||
})
|
||||
.catch(() => {
|
||||
console.warn('科室列表加载失败(可能无权限)');
|
||||
@@ -611,13 +608,13 @@ function getUnitCodeOptions(row) {
|
||||
const unitCodes = [];
|
||||
// 大单位:优先用 code,code 缺失时用字典文本兜底
|
||||
if (row.unitCode != null && String(row.unitCode) !== '') {
|
||||
unitCodes.push({ code: String(row.unitCode), codeText: row.unitCode_dictText });
|
||||
unitCodes.push({ code: String(row.unitCode), codeText: row.unitCode_dictText || String(row.unitCode) });
|
||||
} else if (row.unitCode_dictText) {
|
||||
unitCodes.push({ code: row.unitCode_dictText, codeText: row.unitCode_dictText });
|
||||
}
|
||||
// 小单位:同上
|
||||
if (row.minUnitCode != null && String(row.minUnitCode) !== '') {
|
||||
unitCodes.push({ code: String(row.minUnitCode), codeText: row.minUnitCode_dictText });
|
||||
unitCodes.push({ code: String(row.minUnitCode), codeText: row.minUnitCode_dictText || String(row.minUnitCode) });
|
||||
} else if (row.minUnitCode_dictText) {
|
||||
unitCodes.push({ code: row.minUnitCode_dictText, codeText: row.minUnitCode_dictText });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user