提交 f4621da7 编写于 作者: Mosher's avatar Mosher

add:新增UIlogic相关文件

上级 28d62ed4
export * from './logic-node';
export * from './logic-link';
\ No newline at end of file
/**
* 逻辑连接接口
*
* @export
* @interface ILogicLink
*/
export interface ILogicLink {
/**
* 名称
*
* @type {string}
* @memberof ILogicLink
*/
name: string;
/**
* 下一节点标识
*
* @type {string}
* @memberof ILogicLink
*/
dstLogicNode: string;
/**
* 连接条件
*
* @type {any[]}
* @memberof ILogicLink
*/
linkGroupCond?: any[]
}
\ No newline at end of file
import { ILogicLink } from "./logic-link";
/**
* 逻辑节点接口
*
* @export
* @interface ILogicNode
*/
export interface ILogicNode {
/**
* 代码标识
*
* @type {string}
* @memberof ILogicNode
*/
codeName: string;
/**
* 名称
*
* @type {string}
* @memberof ILogicNode
*/
name: string;
/**
* 逻辑节点类型
* @description 值模式 [云实体逻辑处理节点类型(全部,包括界面逻辑)] {BEGIN:开始、 DEACTION:实体行为、 PREPAREPARAM:准备参数、 RESETPARAM:重置参数、 COPYPARAM:拷贝参数、 BINDPARAM:绑定参数、 APPENDPARAM:附加到数组参数、 SORTPARAM:排序数组参数、 RENEWPARAM:重新建立参数、 RAWSQLCALL:直接SQL调用、 RAWSQLANDLOOPCALL:直接SQL并循环调用、 RAWWEBCALL:直接Web调用、 STARTWF:启动流程、 CANCELWF:取消流程、 THROWEXCEPTION:抛出异常、 SFPLUGIN:系统服务插件、 RAWSFCODE:直接后台代码、 SYSLOGIC:系统逻辑处理、 PREPAREJSPARAM:准备参数、 VIEWCTRLINVOKE:视图部件调用、 RAWJSCODE:直接前台代码、 MSGBOX:消息弹窗、 PFPLUGIN:前端插件调用、 DEUIACTION:实体界面行为调用、 MAINSTATE:主状态、 DEDATASET:实体数据集、 DENOTIFY:实体通知、 DELOGIC:实体逻辑、 COMMIT:提交事务、 ROLLBACK:回滚事务、 DEBUGPARAM:调试逻辑参数、 DEDATAQUERY:实体数据查询、 DEPRINT:实体打印、 DEREPORT:实体报表、 DEDTSQUEUE:实体异步处理队列、 DEDATASYNC:实体数据同步、 DEDATAIMP:实体数据导入、 DEDATAEXP:实体数据导出、 DEDATAAUDIT:实体访问审计、 SUBSYSSAMETHOD:外部服务接口方法、 SYSDATASYNCAGENTOUT:系统数据同步代理输出、 SYSDBTABLEACTION:系统数据库表操作、 SYSBDTABLEACTION:系统大数据表操作、 SYSSEARCHDOCACTION:系统检索文档操作、 SYSBIREPORT:系统智能报表、 END:结束 }
* @type {( string | 'BEGIN' | 'DEACTION' | 'PREPAREPARAM' | 'RESETPARAM' | 'COPYPARAM' | 'BINDPARAM' | 'APPENDPARAM' | 'SORTPARAM' | 'RENEWPARAM' | 'RAWSQLCALL' | 'RAWSQLANDLOOPCALL' | 'RAWWEBCALL' | 'STARTWF' | 'CANCELWF' | 'THROWEXCEPTION' | 'SFPLUGIN' | 'RAWSFCODE' | 'SYSLOGIC' | 'PREPAREJSPARAM' | 'VIEWCTRLINVOKE' | 'RAWJSCODE' | 'MSGBOX' | 'PFPLUGIN' | 'DEUIACTION' | 'MAINSTATE' | 'DEDATASET' | 'DENOTIFY' | 'DELOGIC' | 'COMMIT' | 'ROLLBACK' | 'DEBUGPARAM' | 'DEDATAQUERY' | 'DEPRINT' | 'DEREPORT' | 'DEDTSQUEUE' | 'DEDATASYNC' | 'DEDATAIMP' | 'DEDATAEXP' | 'DEDATAAUDIT' | 'SUBSYSSAMETHOD' | 'SYSDATASYNCAGENTOUT' | 'SYSDBTABLEACTION' | 'SYSBDTABLEACTION' | 'SYSSEARCHDOCACTION' | 'SYSBIREPORT' | 'END')}
*/
logicNodeType: string | 'BEGIN' | 'DEACTION' | 'PREPAREPARAM' | 'RESETPARAM' | 'COPYPARAM' | 'BINDPARAM' | 'APPENDPARAM' | 'SORTPARAM' | 'RENEWPARAM' | 'RAWSQLCALL' | 'RAWSQLANDLOOPCALL' | 'RAWWEBCALL' | 'STARTWF' | 'CANCELWF' | 'THROWEXCEPTION' | 'SFPLUGIN' | 'RAWSFCODE' | 'SYSLOGIC' | 'PREPAREJSPARAM' | 'VIEWCTRLINVOKE' | 'RAWJSCODE' | 'MSGBOX' | 'PFPLUGIN' | 'DEUIACTION' | 'MAINSTATE' | 'DEDATASET' | 'DENOTIFY' | 'DELOGIC' | 'COMMIT' | 'ROLLBACK' | 'DEBUGPARAM' | 'DEDATAQUERY' | 'DEPRINT' | 'DEREPORT' | 'DEDTSQUEUE' | 'DEDATASYNC' | 'DEDATAIMP' | 'DEDATAEXP' | 'DEDATAAUDIT' | 'SUBSYSSAMETHOD' | 'SYSDATASYNCAGENTOUT' | 'SYSDBTABLEACTION' | 'SYSBDTABLEACTION' | 'SYSSEARCHDOCACTION' | 'SYSBIREPORT' | 'END';
/**
* 目标逻辑参数
*
* @type {string}
* @memberof ILogicNode
*/
dstParam?: string;
/**
* 目标参数属性
*
* @type {string}
* @memberof ILogicNode
*/
dstFieldName?: string;
/**
* 目标列表参数起始位置
*
* @type {number}
* @memberof ILogicNode
*/
dstIndex?: number;
/**
* 源逻辑参数
*
* @type {string}
* @memberof ILogicNode
*/
srcParam?: string;
/**
* 源属性名称
*
* @type {string}
* @memberof ILogicNode
*/
srcFieldName?: string;
/**
* 源列表参数起始位置
*
* @type {number}
* @memberof ILogicNode
*/
srcIndex?: number;
/**
* 直接值
*
* @type {string}
* @memberof ILogicNode
*/
srcValue?: string;
/**
* 源列表参数大小
*
* @type {number}
* @memberof ILogicNode
*/
srcSize?: number;
/**
* 逻辑节点连出连接集合
*
* @type {ILogicLink[]}
* @memberof ILogicNode
*/
logicLinks?: ILogicLink[];
/**
* 返回值类型
* @description 值模式 [云实体处理处理返回值类型] {NONEVALUE:无值(NONE)、 NULLVALUE:空值(NULL)、 SRCVALUE:直接值、 LOGICPARAM:逻辑参数对象、 LOGICPARAMFIELD:逻辑参数属性、 BREAK:跳出循环(BREAK) }
* @type {( string | 'NONEVALUE' | 'NULLVALUE' | 'SRCVALUE' | 'LOGICPARAM' | 'LOGICPARAMFIELD' | 'BREAK')}
*/
returnType?: string | 'NONEVALUE' | 'NULLVALUE' | 'SRCVALUE' | 'LOGICPARAM' | 'LOGICPARAMFIELD' | 'BREAK';
/**
* 返回参数
*
* @type {string}
* @memberof ILogicNode
*/
returnParam?: string;
/**
* 返回直接值
*
* @type {string}
* @memberof ILogicNode
*/
returnRawValue?: string;
}
\ No newline at end of file
export enum LogicParamType {
/**
* 简单数据变量
*/
simpleParam = 'simpleParam',
/**
* 数据对象变量
*/
entityParam = 'entityParam',
/**
* 分页查询结果变量
*/
entityPageParam = 'entityPageParam',
/**
* 数据对象列表变量
*/
entityListParam = 'entityListParam',
/**
* 上一次调用返回变量
*/
lastReturnParam = 'lastReturnParam',
/**
* 过滤器对象变量
*/
filterParam = 'filterParam',
/**
* 简单数据列表变量
*/
simpleListParam = 'simpleListParam',
/**
* 应用上下文变量
*/
appContextParam = 'appContextParam',
/**
* 应用全局变量
*/
appGlobalParam = 'appGlobalParam'
}
\ No newline at end of file
export enum LogicParamValueType{
/**
* 设置变量
*/
SETPARAMVALUE = "SETPARAMVALUE",
/**
* 重置变量
*/
RESETPARAM = "RESETPARAM",
/**
* 拷贝变量
*/
COPYPARAM = "COPYPARAM",
/**
* 绑定参数
*/
BINDPARAM = "BINDPARAM",
/**
* 重新建立变量
*/
RENEWPARAM = "RENEWPARAM",
/**
* 附加到数组变量
*/
APPENDPARAM = "APPENDPARAM",
/**
* 排序数组变量
*/
SORTPARAM = "SORTPARAM"
}
\ No newline at end of file
export enum LogicReturnType {
/**
* 无值(NONE)
*/
NONEVALUE = "NONEVALUE",
/**
* 空值(NULL)
*/
NULLVALUE = "NULLVALUE",
/**
* 直接值
*/
SRCVALUE = "SRCVALUE",
/**
* 逻辑参数对象
*/
LOGICPARAM = "LOGICPARAM",
/**
* 逻辑参数属性
*/
LOGICPARAMFIELD = "LOGICPARAMFIELD",
/**
* 跳出循环(BREAK)
*/
BREAK = "BREAK",
}
\ No newline at end of file
/**
* 实体处理逻辑上下文参数对象
*
* @export
* @class ActionContext
*/
export class ActionContext {
/**
* 实体行为服务context
*
* @type {IContext}
* @memberof ActionContext
*/
public appContext: any;
/**
* 逻辑处理参数集合
*
* @type {Map<string, any>}
* @memberof ActionContext
*/
public paramsMap: Map<string, any> = new Map();
/**
* 默认逻辑处理参数名称
*
* @type {string}
* @memberof ActionContext
*/
private defaultParamName: string = '';
/**
* 默认逻辑处理参数
*
* @readonly
* @memberof ActionContext
*/
get defaultParam() {
return this.paramsMap.get(this.defaultParamName);
}
/**
* 上一次调用返回参数名称
*
* @type {string}
* @memberof ActionContext
*/
private lastReturnParamName: string = '';
/**
* 绑定上一次调用返回参数
*
* @readonly
* @memberof ActionContext
*/
public bindLastReturnParam(value: any) {
const lastReturnParam = this.paramsMap.get(this.lastReturnParamName);
if (lastReturnParam) {
lastReturnParam.bind(value);
}
}
/**
* 应用上下文参数名称
*
* @type {string}
* @memberof ActionContext
*/
public appContextParamName: string = '';
/**
* 上下文数据(包括应用上下文和逻辑局部上下文参数)
*
* @readonly
* @memberof UIActionContext
*/
get context() {
const navContextParam = this.paramsMap.get(this.appContextParamName);
if (navContextParam) {
return navContextParam.getReal();
} else {
return this.appContext;
}
}
/**
* 获取逻辑处理参数
*
* @param {string} key 逻辑处理参数的codeName
* @memberof ActionContext
*/
public getParam(key: string) {
return this.paramsMap.get(key);
}
/**
* 返回结果
*
* @type {*}
* @memberof ActionContext
*/
private result: any;
/**
* 设置返回结果
*
* @param {*} opts
* @memberof ActionContext
*/
public setResult(opts: any) {
this.result = opts;
}
/**
* 获取返回结果
*
* @return {*}
* @memberof ActionContext
*/
public getResult() {
return this.result;
}
/**
* 构造函数
*
* @param {IPSAppDELogic} logic 处理逻辑模型对象
* @param {IContext} context 实体行为服务context
* @param {IParams} params 实体行为服务data
* @memberof ActionContext
*/
constructor(logicParams: any[], context: any, params: any) {
this.appContext = context;
// 初始化逻辑处理参数
// if (logic.getPSDELogicParams() && (logic.getPSDELogicParams() as IPSDELogicParam[]).length > 0) {
// for (let logicParam of (logic.getPSDELogicParams() as IPSDELogicParam[])) {
// const initValue = logicParam.default ? params : undefined;
// const logicParamInstance = AppDeLogicParamService.getLogicParamInstance(this, logicParam, initValue);
// this.paramsMap.set(logicParam.codeName, logicParamInstance);
// if (logicParam.default) this.defaultParamName = logicParam.codeName;
// if (logicParam.lastReturnParam) this.lastReturnParamName = logicParam.codeName;
// if(logicParam.appContextParam) this.appContextParamName = logicParam.codeName;
// }
// }
}
}
export * from './logic-node';
export { UIActionContext } from './uiaction-context';
\ No newline at end of file
import { ILogicNode } from "@/interface/logic";
import { UILogicNodeBase } from "./logic-node-base";
import { UIActionContext } from '../uiaction-context';
/**
* 附加到数组参数节点
*
* @export
* @class AppendParamNode
* @extends {LogicNodeBase}
*/
export class UILogicAppendParamNode extends UILogicNodeBase {
/**
* 执行节点
*
* @static
* @param {IPSDEAppendParamLogic} logicNode 逻辑节点
* @param {UIActionContext} actionContext 逻辑上下文
* @memberof AppDeLogicAppendParamNode
*/
public async executeNode(logicNode: ILogicNode, actionContext: UIActionContext) {
try {
this.onAppendParam(logicNode, actionContext);
return this.computeNextNodes(logicNode, actionContext);
} catch (error: any) {
throw new Error(`逻辑节点 ${logicNode.name}${error?.message ? error?.message : '发生未知错误!'}`);
}
}
/**
* 附加到数组
*
* @param {IPSDEAppendParamLogic} logicNode
* @param {UIActionContext} actionContext
* @memberof AppDeLogicAppendParamNode
*/
public onAppendParam(logicNode: ILogicNode, actionContext: UIActionContext) {
// 源数据
const srcParam: any = actionContext.getParam(logicNode.srcParam as string);
// 目标数据
const dstParam: any = actionContext.getParam(logicNode.dstParam as string);
// 源属性
const srcFieldName: string = (logicNode.srcFieldName as string).toLowerCase();
let objParam: any;
if (srcFieldName) {
// objParam = srcParam.get(srcFieldName);
objParam = srcParam.getReal();
} else {
objParam = srcParam.getReal();
}
dstParam.append(logicNode.dstIndex, objParam, logicNode.srcIndex, logicNode.srcSize);
actionContext.bindLastReturnParam(null);
}
}
\ No newline at end of file
import { ILogicNode } from "@/interface/logic/logic-node";
import { UIActionContext } from '../uiaction-context';
import { UILogicNodeBase } from "./logic-node-base";
export class UILogicBeginNode extends UILogicNodeBase {
/**
* 执行节点
*
* @static
* @param {IPSDELogicNode} logicNode 逻辑节点
* @param {ActionContext} actionContext 逻辑上下文
* @memberof AppDeLogicBeginNode
*/
public async executeNode(logicNode: ILogicNode, actionContext: UIActionContext) {
// 默认设置当前逻辑返回结果为当前默认输入参数
actionContext.setResult(actionContext.defaultParam.getReal());
return this.computeNextNodes(logicNode, actionContext);
}
}
\ No newline at end of file
import { ILogicNode } from "@/interface/logic";
import { UIActionContext } from "../uiaction-context";
import { UILogicNodeBase } from "./logic-node-base";
export class UILogicBindParamNode extends UILogicNodeBase {
/**
* 执行节点
*
* @param {IPSDEUIBindParamLogic} logicNode 逻辑节点模型数据
* @param {UIActionContext} actionContext 界面逻辑上下文
* @memberof AppUILogicBindParamNode
*/
public async executeNode(logicNode: ILogicNode, actionContext: UIActionContext) {
try {
this.onBindParam(logicNode, actionContext);
return this.computeNextNodes(logicNode, actionContext);
} catch (error: any) {
throw new Error(`逻辑节点 ${logicNode.name}${error?.message ? error?.message : '发生未知错误!'}`);
}
}
/**
* 处理参数
*
* @param {IPSDEUIBindParamLogic} logicNode 节点模型数据
* @param {UIActionContext} actionContext 逻辑上下文
* @memberof AppUILogicBindParamNode
*/
public onBindParam(logicNode: ILogicNode, actionContext: UIActionContext) {
if (!logicNode || !logicNode.dstParam || !logicNode.srcParam) {
throw new Error(`操作参数或者源参数缺失!`);
}
try {
// 源数据
const srcParam: any = actionContext.getParam(logicNode.srcParam);
// 目标数据
const dstParam: any = actionContext.getParam(logicNode.dstParam);
// 源属性
const srcFieldName: string = logicNode.srcFieldName ? logicNode.srcFieldName.toLowerCase() : '';
if (srcFieldName) {
dstParam.bind(srcParam.get(srcFieldName));
} else {
dstParam.bind(srcParam.getReal());
}
actionContext.bindLastReturnParam(null);
} catch (error: any) {
throw new Error(`逻辑参数${logicNode.dstParam}${error && error.message ? error.message : '发生未知错误!'}`);
}
}
}
\ No newline at end of file
import { ILogicNode } from "@/interface/logic";
import { UIActionContext } from "../uiaction-context";
import { UILogicNodeBase } from "./logic-node-base";
/**
* 拷贝参数节点
*
* @export
* @class UILogicCopyParamNode
* @extends {UILogicNodeBase}
*/
export class UILogicCopyParamNode extends UILogicNodeBase {
/**
* 执行节点
*
* @param {ILogicNode} logicNode 逻辑节点模型数据
* @param {UIActionContext} actionContext 界面逻辑上下文
* @memberof UILogicCopyParamNode
*/
public async executeNode(logicNode: ILogicNode, actionContext: UIActionContext) {
try {
this.onCopyParam(logicNode, actionContext);
return this.computeNextNodes(logicNode, actionContext);
} catch (error: any) {
throw new Error(`逻辑节点 ${logicNode.name}${error && error.message ? error.message : "发生未知错误!"}`);
}
}
/**
* 处理参数
*
* @param {ILogicNode} logicNode 节点模型数据
* @param {UIActionContext} actionContext 逻辑上下文
* @memberof UILogicCopyParamNode
*/
public onCopyParam(logicNode: ILogicNode, actionContext: UIActionContext) {
if (!logicNode || !logicNode.dstParam || !logicNode.srcParam) {
throw new Error(`操作参数或者源参数缺失!`);
}
try {
// 源数据
const srcParam: any = actionContext.getParam(logicNode.srcParam);
// 目标数据
const dstParam: any = actionContext.getParam(logicNode.dstParam);
srcParam.copyTo(dstParam);
actionContext.bindLastReturnParam(null);
} catch (error: any) {
throw new Error(
`逻辑参数${logicNode.dstParam}${error && error.message ? error.message : "发生未知错误!"}`
);
}
}
}
import { ILogicNode } from "@/interface/logic";
import { UIActionContext } from "../uiaction-context";
import { UILogicNodeBase } from "./logic-node-base";
/**
* 实体行为调用节点
*
* @export
* @class AppUILogicDeactionNode
*/
export class UILogicDeActionNode extends UILogicNodeBase {
/**
* 执行节点
*
* @param {ILogicNode} logicNode 逻辑节点模型数据
* @param {UIActionContext} actionContext 界面逻辑上下文
* @memberof AppUILogicDeactionNode
*/
public async executeNode(logicNode: ILogicNode, actionContext: UIActionContext) {
try {
await this.handleDEAction(logicNode, actionContext);
return this.computeNextNodes(logicNode, actionContext);
} catch (error: any) {
throw new Error(`逻辑节点 ${logicNode.name}${error && error.message ? error.message : '发生未知错误!'}`);
}
}
/**
* 处理实体行为
*
* @private
* @param {ILogicNode} logicNode 逻辑节点模型数据
* @param {UIActionContext} actionContext 界面逻辑上下文
* @memberof AppUILogicDeactionNode
*/
private async handleDEAction(logicNode: ILogicNode, actionContext: UIActionContext) {
// const dstEntity = logicNode.getDstPSAppDataEntity();
// const deAction = await getDstPSAppDEAction(logicNode);
// const dstParam = actionContext.getParam((logicNode.getDstPSDEUILogicParam() as IPSDEUILogicParam)?.codeName);
// if (!Object.is(dstParam.logicParamType, UILogicParamType.entityListParam) && !Object.is(dstParam.logicParamType, UILogicParamType.entityParam)) {
// throw new Error(`实体行为操作参数只能为数据对象变量类型或者数据对象列表类型`);
// }
// const retParam = actionContext.getParam((logicNode.getRetPSDEUILogicParam() as IPSDEUILogicParam)?.codeName);
// if (dstEntity && deAction && dstParam) {
// try {
// const service = await DataServiceHelp.getInstance().getService(dstEntity);
// const getTempContext = (data: any) => {
// const tempContext = Util.deepCopy(actionContext.context);
// if (data) {
// Object.assign(tempContext, data);
// }
// return tempContext;
// }
// // 数据对象变量类型
// if (Object.is(dstParam.logicParamType, UILogicParamType.entityParam)) {
// const tempContext = getTempContext(dstParam.getReal());
// const res = await service.execute(deAction.codeName, tempContext, dstParam.getReal() ? dstParam.getReal() : {});
// if (res && res.ok && res.data) {
// if (retParam) {
// retParam.bind(res.data);
// }
// actionContext.bindLastReturnParam(res.data);
// } else {
// throw new Error(`执行实体行为失败`);
// }
// } else {
// // 数据对象列表类型
// if (dstParam.getReal() && (dstParam.getReal().length > 0)) {
// if (dstParam.getReal().length > 20) {
// throw new Error(`操作数据量超过20条,建议使用后台处理逻辑`);
// }
// let promises: any[] = [];
// dstParam.getReal().forEach((item: any) => {
// const tempContext = getTempContext(item);
// promises.push(service.execute(deAction.codeName, tempContext, item ? item : {}));
// })
// const resArray = await Promise.all(promises);
// if (resArray && resArray.length > 0) {
// const resultArray: any[] = [];
// resArray.forEach((res: any) => {
// if (res && res.ok && res.data) {
// resultArray.push(res.data);
// }
// })
// if (retParam) {
// retParam.bind(resultArray);
// }
// actionContext.bindLastReturnParam(resultArray);
// } else {
// throw new Error(`执行实体行为失败`);
// }
// } else {
// if (retParam) {
// retParam.bind([]);
// }
// actionContext.bindLastReturnParam([]);
// }
// }
// } catch (error: any) {
// throw new Error(`${error.message ? error.message : error.data?.message ? error.data.message : '执行实体行为失败'}`);
// }
// } else {
// throw new Error(`执行实体行为所需参数不足`);
// }
}
}
\ No newline at end of file
import { ILogicNode } from '@/interface/logic';
import { UIActionContext } from '../uiaction-context';
import { UILogicNodeBase } from './logic-node-base';
/**
* 调试逻辑参数节点
*
* @export
* @class UILogicDebugParamNode
*/
export class UILogicDebugParamNode extends UILogicNodeBase {
constructor() {
super();
}
/**
* 执行节点
*
* @param {ILogicNode} logicNode 逻辑节点模型数据
* @param {UIActionContext} actionContext 界面逻辑上下文
* @memberof UILogicDebugParamNode
*/
public async executeNode(logicNode: ILogicNode, actionContext: UIActionContext) {
try {
this.handleDebugParam(logicNode, actionContext);
return this.computeNextNodes(logicNode, actionContext);
} catch (error: any) {
throw new Error(`逻辑节点 ${logicNode.name}${error?.message ? error?.message : '发生未知错误!'}`);
}
}
/**
* 处理调试逻辑参数
*
* @private
* @param {ILogicNode} logicNode
* @param {UIActionContext} actionContext
* @memberof UILogicDebugParamNode
*/
private handleDebugParam(logicNode: ILogicNode, actionContext: UIActionContext) {
// if (logicNode.getDstPSDEUILogicParam()) {
// const dstParamValue = actionContext.getParam(logicNode.getDstPSDEUILogicParam()?.codeName as string).getReal();
// actionContext.bindLastReturnParam(null);
// console.log(`逻辑节点${logicNode.name}操作参数值:`, dstParamValue);
// }
}
}
\ No newline at end of file
import { ILogicNode } from "@/interface/logic";
import { UIActionContext } from "../uiaction-context";
import { UILogicNodeBase } from "./logic-node-base";
/**
* 实体数据集节点
*
* @export
* @class UILogicDataSetNode
* @extends {AppUILogicNodeBase}
*/
export class UILogicDataSetNode extends UILogicNodeBase {
constructor() {
super();
}
/**
* 执行节点
*
* @static
* @param {ILogicNode} logicNode 逻辑节点
* @param {ActionContext} actionContext 逻辑上下文
* @memberof UILogicDataSetNode
*/
public async executeNode(logicNode: ILogicNode, actionContext: UIActionContext) {
try {
await this.handleDataSet(logicNode, actionContext);
return this.computeNextNodes(logicNode, actionContext);
} catch (error: any) {
throw new Error(`逻辑节点 ${logicNode.name}${error?.message ? error?.message : '发生未知错误!'}`);
}
}
/**
* 处理实体数据集
*
* @private
* @param {ILogicNode} logicNode
* @param {ActionContext} actionContext
* @memberof UILogicDataSetNode
*/
private async handleDataSet(logicNode: ILogicNode, actionContext: UIActionContext) {
// const dstEntity = logicNode.getDstPSAppDataEntity();
// await dstEntity?.fill();
// const dstDataSet = logicNode.getDstPSAppDEDataSet();
// // 过滤器
// const dstParamModel = logicNode.getDstPSDEUILogicParam();
// const dstParam = actionContext.getParam(dstParamModel?.codeName as string);
// if (!dstParamModel || !Object.is(dstParam.logicParamType, UILogicParamType.filterParam)) {
// throw new Error(`传入参数${dstParamModel?.codeName}类型不正确,必须为过滤器对象`);
// }
// if (dstEntity && dstDataSet) {
// try {
// const service = await DataServiceHelp.getInstance().getService(dstEntity);
// const res = await service.execute(dstDataSet.codeName, actionContext.context, dstParam.getReal() ? dstParam.getReal() : {});
// if (res && res.ok && res.data) {
// // 返回值绑定逻辑参数对象
// if (logicNode.getRetPSDEUILogicParam()) {
// const retParam = actionContext.getParam(logicNode.getRetPSDEUILogicParam()?.codeName as string);
// retParam.bind(res.data);
// }
// actionContext.bindLastReturnParam(res.data);
// } else {
// throw new Error(`查询实体数据集失败`);
// }
// } catch (error: any) {
// throw new Error(`${error.message ? error.message : error.data?.message ? error.data.message : '查询实体数据集失败'}`);
// }
// } else {
// throw new Error(`查询实体数据集参数不足`);
// }
}
}
\ No newline at end of file
import { ILogicNode } from '@/interface/logic';
import { UIActionContext } from '../uiaction-context';
import { UILogicNodeBase } from './logic-node-base';
/**
* 实体处理逻辑节点
*
* @export
* @class UILogicNodeBase
*/
export class UILogicDeLogicNode extends UILogicNodeBase {
constructor() {
super();
}
/**
* 执行节点
*
* @param {ILogicNode} logicNode 逻辑节点模型数据
* @param {UIActionContext} actionContext 界面逻辑上下文
* @memberof UILogicDeLogicNode
*/
public async executeNode(logicNode: ILogicNode, actionContext: UIActionContext) {
try {
await this.handleDELogic(logicNode, actionContext);
return this.computeNextNodes(logicNode, actionContext);
} catch (error: any) {
throw new Error(`逻辑节点 ${logicNode.name}${error?.message ? error?.message : '发生未知错误!'}`);
}
}
/**
* 处理实体处理逻辑
*
* @private
* @param {ILogicNode} logicNode 逻辑节点模型数据
* @param {UIActionContext} actionContext 界面逻辑上下文
* @memberof UILogicDeLogicNode
*/
private async handleDELogic(logicNode: ILogicNode, actionContext: UIActionContext) {
// const dstEntity = logicNode.getDstPSAppDataEntity();
// const deLogicCodeName = logicNode.getDstPSAppDELogic()?.codeName;
// const dstParam = actionContext.getParam((logicNode.getDstPSDEUILogicParam() as IPSDEUILogicParam)?.codeName);
// const retParam = actionContext.getParam((logicNode.getRetPSDEUILogicParam() as IPSDEUILogicParam)?.codeName);
// if (dstEntity && dstParam && deLogicCodeName) {
// try {
// const service = await DataServiceHelp.getInstance().getService(dstEntity);
// const result = await service['executeAppDELogic'](deLogicCodeName, actionContext.context, dstParam.getReal() ? dstParam.getReal() : {});
// if (result) {
// if(retParam){
// retParam.bind(result);
// }
// actionContext.bindLastReturnParam(result);
// return retParam;
// } else {
// throw new Error(`调用实体处理逻辑异常`);
// }
// } catch (error: any) {
// throw new Error(`调用实体处理逻辑异常${error?.message ? error.message : ''}`);
// }
// } else {
// throw new Error(`调用实体处理逻辑参数不足`);
// }
}
}
\ No newline at end of file
import { ILogicNode } from '@/interface/logic';
import { UIActionContext } from '../uiaction-context';
import { UILogicNodeBase } from './logic-node-base';
/**
* 实体界面行为调用节点
*
* @export
* @class AppUILogicDeUIActionNode
*/
export class UILogicDeUIActionNode extends UILogicNodeBase {
constructor() {
super();
}
/**
* 执行节点
*
* @param {ILogicNode} logicNode 逻辑节点模型数据
* @param {UIActionContext} actionContext 界面逻辑上下文
* @memberof AppUILogicDeUIActionNode
*/
public async executeNode(logicNode: ILogicNode, actionContext: UIActionContext) {
try {
await this.handleDEUIAction(logicNode, actionContext);
return this.computeNextNodes(logicNode, actionContext)
} catch (error: any) {
throw new Error(`逻辑节点 ${logicNode.name}${error && error.message ? error.message : '发生未知错误!'}`);
}
}
/**
* 处理界面行为
*
* @private
* @param {ILogicNode} logicNode
* @param {UIActionContext} actionContext
* @memberof AppUILogicDeUIActionNode
*/
private async handleDEUIAction(logicNode: ILogicNode, actionContext: UIActionContext) {
// const data = actionContext.defaultParam.getReal();
// const { context, viewparams } = actionContext;
// const additionalParam = actionContext.additionalParam;
// const dstEntity = logicNode.getDstPSAppDataEntity();
// const dstUIAction = await getDstPSAppDEUIAction(logicNode);
// if (dstEntity && dstUIAction) {
// try {
// const targetUIService = await UIServiceHelp.getInstance().getService(dstEntity,{context});
// await targetUIService.loaded();
// const result = await targetUIService.excuteAction(
// dstUIAction.uIActionTag,
// [data],
// context,
// viewparams,
// additionalParam?.$event,
// actionContext.getParam(actionContext.activeCtrlParamName).getReal(),
// actionContext.getParam(actionContext.activeContainerParamName).getReal(),
// additionalParam?.parentDeName,
// );
// const dstParam = actionContext.getParam((logicNode.getDstPSDEUILogicParam() as IPSDEUILogicParam)?.codeName);
// if (result && result.ok && result.result) {
// dstParam.bind(Array.isArray(result?.result) ? result.result[0] : result.result);
// actionContext.bindLastReturnParam(Array.isArray(result?.result) ? result.result[0] : result.result);
// }
// return dstParam;
// } catch (error: any) {
// throw new Error(`调用实体行为异常${error?.message ? error.message : ''}`);
// }
// } else {
// throw new Error(`调用界面行为参数不足`);
// }
}
}
\ No newline at end of file
import { ILogicNode } from "@/interface/logic";
import { LogicReturnType } from "@/logic/const/logic-return-type";
import { UIActionContext } from "../uiaction-context";
import { UILogicNodeBase } from "./logic-node-base";
/**
* 结束节点
*
* @export
* @class EndNode
*/
export class UILogicEndNode extends UILogicNodeBase {
/**
* 执行节点
*
* @param {ILogicNode} logicNode
* @param {UIActionContext} actionContext
* @return {*}
* @memberof EndNode
*/
public async executeNode(logicNode: ILogicNode, actionContext: UIActionContext) {
try {
this.handleEndNode(logicNode, actionContext);
console.log(`已完成执行${logicNode?.name}节点,操作参数数据如下:`);
if (actionContext.paramsMap && (actionContext.paramsMap.size > 0)) {
for (let [key, value] of actionContext.paramsMap) {
console.log(`${key}:`, value.getReal());
}
}
return { nextNodes: [], actionContext };
} catch (error: any) {
throw new Error(`逻辑节点 ${logicNode.name}${error && error.message ? error.message : '发生未知错误!'}`);
}
}
/**
* 处理结束节点
*
* @private
* @param {IPSDEEndLogic} logicNode
* @param {UIActionContext} actionContext
* @memberof EndNode
*/
private handleEndNode(logicNode: ILogicNode, actionContext: UIActionContext) {
const strReturnType: string = logicNode.returnType as string;
if (Object.is(strReturnType, LogicReturnType.NONEVALUE) || Object.is(strReturnType, LogicReturnType.NULLVALUE)) {
actionContext.setResult(null);
} else if (Object.is(strReturnType, LogicReturnType.SRCVALUE)) {
actionContext.setResult(logicNode.returnRawValue);
} else if (Object.is(strReturnType, LogicReturnType.BREAK)) {
actionContext.setResult(LogicReturnType.BREAK);
} else if (Object.is(strReturnType, LogicReturnType.LOGICPARAM) || Object.is(strReturnType, LogicReturnType.LOGICPARAMFIELD)) {
const returnParam = actionContext.getParam(logicNode.returnParam as string);
if (Object.is(strReturnType, LogicReturnType.LOGICPARAM)) {
actionContext.setResult(returnParam.getReal());
} else {
actionContext.setResult(returnParam.get(logicNode.dstFieldName));
}
} else {
throw new Error(`无法识别的返回值类型${strReturnType}`);
}
}
}
\ No newline at end of file
export { UILogicAppendParamNode } from './appendparam-node';
export { UILogicBeginNode } from './begin-node';
export { UILogicBindParamNode } from './bindparam-node';
export { UILogicCopyParamNode } from './copyparam-node';
export { UILogicDeActionNode } from './deaction-node';
export { UILogicDebugParamNode } from './debugparam-node';
export { UILogicDataSetNode } from './dedataset-node';
export { UILogicDeLogicNode } from './delogic-node';
export { UILogicDeUIActionNode } from './deuiaction-node';
export { UILogicEndNode } from './end-node';
export { UILogicNodeBase } from './logic-node-base';
export { UILogicMsgboxNode } from './msgbox-node';
export { UILogicPluginNode } from './plugin-node';
export { UILogicPrepareParamNode } from './prepareparam-node';
export { UILogicRawCodeNode } from './rawcode-node';
export { UILogicReNewParamNode } from './renewparam-node';
export { UILogicResetParamNode } from './resetparam-node';
export { UILogicSortParamNode } from './sortparam-node';
export { UILogicThrowExceptionNode } from './throw-exception-node';
export { UILogicViewctrlFireEventNode } from './viewctrl-fire-event';
export { UILogicViewctrlInvokeNode } from './viewctrl-invoke-node';
\ No newline at end of file
import { ILogicNode } from "@/interface/logic";
import { Util, Verify } from "@/utils";
import { UIActionContext } from "../uiaction-context";
/**
* 处理逻辑节点基类
*
* @export
* @class UILogicNodeBase
*/
export class UILogicNodeBase {
constructor() {}
/**
* 根据处理链接计算后续逻辑节点
*
* @param {*} logicNode
* @param {UIActionContext} actionContext
* @return {*}
* @memberof LogicNodeBase
*/
public computeNextNodes(logicNode: ILogicNode, actionContext: UIActionContext) {
console.log(`已完成执行${logicNode?.name}节点,操作参数数据如下:`)
if (actionContext.paramsMap && (actionContext.paramsMap.size > 0)) {
for (let [key, value] of actionContext.paramsMap) {
console.log(`${key}:`, Util.deepCopy(value.getReal()));
}
}
let result: any = { nextNodes: [], actionContext };
if (logicNode && logicNode.logicLinks && logicNode.logicLinks.length > 0) {
for (let logicLink of logicNode.logicLinks) {
let nextNode = logicLink.dstLogicNode;
// 没有连接条件组或有条件组且满足条件组时执行下一个节点
if (!logicLink.dstLogicNode || this.computeCond(logicLink.linkGroupCond || [], actionContext)) {
// console.log(`即将执行${nextNode?}节点`);
console.log('执行下一节点');
result.nextNodes.push(nextNode);
}
}
}
return result;
}
/**
* 计算是否通过逻辑连接
*
* @param {} logicLinkCond
* @return {*}
* @memberof UILogicNodeBase
*/
public computeCond(logicLinkCond: any, actionContext: UIActionContext): any {
if (logicLinkCond.logicType == 'GROUP') {
const logicLinkGroupCond = logicLinkCond
const childConds: any = logicLinkGroupCond.getPSDELogicLinkConds();
if (childConds?.length > 0) {
// return Verify.logicForEach(
// childConds,
// (item: any) => {
// return this.computeCond(item, actionContext);
// },
// logicLinkGroupCond.groupOP,
// !!logicLinkGroupCond.notMode,
// );
}
} else {
if (logicLinkCond.logicType == 'SINGLE') {
const logicLinkSingleCond = logicLinkCond
let dstValue = actionContext.getParam(logicLinkSingleCond?.getDstLogicParam?.()?.codeName as string);
if (logicLinkSingleCond.dstFieldName) {
dstValue = dstValue.get(logicLinkSingleCond.dstFieldName.toLowerCase());
}
let targetValue;
if (logicLinkSingleCond.paramType) {
switch (logicLinkSingleCond.paramType) {
case 'CURTIME':
targetValue = Util.dateFormat(new Date(), 'YYYY-MM-DD');
break;
default:
targetValue = logicLinkSingleCond.paramValue;
}
} else {
targetValue = logicLinkSingleCond.paramValue;
}
return Verify.testCond(dstValue, logicLinkSingleCond.condOP, targetValue)
}
}
}
}
\ No newline at end of file
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);
}
}
\ No newline at end of file
import { ILogicNode } from '@/interface/logic';
import { UIActionContext } from '../uiaction-context';
import { UILogicNodeBase } from './logic-node-base';
/**
* 前端扩展插件调用节点
*
* @export
* @class UILogicPluginNode
*/
export class UILogicPluginNode extends UILogicNodeBase {
constructor() {
super();
}
/**
* 执行节点
*
* @param {ILogicNode} logicNode 逻辑节点模型数据
* @param {UIActionContext} actionContext 界面逻辑上下文
* @memberof UILogicPluginNode
*/
public async executeNode(logicNode: ILogicNode, actionContext: UIActionContext) {
throw new Error(`逻辑节点${logicNode.name}前端扩展插件类型暂未实现!`);
}
}
\ No newline at end of file
此差异已折叠。
import { ILogicNode } from '@/interface/logic';
import { UIActionContext } from '../uiaction-context';
import { UILogicNodeBase } from './logic-node-base';
/**
* 直接前台代码节点
*
* @export
* @class UILogicRawCodeNode
*/
export class UILogicRawCodeNode extends UILogicNodeBase {
constructor() {
super();
}
/**
* 执行节点
*
* @param {ILogicNode} logicNode 逻辑节点模型数据
* @param {UIActionContext} actionContext 界面逻辑上下文
* @memberof UILogicRawCodeNode
*/
public async executeNode(logicNode: ILogicNode, actionContext: UIActionContext) {
try {
this.handleRawCode(logicNode, actionContext);
return this.computeNextNodes(logicNode, actionContext);
} catch (error: any) {
throw new Error(`逻辑节点 ${logicNode.name}${error && error.message ? error.message : '发生未知错误!'}`);
}
}
/**
* 处置直接执行代码
*
* @private
* @param {ILogicNode} logicNode
* @param {UIActionContext} actionContext
* @memberof UILogicRawCodeNode
*/
private handleRawCode(logicNode: ILogicNode, actionContext: UIActionContext) {
// let data: any = actionContext.defaultParam.getReal();
// let { context } = actionContext;
// if (logicNode && logicNode.code) {
// eval(logicNode?.code);
// } else {
// throw new Error('无代码片段');
// }
// actionContext.bindLastReturnParam(null);
}
}
\ No newline at end of file
import { ILogicNode } from '@/interface/logic';
import { UIActionContext } from '../uiaction-context';
import { UILogicNodeBase } from './logic-node-base';
/**
* 重新建立参数节点
*
* @export
* @class UILogicReNewParamNode
*/
export class UILogicReNewParamNode extends UILogicNodeBase {
constructor() {
super();
}
/**
* 执行节点
*
* @param {ILogicNode} logicNode 逻辑节点模型数据
* @param {UIActionContext} actionContext 界面逻辑上下文
* @memberof UILogicReNewParamNode
*/
public async executeNode(logicNode: ILogicNode, actionContext: UIActionContext) {
try {
this.onRenewParam(logicNode, actionContext);
return this.computeNextNodes(logicNode, actionContext);
} catch (error: any) {
throw new Error(`逻辑节点 ${logicNode.name}${error && error.message ? error.message : '发生未知错误!'}`);
}
}
/**
* 处理参数
*
* @param {ILogicNode} logicNode 节点模型数据
* @param {UIActionContext} actionContext 逻辑上下文
* @memberof UILogicReNewParamNode
*/
public onRenewParam(logicNode: ILogicNode, actionContext: UIActionContext) {
// if (!logicNode || !logicNode.getDstPSDEUILogicParam()) {
// throw new Error(`操作参数缺失!`);
// }
// try {
// // 目标数据
// const dstParam: any = actionContext.getParam((logicNode.getDstPSDEUILogicParam() as IPSDEUILogicParam)?.codeName);
// dstParam.renew();
// actionContext.bindLastReturnParam(null);
// } catch (error: any) {
// throw new Error(`逻辑参数${logicNode.getDstPSDEUILogicParam()?.name}${error && error.message ? error.message : '发生未知错误!'}`);
// }
}
}
\ No newline at end of file
import { ILogicNode } from '@/interface/logic';
import { UIActionContext } from '../uiaction-context';
import { UILogicNodeBase } from './logic-node-base';
/**
* 重置参数节点
*
* @export
* @class UILogicResetParamNode
*/
export class UILogicResetParamNode extends UILogicNodeBase {
constructor() {
super();
}
/**
* 执行节点
*
* @param {ILogicNode} logicNode 逻辑节点模型数据
* @param {UIActionContext} actionContext 界面逻辑上下文
* @memberof UILogicResetParamNode
*/
public async executeNode(logicNode: ILogicNode, actionContext: UIActionContext) {
try {
this.onResetParam(logicNode, actionContext);
return this.computeNextNodes(logicNode, actionContext);
} catch (error: any) {
throw new Error(`逻辑节点 ${logicNode.name}${error && error.message ? error.message : '发生未知错误!'}`);
}
}
/**
* 处理参数
*
* @param {IPSDELogicNode} logicNode 节点模型数据
* @param {ActionContext} actionContext 逻辑上下文
* @memberof UILogicResetParamNode
*/
public onResetParam(logicNode: ILogicNode, actionContext: UIActionContext) {
// if (!logicNode || !logicNode.getDstPSDEUILogicParam()) {
// throw new Error(`操作参数缺失!`);
// }
// try {
// // 目标数据
// const dstParam: any = actionContext.getParam((logicNode.getDstPSDEUILogicParam() as IPSDEUILogicParam)?.codeName);
// dstParam.resetAll();
// actionContext.bindLastReturnParam(null);
// } catch (error: any) {
// throw new Error(`逻辑参数${logicNode.getDstPSDEUILogicParam()?.name}${error && error.message ? error.message : '发生未知错误!'}`);
// }
}
}
\ No newline at end of file
import { ILogicNode } from '@/interface/logic';
import { UIActionContext } from '../uiaction-context';
import { UILogicNodeBase } from './logic-node-base';
/**
* 排序数组参数节点
*
* @export
* @class UILogicSortParamNode
*/
export class UILogicSortParamNode extends UILogicNodeBase {
constructor() {
super();
}
/**
* 执行节点
*
* @param {ILogicNode} logicNode 逻辑节点模型数据
* @param {UIActionContext} actionContext 界面逻辑上下文
* @memberof UILogicSortParamNode
*/
public async executeNode(logicNode: ILogicNode, actionContext: UIActionContext) {
try {
this.onSortParam(logicNode, actionContext);
return this.computeNextNodes(logicNode, actionContext);
} catch (error: any) {
throw new Error(`逻辑节点 ${logicNode.name}${error && error.message ? error.message : '发生未知错误!'}`);
}
}
/**
* 排序数组变量
*
* @param {ILogicNode} logicNodeParam
* @param {UIActionContext} actionContext
* @memberof UILogicPrepareParamNode
*/
public onSortParam(logicNodeParam: ILogicNode, actionContext: UIActionContext) {
// // 目标数据
// const dstParam: any = actionContext.getParam((logicNodeParam.getDstPSDEUILogicParam() as IPSDEUILogicParam)?.codeName);
// // 目标属性
// const dstFieldName: string = logicNodeParam.dstFieldName?.toLowerCase?.();
// if (!dstFieldName) {
// throw new Error(`逻辑参数${logicNodeParam.name}未指定设置排序属性`);
// }
// dstParam.sort(dstFieldName, logicNodeParam.dstSortDir);
// actionContext.bindLastReturnParam(null);
}
}
\ No newline at end of file
import { ILogicNode } from '@/interface/logic';
import { UIActionContext } from '../uiaction-context';
import { UILogicNodeBase } from './logic-node-base';
/**
* 抛出异常节点
*
* @export
* @class UILogicThrowExceptionNode
*/
export class UILogicThrowExceptionNode extends UILogicNodeBase {
constructor() {
super();
}
/**
* 执行节点
*
* @param {ILogicNode} logicNode 逻辑节点模型数据
* @param {UIActionContext} actionContext 界面逻辑上下文
* @memberof UILogicThrowExceptionNode
*/
public async executeNode(logicNode: ILogicNode, actionContext: UIActionContext) {
// actionContext.actionContainer.$throw(logicNode.errorInfo);
// actionContext.bindLastReturnParam(null);
// console.log(`已完成执行${logicNode?.name}节点,操作参数数据如下:`);
// if (actionContext.paramsMap && (actionContext.paramsMap.size > 0)) {
// for (let [key, value] of actionContext.paramsMap) {
// console.log(`${key}:`, value.getReal());
// }
// }
}
}
\ No newline at end of file
import { ILogicNode } from '@/interface/logic';
import { UIActionContext } from '../uiaction-context';
import { UILogicNodeBase } from './logic-node-base';
/**
* 视图部件事件触发节点
*
* @export
* @class UILogicViewctrlFireEventNode
*/
export class UILogicViewctrlFireEventNode extends UILogicNodeBase {
constructor() {
super();
}
/**
* 执行节点
*
* @param {ILogicNode} logicNode 逻辑节点模型数据
* @param {UIActionContext} actionContext 界面逻辑上下文
* @memberof UILogicViewctrlFireEventNode
*/
public async executeNode(logicNode: ILogicNode, actionContext: UIActionContext) {
try {
await this.handleViewCtrFireEvent(logicNode, actionContext);
return this.computeNextNodes(logicNode, actionContext);
} catch (error: any) {
throw new Error(`逻辑节点 ${logicNode.name}${error && error.message ? error.message : '发生未知错误!'}`);
}
}
/**
* 处理视图部件触发事件
*
* @private
* @param {ILogicNode} logicNode
* @param {UIActionContext} actionContext
* @memberof UILogicViewctrlFireEventNode
*/
private async handleViewCtrFireEvent(logicNode: ILogicNode, actionContext: UIActionContext) {
// // 事件名称
// const eventName = logicNode.eventName;
// // 事件参数
// const eventParam = logicNode.getEventParam();
// // 触发对象
// const fireCtrl = logicNode.getFireCtrl();
// if (!eventName || !eventParam || !fireCtrl) {
// throw new Error(`触发对象、事件名称或者事件参数缺失`);
// }
// // 触发UI对象
// const fireUICtrl = actionContext.getParam(fireCtrl.codeName).getReal();
// // 事件参数
// const eventArgs = actionContext.getParam(eventParam.codeName).getReal();
// if (!fireUICtrl) {
// throw new Error(`获取触发对象异常`);
// }
// try {
// // 自身触发
// fireUICtrl.$emit(eventName, eventArgs);
// // 如果是部件,需向视图抛出
// if (fireUICtrl.controlInstance) {
// fireUICtrl.ctrlEvent({
// controlname: fireUICtrl.controlInstance.name,
// action: eventName,
// data: eventArgs
// })
// }
// // 如果是视图,需向外抛出
// if (fireUICtrl.viewInstance) {
// fireUICtrl.$emit('view-event', { viewName: fireUICtrl.viewCodeName, action: eventName, data: eventArgs });
// }
// actionContext.bindLastReturnParam(null);
// } catch (error:any) {
// throw new Error(`视图部件事件触发未执行成功!`);
// }
}
}
\ No newline at end of file
import { ILogicNode } from '@/interface/logic';
import { UIActionContext } from '../uiaction-context';
import { UILogicNodeBase } from './logic-node-base';
/**
* 视图部件调用节点
*
* @export
* @class UILogicViewctrlInvokeNode
*/
export class UILogicViewctrlInvokeNode extends UILogicNodeBase {
constructor() {
super();
}
/**
* 执行节点
*
* @param {ILogicNode} logicNode 逻辑节点模型数据
* @param {UIActionContext} actionContext 界面逻辑上下文
* @memberof UILogicViewctrlInvokeNode
*/
public async executeNode(logicNode: ILogicNode, actionContext: UIActionContext) {
try {
await this.handleViewCtrlInvoke(logicNode, actionContext);
return this.computeNextNodes(logicNode, actionContext);
} catch (error: any) {
throw new Error(`逻辑节点 ${logicNode.name}${error && error.message ? error.message : '发生未知错误!'}`);
}
}
/**
* 处理视图部件调用
*
* @private
* @param {ILogicNode} logicNode
* @param {UIActionContext} actionContext
* @memberof UILogicViewctrlInvokeNode
*/
private async handleViewCtrlInvoke(logicNode: ILogicNode, actionContext: UIActionContext) {
// const invokeCtrl = logicNode.getInvokeCtrl()?.codeName;
// const invokeMethod = logicNode.invokeMethod;
// const invokeParam = logicNode.getInvokeParam()?.codeName;
// if (!invokeCtrl || !invokeMethod) {
// throw new Error(`界面对象或者调用方法缺失`);
// }
// const invokeUICtrl = actionContext.getParam(invokeCtrl).getReal();
// if (invokeUICtrl[invokeMethod] && invokeUICtrl[invokeMethod] instanceof Function) {
// try {
// const result = await invokeUICtrl[invokeMethod]();
// if (invokeParam) {
// actionContext.getParam(invokeParam).bind(result);
// }
// actionContext.bindLastReturnParam(result);
// } catch (error:any) {
// throw new Error(`${invokeCtrl}界面对象调用${invokeMethod}方法发生异常`);
// }
// } else {
// throw new Error(`${invokeCtrl}界面对象不存在${invokeMethod}方法`);
// }
}
}
\ No newline at end of file
/**
* 界面处理逻辑上下文参数对象
*
* @export
* @class UIActionContext
*/
export class UIActionContext {
/**
* 应用上下文
*
* @type {IContext}
* @memberof UIActionContext
*/
private appContext: any;
/**
* 视图参数
*
* @type {IParams}
* @memberof UIActionContext
*/
private viewParam: any;
/**
* 默认逻辑处理参数名称
*
* @type {string}
* @memberof UIActionContext
*/
public defaultParamName: string = '';
/**
* 应用上下文参数名称
*
* @type {string}
* @memberof UIActionContext
*/
public navContextParamName: string = '';
/**
* 视图参数名称
*
* @type {string}
* @memberof UIActionContext
*/
public navViewParamParamName: string = '';
/**
* 当前容器对象名称
*
* @type {string}
* @memberof UIActionContext
*/
public activeContainerParamName: string = '';
/**
* 当前激活部件对象名称
*
* @type {string}
* @memberof UIActionContext
*/
public activeCtrlParamName: string = '';
/**
* 当前激活视图对象名称
*
* @type {string}
* @memberof UIActionContext
*/
public activeViewParamName: string = '';
/**
* 容器对象
*
* @type {*}
* @memberof UIActionContext
*/
public actionContainer: any;
/**
* 附加参数
*
* @type {*}
* @memberof UIActionContext
*/
public additionalParam: any;
/**
* 逻辑处理参数集合
*
* @type {Map<string, any>}
* @memberof UIActionContext
*/
public paramsMap: Map<string, any> = new Map();
/**
* 默认逻辑处理参数
*
* @readonly
* @memberof UIActionContext
*/
get defaultParam() {
return this.paramsMap.get(this.defaultParamName);
}
/**
* 上下文数据(包括应用上下文和逻辑局部上下文参数)
*
* @readonly
* @memberof UIActionContext
*/
get context() {
const navContextParam = this.paramsMap.get(this.navContextParamName);
if (navContextParam) {
return navContextParam.getReal();
} else {
return this.appContext;
}
}
/**
* 视图参数数据(包括外部传入视图参数和逻辑局部视图参数)
*
* @readonly
* @memberof UIActionContext
*/
get viewparams() {
const navViewParamParam = this.paramsMap.get(this.navViewParamParamName);
if (navViewParamParam) {
return navViewParamParam.getReal();
} else {
return this.viewParam;
}
}
/**
* 获取逻辑处理参数
*
* @param {string} key 逻辑处理参数的codeName
* @memberof UIActionContext
*/
public getParam(key: string) {
return this.paramsMap.get(key);
}
/**
* 返回结果
*
* @type {*}
* @memberof UIActionContext
*/
private result: any;
/**
* 设置返回结果
*
* @param {*} opts
* @memberof UIActionContext
*/
public setResult(opts: any) {
this.result = opts;
}
/**
* 获取返回结果
*
* @return {*}
* @memberof UIActionContext
*/
public getResult() {
return this.result;
}
/**
* 上一次调用返回参数名称
*
* @type {string}
* @memberof UIActionContext
*/
private lastReturnParamName: string = '';
/**
* 绑定上一次调用返回参数
*
* @readonly
* @memberof UIActionContext
*/
public bindLastReturnParam(value: any) {
const lastReturnParam = this.paramsMap.get(this.lastReturnParamName);
if (lastReturnParam) {
lastReturnParam.bind(value);
}
}
/**
* 构造函数
*
* @param {*} logic 处理逻辑模型对象
* @param {any[]} args 数据对象
* @param {*} context 应用上下文
* @param {*} params 视图参数
* @param {*} $event 事件源对象
* @param {*} xData 部件对象
* @param {*} actioncontext 界面容器对象
* @param {*} srfParentDeName 关联父应用实体代码名称
* @memberof UIActionContext
*/
constructor(logicParams: any, args: any[], context: any = {}, params: any = {},
$event?: any, xData?: any, actioncontext?: any, srfParentDeName?: string) {
this.appContext = context;
this.viewParam = params;
this.actionContainer = actioncontext;
this.additionalParam = { args, $event, xData, actioncontext, srfParentDeName };
// 初始化界面逻辑处理参数
if (logicParams && logicParams.length > 0) {
for (let logicParam of logicParams) {
// const uiLogicParamInstance = AppDeUILogicParamService.getLogicParamInstance(this, logicParam, { args, context, params, $event, xData, actioncontext, srfParentDeName });
// this.paramsMap.set(logicParam.codeName, uiLogicParamInstance);
// if (logicParam.default) this.defaultParamName = logicParam.codeName;
// if (logicParam.navContextParam) this.navContextParamName = logicParam.codeName;
// if (logicParam.navViewParamParam) this.navViewParamParamName = logicParam.codeName;
// if (logicParam.activeContainerParam) this.activeContainerParamName = logicParam.codeName;
// if (logicParam.activeCtrlParam) this.activeCtrlParamName = logicParam.codeName;
// if (logicParam.activeViewParam) this.activeViewParamName = logicParam.codeName;
// if (logicParam.lastReturnParam) this.lastReturnParamName = logicParam.codeName;
}
}
}
}
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册