@ibiz-template/model-helper 0.7.41-alpha.5 → 0.7.41-alpha.52

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.
@@ -5,7 +5,8 @@ import { mergeAppMenu } from './merge-app-menu';
5
5
  import { mergeDEDrControl } from './merge-de-drcontrol';
6
6
  import { mergeAppDEUIActionGroup } from './merge-app-uiaction-group';
7
7
  import { mergeTreeView } from './merge-treeview';
8
- import { mergeAppDEForm } from './merge-de-form';
8
+ import { getFormdataRelationTags, mergeAppDEForm, mergeFormDRTabpanel, } from './merge-de-form';
9
+ import { mergeAppCodeList } from './merge-app-codelist';
9
10
  /**
10
11
  * 子应用模型合并对象
11
12
  *
@@ -34,6 +35,11 @@ export class MergeSubModelHelper {
34
35
  * @param {ISubAppRef[]} subAppRefs
35
36
  */
36
37
  mergeAppMainMenu(view, controls, subAppRefs) {
38
+ // config.common.mergeAppMenu参数值为disable,不处理该应用的菜单合并
39
+ if (ibiz.config.common.mergeAppMenu &&
40
+ ibiz.config.common.mergeAppMenu === 'disable') {
41
+ return;
42
+ }
37
43
  const dstAppMenu = controls === null || controls === void 0 ? void 0 : controls.find(item => {
38
44
  return item.controlType === 'APPMENU' && item.name === 'appmenu';
39
45
  });
@@ -41,6 +47,23 @@ export class MergeSubModelHelper {
41
47
  for (let i = 0; i < subAppRefs.length; i++) {
42
48
  const srcAppMenu = subAppRefs[i].appMenuModel;
43
49
  if (srcAppMenu) {
50
+ const { userTag } = srcAppMenu;
51
+ if (userTag) {
52
+ const [userKey, userValue] = userTag.split(':');
53
+ // mergemenutag: 目标菜单代码名称,目标菜单代码名称建议识别正则缺省配置以匹配更多目标
54
+ if (userKey === 'mergemenutag') {
55
+ try {
56
+ const userValueReg = new RegExp(userValue);
57
+ if (!userValueReg.test(dstAppMenu.codeName)) {
58
+ continue;
59
+ }
60
+ }
61
+ catch (error) {
62
+ ibiz.log.warn(`[菜单合并]:无效的正则表达式${userValue},忽略处理`);
63
+ continue;
64
+ }
65
+ }
66
+ }
44
67
  mergeAppMenu(dstAppMenu, srcAppMenu);
45
68
  }
46
69
  }
@@ -56,6 +79,11 @@ export class MergeSubModelHelper {
56
79
  * @return {*} {void}
57
80
  */
58
81
  mergeSubAppExtendedMenu(view, controls, subAppRefs) {
82
+ // config.common.mergeAppMenu参数值为disable,不处理该应用的菜单合并
83
+ if (ibiz.config.common.mergeAppMenu &&
84
+ ibiz.config.common.mergeAppMenu === 'disable') {
85
+ return;
86
+ }
59
87
  if (view.viewType !== 'APPINDEXVIEW' || !controls)
60
88
  return;
61
89
  const dstAppMenus = controls.filter(item => {
@@ -114,27 +142,7 @@ export class MergeSubModelHelper {
114
142
  });
115
143
  if (dstToolBar && dstToolBar.detoolbarItems) {
116
144
  const dstToolBarItems = dstToolBar.detoolbarItems;
117
- if (dstToolBarItems && dstToolBarItems.length > 0) {
118
- for (let i = 0; i < dstToolBarItems.length; i++) {
119
- const dstToolBarItem = dstToolBarItems[i];
120
- if (dstToolBarItem &&
121
- dstToolBarItem.uiactionGroup) {
122
- const dstUIActionGroup = dstToolBarItem
123
- .uiactionGroup;
124
- if (dstUIActionGroup) {
125
- for (let j = 0; j < subAppRefs.length; j++) {
126
- if (subAppRefs[j].appId === view.appId) {
127
- continue;
128
- }
129
- const srcAppDEUIActionGroup = ibiz.hub.getSubAppDEUIActionGroups(dstUIActionGroup.uniqueTag, subAppRefs[j].appId);
130
- if (srcAppDEUIActionGroup) {
131
- mergeAppDEUIActionGroup(dstToolBarItems[i].uiactionGroup, srcAppDEUIActionGroup);
132
- }
133
- }
134
- }
135
- }
136
- }
137
- }
145
+ this.recursiveMergeSubAppToolbarItemActionGroup(dstToolBarItems, view, subAppRefs);
138
146
  }
139
147
  controls.forEach(control => {
140
148
  if (control && control.controls) {
@@ -142,6 +150,40 @@ export class MergeSubModelHelper {
142
150
  }
143
151
  });
144
152
  }
153
+ /**
154
+ * @description 递归合并工具项界面行为组
155
+ * @param {IDEToolbarItem[]} dstToolBarItems
156
+ * @param {IAppView} view
157
+ * @param {ISubAppRef[]} subAppRefs
158
+ * @memberof MergeSubModelHelper
159
+ */
160
+ recursiveMergeSubAppToolbarItemActionGroup(dstToolBarItems, view, subAppRefs) {
161
+ if (dstToolBarItems && dstToolBarItems.length > 0) {
162
+ for (let i = 0; i < dstToolBarItems.length; i++) {
163
+ const dstToolBarItem = dstToolBarItems[i];
164
+ if (dstToolBarItem &&
165
+ dstToolBarItem.uiactionGroup) {
166
+ const dstUIActionGroup = dstToolBarItem
167
+ .uiactionGroup;
168
+ if (dstUIActionGroup) {
169
+ for (let j = 0; j < subAppRefs.length; j++) {
170
+ if (subAppRefs[j].appId === view.appId) {
171
+ continue;
172
+ }
173
+ const srcAppDEUIActionGroup = ibiz.hub.getSubAppDEUIActionGroups(dstUIActionGroup.uniqueTag, subAppRefs[j].appId);
174
+ if (srcAppDEUIActionGroup) {
175
+ mergeAppDEUIActionGroup(dstToolBarItems[i].uiactionGroup, srcAppDEUIActionGroup);
176
+ }
177
+ }
178
+ }
179
+ }
180
+ if (dstToolBarItem.detoolbarItems) {
181
+ this.recursiveMergeSubAppToolbarItemActionGroup(dstToolBarItem
182
+ .detoolbarItems, view, subAppRefs);
183
+ }
184
+ }
185
+ }
186
+ }
145
187
  /**
146
188
  * 合并树上下文菜单
147
189
  *
@@ -180,13 +222,15 @@ export class MergeSubModelHelper {
180
222
  if (srcAppDEUIActionGroup) {
181
223
  mergeAppDEUIActionGroup(dstContextMenuItems[i]
182
224
  .uiactionGroup, srcAppDEUIActionGroup);
183
- const targetDeTreeNode = (_b = dstTree.detreeNodes) === null || _b === void 0 ? void 0 : _b.find(treeNode => {
225
+ const targetDeTreeNodes = (_b = dstTree.detreeNodes) === null || _b === void 0 ? void 0 : _b.filter(treeNode => {
184
226
  return (treeNode.decontextMenu &&
185
227
  treeNode.decontextMenu.modelId ===
186
228
  dstContextMenu.modelId);
187
229
  });
188
- if (targetDeTreeNode) {
189
- targetDeTreeNode.decontextMenu = dstContextMenu;
230
+ if (targetDeTreeNodes && targetDeTreeNodes.length > 0) {
231
+ targetDeTreeNodes.forEach(targetDeTreeNode => {
232
+ targetDeTreeNode.decontextMenu = dstContextMenu;
233
+ });
190
234
  }
191
235
  }
192
236
  }
@@ -314,13 +358,65 @@ export class MergeSubModelHelper {
314
358
  if (forms.length === 0)
315
359
  return;
316
360
  forms.forEach(dstForm => {
317
- const ids = dstForm.id.split('.');
361
+ var _a, _b;
362
+ const appDataEntityId = (_b = (_a = dstForm.appDataEntityId) === null || _a === void 0 ? void 0 : _a.split('.')) === null || _b === void 0 ? void 0 : _b[1];
363
+ const { codeName } = dstForm;
364
+ // 查找源表单存在基于数据关系部件构建的分页部件的数据关系标识
365
+ const dataRelationTags = getFormdataRelationTags(dstForm);
318
366
  for (let i = 0; i < subAppRefs.length; i++) {
319
- const srcForm = ibiz.hub.getSubAppControl(ids[1] + ids[2], subAppRefs[i].appId);
367
+ const srcForm = ibiz.hub.getSubAppControl(appDataEntityId + codeName, subAppRefs[i].appId);
368
+ // 常规表单合并
320
369
  if (srcForm) {
321
370
  mergeAppDEForm(dstForm, srcForm);
322
371
  }
372
+ // 表单分页部件合并(数据关系部件)
373
+ if (dataRelationTags && dataRelationTags.length > 0) {
374
+ for (let j = 0; j < dataRelationTags.length; j++) {
375
+ const dataRelationTag = dataRelationTags[j];
376
+ const dataRelationForm = ibiz.hub.getSubAppControl(appDataEntityId + dataRelationTag, subAppRefs[i].appId);
377
+ if (dataRelationForm) {
378
+ mergeFormDRTabpanel(dataRelationTag, dstForm, dataRelationForm);
379
+ }
380
+ }
381
+ }
323
382
  }
324
383
  });
325
384
  }
385
+ /**
386
+ * @description 合并子应用代码表(子应用代码表标识和主应用代码表标识一致,包含模块、代码表代码名称2部分内容保持一致)
387
+ * @param codelist
388
+ * @param subAppRefs
389
+ */
390
+ mergeSubAppCodeList(codelist, subAppRefs) {
391
+ if (!codelist || !subAppRefs || subAppRefs.length === 0)
392
+ return;
393
+ for (let i = 0; i < subAppRefs.length; i++) {
394
+ const subCodeList = ibiz.hub.getSubAppCodeList(codelist.codeListTag, subAppRefs[i].appId);
395
+ if (subCodeList) {
396
+ mergeAppCodeList(codelist, subCodeList);
397
+ }
398
+ }
399
+ }
400
+ /**
401
+ * @description 合并子应用AC自填模式界面行为组
402
+ * @param {(IAppDEACMode[] | undefined)} acModes
403
+ * @param {ISubAppRef[]} subAppRefs
404
+ * @returns {*} {void}
405
+ * @memberof MergeSubModelHelper
406
+ */
407
+ mergeSubAppDEACModesActionGroup(acModes, subAppRefs) {
408
+ if (!acModes || !acModes.length || !subAppRefs || !subAppRefs.length)
409
+ return;
410
+ for (let index = 0; index < acModes.length; index++) {
411
+ const { deuiactionGroup } = acModes[index];
412
+ if (deuiactionGroup) {
413
+ for (let j = 0; j < subAppRefs.length; j++) {
414
+ const srcAppDEUIActionGroup = ibiz.hub.getSubAppDEUIActionGroups(deuiactionGroup.uniqueTag, subAppRefs[j].appId);
415
+ if (srcAppDEUIActionGroup) {
416
+ mergeAppDEUIActionGroup(deuiactionGroup, srcAppDEUIActionGroup);
417
+ }
418
+ }
419
+ }
420
+ }
421
+ }
326
422
  }
@@ -1 +1 @@
1
- {"version":3,"file":"merge-treeview.d.ts","sourceRoot":"","sources":["../../../src/utils/merge-model/merge-treeview.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAE3C;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,CAiCjE"}
1
+ {"version":3,"file":"merge-treeview.d.ts","sourceRoot":"","sources":["../../../src/utils/merge-model/merge-treeview.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAiB,MAAM,kBAAkB,CAAC;AAE1D;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,CAyDjE"}
@@ -17,10 +17,10 @@ export function mergeTreeView(dst, source) {
17
17
  }
18
18
  source.detreeNodes.forEach(sourceNode => {
19
19
  var _a;
20
- const isExist = dst.detreeNodes.find(dstNode => {
20
+ const item = dst.detreeNodes.find(dstNode => {
21
21
  return dstNode.id === sourceNode.id;
22
22
  });
23
- if (!isExist) {
23
+ if (!item) {
24
24
  (_a = dst.detreeNodes) === null || _a === void 0 ? void 0 : _a.push(sourceNode);
25
25
  }
26
26
  });
@@ -32,13 +32,149 @@ export function mergeTreeView(dst, source) {
32
32
  }
33
33
  source.detreeNodeRSs.forEach(sourceNodeRs => {
34
34
  var _a;
35
- const isExist = dst.detreeNodeRSs.find(dstNodeRs => {
35
+ // 若配置了用户标记(dynamic_overlay:before|after|replace|delete|start|end:noderesid),则需根据用户标记进行合并,否则原始数据没有则直接附加末尾
36
+ if (sourceNodeRs.userTag &&
37
+ sourceNodeRs.userTag.startsWith('dynamic_overlay') &&
38
+ sourceNodeRs.userTag.split(':').length === 3) {
39
+ mergeSubAppTreeNodeResToDst(dst, sourceNodeRs);
40
+ }
41
+ else {
42
+ const itemIndex = dst.detreeNodeRSs.findIndex(dstNodeRs => {
43
+ return (dstNodeRs.parentDETreeNodeId === sourceNodeRs.parentDETreeNodeId &&
44
+ dstNodeRs.childDETreeNodeId === sourceNodeRs.childDETreeNodeId);
45
+ });
46
+ // 若存在end标记,则需要添加到第一个end标记节点关系前面,保证end标记节点关系始终添加到最后
47
+ const endIndex = dst.detreeNodeRSs.findIndex(dstNodeRs => {
48
+ var _a;
49
+ if (dstNodeRs.parentDETreeNodeId === sourceNodeRs.parentDETreeNodeId) {
50
+ const tags = (_a = sourceNodeRs.userTag) === null || _a === void 0 ? void 0 : _a.split(':');
51
+ if (!tags || tags.length !== 3 || tags[1] !== 'end')
52
+ return false;
53
+ return true;
54
+ }
55
+ return false;
56
+ });
57
+ if (itemIndex === -1) {
58
+ if (endIndex === -1) {
59
+ (_a = dst.detreeNodeRSs) === null || _a === void 0 ? void 0 : _a.push(sourceNodeRs);
60
+ }
61
+ else {
62
+ dst.detreeNodeRSs.splice(endIndex, 0, sourceNodeRs);
63
+ }
64
+ }
65
+ }
66
+ });
67
+ }
68
+ }
69
+ /**
70
+ * 合并指定子应用树节点关系到主应用树指定位置
71
+ * @param dst 原始树
72
+ * @param sourceNode 子应用树节点关系
73
+ */
74
+ function mergeSubAppTreeNodeResToDst(dst, sourceNodeRs) {
75
+ var _a;
76
+ // dynamic_overlay:before|after|replace|delete|start|end:nodeid 定义附加位置
77
+ const [dynamicOverlay, targetPosition, targetTag] = sourceNodeRs.userTag.split(':');
78
+ if (!dynamicOverlay || !targetPosition || !targetTag)
79
+ return;
80
+ switch (targetPosition) {
81
+ case 'before':
82
+ // 在目标节点之前,dynamic_overlay:before:childnodeid,这儿最后一节拼接的是子节点标识
83
+ const beforeIndex = dst.detreeNodeRSs.findIndex(dstNode => {
84
+ return (dstNode.childDETreeNodeId === targetTag &&
85
+ dstNode.parentDETreeNodeId === sourceNodeRs.parentDETreeNodeId);
86
+ });
87
+ if (beforeIndex !== -1) {
88
+ dst.detreeNodeRSs.splice(beforeIndex, 0, sourceNodeRs);
89
+ }
90
+ break;
91
+ case 'after':
92
+ // 在目标节点之后,格式如:dynamic_overlay:after:childnodeid,最后一节拼接的是子节点标识
93
+ const afterIndex = dst.detreeNodeRSs.findIndex(dstNode => {
94
+ return (dstNode.childDETreeNodeId === targetTag &&
95
+ dstNode.parentDETreeNodeId === sourceNodeRs.parentDETreeNodeId);
96
+ });
97
+ if (afterIndex !== -1) {
98
+ dst.detreeNodeRSs.splice(afterIndex + 1, 0, sourceNodeRs);
99
+ }
100
+ break;
101
+ case 'replace':
102
+ // 替换目标节点,格式如:dynamic_overlay:replace:childnodeid,最后一节拼接的是子节点标识
103
+ const replaceIndex = dst.detreeNodeRSs.findIndex(dstNode => {
104
+ return (dstNode.childDETreeNodeId === targetTag &&
105
+ dstNode.parentDETreeNodeId === sourceNodeRs.parentDETreeNodeId);
106
+ });
107
+ if (replaceIndex !== -1) {
108
+ dst.detreeNodeRSs.splice(replaceIndex, 1, sourceNodeRs);
109
+ }
110
+ break;
111
+ case 'delete':
112
+ // 删除目标节点,格式如:dynamic_overlay:delete:childnodeid,最后一节拼接的是子节点标识
113
+ const deleteIndex = dst.detreeNodeRSs.findIndex(dstNode => {
114
+ return (dstNode.childDETreeNodeId === targetTag &&
115
+ dstNode.parentDETreeNodeId === sourceNodeRs.parentDETreeNodeId);
116
+ });
117
+ if (deleteIndex !== -1) {
118
+ dst.detreeNodeRSs.splice(deleteIndex, 1);
119
+ }
120
+ break;
121
+ case 'start':
122
+ // 在目标节点内部开始,格式如:dynamic_overlay:start:随机字符,最后一节拼接的是随机字符,读的是当前节点关系的父节点标识
123
+ const startIndex = dst.detreeNodeRSs.findIndex(dstNode => {
124
+ return dstNode.parentDETreeNodeId === sourceNodeRs.parentDETreeNodeId;
125
+ });
126
+ if (startIndex !== -1) {
127
+ dst.detreeNodeRSs.splice(startIndex, 0, sourceNodeRs);
128
+ }
129
+ break;
130
+ case 'end':
131
+ // 在目标节点内部结束,格式如:dynamic_overlay:end:随机字符,最后一节拼接的是随机字符,读的是当前节点关系的父节点标识
132
+ const endIndex = getLastIndex(dst.detreeNodeRSs, dstNode => {
133
+ return dstNode.parentDETreeNodeId === sourceNodeRs.parentDETreeNodeId;
134
+ });
135
+ if (endIndex !== -1) {
136
+ dst.detreeNodeRSs.splice(endIndex + 1, 0, sourceNodeRs);
137
+ }
138
+ break;
139
+ default:
140
+ // 未识别位置,若源树不存在该关系,则直接附加到最后
141
+ const defaultIndex = dst.detreeNodeRSs.findIndex(dstNodeRs => {
36
142
  return (dstNodeRs.parentDETreeNodeId === sourceNodeRs.parentDETreeNodeId &&
37
143
  dstNodeRs.childDETreeNodeId === sourceNodeRs.childDETreeNodeId);
38
144
  });
39
- if (!isExist) {
40
- (_a = dst.detreeNodeRSs) === null || _a === void 0 ? void 0 : _a.push(sourceNodeRs);
145
+ // 若存在end标记,则需要添加到第一个end标记节点关系前面,保证end标记节点关系始终添加到最后
146
+ const defaultEndIndex = dst.detreeNodeRSs.findIndex(dstNodeRs => {
147
+ var _a;
148
+ if (dstNodeRs.parentDETreeNodeId === sourceNodeRs.parentDETreeNodeId) {
149
+ const tags = (_a = sourceNodeRs.userTag) === null || _a === void 0 ? void 0 : _a.split(':');
150
+ if (!tags || tags.length !== 3 || tags[1] !== 'end')
151
+ return false;
152
+ return true;
153
+ }
154
+ return false;
155
+ });
156
+ if (defaultIndex === -1) {
157
+ if (defaultEndIndex === -1) {
158
+ (_a = dst.detreeNodeRSs) === null || _a === void 0 ? void 0 : _a.push(sourceNodeRs);
159
+ }
160
+ else {
161
+ dst.detreeNodeRSs.splice(defaultEndIndex, 0, sourceNodeRs);
162
+ }
41
163
  }
42
- });
164
+ break;
165
+ }
166
+ }
167
+ /**
168
+ * 获取指定数组中满足条件的最后一个元素
169
+ * @param arr 指定数组
170
+ * @param predicate 过滤条件
171
+ * @returns 找到则返回指定元素下标,反之返回-1
172
+ */
173
+ function getLastIndex(arr, predicate) {
174
+ for (let i = arr.length - 1; i >= 0; i--) {
175
+ if (predicate(arr[i])) {
176
+ return i;
177
+ }
43
178
  }
179
+ return -1;
44
180
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ibiz-template/model-helper",
3
- "version": "0.7.41-alpha.5",
3
+ "version": "0.7.41-alpha.52",
4
4
  "description": "模型辅助库",
5
5
  "main": "out/index.js",
6
6
  "types": "out/index.d.ts",
@@ -30,14 +30,14 @@
30
30
  "author": "iBiz",
31
31
  "license": "MIT",
32
32
  "dependencies": {
33
- "@ibiz-template/core": "^0.7.41-alpha.2",
34
- "@ibiz/model-core": "^0.1.77",
35
- "@ibiz/rt-model-api": "0.2.74",
33
+ "@ibiz-template/core": "^0.7.41-alpha.52",
34
+ "@ibiz/model-core": "^0.1.84",
35
+ "@ibiz/rt-model-api": "0.2.82",
36
36
  "pluralize": "^8.0.0",
37
37
  "ramda": "^0.29.1"
38
38
  },
39
39
  "devDependencies": {
40
- "@ibiz-template/runtime": "^0.7.41-alpha.5",
40
+ "@ibiz-template/runtime": "^0.7.41-alpha.52",
41
41
  "@types/pluralize": "^0.0.33",
42
42
  "@types/ramda": "^0.29.10"
43
43
  },
@@ -45,5 +45,5 @@
45
45
  "@ibiz-template/runtime": "^0.6.0",
46
46
  "ramda": "^0.29.0"
47
47
  },
48
- "gitHead": "95d8b20bb9c6d513b424e78ed634599b26966801"
48
+ "gitHead": "c74c5ef7d621be7c892a0da41feab360af205b7c"
49
49
  }