@byteluck-fe/model-driven-engine 2.6.0-alpha.17c → 2.6.0-alpha.17e
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.
|
@@ -680,6 +680,12 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
680
680
|
return this.setInstance(instance, props, value, rowIndex);
|
|
681
681
|
}
|
|
682
682
|
},
|
|
683
|
+
{
|
|
684
|
+
key: "getRule",
|
|
685
|
+
value: function getRule(controlType, props) {
|
|
686
|
+
return Runtime.staticGetRules(controlType, props);
|
|
687
|
+
}
|
|
688
|
+
},
|
|
683
689
|
{
|
|
684
690
|
key: "getAllRules",
|
|
685
691
|
value: function getAllRules(controlId) {
|
|
@@ -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";
|
|
@@ -162,14 +162,9 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls1) {
|
|
|
162
162
|
var antdRules = {};
|
|
163
163
|
var ruleItems = {};
|
|
164
164
|
loopDataViewControl(this._instance, function(dataView) {
|
|
165
|
-
var result =
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
var rules = new Rules(dataView.props);
|
|
169
|
-
result = Array.from(rules)[0];
|
|
170
|
-
}
|
|
171
|
-
ruleItems[dataView.id] = JSONCopy(result);
|
|
172
|
-
antdRules[dataView.id] = JSONCopy(result);
|
|
165
|
+
var result = Runtime.staticGetRules(dataView.type, dataView.props);
|
|
166
|
+
ruleItems[dataView.id] = JSONCopy(result[0]);
|
|
167
|
+
antdRules[dataView.id] = JSONCopy(result[0]);
|
|
173
168
|
loopFormControl(dataView.children, function(item) {
|
|
174
169
|
// if (
|
|
175
170
|
// item instanceof RuntimeFormControl ||
|
|
@@ -192,14 +187,9 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls1) {
|
|
|
192
187
|
get: function get() {
|
|
193
188
|
var ruleItems = {};
|
|
194
189
|
loopDataViewControl(this._instance, function(dataView) {
|
|
195
|
-
var result =
|
|
196
|
-
var Rules = Runtime.staticControlsRuntimeRules.get(dataView.type);
|
|
197
|
-
if (Rules) {
|
|
198
|
-
var rules = new Rules(dataView.props);
|
|
199
|
-
result = Array.from(rules)[0];
|
|
200
|
-
}
|
|
190
|
+
var result = Runtime.staticGetRules(dataView.type, dataView.props);
|
|
201
191
|
// ruleItems[dataView.id] = dataView.rules[0]
|
|
202
|
-
ruleItems[dataView.id] = result;
|
|
192
|
+
ruleItems[dataView.id] = result[0];
|
|
203
193
|
loopFormControl(dataView.children, function(item) {
|
|
204
194
|
// if (
|
|
205
195
|
// item instanceof RuntimeFormControl ||
|
|
@@ -218,14 +208,9 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls1) {
|
|
|
218
208
|
get: function get() {
|
|
219
209
|
var antdRules = {};
|
|
220
210
|
loopDataViewControl(this._instance, function(dataView) {
|
|
221
|
-
var result =
|
|
222
|
-
var Rules = Runtime.staticControlsRuntimeRules.get(dataView.type);
|
|
223
|
-
if (Rules) {
|
|
224
|
-
var rules = new Rules(dataView.props);
|
|
225
|
-
result = Array.from(rules)[0];
|
|
226
|
-
}
|
|
211
|
+
var result = Runtime.staticGetRules(dataView.type, dataView.props);
|
|
227
212
|
// antdRules[dataView.id] = dataView.rules[0]
|
|
228
|
-
antdRules[dataView.id] = result;
|
|
213
|
+
antdRules[dataView.id] = result[0];
|
|
229
214
|
loopFormControl(dataView.children, function(item) {
|
|
230
215
|
// if (
|
|
231
216
|
// item instanceof RuntimeFormControl ||
|
|
@@ -243,21 +228,29 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls1) {
|
|
|
243
228
|
return Runtime;
|
|
244
229
|
}(RegisterControls);
|
|
245
230
|
function loop(control, parentId, callback) {
|
|
246
|
-
|
|
247
|
-
control
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
loop(ctl.children, ctl.id, callback);
|
|
231
|
+
var _instances = Array.isArray(control) ? control : [
|
|
232
|
+
control
|
|
233
|
+
];
|
|
234
|
+
_instances.map(function(item) {
|
|
235
|
+
callback(item, parentId);
|
|
236
|
+
if (hasChildrenControl(item)) {
|
|
237
|
+
var ctl = item;
|
|
238
|
+
if (!ctl.children) {
|
|
239
|
+
ctl.children = [];
|
|
256
240
|
}
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
241
|
+
// @ts-ignore
|
|
242
|
+
loop(ctl.children, ctl.id, callback);
|
|
243
|
+
}
|
|
244
|
+
if (hasHeaderOrFooterControl(item, 'headers')) {
|
|
245
|
+
loop(item.props.headers, item.id, callback);
|
|
246
|
+
}
|
|
247
|
+
if (hasHeaderOrFooterControl(item, 'footers')) {
|
|
248
|
+
loop(item.props.footers, item.id, callback);
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
function hasHeaderOrFooterControl(control, checkType) {
|
|
253
|
+
return checkType in control.props && isArray(control.props[checkType]);
|
|
261
254
|
}
|
|
262
255
|
/**
|
|
263
256
|
* 控件是否在视图中隐藏,遍历查找所有parent
|
|
@@ -275,12 +268,7 @@ item) {
|
|
|
275
268
|
if (getControlIsHide(item)) {
|
|
276
269
|
return;
|
|
277
270
|
}
|
|
278
|
-
var result =
|
|
279
|
-
var Rules = Runtime.staticControlsRuntimeRules.get(item.type);
|
|
280
|
-
if (Rules) {
|
|
281
|
-
var rules = new Rules(item.props);
|
|
282
|
-
result = Array.from(rules);
|
|
283
|
-
}
|
|
271
|
+
var result = Runtime.staticGetRules(item.type, item.props);
|
|
284
272
|
// if (item instanceof RuntimeFormControl) {
|
|
285
273
|
if (item.controlType === CONTROL_BASE_TYPE.FORM) {
|
|
286
274
|
// data[item.id] = item.rules
|
|
@@ -306,12 +294,7 @@ item) {
|
|
|
306
294
|
// itemRules.fields[index].fields[formControl.id] = (
|
|
307
295
|
// formControl as RuntimeFormControl
|
|
308
296
|
// ).rules
|
|
309
|
-
var childResult =
|
|
310
|
-
var childRules = Runtime.staticControlsRuntimeRules.get(formControl.type);
|
|
311
|
-
if (childRules) {
|
|
312
|
-
var childrules = new childRules(formControl.props);
|
|
313
|
-
childResult = Array.from(childrules);
|
|
314
|
-
}
|
|
297
|
+
var childResult = Runtime.staticGetRules(formControl.type, formControl.props);
|
|
315
298
|
// @ts-ignore
|
|
316
299
|
itemRules.fields[index].fields[formControl.id] = childResult;
|
|
317
300
|
}
|
|
@@ -325,12 +308,7 @@ item) {
|
|
|
325
308
|
if (getControlIsHide(item)) {
|
|
326
309
|
return;
|
|
327
310
|
}
|
|
328
|
-
var result =
|
|
329
|
-
var Rules = Runtime.staticControlsRuntimeRules.get(item.type);
|
|
330
|
-
if (Rules) {
|
|
331
|
-
var rules = new Rules(item.props);
|
|
332
|
-
result = Array.from(rules);
|
|
333
|
-
}
|
|
311
|
+
var result = Runtime.staticGetRules(item.type, item.props);
|
|
334
312
|
// if (item instanceof RuntimeFormControl) {
|
|
335
313
|
if (item.controlType === CONTROL_BASE_TYPE.FORM) {
|
|
336
314
|
// antdRules[item.id] = item.rules
|
|
@@ -341,12 +319,7 @@ item) {
|
|
|
341
319
|
var rules = {};
|
|
342
320
|
loopFormSchema(row.children, function(formControl) {
|
|
343
321
|
// rules[formControl.id] = (formControl as RuntimeFormControl).rules
|
|
344
|
-
var childResult =
|
|
345
|
-
var childRules = Runtime.staticControlsRuntimeRules.get(formControl.type);
|
|
346
|
-
if (childRules) {
|
|
347
|
-
var childrules = new childRules(formControl.props);
|
|
348
|
-
childResult = Array.from(childrules);
|
|
349
|
-
}
|
|
322
|
+
var childResult = Runtime.staticGetRules(formControl.type, formControl.props);
|
|
350
323
|
rules[formControl.id] = childResult;
|
|
351
324
|
});
|
|
352
325
|
antdRules[item.id].push(rules);
|