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

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.
@@ -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);
@@ -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
  }
@@ -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,37 @@ 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
+ console.log(Array.from(this.rs2Map.values()));
113
+ }
114
+
75
115
  /**
76
116
  * 界面域销毁
77
117
  *