@byteluck-fe/model-driven-engine 2.7.0-alpha.12 → 2.7.0-alpha.13
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.
- package/dist/esm/common/ActionManager.js +157 -40
- package/dist/esm/common/DataManager.js +129 -20
- package/dist/esm/common/Engine.js +338 -211
- package/dist/esm/common/OkWorker.js +27 -13
- package/dist/esm/common/Runtime.js +26 -11
- package/dist/esm/common/Store.js +51 -50
- package/dist/esm/common/checkerValue.js +39 -39
- package/dist/esm/common/index.js +2 -2
- package/dist/esm/common/proxyState.js +47 -47
- package/dist/esm/index.js +3 -3
- package/dist/esm/plugins/CalcPlugin.js +67 -59
- package/dist/esm/plugins/ControlsEventPlugin.js +191 -68
- package/dist/esm/plugins/ES6ModulePlugin.js +24 -8
- package/dist/esm/plugins/LifecycleEventPlugin.js +183 -64
- package/dist/esm/plugins/StylePlugin.js +22 -7
- package/dist/esm/plugins/index.js +5 -5
- package/dist/esm/utils/index.js +1 -1
- package/dist/esm/utils/runtimeUtils.js +5 -7
- package/dist/index.umd.js +10 -10
- package/dist/types/common/Engine.d.ts +6 -6
- package/dist/types/common/Runtime.d.ts +1 -1
- package/dist/types/common/Store.d.ts +5 -5
- package/dist/types/common/proxyState.d.ts +3 -3
- package/dist/types/plugins/ControlsEventPlugin.d.ts +1 -1
- package/dist/types/plugins/ES6ModulePlugin.d.ts +4 -4
- package/dist/types/plugins/LifecycleEventPlugin.d.ts +1 -1
- package/dist/types/plugins/StylePlugin.d.ts +1 -1
- package/package.json +4 -4
|
@@ -159,6 +159,30 @@ function _objectSpread(target) {
|
|
|
159
159
|
}
|
|
160
160
|
return target;
|
|
161
161
|
}
|
|
162
|
+
function ownKeys(object, enumerableOnly) {
|
|
163
|
+
var keys = Object.keys(object);
|
|
164
|
+
if (Object.getOwnPropertySymbols) {
|
|
165
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
166
|
+
if (enumerableOnly) {
|
|
167
|
+
symbols = symbols.filter(function(sym) {
|
|
168
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
keys.push.apply(keys, symbols);
|
|
172
|
+
}
|
|
173
|
+
return keys;
|
|
174
|
+
}
|
|
175
|
+
function _objectSpreadProps(target, source) {
|
|
176
|
+
source = source != null ? source : {};
|
|
177
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
178
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
179
|
+
} else {
|
|
180
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
181
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
return target;
|
|
185
|
+
}
|
|
162
186
|
function _possibleConstructorReturn(self, call) {
|
|
163
187
|
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
|
164
188
|
return call;
|
|
@@ -221,44 +245,147 @@ function _createSuper(Derived) {
|
|
|
221
245
|
return _possibleConstructorReturn(this, result);
|
|
222
246
|
};
|
|
223
247
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
248
|
+
var __generator = this && this.__generator || function(thisArg, body) {
|
|
249
|
+
var f, y, t, g, _ = {
|
|
250
|
+
label: 0,
|
|
251
|
+
sent: function() {
|
|
252
|
+
if (t[0] & 1) throw t[1];
|
|
253
|
+
return t[1];
|
|
254
|
+
},
|
|
255
|
+
trys: [],
|
|
256
|
+
ops: []
|
|
257
|
+
};
|
|
258
|
+
return g = {
|
|
259
|
+
next: verb(0),
|
|
260
|
+
"throw": verb(1),
|
|
261
|
+
"return": verb(2)
|
|
262
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
263
|
+
return this;
|
|
264
|
+
}), g;
|
|
265
|
+
function verb(n) {
|
|
266
|
+
return function(v) {
|
|
267
|
+
return step([
|
|
268
|
+
n,
|
|
269
|
+
v
|
|
270
|
+
]);
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
function step(op) {
|
|
274
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
275
|
+
while(_)try {
|
|
276
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
277
|
+
if (y = 0, t) op = [
|
|
278
|
+
op[0] & 2,
|
|
279
|
+
t.value
|
|
280
|
+
];
|
|
281
|
+
switch(op[0]){
|
|
282
|
+
case 0:
|
|
283
|
+
case 1:
|
|
284
|
+
t = op;
|
|
285
|
+
break;
|
|
286
|
+
case 4:
|
|
287
|
+
_.label++;
|
|
288
|
+
return {
|
|
289
|
+
value: op[1],
|
|
290
|
+
done: false
|
|
291
|
+
};
|
|
292
|
+
case 5:
|
|
293
|
+
_.label++;
|
|
294
|
+
y = op[1];
|
|
295
|
+
op = [
|
|
296
|
+
0
|
|
297
|
+
];
|
|
298
|
+
continue;
|
|
299
|
+
case 7:
|
|
300
|
+
op = _.ops.pop();
|
|
301
|
+
_.trys.pop();
|
|
302
|
+
continue;
|
|
303
|
+
default:
|
|
304
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
305
|
+
_ = 0;
|
|
306
|
+
continue;
|
|
307
|
+
}
|
|
308
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
309
|
+
_.label = op[1];
|
|
310
|
+
break;
|
|
311
|
+
}
|
|
312
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
313
|
+
_.label = t[1];
|
|
314
|
+
t = op;
|
|
315
|
+
break;
|
|
316
|
+
}
|
|
317
|
+
if (t && _.label < t[2]) {
|
|
318
|
+
_.label = t[2];
|
|
319
|
+
_.ops.push(op);
|
|
320
|
+
break;
|
|
321
|
+
}
|
|
322
|
+
if (t[2]) _.ops.pop();
|
|
323
|
+
_.trys.pop();
|
|
324
|
+
continue;
|
|
325
|
+
}
|
|
326
|
+
op = body.call(thisArg, _);
|
|
327
|
+
} catch (e) {
|
|
328
|
+
op = [
|
|
329
|
+
6,
|
|
330
|
+
e
|
|
331
|
+
];
|
|
332
|
+
y = 0;
|
|
333
|
+
} finally{
|
|
334
|
+
f = t = 0;
|
|
335
|
+
}
|
|
336
|
+
if (op[0] & 5) throw op[1];
|
|
337
|
+
return {
|
|
338
|
+
value: op[0] ? op[1] : void 0,
|
|
339
|
+
done: true
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
import { isDataBind } from "@byteluck-fe/model-driven-core";
|
|
344
|
+
import { CONTROL_BASE_TYPE, CONTROL_TYPE, DEFAULT_LOCALE, error, genNonDuplicateId, isString, JSONCopy, log, RulesMessage, updateValueFromKeys, warn, Watcher } from "@byteluck-fe/model-driven-shared";
|
|
345
|
+
import { Runtime } from "./Runtime";
|
|
346
|
+
import { Store } from "./Store";
|
|
347
|
+
import { findItem, proxyState } from "./proxyState";
|
|
348
|
+
import { ActionManager } from "./ActionManager";
|
|
349
|
+
import { DataManager } from "./DataManager";
|
|
350
|
+
import { checkerSubtableValue, checkerValue } from "./checkerValue";
|
|
351
|
+
if (typeof window !== "undefined") {
|
|
234
352
|
// @ts-ignore
|
|
235
353
|
window.engines = {};
|
|
236
354
|
}
|
|
237
355
|
// setState的时候,存储options中转变量
|
|
238
356
|
var eventOptionsTemp = null;
|
|
239
357
|
// 当前正在注册的插件名称
|
|
240
|
-
var applyingPluginName =
|
|
241
|
-
|
|
242
|
-
/*#__PURE__*/ function(
|
|
358
|
+
var applyingPluginName = "";
|
|
359
|
+
// 整体渲染引擎 并且 提供发布订阅能力
|
|
360
|
+
var Engine = /*#__PURE__*/ function(Watcher) {
|
|
243
361
|
"use strict";
|
|
244
|
-
_inherits(Engine,
|
|
362
|
+
_inherits(Engine, Watcher);
|
|
245
363
|
var _super = _createSuper(Engine);
|
|
246
364
|
function Engine(props) {
|
|
247
365
|
_classCallCheck(this, Engine);
|
|
248
366
|
var _this;
|
|
249
367
|
_this = _super.call(this);
|
|
250
|
-
_this
|
|
368
|
+
_defineProperty(_assertThisInitialized(_this), "store", void 0);
|
|
369
|
+
_defineProperty(_assertThisInitialized(_this), "rawStore", {});
|
|
370
|
+
_defineProperty(_assertThisInitialized(_this), "parent", void 0);
|
|
371
|
+
// 提供注册运行态控件以及实例化控件的能力
|
|
372
|
+
_defineProperty(_assertThisInitialized(_this), "runtime", void 0);
|
|
251
373
|
// 提供子线程处理脚本以及修改数据的能力
|
|
252
374
|
// public worker: OkWorker
|
|
253
|
-
_this
|
|
254
|
-
_this
|
|
255
|
-
_this
|
|
256
|
-
|
|
257
|
-
_this
|
|
258
|
-
_this
|
|
375
|
+
_defineProperty(_assertThisInitialized(_this), "isMounted", false);
|
|
376
|
+
_defineProperty(_assertThisInitialized(_this), "id", genNonDuplicateId(8));
|
|
377
|
+
_defineProperty(_assertThisInitialized(_this), "externalParams", void 0);
|
|
378
|
+
// 提供外部注册插件,在不同的hooks触发时执行固定函数的能力
|
|
379
|
+
_defineProperty(_assertThisInitialized(_this), "__plugins", void 0);
|
|
380
|
+
_defineProperty(_assertThisInitialized(_this), "__pluginsApplied", false);
|
|
381
|
+
_defineProperty(_assertThisInitialized(_this), "$options", void 0);
|
|
382
|
+
_defineProperty(_assertThisInitialized(_this), "actionManager", new ActionManager());
|
|
383
|
+
_defineProperty(_assertThisInitialized(_this), "dataManager", void 0);
|
|
384
|
+
_defineProperty(_assertThisInitialized(_this), "_jobTasks", []);
|
|
385
|
+
_defineProperty(_assertThisInitialized(_this), "createControlInstance", _this.createInstance);
|
|
259
386
|
_this.$options = Object.freeze(props);
|
|
260
|
-
var
|
|
261
|
-
language, language =
|
|
387
|
+
var _this_$options = _this.$options, _this_$options_autoMount = _this_$options.autoMount, autoMount = _this_$options_autoMount === void 0 ? true : _this_$options_autoMount, schema = _this_$options.schema, beforeCreateInstance = _this_$options.beforeCreateInstance, externalParams = _this_$options.externalParams, _this_$options_language = _this_$options.// fieldModel,
|
|
388
|
+
language, language = _this_$options_language === void 0 ? DEFAULT_LOCALE : _this_$options_language, _this_$options_debug = _this_$options.debug, debug = _this_$options_debug === void 0 ? false : _this_$options_debug;
|
|
262
389
|
RulesMessage.setLocale(language);
|
|
263
390
|
_this.debug = debug;
|
|
264
391
|
_this.runtime = new Runtime({
|
|
@@ -269,7 +396,7 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
269
396
|
_this.store = new Store({
|
|
270
397
|
instance: _this.runtime.instance
|
|
271
398
|
});
|
|
272
|
-
_this.debugLog(
|
|
399
|
+
_this.debugLog("engine is Instantiation complete");
|
|
273
400
|
// 自动执行挂载完成,也可以手动调用mount方法
|
|
274
401
|
autoMount && _this.mount();
|
|
275
402
|
return _this;
|
|
@@ -300,8 +427,8 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
300
427
|
for(var _len = arguments.length, arg = new Array(_len), _key = 0; _key < _len; _key++){
|
|
301
428
|
arg[_key] = arguments[_key];
|
|
302
429
|
}
|
|
303
|
-
var
|
|
304
|
-
(
|
|
430
|
+
var _this_runtime;
|
|
431
|
+
(_this_runtime = this.runtime).register.apply(_this_runtime, _toConsumableArray(arg));
|
|
305
432
|
return this;
|
|
306
433
|
}
|
|
307
434
|
},
|
|
@@ -309,14 +436,14 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
309
436
|
key: "mount",
|
|
310
437
|
value: function mount() {
|
|
311
438
|
this.debugLog("engine的mount方法开始调用");
|
|
312
|
-
var
|
|
439
|
+
var _this_$options = this.$options, _this_$options_plugins = _this_$options.plugins, plugins = _this_$options_plugins === void 0 ? [] : _this_$options_plugins;
|
|
313
440
|
this._handlerProxyState();
|
|
314
441
|
this.__plugins = plugins;
|
|
315
442
|
this.applyPlugins();
|
|
316
443
|
// 触发所有控件的默认值的change事件
|
|
317
444
|
this.setStates(this.getState());
|
|
318
445
|
this.debugLog("engine的mount方法调用结束");
|
|
319
|
-
if (this.debug && typeof window !==
|
|
446
|
+
if (this.debug && typeof window !== "undefined") {
|
|
320
447
|
// @ts-ignore
|
|
321
448
|
window.engines[this.id] = this;
|
|
322
449
|
}
|
|
@@ -325,7 +452,7 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
325
452
|
{
|
|
326
453
|
key: "destroy",
|
|
327
454
|
value: function destroy() {
|
|
328
|
-
if (this.debug && typeof window !==
|
|
455
|
+
if (this.debug && typeof window !== "undefined") {
|
|
329
456
|
// @ts-ignore
|
|
330
457
|
delete window.engines[this.id];
|
|
331
458
|
}
|
|
@@ -347,7 +474,6 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
347
474
|
}
|
|
348
475
|
// @ts-ignore
|
|
349
476
|
if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE)) {
|
|
350
|
-
var ref;
|
|
351
477
|
if (newValue === null) {
|
|
352
478
|
return [];
|
|
353
479
|
}
|
|
@@ -362,12 +488,12 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
362
488
|
}, {});
|
|
363
489
|
// @ts-ignore
|
|
364
490
|
var emptyState = this.getEmptyState(instance.id);
|
|
365
|
-
return
|
|
366
|
-
// @ts-ignore
|
|
367
|
-
|
|
491
|
+
return newValue === null || newValue === void 0 ? void 0 : newValue.map(function(row) {
|
|
492
|
+
return(// @ts-ignore
|
|
493
|
+
checkerSubtableValue(fieldTypeMap, row, emptyState));
|
|
368
494
|
});
|
|
369
495
|
}
|
|
370
|
-
var keys = key.split(
|
|
496
|
+
var keys = key.split(".");
|
|
371
497
|
var lastKey = keys[keys.length - 1];
|
|
372
498
|
try {
|
|
373
499
|
return checkerValue(instance.fieldType, lastKey, newValue, oldValue);
|
|
@@ -400,7 +526,7 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
400
526
|
var newRows = [];
|
|
401
527
|
for(var i = 0; i < len; i++){
|
|
402
528
|
// @ts-ignore
|
|
403
|
-
var row = _this.listControlCreateRow(subtable,
|
|
529
|
+
var row = _this.listControlCreateRow(subtable, "subtable-row");
|
|
404
530
|
row && newRows.push(row);
|
|
405
531
|
}
|
|
406
532
|
// @ts-ignore
|
|
@@ -414,19 +540,19 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
414
540
|
if (type && args) {
|
|
415
541
|
// const subtableOldLength = subtable.children.length
|
|
416
542
|
switch(type){
|
|
417
|
-
case
|
|
418
|
-
case
|
|
419
|
-
var
|
|
543
|
+
case "push":
|
|
544
|
+
case "unshift":
|
|
545
|
+
var _subtable_children;
|
|
420
546
|
var newRowLengths = args.length;
|
|
421
547
|
createdNewRows = createRows(newRowLengths);
|
|
422
548
|
createdNewRowsData = args;
|
|
423
|
-
(
|
|
549
|
+
(_subtable_children = subtable.children)[type].apply(_subtable_children, _toConsumableArray(createdNewRows));
|
|
424
550
|
this.runtime.getFlatInstances();
|
|
425
551
|
break;
|
|
426
|
-
case
|
|
552
|
+
case "splice":
|
|
427
553
|
if (args.length > 2) {
|
|
428
554
|
var // @ts-ignore
|
|
429
|
-
|
|
555
|
+
_subtable_children1;
|
|
430
556
|
var newRowLengths1 = args.length - 2;
|
|
431
557
|
var newValues = args.slice(2);
|
|
432
558
|
createdNewRows = createRows(newRowLengths1);
|
|
@@ -435,7 +561,7 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
435
561
|
var start = args[0];
|
|
436
562
|
// 替换几个
|
|
437
563
|
var replace = args[1];
|
|
438
|
-
(
|
|
564
|
+
(_subtable_children1 = subtable.children)[type].apply(_subtable_children1, [
|
|
439
565
|
start,
|
|
440
566
|
replace
|
|
441
567
|
].concat(_toConsumableArray(createdNewRows)));
|
|
@@ -446,29 +572,29 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
446
572
|
// })
|
|
447
573
|
} else {
|
|
448
574
|
var // @ts-ignore
|
|
449
|
-
|
|
450
|
-
(
|
|
575
|
+
_subtable_children2;
|
|
576
|
+
(_subtable_children2 = subtable.children)[type].apply(_subtable_children2, _toConsumableArray(args));
|
|
451
577
|
this.runtime.getFlatInstances();
|
|
452
578
|
}
|
|
453
579
|
break;
|
|
454
580
|
default:
|
|
455
581
|
var // @ts-ignore
|
|
456
|
-
|
|
457
|
-
(
|
|
582
|
+
_subtable_children3;
|
|
583
|
+
(_subtable_children3 = subtable.children)[type].apply(_subtable_children3, _toConsumableArray(args));
|
|
458
584
|
this.runtime.getFlatInstances();
|
|
459
585
|
break;
|
|
460
586
|
}
|
|
461
|
-
if (type ===
|
|
587
|
+
if (type === "splice") {
|
|
462
588
|
deleted = result;
|
|
463
589
|
} else if ([
|
|
464
|
-
|
|
465
|
-
|
|
590
|
+
"pop",
|
|
591
|
+
"shift"
|
|
466
592
|
].includes(type)) {
|
|
467
593
|
deleted = [
|
|
468
594
|
result
|
|
469
595
|
];
|
|
470
596
|
}
|
|
471
|
-
this.emit(
|
|
597
|
+
this.emit("list-change", {
|
|
472
598
|
instance: subtable,
|
|
473
599
|
value: this.getState(subtable.id),
|
|
474
600
|
options: Object.assign({}, options, {
|
|
@@ -495,26 +621,26 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
495
621
|
// if (instance instanceof RuntimeListControl) {
|
|
496
622
|
if (instance.controlType === CONTROL_BASE_TYPE.LIST) {
|
|
497
623
|
var // @ts-ignore
|
|
498
|
-
|
|
624
|
+
_instance_children;
|
|
499
625
|
instance.children.length = 0;
|
|
500
626
|
var newValue = value;
|
|
501
627
|
// @ts-ignore
|
|
502
628
|
var newRows = [];
|
|
503
629
|
for(var i = 0; i < newValue.length; i++){
|
|
504
630
|
// @ts-ignore
|
|
505
|
-
var row = this.listControlCreateRow(instance,
|
|
631
|
+
var row = this.listControlCreateRow(instance, "subtable-row");
|
|
506
632
|
row && newRows.push(row);
|
|
507
633
|
}
|
|
508
|
-
(
|
|
634
|
+
(_instance_children = instance.children).push.apply(_instance_children, _toConsumableArray(newRows));
|
|
509
635
|
this.runtime.getFlatInstances();
|
|
510
636
|
// 这里已经能拿到控件实例,所以在这里触发setStates,触发每一行每一个控件的change事件
|
|
511
637
|
// for (let i = 0; i < newValue.length; i++) {
|
|
512
638
|
// this.setStates(newValue[i], i, options)
|
|
513
639
|
// }
|
|
514
|
-
this.emit(
|
|
640
|
+
this.emit("list-change", {
|
|
515
641
|
instance: instance,
|
|
516
642
|
value: value,
|
|
517
|
-
options: _objectSpread({}, options, {
|
|
643
|
+
options: _objectSpreadProps(_objectSpread({}, options), {
|
|
518
644
|
// @ts-ignore
|
|
519
645
|
changed: newRows,
|
|
520
646
|
data: newValue,
|
|
@@ -522,11 +648,11 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
522
648
|
})
|
|
523
649
|
});
|
|
524
650
|
} else {
|
|
525
|
-
this.emit(
|
|
651
|
+
this.emit("change", {
|
|
526
652
|
instance: instance,
|
|
527
653
|
value: this.getState(instance.id, index),
|
|
528
654
|
rowIndex: index,
|
|
529
|
-
options: _objectSpread({}, options, {
|
|
655
|
+
options: _objectSpreadProps(_objectSpread({}, options), {
|
|
530
656
|
oldValue: oldValue
|
|
531
657
|
})
|
|
532
658
|
});
|
|
@@ -540,13 +666,13 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
540
666
|
if (this.__pluginsApplied) return;
|
|
541
667
|
this.__plugins.forEach(function(plugin) {
|
|
542
668
|
try {
|
|
543
|
-
var
|
|
544
|
-
applyingPluginName = (
|
|
669
|
+
var _plugin_pluginName;
|
|
670
|
+
applyingPluginName = (_plugin_pluginName = plugin.pluginName) !== null && _plugin_pluginName !== void 0 ? _plugin_pluginName : plugin.constructor.name;
|
|
545
671
|
plugin.apply(_this);
|
|
546
672
|
} catch (e) {
|
|
547
673
|
error("".concat(applyingPluginName, " Plugin apply Error \n ").concat(e));
|
|
548
674
|
} finally{
|
|
549
|
-
applyingPluginName =
|
|
675
|
+
applyingPluginName = "";
|
|
550
676
|
}
|
|
551
677
|
});
|
|
552
678
|
this.__pluginsApplied = true;
|
|
@@ -560,12 +686,12 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
560
686
|
// if (row instanceof RuntimeLayoutControl) {
|
|
561
687
|
// @ts-ignore
|
|
562
688
|
if (row.controlType === CONTROL_BASE_TYPE.LAYOUT) {
|
|
563
|
-
var
|
|
689
|
+
var _inst_children;
|
|
564
690
|
var inst = row;
|
|
565
691
|
var template = JSONCopy(instance.props.headers);
|
|
566
692
|
// @ts-ignore
|
|
567
693
|
var columns = this.createControl(template);
|
|
568
|
-
(
|
|
694
|
+
(_inst_children = inst.children).push.apply(_inst_children, _toConsumableArray(columns));
|
|
569
695
|
}
|
|
570
696
|
return row;
|
|
571
697
|
}
|
|
@@ -574,7 +700,7 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
574
700
|
key: "listControlAddRow",
|
|
575
701
|
value: function listControlAddRow(instance) {
|
|
576
702
|
var // @ts-ignore
|
|
577
|
-
rowType = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] :
|
|
703
|
+
rowType = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "subtable-row";
|
|
578
704
|
var row = this.listControlCreateRow(instance, rowType);
|
|
579
705
|
if (!row) return;
|
|
580
706
|
instance.children.push(row);
|
|
@@ -588,37 +714,40 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
588
714
|
var _this1 = this, _superprop_get_emit = function() {
|
|
589
715
|
return _get(_getPrototypeOf(Engine.prototype), "emit", _this);
|
|
590
716
|
};
|
|
591
|
-
return _asyncToGenerator(
|
|
717
|
+
return _asyncToGenerator(function() {
|
|
592
718
|
var needWait, promiseResolver, promise, results;
|
|
593
|
-
return
|
|
594
|
-
|
|
719
|
+
return __generator(this, function(_state) {
|
|
720
|
+
switch(_state.label){
|
|
595
721
|
case 0:
|
|
596
|
-
if (!(eventKey ===
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
if (
|
|
601
|
-
|
|
602
|
-
|
|
722
|
+
if (!(eventKey === "engine-mounted")) return [
|
|
723
|
+
3,
|
|
724
|
+
3
|
|
725
|
+
];
|
|
726
|
+
if (_this1.isMounted) {
|
|
727
|
+
warn("The engine-mounted life cycle can only be triggered once");
|
|
728
|
+
return [
|
|
729
|
+
2,
|
|
730
|
+
Promise.resolve([])
|
|
731
|
+
];
|
|
603
732
|
}
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
break;
|
|
610
|
-
}
|
|
611
|
-
console.time('engine-mounted need wait');
|
|
733
|
+
if (!_this1._jobTasks.length) return [
|
|
734
|
+
3,
|
|
735
|
+
2
|
|
736
|
+
];
|
|
737
|
+
console.time("engine-mounted need wait");
|
|
612
738
|
needWait = _toConsumableArray(_this1._jobTasks);
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
case
|
|
739
|
+
return [
|
|
740
|
+
4,
|
|
741
|
+
Promise.all(needWait)
|
|
742
|
+
];
|
|
743
|
+
case 1:
|
|
744
|
+
_state.sent();
|
|
745
|
+
console.timeEnd("engine-mounted need wait");
|
|
746
|
+
_state.label = 2;
|
|
747
|
+
case 2:
|
|
618
748
|
_this1.isMounted = true;
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
;
|
|
749
|
+
_state.label = 3;
|
|
750
|
+
case 3:
|
|
622
751
|
// 如果没有挂载的话,需要记录在挂载之前触发的所有任务
|
|
623
752
|
if (!_this1.isMounted) {
|
|
624
753
|
promise = new Promise(function(resolve) {
|
|
@@ -626,22 +755,24 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
626
755
|
});
|
|
627
756
|
_this1._jobTasks.push(promise);
|
|
628
757
|
}
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
758
|
+
return [
|
|
759
|
+
4,
|
|
760
|
+
_superprop_get_emit().call(_this1, eventKey, payload)
|
|
761
|
+
];
|
|
762
|
+
case 4:
|
|
763
|
+
results = _state.sent();
|
|
633
764
|
if (promiseResolver && promise) {
|
|
634
765
|
// 每一个任务完成的时候,都把自己从task中去掉
|
|
635
766
|
promiseResolver();
|
|
636
767
|
_this1._jobTasks.splice(_this1._jobTasks.indexOf(promise), 1);
|
|
637
768
|
}
|
|
638
|
-
return
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
769
|
+
return [
|
|
770
|
+
2,
|
|
771
|
+
results
|
|
772
|
+
];
|
|
642
773
|
}
|
|
643
|
-
}
|
|
644
|
-
})
|
|
774
|
+
});
|
|
775
|
+
})();
|
|
645
776
|
}
|
|
646
777
|
},
|
|
647
778
|
{
|
|
@@ -659,8 +790,8 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
659
790
|
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
660
791
|
args[_key] = arguments[_key];
|
|
661
792
|
}
|
|
662
|
-
var
|
|
663
|
-
return (
|
|
793
|
+
var _this_runtime;
|
|
794
|
+
return (_this_runtime = this.runtime).createControl.apply(_this_runtime, _toConsumableArray(args));
|
|
664
795
|
}
|
|
665
796
|
},
|
|
666
797
|
{
|
|
@@ -688,10 +819,10 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
688
819
|
if (controlId === undefined) {
|
|
689
820
|
return rules;
|
|
690
821
|
} else {
|
|
691
|
-
var
|
|
822
|
+
var _rules_rules_controlId, _rules_antdRules_controlId;
|
|
692
823
|
return {
|
|
693
|
-
rules: (
|
|
694
|
-
antdRules: (
|
|
824
|
+
rules: (_rules_rules_controlId = rules.rules[controlId]) === null || _rules_rules_controlId === void 0 ? void 0 : _rules_rules_controlId.fields,
|
|
825
|
+
antdRules: (_rules_antdRules_controlId = rules.antdRules[controlId]) === null || _rules_antdRules_controlId === void 0 ? void 0 : _rules_antdRules_controlId.fields
|
|
695
826
|
};
|
|
696
827
|
}
|
|
697
828
|
}
|
|
@@ -702,8 +833,8 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
702
833
|
if (controlId === undefined) {
|
|
703
834
|
return this.runtime.rules;
|
|
704
835
|
} else {
|
|
705
|
-
var
|
|
706
|
-
return (
|
|
836
|
+
var _this_runtime_rules_controlId;
|
|
837
|
+
return (_this_runtime_rules_controlId = this.runtime.rules[controlId]) === null || _this_runtime_rules_controlId === void 0 ? void 0 : _this_runtime_rules_controlId.fields;
|
|
707
838
|
}
|
|
708
839
|
}
|
|
709
840
|
},
|
|
@@ -713,8 +844,8 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
713
844
|
if (controlId === undefined) {
|
|
714
845
|
return this.runtime.antdRules;
|
|
715
846
|
} else {
|
|
716
|
-
var
|
|
717
|
-
return (
|
|
847
|
+
var _this_runtime_antdRules_controlId;
|
|
848
|
+
return (_this_runtime_antdRules_controlId = this.runtime.antdRules[controlId]) === null || _this_runtime_antdRules_controlId === void 0 ? void 0 : _this_runtime_antdRules_controlId.fields;
|
|
718
849
|
}
|
|
719
850
|
}
|
|
720
851
|
},
|
|
@@ -751,9 +882,9 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
751
882
|
key: "setState",
|
|
752
883
|
value: function setState(controlId, value, rowIndex, options) {
|
|
753
884
|
eventOptionsTemp = options;
|
|
754
|
-
this.debugLog(
|
|
885
|
+
this.debugLog("[%o]: 触发setState, 修改的值为%o, rowIndex=%o, options=%o", controlId, value, rowIndex, options);
|
|
755
886
|
this.store.setState(controlId, value, rowIndex);
|
|
756
|
-
this.debugLog(
|
|
887
|
+
this.debugLog("[%o]: setState完成, 修改的值为%o, rowIndex=%o", controlId, value, rowIndex);
|
|
757
888
|
eventOptionsTemp = null;
|
|
758
889
|
}
|
|
759
890
|
},
|
|
@@ -766,20 +897,19 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
766
897
|
var _this = this;
|
|
767
898
|
var newStates = states !== null && states !== void 0 ? states : {};
|
|
768
899
|
Object.keys(newStates).forEach(function(stateId) {
|
|
769
|
-
var _this2 = _this;
|
|
770
900
|
Object.entries(_this.store.controlIdMapping).forEach(function(param) {
|
|
771
901
|
var _param = _slicedToArray(param, 2), controlId = _param[0], controlIdMapping = _param[1];
|
|
772
902
|
if (controlIdMapping.dataView === stateId) {
|
|
773
903
|
// state对象是dataView包裹的
|
|
774
904
|
var value = newStates[stateId][controlId];
|
|
775
905
|
if (value !== undefined) {
|
|
776
|
-
|
|
906
|
+
_this.setState(controlId, value, rowIndex, options);
|
|
777
907
|
}
|
|
778
908
|
} else {
|
|
779
909
|
// state对象是单独的,没有被dataView包裹的
|
|
780
910
|
if (controlId === stateId || controlIdMapping.children && controlIdMapping.children[stateId]) {
|
|
781
911
|
if (newStates[stateId] !== undefined) {
|
|
782
|
-
|
|
912
|
+
_this.setState(stateId, newStates[stateId], rowIndex, options);
|
|
783
913
|
}
|
|
784
914
|
}
|
|
785
915
|
}
|
|
@@ -807,11 +937,11 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
807
937
|
if (!dataBindMapping1) {
|
|
808
938
|
return;
|
|
809
939
|
}
|
|
810
|
-
var
|
|
940
|
+
var dataBind = dataBindMapping1.dataBind, controlId1 = dataBindMapping1.controlId;
|
|
811
941
|
var state = this.getState(controlId1, rowIndex);
|
|
812
942
|
//if (dataBind instanceof ObjectDataBind) {
|
|
813
|
-
if (!isDataBind(
|
|
814
|
-
return Object.entries(
|
|
943
|
+
if (!isDataBind(dataBind)) {
|
|
944
|
+
return Object.entries(dataBind).reduce(function(result, param) {
|
|
815
945
|
var _param = _slicedToArray(param, 2), key = _param[0], dataBind = _param[1];
|
|
816
946
|
// objectDataBind的元素,跳过下一次赋值
|
|
817
947
|
if (dataBind.fieldCode === fieldCode) {
|
|
@@ -838,18 +968,18 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
838
968
|
var data = getFieldData.map(function(item) {
|
|
839
969
|
var obj = {};
|
|
840
970
|
for(var key in item){
|
|
841
|
-
var
|
|
842
|
-
var fieldCode = (
|
|
971
|
+
var _controlIdMapping_controlId_children_key, _controlIdMapping_controlId, _controlIdMapping_controlId_children_key_dataBind;
|
|
972
|
+
var fieldCode = (_controlIdMapping_controlId_children_key = (_controlIdMapping_controlId = controlIdMapping[controlId]) === null || _controlIdMapping_controlId === void 0 ? void 0 : _controlIdMapping_controlId.children[key]) === null || _controlIdMapping_controlId_children_key === void 0 ? void 0 : (_controlIdMapping_controlId_children_key_dataBind = _controlIdMapping_controlId_children_key.dataBind) === null || _controlIdMapping_controlId_children_key_dataBind === void 0 ? void 0 : _controlIdMapping_controlId_children_key_dataBind.fieldCode;
|
|
843
973
|
//未绑定字段的控件,直接抛弃
|
|
844
|
-
if (fieldCode !==
|
|
845
|
-
var
|
|
974
|
+
if (fieldCode !== "") {
|
|
975
|
+
var _controlIdMapping_controlId1;
|
|
846
976
|
if (fieldCode) {
|
|
847
977
|
obj[fieldCode] = item[key];
|
|
848
|
-
} else if ((
|
|
978
|
+
} else if ((_controlIdMapping_controlId1 = controlIdMapping[controlId]) === null || _controlIdMapping_controlId1 === void 0 ? void 0 : _controlIdMapping_controlId1.children[key]) {
|
|
849
979
|
// 兼容一个控件需要绑定多个字段的情况
|
|
850
980
|
for(var keyChi in item[key]){
|
|
851
|
-
var
|
|
852
|
-
obj[(
|
|
981
|
+
var _controlIdMapping_controlId_children_key1, _controlIdMapping_controlId2;
|
|
982
|
+
obj[(_controlIdMapping_controlId_children_key1 = (_controlIdMapping_controlId2 = controlIdMapping[controlId]) === null || _controlIdMapping_controlId2 === void 0 ? void 0 : _controlIdMapping_controlId2.children[key]) === null || _controlIdMapping_controlId_children_key1 === void 0 ? void 0 : _controlIdMapping_controlId_children_key1.dataBind[keyChi].fieldCode] = item[key][keyChi];
|
|
853
983
|
}
|
|
854
984
|
}
|
|
855
985
|
}
|
|
@@ -858,45 +988,45 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
858
988
|
});
|
|
859
989
|
return data;
|
|
860
990
|
} else {
|
|
861
|
-
var _loop = function(
|
|
862
|
-
var
|
|
863
|
-
if ((
|
|
864
|
-
var
|
|
865
|
-
|
|
866
|
-
} else if ((
|
|
867
|
-
var
|
|
991
|
+
var _loop = function(key) {
|
|
992
|
+
var _controlIdMapping_key, _controlIdMapping_key_dataBind, _controlIdMapping_key1, _controlIdMapping_key_dataBind1;
|
|
993
|
+
if ((_controlIdMapping_key = controlIdMapping[key]) === null || _controlIdMapping_key === void 0 ? void 0 : (_controlIdMapping_key_dataBind = _controlIdMapping_key.dataBind) === null || _controlIdMapping_key_dataBind === void 0 ? void 0 : _controlIdMapping_key_dataBind.fieldCode) {
|
|
994
|
+
var _controlIdMapping_key2;
|
|
995
|
+
obj[(_controlIdMapping_key2 = controlIdMapping[key]) === null || _controlIdMapping_key2 === void 0 ? void 0 : _controlIdMapping_key2.dataBind.fieldCode] = getFieldData[key];
|
|
996
|
+
} else if ((_controlIdMapping_key1 = controlIdMapping[key]) === null || _controlIdMapping_key1 === void 0 ? void 0 : (_controlIdMapping_key_dataBind1 = _controlIdMapping_key1.dataBind) === null || _controlIdMapping_key_dataBind1 === void 0 ? void 0 : _controlIdMapping_key_dataBind1.dataCode) {
|
|
997
|
+
var _controlIdMapping_key3;
|
|
868
998
|
// 明细字表只循环一层明细子表未递归
|
|
869
|
-
|
|
999
|
+
obj[(_controlIdMapping_key3 = controlIdMapping[key]) === null || _controlIdMapping_key3 === void 0 ? void 0 : _controlIdMapping_key3.dataBind.dataCode] = getFieldData[key].map(function(item) {
|
|
870
1000
|
var objChi = {};
|
|
871
1001
|
for(var keyChi in item){
|
|
872
|
-
var
|
|
873
|
-
var fieldCode = (
|
|
1002
|
+
var _controlIdMapping_key_children_keyChi;
|
|
1003
|
+
var fieldCode = (_controlIdMapping_key_children_keyChi = controlIdMapping[key].children[keyChi]) === null || _controlIdMapping_key_children_keyChi === void 0 ? void 0 : _controlIdMapping_key_children_keyChi.dataBind.fieldCode;
|
|
874
1004
|
//未绑定字段的控件,直接抛弃
|
|
875
|
-
if (fieldCode !==
|
|
1005
|
+
if (fieldCode !== "") {
|
|
876
1006
|
if (fieldCode) {
|
|
877
1007
|
objChi[fieldCode] = item[keyChi];
|
|
878
1008
|
} else {
|
|
879
1009
|
for(var keyChi1 in item[keyChi]){
|
|
880
|
-
var
|
|
881
|
-
objChi[(
|
|
1010
|
+
var _controlIdMapping_key_children_keyChi1;
|
|
1011
|
+
objChi[(_controlIdMapping_key_children_keyChi1 = controlIdMapping[key].children[keyChi]) === null || _controlIdMapping_key_children_keyChi1 === void 0 ? void 0 : _controlIdMapping_key_children_keyChi1.dataBind[keyChi1].fieldCode] = item[keyChi][keyChi1];
|
|
882
1012
|
}
|
|
883
1013
|
}
|
|
884
1014
|
}
|
|
885
1015
|
}
|
|
886
1016
|
return objChi;
|
|
887
1017
|
});
|
|
888
|
-
} else if (controlIdMapping[
|
|
1018
|
+
} else if (controlIdMapping[key]) {
|
|
889
1019
|
// 兼容一个控件需要绑定多个字段的情况
|
|
890
|
-
for(var
|
|
891
|
-
var
|
|
892
|
-
|
|
1020
|
+
for(var keyChi in getFieldData[key]){
|
|
1021
|
+
var _controlIdMapping_key_dataBind_keyChi, _controlIdMapping_key4;
|
|
1022
|
+
obj[(_controlIdMapping_key_dataBind_keyChi = (_controlIdMapping_key4 = controlIdMapping[key]) === null || _controlIdMapping_key4 === void 0 ? void 0 : _controlIdMapping_key4.dataBind[keyChi]) === null || _controlIdMapping_key_dataBind_keyChi === void 0 ? void 0 : _controlIdMapping_key_dataBind_keyChi.fieldCode] = getFieldData[key][keyChi];
|
|
893
1023
|
}
|
|
894
1024
|
}
|
|
895
1025
|
};
|
|
896
1026
|
// 主表
|
|
897
|
-
var
|
|
898
|
-
for(var
|
|
899
|
-
return
|
|
1027
|
+
var obj = {};
|
|
1028
|
+
for(var key in getFieldData)_loop(key);
|
|
1029
|
+
return obj;
|
|
900
1030
|
}
|
|
901
1031
|
}
|
|
902
1032
|
return;
|
|
@@ -916,13 +1046,13 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
916
1046
|
if (!dataBindMapping) {
|
|
917
1047
|
return;
|
|
918
1048
|
}
|
|
919
|
-
var
|
|
1049
|
+
var dataBind = dataBindMapping.dataBind, controlId = dataBindMapping.controlId;
|
|
920
1050
|
// if (dataBind instanceof ObjectDataBind) {
|
|
921
|
-
if (!isDataBind(
|
|
922
|
-
var
|
|
923
|
-
var oldState = (
|
|
1051
|
+
if (!isDataBind(dataBind)) {
|
|
1052
|
+
var _JSONCopy;
|
|
1053
|
+
var oldState = (_JSONCopy = JSONCopy(this.getState(controlId, rowIndex))) !== null && _JSONCopy !== void 0 ? _JSONCopy : this.getEmptyState(controlId);
|
|
924
1054
|
// fieldCode不代表是key,所以需要找到对应的key
|
|
925
|
-
var newState = Object.entries(
|
|
1055
|
+
var newState = Object.entries(dataBind).reduce(function(result, param) {
|
|
926
1056
|
var _param = _slicedToArray(param, 2), key = _param[0], dataBind = _param[1];
|
|
927
1057
|
// objectDataBind的元素,跳过下一次赋值
|
|
928
1058
|
if (dataBind.fieldCode === fieldCode) {
|
|
@@ -952,7 +1082,7 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
952
1082
|
}
|
|
953
1083
|
var skipKeys = [];
|
|
954
1084
|
mapping.fields.forEach(function(item) {
|
|
955
|
-
var
|
|
1085
|
+
var dataBind = item.dataBind, controlId = item.controlId, fieldCode = item.fieldCode;
|
|
956
1086
|
if (skipKeys.includes(fieldCode)) {
|
|
957
1087
|
return;
|
|
958
1088
|
}
|
|
@@ -961,11 +1091,11 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
961
1091
|
}
|
|
962
1092
|
// 对象类型的值
|
|
963
1093
|
// if (dataBind instanceof ObjectDataBind) {
|
|
964
|
-
if (!isDataBind(
|
|
965
|
-
var
|
|
966
|
-
var oldState = (
|
|
1094
|
+
if (!isDataBind(dataBind)) {
|
|
1095
|
+
var _JSONCopy;
|
|
1096
|
+
var oldState = (_JSONCopy = JSONCopy(_this.getState(controlId, rowIndex))) !== null && _JSONCopy !== void 0 ? _JSONCopy : _this.getEmptyState(controlId);
|
|
967
1097
|
// fieldCode不代表是key,所以需要找到对应的key
|
|
968
|
-
var newState = Object.entries(
|
|
1098
|
+
var newState = Object.entries(dataBind).reduce(function(result, param) {
|
|
969
1099
|
var _param = _slicedToArray(param, 2), key = _param[0], dataBind = _param[1];
|
|
970
1100
|
// objectDataBind的元素,跳过下一次赋值
|
|
971
1101
|
skipKeys.push(dataBind.fieldCode);
|
|
@@ -995,9 +1125,9 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
995
1125
|
return;
|
|
996
1126
|
}
|
|
997
1127
|
var skipKeys = [];
|
|
998
|
-
var
|
|
1128
|
+
var result = {};
|
|
999
1129
|
mapping.fields.forEach(function(item) {
|
|
1000
|
-
var
|
|
1130
|
+
var dataBind = item.dataBind, controlId = item.controlId, fieldCode = item.fieldCode;
|
|
1001
1131
|
if (skipKeys.includes(fieldCode)) {
|
|
1002
1132
|
return;
|
|
1003
1133
|
}
|
|
@@ -1006,10 +1136,10 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
1006
1136
|
}
|
|
1007
1137
|
// 对象类型的值
|
|
1008
1138
|
// if (dataBind instanceof ObjectDataBind) {
|
|
1009
|
-
if (!isDataBind(
|
|
1139
|
+
if (!isDataBind(dataBind)) {
|
|
1010
1140
|
var oldState = _this.getEmptyState(controlId);
|
|
1011
1141
|
// fieldCode不代表是key,所以需要找到对应的key
|
|
1012
|
-
|
|
1142
|
+
result[item.controlId] = Object.entries(dataBind).reduce(function(result, param) {
|
|
1013
1143
|
var _param = _slicedToArray(param, 2), key = _param[0], dataBind = _param[1];
|
|
1014
1144
|
// objectDataBind的元素,跳过下一次赋值
|
|
1015
1145
|
skipKeys.push(dataBind.fieldCode);
|
|
@@ -1020,10 +1150,10 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
1020
1150
|
return result;
|
|
1021
1151
|
}, oldState);
|
|
1022
1152
|
} else {
|
|
1023
|
-
|
|
1153
|
+
result[controlId] = state[fieldCode];
|
|
1024
1154
|
}
|
|
1025
1155
|
});
|
|
1026
|
-
return
|
|
1156
|
+
return result;
|
|
1027
1157
|
}
|
|
1028
1158
|
},
|
|
1029
1159
|
{
|
|
@@ -1033,14 +1163,13 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
1033
1163
|
* @options 传递给关联事件中 EventPayload中的options,一般在plugin中监听使用
|
|
1034
1164
|
*/ key: "setData",
|
|
1035
1165
|
value: function setData(dataSet, options) {
|
|
1036
|
-
var
|
|
1166
|
+
var _this = this;
|
|
1037
1167
|
this.debugLog("engine setData方法执行,参数为%o,%o。", dataSet, options);
|
|
1038
1168
|
var newState = this.store.defaultState;
|
|
1039
1169
|
Object.keys(dataSet).map(function(dataCode) {
|
|
1040
1170
|
var entity = dataSet[dataCode];
|
|
1041
1171
|
if (Array.isArray(entity)) {
|
|
1042
|
-
var
|
|
1043
|
-
var mapping = _this6.getDataBindMapping(dataCode);
|
|
1172
|
+
var mapping = _this.getDataBindMapping(dataCode);
|
|
1044
1173
|
if (!mapping) {
|
|
1045
1174
|
return;
|
|
1046
1175
|
}
|
|
@@ -1048,22 +1177,21 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
1048
1177
|
newState[mapping.dataViewId] = {};
|
|
1049
1178
|
}
|
|
1050
1179
|
if (!entity.length) {
|
|
1051
|
-
var
|
|
1052
|
-
newState[mapping.dataViewId][mapping.controlId] = (
|
|
1180
|
+
var _newState_mapping_dataViewId_mapping_controlId;
|
|
1181
|
+
newState[mapping.dataViewId][mapping.controlId] = (_newState_mapping_dataViewId_mapping_controlId = newState[mapping.dataViewId][mapping.controlId]) !== null && _newState_mapping_dataViewId_mapping_controlId !== void 0 ? _newState_mapping_dataViewId_mapping_controlId : [];
|
|
1053
1182
|
} else {
|
|
1054
1183
|
newState[mapping.dataViewId][mapping.controlId] = [];
|
|
1055
1184
|
}
|
|
1056
1185
|
entity.map(function(row) {
|
|
1057
|
-
var
|
|
1058
|
-
var newRow = JSONCopy(_this4.store.emptyState[mapping.dataViewId][mapping.controlId]);
|
|
1186
|
+
var newRow = JSONCopy(_this.store.emptyState[mapping.dataViewId][mapping.controlId]);
|
|
1059
1187
|
var skipKey = [] //qiyu ObjectDataBind中会提前将相关key拿出来赋值,为了避免重复赋值,设置了此变量
|
|
1060
1188
|
;
|
|
1061
1189
|
Object.keys(row).map(function(fieldCode) {
|
|
1062
|
-
var
|
|
1190
|
+
var _this_store_dataBindMapping_dataCode, _this_store_dataBindMapping_dataCode_fields;
|
|
1063
1191
|
if (skipKey.includes(fieldCode)) {
|
|
1064
1192
|
return;
|
|
1065
1193
|
}
|
|
1066
|
-
var fieldMapping = (
|
|
1194
|
+
var fieldMapping = (_this_store_dataBindMapping_dataCode = _this.store.dataBindMapping[dataCode]) === null || _this_store_dataBindMapping_dataCode === void 0 ? void 0 : (_this_store_dataBindMapping_dataCode_fields = _this_store_dataBindMapping_dataCode.fields) === null || _this_store_dataBindMapping_dataCode_fields === void 0 ? void 0 : _this_store_dataBindMapping_dataCode_fields.find(function(i) {
|
|
1067
1195
|
return i.fieldCode === fieldCode;
|
|
1068
1196
|
});
|
|
1069
1197
|
if (fieldMapping) {
|
|
@@ -1072,8 +1200,8 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
1072
1200
|
newRow[fieldMapping.controlId] = row[fieldCode];
|
|
1073
1201
|
// } else if (fieldMapping.dataBind instanceof ObjectDataBind) {
|
|
1074
1202
|
} else if (!isDataBind(fieldMapping.dataBind)) {
|
|
1075
|
-
var
|
|
1076
|
-
var objValue = JSONCopy((
|
|
1203
|
+
var _this_getEmptyState;
|
|
1204
|
+
var objValue = JSONCopy((_this_getEmptyState = _this.getEmptyState(fieldMapping.controlId)) !== null && _this_getEmptyState !== void 0 ? _this_getEmptyState : {});
|
|
1077
1205
|
Object.keys(fieldMapping.dataBind).map(function(key) {
|
|
1078
1206
|
var dataBind = fieldMapping.dataBind[key];
|
|
1079
1207
|
if (row[dataBind.fieldCode] !== undefined) {
|
|
@@ -1088,19 +1216,18 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
1088
1216
|
newState[mapping.dataViewId][mapping.controlId].push(newRow);
|
|
1089
1217
|
});
|
|
1090
1218
|
} else if (entity) {
|
|
1091
|
-
var
|
|
1092
|
-
var
|
|
1219
|
+
var _Object_keys;
|
|
1220
|
+
var skipKey = [] //qiyu ObjectDataBind中会提前将相关key拿出来赋值,为了避免重复赋值,设置了此变量
|
|
1093
1221
|
;
|
|
1094
|
-
var emptyState = JSONCopy(
|
|
1095
|
-
if (!((
|
|
1222
|
+
var emptyState = JSONCopy(_this.store.emptyState);
|
|
1223
|
+
if (!((_Object_keys = Object.keys(entity)) === null || _Object_keys === void 0 ? void 0 : _Object_keys.length)) {
|
|
1096
1224
|
// newState = this.store.defaultState
|
|
1097
1225
|
} else {
|
|
1098
|
-
var _this3 = _this6;
|
|
1099
1226
|
Object.keys(entity).map(function(fieldCode) {
|
|
1100
|
-
if (
|
|
1227
|
+
if (skipKey.includes(fieldCode)) {
|
|
1101
1228
|
return;
|
|
1102
1229
|
}
|
|
1103
|
-
var mapping =
|
|
1230
|
+
var mapping = _this.getDataBindMapping(dataCode, fieldCode);
|
|
1104
1231
|
if (mapping) {
|
|
1105
1232
|
if (!newState[mapping.dataViewId[0]]) {
|
|
1106
1233
|
newState[mapping.dataViewId[0]] = {};
|
|
@@ -1110,31 +1237,31 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
1110
1237
|
newState[mapping.dataViewId[0]][mapping.controlId] = entity[fieldCode] !== undefined ? entity[fieldCode] : emptyState[mapping.dataViewId[0]][mapping.controlId];
|
|
1111
1238
|
// } else if (mapping.dataBind instanceof ObjectDataBind) {
|
|
1112
1239
|
} else if (!isDataBind(mapping.dataBind)) {
|
|
1113
|
-
var
|
|
1114
|
-
var objValue = (
|
|
1240
|
+
var _this_getEmptyState;
|
|
1241
|
+
var objValue = (_this_getEmptyState = _this.getEmptyState(mapping.controlId)) !== null && _this_getEmptyState !== void 0 ? _this_getEmptyState : {};
|
|
1115
1242
|
Object.keys(mapping.dataBind).map(function(key) {
|
|
1116
1243
|
var dataBind = mapping.dataBind[key];
|
|
1117
1244
|
if (entity[dataBind.fieldCode] !== undefined) {
|
|
1118
1245
|
objValue[key] = entity[dataBind.fieldCode];
|
|
1119
1246
|
}
|
|
1120
|
-
|
|
1247
|
+
skipKey.push(dataBind.fieldCode);
|
|
1121
1248
|
});
|
|
1122
1249
|
newState[mapping.dataViewId[0]][mapping.controlId] = objValue;
|
|
1123
1250
|
}
|
|
1124
1251
|
}
|
|
1125
1252
|
});
|
|
1126
1253
|
}
|
|
1127
|
-
var newMapping =
|
|
1254
|
+
var newMapping = _this.getDataBindMapping(dataCode);
|
|
1128
1255
|
if (newMapping) {
|
|
1129
|
-
var
|
|
1130
|
-
var mappingKeys = newMapping === null || newMapping === void 0 ? void 0 : (
|
|
1256
|
+
var _newMapping_fields;
|
|
1257
|
+
var mappingKeys = newMapping === null || newMapping === void 0 ? void 0 : (_newMapping_fields = newMapping.fields) === null || _newMapping_fields === void 0 ? void 0 : _newMapping_fields.map(function(item) {
|
|
1131
1258
|
return item === null || item === void 0 ? void 0 : item.controlId;
|
|
1132
1259
|
});
|
|
1133
|
-
var mappingValue =
|
|
1134
|
-
var
|
|
1135
|
-
var mainStateKeys = Object.keys((
|
|
1260
|
+
var mappingValue = _this.getEmptyState(newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId);
|
|
1261
|
+
var _newState_newMapping_controlId;
|
|
1262
|
+
var mainStateKeys = Object.keys((_newState_newMapping_controlId = newState === null || newState === void 0 ? void 0 : newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId]) !== null && _newState_newMapping_controlId !== void 0 ? _newState_newMapping_controlId : {});
|
|
1136
1263
|
mappingKeys === null || mappingKeys === void 0 ? void 0 : mappingKeys.forEach(function(key) {
|
|
1137
|
-
if (!mainStateKeys.includes(key) && key !==
|
|
1264
|
+
if (!mainStateKeys.includes(key) && key !== "uid" && newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId]) {
|
|
1138
1265
|
if (Object.keys(newState).length) {
|
|
1139
1266
|
Object.assign(newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId], _defineProperty({}, key, mappingValue[key]));
|
|
1140
1267
|
} else {
|
|
@@ -1142,7 +1269,7 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
1142
1269
|
}
|
|
1143
1270
|
}
|
|
1144
1271
|
});
|
|
1145
|
-
|
|
1272
|
+
_this.debugLog("engine setData方法默认值及表单数据组合完成,参数为%o。", newState);
|
|
1146
1273
|
}
|
|
1147
1274
|
}
|
|
1148
1275
|
});
|
|
@@ -1210,13 +1337,13 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
1210
1337
|
}
|
|
1211
1338
|
}
|
|
1212
1339
|
} else {
|
|
1213
|
-
var
|
|
1214
|
-
var controlIdMapping = (
|
|
1215
|
-
var
|
|
1216
|
-
var
|
|
1340
|
+
var _this_getControlIdMapping;
|
|
1341
|
+
var controlIdMapping = (_this_getControlIdMapping = this.getControlIdMapping()) !== null && _this_getControlIdMapping !== void 0 ? _this_getControlIdMapping : {};
|
|
1342
|
+
var _Object_entries_find;
|
|
1343
|
+
var _ref = _slicedToArray((_Object_entries_find = Object.entries(controlIdMapping).find(function(param) {
|
|
1217
1344
|
var _param = _slicedToArray(param, 2), _ = _param[0], mapping = _param[1];
|
|
1218
1345
|
return mapping.children && controlId in mapping.children;
|
|
1219
|
-
})) !== null &&
|
|
1346
|
+
})) !== null && _Object_entries_find !== void 0 ? _Object_entries_find : [], 1), subtableId = _ref[0];
|
|
1220
1347
|
if (subtableId) {
|
|
1221
1348
|
var subtable = this.getInstance(subtableId);
|
|
1222
1349
|
// @ts-ignore
|
|
@@ -1243,16 +1370,16 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
1243
1370
|
{
|
|
1244
1371
|
key: "setInstance",
|
|
1245
1372
|
value: function setInstance(instance, props, value, rowIndex) {
|
|
1373
|
+
var _this = this;
|
|
1246
1374
|
try {
|
|
1247
|
-
if (typeof instance ===
|
|
1248
|
-
var _this = this;
|
|
1375
|
+
if (typeof instance === "string" && rowIndex === -1) {
|
|
1249
1376
|
//修改明细表整列属性的逻辑
|
|
1250
1377
|
var instances = this.getInstances(instance, rowIndex === -1);
|
|
1251
1378
|
instances.map(function(_instance) {
|
|
1252
1379
|
if (_instance) {
|
|
1253
1380
|
_this.debugLog("[%o]: 修改instance: %o的%o属性,修改的值为%o。", _instance.id, _instance, props, value);
|
|
1254
1381
|
updateValueFromKeys(_instance.props, props, value);
|
|
1255
|
-
_this.schemaEvent(
|
|
1382
|
+
_this.schemaEvent("schema-change", {
|
|
1256
1383
|
instance: _instance,
|
|
1257
1384
|
props: props,
|
|
1258
1385
|
value: value,
|
|
@@ -1261,19 +1388,19 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
1261
1388
|
}
|
|
1262
1389
|
});
|
|
1263
1390
|
} else {
|
|
1264
|
-
var
|
|
1265
|
-
if (typeof instance ===
|
|
1266
|
-
|
|
1391
|
+
var _instance;
|
|
1392
|
+
if (typeof instance === "string") {
|
|
1393
|
+
_instance = this.getInstance(instance, rowIndex);
|
|
1267
1394
|
} else {
|
|
1268
|
-
|
|
1395
|
+
_instance = instance;
|
|
1269
1396
|
}
|
|
1270
|
-
if (!
|
|
1397
|
+
if (!_instance) {
|
|
1271
1398
|
return;
|
|
1272
1399
|
}
|
|
1273
|
-
this.debugLog("[%o]: 修改instance: %o的%o属性,修改的值为%o。",
|
|
1274
|
-
updateValueFromKeys(
|
|
1275
|
-
this.schemaEvent(
|
|
1276
|
-
instance:
|
|
1400
|
+
this.debugLog("[%o]: 修改instance: %o的%o属性,修改的值为%o。", _instance.id, _instance, props, value);
|
|
1401
|
+
updateValueFromKeys(_instance.props, props, value);
|
|
1402
|
+
this.schemaEvent("schema-change", {
|
|
1403
|
+
instance: _instance,
|
|
1277
1404
|
props: props,
|
|
1278
1405
|
value: value,
|
|
1279
1406
|
rowIndex: rowIndex
|
|
@@ -1443,8 +1570,8 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
1443
1570
|
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
1444
1571
|
args[_key] = arguments[_key];
|
|
1445
1572
|
}
|
|
1446
|
-
var
|
|
1447
|
-
return (
|
|
1573
|
+
var _this_runtime;
|
|
1574
|
+
return (_this_runtime = this.runtime).registerControlConfig.apply(_this_runtime, _toConsumableArray(args));
|
|
1448
1575
|
}
|
|
1449
1576
|
},
|
|
1450
1577
|
{
|
|
@@ -1456,12 +1583,12 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
1456
1583
|
{
|
|
1457
1584
|
key: "inList",
|
|
1458
1585
|
value: function inList(controlId) {
|
|
1459
|
-
var
|
|
1460
|
-
var mapping = (
|
|
1586
|
+
var _this_store_controlIdMapping;
|
|
1587
|
+
var mapping = (_this_store_controlIdMapping = this.store.controlIdMapping) !== null && _this_store_controlIdMapping !== void 0 ? _this_store_controlIdMapping : {};
|
|
1461
1588
|
var listKey = undefined;
|
|
1462
1589
|
Object.keys(mapping).some(function(key) {
|
|
1463
|
-
var
|
|
1464
|
-
var matched = (
|
|
1590
|
+
var _mapping_key, _mapping_key_children;
|
|
1591
|
+
var matched = (_mapping_key = mapping[key]) === null || _mapping_key === void 0 ? void 0 : (_mapping_key_children = _mapping_key.children) === null || _mapping_key_children === void 0 ? void 0 : _mapping_key_children.hasOwnProperty(controlId);
|
|
1465
1592
|
if (matched) {
|
|
1466
1593
|
listKey = key;
|
|
1467
1594
|
}
|