Fix Bug #548: 发往科室字段未能正确回显 — 编辑初始化时 transferValue 变化触发 projectWithDepartment 清空 form.targetDepartment,已加 isInitializing 标志拦截

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-19 08:59:52 +08:00
parent fa18e94cd9
commit 798c5e19e2

View File

@@ -244,6 +244,8 @@ const getList = async () => {
const handleSearch = () => {
// 搜索时保持已选中的项目不受影响
};
// 编辑初始化标志:避免 applyEditTransferSelection 设置 transferValue 时触发 projectWithDepartment 覆盖 descJson 中的科室值
const isInitializing = ref(false);
const transferValue = ref([]);
const form = reactive({
// categoryType: '', // 项目类别
@@ -341,6 +343,7 @@ const projectWithDepartment = (selectProjectIds, type) => {
watch(
() => transferValue.value,
(newValue) => {
if (isInitializing.value) return;
projectWithDepartment(newValue, 1);
}
);
@@ -377,7 +380,10 @@ const applyEditTransferSelection = () => {
}
}
const uniq = [...new Set(selectedIds)]
// 设置初始化标志,防止 transferValue 变化触发 projectWithDepartment 覆盖 descJson 中的科室值
isInitializing.value = true
transferValue.value = uniq
isInitializing.value = false
if (newData.requestFormDetailList.length && uniq.length === 0) {
console.warn(
'[LaboratoryTests] 申请单明细未能在项目字典中匹配到项,请核对 activityId / 项目名称',
@@ -427,7 +433,9 @@ watch(
selectedIds.push(matched.adviceDefinitionId);
}
});
isInitializing.value = true;
transferValue.value = selectedIds;
isInitializing.value = false;
}
);