表格优化

This commit is contained in:
仲么了
2023-12-27 10:39:40 +08:00
parent e1299a5520
commit d42936398e
6 changed files with 232 additions and 61 deletions

View File

@@ -15,6 +15,8 @@ export default class TableStore {
public url
public pk
public method: Method
public initData: any = null
public table: CnTable = reactive({
ref: null,
selection: [],
@@ -37,6 +39,10 @@ export default class TableStore {
}
index() {
// 重置用的数据数据
if (!this.initData) {
this.initData = JSON.parse(JSON.stringify(this.table.params))
}
createAxios(
Object.assign(
{
@@ -59,6 +65,21 @@ export default class TableStore {
*/
onTableAction = (event: string, data: anyObj) => {
const actionFun = new Map([
[
'search',
() => {
this.table.params.pageNum = 1
this.index()
}
],
[
'reset',
() => {
delete this.initData.pageSize
Object.assign(this.table.params, this.initData)
this.index()
}
],
[
'selection-change',
() => {
@@ -91,7 +112,6 @@ export default class TableStore {
}
]
])
const action = actionFun.get(event) || actionFun.get('default')
action!.call(this)
}