fix: 修复客商档案清空客商风险后仍按上次条件查询
Avue 搜索事件只回传非空筛选项,被清空的字段不会出现在参数里, 与上一次查询条件合并会保留旧值,改为点击查询时整体重建查询条件。
This commit is contained in:
@@ -5519,7 +5519,9 @@ export default {
|
||||
this.onLoad(this.page);
|
||||
},
|
||||
searchChange(params, done) {
|
||||
this.query = this.buildQuery(params);
|
||||
// Avue 只回传非空筛选项,被清空的字段不会出现在 params 里,
|
||||
// 因此查询条件必须整体重建,不能与上一次的 this.query 合并,否则清空后仍会带上次的值
|
||||
this.query = this.buildQuery(params, true);
|
||||
this.page.currentPage = 1;
|
||||
this.onLoad(this.page, this.query);
|
||||
done();
|
||||
@@ -5611,9 +5613,10 @@ export default {
|
||||
[this.website.tokenHeader]: getToken(),
|
||||
};
|
||||
},
|
||||
buildQuery(params = {}) {
|
||||
// 新条件覆盖旧条件;本次显式清空的字段必须从查询里去掉,避免第二次搜索仍带着上一次的客商名称。
|
||||
const merged = { ...this.query, ...params };
|
||||
// replace=true 表示以本次搜索条件为准整体重建(清空字段不会回传,需丢弃旧条件);
|
||||
// 翻页、刷新等场景传 false,沿用上一次的查询条件
|
||||
buildQuery(params = {}, replace = false) {
|
||||
const merged = replace ? { ...params } : { ...this.query, ...params };
|
||||
Object.keys(params).forEach(key => {
|
||||
const value = params[key];
|
||||
if (
|
||||
|
||||
Reference in New Issue
Block a user