msgbox-node.ts 3.0 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
import { ILogicNode } from '@/interface/logic';
import { Subject } from 'rxjs';
import { UIActionContext } from '../uiaction-context';
import { UILogicNodeBase } from './logic-node-base';
/**
 * 消息弹窗节点
 *
 * @export
 * @class UILogicMsgboxNode
 */
export class UILogicMsgboxNode extends UILogicNodeBase {

    constructor() {
        super();
    }

    /**
     * 执行节点
     *
     * @param {ILogicNode} logicNode 逻辑节点模型数据
     * @param {UIActionContext} actionContext 界面逻辑上下文
     * @memberof UILogicMsgboxNode
     */
    public async executeNode(logicNode: ILogicNode, actionContext: UIActionContext) {
        try {
            // return new Promise<void>((resolve) => {
            //     let msgBoxParam: any = actionContext.getParam((logicNode.getMsgBoxParam() as IPSDEUILogicParam)?.codeName);
            //     const data = msgBoxParam?.getReal();
            //     const options = {
            //         type: logicNode.msgBoxType?.toLowerCase(),
            //         title: data?.title ? data.title : logicNode.title ? eval('`' + logicNode.title + '`') : '消息',
            //         content: data?.message ? data.message : logicNode.message ? eval('`' + logicNode.message + '`') : '',
            //         buttonType: logicNode.buttonsType?.toLowerCase(),
            //         showMode: logicNode.showMode?.toLowerCase(),
            //         showClose: false,
            //         mask: true,
            //         maskClosable: true
            //     };
            //     const subject: Subject<any> | null = AppMessageBoxService.getInstance().open(options);
            //     const subscription = subject?.subscribe((result: any) => {
            //         resolve(this.handleResponse(logicNode, actionContext, options, result));
            //         subscription!.unsubscribe();
            //         subject.complete();
            //     })
            // });
        } catch (error: any) {
            throw new Error(`逻辑节点 ${logicNode.name}${error && error.message ? error.message : '发生未知错误!'}`);
        }
    }

    /**
     * 处理响应
     *
     * @param {ILogicNode} logicNode 逻辑节点模型数据
     * @param {UIActionContext} actionContext 界面逻辑上下文
     * @param {string} result 响应结果
     * @memberof UILogicMsgboxNode
     */
    public handleResponse(logicNode: ILogicNode, actionContext: UIActionContext, options: any, result: string) {
        // const { buttonsType } = logicNode;
        // if (!Object.is(buttonsType, 'YESNO') && !Object.is(buttonsType, 'YESNOCANCEL') && !Object.is(buttonsType, 'OK') && !Object.is(buttonsType, 'OKCANCEL')) {
        //     throw new Error(`${buttonsType}未实现`);
        // }
        // let msgBoxParam: any = actionContext.getParam((logicNode.getMsgBoxParam() as IPSDEUILogicParam)?.codeName);
        // if (msgBoxParam){
        //     msgBoxParam.bind(result);
        // }
        // actionContext.bindLastReturnParam(result);
        // return this.computeNextNodes(logicNode, actionContext);
    }
}