import React from 'react'; import { Field, FieldConfigs, FieldError } from '../../components/formFields/common'; import Step, { StepConfig, StepProps } from '../common'; import { ParamConfig } from '../../interface'; /** * 表单步骤配置文件格式定义 * - layout: 表单布局类型 * - * horizontal: 左侧文本、右侧输入框、纵向排列 * - * vertical: 顶部文本、底部输入框、纵向排列 * - * inline: 左侧文本、右侧输入框、横向排列 * - fields: 表单项配置列表 */ export interface FilterConfig extends StepConfig { type: 'filter'; fields?: FieldConfigs[]; defaultValue?: ParamConfig; hiddenSubmit?: boolean; hiddenReset?: boolean; submitText?: string; resetText?: string; } /** * 表单步骤组件 - UI渲染方法 - 入参格式 * - layout: 表单布局类型 * - * horizontal: 左侧文本、右侧输入框、纵向排列 * - * vertical: 顶部文本、底部输入框、纵向排列 * - * inline: 左侧文本、右侧输入框、横向排列 * - submit: 表单提交操作事件 * - cancel: 表单取消操作事件 * - children: 表单内容 */ export interface IFilter { onSubmit?: () => Promise; onReset?: () => Promise; submitText?: string; resetText?: string; children: React.ReactNode[]; } /** * 表单项容器组件 - UI渲染方法 - 入参格式 * - label: 表单项名称 * - status: 表单项状态 * - * normal 默认状态 * - * error 错误 * - * loading 加载中 * - description: 表单项说明 * - message: 表单项消息 * - layout: 表单项布局 * - * horizontal: 左侧文本、右侧输入框、纵向排列 * - * vertical: 顶部文本、底部输入框、纵向排列 * - * inline: 左侧文本、右侧输入框、横向排列 * - children: 表单项内容 */ export interface IFilterItem { label: string; status: 'normal' | 'error' | 'loading'; description?: string; message?: string; visitable: boolean; fieldType: string; children: React.ReactNode; } /** * 表单步骤组件 - 状态 * - filterData: 表单的值 */ interface FilterState { formValue: { [field: string]: any; }; formData: { status: 'normal' | 'error' | 'loading'; message?: string; }[]; } /** * 表单步骤组件 */ export default class FilterStep extends Step { getALLComponents: (type: any) => typeof Field; formFields: Array | null>; formFieldsMounted: Array; dependentFields_: string[]; formValue: { [field: string]: any; }; formData: { status: 'normal' | 'error' | 'loading'; message?: string; }[]; /** * 初始化表单的值 * @param props */ constructor(props: StepProps); /** * 重写表单步骤装载事件 */ stepPush: () => Promise; handleFormFieldMount: (formFieldIndex: number) => Promise; /** * 处理表单提交事件 */ handleSubmit: () => Promise; /** * 处理表单返回事件 */ handleReset: () => Promise; /** * 处理表单项change事件 * @param field 表单项配置 * @param value 目标值 */ handleChange: (formFieldIndex: number, value: any) => Promise; handleValueSet: (formFieldIndex: number, path: string, value: any, validation: true | FieldError[], options?: { noPathCombination?: boolean; }) => Promise; handleValueUnset: (formFieldIndex: number, path: string, validation: true | FieldError[], options?: { noPathCombination?: boolean; }) => Promise; handleValueListAppend: (formFieldIndex: number, path: string, value: any, validation: true | FieldError[], options?: { noPathCombination?: boolean; }) => Promise; handleValueListSplice: (formFieldIndex: number, path: string, index: number, count: number, validation: true | FieldError[], options?: { noPathCombination?: boolean; }) => Promise; handleValueListSort: (formFieldIndex: number, path: string, index: number, sortType: 'up' | 'down', validation: true | FieldError[], options?: { noPathCombination?: boolean; }) => Promise; /** * 表单步骤组件 - UI渲染方法 * 各UI库需重写该方法 * @param props */ renderComponent: (props: IFilter) => JSX.Element; /** * 表单项组件 - UI渲染方法 * 各UI库需重写该方法 * @param props */ renderItemComponent: (props: IFilterItem) => JSX.Element; render(): JSX.Element; } export {};