index.ts 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import { TableColumnCtx } from 'element-plus/es/components/table/src/table-column/defaults'
  2. export interface EnumProps {
  3. label: string // 选项框显示的文字
  4. value: any // 选项框值
  5. disabled?: boolean // 是否禁用此选项
  6. tagType?: string // 当 tag 为 true 时,此选择会指定 tag 显示类型
  7. children?: EnumProps[] // 为树形选择时,可以通过 children 属性指定子选项
  8. [key: string]: any
  9. }
  10. export type SearchType =
  11. | 'input'
  12. | 'input-number'
  13. | 'select'
  14. | 'select-v2'
  15. | 'tree-select'
  16. | 'cascader'
  17. | 'date-picker'
  18. | 'time-picker'
  19. | 'time-select'
  20. | 'switch'
  21. | 'slider'
  22. export type SearchProps = {
  23. el: SearchType // 当前项搜索框的类型
  24. props?: any // 搜索项参数,根据 element plus 官方文档来传递,该属性所有值会透传到组件
  25. key?: string // 当搜索项 key 不为 prop 属性时,可通过 key 指定
  26. order?: number // 搜索项排序(从大到小)
  27. span?: number // 搜索项所占用的列数,默认为1列
  28. offset?: number // 搜索字段左侧偏移列数
  29. defaultValue?: string | number | boolean | any[] // 搜索项默认值
  30. }
  31. export interface ColumnProps<T = any>
  32. extends Partial<Omit<TableColumnCtx<T>, 'children' | 'renderHeader' | 'renderCell'>> {
  33. tag?: boolean // 是否是标签展示
  34. isShow?: boolean // 是否显示在表格当中
  35. search?: SearchProps | undefined // 搜索项配置
  36. // enum?: EnumProps[] | ((params?: any) => Promise<any>) // 枚举类型(渲染值的字典)
  37. isFilterEnum?: boolean // 当前单元格值是否根据 enum 格式化(示例:enum 只作为搜索项数据)
  38. fieldNames?: { label: string; value: string } // 指定 label && value 的 key 值
  39. headerRender?: (row: ColumnProps) => any // 自定义表头内容渲染(tsx语法)
  40. render?: (scope: { row: T }) => any // 自定义单元格内容渲染(tsx语法)
  41. name?: string
  42. ellipsis?: boolean
  43. _children?: ColumnProps<T>[] // 多级表头
  44. }