index.d.ts 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. import type { ElTable, ElTableColumn, TableColumnCtx } from 'element-plus/lib/components/table'
  2. // import type { ElTable, ElTableColumn, TableColumnCtx } from 'element-plus/es/components/table'
  3. export type LeColumnSlots = {
  4. // default?: ((scope: Record<string, any>) => any) | string
  5. // header?: ((scope: Record<string, any>) => any) | string
  6. default?: ((scope: { row; column; $index }) => HTMLDivElement | string) | string
  7. header?: ((scope: { column; $index }) => HTMLDivElement | string) | string
  8. }
  9. export type LeColumnProps = {
  10. // 多语言label转义字符
  11. t_label?: string
  12. // 插槽
  13. slots?: LeColumnSlots
  14. // 多级表头
  15. children?: LeTableColumnProps[]
  16. }
  17. /* Column */
  18. export type LeTableColumnProps = InstanceType<typeof ElTableColumn>['$props'] & LeColumnProps
  19. // Options 配置
  20. export type Options = {
  21. // el-table参数
  22. height?: string
  23. maxHeight?: string
  24. size?: string
  25. // 表格分页器 pageSizes (默认:[10, 20, 50, 100])
  26. pageSizes?: number[]
  27. // 表格分页器 layout (默认:'total, sizes, prev, pager, next, jumper')
  28. layout?: string
  29. // 表格分页器 背景 (默认:true)
  30. background?: boolean
  31. // 额外table参数
  32. // 表格loading (默认:false)
  33. loading?: boolean
  34. // 是否多选类型 (默认:false)
  35. multipleSelect?: boolean
  36. // 多选类型|(currentRowKey当前行选中key)选中标记唯一key (默认:'id') 【table $prop属性之一】
  37. rowKey?: (row) => any | string
  38. // 根据 该值 查找当前页面数据是否包含当前数据 添加 高亮状态 (默认:'id')
  39. currentRowKey?: string
  40. // table 默认 column 对齐方式 (默认:'center')
  41. align?: string
  42. // table 默认 column 是否允许拖动 (默认:true)
  43. resizable?: boolean
  44. // table 默认 column 是否允许拖动 (默认:true)
  45. showOverflowTooltip?: boolean
  46. // 是否展示数据序列号 (默认:true)
  47. showIndex?: boolean
  48. // 展示数据序列号_label (默认:'序号')
  49. indexLabel?: string
  50. // table 默认 column 是否允许拖动 (默认:true)
  51. showPagination?: boolean
  52. // 其他
  53. [key: string]: any
  54. }
  55. /* TableOptions */
  56. export type LeTableOptions = InstanceType<typeof ElTable>['$props'] & Options
  57. // TableProps
  58. export type LeTableProps = {
  59. // 数据列表
  60. list?: Record<string, any>[]
  61. // columns列表
  62. columns: LeTableColumnProps[]
  63. // 选中column的配置参数
  64. checkedOptions?: LeTableColumnProps[]
  65. // 自定义列配置相关
  66. columnsConfig?: {
  67. defaultCheckedOptions?: LeTableColumnProps[]
  68. columns?: LeTableColumnProps[]
  69. }
  70. // 搜索条件
  71. searchParams?: SearchParams
  72. // 数组总数
  73. total?: number
  74. // 表格的控制参数
  75. options?: LeTableOptions
  76. curRow?: { [key: string]: any } | null
  77. }
  78. /* TableActions */
  79. export type LeTableActions = {
  80. // reload: (opt?: FetchParams) => Promise<void>
  81. }
  82. export type SearchParams = {
  83. page: number
  84. pageSize: number
  85. [key: string]: any
  86. }
  87. export type RenderScope<T> = {
  88. row: T
  89. $index: number
  90. column: TableColumnCtx<T>
  91. [key: string]: any
  92. }