Fix Bug #463: [目录管理-诊疗目录] 新增/编辑弹窗中"诊疗子项"检索功能失效,无法搜到已维护的项目
根因:medicineList.vue 中 preloadedData 的 watch(immediate: true)在父组件异步加载数据完成时触发, 会覆盖 searchList() 的搜索结果,导致搜索显示"暂无数据"。 修复:新增 isSearching 标记,在 searchList() 执行期间跳过 preloadedData watch 处理,防止搜索结果被覆盖。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -38,6 +38,9 @@ const filteredList = ref([]); // 过滤后的数据列表
|
|||||||
const hasLoaded = ref(false); // 标记是否已加载数据
|
const hasLoaded = ref(false); // 标记是否已加载数据
|
||||||
const isLoading = ref(false); // 标记是否正在加载
|
const isLoading = ref(false); // 标记是否正在加载
|
||||||
|
|
||||||
|
// 标记是否正在执行搜索(用于防止 preloadedData 覆盖搜索结果)
|
||||||
|
const isSearching = ref(false);
|
||||||
|
|
||||||
// 获取诊疗项目列表
|
// 获取诊疗项目列表
|
||||||
function getList() {
|
function getList() {
|
||||||
if (hasLoaded.value) return; // 如果已经加载过数据,则不再重复请求
|
if (hasLoaded.value) return; // 如果已经加载过数据,则不再重复请求
|
||||||
@@ -66,6 +69,7 @@ function getList() {
|
|||||||
// 服务端搜索(当用户输入搜索关键词时)
|
// 服务端搜索(当用户输入搜索关键词时)
|
||||||
function searchList(searchKey) {
|
function searchList(searchKey) {
|
||||||
if (!searchKey || searchKey.trim() === '') return;
|
if (!searchKey || searchKey.trim() === '') return;
|
||||||
|
isSearching.value = true;
|
||||||
isLoading.value = true;
|
isLoading.value = true;
|
||||||
// 使用较大的pageSize确保搜索结果尽可能多
|
// 使用较大的pageSize确保搜索结果尽可能多
|
||||||
getDiagnosisTreatmentList({ statusEnum: 2, searchKey: searchKey.trim(), pageSize: 5000, pageNo: 1 })
|
getDiagnosisTreatmentList({ statusEnum: 2, searchKey: searchKey.trim(), pageSize: 5000, pageNo: 1 })
|
||||||
@@ -79,6 +83,7 @@ function searchList(searchKey) {
|
|||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
isLoading.value = false;
|
isLoading.value = false;
|
||||||
|
isSearching.value = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,6 +124,8 @@ watch(
|
|||||||
watch(
|
watch(
|
||||||
() => props.preloadedData,
|
() => props.preloadedData,
|
||||||
(newData) => {
|
(newData) => {
|
||||||
|
// 正在搜索时跳过,避免覆盖searchList的搜索结果
|
||||||
|
if (isSearching.value) return;
|
||||||
if (newData && newData.length > 0) {
|
if (newData && newData.length > 0) {
|
||||||
diagnosisTreatmentList.value = newData;
|
diagnosisTreatmentList.value = newData;
|
||||||
filterList(); // 更新过滤
|
filterList(); // 更新过滤
|
||||||
|
|||||||
Reference in New Issue
Block a user