typing.d.ts 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. import type { ParamsType } from '@ant-design/pro-provider'
  2. import type { MainMenuKeyEnum, ColumnStateEnum } from '@/utils/cache/cacheEnum'
  3. import type {
  4. ActionType,
  5. ColumnsState,
  6. ListToolBarProps,
  7. ProColumns,
  8. RequestData
  9. } from '@ant-design/pro-table'
  10. import type { AlertRenderType } from '@ant-design/pro-table/lib/components/Alert'
  11. import type { SearchConfig } from '@ant-design/pro-table/lib/components/Form/FormRender'
  12. import type { OptionConfig, ToolBarProps } from '@ant-design/pro-table/lib/components/ToolBar'
  13. import type { DensitySize } from '@ant-design/pro-table/lib/components/ToolBar/DensityIcon'
  14. import type { ProSchemaComponentTypes } from '@ant-design/pro-utils'
  15. import type { SpinProps, TableProps, CardProps } from 'antd'
  16. import type { LabelTooltipType } from 'antd/lib/form/FormItemLabel'
  17. import type { SortOrder } from 'antd/lib/table/interface'
  18. import type { ProFieldEmptyText } from '@ant-design/pro-field'
  19. import type { Bordered } from '@ant-design/pro-table/lib/typing'
  20. import type { ReactNode } from 'react-router/node_modules/@types/react'
  21. export type BasicTableProps<T, U extends ParamsType, ValueType = 'text'> = {
  22. /** @name 配置search栏tooltip的title属性 */
  23. searchTooptip?: boolean | string | ReactNode
  24. /** @name 启用列可伸缩功能 */
  25. resizable?: boolean
  26. /** @type 枚举表中的菜单常量 */
  27. mainMenuType?: MainMenuKeyEnum
  28. /** @type 枚举表中的表格列常量 */
  29. columnStateType?: ColumnStateEnum
  30. columns?: ProColumns<T, ValueType>[]
  31. /** @name ListToolBar 的属性 */
  32. toolbar?: ListToolBarProps
  33. params?: U
  34. columnsStateMap?: Record<string, ColumnsState>
  35. onColumnsStateChange?: (map: Record<string, ColumnsState>) => void
  36. onSizeChange?: (size: DensitySize) => void
  37. /** @name table 外面卡片的设置 */
  38. cardProps?: CardProps
  39. /** @name 渲染 table */
  40. /** @name 一个获得 dataSource 的方法 */
  41. request?: (
  42. params: U & {
  43. pageSize?: number
  44. current?: number
  45. keyword?: string
  46. },
  47. sort: Record<string, SortOrder>,
  48. filter: Record<string, React.ReactText[] | null>
  49. ) => Promise<Partial<RequestData<T>>>
  50. /** @name 对数据进行一些处理 */
  51. postData?: (data: any[]) => any[]
  52. /** @name 默认的数据 */
  53. defaultData?: T[]
  54. /** @name 初始化的参数,可以操作 table */
  55. actionRef?: React.MutableRefObject<ActionType | undefined> | ((actionRef: ActionType) => void)
  56. /** @name 渲染操作栏 */
  57. toolBarRender?: ToolBarProps<T>['toolBarRender'] | false
  58. /** @name 数据加载完成后触发 */
  59. onLoad?: (dataSource: T[]) => void
  60. /** @name loading 被修改时触发,一般是网络请求导致的 */
  61. onLoadingChange?: (loading: boolean | SpinProps | undefined) => void
  62. /** @name 数据加载失败时触发 */
  63. onRequestError?: (e: Error) => void
  64. /**
  65. * 是否轮询 ProTable 它不会自动提交表单,如果你想自动提交表单的功能,需要在 onValueChange 中调用 formRef.current?.submit()
  66. *
  67. * @param dataSource 返回当前的表单数据,你可以用它判断要不要打开轮询
  68. */
  69. polling?: number | ((dataSource: T[]) => number)
  70. /** @name 给封装的 table 的 className */
  71. tableClassName?: string
  72. /** @name 给封装的 table 的 style */
  73. tableStyle?: CSSProperties
  74. /** @name 左上角的 title */
  75. headerTitle?: React.ReactNode
  76. /** @name 标题旁边的 tooltip */
  77. tooltip?: string | LabelTooltipType
  78. /** @name 操作栏配置 */
  79. options?: OptionConfig | false
  80. /**
  81. * @type SearchConfig
  82. * @name 是否显示搜索表单
  83. */
  84. search?: false | SearchConfig
  85. /**
  86. * 暂时只支持 moment - string 会格式化为 YYYY-DD-MM - number 代表时间戳
  87. *
  88. * @name 如何格式化日期
  89. */
  90. dateFormatter?: 'string' | 'number' | false
  91. /** @name 格式化搜索表单提交数据 */
  92. beforeSearchSubmit?: (params: Partial<U>) => any
  93. /**
  94. * 设置或者返回false 即可关闭
  95. *
  96. * @name 自定义 table 的 alert
  97. */
  98. tableAlertRender?: AlertRenderType<T>
  99. /**
  100. * 设置或者返回false 即可关闭
  101. *
  102. * @name 自定义 table 的 alert 的操作
  103. */
  104. tableAlertOptionRender?: AlertRenderType<T>
  105. /** @name 选择项配置 */
  106. rowSelection?: TableProps<T>['rowSelection'] | false
  107. style?: React.CSSProperties
  108. /** 支持 ProTable 的类型 */
  109. type?: ProSchemaComponentTypes
  110. /** @name 提交表单时触发 */
  111. onSubmit?: (params: U) => void
  112. /** @name 重置表单时触发 */
  113. onReset?: () => void
  114. /** @name 空值时显示 */
  115. columnEmptyText?: ProFieldEmptyText
  116. /** @name 是否手动触发请求 */
  117. manualRequest?: boolean
  118. /** @name 查询表单和 Table 的卡片 border 配置 */
  119. cardBordered?: Bordered
  120. /** Debounce time */
  121. debounceTime?: number
  122. } & Omit<TableProps<T>, 'columns' | 'rowSelection'>
  123. declare const ProviderWarp: {
  124. <T extends Record<string, any>, U extends ParamsType = ParamsType, ValueType = 'text'>(
  125. props: BasicTableProps<T, U, ValueType>
  126. ): JSX.Element
  127. // eslint-disable-next-line @typescript-eslint/consistent-type-imports
  128. Summary: typeof import('rc-table/lib/Footer/Summary').default
  129. }
  130. export default ProviderWarp