Fix Bug #448: 门诊划价模块-项目分类过滤失效,选择"耗材"类型时仍能检索出药品
根因: adviceBaseList.vue 中 adviceQueryParams 的 watch 在 popoverVisible=false 时 直接 return,未将参数同步到 queryParams。当 handleFocus 同时修改 adviceQueryParams 和 showPopover 时,Vue 的 watch 触发顺序不确定: - 若 adviceQueryParams watch 先触发(popoverVisible 仍为 false),则 queryParams 保持旧值 - 随后 popoverVisible watch 触发时虽然会同步参数,但存在时序竞态导致查询参数不正确 修复: 将参数同步逻辑移至 early return 之前,确保 queryParams 始终与 adviceQueryParams 保持一致,API 请求仍在 popoverVisible=true 时才触发。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -69,13 +69,14 @@ const throttledGetList = throttle(
|
||||
watch(
|
||||
() => props.adviceQueryParams,
|
||||
(newValue) => {
|
||||
// 只有在弹窗打开时才响应 adviceQueryParams 的变化,避免选择项目后弹窗关闭时触发不必要的请求
|
||||
if (!props.popoverVisible) {
|
||||
return;
|
||||
}
|
||||
// 始终同步参数到 queryParams,避免弹窗打开时使用旧参数
|
||||
queryParams.value.searchKey = newValue?.searchKey;
|
||||
queryParams.value.adviceType = newValue?.adviceType;
|
||||
queryParams.value.categoryCode = newValue?.categoryCode;
|
||||
// 只有在弹窗打开时才触发 API 请求
|
||||
if (!props.popoverVisible) {
|
||||
return;
|
||||
}
|
||||
throttledGetList();
|
||||
},
|
||||
{ deep: true }
|
||||
|
||||
Reference in New Issue
Block a user