|
@@ -0,0 +1,128 @@
|
|
|
|
|
+import type { ParamsType } from '@ant-design/pro-provider'
|
|
|
|
|
+import type { MainMenuKeyEnum, ColumnStateEnum } from '@/utils/cache/cacheEnum'
|
|
|
|
|
+import type {
|
|
|
|
|
+ ActionType,
|
|
|
|
|
+ ColumnsState,
|
|
|
|
|
+ ListToolBarProps,
|
|
|
|
|
+ ProColumns,
|
|
|
|
|
+ RequestData
|
|
|
|
|
+} from '@ant-design/pro-table'
|
|
|
|
|
+import type { AlertRenderType } from '@ant-design/pro-table/lib/components/Alert'
|
|
|
|
|
+import type { SearchConfig } from '@ant-design/pro-table/lib/components/Form/FormRender'
|
|
|
|
|
+import type { OptionConfig, ToolBarProps } from '@ant-design/pro-table/lib/components/ToolBar'
|
|
|
|
|
+import type { DensitySize } from '@ant-design/pro-table/lib/components/ToolBar/DensityIcon'
|
|
|
|
|
+import type { ProSchemaComponentTypes } from '@ant-design/pro-utils'
|
|
|
|
|
+import type { SpinProps, TableProps, CardProps } from 'antd'
|
|
|
|
|
+import type { LabelTooltipType } from 'antd/lib/form/FormItemLabel'
|
|
|
|
|
+import type { SortOrder } from 'antd/lib/table/interface'
|
|
|
|
|
+import type { ProFieldEmptyText } from '@ant-design/pro-field'
|
|
|
|
|
+import type { Bordered } from '@ant-design/pro-table/lib/typing'
|
|
|
|
|
+
|
|
|
|
|
+export type BasicTableProps<T, U extends ParamsType, ValueType = 'text'> = {
|
|
|
|
|
+ /** @type 枚举表中的菜单常量 */
|
|
|
|
|
+ mainMenuType?: MainMenuKeyEnum
|
|
|
|
|
+ /** @type 枚举表中的表格列常量 */
|
|
|
|
|
+ columnStateType?: ColumnStateEnum
|
|
|
|
|
+ columns?: ProColumns<T, ValueType>[]
|
|
|
|
|
+ /** @name ListToolBar 的属性 */
|
|
|
|
|
+ toolbar?: ListToolBarProps
|
|
|
|
|
+ params?: U
|
|
|
|
|
+ columnsStateMap?: Record<string, ColumnsState>
|
|
|
|
|
+ onColumnsStateChange?: (map: Record<string, ColumnsState>) => void
|
|
|
|
|
+ onSizeChange?: (size: DensitySize) => void
|
|
|
|
|
+ /** @name table 外面卡片的设置 */
|
|
|
|
|
+ cardProps?: CardProps
|
|
|
|
|
+ /** @name 渲染 table */
|
|
|
|
|
+
|
|
|
|
|
+ /** @name 一个获得 dataSource 的方法 */
|
|
|
|
|
+ request?: (
|
|
|
|
|
+ params: U & {
|
|
|
|
|
+ pageSize?: number
|
|
|
|
|
+ current?: number
|
|
|
|
|
+ keyword?: string
|
|
|
|
|
+ },
|
|
|
|
|
+ sort: Record<string, SortOrder>,
|
|
|
|
|
+ filter: Record<string, React.ReactText[] | null>
|
|
|
|
|
+ ) => Promise<Partial<RequestData<T>>>
|
|
|
|
|
+ /** @name 对数据进行一些处理 */
|
|
|
|
|
+ postData?: (data: any[]) => any[]
|
|
|
|
|
+ /** @name 默认的数据 */
|
|
|
|
|
+ defaultData?: T[]
|
|
|
|
|
+ /** @name 初始化的参数,可以操作 table */
|
|
|
|
|
+ actionRef?: React.MutableRefObject<ActionType | undefined> | ((actionRef: ActionType) => void)
|
|
|
|
|
+ /** @name 渲染操作栏 */
|
|
|
|
|
+ toolBarRender?: ToolBarProps<T>['toolBarRender'] | false
|
|
|
|
|
+ /** @name 数据加载完成后触发 */
|
|
|
|
|
+ onLoad?: (dataSource: T[]) => void
|
|
|
|
|
+ /** @name loading 被修改时触发,一般是网络请求导致的 */
|
|
|
|
|
+ onLoadingChange?: (loading: boolean | SpinProps | undefined) => void
|
|
|
|
|
+ /** @name 数据加载失败时触发 */
|
|
|
|
|
+ onRequestError?: (e: Error) => void
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 是否轮询 ProTable 它不会自动提交表单,如果你想自动提交表单的功能,需要在 onValueChange 中调用 formRef.current?.submit()
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param dataSource 返回当前的表单数据,你可以用它判断要不要打开轮询
|
|
|
|
|
+ */
|
|
|
|
|
+ polling?: number | ((dataSource: T[]) => number)
|
|
|
|
|
+ /** @name 给封装的 table 的 className */
|
|
|
|
|
+ tableClassName?: string
|
|
|
|
|
+ /** @name 给封装的 table 的 style */
|
|
|
|
|
+ tableStyle?: CSSProperties
|
|
|
|
|
+ /** @name 左上角的 title */
|
|
|
|
|
+ headerTitle?: React.ReactNode
|
|
|
|
|
+ /** @name 标题旁边的 tooltip */
|
|
|
|
|
+ tooltip?: string | LabelTooltipType
|
|
|
|
|
+ /** @name 操作栏配置 */
|
|
|
|
|
+ options?: OptionConfig | false
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @type SearchConfig
|
|
|
|
|
+ * @name 是否显示搜索表单
|
|
|
|
|
+ */
|
|
|
|
|
+ search?: false | SearchConfig
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 暂时只支持 moment - string 会格式化为 YYYY-DD-MM - number 代表时间戳
|
|
|
|
|
+ *
|
|
|
|
|
+ * @name 如何格式化日期
|
|
|
|
|
+ */
|
|
|
|
|
+ dateFormatter?: 'string' | 'number' | false
|
|
|
|
|
+ /** @name 格式化搜索表单提交数据 */
|
|
|
|
|
+ beforeSearchSubmit?: (params: Partial<U>) => any
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 设置或者返回false 即可关闭
|
|
|
|
|
+ *
|
|
|
|
|
+ * @name 自定义 table 的 alert
|
|
|
|
|
+ */
|
|
|
|
|
+ tableAlertRender?: AlertRenderType<T>
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 设置或者返回false 即可关闭
|
|
|
|
|
+ *
|
|
|
|
|
+ * @name 自定义 table 的 alert 的操作
|
|
|
|
|
+ */
|
|
|
|
|
+ tableAlertOptionRender?: AlertRenderType<T>
|
|
|
|
|
+ /** @name 选择项配置 */
|
|
|
|
|
+ rowSelection?: TableProps<T>['rowSelection'] | false
|
|
|
|
|
+ style?: React.CSSProperties
|
|
|
|
|
+ /** 支持 ProTable 的类型 */
|
|
|
|
|
+ type?: ProSchemaComponentTypes
|
|
|
|
|
+ /** @name 提交表单时触发 */
|
|
|
|
|
+ onSubmit?: (params: U) => void
|
|
|
|
|
+ /** @name 重置表单时触发 */
|
|
|
|
|
+ onReset?: () => void
|
|
|
|
|
+ /** @name 空值时显示 */
|
|
|
|
|
+ columnEmptyText?: ProFieldEmptyText
|
|
|
|
|
+ /** @name 是否手动触发请求 */
|
|
|
|
|
+ manualRequest?: boolean
|
|
|
|
|
+ /** @name 查询表单和 Table 的卡片 border 配置 */
|
|
|
|
|
+ cardBordered?: Bordered
|
|
|
|
|
+ /** Debounce time */
|
|
|
|
|
+ debounceTime?: number
|
|
|
|
|
+} & Omit<TableProps<T>, 'columns' | 'rowSelection'>
|
|
|
|
|
+
|
|
|
|
|
+declare const ProviderWarp: {
|
|
|
|
|
+ <T extends Record<string, any>, U extends ParamsType = ParamsType, ValueType = 'text'>(
|
|
|
|
|
+ props: BasicTableProps<T, U, ValueType>
|
|
|
|
|
+ ): JSX.Element
|
|
|
|
|
+ // eslint-disable-next-line @typescript-eslint/consistent-type-imports
|
|
|
|
|
+ Summary: typeof import('rc-table/lib/Footer/Summary').default
|
|
|
|
|
+}
|
|
|
|
|
+export default ProviderWarp
|