@ibiz-template/runtime 0.5.3-beta.5 → 0.5.3-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/index.esm.js +157 -92
  2. package/dist/index.system.min.js +1 -1
  3. package/out/app-hub.d.ts +12 -2
  4. package/out/app-hub.d.ts.map +1 -1
  5. package/out/app-hub.js +22 -2
  6. package/out/application.js +1 -1
  7. package/out/de-logic/utils/handle-src-val.d.ts +15 -0
  8. package/out/de-logic/utils/handle-src-val.d.ts.map +1 -1
  9. package/out/de-logic/utils/handle-src-val.js +10 -1
  10. package/out/interface/common/i-app-hub-service/i-app-hub-service.d.ts +4 -3
  11. package/out/interface/common/i-app-hub-service/i-app-hub-service.d.ts.map +1 -1
  12. package/out/register/helper/panel-item-register.d.ts.map +1 -1
  13. package/out/register/helper/panel-item-register.js +36 -30
  14. package/out/service/dto/method.dto.d.ts +0 -9
  15. package/out/service/dto/method.dto.d.ts.map +1 -1
  16. package/out/service/dto/method.dto.js +7 -12
  17. package/out/service/mqtt/mqtt.service.js +2 -2
  18. package/out/service/service/auth/v7-auth.service.d.ts.map +1 -1
  19. package/out/service/service/auth/v7-auth.service.js +2 -0
  20. package/out/service/service/entity/method/fetch.d.ts.map +1 -1
  21. package/out/service/service/entity/method/fetch.js +22 -20
  22. package/out/service/utils/dynamic-code-list/dynamic-code-list.js +9 -9
  23. package/out/service/utils/res-path/res-path.d.ts +2 -2
  24. package/out/service/utils/res-path/res-path.d.ts.map +1 -1
  25. package/out/service/utils/res-path/res-path.js +1 -1
  26. package/out/ui-logic/ui-logic-node/debug-param-node/debug-param-node.js +1 -1
  27. package/out/ui-logic/ui-logic-node/raw-js-code-node/raw-js-code-node.d.ts.map +1 -1
  28. package/out/ui-logic/ui-logic-node/raw-js-code-node/raw-js-code-node.js +0 -1
  29. package/out/utils/script/script-function.js +1 -1
  30. package/out/utils/ui-domain/ui-domain.d.ts +32 -6
  31. package/out/utils/ui-domain/ui-domain.d.ts.map +1 -1
  32. package/out/utils/ui-domain/ui-domain.js +45 -9
  33. package/package.json +3 -3
  34. package/src/app-hub.ts +27 -2
  35. package/src/application.ts +1 -1
  36. package/src/de-logic/utils/handle-src-val.ts +29 -1
  37. package/src/interface/common/i-app-hub-service/i-app-hub-service.ts +4 -3
  38. package/src/register/helper/panel-item-register.ts +43 -37
  39. package/src/service/dto/method.dto.ts +7 -13
  40. package/src/service/mqtt/mqtt.service.ts +2 -2
  41. package/src/service/service/auth/v7-auth.service.ts +2 -0
  42. package/src/service/service/entity/method/fetch.ts +26 -25
  43. package/src/service/utils/dynamic-code-list/dynamic-code-list.ts +9 -9
  44. package/src/service/utils/res-path/res-path.ts +2 -2
  45. package/src/ui-logic/ui-logic-node/debug-param-node/debug-param-node.ts +1 -1
  46. package/src/ui-logic/ui-logic-node/raw-js-code-node/raw-js-code-node.ts +0 -1
  47. package/src/utils/script/script-function.ts +1 -1
  48. package/src/utils/ui-domain/ui-domain.ts +48 -9
@@ -18,14 +18,31 @@ export class UIDomain {
18
18
  */
19
19
  constructor(id) {
20
20
  /**
21
- * DTO 父子关系映射
21
+ * 状态
22
+ *
23
+ * @author chitanda
24
+ * @date 2024-01-15 19:01:51
25
+ * @type {{ rsInit: boolean }} 关系是否已经初始化
26
+ */
27
+ this.state = { rsInit: false };
28
+ /**
29
+ * DTO 子父关系映射
22
30
  *
23
31
  * @author chitanda
24
32
  * @date 2023-12-26 15:12:13
25
33
  * @protected
26
- * @type {Map<string, IAppDERS[]>}
34
+ * @type {Map<string, IAppDERS[]>} Map<子实体, 当前实体的父关系>
27
35
  */
28
36
  this.rsMap = new Map();
37
+ /**
38
+ * DTO 父子关系映射
39
+ *
40
+ * @author chitanda
41
+ * @date 2024-01-15 17:01:42
42
+ * @protected
43
+ * @type {Map<string, IAppDERS[]>}
44
+ */
45
+ this.rs2Map = new Map();
29
46
  if (id) {
30
47
  this.id = id;
31
48
  }
@@ -38,26 +55,45 @@ export class UIDomain {
38
55
  *
39
56
  * @author chitanda
40
57
  * @date 2023-12-26 15:12:31
41
- * @param {string} entity
58
+ * @param {string} appDataEntityId
42
59
  * @param {IAppDERS} configs
43
60
  */
44
- setDERConfig(deCodeName, configs) {
45
- this.rsMap.set(deCodeName, configs);
61
+ setDERConfig(appDataEntityId, configs) {
62
+ this.rsMap.set(appDataEntityId, configs);
46
63
  }
47
64
  /**
48
65
  * 获取当前界面域下,具体实体的关系(在数据加载完成之后才有值)
49
66
  *
50
67
  * @author chitanda
51
68
  * @date 2023-12-26 16:12:07
52
- * @param {string} deCodeName
69
+ * @param {string} appDataEntityId
53
70
  * @return {*} {IAppDERS[]}
54
71
  */
55
- getDERConfig(deCodeName) {
56
- if (this.rsMap.has(deCodeName)) {
57
- return this.rsMap.get(deCodeName);
72
+ getDERConfig(appDataEntityId) {
73
+ if (this.rsMap.has(appDataEntityId)) {
74
+ return this.rsMap.get(appDataEntityId);
58
75
  }
59
76
  return [];
60
77
  }
78
+ /**
79
+ * 根据模型给的子实体中的父关系模型,计算每个实体的子关系模型
80
+ *
81
+ * @author chitanda
82
+ * @date 2024-01-15 19:01:49
83
+ */
84
+ calcParentRs() {
85
+ this.rs2Map.clear();
86
+ this.rsMap.forEach((configs, appDataEntityId) => {
87
+ configs.forEach(config => {
88
+ config.minorAppDataEntityId = appDataEntityId;
89
+ const major = config.majorAppDataEntityId;
90
+ if (!this.rs2Map.has(major)) {
91
+ this.rs2Map.set(major, []);
92
+ }
93
+ this.rs2Map.get(major).push(config);
94
+ });
95
+ });
96
+ }
61
97
  /**
62
98
  * 界面域销毁
63
99
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ibiz-template/runtime",
3
- "version": "0.5.3-beta.5",
3
+ "version": "0.5.3-beta.7",
4
4
  "description": "控制器包",
5
5
  "type": "module",
6
6
  "main": "out/index.js",
@@ -29,7 +29,7 @@
29
29
  "author": "chitanda",
30
30
  "license": "MIT",
31
31
  "devDependencies": {
32
- "@ibiz-template/core": "^0.5.2",
32
+ "@ibiz-template/core": "^0.5.3-beta.7",
33
33
  "@ibiz/model-core": "^0.1.3",
34
34
  "@types/path-browserify": "^1.0.2",
35
35
  "@types/qs": "^6.9.11",
@@ -59,5 +59,5 @@
59
59
  "qx-util": "^0.4.8",
60
60
  "ramda": "^0.29.0"
61
61
  },
62
- "gitHead": "5e76e5c131a8b28decd6af541137e756e2ca8c77"
62
+ "gitHead": "8a6d086ba278298213201f71876fc18d1a1995c3"
63
63
  }
package/src/app-hub.ts CHANGED
@@ -66,6 +66,16 @@ export class AppHub implements IAppHubService {
66
66
  */
67
67
  protected view2appMap: Map<string, string> = new Map();
68
68
 
69
+ /**
70
+ * 当前注册的应用视图优先级
71
+ *
72
+ * @author chitanda
73
+ * @date 2024-01-15 15:01:57
74
+ * @protected
75
+ * @type {Map<string, number>}
76
+ */
77
+ protected view2appPriorityMap: Map<string, number> = new Map();
78
+
69
79
  /**
70
80
  * 实例化的应用视图模型
71
81
  *
@@ -176,13 +186,28 @@ export class AppHub implements IAppHubService {
176
186
  * 设置应用视图所属应用
177
187
  *
178
188
  * @author chitanda
179
- * @date 2023-04-17 23:04:37
189
+ * @date 2024-01-15 15:01:41
180
190
  * @param {string} tag 视图 codeName 或者视图 id
181
191
  * @param {string} [appId=ibiz.env.appId]
192
+ * @param {number} [priority=-1] 视图的优先级,值越小优先级越高。1为最高优先级
182
193
  */
183
- setAppView(tag: string, appId: string = ibiz.env.appId): void {
194
+ setAppView(
195
+ tag: string,
196
+ appId: string = ibiz.env.appId,
197
+ priority: number = -1,
198
+ ): void {
184
199
  const id = this.calcAppViewId(tag);
200
+ if (this.view2appMap.has(id)) {
201
+ const _priority = this.view2appPriorityMap.get(id);
202
+ // 已经存在优先级高的视图直接跳过,若优先级相同或更高则覆盖
203
+ if (_priority && _priority < priority) {
204
+ return;
205
+ }
206
+ }
185
207
  this.view2appMap.set(id, appId);
208
+ if (priority !== -1) {
209
+ this.view2appPriorityMap.set(id, priority);
210
+ }
186
211
  }
187
212
 
188
213
  /**
@@ -130,7 +130,7 @@ export class Application implements IAppService {
130
130
  async init(): Promise<void> {
131
131
  await this.authority.init();
132
132
  await this.loadAppModelStyle();
133
- if (ibiz.env.enableMqtt && ibiz.appData) {
133
+ if (ibiz.env.enableMqtt && ibiz.appData && ibiz.auth.isAnonymous !== true) {
134
134
  this.mqtt = new MqttService(
135
135
  ibiz.appData.mqtttopic,
136
136
  getToken()!,
@@ -20,6 +20,24 @@ type SrcValParams = {
20
20
  * 源参数对象id
21
21
  */
22
22
  srcDELogicParamId?: string;
23
+
24
+ /**
25
+ * 目标逻辑参数
26
+ *
27
+ */
28
+ dstDELogicParamId?: string;
29
+
30
+ /**
31
+ * 目标属性名称
32
+ *
33
+ */
34
+ dstFieldName?: string;
35
+
36
+ /**
37
+ * 表达式
38
+ *
39
+ */
40
+ expression?: string;
23
41
  };
24
42
 
25
43
  /**
@@ -35,7 +53,8 @@ export function handleSrcVal(
35
53
  ctx: DELogicContext,
36
54
  srcValParams: SrcValParams,
37
55
  ): unknown {
38
- const { srcDELogicParamId, srcFieldName, srcValue } = srcValParams;
56
+ const { srcDELogicParamId, srcFieldName, srcValue, expression } =
57
+ srcValParams;
39
58
  // 没有源值类型就是逻辑参数
40
59
  const srcValueType = srcValParams.srcValueType || 'SRCDLPARAM';
41
60
  // 取属性值
@@ -74,6 +93,15 @@ export function handleSrcVal(
74
93
  case 'ENVPARAM':
75
94
  value = clone(ibiz.env);
76
95
  break;
96
+ case 'EXPRESSION':
97
+ if (!expression) {
98
+ throw new ModelError(srcValParams, `表达式为空`);
99
+ }
100
+ value = ScriptFactory.execScriptFn(ctx, expression!, {
101
+ singleRowReturn: true,
102
+ isAsync: false,
103
+ });
104
+ break;
77
105
  default:
78
106
  throw new ModelError(srcValParams, `暂未支持源值类型${srcValueType}`);
79
107
  }
@@ -90,11 +90,12 @@ export interface IAppHubService {
90
90
  * 设置应用视图所属应用,兼容识别视图 codeName 或 id
91
91
  *
92
92
  * @author chitanda
93
- * @date 2023-04-23 15:04:56
93
+ * @date 2024-01-15 15:01:39
94
94
  * @param {string} tag
95
- * @param {string} [appId=ibiz.env.appId]
95
+ * @param {string} [appId]
96
+ * @param {number} [priority]
96
97
  */
97
- setAppView(tag: string, appId?: string): void;
98
+ setAppView(tag: string, appId?: string, priority?: number): void;
98
99
 
99
100
  /**
100
101
  * 应用视图是否已注册
@@ -46,7 +46,8 @@ export async function getPanelItemProvider(
46
46
  model: IPanelItem,
47
47
  ): Promise<IPanelItemProvider | undefined> {
48
48
  let provider: IPanelItemProvider | undefined;
49
- const { itemType, sysPFPluginId, appId } = model as Required<IPanelItem>;
49
+ const { itemType, sysPFPluginId, appId, controlRenders } =
50
+ model as Required<IPanelItem>;
50
51
 
51
52
  // 找插件适配器
52
53
  if (sysPFPluginId) {
@@ -60,50 +61,55 @@ export async function getPanelItemProvider(
60
61
  return provider;
61
62
  }
62
63
  }
63
-
64
- // 特殊容器类型
65
- if (itemType === 'CONTAINER') {
66
- const predefinedType =
67
- (model as IPanelContainer).predefinedType || 'DEFAULT';
68
- const key = `CONTAINER_${predefinedType}`;
69
- provider = getProvider(key);
70
- if (!provider) {
71
- ibiz.log.error(
72
- `找不到面板容器预置类型为${predefinedType}的适配器,注册key为${key}`,
73
- );
74
- } else {
75
- return provider;
76
- }
77
- }
78
-
79
- // 特殊直接内容类型
80
- if (itemType === 'RAWITEM') {
81
- const predefinedType =
82
- (model as IPanelRawItem).rawItem?.predefinedType || 'DEFAULT';
83
- const key = `RAWITEM_${predefinedType}`;
84
- provider = getProvider(key);
85
- if (!provider) {
86
- ibiz.log.error(
87
- `找不到面板成员直接内容预置类型为${predefinedType}的适配器,注册key为${key}`,
88
- );
89
- } else {
90
- return provider;
64
+ if (controlRenders && controlRenders.length > 0) {
65
+ // 默认预定义 绘制器
66
+ provider = getProvider('PREDEFINE_RENDER');
67
+ } else {
68
+ // 特殊容器类型
69
+ if (itemType === 'CONTAINER') {
70
+ const predefinedType =
71
+ (model as IPanelContainer).predefinedType || 'DEFAULT';
72
+ const key = `CONTAINER_${predefinedType}`;
73
+ provider = getProvider(key);
74
+ if (!provider) {
75
+ ibiz.log.error(
76
+ `找不到面板容器预置类型为${predefinedType}的适配器,注册key为${key}`,
77
+ );
78
+ } else {
79
+ return provider;
80
+ }
91
81
  }
92
- }
93
82
 
94
- if (itemType === 'FIELD') {
95
- const { editor } = model as IPanelField;
96
- if (editor && editor.predefinedType) {
97
- const key = `FIELD_${editor.predefinedType.toUpperCase()}`;
83
+ // 特殊直接内容类型
84
+ if (itemType === 'RAWITEM') {
85
+ const predefinedType =
86
+ (model as IPanelRawItem).rawItem?.predefinedType || 'DEFAULT';
87
+ const key = `RAWITEM_${predefinedType}`;
98
88
  provider = getProvider(key);
99
- if (provider) {
89
+ if (!provider) {
90
+ ibiz.log.error(
91
+ `找不到面板成员直接内容预置类型为${predefinedType}的适配器,注册key为${key}`,
92
+ );
93
+ } else {
100
94
  return provider;
101
95
  }
102
96
  }
97
+
98
+ if (itemType === 'FIELD') {
99
+ const { editor } = model as IPanelField;
100
+ if (editor && editor.predefinedType) {
101
+ const key = `FIELD_${editor.predefinedType.toUpperCase()}`;
102
+ provider = getProvider(key);
103
+ if (provider) {
104
+ return provider;
105
+ }
106
+ }
107
+ }
108
+
109
+ // 找面板成员类型
110
+ provider = getProvider(itemType);
103
111
  }
104
112
 
105
- // 找面板成员类型
106
- provider = getProvider(itemType);
107
113
  if (!provider) {
108
114
  ibiz.log.error(`找不到面板成员类型${itemType}对应的适配器`);
109
115
  } else {
@@ -28,16 +28,6 @@ export class MethodDto {
28
28
 
29
29
  protected dtoMap: Map<string, MethodDto> = new Map();
30
30
 
31
- /**
32
- * 当前 DTO 是否已经计算过关系相关逻辑
33
- *
34
- * @link this.calcRs
35
- * @author chitanda
36
- * @date 2023-12-26 16:12:18
37
- * @protected
38
- */
39
- protected isCalcRs = false;
40
-
41
31
  /**
42
32
  * Creates an instance of MethodDto.
43
33
  * @author lxm
@@ -208,7 +198,12 @@ export class MethodDto {
208
198
  if (this.isLocalMode && !this.inSelfLoop) {
209
199
  this.service.local.clear();
210
200
  }
211
- await this.calcRs(context);
201
+ const uiDomain = ibiz.uiDomainManager.get(context.srfsessionid);
202
+ if (uiDomain && uiDomain.state.rsInit !== true) {
203
+ await this.calcRs(context);
204
+ uiDomain.calcParentRs();
205
+ uiDomain.state.rsInit = true;
206
+ }
212
207
  return Promise.all(
213
208
  data.map(async datum => {
214
209
  const all = this.fields
@@ -263,10 +258,9 @@ export class MethodDto {
263
258
  * @return {*} {Promise<void>}
264
259
  */
265
260
  protected async calcRs(context: IContext, depth: number = 0): Promise<void> {
266
- if (this.isCalcRs || depth > 10) {
261
+ if (depth > 10) {
267
262
  return;
268
263
  }
269
- this.isCalcRs = true;
270
264
  depth += 1;
271
265
 
272
266
  const uiDomain = ibiz.uiDomainManager.get(context.srfsessionid);
@@ -99,10 +99,10 @@ export class MqttService {
99
99
  ibiz.log.debug('mqtt message', topic, payload.toString());
100
100
  });
101
101
  this.client.on('reconnect', () => {
102
- ibiz.log.debug('mqtt reconnect');
102
+ ibiz.log.warn('mqtt reconnect');
103
103
  });
104
104
  this.client.on('close', () => {
105
- console.debug('mqtt close');
105
+ ibiz.log.warn('mqtt close');
106
106
  });
107
107
  }
108
108
 
@@ -82,6 +82,8 @@ export class V7AuthService implements IAuthService {
82
82
  clearCookie(CoreConst.TOKEN_EXPIRES);
83
83
  clearCookie(CoreConst.TOKEN_REMEMBER);
84
84
  clearCookie(CoreConst.IS_ANONYMOUS);
85
+ ibiz.appData = undefined;
86
+ ibiz.orgData = undefined;
85
87
  return true;
86
88
  } catch (err: unknown) {
87
89
  ibiz.notification.error({
@@ -32,40 +32,41 @@ export class FetchMethod extends Method {
32
32
  // 过滤参数,必须是对象
33
33
  const searchParams = params && !isArray(params) ? params : params2 || {};
34
34
 
35
+ // 根据数据集合来源查询数据
36
+ let res: HttpResponse<IData[]>;
37
+
35
38
  if (this.isLocalMode) {
36
39
  const cond = DEDQCondUtil.getCond(this.method);
37
40
  const items = await this.searchLocal(
38
41
  cond,
39
42
  new SearchFilter(context, searchParams),
40
43
  );
41
- return new HttpResponse<IDataEntity[]>(items, 200);
42
- }
44
+ res = new HttpResponse<IDataEntity[]>(items, 200);
45
+ } else {
46
+ switch (this.method.dataSetType) {
47
+ case 'INDEXDE':
48
+ case 'CODELIST':
49
+ case 'MULTIFORM':
50
+ res = await this.fetchCodeListSet(context, searchParams);
51
+ break;
52
+ case 'REMOTE':
53
+ {
54
+ const path = this.calcPath(context);
55
+ res = await this.request(path, context, params, params2);
56
+ }
57
+ break;
58
+ default:
59
+ throw new ModelError(
60
+ this.method,
61
+ `数据来源类型${this.method.dataSetType}暂未支持`,
62
+ );
63
+ }
43
64
 
44
- // 根据数据集合来源查询数据
45
- let res: HttpResponse<IData[]>;
46
- switch (this.method.dataSetType) {
47
- case 'INDEXDE':
48
- case 'CODELIST':
49
- case 'MULTIFORM':
50
- res = await this.fetchCodeListSet(context, searchParams);
51
- break;
52
- case 'REMOTE':
53
- {
54
- const path = this.calcPath(context);
55
- res = await this.request(path, context, params, params2);
56
- }
57
- break;
58
- default:
59
- throw new ModelError(
60
- this.method,
61
- `数据来源类型${this.method.dataSetType}暂未支持`,
62
- );
65
+ // 转换实体对象
66
+ const items: IData[] = res.data || [];
67
+ res.data = items.map(item => this.createEntity(item));
63
68
  }
64
69
 
65
- // 转换实体对象
66
- const items: IData[] = res.data || [];
67
- res.data = items.map(item => this.createEntity(item));
68
-
69
70
  // 计算属性逻辑,每条数据走一遍
70
71
  if (res.data) {
71
72
  await execFieldLogics(
@@ -262,16 +262,16 @@ export class DynamicCodeListCache {
262
262
  );
263
263
  let resultItems: CodeListItem[] = [];
264
264
  if (res.data.length) {
265
- res.data.forEach((item: IData) => {
266
- if (pvalueAppDEFieldId) {
267
- const tempItems = this.prepareTreeData(res.data as IData[]);
268
- if (tempItems) {
269
- resultItems = tempItems;
270
- }
271
- } else {
272
- resultItems.push(this.convertData(item));
265
+ if (pvalueAppDEFieldId) {
266
+ const tempItems = this.prepareTreeData(res.data as IData[]);
267
+ if (tempItems) {
268
+ resultItems = tempItems;
273
269
  }
274
- });
270
+ } else {
271
+ res.data.forEach((item: IData) => {
272
+ resultItems.push(this.convertData(item));
273
+ });
274
+ }
275
275
  }
276
276
  return Object.freeze(resultItems) as CodeListItem[];
277
277
  }
@@ -12,12 +12,12 @@ const reg = /\$\{(.*?)\}/g;
12
12
  * @author lxm
13
13
  * @date 2023-07-12 07:02:52
14
14
  * @export
15
- * @param {IContext} context
15
+ * @param {IParams} context
16
16
  * @param {IAppDataEntity} entity
17
17
  * @return {*} {({ path: string; keys: string[] } | undefined)}
18
18
  */
19
19
  export function getMatchResPath(
20
- context: IContext,
20
+ context: IParams,
21
21
  entity: IAppDataEntity,
22
22
  ): { path: string; keys: string[] } | undefined {
23
23
  const pathItems = entity.requestPaths || [];
@@ -21,6 +21,6 @@ export class DebugParamNode extends UILogicNode {
21
21
  throw new RuntimeModelError(this.model, '缺少目标参数对象配置');
22
22
  }
23
23
  const param = ctx.params[dstDEUILogicParamId];
24
- console.log(`逻辑节点${name}操作参数值:`, param);
24
+ ibiz.log.debug(`逻辑节点${name}操作参数值:`, param);
25
25
  }
26
26
  }
@@ -7,7 +7,6 @@ export class RawJSCodeNode extends UILogicNode {
7
7
  declare model: IDEUIRawCodeLogic;
8
8
 
9
9
  async exec(ctx: UILogicContext): Promise<void> {
10
- console.log(ctx);
11
10
  ScriptFactory.execScriptFn(
12
11
  {
13
12
  view: ctx.view,
@@ -31,7 +31,7 @@ export class ScriptFunction {
31
31
  try {
32
32
  return fn.apply({}, args);
33
33
  } catch (error) {
34
- console.log('报错脚本', code);
34
+ ibiz.log.error('报错脚本', code);
35
35
  throw error;
36
36
  }
37
37
  };
@@ -20,15 +20,34 @@ export class UIDomain {
20
20
  readonly id: string;
21
21
 
22
22
  /**
23
- * DTO 父子关系映射
23
+ * 状态
24
+ *
25
+ * @author chitanda
26
+ * @date 2024-01-15 19:01:51
27
+ * @type {{ rsInit: boolean }} 关系是否已经初始化
28
+ */
29
+ readonly state: { rsInit: boolean } = { rsInit: false };
30
+
31
+ /**
32
+ * DTO 子父关系映射
24
33
  *
25
34
  * @author chitanda
26
35
  * @date 2023-12-26 15:12:13
27
36
  * @protected
28
- * @type {Map<string, IAppDERS[]>}
37
+ * @type {Map<string, IAppDERS[]>} Map<子实体, 当前实体的父关系>
29
38
  */
30
39
  protected rsMap: Map<string, IAppDERS[]> = new Map();
31
40
 
41
+ /**
42
+ * DTO 父子关系映射
43
+ *
44
+ * @author chitanda
45
+ * @date 2024-01-15 17:01:42
46
+ * @protected
47
+ * @type {Map<string, IAppDERS[]>}
48
+ */
49
+ protected rs2Map: Map<string, IAppDERS[]> = new Map();
50
+
32
51
  /**
33
52
  * Creates an instance of UIDomain.
34
53
  *
@@ -50,11 +69,11 @@ export class UIDomain {
50
69
  *
51
70
  * @author chitanda
52
71
  * @date 2023-12-26 15:12:31
53
- * @param {string} entity
72
+ * @param {string} appDataEntityId
54
73
  * @param {IAppDERS} configs
55
74
  */
56
- setDERConfig(deCodeName: string, configs: IAppDERS[]): void {
57
- this.rsMap.set(deCodeName, configs);
75
+ setDERConfig(appDataEntityId: string, configs: IAppDERS[]): void {
76
+ this.rsMap.set(appDataEntityId, configs);
58
77
  }
59
78
 
60
79
  /**
@@ -62,16 +81,36 @@ export class UIDomain {
62
81
  *
63
82
  * @author chitanda
64
83
  * @date 2023-12-26 16:12:07
65
- * @param {string} deCodeName
84
+ * @param {string} appDataEntityId
66
85
  * @return {*} {IAppDERS[]}
67
86
  */
68
- getDERConfig(deCodeName: string): IAppDERS[] {
69
- if (this.rsMap.has(deCodeName)) {
70
- return this.rsMap.get(deCodeName)!;
87
+ getDERConfig(appDataEntityId: string): IAppDERS[] {
88
+ if (this.rsMap.has(appDataEntityId)) {
89
+ return this.rsMap.get(appDataEntityId)!;
71
90
  }
72
91
  return [];
73
92
  }
74
93
 
94
+ /**
95
+ * 根据模型给的子实体中的父关系模型,计算每个实体的子关系模型
96
+ *
97
+ * @author chitanda
98
+ * @date 2024-01-15 19:01:49
99
+ */
100
+ calcParentRs(): void {
101
+ this.rs2Map.clear();
102
+ this.rsMap.forEach((configs, appDataEntityId) => {
103
+ configs.forEach(config => {
104
+ config.minorAppDataEntityId = appDataEntityId;
105
+ const major = config.majorAppDataEntityId!;
106
+ if (!this.rs2Map.has(major)) {
107
+ this.rs2Map.set(major, []);
108
+ }
109
+ this.rs2Map.get(major)!.push(config);
110
+ });
111
+ });
112
+ }
113
+
75
114
  /**
76
115
  * 界面域销毁
77
116
  *