Files
admin-govern/types/table.d.ts

113 lines
3.6 KiB
TypeScript
Raw Permalink Normal View History

2023-12-22 16:19:33 +08:00
import Table from '@/components/table/index.vue'
import { Component } from 'vue'
2024-01-18 18:19:59 +08:00
import type { VxeColumnProps, VxeTableInstance } from 'vxe-table'
2023-12-27 15:06:57 +08:00
import type { PopconfirmProps, ButtonType, ButtonProps } from 'element-plus'
2023-12-22 16:19:33 +08:00
import { Mutable } from 'element-plus/es/utils'
declare global {
interface CnTable {
2024-01-18 18:19:59 +08:00
ref: VxeTableInstance | null
2024-01-03 13:20:19 +08:00
data: TableRow[] | any
2024-12-26 15:56:32 +08:00
allData: TableRow[] | any
2025-11-14 15:00:10 +08:00
copyData: TableRow[] | any
2025-11-14 09:33:35 +08:00
filename: any
2024-12-26 15:56:32 +08:00
allFlag: Boolean
2023-12-28 09:59:28 +08:00
// 前端分页数据
webPagingData: TableRow[][]
2023-12-22 16:19:33 +08:00
// 表格加载状态
loading: boolean
// 当前选中行
selection: TableRow[]
// 表格列定义
column: TableColumn[]
// 数据总量
total: number
params: {
2023-12-28 09:59:28 +08:00
pageNum: number
pageSize: number
2023-12-22 16:19:33 +08:00
[key: string]: any
}
2024-01-04 10:38:41 +08:00
loadCallback: (() => void) | null
resetCallback: (() => void) | null
2024-01-17 09:53:00 +08:00
beforeSearchFun: (() => void) | null
2025-11-14 09:33:35 +08:00
exportProcessingData: (() => void) | null
2024-01-04 10:38:41 +08:00
height: string
publicHeight: number
2023-12-22 16:19:33 +08:00
}
/* 表格行 */
interface TableRow extends anyObj {
children?: TableRow[]
}
/* 表格列 */
2023-12-27 15:06:57 +08:00
interface TableColumn extends VxeColumnProps {
2023-12-22 16:19:33 +08:00
render?:
| 'icon'
| 'switch'
| 'image'
| 'tag'
| 'datetime'
| 'color'
| 'buttons'
| 'slot'
| 'customTemplate'
2025-11-14 09:33:35 +08:00
| 'renderFormatter'
2023-12-22 16:19:33 +08:00
| 'customRender'
// 默认值
default?: any
// 操作按钮组
buttons?: OptButton[]
// 自定义数据:比如渲染为Tag时,可以指定不同值时的Tag的Type属性 { open: 'success', close: 'info' }
custom?: any
// 值替换数据,如{open: '开'}
replaceValue?: any
2025-11-14 09:33:35 +08:00
effect?: any
2023-12-22 16:19:33 +08:00
// 时间格式化
timeFormat?: string
2025-11-14 09:33:35 +08:00
// 开关控制
onChangeField?: (row: TableRow, value: any) => void
activeValue?: string
inactiveValue?: string
activeText?: string
inactiveText?: string
2023-12-22 16:19:33 +08:00
// 自定义组件/函数渲染
customRender?: string | Component
// 使用了 render 属性时,渲染前对字段值的预处理方法,请返回新值
2023-12-28 11:27:03 +08:00
renderFormatter?: (row: TableRow, field: TableColumn, value: any, column: any, index: number) => any
2023-12-28 14:06:57 +08:00
// 自定义渲染模板方法可返回jsx内容
2023-12-22 16:19:33 +08:00
customTemplate?: (
row: TableRow,
field: TableColumn,
value: any,
2023-12-27 15:06:57 +08:00
column: VxeColumnProps,
2023-12-22 16:19:33 +08:00
index: number
) => string
2023-12-29 15:45:07 +08:00
children?: TableColumn[]
2025-11-14 09:33:35 +08:00
property?: string
clickable?: boolean // 是否可点击
2023-12-22 16:19:33 +08:00
}
/* 表格右侧操作按钮 */
interface OptButton {
// 渲染方式:tipButton=带tip的按钮,confirmButton=带确认框的按钮,moveButton=移动按钮,basicButton=普通按钮
render: 'tipButton' | 'confirmButton' | 'moveButton' | 'basicButton'
2024-01-25 16:42:56 +08:00
name?: string
2023-12-22 16:19:33 +08:00
title?: string
text?: string
class?: string
type: ButtonType
icon: string
popconfirm?: Partial<Mutable<PopconfirmProps>>
disabledTip?: boolean
// 自定义点击事件
click?: (row: TableRow, field: TableColumn) => void
2025-11-14 09:33:35 +08:00
2023-12-22 16:19:33 +08:00
// 按钮是否禁用,请返回布尔值
disabled?: (row: TableRow, field: TableColumn) => boolean
2025-11-14 09:33:35 +08:00
showDisabled?: (row: TableRow, field: TableColumn) => boolean
2023-12-22 16:19:33 +08:00
// 自定义el-button属性
attr?: Partial<Mutable<ButtonProps>>
}
}