补充 form 的schema 说明

This commit is contained in:
2betop 2020-09-11 10:08:53 +08:00
parent 91a0c933bb
commit 6a81280251
2 changed files with 161 additions and 34 deletions

View File

@ -269,6 +269,11 @@ export type SchemaName = string;
*/
export type SchemaReload = string;
/**
*
*/
export type SchemaRedirect = string;
/**
*
*

View File

@ -35,7 +35,17 @@ import {isAlive} from 'mobx-state-tree';
import {asFormItem, FormControlSchema} from './Item';
import {SimpleMap} from '../../utils/SimpleMap';
import {trace} from 'mobx';
import {BaseSchema, SchemaApi, SchemaDefaultData} from '../../Schema';
import {
BaseSchema,
SchemaApi,
SchemaClassName,
SchemaCollection,
SchemaDefaultData,
SchemaExpression,
SchemaName,
SchemaRedirect,
SchemaReload
} from '../../Schema';
import {ActionSchema} from '../Action';
export interface FormSchemaHorizontal {
@ -50,7 +60,14 @@ export interface FormSchemaHorizontal {
* https://baidu.gitee.io/amis/docs/components/form/index
*/
export interface FormSchema extends BaseSchema {
/**
*
*/
type: 'form';
/**
*
*/
title?: string;
/**
@ -80,18 +97,153 @@ export interface FormSchema extends BaseSchema {
*/
debug?: boolean;
/**
*
*/
initApi?: SchemaApi;
/**
* Form api,initApi不同的是 finished true
*/
initAsyncApi?: SchemaApi;
/**
* initAsyncApi后data.finished来判断是否完成xxxdata.xxx中获取
*/
initFinishedField?: string;
/**
* initAsyncApi以后
*/
initCheckInterval?: number;
/**
*
*/
initFetch?: boolean;
/**
* api sendOn
*/
initFetchOn: SchemaExpression;
/**
* initApi
*/
interval?: number;
/**
*
*/
silentPolling?: boolean;
/**
*
*/
stopAutoRefreshWhen?: string;
/**
*
*/
persistData?: boolean;
/**
*
*/
clearPersistDataAfterSubmit?: boolean;
/**
* Form api
*/
api?: SchemaApi;
/**
*
* finished true
*/
initApi?: SchemaApi;
asyncApi?: SchemaApi;
/**
* 3 asyncApi
*/
checkInterval?: number;
/**
* `finished` `is_success`
*/
finishedField?: string;
/**
*
*/
resetAfterSubmit?: boolean;
mode?: 'normal' | 'inline' | 'horizontal';
horizontal?: FormSchemaHorizontal;
/**
*
*/
autoFocus?: boolean;
messages?: {
fetchFailed?: string;
fetchSuccess?: string;
saveFailed?: string;
saveSuccess?: string;
validateFailed?: string;
};
name?: SchemaName;
/**
* panel className
*/
panelClassName?: SchemaClassName;
/**
* id, asyncApi
* @default id
*/
primaryField?: string;
redirect?: SchemaRedirect;
reload?: SchemaReload;
/**
*
*/
submitOnChange?: boolean;
/**
*
*/
submitOnInit?: boolean;
/**
*
*/
submitText?: string;
/**
* api form name `CRUD` name target `Form` `Form` `initApi` `schemaApi`api form `CRUD` Form
*/
target?: string;
/**
* panel
*/
wrapWithPanel?: boolean;
/**
*
*/
body?: SchemaCollection;
/**
*
*/
affixFooter?: boolean;
}
export type FormGroup = FormSchema & {
@ -106,38 +258,8 @@ export type FormHorizontal = FormSchemaHorizontal;
export interface FormProps extends RendererProps, Omit<FormSchema, 'mode'> {
data: any;
store: IFormStore;
wrapperComponent: React.ReactType;
title?: string; // 标题
submitText?: string;
submitOnChange?: boolean; // 设置是否一修改就提交。
submitOnInit?: boolean;
resetAfterSubmit?: boolean;
initApi?: Api; // 可以用来设置初始数据。
initAsyncApi?: Api; // 如果 api 处理时间过长,可以开启 initAsyncApi 来处理。轮询检测是否真的完成了。
initCheckInterval?: number;
initFinishedField?: string;
interval?: number;
silentPolling?: boolean;
stopAutoRefreshWhen?: string;
api?: Api; // 用来保存的 api
asyncApi?: Api; // 如果 api 处理时间过长,可以开启 asyncApi 来处理。轮询检测是否真的完成了。
checkInterval?: number;
finishedField?: string;
initFetch?: boolean; // 是否初始拉取?
initFetchOn?: string;
className?: string;
body?: SchemaNode;
wrapWithPanel?: boolean;
panelClassName?: string;
mode?: 'normal' | 'inline' | 'horizontal' | 'row';
affixFooter?: boolean;
collapsable?: boolean;
debug?: boolean;
autoFocus?: boolean;
horizontal: FormHorizontal;
wrapperComponent: React.ElementType;
canAccessSuperData: boolean;
persistData: boolean; // 开启本地缓存
clearPersistDataAfterSubmit: boolean; // 提交成功后清空本地缓存
trimValues?: boolean;
lazyLoad?: boolean;
simpleMode?: boolean;