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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
import { IPSDEUILogicParam } from "@ibiz/dynamic-model-api";
import { IContext, IParams } from "ibiz-core";
import { AppDeUILogicParamService } from "./uilogic-param/ui-logic-param-service";
/**
* 界面处理逻辑上下文参数对象
*
* @export
* @class UIActionContext
*/
export class UIActionContext {
/**
* 应用上下文
*
* @type {IContext}
* @memberof UIActionContext
*/
private appContext: IContext;
/**
* 视图参数
*
* @type {IParams}
* @memberof UIActionContext
*/
private viewParam: IParams;
/**
* 默认逻辑处理参数名称
*
* @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(logic: 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 };
const temParams = { args, context, params, $event, xData, actioncontext, srfParentDeName };
this.initPresetParams(temParams);
// 初始化界面逻辑处理参数
if (logic.getPSDEUILogicParams() && (logic.getPSDEUILogicParams() as IPSDEUILogicParam[]).length > 0) {
for (let logicParam of (logic.getPSDEUILogicParams() as IPSDEUILogicParam[])) {
const uiLogicParamInstance = AppDeUILogicParamService.getLogicParamInstance(this, logicParam, temParams);
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;
}
}
}
/**
* 初始化预置参数
*
* @param {*} params
* @memberof UIActionContext
*/
initPresetParams(params: any) {
const logicParams: any[] = [
{ codeName: 'activeContainer', activeContainerParam: true },
{ codeName: 'activeCtrl', activeCtrlParam: true },
{ codeName: 'activeView', activeViewParam: true },
]
for (const logicParam of logicParams) {
const uiLogicParamInstance = AppDeUILogicParamService.getLogicParamInstance(this, logicParam, params);
this.paramsMap.set(logicParam.codeName, uiLogicParamInstance);
if (logicParam.activeContainerParam) this.activeContainerParamName = logicParam.codeName;
if (logicParam.activeCtrlParam) this.activeCtrlParamName = logicParam.codeName;
if (logicParam.activeViewParam) this.activeViewParamName = logicParam.codeName;
}
}
}