Compare commits

...

1 Commits

Author SHA1 Message Date
ibuler
200b83c105 perf: table search two times, one init one search 2024-07-10 19:50:10 +08:00
2 changed files with 31 additions and 2 deletions

View File

@@ -124,6 +124,9 @@ export default {
return this.iHasLeftActions ? 'right' : 'left' return this.iHasLeftActions ? 'right' : 'left'
} }
}, },
created() {
this.$emit('done')
},
methods: { methods: {
handleTagSearch(val) { handleTagSearch(val) {
this.searchTable(val) this.searchTable(val)

View File

@@ -8,9 +8,11 @@
:selected-rows="selectedRows" :selected-rows="selectedRows"
:table-url="tableUrl" :table-url="tableUrl"
v-bind="iHeaderActions" v-bind="iHeaderActions"
@done="handleActionInitialDone"
/> />
<IBox class="table-content"> <IBox class="table-content">
<AutoDataTable <AutoDataTable
v-if="actionInit"
ref="dataTable" ref="dataTable"
:config="iTableConfig" :config="iTableConfig"
:filter-table="filter" :filter-table="filter"
@@ -73,9 +75,11 @@ export default {
return { return {
selectedRows: [], selectedRows: [],
init: false, init: false,
extraQuery: extraQuery,
urlUpdated: {}, urlUpdated: {},
isDeactivated: false isDeactivated: false,
extraQuery: extraQuery,
actionInit: this.headerActions.has === false,
initQuery: {}
} }
}, },
computed: { computed: {
@@ -203,13 +207,35 @@ export default {
}, 500) }, 500)
}, },
methods: { methods: {
handleActionInitialDone() {
setTimeout(() => {
this.actionInit = true
}, 100)
},
handleSelectionChange(val) { handleSelectionChange(val) {
this.selectedRows = val this.selectedRows = val
}, },
reloadTable() { reloadTable() {
this.dataTable?.getList() this.dataTable?.getList()
}, },
updateInitQuery(attrs) {
if (!this.actionInit) {
this.initQuery = attrs
for (const key in attrs) {
this.$set(this.extraQuery, key, attrs[key])
}
return true
}
const removeKeys = Object.keys(this.initQuery).filter(key => !attrs[key])
for (const key of removeKeys) {
this.$delete(this.extraQuery, key)
}
},
search(attrs) { search(attrs) {
const init = this.updateInitQuery(attrs)
if (init) {
return
}
this.$log.debug('ListTable: search table', attrs) this.$log.debug('ListTable: search table', attrs)
this.$emit('TagSearch', attrs) this.$emit('TagSearch', attrs)
this.$refs.dataTable?.$refs.dataTable?.search(attrs, true) this.$refs.dataTable?.$refs.dataTable?.search(attrs, true)