import React from 'react'; import { ColumnsConfig, ParamConfig } from '../../interface'; import { FieldConfigs as getFieldConfigs } from './'; import { ConditionConfig } from '../../util/condition'; import { StatementConfig } from '../../util/statement'; import { PageListItem } from '../../main'; /** * 表单项基类配置文件格式定义 * - field: 表单项字段名 * - type: 表单项类型 * - * text: 短文本类型 * - * form: 子表单类型 * - label: 表单项名称 * - required: 表单项必填 * - readonly: 表单项只读 * - disabled: 表单项不可编辑 * - default: 表单项默认值 // 改为defaultValue * - - type: 默认值类型 * - - * static: 固定值 * - - * data: 上一步骤数据 * - - * query: 页面GET方法传参 * - - * hash: 页面HASH传参 * - - * interface: 接口入参获取 * - - value: 默认值(static类型使用) * - - field: 字段名(data/query/hash类型使用)(hash类型选填) */ export interface FieldConfig { field: string; label: string; required?: boolean; readonly?: boolean; disabled?: boolean; display?: 'none'; defaultValue?: ParamConfig; subLabelConfig?: { enable: boolean; mode: 'plain' | 'markdown' | 'html'; content: StatementConfig; }; condition?: ConditionConfig; extra?: StatementConfig; columns?: ColumnsConfig; styles?: object; } /** * 表单项配置文件格式定义 - 枚举 */ export declare type FieldConfigs = getFieldConfigs; /** * 表单项子类需实现的方法 * - reset: 表单项重置当前值 * - set: 表单项设置当前值 * - get: 表单项获取当前值 * - validate: 表单项的值校验方法 */ export interface IField { reset: () => Promise; set: (value: T) => Promise; get: () => Promise; validate: (value: T) => Promise; fieldFormat: () => Promise<{}>; } /** * 表单项子类需要的入参 * - ref: * - formLayout: * - value: * - data: * - step: * - config: * - onChange: */ export interface FieldProps { ref: (instance: Field | null) => void; form: React.ReactNode; formLayout: 'horizontal' | 'vertical' | 'inline'; value: T; record: { [field: string]: any; }; data: any[]; config: C; onChange: (value: T) => Promise; onValueSet: (path: string, value: T, validation: true | FieldError[], options?: { noPathCombination?: boolean; }) => Promise; onValueUnset: (path: string, validation: true | FieldError[], options?: { noPathCombination?: boolean; }) => Promise; onValueListAppend: (path: string, value: any, validation: true | FieldError[], options?: { noPathCombination?: boolean; }) => Promise; onValueListSplice: (path: string, index: number, count: number, validation: true | FieldError[], options?: { noPathCombination?: boolean; }) => Promise; onValueListSort: (path: string, index: number, sortType: 'up' | 'down', validation: true | FieldError[], options?: { noPathCombination?: boolean; }) => Promise; baseRoute: string; containerPath: string; onReportFields?: (field: string) => Promise; step: { [field: string]: any; }; loadDomain: (domain: string) => Promise; loadPageList: () => Promise>; } /** * 表单项配置接口获取数据需要的入参 * - url: 请求地址 * - method: 请求类型 * - withCredentials?: 跨域是否提供凭据信息 * - response: 返回值 * - format?: 格式化返回值 * - responseArrayKey?: format === 'array' 时配置 key 值 * - responseArrayValue?: format === 'array' 时配置 value 值 */ export interface FieldInterface { interface?: { url: string; method: 'GET' | 'POST' | 'get' | 'post'; withCredentials?: boolean; response: string; format?: 'array' | 'key'; responseArrayKey?: string; responseArrayValue?: string; }; } /** * 表单项基类 * - C: 表单项的配置文件类型 * - E: 表单项的渲染方法入参 * - T: 表单项的值类型 * - S: 表单项的扩展状态 */ export declare class Field extends React.Component, S> implements IField { dependentFields: string[]; static defaultProps: { config: {}; }; /** * 获取默认值 */ defaultValue: () => Promise; reset: () => Promise; set: (value: any) => Promise; get: () => Promise; validate: (value: T) => Promise; fieldFormat: () => Promise<{}>; didMount: () => Promise; /** * 根据mode不同,处理subLabel内容 * @param config 子项config * @returns */ handleSubLabelContent(config: any): JSX.Element | undefined; /** * 上报param依赖字段名称 * @param field */ handleReportFields: (field: string) => void; renderComponent: (props: E) => JSX.Element; shouldComponentUpdate(nextProps: FieldProps, nextState: S): boolean; render: () => JSX.Element; } export interface DisplayProps { value: T; record: { [field: string]: any; }; data: any[]; step: { [field: string]: any; }; config: C; onValueSet: (path: string, value: T, options?: { noPathCombination?: boolean; }) => Promise; onValueUnset: (path: string, options?: { noPathCombination?: boolean; }) => Promise; onValueListAppend: (path: string, value: any, options?: { noPathCombination?: boolean; }) => Promise; onValueListSplice: (path: string, index: number, count: number, options?: { noPathCombination?: boolean; }) => Promise; baseRoute: string; loadDomain: (domain: string) => Promise; } export declare class Display extends React.Component, S> { defaultValue: () => Promise; reset: () => Promise; set: (value: any) => Promise; get: () => Promise; renderComponent: (props: E) => JSX.Element; didMount: () => Promise; render: () => JSX.Element; } export declare class FieldError { message: string; constructor(message: string); }