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