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
|
|
|
|
|
|
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
|
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'
|
|
|
|
|
|
| 'customRender'
|
|
|
|
|
|
// 默认值
|
|
|
|
|
|
default?: any
|
|
|
|
|
|
// 操作按钮组
|
|
|
|
|
|
buttons?: OptButton[]
|
|
|
|
|
|
// 自定义数据:比如渲染为Tag时,可以指定不同值时的Tag的Type属性 { open: 'success', close: 'info' }
|
|
|
|
|
|
custom?: any
|
|
|
|
|
|
// 值替换数据,如{open: '开'}
|
|
|
|
|
|
replaceValue?: any
|
|
|
|
|
|
// 时间格式化
|
|
|
|
|
|
timeFormat?: string
|
2024-11-27 16:01:08 +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[]
|
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
|
2024-10-31 14:36:09 +08:00
|
|
|
|
loading?: string
|
2023-12-22 16:19:33 +08:00
|
|
|
|
type: ButtonType
|
|
|
|
|
|
icon: string
|
|
|
|
|
|
popconfirm?: Partial<Mutable<PopconfirmProps>>
|
|
|
|
|
|
disabledTip?: boolean
|
|
|
|
|
|
// 自定义点击事件
|
|
|
|
|
|
click?: (row: TableRow, field: TableColumn) => void
|
|
|
|
|
|
// 按钮是否禁用,请返回布尔值
|
|
|
|
|
|
disabled?: (row: TableRow, field: TableColumn) => boolean
|
|
|
|
|
|
// 自定义el-button属性
|
|
|
|
|
|
attr?: Partial<Mutable<ButtonProps>>
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|