import * as H from "history"; import * as React from "react"; import { Map } from "immutable"; import { AppConfig } from "./app"; import { IEvent, FromItemEvents } from "./page/events"; import { ModalFuncProps } from "antd/lib/modal"; import { WrappedFormUtils } from "antd/lib/form/Form"; import { Omit, IDictionary, FormMode, PageControlMode } from "./typeDefinition"; import { ToolbarControls } from "./page/big/toolbar"; import { RouteComponentProps, StaticContext } from "react-router"; import { PageTemplateType, PageControls, PageConfig } from "./page"; import { FormItems, FormControls, FormSections, FromControlType } from "./page/big/form"; import { ComplexSearchControls } from "./page/small/complexSearch"; import { ControlData } from "./clientData"; import { FindControls } from "./page/big/find"; /** 树形结构数据格式化前的源 */ export interface ITreeDataSource extends IDictionary { id: string; value: string; text: string; parentId: string; } /** 格式化后的树形结构 */ export interface ITreeDataType extends IDictionary { id: string; value: string; text: string; children?: ITreeDataType[]; } export interface IAction { type: string; } export interface IGetPagePathMatchParams { page?: string; systemId?: string; moduleId?: string; pageId?: string; childrenIds?: string; } export declare type IPathMatchParams = Omit; interface ILocationState extends IDictionary { key?: string; } export interface ILocation extends H.Location { query: IDictionary; } declare type SubscriptionAPI = IModelList & RouteComponentProps; /** dva & route */ export interface ISubscriptionAPI extends SubscriptionAPI { location: ILocation; dispatch(action: A): A; } /** * `pages` 的 `action` 定义 */ export interface IRemovePagesAction extends IAction { params?: { pageId: string; }; } /** * `pages` 的 `action` 定义 */ export interface ISetPagesAction extends IAction { params?: { pageId: string; page?: IPageInstance; /** 模板实例 */ template?: IDictionary; /** 逻辑页实例 */ logic?: IDictionary; /** 大控件集合 */ controls?: { controlId: string; data: IDictionary; }; /** 小控件集合 */ control2items?: { controlId: string; basisId: string; data: IDictionary; }; }; } export interface ICommTypes { /** * 页面Id */ pageId: string; /** 父页面Id */ parentId: string; } export declare type ICommPropTypes = ISubscriptionAPI & ICommTypes; /** * 模板页公共Prop */ export interface ITemplatePropTypes extends ICommPropTypes { } /** 大控件公共参数 */ export interface IControlTypes extends ICommTypes { /** * 大控件Id */ controlId: string; } /** 小控件公共参数 */ export interface IBasisControlTypes extends IControlTypes { /** * 小控件Id */ basisId: string; } /** * 逻辑页PropTypes */ export interface ILogicsPagePropTypes extends ICommPropTypes { /** 当前页面父级Id */ parentId: string; } /** * 大控件公共Prop */ export declare type IControlPropTypes = ISubscriptionAPI & IControlTypes; /** * 小控件公共Prop */ export declare type IBasisControlPropTypes = ISubscriptionAPI & IBasisControlTypes & { /** * 大控件类型 */ bigMode: PageControlMode; }; declare type IFormControlTypes = IBasisControlPropTypes & FromControlType; /** * 表单小控件公共Prop */ export interface IFormControlPropTypes any> extends IFormControlTypes { /** 表单子项公共属性,当该组件在表单内时有效 */ formItems?: Omit, keyof { control?: FormControls; }>; value?: V; onChange?: C; mode?: FormMode; } export interface IExecEventsParams { /** 要执行的事件配置 */ events?: IEvent[]; /** 要执行的事件参数 */ params: IDictionary; } /** * `utils.renderTemplates` 参数集 */ export interface IRenderTemplatesParams extends ICommTypes { /** * 父级页面Id */ parentId: string; /** * 模板类型 */ templates: PageTemplateType; /** * 该应用服务端静态资源的`origin` */ staticHost: string; /** 额外的参数 */ extra?: T; } /** * `utils.renderControls` 参数集 */ export interface IRenderControlsParams extends IControlTypes { /** 大控件类型与属性 */ control: PageControls; controlUUID?: number; /** 额外的参数 */ extra?: T; } /** * `utils.renderFormControl` 参数集 */ export interface IRenderFormControlParams extends IBasisControlTypes { /** * 经 `Form.create()` 包装过的组件会自带 `this.props.form` 属性 */ form: WrappedFormUtils; /** * 表单子控件类型 */ control: C; /** * 表单子控件公共属性 */ config: FormItems; /** * 表单区域属性 */ section: FormSections; /** 额外的参数 */ extra?: E; } /** * `utils.renderToolBarControl` 参数集 */ export interface IRenderToolBarControlParams extends IBasisControlTypes { control: ToolbarControls; /** 额外的参数 */ extra?: T; } /** * `utils.renderFindControl` 参数集 */ export interface IRenderFindControlParams extends IBasisControlTypes { control: FindControls; /** 额外的参数 */ extra?: T; } /** * 全局工具库 */ export interface IUtils { /** * 根据模板类型获取对应的模板页 */ renderTemplates(params: IRenderTemplatesParams): React.ReactNode; /** * 根据大控件类型获取对应的大控件 */ renderControls(params: IRenderControlsParams): React.ReactNode; /** * 根据表单子控件类型获取对应的表单子控件 */ renderFormControl(params: IRenderFormControlParams): React.ReactNode; /** * 根据复杂搜索的子控件类型获取对应的复杂搜索子控件 */ renderComplexSearchControl(params: IRenderFormControlParams): React.ReactNode; /** * 根据工具栏子控件类型获取对应的工具栏子控件 */ renderToolBarControl(params: IRenderToolBarControlParams): React.ReactNode; /** * 根据搜索栏子控件类型获取对应的搜索栏子控件 */ renderFindControl(params: IRenderFindControlParams): React.ReactNode; /** * 把对象转换成用于url链接的字符串 * @param path url路径 * @param params 对象 */ url2string(path: string, params?: object | undefined): string; } /** * 当前应用全局配置 * * `models` 中的 `config` 的 `state` */ export interface IConfigModel extends AppConfig { isMobile: boolean; collapsed: boolean; /** 该应用服务端Api的`origin */ apiHost: string; /** 该应用服务端静态资源的`origin */ staticHost: string; loading: boolean; error: boolean; /** 提供的服务是否属于静态网站 */ isStatic: boolean; } /** 当前页面实例大控件集合 */ export interface IPageInstanceControls extends IDictionary { /** 大控件下的小控件集合 */ items?: Map; } export interface IPageRefreshParams { /** 要跳转页面的路径 */ match: IGetPagePathMatchParams; /** 当前页面信息是否回收 */ recovery?: boolean; /** 需要传递的参数 */ params?: IDictionary; } export interface IGetChildrenParams { modelList?: IModelList; /** 子页面Id */ childrenId: string; } export interface IGetControlParams { page?: IPageInstance; /** 大控件Id */ controlId: string; } export interface IGetBasisControlParams { page?: IPageInstance; /** 大控件Id */ controlId: string; /** 小控件Id */ basisId: string; } export interface ModalFuncparams extends Omit { onOk?: (location: H.Location, ...args: any[]) => any | PromiseLike; onCancel?: (location: H.Location, ...args: any[]) => any | PromiseLike; } /** * 当前页面实例 */ export interface IPageInstance extends IDictionary { pageId: string; /** 模板实例 */ template?: IDictionary; /** 逻辑页实例 */ logic?: IDictionary; /** 当前页面的控件实例集合 */ controls?: Map; /** 刷新顶级页面 */ refresh: (params: IPageRefreshParams) => void; /** 在当前页面打开一个新页面 */ push: (params: IPageRefreshParams) => void; /** 在浏览历史中前进或后退 */ go: (number: number) => void; /** 返回,相当于`go(-1)` */ goBack(): void; /** 替换当前页面 */ replace: (params: IPageRefreshParams) => void; /** * 改变当前页面的`prompt`状态 * @param when 是否启用 */ prompt: (when: boolean, params?: ModalFuncparams) => Promise; /** 获取参数并解析执行相应的方法 */ getParam: (paramExp: string, params: IDictionary) => Promise; getParent: () => IPageInstance | undefined; /** 获取子页面实例 */ getChildren: (params: IGetChildrenParams) => IPageInstance | undefined; /** 根据大控件Id获取大控件的实例 */ getControl(params: IGetControlParams): T | undefined; /** 获取页面配置 */ getPageConfig(): PageConfig | undefined; /** * 获取数据源 * @param data 数据源配置 * @param params 额外参数 */ getDataSource(data: D, params?: IDictionary | undefined): Promise; /** * 执行控制器 * @param controllerId 控制器Id * @param params 额外参数 */ execController(controllerId?: string | undefined, params?: IDictionary | undefined): Promise; } export interface IAddControlsAction extends IAction { params?: { __uniqueId: string; props: any; }; } export interface ICleanControlsAction extends IAction { params?: { __uniqueId: string; }; } /** 全局变量 */ export interface IModelList { /** 当前应用全局配置 */ config: IConfigModel; /** 页面实例集合 */ pages: Map; } export {};