@byteluck-fe/model-driven-engine 2.7.0-alpha.18 → 2.7.0-alpha.20
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 +8 -8
- 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 +3 -3
|
@@ -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
|
|
@@ -415,19 +541,19 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
415
541
|
if (type && args) {
|
|
416
542
|
// const subtableOldLength = subtable.children.length
|
|
417
543
|
switch(type){
|
|
418
|
-
case
|
|
419
|
-
case
|
|
420
|
-
var
|
|
544
|
+
case "push":
|
|
545
|
+
case "unshift":
|
|
546
|
+
var _subtable_children;
|
|
421
547
|
var newRowLengths = args.length;
|
|
422
548
|
createdNewRows = createRows(newRowLengths);
|
|
423
549
|
createdNewRowsData = args;
|
|
424
|
-
(
|
|
550
|
+
(_subtable_children = subtable.children)[type].apply(_subtable_children, _toConsumableArray(createdNewRows));
|
|
425
551
|
this.runtime.getFlatInstances();
|
|
426
552
|
break;
|
|
427
|
-
case
|
|
553
|
+
case "splice":
|
|
428
554
|
if (args.length > 2) {
|
|
429
555
|
var // @ts-ignore
|
|
430
|
-
|
|
556
|
+
_subtable_children1;
|
|
431
557
|
var newRowLengths1 = args.length - 2;
|
|
432
558
|
var newValues = args.slice(2);
|
|
433
559
|
createdNewRows = createRows(newRowLengths1);
|
|
@@ -436,7 +562,7 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
436
562
|
var start = args[0];
|
|
437
563
|
// 替换几个
|
|
438
564
|
var replace = args[1];
|
|
439
|
-
(
|
|
565
|
+
(_subtable_children1 = subtable.children)[type].apply(_subtable_children1, [
|
|
440
566
|
start,
|
|
441
567
|
replace
|
|
442
568
|
].concat(_toConsumableArray(createdNewRows)));
|
|
@@ -447,7 +573,7 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
447
573
|
// })
|
|
448
574
|
} else {
|
|
449
575
|
var // @ts-ignore
|
|
450
|
-
|
|
576
|
+
_subtable_children2;
|
|
451
577
|
// 从哪儿开始
|
|
452
578
|
var start1 = args[0];
|
|
453
579
|
// 替换几个
|
|
@@ -455,28 +581,28 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
455
581
|
if (start1 + replace1 === subtable.children.length - 1) {
|
|
456
582
|
isDeleteLastOne = true;
|
|
457
583
|
}
|
|
458
|
-
(
|
|
584
|
+
(_subtable_children2 = subtable.children)[type].apply(_subtable_children2, _toConsumableArray(args));
|
|
459
585
|
this.runtime.getFlatInstances();
|
|
460
586
|
}
|
|
461
587
|
break;
|
|
462
588
|
default:
|
|
463
589
|
var // @ts-ignore
|
|
464
|
-
|
|
465
|
-
(
|
|
590
|
+
_subtable_children3;
|
|
591
|
+
(_subtable_children3 = subtable.children)[type].apply(_subtable_children3, _toConsumableArray(args));
|
|
466
592
|
this.runtime.getFlatInstances();
|
|
467
593
|
break;
|
|
468
594
|
}
|
|
469
|
-
if (type ===
|
|
595
|
+
if (type === "splice") {
|
|
470
596
|
deleted = result;
|
|
471
597
|
} else if ([
|
|
472
|
-
|
|
473
|
-
|
|
598
|
+
"pop",
|
|
599
|
+
"shift"
|
|
474
600
|
].includes(type)) {
|
|
475
601
|
deleted = [
|
|
476
602
|
result
|
|
477
603
|
];
|
|
478
604
|
}
|
|
479
|
-
this.emit(
|
|
605
|
+
this.emit("list-change", {
|
|
480
606
|
instance: subtable,
|
|
481
607
|
value: this.getState(subtable.id),
|
|
482
608
|
options: Object.assign({}, options, {
|
|
@@ -504,26 +630,26 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
504
630
|
// if (instance instanceof RuntimeListControl) {
|
|
505
631
|
if (instance.controlType === CONTROL_BASE_TYPE.LIST) {
|
|
506
632
|
var // @ts-ignore
|
|
507
|
-
|
|
633
|
+
_instance_children;
|
|
508
634
|
instance.children.length = 0;
|
|
509
635
|
var newValue = value;
|
|
510
636
|
// @ts-ignore
|
|
511
637
|
var newRows = [];
|
|
512
638
|
for(var i = 0; i < newValue.length; i++){
|
|
513
639
|
// @ts-ignore
|
|
514
|
-
var row = this.listControlCreateRow(instance,
|
|
640
|
+
var row = this.listControlCreateRow(instance, "subtable-row");
|
|
515
641
|
row && newRows.push(row);
|
|
516
642
|
}
|
|
517
|
-
(
|
|
643
|
+
(_instance_children = instance.children).push.apply(_instance_children, _toConsumableArray(newRows));
|
|
518
644
|
this.runtime.getFlatInstances();
|
|
519
645
|
// 这里已经能拿到控件实例,所以在这里触发setStates,触发每一行每一个控件的change事件
|
|
520
646
|
// for (let i = 0; i < newValue.length; i++) {
|
|
521
647
|
// this.setStates(newValue[i], i, options)
|
|
522
648
|
// }
|
|
523
|
-
this.emit(
|
|
649
|
+
this.emit("list-change", {
|
|
524
650
|
instance: instance,
|
|
525
651
|
value: value,
|
|
526
|
-
options: _objectSpread({}, options, {
|
|
652
|
+
options: _objectSpreadProps(_objectSpread({}, options), {
|
|
527
653
|
// @ts-ignore
|
|
528
654
|
changed: newRows,
|
|
529
655
|
data: newValue,
|
|
@@ -531,11 +657,11 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
531
657
|
})
|
|
532
658
|
});
|
|
533
659
|
} else {
|
|
534
|
-
this.emit(
|
|
660
|
+
this.emit("change", {
|
|
535
661
|
instance: instance,
|
|
536
662
|
value: this.getState(instance.id, index),
|
|
537
663
|
rowIndex: index,
|
|
538
|
-
options: _objectSpread({}, options, {
|
|
664
|
+
options: _objectSpreadProps(_objectSpread({}, options), {
|
|
539
665
|
oldValue: oldValue
|
|
540
666
|
})
|
|
541
667
|
});
|
|
@@ -549,13 +675,13 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
549
675
|
if (this.__pluginsApplied) return;
|
|
550
676
|
this.__plugins.forEach(function(plugin) {
|
|
551
677
|
try {
|
|
552
|
-
var
|
|
553
|
-
applyingPluginName = (
|
|
678
|
+
var _plugin_pluginName;
|
|
679
|
+
applyingPluginName = (_plugin_pluginName = plugin.pluginName) !== null && _plugin_pluginName !== void 0 ? _plugin_pluginName : plugin.constructor.name;
|
|
554
680
|
plugin.apply(_this);
|
|
555
681
|
} catch (e) {
|
|
556
682
|
error("".concat(applyingPluginName, " Plugin apply Error \n ").concat(e));
|
|
557
683
|
} finally{
|
|
558
|
-
applyingPluginName =
|
|
684
|
+
applyingPluginName = "";
|
|
559
685
|
}
|
|
560
686
|
});
|
|
561
687
|
this.__pluginsApplied = true;
|
|
@@ -569,12 +695,12 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
569
695
|
// if (row instanceof RuntimeLayoutControl) {
|
|
570
696
|
// @ts-ignore
|
|
571
697
|
if (row.controlType === CONTROL_BASE_TYPE.LAYOUT) {
|
|
572
|
-
var
|
|
698
|
+
var _inst_children;
|
|
573
699
|
var inst = row;
|
|
574
700
|
var template = JSONCopy(instance.props.headers);
|
|
575
701
|
// @ts-ignore
|
|
576
702
|
var columns = this.createControl(template);
|
|
577
|
-
(
|
|
703
|
+
(_inst_children = inst.children).push.apply(_inst_children, _toConsumableArray(columns));
|
|
578
704
|
}
|
|
579
705
|
return row;
|
|
580
706
|
}
|
|
@@ -583,7 +709,7 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
583
709
|
key: "listControlAddRow",
|
|
584
710
|
value: function listControlAddRow(instance) {
|
|
585
711
|
var // @ts-ignore
|
|
586
|
-
rowType = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] :
|
|
712
|
+
rowType = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "subtable-row";
|
|
587
713
|
var row = this.listControlCreateRow(instance, rowType);
|
|
588
714
|
if (!row) return;
|
|
589
715
|
instance.children.push(row);
|
|
@@ -597,37 +723,40 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
597
723
|
var _this1 = this, _superprop_get_emit = function() {
|
|
598
724
|
return _get(_getPrototypeOf(Engine.prototype), "emit", _this);
|
|
599
725
|
};
|
|
600
|
-
return _asyncToGenerator(
|
|
726
|
+
return _asyncToGenerator(function() {
|
|
601
727
|
var needWait, promiseResolver, promise, results;
|
|
602
|
-
return
|
|
603
|
-
|
|
728
|
+
return __generator(this, function(_state) {
|
|
729
|
+
switch(_state.label){
|
|
604
730
|
case 0:
|
|
605
|
-
if (!(eventKey ===
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
if (
|
|
610
|
-
|
|
611
|
-
|
|
731
|
+
if (!(eventKey === "engine-mounted")) return [
|
|
732
|
+
3,
|
|
733
|
+
3
|
|
734
|
+
];
|
|
735
|
+
if (_this1.isMounted) {
|
|
736
|
+
warn("The engine-mounted life cycle can only be triggered once");
|
|
737
|
+
return [
|
|
738
|
+
2,
|
|
739
|
+
Promise.resolve([])
|
|
740
|
+
];
|
|
612
741
|
}
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
break;
|
|
619
|
-
}
|
|
620
|
-
console.time('engine-mounted need wait');
|
|
742
|
+
if (!_this1._jobTasks.length) return [
|
|
743
|
+
3,
|
|
744
|
+
2
|
|
745
|
+
];
|
|
746
|
+
console.time("engine-mounted need wait");
|
|
621
747
|
needWait = _toConsumableArray(_this1._jobTasks);
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
case
|
|
748
|
+
return [
|
|
749
|
+
4,
|
|
750
|
+
Promise.all(needWait)
|
|
751
|
+
];
|
|
752
|
+
case 1:
|
|
753
|
+
_state.sent();
|
|
754
|
+
console.timeEnd("engine-mounted need wait");
|
|
755
|
+
_state.label = 2;
|
|
756
|
+
case 2:
|
|
627
757
|
_this1.isMounted = true;
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
;
|
|
758
|
+
_state.label = 3;
|
|
759
|
+
case 3:
|
|
631
760
|
// 如果没有挂载的话,需要记录在挂载之前触发的所有任务
|
|
632
761
|
if (!_this1.isMounted) {
|
|
633
762
|
promise = new Promise(function(resolve) {
|
|
@@ -635,22 +764,24 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
635
764
|
});
|
|
636
765
|
_this1._jobTasks.push(promise);
|
|
637
766
|
}
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
767
|
+
return [
|
|
768
|
+
4,
|
|
769
|
+
_superprop_get_emit().call(_this1, eventKey, payload)
|
|
770
|
+
];
|
|
771
|
+
case 4:
|
|
772
|
+
results = _state.sent();
|
|
642
773
|
if (promiseResolver && promise) {
|
|
643
774
|
// 每一个任务完成的时候,都把自己从task中去掉
|
|
644
775
|
promiseResolver();
|
|
645
776
|
_this1._jobTasks.splice(_this1._jobTasks.indexOf(promise), 1);
|
|
646
777
|
}
|
|
647
|
-
return
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
778
|
+
return [
|
|
779
|
+
2,
|
|
780
|
+
results
|
|
781
|
+
];
|
|
651
782
|
}
|
|
652
|
-
}
|
|
653
|
-
})
|
|
783
|
+
});
|
|
784
|
+
})();
|
|
654
785
|
}
|
|
655
786
|
},
|
|
656
787
|
{
|
|
@@ -668,8 +799,8 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
668
799
|
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
669
800
|
args[_key] = arguments[_key];
|
|
670
801
|
}
|
|
671
|
-
var
|
|
672
|
-
return (
|
|
802
|
+
var _this_runtime;
|
|
803
|
+
return (_this_runtime = this.runtime).createControl.apply(_this_runtime, _toConsumableArray(args));
|
|
673
804
|
}
|
|
674
805
|
},
|
|
675
806
|
{
|
|
@@ -697,10 +828,10 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
697
828
|
if (controlId === undefined) {
|
|
698
829
|
return rules;
|
|
699
830
|
} else {
|
|
700
|
-
var
|
|
831
|
+
var _rules_rules_controlId, _rules_antdRules_controlId;
|
|
701
832
|
return {
|
|
702
|
-
rules: (
|
|
703
|
-
antdRules: (
|
|
833
|
+
rules: (_rules_rules_controlId = rules.rules[controlId]) === null || _rules_rules_controlId === void 0 ? void 0 : _rules_rules_controlId.fields,
|
|
834
|
+
antdRules: (_rules_antdRules_controlId = rules.antdRules[controlId]) === null || _rules_antdRules_controlId === void 0 ? void 0 : _rules_antdRules_controlId.fields
|
|
704
835
|
};
|
|
705
836
|
}
|
|
706
837
|
}
|
|
@@ -711,8 +842,8 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
711
842
|
if (controlId === undefined) {
|
|
712
843
|
return this.runtime.rules;
|
|
713
844
|
} else {
|
|
714
|
-
var
|
|
715
|
-
return (
|
|
845
|
+
var _this_runtime_rules_controlId;
|
|
846
|
+
return (_this_runtime_rules_controlId = this.runtime.rules[controlId]) === null || _this_runtime_rules_controlId === void 0 ? void 0 : _this_runtime_rules_controlId.fields;
|
|
716
847
|
}
|
|
717
848
|
}
|
|
718
849
|
},
|
|
@@ -722,8 +853,8 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
722
853
|
if (controlId === undefined) {
|
|
723
854
|
return this.runtime.antdRules;
|
|
724
855
|
} else {
|
|
725
|
-
var
|
|
726
|
-
return (
|
|
856
|
+
var _this_runtime_antdRules_controlId;
|
|
857
|
+
return (_this_runtime_antdRules_controlId = this.runtime.antdRules[controlId]) === null || _this_runtime_antdRules_controlId === void 0 ? void 0 : _this_runtime_antdRules_controlId.fields;
|
|
727
858
|
}
|
|
728
859
|
}
|
|
729
860
|
},
|
|
@@ -760,9 +891,9 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
760
891
|
key: "setState",
|
|
761
892
|
value: function setState(controlId, value, rowIndex, options) {
|
|
762
893
|
eventOptionsTemp = options;
|
|
763
|
-
this.debugLog(
|
|
894
|
+
this.debugLog("[%o]: 触发setState, 修改的值为%o, rowIndex=%o, options=%o", controlId, value, rowIndex, options);
|
|
764
895
|
this.store.setState(controlId, value, rowIndex);
|
|
765
|
-
this.debugLog(
|
|
896
|
+
this.debugLog("[%o]: setState完成, 修改的值为%o, rowIndex=%o", controlId, value, rowIndex);
|
|
766
897
|
eventOptionsTemp = null;
|
|
767
898
|
}
|
|
768
899
|
},
|
|
@@ -775,20 +906,19 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
775
906
|
var _this = this;
|
|
776
907
|
var newStates = states !== null && states !== void 0 ? states : {};
|
|
777
908
|
Object.keys(newStates).forEach(function(stateId) {
|
|
778
|
-
var _this2 = _this;
|
|
779
909
|
Object.entries(_this.store.controlIdMapping).forEach(function(param) {
|
|
780
910
|
var _param = _slicedToArray(param, 2), controlId = _param[0], controlIdMapping = _param[1];
|
|
781
911
|
if (controlIdMapping.dataView === stateId) {
|
|
782
912
|
// state对象是dataView包裹的
|
|
783
913
|
var value = newStates[stateId][controlId];
|
|
784
914
|
if (value !== undefined) {
|
|
785
|
-
|
|
915
|
+
_this.setState(controlId, value, rowIndex, options);
|
|
786
916
|
}
|
|
787
917
|
} else {
|
|
788
918
|
// state对象是单独的,没有被dataView包裹的
|
|
789
919
|
if (controlId === stateId || controlIdMapping.children && controlIdMapping.children[stateId]) {
|
|
790
920
|
if (newStates[stateId] !== undefined) {
|
|
791
|
-
|
|
921
|
+
_this.setState(stateId, newStates[stateId], rowIndex, options);
|
|
792
922
|
}
|
|
793
923
|
}
|
|
794
924
|
}
|
|
@@ -816,11 +946,11 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
816
946
|
if (!dataBindMapping1) {
|
|
817
947
|
return;
|
|
818
948
|
}
|
|
819
|
-
var
|
|
949
|
+
var dataBind = dataBindMapping1.dataBind, controlId1 = dataBindMapping1.controlId;
|
|
820
950
|
var state = this.getState(controlId1, rowIndex);
|
|
821
951
|
//if (dataBind instanceof ObjectDataBind) {
|
|
822
|
-
if (!isDataBind(
|
|
823
|
-
return Object.entries(
|
|
952
|
+
if (!isDataBind(dataBind)) {
|
|
953
|
+
return Object.entries(dataBind).reduce(function(result, param) {
|
|
824
954
|
var _param = _slicedToArray(param, 2), key = _param[0], dataBind = _param[1];
|
|
825
955
|
// objectDataBind的元素,跳过下一次赋值
|
|
826
956
|
if (dataBind.fieldCode === fieldCode) {
|
|
@@ -847,18 +977,18 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
847
977
|
var data = getFieldData.map(function(item) {
|
|
848
978
|
var obj = {};
|
|
849
979
|
for(var key in item){
|
|
850
|
-
var
|
|
851
|
-
var fieldCode = (
|
|
980
|
+
var _controlIdMapping_controlId_children_key, _controlIdMapping_controlId, _controlIdMapping_controlId_children_key_dataBind;
|
|
981
|
+
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;
|
|
852
982
|
//未绑定字段的控件,直接抛弃
|
|
853
|
-
if (fieldCode !==
|
|
854
|
-
var
|
|
983
|
+
if (fieldCode !== "") {
|
|
984
|
+
var _controlIdMapping_controlId1;
|
|
855
985
|
if (fieldCode) {
|
|
856
986
|
obj[fieldCode] = item[key];
|
|
857
|
-
} else if ((
|
|
987
|
+
} else if ((_controlIdMapping_controlId1 = controlIdMapping[controlId]) === null || _controlIdMapping_controlId1 === void 0 ? void 0 : _controlIdMapping_controlId1.children[key]) {
|
|
858
988
|
// 兼容一个控件需要绑定多个字段的情况
|
|
859
989
|
for(var keyChi in item[key]){
|
|
860
|
-
var
|
|
861
|
-
obj[(
|
|
990
|
+
var _controlIdMapping_controlId_children_key1, _controlIdMapping_controlId2;
|
|
991
|
+
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];
|
|
862
992
|
}
|
|
863
993
|
}
|
|
864
994
|
}
|
|
@@ -867,45 +997,45 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
867
997
|
});
|
|
868
998
|
return data;
|
|
869
999
|
} else {
|
|
870
|
-
var _loop = function(
|
|
871
|
-
var
|
|
872
|
-
if ((
|
|
873
|
-
var
|
|
874
|
-
|
|
875
|
-
} else if ((
|
|
876
|
-
var
|
|
1000
|
+
var _loop = function(key) {
|
|
1001
|
+
var _controlIdMapping_key, _controlIdMapping_key_dataBind, _controlIdMapping_key1, _controlIdMapping_key_dataBind1;
|
|
1002
|
+
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) {
|
|
1003
|
+
var _controlIdMapping_key2;
|
|
1004
|
+
obj[(_controlIdMapping_key2 = controlIdMapping[key]) === null || _controlIdMapping_key2 === void 0 ? void 0 : _controlIdMapping_key2.dataBind.fieldCode] = getFieldData[key];
|
|
1005
|
+
} 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) {
|
|
1006
|
+
var _controlIdMapping_key3;
|
|
877
1007
|
// 明细字表只循环一层明细子表未递归
|
|
878
|
-
|
|
1008
|
+
obj[(_controlIdMapping_key3 = controlIdMapping[key]) === null || _controlIdMapping_key3 === void 0 ? void 0 : _controlIdMapping_key3.dataBind.dataCode] = getFieldData[key].map(function(item) {
|
|
879
1009
|
var objChi = {};
|
|
880
1010
|
for(var keyChi in item){
|
|
881
|
-
var
|
|
882
|
-
var fieldCode = (
|
|
1011
|
+
var _controlIdMapping_key_children_keyChi;
|
|
1012
|
+
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;
|
|
883
1013
|
//未绑定字段的控件,直接抛弃
|
|
884
|
-
if (fieldCode !==
|
|
1014
|
+
if (fieldCode !== "") {
|
|
885
1015
|
if (fieldCode) {
|
|
886
1016
|
objChi[fieldCode] = item[keyChi];
|
|
887
1017
|
} else {
|
|
888
1018
|
for(var keyChi1 in item[keyChi]){
|
|
889
|
-
var
|
|
890
|
-
objChi[(
|
|
1019
|
+
var _controlIdMapping_key_children_keyChi1;
|
|
1020
|
+
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];
|
|
891
1021
|
}
|
|
892
1022
|
}
|
|
893
1023
|
}
|
|
894
1024
|
}
|
|
895
1025
|
return objChi;
|
|
896
1026
|
});
|
|
897
|
-
} else if (controlIdMapping[
|
|
1027
|
+
} else if (controlIdMapping[key]) {
|
|
898
1028
|
// 兼容一个控件需要绑定多个字段的情况
|
|
899
|
-
for(var
|
|
900
|
-
var
|
|
901
|
-
|
|
1029
|
+
for(var keyChi in getFieldData[key]){
|
|
1030
|
+
var _controlIdMapping_key_dataBind_keyChi, _controlIdMapping_key4;
|
|
1031
|
+
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];
|
|
902
1032
|
}
|
|
903
1033
|
}
|
|
904
1034
|
};
|
|
905
1035
|
// 主表
|
|
906
|
-
var
|
|
907
|
-
for(var
|
|
908
|
-
return
|
|
1036
|
+
var obj = {};
|
|
1037
|
+
for(var key in getFieldData)_loop(key);
|
|
1038
|
+
return obj;
|
|
909
1039
|
}
|
|
910
1040
|
}
|
|
911
1041
|
return;
|
|
@@ -925,13 +1055,13 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
925
1055
|
if (!dataBindMapping) {
|
|
926
1056
|
return;
|
|
927
1057
|
}
|
|
928
|
-
var
|
|
1058
|
+
var dataBind = dataBindMapping.dataBind, controlId = dataBindMapping.controlId;
|
|
929
1059
|
// if (dataBind instanceof ObjectDataBind) {
|
|
930
|
-
if (!isDataBind(
|
|
931
|
-
var
|
|
932
|
-
var oldState = (
|
|
1060
|
+
if (!isDataBind(dataBind)) {
|
|
1061
|
+
var _JSONCopy;
|
|
1062
|
+
var oldState = (_JSONCopy = JSONCopy(this.getState(controlId, rowIndex))) !== null && _JSONCopy !== void 0 ? _JSONCopy : this.getEmptyState(controlId);
|
|
933
1063
|
// fieldCode不代表是key,所以需要找到对应的key
|
|
934
|
-
var newState = Object.entries(
|
|
1064
|
+
var newState = Object.entries(dataBind).reduce(function(result, param) {
|
|
935
1065
|
var _param = _slicedToArray(param, 2), key = _param[0], dataBind = _param[1];
|
|
936
1066
|
// objectDataBind的元素,跳过下一次赋值
|
|
937
1067
|
if (dataBind.fieldCode === fieldCode) {
|
|
@@ -961,7 +1091,7 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
961
1091
|
}
|
|
962
1092
|
var skipKeys = [];
|
|
963
1093
|
mapping.fields.forEach(function(item) {
|
|
964
|
-
var
|
|
1094
|
+
var dataBind = item.dataBind, controlId = item.controlId, fieldCode = item.fieldCode;
|
|
965
1095
|
if (skipKeys.includes(fieldCode)) {
|
|
966
1096
|
return;
|
|
967
1097
|
}
|
|
@@ -970,11 +1100,11 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
970
1100
|
}
|
|
971
1101
|
// 对象类型的值
|
|
972
1102
|
// if (dataBind instanceof ObjectDataBind) {
|
|
973
|
-
if (!isDataBind(
|
|
974
|
-
var
|
|
975
|
-
var oldState = (
|
|
1103
|
+
if (!isDataBind(dataBind)) {
|
|
1104
|
+
var _JSONCopy;
|
|
1105
|
+
var oldState = (_JSONCopy = JSONCopy(_this.getState(controlId, rowIndex))) !== null && _JSONCopy !== void 0 ? _JSONCopy : _this.getEmptyState(controlId);
|
|
976
1106
|
// fieldCode不代表是key,所以需要找到对应的key
|
|
977
|
-
var newState = Object.entries(
|
|
1107
|
+
var newState = Object.entries(dataBind).reduce(function(result, param) {
|
|
978
1108
|
var _param = _slicedToArray(param, 2), key = _param[0], dataBind = _param[1];
|
|
979
1109
|
// objectDataBind的元素,跳过下一次赋值
|
|
980
1110
|
skipKeys.push(dataBind.fieldCode);
|
|
@@ -1004,9 +1134,9 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
1004
1134
|
return;
|
|
1005
1135
|
}
|
|
1006
1136
|
var skipKeys = [];
|
|
1007
|
-
var
|
|
1137
|
+
var result = {};
|
|
1008
1138
|
mapping.fields.forEach(function(item) {
|
|
1009
|
-
var
|
|
1139
|
+
var dataBind = item.dataBind, controlId = item.controlId, fieldCode = item.fieldCode;
|
|
1010
1140
|
if (skipKeys.includes(fieldCode)) {
|
|
1011
1141
|
return;
|
|
1012
1142
|
}
|
|
@@ -1015,10 +1145,10 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
1015
1145
|
}
|
|
1016
1146
|
// 对象类型的值
|
|
1017
1147
|
// if (dataBind instanceof ObjectDataBind) {
|
|
1018
|
-
if (!isDataBind(
|
|
1148
|
+
if (!isDataBind(dataBind)) {
|
|
1019
1149
|
var oldState = _this.getEmptyState(controlId);
|
|
1020
1150
|
// fieldCode不代表是key,所以需要找到对应的key
|
|
1021
|
-
|
|
1151
|
+
result[item.controlId] = Object.entries(dataBind).reduce(function(result, param) {
|
|
1022
1152
|
var _param = _slicedToArray(param, 2), key = _param[0], dataBind = _param[1];
|
|
1023
1153
|
// objectDataBind的元素,跳过下一次赋值
|
|
1024
1154
|
skipKeys.push(dataBind.fieldCode);
|
|
@@ -1029,10 +1159,10 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
1029
1159
|
return result;
|
|
1030
1160
|
}, oldState);
|
|
1031
1161
|
} else {
|
|
1032
|
-
|
|
1162
|
+
result[controlId] = state[fieldCode];
|
|
1033
1163
|
}
|
|
1034
1164
|
});
|
|
1035
|
-
return
|
|
1165
|
+
return result;
|
|
1036
1166
|
}
|
|
1037
1167
|
},
|
|
1038
1168
|
{
|
|
@@ -1042,14 +1172,13 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
1042
1172
|
* @options 传递给关联事件中 EventPayload中的options,一般在plugin中监听使用
|
|
1043
1173
|
*/ key: "setData",
|
|
1044
1174
|
value: function setData(dataSet, options) {
|
|
1045
|
-
var
|
|
1175
|
+
var _this = this;
|
|
1046
1176
|
this.debugLog("engine setData方法执行,参数为%o,%o。", dataSet, options);
|
|
1047
1177
|
var newState = this.store.defaultState;
|
|
1048
1178
|
Object.keys(dataSet).map(function(dataCode) {
|
|
1049
1179
|
var entity = dataSet[dataCode];
|
|
1050
1180
|
if (Array.isArray(entity)) {
|
|
1051
|
-
var
|
|
1052
|
-
var mapping = _this6.getDataBindMapping(dataCode);
|
|
1181
|
+
var mapping = _this.getDataBindMapping(dataCode);
|
|
1053
1182
|
if (!mapping) {
|
|
1054
1183
|
return;
|
|
1055
1184
|
}
|
|
@@ -1057,22 +1186,21 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
1057
1186
|
newState[mapping.dataViewId] = {};
|
|
1058
1187
|
}
|
|
1059
1188
|
if (!entity.length) {
|
|
1060
|
-
var
|
|
1061
|
-
newState[mapping.dataViewId][mapping.controlId] = (
|
|
1189
|
+
var _newState_mapping_dataViewId_mapping_controlId;
|
|
1190
|
+
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 : [];
|
|
1062
1191
|
} else {
|
|
1063
1192
|
newState[mapping.dataViewId][mapping.controlId] = [];
|
|
1064
1193
|
}
|
|
1065
1194
|
entity.map(function(row) {
|
|
1066
|
-
var
|
|
1067
|
-
var newRow = JSONCopy(_this4.store.emptyState[mapping.dataViewId][mapping.controlId]);
|
|
1195
|
+
var newRow = JSONCopy(_this.store.emptyState[mapping.dataViewId][mapping.controlId]);
|
|
1068
1196
|
var skipKey = [] //qiyu ObjectDataBind中会提前将相关key拿出来赋值,为了避免重复赋值,设置了此变量
|
|
1069
1197
|
;
|
|
1070
1198
|
Object.keys(row).map(function(fieldCode) {
|
|
1071
|
-
var
|
|
1199
|
+
var _this_store_dataBindMapping_dataCode, _this_store_dataBindMapping_dataCode_fields;
|
|
1072
1200
|
if (skipKey.includes(fieldCode)) {
|
|
1073
1201
|
return;
|
|
1074
1202
|
}
|
|
1075
|
-
var fieldMapping = (
|
|
1203
|
+
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) {
|
|
1076
1204
|
return i.fieldCode === fieldCode;
|
|
1077
1205
|
});
|
|
1078
1206
|
if (fieldMapping) {
|
|
@@ -1081,8 +1209,8 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
1081
1209
|
newRow[fieldMapping.controlId] = row[fieldCode];
|
|
1082
1210
|
// } else if (fieldMapping.dataBind instanceof ObjectDataBind) {
|
|
1083
1211
|
} else if (!isDataBind(fieldMapping.dataBind)) {
|
|
1084
|
-
var
|
|
1085
|
-
var objValue = JSONCopy((
|
|
1212
|
+
var _this_getEmptyState;
|
|
1213
|
+
var objValue = JSONCopy((_this_getEmptyState = _this.getEmptyState(fieldMapping.controlId)) !== null && _this_getEmptyState !== void 0 ? _this_getEmptyState : {});
|
|
1086
1214
|
Object.keys(fieldMapping.dataBind).map(function(key) {
|
|
1087
1215
|
var dataBind = fieldMapping.dataBind[key];
|
|
1088
1216
|
if (row[dataBind.fieldCode] !== undefined) {
|
|
@@ -1097,19 +1225,18 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
1097
1225
|
newState[mapping.dataViewId][mapping.controlId].push(newRow);
|
|
1098
1226
|
});
|
|
1099
1227
|
} else if (entity) {
|
|
1100
|
-
var
|
|
1101
|
-
var
|
|
1228
|
+
var _Object_keys;
|
|
1229
|
+
var skipKey = [] //qiyu ObjectDataBind中会提前将相关key拿出来赋值,为了避免重复赋值,设置了此变量
|
|
1102
1230
|
;
|
|
1103
|
-
var emptyState = JSONCopy(
|
|
1104
|
-
if (!((
|
|
1231
|
+
var emptyState = JSONCopy(_this.store.emptyState);
|
|
1232
|
+
if (!((_Object_keys = Object.keys(entity)) === null || _Object_keys === void 0 ? void 0 : _Object_keys.length)) {
|
|
1105
1233
|
// newState = this.store.defaultState
|
|
1106
1234
|
} else {
|
|
1107
|
-
var _this3 = _this6;
|
|
1108
1235
|
Object.keys(entity).map(function(fieldCode) {
|
|
1109
|
-
if (
|
|
1236
|
+
if (skipKey.includes(fieldCode)) {
|
|
1110
1237
|
return;
|
|
1111
1238
|
}
|
|
1112
|
-
var mapping =
|
|
1239
|
+
var mapping = _this.getDataBindMapping(dataCode, fieldCode);
|
|
1113
1240
|
if (mapping) {
|
|
1114
1241
|
if (!newState[mapping.dataViewId[0]]) {
|
|
1115
1242
|
newState[mapping.dataViewId[0]] = {};
|
|
@@ -1119,31 +1246,31 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
1119
1246
|
newState[mapping.dataViewId[0]][mapping.controlId] = entity[fieldCode] !== undefined ? entity[fieldCode] : emptyState[mapping.dataViewId[0]][mapping.controlId];
|
|
1120
1247
|
// } else if (mapping.dataBind instanceof ObjectDataBind) {
|
|
1121
1248
|
} else if (!isDataBind(mapping.dataBind)) {
|
|
1122
|
-
var
|
|
1123
|
-
var objValue = (
|
|
1249
|
+
var _this_getEmptyState;
|
|
1250
|
+
var objValue = (_this_getEmptyState = _this.getEmptyState(mapping.controlId)) !== null && _this_getEmptyState !== void 0 ? _this_getEmptyState : {};
|
|
1124
1251
|
Object.keys(mapping.dataBind).map(function(key) {
|
|
1125
1252
|
var dataBind = mapping.dataBind[key];
|
|
1126
1253
|
if (entity[dataBind.fieldCode] !== undefined) {
|
|
1127
1254
|
objValue[key] = entity[dataBind.fieldCode];
|
|
1128
1255
|
}
|
|
1129
|
-
|
|
1256
|
+
skipKey.push(dataBind.fieldCode);
|
|
1130
1257
|
});
|
|
1131
1258
|
newState[mapping.dataViewId[0]][mapping.controlId] = objValue;
|
|
1132
1259
|
}
|
|
1133
1260
|
}
|
|
1134
1261
|
});
|
|
1135
1262
|
}
|
|
1136
|
-
var newMapping =
|
|
1263
|
+
var newMapping = _this.getDataBindMapping(dataCode);
|
|
1137
1264
|
if (newMapping) {
|
|
1138
|
-
var
|
|
1139
|
-
var mappingKeys = newMapping === null || newMapping === void 0 ? void 0 : (
|
|
1265
|
+
var _newMapping_fields;
|
|
1266
|
+
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) {
|
|
1140
1267
|
return item === null || item === void 0 ? void 0 : item.controlId;
|
|
1141
1268
|
});
|
|
1142
|
-
var mappingValue =
|
|
1143
|
-
var
|
|
1144
|
-
var mainStateKeys = Object.keys((
|
|
1269
|
+
var mappingValue = _this.getEmptyState(newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId);
|
|
1270
|
+
var _newState_newMapping_controlId;
|
|
1271
|
+
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 : {});
|
|
1145
1272
|
mappingKeys === null || mappingKeys === void 0 ? void 0 : mappingKeys.forEach(function(key) {
|
|
1146
|
-
if (!mainStateKeys.includes(key) && key !==
|
|
1273
|
+
if (!mainStateKeys.includes(key) && key !== "uid" && newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId]) {
|
|
1147
1274
|
if (Object.keys(newState).length) {
|
|
1148
1275
|
Object.assign(newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId], _defineProperty({}, key, mappingValue[key]));
|
|
1149
1276
|
} else {
|
|
@@ -1151,7 +1278,7 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
1151
1278
|
}
|
|
1152
1279
|
}
|
|
1153
1280
|
});
|
|
1154
|
-
|
|
1281
|
+
_this.debugLog("engine setData方法默认值及表单数据组合完成,参数为%o。", newState);
|
|
1155
1282
|
}
|
|
1156
1283
|
}
|
|
1157
1284
|
});
|
|
@@ -1219,13 +1346,13 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
1219
1346
|
}
|
|
1220
1347
|
}
|
|
1221
1348
|
} else {
|
|
1222
|
-
var
|
|
1223
|
-
var controlIdMapping = (
|
|
1224
|
-
var
|
|
1225
|
-
var
|
|
1349
|
+
var _this_getControlIdMapping;
|
|
1350
|
+
var controlIdMapping = (_this_getControlIdMapping = this.getControlIdMapping()) !== null && _this_getControlIdMapping !== void 0 ? _this_getControlIdMapping : {};
|
|
1351
|
+
var _Object_entries_find;
|
|
1352
|
+
var _ref = _slicedToArray((_Object_entries_find = Object.entries(controlIdMapping).find(function(param) {
|
|
1226
1353
|
var _param = _slicedToArray(param, 2), _ = _param[0], mapping = _param[1];
|
|
1227
1354
|
return mapping.children && controlId in mapping.children;
|
|
1228
|
-
})) !== null &&
|
|
1355
|
+
})) !== null && _Object_entries_find !== void 0 ? _Object_entries_find : [], 1), subtableId = _ref[0];
|
|
1229
1356
|
if (subtableId) {
|
|
1230
1357
|
var subtable = this.getInstance(subtableId);
|
|
1231
1358
|
// @ts-ignore
|
|
@@ -1252,16 +1379,16 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
1252
1379
|
{
|
|
1253
1380
|
key: "setInstance",
|
|
1254
1381
|
value: function setInstance(instance, props, value, rowIndex) {
|
|
1382
|
+
var _this = this;
|
|
1255
1383
|
try {
|
|
1256
|
-
if (typeof instance ===
|
|
1257
|
-
var _this = this;
|
|
1384
|
+
if (typeof instance === "string" && rowIndex === -1) {
|
|
1258
1385
|
//修改明细表整列属性的逻辑
|
|
1259
1386
|
var instances = this.getInstances(instance, rowIndex === -1);
|
|
1260
1387
|
instances.map(function(_instance) {
|
|
1261
1388
|
if (_instance) {
|
|
1262
1389
|
_this.debugLog("[%o]: 修改instance: %o的%o属性,修改的值为%o。", _instance.id, _instance, props, value);
|
|
1263
1390
|
updateValueFromKeys(_instance.props, props, value);
|
|
1264
|
-
_this.schemaEvent(
|
|
1391
|
+
_this.schemaEvent("schema-change", {
|
|
1265
1392
|
instance: _instance,
|
|
1266
1393
|
props: props,
|
|
1267
1394
|
value: value,
|
|
@@ -1270,19 +1397,19 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
1270
1397
|
}
|
|
1271
1398
|
});
|
|
1272
1399
|
} else {
|
|
1273
|
-
var
|
|
1274
|
-
if (typeof instance ===
|
|
1275
|
-
|
|
1400
|
+
var _instance;
|
|
1401
|
+
if (typeof instance === "string") {
|
|
1402
|
+
_instance = this.getInstance(instance, rowIndex);
|
|
1276
1403
|
} else {
|
|
1277
|
-
|
|
1404
|
+
_instance = instance;
|
|
1278
1405
|
}
|
|
1279
|
-
if (!
|
|
1406
|
+
if (!_instance) {
|
|
1280
1407
|
return;
|
|
1281
1408
|
}
|
|
1282
|
-
this.debugLog("[%o]: 修改instance: %o的%o属性,修改的值为%o。",
|
|
1283
|
-
updateValueFromKeys(
|
|
1284
|
-
this.schemaEvent(
|
|
1285
|
-
instance:
|
|
1409
|
+
this.debugLog("[%o]: 修改instance: %o的%o属性,修改的值为%o。", _instance.id, _instance, props, value);
|
|
1410
|
+
updateValueFromKeys(_instance.props, props, value);
|
|
1411
|
+
this.schemaEvent("schema-change", {
|
|
1412
|
+
instance: _instance,
|
|
1286
1413
|
props: props,
|
|
1287
1414
|
value: value,
|
|
1288
1415
|
rowIndex: rowIndex
|
|
@@ -1452,8 +1579,8 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
1452
1579
|
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
1453
1580
|
args[_key] = arguments[_key];
|
|
1454
1581
|
}
|
|
1455
|
-
var
|
|
1456
|
-
return (
|
|
1582
|
+
var _this_runtime;
|
|
1583
|
+
return (_this_runtime = this.runtime).registerControlConfig.apply(_this_runtime, _toConsumableArray(args));
|
|
1457
1584
|
}
|
|
1458
1585
|
},
|
|
1459
1586
|
{
|
|
@@ -1465,12 +1592,12 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
|
|
|
1465
1592
|
{
|
|
1466
1593
|
key: "inList",
|
|
1467
1594
|
value: function inList(controlId) {
|
|
1468
|
-
var
|
|
1469
|
-
var mapping = (
|
|
1595
|
+
var _this_store_controlIdMapping;
|
|
1596
|
+
var mapping = (_this_store_controlIdMapping = this.store.controlIdMapping) !== null && _this_store_controlIdMapping !== void 0 ? _this_store_controlIdMapping : {};
|
|
1470
1597
|
var listKey = undefined;
|
|
1471
1598
|
Object.keys(mapping).some(function(key) {
|
|
1472
|
-
var
|
|
1473
|
-
var matched = (
|
|
1599
|
+
var _mapping_key, _mapping_key_children;
|
|
1600
|
+
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);
|
|
1474
1601
|
if (matched) {
|
|
1475
1602
|
listKey = key;
|
|
1476
1603
|
}
|