import React from 'react'; import { Field, FieldConfig, FieldError, FieldProps, IField } from '../common'; import { FieldConfigs } from '..'; import { IFormItem } from '../../../steps/form'; import InterfaceHelper, { InterfaceConfig } from '../../../util/interface'; import { ColumnsConfig } from '../../../interface'; /** * 子表单配置项 * - configFrom: 配置来源(get用途) * - * - type: 'data' | 'interface' // 来源类型 * - * - dataField: 值来源字段 // 仅type为data时生效 * - * - configField: 配置项来源字段 // 仅type为data时生效 * - * - interface: 来源接口配置 // 仅type为interface时生效 * - withConfig: 拓展配置(set用途) * - * - enable: 是否开启 * - * - dataField: (序列化)数据 * - * - configField: (序列化)配置 */ export interface ImportSubformFieldConfig extends FieldConfig { type: 'import_subform'; interface?: InterfaceConfig; configFrom?: ImportSubformConfigFromData | ImportSubformConfigFromInterface; withConfig?: { enable: boolean; dataField: string; configField: string; }; childColumns?: ColumnsConfig; } interface ImportSubformConfigFromData { type: 'data'; dataField?: string; configField?: string; } interface ImportSubformConfigFromInterface { type: 'interface'; interface?: InterfaceConfig; } export interface IImportSubformField { columns?: ColumnsConfig; children: React.ReactNode[]; } interface IImportSubformFieldState { didMount: boolean; fields: FieldConfigs[]; formData: { status: 'normal' | 'error' | 'loading'; message?: string; }[]; } export default class ImportSubformField extends Field implements IField { getALLComponents: (type: any) => typeof Field; requestConfig: string; value: string; formFields: Array | null>; formFieldsMounted: Array; interfaceHelper: InterfaceHelper; constructor(props: FieldProps); didMount: () => Promise; get: () => Promise; reset: () => Promise; validate: (value: any) => Promise; handleMount: (formFieldIndex: number) => Promise; handleChange: (formFieldIndex: number, value: any) => Promise; /** * 处理set、unset、append、splice、sort后的操作 */ handleValueCallback: (formFieldIndex: number, validation: true | FieldError[]) => 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; /** * 处理data 兼容非法json的情况 * @param {any} data 待处理数据 * @returns 返回data反序列化形式 */ handleDataToUnstringfy: (data: any) => any; renderComponent: (props: IImportSubformField) => JSX.Element; /** * 表单项组件 - UI渲染方法 * 各UI库需重写该方法 * @param props */ renderItemComponent: (props: IFormItem) => JSX.Element; getConfigData: () => void; componentDidMount(): void; componentDidUpdate(): void; render: () => any; } export {};