| import { TableProps } from 'antd'; |
| import type { TableColumnType } from 'antd'; |
| import { FRProps, FormInstance } from 'form-render'; |
| import type { ConfigProviderProps } from 'antd/es/config-provider'; |
| import type { TableRenderStoreType } from './core/store'; |
|
|
| export type ColumnsSettingValueType = Array<{ |
| |
| key: string, |
| |
| hidden: boolean, |
| |
| fixed?: 'right' | 'left' |
| }> |
|
|
| export type ToolbarActionConfig = { |
| |
| enabled?: Array<'refresh' | 'columnsSetting' | 'fullScreen' | 'density'>, |
| |
| columnsSettingValue?: ColumnsSettingValueType |
| |
| onColumnsSettingChange?: (val: ColumnsSettingValueType) => void; |
| } |
| export type DoSearchType = ( |
| params: { |
| current?: number; |
| tab?: number | string; |
| pageSize?: number; |
| sorter?: any; |
| }, |
| customSearch?: any |
| ) => Promise<void> |
|
|
| export type RefreshType = ( |
| params?: { stay?: boolean; tab?: number | string }, |
| search?: any |
| ) => Promise<void> |
|
|
| export type ChangeTabType = (tab: number | string) => Promise<void>; |
|
|
| export interface TableContext { |
| doSearch: DoSearchType, |
| refresh: RefreshType, |
| changeTab: ChangeTabType, |
| form: FormInstance, |
| getState: () => TableRenderStoreType & { search: Record<string, any> }, |
| } |
|
|
| export type ProColumnsType<T extends object = any> = Array< |
| TableColumnType<T> & { |
| dataIndex?: string; |
| |
| copyable?: boolean; |
| |
| valueType?: 'text' | 'money' | 'date' | 'dateTime' | 'code' | 'tag' | 'tags' | 'progress' | 'dateRange' | 'dateTimeRange' | 'image'; |
| |
| enum?: Record<string, string>; |
| } |
| >; |
|
|
| export interface TableState<RecordType> { |
| loading: boolean; |
| api: ApiType<RecordType>; |
| tab: number; |
| dataSource: Array<RecordType>; |
| extraData: any; |
| extraParams: Record<string, any>; |
| pagination: { |
| current: number; |
| pageSize: number; |
| total: number; |
| }; |
| tableSize: TableProps<any>['size']; |
| sorter: any; |
| } |
|
|
| |
| export interface SearchProps<RecordType> extends Omit<FRProps, 'form'> { |
| debug?: boolean; |
| searchBtnStyle?: React.CSSProperties; |
| searchBtnClassName?: string; |
| displayType?: any; |
| propsSchema?: any; |
| className?: string; |
| style?: React.CSSProperties; |
| hidden?: boolean; |
| searchOnMount?: boolean | unknown; |
| searchWithError?: boolean; |
| searchBtnRender?: ( |
| submit: Function, |
| clearSearch: Function, |
| other: any |
| ) => React.ReactNode[]; |
| searchText?: string; |
| resetText?: string; |
| onSearch?: (search: any) => any; |
| afterSearch?: (params: any) => any; |
| widgets?: any; |
| form?: any; |
| [key: string]: any |
| } |
|
|
| type ApiType<RecordType> = |
| | SearchApi<RecordType> |
| | Array<{ api: SearchApi<RecordType>; name: string }>; |
|
|
| export type SearchApi<RecordType> = ( |
| params: Record<string, any> & { |
| current: number; |
| pageSize: number; |
| tab?: number; |
| }, |
| sorter?: any |
| ) => Promise<{ |
|
|
| |
| |
| |
| rows?: Array<RecordType>; |
| data: Array<RecordType>; |
| total: number; |
| pageSize?: number; |
| }>; |
|
|
| export interface TablePropsC<RecordType extends Object = any> |
| extends Omit<TableProps<RecordType>, 'columns' | 'dataSource' | 'title'> { |
| |
| columns: ProColumnsType<RecordType>; |
| |
| title?: string | React.ReactNode; |
| } |
|
|
| export interface TableRenderProps<RecordType extends Object = any> |
| extends Omit<TablePropsC<RecordType>, 'locale'> { |
| |
| |
| |
| debug?: boolean; |
| |
| toolbarRender?: React.ReactNode; |
| |
| |
| |
| |
| |
| toolbarAction?: boolean | Pick<ToolbarActionConfig, 'enabled'>; |
| |
| pageChangeWithRequest?: boolean; |
| onTabChange?: () => any; |
| search?: SearchProps<RecordType>; |
| locale?: 'zh-CN' | 'en-US'; |
| |
| |
| |
| configProvider?: ConfigProviderProps; |
| |
| |
| |
| tableWrapper?: (tableNode: React.ReactNode) => React.ReactNode; |
| request?: ApiType<RecordType>; |
| |
| autoRequest?: boolean; |
| } |
|
|