85 lines
2.4 KiB
Plaintext
85 lines
2.4 KiB
Plaintext
import { ComponentType } from './index';
|
|
import type { CSSProperties } from 'vue';
|
|
import type { ButtonProps } from 'ant-design-vue/lib/button';
|
|
import type { ColEx } from '../types';
|
|
import type { RowProps } from 'ant-design-vue/lib/grid/Row';
|
|
export interface RenderReturnParams {
|
|
schema: FormSchema;
|
|
values: Recordable;
|
|
model: Recordable;
|
|
field: string;
|
|
}
|
|
|
|
export interface componentProps {
|
|
options?: any[];
|
|
placeholder?: string;
|
|
showButton?: boolean;
|
|
onInput?: () => Recordable;
|
|
onChange?: () => Recordable;
|
|
}
|
|
|
|
export interface FormSchema {
|
|
name: string;
|
|
label: string;
|
|
labelMessage?: string;
|
|
labelMessageStyle?: object | string;
|
|
defaultValue?: any;
|
|
component?: ComponentType;
|
|
componentProps?: any;
|
|
slot?: string;
|
|
rules?: object | object[];
|
|
colProps?: Partial<ColEx>;
|
|
isFull?: boolean;
|
|
suffix?: string;
|
|
showFeedback?: boolean;
|
|
showLabel?: boolean;
|
|
requireMarkPlacement?: string;
|
|
hidden?: boolean | ((renderCallbackParams: RenderReturnParams) => boolean);
|
|
}
|
|
|
|
export interface FormProps {
|
|
model?: Recordable;
|
|
labelCol?: Partial<ColEx>;
|
|
schemas?: FormSchema[];
|
|
inline: boolean;
|
|
layout?: string;
|
|
size: string;
|
|
labelPlacement: string;
|
|
isFull: boolean;
|
|
actInheritLabelCol?: boolean;
|
|
showActionButtonGroup?: boolean;
|
|
showResetButton?: boolean;
|
|
resetButtonOptions?: Partial<ButtonProps>;
|
|
showSubmitButton?: boolean;
|
|
showAdvancedButton?: boolean;
|
|
submitButtonOptions?: Partial<ButtonProps>;
|
|
submitButtonText?: string;
|
|
resetButtonText?: string;
|
|
rowProps?: Partial<RowProps>;
|
|
colProps?: Partial<ColEx>;
|
|
resetFunc?: () => Promise<void>;
|
|
submitFunc?: () => Promise<void>;
|
|
submitOnReset?: boolean;
|
|
baseRowStyle?: CSSProperties;
|
|
actionStyle?: CSSProperties;
|
|
draggable?: boolean;
|
|
}
|
|
|
|
export interface FormActionType {
|
|
submit: () => Promise<any>;
|
|
setProps: (formProps: Partial<FormProps>) => Promise<void>;
|
|
setSchema: (schemaProps: Partial<FormSchema[]>) => Promise<void>;
|
|
setFieldsValue: (values: Recordable) => void;
|
|
clearValidate: (name?: string | string[]) => Promise<void>;
|
|
getFieldsValue: () => Recordable;
|
|
resetFields: () => Promise<void>;
|
|
validate: (nameList?: any[]) => Promise<any>;
|
|
mergeValidateInfo: (items: any[]) => object;
|
|
validateInfos: object;
|
|
setLoadingSub: (status: boolean) => void;
|
|
}
|
|
|
|
export type RegisterFn = (formInstance: FormActionType) => void;
|
|
|
|
export type UseFormReturnType = [RegisterFn, FormActionType];
|