动态table高度

This commit is contained in:
仲么了
2024-01-04 10:38:41 +08:00
parent 2bb7a82778
commit d4ee8e7821
5 changed files with 147 additions and 99 deletions

View File

@@ -2,7 +2,7 @@ import { reactive } from 'vue'
import createAxios from '@/utils/request'
import { requestPayload } from '@/utils/request'
import { Method } from 'axios'
import { mainHeight } from '@/utils/layout'
interface TableStoreParams {
url: string
pk?: string
@@ -10,6 +10,8 @@ interface TableStoreParams {
params?: anyObj
method?: Method
isWebPaging?: boolean // 是否前端分页
showPage?: boolean
publicHeight?: number
resetCallback?: () => void
loadCallback?: () => void
}
@@ -20,6 +22,7 @@ export default class TableStore {
public method: Method
public initData: any = null
public isWebPaging = false
public showPage = true
public table: CnTable = reactive({
ref: null,
selection: [],
@@ -33,7 +36,9 @@ export default class TableStore {
loading: true,
column: [],
loadCallback: null,
resetCallback: null
resetCallback: null,
height: mainHeight(20 + (this.showPage ? 58 : 0)).height as string,
publicHeight: 0
})
constructor(public options: TableStoreParams) {
@@ -42,6 +47,8 @@ export default class TableStore {
this.isWebPaging = options.isWebPaging || false
this.method = options.method || 'GET'
this.table.column = options.column
this.showPage = options.showPage || true
this.table.publicHeight = options.publicHeight || 0
this.table.resetCallback = options.resetCallback || null
this.table.loadCallback = options.loadCallback || null
Object.assign(this.table.params, options.params)