修改 测试bug
This commit is contained in:
@@ -5,17 +5,18 @@ import { Method } from 'axios'
|
||||
import { mainHeight } from '@/utils/layout'
|
||||
|
||||
interface TableStoreParams {
|
||||
url: string
|
||||
pk?: string
|
||||
url: string // 请求地址
|
||||
pk?: string
|
||||
column: TableColumn[]
|
||||
params?: anyObj
|
||||
method?: Method
|
||||
params?: anyObj
|
||||
method?: Method // 请求方式
|
||||
isWebPaging?: boolean // 是否前端分页
|
||||
showPage?: boolean
|
||||
publicHeight?: number
|
||||
resetCallback?: () => void
|
||||
loadCallback?: () => void
|
||||
beforeSearchFun?: () => void
|
||||
showPage?: boolean //是否需要分页
|
||||
paramsPOST?: boolean // post请求 params传参
|
||||
publicHeight?: number //计算高度
|
||||
resetCallback?: () => void // 重置
|
||||
loadCallback?: () => void // 接口调用后的回调
|
||||
beforeSearchFun?: () => void // 接口调用前的回调
|
||||
}
|
||||
|
||||
export default class TableStore {
|
||||
@@ -24,6 +25,7 @@ export default class TableStore {
|
||||
public method: Method
|
||||
public initData: any = null
|
||||
public isWebPaging = false
|
||||
public paramsPOST = true
|
||||
public showPage = true
|
||||
public table: CnTable = reactive({
|
||||
ref: null,
|
||||
@@ -47,6 +49,7 @@ export default class TableStore {
|
||||
constructor(public options: TableStoreParams) {
|
||||
this.url = options.url
|
||||
this.pk = options.pk || 'id'
|
||||
this.paramsPOST = options.paramsPOST || false
|
||||
this.isWebPaging = options.isWebPaging || false
|
||||
this.method = options.method || 'GET'
|
||||
this.table.column = options.column
|
||||
@@ -73,12 +76,12 @@ export default class TableStore {
|
||||
url: this.url,
|
||||
method: this.method
|
||||
},
|
||||
requestPayload(this.method, this.table.params)
|
||||
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
|
||||
this.table.total = res.data?.total || res.data.length || 0
|
||||
} else {
|
||||
this.table.data = []
|
||||
this.table.total = 0
|
||||
|
||||
Reference in New Issue
Block a user