import React from 'react'; import { DetailField, DetailFieldConfigs } from '../../components/detail/common'; import Step, { StepConfig, StepProps } from '../common'; import { ColumnsConfig, ParamConfig } from '../../interface'; /** * 详情步骤配置文件格式定义 * - type 对应 detail * - layout: 表单布局类型 * - * horizontal: 左侧文本、右侧输入框、纵向排列 * - * vertical: 顶部文本、底部输入框、纵向排列 * - columns: 分栏设置 * - * type: 分栏类型 * - * - * span: 固定分栏 * - * - * width: 宽度分栏 * - * value: 分栏相关配置值 * - * wrap: 分栏后是否换行 * - * gap: 分栏边距 * - fields: 详情项配置列表 * - defaultValue 默认值 * - hiddenBack 是否隐藏返回按钮 * - backText 返回按钮文案 */ export interface DetailConfig extends StepConfig { type: 'detail'; layout?: 'horizontal' | 'vertical'; columns?: ColumnsConfig; unstringify?: string[]; fields?: DetailFieldConfigs[]; defaultValue?: ParamConfig; hiddenBack?: boolean; backText?: string; } /** * 详情步骤组件 - UI渲染方法 - 入参格式 * - layout: 表单布局类型 * - * horizontal: 左侧文本、右侧输入框、纵向排列 * - * vertical: 顶部文本、底部输入框、纵向排列 * - * inline: 左侧文本、右侧输入框、横向排列 * - columns: 分栏设置 * - * type: 分栏类型 * - * - * span: 固定分栏 * - * - * width: 宽度分栏 * - * value: 分栏相关配置值 * - * wrap: 分栏后是否换行 * - * gap: 分栏边距 * - children: 表单内容 */ export interface IDetail { layout: 'horizontal' | 'vertical'; columns?: ColumnsConfig; children: React.ReactNode[]; onBack?: () => Promise; backText?: string; } /** * 详情项组件 - UI渲染方法 * - key: react需要的unique key * - label: 详情项名称 * - layout: 详情项布局 * - columns: 分栏设置 * - * type: 分栏类型 * - * - * span: 固定分栏 * - * - * width: 宽度分栏 * - * value: 分栏相关配置值 * - * wrap: 分栏后是否换行 * - * gap: 分栏边距 * - collapsible: 详情页group展开收起配置 * - visitable: 详情项可见性 * - * horizontal: 左侧文本、右侧输入框、纵向排列 * - * vertical: 顶部文本、底部输入框、纵向排列 * - * inline: 左侧文本、右侧输入框、横向排列 * - children: 详情项内容 */ export interface IDetailItem { key: string | number; label: string; layout: 'horizontal' | 'vertical'; columns?: ColumnsConfig; styles?: object; collapsible?: 'header' | 'disabled'; visitable: boolean; fieldType: string; children: React.ReactNode; } /** * 详情步骤组件 - 状态 * - formData: 表单的值 */ interface DetailState { ready: boolean; detailValue: { [field: string]: any; }; } /** * 表单步骤组件 */ export default class DetailStep extends Step { getALLComponents: (type: any) => typeof DetailField; detailFields: Array | null>; detailFieldsMounted: Array; detailValue: { [field: string]: any; }; detailData: { status: 'normal' | 'error' | 'loading'; message?: string; name: string; hidden: boolean; }[]; /** * 初始化表单的值 * @param props */ constructor(props: StepProps); /** * 重写表单步骤装载事件 */ stepPush: () => Promise; handleDetailFieldMount: (detailFieldIndex: number) => Promise; /** * 处理表单返回事件 */ handleCancel: () => Promise; /** * 处理详情项change事件 * @param field 详情项配置 * @param value 目标值 */ handleChange: (detailFieldIndex: number, value: any) => Promise; handleValueSet: (detailFieldIndex: number, path: string, value: any, options?: { noPathCombination?: boolean; }) => Promise; handleValueUnset: (detailFieldIndex: number, path: string, options?: { noPathCombination?: boolean; }) => Promise; handleValueListAppend: (detailFieldIndex: number, path: string, value: any, options?: { noPathCombination?: boolean; }) => Promise; handleValueListSplice: (detailFieldIndex: number, path: string, index: number, count: number, options?: { noPathCombination?: boolean; }) => Promise; /** * 详情步骤组件 - UI渲染方法 * 各UI库需重写该方法 * @param props */ renderComponent: (props: IDetail) => JSX.Element; /** * 详情项组件 - UI渲染方法 * 各UI库需重写该方法 * @param props */ renderItemComponent: (props: IDetailItem) => JSX.Element; render(): JSX.Element; } export {};