Fix Bug #448: 门诊划价模块-项目分类过滤失效,选择"耗材"类型时仍能检索出药品

根因:getList() 直接发送 queryParams.value 到后端,其中包含 undefined 值的
属性(如 adviceType 未选择时)。后端接收 adviceType=null 后回退到查询所有类型
(List.of(1,2,3)),导致药品出现在耗材的搜索结果中。

修复:显式构建 requestParams 对象,仅包含已定义的过滤参数(adviceType、
categoryCode、searchKey),避免 undefined 值被发送到后端。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
荀彧
2026-05-14 00:20:09 +08:00
parent 53e3e9c4c0
commit 95da4c2a57

View File

@@ -115,22 +115,44 @@ function getList() {
console.log('[adviceBaseList] getList() 跳过:未选择患者');
return; // 不执行API调用
}
// 只有在弹窗打开时才执行查询
if (!props.popoverVisible) {
console.log('[adviceBaseList] getList() 跳过:弹窗未打开');
return;
}
queryParams.value.organizationId = props.patientInfo.orgId;
console.log('[adviceBaseList] getList() 请求参数:', JSON.stringify(queryParams.value));
getAdviceBaseInfo(queryParams.value).then((res) => {
// 🔧 Bug #448 修复:显式构建请求参数,确保 adviceType 正确传递
// 不直接使用 queryParams.value避免 undefined 值被发送到后端导致过滤失效
const requestParams = {
pageSize: queryParams.value.pageSize,
pageNum: queryParams.value.pageNum,
organizationId: props.patientInfo.orgId,
};
// 只在 adviceType 有值时添加0 是无效值undefined/null 会导致后端查询所有类型)
if (queryParams.value.adviceType != null && queryParams.value.adviceType !== 0) {
requestParams.adviceType = queryParams.value.adviceType;
}
// 只在 categoryCode 有值时添加
if (queryParams.value.categoryCode) {
requestParams.categoryCode = queryParams.value.categoryCode;
}
// 只在 searchKey 有值时添加
if (queryParams.value.searchKey) {
requestParams.searchKey = queryParams.value.searchKey;
}
console.log('[adviceBaseList] getList() 请求参数:', JSON.stringify(requestParams));
getAdviceBaseInfo(requestParams).then((res) => {
console.log('[adviceBaseList] getList() 响应数据:', {
total: res.data?.total,
recordsCount: res.data?.records?.length || 0,
firstRecord: res.data?.records?.[0]?.adviceName || '无数据',
adviceType: queryParams.value.adviceType
adviceType: requestParams.adviceType
});
adviceBaseList.value = res.data.records || [];
total.value = res.data.total || 0;