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
72
73
74
75
76
import { IPSDEUIDEDataSetLogic } from "@ibiz/dynamic-model-api";
import { LogUtil } from "ibiz-core";
import { UILogicParamType } from "../const/ui-logic-param-type";
import { UIActionContext } from "../uiaction-context";
import { AppUILogicNodeBase } from "./logic-node-base";
/**
* 实体数据集节点
*
* @export
* @class AppDeUIDataSetNode
* @extends {AppUILogicNodeBase}
*/
export class AppDeUIDataSetNode extends AppUILogicNodeBase {
constructor() {
super();
}
/**
* 执行节点
*
* @static
* @param {IPSDEUIDEDataSetLogic} logicNode 逻辑节点
* @param {ActionContext} actionContext 逻辑上下文
* @memberof AppDeUIDataSetNode
*/
public async executeNode(logicNode: IPSDEUIDEDataSetLogic, actionContext: UIActionContext) {
try {
await this.handleDataSet(logicNode, actionContext);
return this.computeNextNodes(logicNode, actionContext);
} catch (error: any) {
LogUtil.error(`逻辑节点${logicNode.name}${error?.message ? error?.message : '发生未知错误!'}`);
}
}
/**
* 处理实体数据集
*
* @private
* @param {IPSDEUIDEDataSetLogic} logicNode
* @param {ActionContext} actionContext
* @memberof AppDeUIDataSetNode
*/
private async handleDataSet(logicNode: IPSDEUIDEDataSetLogic, actionContext: UIActionContext) {
const dstEntity = logicNode.getDstPSAppDataEntity();
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 (window as any).___ibz___.gs.getService(dstEntity.codeName);
const res = await service[dstDataSet.codeName](actionContext.context, dstParam.getReal() ? dstParam.getReal() : {});
if (res && res.status == 200 && 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(`查询实体数据集失败`);
}
} else {
throw new Error(`查询实体数据集参数不足`);
}
}
}