电压暂降
This commit is contained in:
@@ -9,6 +9,7 @@ interface TableStoreParams {
|
||||
column: TableColumn[]
|
||||
params?: anyObj
|
||||
method?: Method
|
||||
isWebPaging?: boolean // 是否前端分页
|
||||
}
|
||||
|
||||
export default class TableStore {
|
||||
@@ -16,15 +17,16 @@ export default class TableStore {
|
||||
public pk
|
||||
public method: Method
|
||||
public initData: any = null
|
||||
|
||||
public isWebPaging = false
|
||||
public table: CnTable = reactive({
|
||||
ref: null,
|
||||
selection: [],
|
||||
data: [],
|
||||
webPagingData: [],
|
||||
total: 0,
|
||||
params: {
|
||||
pageNum: 1,
|
||||
pageSize: 10
|
||||
pageSize: 20
|
||||
},
|
||||
loading: true,
|
||||
column: []
|
||||
@@ -33,6 +35,7 @@ export default class TableStore {
|
||||
constructor(public options: TableStoreParams) {
|
||||
this.url = options.url
|
||||
this.pk = options.pk || 'id'
|
||||
this.isWebPaging = options.isWebPaging || false
|
||||
this.method = options.method || 'GET'
|
||||
this.table.column = options.column
|
||||
Object.assign(this.table.params, options.params)
|
||||
@@ -52,10 +55,12 @@ export default class TableStore {
|
||||
requestPayload(this.method, this.table.params)
|
||||
)
|
||||
).then((res: any) => {
|
||||
|
||||
this.table.data = res.data.records || res.data
|
||||
console.log(this.table.data)
|
||||
this.table.total = res.data.total || res.data.length
|
||||
if (this.isWebPaging) {
|
||||
this.table.webPagingData = window.XEUtils.chunk(this.table.data, this.table.params.pageSize)
|
||||
this.table.data = this.table.webPagingData[this.table.params.pageNum - 1]
|
||||
}
|
||||
this.table.loading = false
|
||||
})
|
||||
}
|
||||
@@ -91,14 +96,29 @@ export default class TableStore {
|
||||
[
|
||||
'page-size-change',
|
||||
() => {
|
||||
this.table.params!.pageSize = data.size
|
||||
this.table.params.pageSize = data.size
|
||||
this.table.params.pageNum = 1
|
||||
|
||||
if (this.isWebPaging) {
|
||||
this.table.webPagingData = window.XEUtils.chunk(
|
||||
window.XEUtils.flatten(this.table.webPagingData),
|
||||
this.table.params.pageSize
|
||||
)
|
||||
this.table.data = this.table.webPagingData[this.table.params.pageNum - 1]
|
||||
} else {
|
||||
this.index()
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
'current-page-change',
|
||||
() => {
|
||||
this.table.params!.pageNum = data.page
|
||||
this.index()
|
||||
this.table.params.pageNum = data.page
|
||||
if (this.isWebPaging) {
|
||||
this.table.data = this.table.webPagingData[data.page - 1]
|
||||
} else {
|
||||
this.index()
|
||||
}
|
||||
}
|
||||
],
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user