@byteluck-fe/model-driven-engine 2.6.0-alpha.17b → 2.6.0-alpha.17d
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.
|
@@ -1466,12 +1466,8 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
1466
1466
|
{
|
|
1467
1467
|
key: "register",
|
|
1468
1468
|
value: // 注册外部控件
|
|
1469
|
-
function register() {
|
|
1470
|
-
|
|
1471
|
-
arg[_key] = arguments[_key];
|
|
1472
|
-
}
|
|
1473
|
-
var _Runtime;
|
|
1474
|
-
return (_Runtime = Runtime).register.apply(_Runtime, _toConsumableArray(arg));
|
|
1469
|
+
function register(control) {
|
|
1470
|
+
return Runtime.register(control, 'Runtime');
|
|
1475
1471
|
}
|
|
1476
1472
|
},
|
|
1477
1473
|
{
|
|
@@ -84,7 +84,7 @@ function _createSuper(Derived) {
|
|
|
84
84
|
};
|
|
85
85
|
}
|
|
86
86
|
import { RegisterControls } from '@byteluck-fe/model-driven-core';
|
|
87
|
-
import { CONTROL_BASE_TYPE, CONTROL_TYPE, JSONCopy, loopFormSchema } from '@byteluck-fe/model-driven-shared';
|
|
87
|
+
import { CONTROL_BASE_TYPE, CONTROL_TYPE, JSONCopy, loopFormSchema, isArray } from '@byteluck-fe/model-driven-shared';
|
|
88
88
|
import { hasChildrenControl, loopDataViewControl, loopFormControl } from '../utils/runtimeUtils';
|
|
89
89
|
export var Runtime = /*#__PURE__*/ function(RegisterControls1) {
|
|
90
90
|
"use strict";
|
|
@@ -96,6 +96,7 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls1) {
|
|
|
96
96
|
_this = _super.call(this, 'Runtime');
|
|
97
97
|
_this._flatInstances = [];
|
|
98
98
|
_this._instanceMap = {};
|
|
99
|
+
_this._controlParentIdMap = {};
|
|
99
100
|
var schema = props.schema;
|
|
100
101
|
_this._schema = schema;
|
|
101
102
|
_this._instance = _this.createControl(schema, props.beforeCreateInstance);
|
|
@@ -108,19 +109,26 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls1) {
|
|
|
108
109
|
value: function getFlatInstances() {
|
|
109
110
|
var instances = [];
|
|
110
111
|
var instanceMap = {};
|
|
111
|
-
|
|
112
|
+
var controlParentIdMap = {};
|
|
113
|
+
loop(this._instance, '', function(item, parentId) {
|
|
112
114
|
// 3.4.1 避免将subtable-row 放到 _flatInstances 中
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
115
|
+
//4.3.0-lh2 将自处注释掉,为使instance.parent能取到父级
|
|
116
|
+
// if (item.type === 'subtable-row' || item.type === 'subtable-column') {
|
|
117
|
+
// return
|
|
118
|
+
// }
|
|
116
119
|
instances.push(item);
|
|
117
120
|
if (!instanceMap[item.id]) {
|
|
118
121
|
instanceMap[item.id] = [];
|
|
119
122
|
}
|
|
120
123
|
instanceMap[item.id].push(item);
|
|
124
|
+
if (parentId) {
|
|
125
|
+
// @ts-ignore
|
|
126
|
+
controlParentIdMap[item.id] = parentId;
|
|
127
|
+
}
|
|
121
128
|
});
|
|
122
129
|
this._flatInstances = instances;
|
|
123
130
|
this._instanceMap = instanceMap;
|
|
131
|
+
this._controlParentIdMap = controlParentIdMap;
|
|
124
132
|
return this._flatInstances;
|
|
125
133
|
}
|
|
126
134
|
},
|
|
@@ -234,22 +242,30 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls1) {
|
|
|
234
242
|
]);
|
|
235
243
|
return Runtime;
|
|
236
244
|
}(RegisterControls);
|
|
237
|
-
function loop(control, callback) {
|
|
238
|
-
|
|
239
|
-
control
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
loop(ctl.children, callback);
|
|
245
|
+
function loop(control, parentId, callback) {
|
|
246
|
+
var _instances = Array.isArray(control) ? control : [
|
|
247
|
+
control
|
|
248
|
+
];
|
|
249
|
+
_instances.map(function(item) {
|
|
250
|
+
callback(item, parentId);
|
|
251
|
+
if (hasChildrenControl(item)) {
|
|
252
|
+
var ctl = item;
|
|
253
|
+
if (!ctl.children) {
|
|
254
|
+
ctl.children = [];
|
|
248
255
|
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
256
|
+
// @ts-ignore
|
|
257
|
+
loop(ctl.children, ctl.id, callback);
|
|
258
|
+
}
|
|
259
|
+
if (hasHeaderOrFooterControl(item, 'headers')) {
|
|
260
|
+
loop(item.props.headers, item.id, callback);
|
|
261
|
+
}
|
|
262
|
+
if (hasHeaderOrFooterControl(item, 'footers')) {
|
|
263
|
+
loop(item.props.footers, item.id, callback);
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
function hasHeaderOrFooterControl(control, checkType) {
|
|
268
|
+
return checkType in control.props && isArray(control.props[checkType]);
|
|
253
269
|
}
|
|
254
270
|
/**
|
|
255
271
|
* 控件是否在视图中隐藏,遍历查找所有parent
|