diff --git a/openhis-ui-vue3/src/views/catalog/diagnosistreatment/components/medicineList.vue b/openhis-ui-vue3/src/views/catalog/diagnosistreatment/components/medicineList.vue index 9e79c4bcf..26367a32c 100755 --- a/openhis-ui-vue3/src/views/catalog/diagnosistreatment/components/medicineList.vue +++ b/openhis-ui-vue3/src/views/catalog/diagnosistreatment/components/medicineList.vue @@ -38,6 +38,9 @@ const filteredList = ref([]); // 过滤后的数据列表 const hasLoaded = ref(false); // 标记是否已加载数据 const isLoading = ref(false); // 标记是否正在加载 +// 标记是否正在执行搜索(用于防止 preloadedData 覆盖搜索结果) +const isSearching = ref(false); + // 获取诊疗项目列表 function getList() { if (hasLoaded.value) return; // 如果已经加载过数据,则不再重复请求 @@ -66,6 +69,7 @@ function getList() { // 服务端搜索(当用户输入搜索关键词时) function searchList(searchKey) { if (!searchKey || searchKey.trim() === '') return; + isSearching.value = true; isLoading.value = true; // 使用较大的pageSize确保搜索结果尽可能多 getDiagnosisTreatmentList({ statusEnum: 2, searchKey: searchKey.trim(), pageSize: 5000, pageNo: 1 }) @@ -79,6 +83,7 @@ function searchList(searchKey) { }) .finally(() => { isLoading.value = false; + isSearching.value = false; }); } @@ -119,6 +124,8 @@ watch( watch( () => props.preloadedData, (newData) => { + // 正在搜索时跳过,避免覆盖searchList的搜索结果 + if (isSearching.value) return; if (newData && newData.length > 0) { diagnosisTreatmentList.value = newData; filterList(); // 更新过滤