feat(advice): 添加药品库存过滤功能
- 在搜索结果中过滤掉无库存的药品项目 - 仅对药品类型(adviceType === 1)进行库存检查 - 计算库存总数量并过滤库存大于0的项目 - 保持非药品类型的原有搜索逻辑不变 - 优化代码缩进格式以提高可读性
This commit is contained in:
@@ -190,6 +190,19 @@ const filteredAdviceBaseList = computed(() => {
|
||||
).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;
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user