跳到主要内容

SettingProvider - 组件默认设置

为组件提供统一的默认设置,在外围包裹一次即可全局生效。

SchemaForm​

比如可以统一配置 SchemaForm 默认的验证提示语。

ModalForm​

比如可以统一配置弹窗表单的默认布局。

或者可以统一配置弹窗表单的默认宽度。

ProTable​

比如可以统一配置分页选项。

用户列表
用户名电话昵称性别创建日期操作
暂无数据
暂无数据

或者统一配置搜索区域。

用户列表
用户名电话昵称性别创建日期操作
暂无数据
暂无数据

或者统一配置表格大小。

用户列表
用户名电话昵称性别创建日期操作
暂无数据
暂无数据

FormUpload​

可以在这里统一设置 action, header, children, responseToFileList 等属性。

API​

SettingProvider​

属性名描述类型默认值
locale语言包配置-zhCN
schemaFormSettingSchemaForm组件的设置项-
modalFormSettingModalForm 组件的设置项-
proTableSettingProTable组件的设置项-
formUploadSettingFormUpload组件的设置项-

SchemaFormSettingProps​

属性名描述类型默认值
name--string--
initialValues--Store--
component--string | false | FC<any> | ComponentClass<any, any>--
fields--FieldData<any>[]--
validateMessages--ValidateMessages--
onValuesChange--((changedValues: Partial<Record<string, any>>, values: Record<string, any>) => void)--
onFieldsChange--((changedFields: FieldData<any>[], allFields: FieldData<any>[]) => void)--
onFinishFailed--((errorInfo: ValidateErrorEntity<Record<string, any>>) => void)--
validateTrigger--string | false | string[]--
preserve--boolean--
clearOnDestroy--boolean--
classNames--FormClassNamesType--
styles--FormStylesType--
prefixCls--string--
colon--boolean--
layout--FormLayout--
labelAlign--FormLabelAlign--
labelWrap--boolean--
labelCol--ColProps--
wrapperCol--ColProps--
feedbackIcons--FeedbackIcons--
size--SizeType--
disabled--boolean--
scrollToFirstError--boolean | ScrollFocusOptions--
requiredMark--RequiredMark--
rootClassName--string--
variant--"outlined" | "borderless" | "filled" | "underlined"--
submitter提交按钮相关配置.boolean | SubmitterProps & { style: React.CSSProperties }false
loading表单按钮的 loading 状态boolean--
onLoadingChange这是一个可选的属性(onLoadingChange),它接受一个名为loading的参数,类型为boolean,表示加载状态是否改变。((loading: boolean) => void)--
syncToUrl同步结果到 url 中boolean | ((values: Record<string, any>, type: "get" | "set") => Record<string, any>)--
syncToUrlAsImportant当 syncToUrl 为 true,在页面回显示时,以url上的参数为主,默认为falseboolean--
extraUrlParams额外的 url 参数 中Record<string, any>--
syncToInitialValues同步结果到 initialValues,默认为true如果为false,reset的时将会忽略从url上获取的数据boolean--
omitNil如果为 false,会原样保存。booleantrue
dateFormatter格式化 Date 的方式,默认转化为 stringfalse | "string" | "number" | (string & {}) | ((value: Dayjs, valueType: string) => string | number)--
onInit表单初始化成功,比如布局,label等计算完成((values: Record<string, any>, form: ProFormInstance<any>) => void)--
params发起网络请求的参数Record<string, any>--
request发起网络请求的参数,返回值会覆盖给 initialValuesProRequestData<Record<string, any>, Record<string, any>>--
isKeyPressSubmit是否回车提交boolean--
formKey用于控制form 是否相同的key,高阶用法string--
autoFocusFirstInput--boolean--
readonly是否为只读模式booleanfalse
gridopen grid layoutbooleanfalse
colPropsonly works when grid is enabledColProps{ xs: 24 }
rowPropsonly works when grid is enabledRowProps{ gutter: 8 }
embed是否为内嵌模式booleanfalse
valueBaseName开启embed后处理套嵌数据结构; 在onFinish收集数据时, 会挂在该字段下. 仅适用于embed模式stringfalse
readonlyType只读时的展示形式。可选 form 或 descriptions"form" | "descriptions"form
descriptionsProps描述模式下的表格样式配置
Omit<DescriptionsProps, 'items' | 'columns'>
--

ModalFormSettingProps​

属性名描述类型默认值
className--string--
style--CSSProperties--
titleThe modal dialog's titleReactNode--
classNames--ModalClassNamesType--
styles--ModalStylesType--
prefixCls--string--
rootClassName--string--
loading5.18.0boolean--
footer--ReactNode | ((originNode: ReactNode, extra: { OkBtn: FC<{}>; CancelBtn: FC<{}>; }) => ReactNode)--
widthWidth of the modal dialogstring | number | Partial<Record<Breakpoint, string | number>>--
transitionName--string--
maskTransitionName--string--
mask--MaskType--
focusTriggerAfterClosePlease use `focusable.focusTriggerAfterClose` insteadboolean--
keyboard--boolean--
rootStyle--CSSProperties--
afterClose--(() => void)--
afterOpenChangeCallback when the animation ends when Modal is turned on and off((open: boolean) => void)--
closable--boolean | (ClosableType & AriaAttributes & { onClose?: (() => void); afterClose?: (() => void) | undefined; }) | undefined--
maskClosableWhether to close the modal dialog when the mask (area outside the modal) is clickedboolean--
visible--boolean--
destroyOnHidden5.25.0boolean--
mousePosition--MousePosition--
wrapStyle--Record<string, any>--
bodyStylePlease use `styles.body` insteadCSSProperties--
maskStylePlease use `styles.mask` insteadCSSProperties--
wrapClassName--string--
height--string | number--
zIndex--number--
bodyProps--any--
maskProps--any--
wrapProps--any--
getContainer--string | false | HTMLElement | getContainerFunc--
closeIcon--ReactNode--
modalRender--((node: ReactNode) => ReactNode)--
forceRenderForce render Modalboolean--
panelRef--Ref<HTMLDivElement>--
openWhether the modal dialog is visible or notboolean--
confirmLoadingWhether to apply loading visual effect for OK button or notboolean--
onCancelSpecify a function that will be called when a user clicks mask, close button on top right or Cancel button((e: MouseEvent<HTMLButtonElement, MouseEvent>) => void)--
centeredCentered Modalboolean--
okTextText of the OK buttonReactNode--
okTypeButton `type` of the OK buttonLegacyButtonType--
cancelTextText of the Cancel buttonReactNode--
okButtonProps--ButtonProps--
cancelButtonProps--ButtonProps--
destroyOnClosePlease use `destroyOnHidden` insteadboolean--
focusable--FocusableConfig--
onOpen打开弹框后的回调, 可以在这里请求数据;(formType, formRef, formData) => Promise | void--
formProps传递给表单的参数, 请参考SchemaForm组件的apiOmit<SchemaFormProps, 'innerRef' | 'formRef' | 'onFinish' | 'columns' | 'form'>--
confirmOnClose关闭弹窗提醒, 当表单项发生改动时会弹出确认框boolean | { title?: string; content?: string }{ title: '确认关闭', content: '表单项内容未保存, 是否确认关闭?' }

ProTableSettingProps​

属性名描述类型默认值
name用于 table 的 headerTitle 的显示, 还有弹出框的 title 显示; 可以配合 locale 修改文案。string--
className--string--
id--string--
style--CSSProperties--
title--PanelRender<any>--
onChange--((pagination: TablePaginationConfig, filters: Record<string, FilterValue | null>, sorter: SorterResult<any> | SorterResult<...>[], extra: TableCurrentDataSource<...>) => void)--
onReset重置表单时触发(() => void)--
onLoad数据加载完成后触发((dataSource: any[]) => void)--
onScroll--UIEventHandler<HTMLDivElement>--
classNames--TableClassNamesType<any>--
styles--TableStylesType<any>--
prefixCls--string--
size--SizeType--
rootClassName--string--
loading--boolean | SpinProps--
onLoadingChangeloading 被修改时触发,一般是网络请求导致的((loading: boolean | SpinProps) => void) | undefined--
formRef操作自带的 formMutableRefObject<ProFormInstance> | undefined--
dateFormatter暂时只支持 dayjs - string 会格式化为 YYYY-DD-MM - number 代表时间戳false | "string" | "number" | (string & {}) | ((value: Dayjs, valueType: string) => string | number)--
paramsrequest 的参数,修改之后会触发更新any--
footer--PanelRender<any>--
onOpen打开弹框后的回调, 可以在这里请求数据;(formType, formRef, formData) => Promise | void--
rowSelection选择项配置false | (TableRowSelection<any> & { alwaysShowAlert?: boolean; }) | undefined--
scroll--({ x?: string | number | true; y?: string | number | undefined; } & { scrollToFirstRowOnChange?: boolean | undefined; }) | undefined--
indentSize--number--
rowKey--string | number | symbol | GetRowKey<any>--
tableLayout--TableLayout--
expandableConfig expand rowsExpandableConfig<any>--
rowClassName--string | RowClassName<any>--
summary--((data: readonly any[]) => ReactNode)--
caption--ReactNode--
showHeader--boolean--
components--TableComponents<any>--
onRow--GetComponentProps<any>--
onHeaderRow--GetComponentProps<readonly ColumnType<any>[]>--
direction--Direction--
sticky--boolean | TableSticky--
rowHoverable--boolean--
measureRowRenderInternal usage, may remove by refactor.((measureRow: ReactNode) => ReactNode)--
dropdownPrefixCls--string--
dataSource--readonly any[]--
pagination--false | TablePaginationConfig--
bordered--boolean--
locale--TableLocale--
getPopupContainer--GetPopupContainer--
sortDirections--SortOrder[]--
showSorterTooltip--boolean | SorterTooltipProps--
virtual--boolean--
tableAlertOptionRender自定义 table alert 右侧区域;false | ((option: { selectedRowKeys: any[]; selectedRows: any[]; onCleanSelected: () => void; }, doms: { delDom?: ReactNode; cancelDom: ReactNode; }) => ReactNode)--
search搜索区域的选项;
false | {labelWrap?: boolean} & SearchConfig
--
toolbarListToolBar 的属性ListToolBarProps--
ghost幽灵模式,即是否取消卡片内容区域的 padding 和 卡片的背景颜色。boolean--
columnsStateMap列状态配置,可以配置是否浮动和是否展示Record<string, ColumnsState>--
onColumnsStateChange列状态配置修改触发事件((map: Record<string, ColumnsState>) => void)--
columnsState列状态的配置,可以用来操作列功能ColumnStateType--
onSizeChange--((size: DensitySize) => void)--
cardPropstable 外面卡片的设置false | CardProps--
tableRender渲染 table((props: ProTableProps<any, any, "text">, defaultDom: Element, domList: { toolbar: Element; alert: Element | undefined; table: Element | undefined; }) => ReactNode) | undefined--
tableViewRender渲染 table 视图,用于定制 ProList,不推荐直接使用((props: TableProps<any>, defaultDom: Element) => Element) | undefined--
tableExtraRendertable 和搜索表单之间的 dom 渲染((props: ProTableProps<any, any, "text">, dataSource: any[]) => ReactNode)--
searchFormRender渲染搜索表单((props: ProTableProps<any, any, "text">, defaultDom: Element) => ReactNode)--
postData对数据进行一些处理any--
defaultData默认的数据any[]--
toolBarRender渲染操作栏false | ((action: ActionType, rows: { selectedRowKeys?: (string | number)[] | undefined; selectedRows?: any[] | undefined; }) => ReactNode[]) | undefined--
optionsRender--((props: ToolBarProps<any>, defaultDom: ReactNode[]) => ReactNode[])--
onRequestError数据加载失败时触发((e: Error) => void)--
polling是否轮询 ProTable 它不会自动提交表单,如果你想自动提交表单的功能,需要在 onValueChange 中调用 formRef.current?.submit()number | ((dataSource: any[]) => number)--
tableClassName给封装的 table 的 classNamestring--
tableStyle给封装的 table 的 styleCSSProperties--
headerTitle左上角的 titleReactNode--
tooltip标题旁边的 tooltipLabelTooltipType--
options操作栏配置false | OptionConfig--
beforeSearchSubmit格式化搜索表单提交数据((params: Partial<any>) => any)--
tableAlertRender设置或者返回false 即可关闭AlertRenderType<any>--
type支持 ProTable 的类型ProSchemaComponentTypes--
columnEmptyText空值时显示ProFieldEmptyText--
manualRequest是否手动触发请求boolean--
editable编辑行相关的配置RowEditableConfig<any>--
onDataSourceChange可编辑表格修改数据的改变((dataSource: any[]) => void)--
cardBordered查询表单和 Table 的卡片 border 配置Bordered--
debounceTime去抖时间number--
revalidateOnFocus只在request 存在的时候生效,可编辑表格也不会生效booleanfalse
defaultSize默认的表格大小SizeType--
ErrorBoundary错误边界自定义false | ComponentClass<any, any>--
delFunction传入的删除函数;((selectedIds: (string | number)[], record: any) => void | Promise<any>)--
delPermission是否有删除权限; 不传默认为有;(() => boolean)--
tableAlertOption多选删除功能的选项;--
modalFormProps传递给 ModalForm 组件的属性。
Omit<ModalFormProps, 'innerRef' | 'onFinish' | 'onOpen' | 'columns'>
--
noPadding移除 Card 包裹的 padding; 已废弃; 用 cardStyle = false 替代;boolean--
delConfirmType删除的确认弹框类型。"popconfirm" | "modal"popconfirm
delPopconfirmProps传给删除确认框的属性。title 和 description 可以是函数;(Omit<PopconfirmProps, "title" | "description"> & { title?: ReactNode | ((record: any, index: any) => ReactNode); description?: ReactNode | ((record: any, index: any) => ReactNode); })--
delModalConfirmProps传给删除确认框的属性。title 和 content 可以是函数;(Omit<ModalFuncProps, "title" | "content"> & { title?: ReactNode | ((record: any, index: any) => ReactNode); content?: ReactNode | ((record: any, index: any) => ReactNode); })--
delSuccessProps删除成功后的提示属性(传递给 Message 的属性)。false 关闭提示。{content: "删除成功", type: "success"}
optionColumnSpaceProps传给操作列中包裹各按钮的 Space 组件的属性。{size: 'small'}
defaultHideInSearchcolumns 中的列是否默认在搜索区域里隐藏。booleanfalse
rakLocale用于修改 headerTitle 的后缀文案和 formType 等对应的文案。LocaleTypezh_CH

FormUploadSettingProps​

属性名描述类型默认值
onFinish文件全部上传完成后的回调(所有文件的状态都是非uploading)((files: UploadFile<any>[]) => void)--
childrenchildren({ loading: boolean }) => Element | Element--
action文件上传接口string--
method--"POST" | "PUT" | "PATCH" | "post" | "put" | "patch"--
name--string--
className--string--
id--string--
style--CSSProperties--
onDrop--((event: DragEvent<HTMLDivElement>) => void)--
classNames--UploadClassNamesType<any>--
styles--UploadStylesType<any>--
prefixCls--string--
disabled--boolean--
rootClassName--string--
data--Record<string, unknown> | ((file: UploadFile<any>) => Record<string, unknown> | Promise<Record<string, unknown>>)--
locale--UploadLocale--
type--UploadType--
hasControlInside--boolean--
pastable--boolean--
accept--string | AcceptConfig--
multiple--boolean--
defaultFileList--UploadFile<any>[]--
directory--boolean--
headers--HttpRequestHeader--
showUploadList--boolean | ShowUploadListInterface<any>--
beforeUpload--((file: RcFile, fileList: RcFile[]) => BeforeUploadValueType | Promise<BeforeUploadValueType>)--
listType--UploadListType--
onPreview--((file: UploadFile<any>) => void)--
onDownload--((file: UploadFile<any>) => void)--
onRemove--((file: UploadFile<any>) => boolean | void | Promise<boolean | void>)--
supportServerRender--boolean--
customRequest--((options: UploadRequestOption<any>, info: { defaultRequest: (option: UploadRequestOption<any>) => void; }) => void)--
withCredentials--boolean--
openFileDialogOnClick--boolean--
previewFile--PreviewFileHandler--
iconRender--((file: UploadFile<any>, listType?: UploadListType) => ReactNode) | undefined--
isImageUrl--((file: UploadFile<any>) => boolean)--
progress--UploadListProgressProps--
itemRender--ItemRender<any>--
maxCountConfig max count of `fileList`. Will replace current one when `maxCount` is 1number--
nameKey自定义文件列表中name的取值字段stringname
urlKey自定义文件列表中url的取值字段stringurl
responseToFileList可以将后台返回的数据合并进 fileList((res: any) => Record<string, any>)--
errorHandle上传失败后的处理函数((res: any) => void)--