From 01f60513aeddaa5f8267147c98c08e5356dc1a7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=B3=E7=BE=BD?= <关羽@gentronhealth.com> Date: Wed, 13 May 2026 17:16:32 +0800 Subject: [PATCH] =?UTF-8?q?Fix=20Bug=20#463:=20[=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E7=AE=A1=E7=90=86-=E8=AF=8A=E7=96=97=E7=9B=AE=E5=BD=95]=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E/=E7=BC=96=E8=BE=91=E5=BC=B9=E7=AA=97?= =?UTF-8?q?=E4=B8=AD"=E8=AF=8A=E7=96=97=E5=AD=90=E9=A1=B9"=E6=A3=80?= =?UTF-8?q?=E7=B4=A2=E5=8A=9F=E8=83=BD=E5=A4=B1=E6=95=88=EF=BC=8C=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E6=90=9C=E5=88=B0=E5=B7=B2=E7=BB=B4=E6=8A=A4=E7=9A=84?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根因分析:medicineList.vue 的搜索功能仅做本地过滤,数据受限于初始加载的1000条(pageSize: 1000), 输入搜索关键词时不会向后端发起新的请求,导致不在前1000条内的项目无法被搜到。 修复策略: 1. medicineList.vue:当用户输入搜索关键词时,新增 searchList() 走服务端搜索(调用 API 的 searchKey 参数), 使用 pageSize: 5000 提高搜索覆盖率;搜索词清空时恢复使用预加载数据 2. 放宽 childrenJson 过滤条件,从严格的 == null 改为兼容空字符串(== null || === '') 3. 修复 diagnosisTreatmentDialog.vue 中 medicineList 的重复 import --- .../components/diagnosisTreatmentDialog.vue | 1 - .../components/medicineList.vue | 56 +++++++++++++++++-- 2 files changed, 52 insertions(+), 5 deletions(-) diff --git a/openhis-ui-vue3/src/views/catalog/diagnosistreatment/components/diagnosisTreatmentDialog.vue b/openhis-ui-vue3/src/views/catalog/diagnosistreatment/components/diagnosisTreatmentDialog.vue index bc6ba7b56..f24b2d348 100755 --- a/openhis-ui-vue3/src/views/catalog/diagnosistreatment/components/diagnosisTreatmentDialog.vue +++ b/openhis-ui-vue3/src/views/catalog/diagnosistreatment/components/diagnosisTreatmentDialog.vue @@ -372,7 +372,6 @@ import { } from './diagnosistreatment'; import PopoverList from '@/components/OpenHis/popoverList/index.vue'; import medicineList from './medicineList.vue'; -import MedicineList from '../components/medicineList.vue'; import {getCurrentInstance, nextTick, watch} from 'vue'; const { proxy } = getCurrentInstance(); 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 93d4f7582..9e79c4bcf 100755 --- a/openhis-ui-vue3/src/views/catalog/diagnosistreatment/components/medicineList.vue +++ b/openhis-ui-vue3/src/views/catalog/diagnosistreatment/components/medicineList.vue @@ -36,6 +36,7 @@ const emit = defineEmits(['selectRow']); const diagnosisTreatmentList = ref([]); // 原始数据列表 const filteredList = ref([]); // 过滤后的数据列表 const hasLoaded = ref(false); // 标记是否已加载数据 +const isLoading = ref(false); // 标记是否正在加载 // 获取诊疗项目列表 function getList() { @@ -53,7 +54,7 @@ function getList() { getDiagnosisTreatmentList({ statusEnum: 2, pageSize: 1000, pageNo: 1 }) .then((res) => { diagnosisTreatmentList.value = - res.data?.records?.filter((item) => item.childrenJson == null) || []; + res.data?.records?.filter((item) => item.childrenJson == null || item.childrenJson === '') || []; filterList(); // 初始化过滤 hasLoaded.value = true; // 标记为已加载 }) @@ -62,6 +63,47 @@ function getList() { }); } +// 服务端搜索(当用户输入搜索关键词时) +function searchList(searchKey) { + if (!searchKey || searchKey.trim() === '') return; + isLoading.value = true; + // 使用较大的pageSize确保搜索结果尽可能多 + getDiagnosisTreatmentList({ statusEnum: 2, searchKey: searchKey.trim(), pageSize: 5000, pageNo: 1 }) + .then((res) => { + diagnosisTreatmentList.value = + res.data?.records?.filter((item) => item.childrenJson == null || item.childrenJson === '') || []; + filterList(); + }) + .catch((err) => { + console.error('搜索诊疗项目数据失败:', err); + }) + .finally(() => { + isLoading.value = false; + }); +} + +// 获取预加载数据(不带搜索关键词时使用) +function loadPreloadedData() { + if (props.preloadedData && props.preloadedData.length > 0) { + diagnosisTreatmentList.value = props.preloadedData; + filterList(); + hasLoaded.value = true; + return; + } + + if (hasLoaded.value) return; + getDiagnosisTreatmentList({ statusEnum: 2, pageSize: 1000, pageNo: 1 }) + .then((res) => { + diagnosisTreatmentList.value = + res.data?.records?.filter((item) => item.childrenJson == null || item.childrenJson === '') || []; + filterList(); + hasLoaded.value = true; + }) + .catch((err) => { + console.error('获取诊疗项目数据失败:', err); + }); +} + // 监听shouldLoadData属性变化,仅在首次为true时加载数据 watch( () => props.shouldLoadData, @@ -86,11 +128,17 @@ watch( { immediate: true } ); -// 监听搜索关键词变化,实时过滤数据 +// 监听搜索关键词变化,有搜索词时走服务端搜索,否则走本地过滤 watch( () => props.searchKey, - () => { - filterList(); + (newVal) => { + if (newVal && newVal.trim() !== '') { + // 有搜索关键词,走服务端搜索 + searchList(newVal); + } else { + // 搜索词为空,使用预加载数据 + loadPreloadedData(); + } } );