open-yu-que-ui-logic-base.ts 3.1 KB
Newer Older
1 2
import { UIActionContext } from "@/logic/uiaction-context";
import { BeginNode, EndNode, AppendParamNode } from "@/logic/logic-node";
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

/**
 * 打开语雀文档
 *
 * @export
 * @class OpenYuQueUILogicBase
 */
export default class OpenYuQueUILogicBase {

    /**
     * Creates an instance of  OpenYuQueBase.
     * 
     * @param {*} [opts={}]
     * @memberof  OpenYuQueUILogicBase
     */
    constructor(opts: any = {}) { }

20
    protected readonly startLogicNode: string = 'Begin';
21

22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
    protected logicParams: any[] = [
        {
            name: '传入变量',
            codeName: 'Default',
            default: true,
            navContextParam: false,
            navViewParamParam: false,
            activeContainerParam: false,
            activeCtrlParam: false,
            activeViewParam: false,
            lastReturnParam: false
        },
    ];


    protected logicNodes: ILogicNode[] = [
38 39 40
        { codeName: 'Begin', name: '开始', logicNodeType: 'BEGIN', logicLinks: [ { name: '连接名称', dstLogicNode: 'DEUIACTION1', } ] },
        { codeName: 'END1', name: '结束', logicNodeType: 'END', returnType: 'NONEVALUE', returnRawValue: '', },
        { codeName: 'DEUIACTION1', name: '界面行为', logicNodeType: 'DEUIACTION', dstParam: 'Default', logicLinks: [ { name: '连接名称', dstLogicNode: 'END1', } ] },
41 42 43 44 45
    ];

    public beforeExecute(args: any, context: any = {}, params: any = {},
        $event?: any, xData?: any, actioncontext?: any, srfParentDeName?: string) {
        return new UIActionContext(this.logicParams, args, context, params, $event, xData, actioncontext, srfParentDeName)
46 47 48 49 50 51 52 53 54 55 56 57 58 59
    }

    /**
     * 执行
     *
     * @param {any[]} args
     * @param {*} [context={}]
     * @param {*} [params={}]
     * @param {*} [$event]
     * @param {*} [xData]
     * @param {*} [actionContext]
     * @param {string} [srfParentDeName]
     * @memberof GridViewLoadUILogicBase
     */
60 61 62 63 64 65 66 67 68 69
    async execute(args: any[], context:any = {} ,params: any = {}, $event?: any, xData?: any, actioncontext?: any, srfParentDeName?: string) {
        try {
            const actionContext = this.beforeExecute(args, context, params, $event, xData, actioncontext, srfParentDeName);
            const startNode = this.logicNodes.find((logicNode: ILogicNode) => logicNode.codeName === this.startLogicNode);
            if (!startNode) {
                throw new Error('没有开始节点');
            }
            await this.executeNode(startNode, actionContext);
            return actionContext.getResult();
        } catch (error: any) {
70
            throw new Error(`${error && error.message ? error.message : '发生未知错误!'}`);
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
        }
    }

    executeNode(logicNode: ILogicNode, actionContext: UIActionContext) {
        try {
            switch (logicNode.logicNodeType) {
                case 'BEGIN':
                    console.log(111, '执行开始节点');
                    break;
                case 'END':
                    console.log(111, '执行结束节点');
                    break;
            }
        } catch (error: any) {

        }
87 88 89 90
    }


}