Skip to content

Commit 2342d1d

Browse files
committed
refactor(BaTable):优化公共搜索初始化逻辑、优化 getData 筛选条件设定
1 parent 26914d8 commit 2342d1d

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

web/src/utils/baTable.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,8 @@ export default class baTable {
316316
[
317317
'com-search',
318318
() => {
319-
this.table.filter!.search = this.getComSearchData()
319+
// 主动触发公共搜索,采用覆盖模式设定请求筛选数据
320+
this.setFilterSearchData(this.getComSearchData(), 'cover')
320321

321322
// 刷新表格
322323
this.onTableHeaderAction('refresh', { event: 'com-search', data: this.table.filter!.search })
@@ -491,15 +492,17 @@ export default class baTable {
491492
const route = useRoute()
492493
this.table.routePath = route.fullPath
493494

494-
// 初始化公共搜索表单数据和字段 Map
495-
this.initComSearch()
495+
// 按需初始化公共搜索表单数据和字段Map
496+
if (this.comSearch.fieldData.size === 0) {
497+
this.initComSearch()
498+
}
496499

497500
if (this.table.acceptQuery && !isEmpty(route.query)) {
498501
// 根据当前 URL 的 query 初始化公共搜索默认值
499502
this.setComSearchData(route.query)
500503

501504
// 获取公共搜索数据合并至表格筛选条件
502-
this.table.filter!.search = this.getComSearchData().concat(this.table.filter?.search ?? [])
505+
this.setFilterSearchData(this.getComSearchData(), 'merge')
503506
}
504507
}
505508

0 commit comments

Comments
 (0)