import React from 'react'; import Step from './steps/common'; import { StepConfigs } from './steps'; import { RichStringConfig } from './interface'; /** * 页面配置文件格式定义 * - basic: 页面基本配置 * - - title: 页面标题 * - - description: 页面描述 * - steps: 页面流转步骤 */ export interface CCMSConfig { basic?: BasicConfig; steps?: StepConfigs[]; } export interface BasicConfig { title?: string; description?: RichStringConfig; } /** * 页面组件 - UI渲染方法 - 入参格式 * - title: 页面标题 * - description: 页面描述 * - children: 页面内容 */ export interface ICCMS { title: string; description: React.ReactNode; children: React.ReactNode; } /** * 页面组件 - 入参格式 * - config: 页面配置文件 * - sourceData: 传入数据 */ export interface CCMSProps { config: CCMSConfig; sourceData: any; baseRoute: string; checkPageAuth: (pageID: any) => Promise; loadPageURL: (pageID: any) => Promise; loadPageFrameURL: (pageID: any) => Promise; loadPageConfig: (pageID: any) => Promise; loadPageList: () => Promise>; loadDomain: (domain: string) => Promise; handlePageRedirect?: (path: string, replaceHistory: boolean) => void; callback: (success: boolean) => void; onMount?: () => void; handleFormValue?: (payload: object) => object; } /** * 页面组件 - 状态 * - realStep: 数据当前所在步骤 * - viewStep: 界面当前所在步骤 * - data: 各步骤数据 */ export interface CCMSState { realStep: number; viewStep: number[]; data: any[]; } /** * 页面列表项 * - key: 此项必须设置(其值在整个树范围内唯一) * - value: 默认根据此属性值进行筛选(其值在整个树范围内唯一) * - title: 树节点显示的内容 * - children: 子节点 */ export interface PageListItem { key: string | number; value: string | number; title: string; children?: Array; } /** * 页面组件 */ export default class CCMS extends React.Component { getStepComponent: (key: string) => any; /** * 各步骤所使用的UI组件的实例 */ steps: (Step | null)[]; /** * 是否已经首次挂载 */ mounted: boolean; /** * 初始化 * @param props 页面组件 - 入参 * * 数据当前所在步骤 初始为 0 * 界面当前所在步骤 初始为 -1 - 界面0需要在数据0执行结束(componentDidMount)后展示 * 各步骤数据 初始为 sourceData */ constructor(props: CCMSProps); /** * 执行界面0的挂载 */ componentDidMount(): void; /** * 处理页面步骤的提交事件 * @param step 当前页面所在步骤 * @param result 当前页面所在步骤所提交的数据 */ handleSubmit: (step: number, result: any, unmountView?: boolean) => Promise; /** * 处理页面步骤的界面切换事件 * @param step 目标页面所在步骤 */ handleMount: (step: number) => Promise; /** * 处理页面步骤的界面后退时间 */ handleUnmount: (step: number, reload?: boolean, data?: any) => Promise; /** * 页面组件 - UI渲染方法 * 各UI库需重写该方法 * @param props 页面组件 - UI渲染方法 - 入参 */ renderComponent: (props: ICCMS) => JSX.Element; render(): JSX.Element; }