表格优化
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user