添加全局变量

This commit is contained in:
GGJ
2024-10-16 10:49:48 +08:00
parent 376f6cc31b
commit 89535b6059
11 changed files with 57 additions and 40 deletions

View File

@@ -6,16 +6,16 @@ import { mainHeight } from '@/utils/layout'
interface TableStoreParams {
url: string // 请求地址
pk?: string
pk?: string
column: TableColumn[]
params?: anyObj
method?: Method // 请求方式
params?: anyObj
method?: Method // 请求方式
isWebPaging?: boolean // 是否前端分页
showPage?: boolean //是否需要分页
paramsPOST?: boolean // post请求 params传参
publicHeight?: number //计算高度
resetCallback?: () => void // 重置
loadCallback?: () => void // 接口调用后的回调
loadCallback?: () => void // 接口调用后的回调
beforeSearchFun?: () => void // 接口调用前的回调
}
@@ -78,24 +78,28 @@ export default class TableStore {
},
requestPayload(this.method, this.table.params, this.paramsPOST)
)
).then((res: any) => {
if (res.data) {
this.table.data = res.data.records || res.data
this.table.total = res.data?.total || res.data.length || 0
} else {
this.table.data = []
this.table.total = 0
}
if (Array.isArray(res)) {
this.table.data = res
}
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.loadCallback && this.table.loadCallback()
this.table.loading = false
})
)
.then((res: any) => {
if (res.data) {
this.table.data = res.data.records || res.data
this.table.total = res.data?.total || res.data.length || 0
} else {
this.table.data = []
this.table.total = 0
}
if (Array.isArray(res)) {
this.table.data = res
}
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.loadCallback && this.table.loadCallback()
this.table.loading = false
})
.catch(() => {
this.table.loading = false
})
}
/**