From 04ad139eae2006a3bbf6df7c11c82a7810128a30 Mon Sep 17 00:00:00 2001 From: chenqi Date: Mon, 2 Mar 2026 11:38:34 +0800 Subject: [PATCH] =?UTF-8?q?feat(advice):=20=E6=B7=BB=E5=8A=A0=E8=8D=AF?= =?UTF-8?q?=E5=93=81=E5=BA=93=E5=AD=98=E8=BF=87=E6=BB=A4=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在搜索结果中过滤掉无库存的药品项目 - 仅对药品类型(adviceType === 1)进行库存检查 - 计算库存总数量并过滤库存大于0的项目 - 保持非药品类型的原有搜索逻辑不变 - 优化代码缩进格式以提高可读性 --- .../components/adviceBaseList.vue | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/openhis-ui-vue3/src/views/doctorstation/components/adviceBaseList.vue b/openhis-ui-vue3/src/views/doctorstation/components/adviceBaseList.vue index 6c8b91a4..f2625966 100644 --- a/openhis-ui-vue3/src/views/doctorstation/components/adviceBaseList.vue +++ b/openhis-ui-vue3/src/views/doctorstation/components/adviceBaseList.vue @@ -182,14 +182,27 @@ const filteredAdviceBaseList = computed(() => { if (!props.adviceQueryParams.searchKey) { result = adviceBaseList.value.slice(0, 50); // 返回前50个常用项目 } else { - const searchKey = props.adviceQueryParams.searchKey.toLowerCase(); + const searchKey = props.adviceQueryParams.searchKey.toLowerCase(); result = adviceBaseList.value.filter(item => - item.adviceName.toLowerCase().includes(searchKey) || - item.py_str?.toLowerCase().includes(searchKey) || - item.wb_str?.toLowerCase().includes(searchKey) - ).slice(0, 100); // 限制返回数量 + item.adviceName.toLowerCase().includes(searchKey) || + item.py_str?.toLowerCase().includes(searchKey) || + item.wb_str?.toLowerCase().includes(searchKey) + ).slice(0, 100); // 限制返回数量 } - + + // 过滤无库存的药品(只针对药品类型 adviceType === 1) + result = result.filter(item => { + if (item.adviceType === 1) { + // 检查是否有库存 + if (item.inventoryList && item.inventoryList.length > 0) { + const totalQuantity = item.inventoryList.reduce((sum, inv) => sum + (inv.quantity || 0), 0); + return totalQuantity > 0; + } + return false; // 无库存列表或库存为空,视为无库存 + } + return true; // 非药品类型不过滤 + }); + return result; });