@byteluck-fe/model-driven-engine 2.8.2-beta.1 → 2.8.2-beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -30
- package/dist/esm/common/ActionManager.js +10 -9
- package/dist/esm/common/DataManager.js +2 -2
- package/dist/esm/common/Engine.js +120 -146
- package/dist/esm/common/OkWorker.js +8 -8
- package/dist/esm/common/Runtime.js +29 -45
- package/dist/esm/common/Store.js +16 -13
- package/dist/esm/common/checkerValue.js +39 -59
- package/dist/esm/common/index.js +2 -2
- package/dist/esm/common/proxyState.js +56 -52
- package/dist/esm/index.js +3 -3
- package/dist/esm/plugins/CalcPlugin.js +61 -57
- package/dist/esm/plugins/ControlsEventPlugin.js +4 -4
- package/dist/esm/plugins/ES6ModulePlugin.js +6 -6
- package/dist/esm/plugins/LifecycleEventPlugin.js +7 -6
- package/dist/esm/plugins/StylePlugin.js +14 -13
- package/dist/esm/plugins/index.js +5 -5
- package/dist/esm/utils/index.js +1 -1
- package/dist/esm/utils/runtimeUtils.js +4 -4
- package/dist/index.umd.js +6 -11
- package/dist/types/common/ActionManager.d.ts +14 -14
- package/dist/types/common/DataManager.d.ts +10 -10
- package/dist/types/common/Engine.d.ts +194 -194
- package/dist/types/common/OkWorker.d.ts +13 -13
- package/dist/types/common/Plugin.d.ts +6 -6
- package/dist/types/common/Runtime.d.ts +31 -31
- package/dist/types/common/Store.d.ts +54 -54
- package/dist/types/common/checkerValue.d.ts +3 -3
- package/dist/types/common/index.d.ts +2 -2
- package/dist/types/common/proxyState.d.ts +30 -30
- package/dist/types/index.d.ts +3 -3
- package/dist/types/plugins/CalcPlugin.d.ts +121 -121
- package/dist/types/plugins/ControlsEventPlugin.d.ts +15 -15
- package/dist/types/plugins/ES6ModulePlugin.d.ts +27 -27
- package/dist/types/plugins/LifecycleEventPlugin.d.ts +15 -14
- package/dist/types/plugins/StylePlugin.d.ts +12 -12
- package/dist/types/plugins/index.d.ts +5 -5
- package/dist/types/utils/index.d.ts +1 -1
- package/dist/types/utils/runtimeUtils.d.ts +5 -5
- package/package.json +4 -4
|
@@ -44,6 +44,10 @@ function _async_to_generator(fn) {
|
|
|
44
44
|
});
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
|
+
function _call_super(_this, derived, args) {
|
|
48
|
+
derived = _get_prototype_of(derived);
|
|
49
|
+
return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
|
|
50
|
+
}
|
|
47
51
|
function _class_call_check(instance, Constructor) {
|
|
48
52
|
if (!(instance instanceof Constructor)) {
|
|
49
53
|
throw new TypeError("Cannot call a class as a function");
|
|
@@ -222,28 +226,12 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
222
226
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
223
227
|
}
|
|
224
228
|
function _is_native_reflect_construct() {
|
|
225
|
-
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
226
|
-
if (Reflect.construct.sham) return false;
|
|
227
|
-
if (typeof Proxy === "function") return true;
|
|
228
229
|
try {
|
|
229
|
-
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
return
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
function _create_super(Derived) {
|
|
236
|
-
var hasNativeReflectConstruct = _is_native_reflect_construct();
|
|
237
|
-
return function _createSuperInternal() {
|
|
238
|
-
var Super = _get_prototype_of(Derived), result;
|
|
239
|
-
if (hasNativeReflectConstruct) {
|
|
240
|
-
var NewTarget = _get_prototype_of(this).constructor;
|
|
241
|
-
result = Reflect.construct(Super, arguments, NewTarget);
|
|
242
|
-
} else {
|
|
243
|
-
result = Super.apply(this, arguments);
|
|
244
|
-
}
|
|
245
|
-
return _possible_constructor_return(this, result);
|
|
246
|
-
};
|
|
230
|
+
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
231
|
+
} catch (_) {}
|
|
232
|
+
return (_is_native_reflect_construct = function() {
|
|
233
|
+
return !!result;
|
|
234
|
+
})();
|
|
247
235
|
}
|
|
248
236
|
function _ts_generator(thisArg, body) {
|
|
249
237
|
var f, y, t, g, _ = {
|
|
@@ -340,50 +328,35 @@ function _ts_generator(thisArg, body) {
|
|
|
340
328
|
};
|
|
341
329
|
}
|
|
342
330
|
}
|
|
343
|
-
import { isDataBind } from
|
|
344
|
-
import { CONTROL_BASE_TYPE, CONTROL_TYPE, DEFAULT_LOCALE, error, genNonDuplicateId, isString, JSONCopy, log, RulesMessage, updateValueFromKeys, warn, Watcher, isBuiltInControls } from
|
|
345
|
-
import { Runtime } from
|
|
346
|
-
import { Store } from
|
|
347
|
-
import { findItem, proxyState } from
|
|
348
|
-
import { ActionManager } from
|
|
349
|
-
import { DataManager } from
|
|
350
|
-
import { checkerSubtableValue, checkerValue } from
|
|
351
|
-
import { buildUUID } from
|
|
352
|
-
if (typeof window !==
|
|
331
|
+
import { isDataBind } from '@byteluck-fe/model-driven-core';
|
|
332
|
+
import { CONTROL_BASE_TYPE, CONTROL_TYPE, DEFAULT_LOCALE, error, genNonDuplicateId, isString, JSONCopy, log, RulesMessage, updateValueFromKeys, warn, Watcher, isBuiltInControls } from '@byteluck-fe/model-driven-shared';
|
|
333
|
+
import { Runtime } from './Runtime';
|
|
334
|
+
import { Store } from './Store';
|
|
335
|
+
import { findItem, proxyState } from './proxyState';
|
|
336
|
+
import { ActionManager } from './ActionManager';
|
|
337
|
+
import { DataManager } from './DataManager';
|
|
338
|
+
import { checkerSubtableValue, checkerValue } from './checkerValue';
|
|
339
|
+
import { buildUUID } from '../utils/runtimeUtils';
|
|
340
|
+
if (typeof window !== 'undefined') {
|
|
353
341
|
// @ts-ignore
|
|
354
342
|
window.engines = {};
|
|
355
343
|
}
|
|
356
344
|
// setState的时候,存储options中转变量
|
|
357
345
|
var eventOptionsTemp = null;
|
|
358
346
|
// 当前正在注册的插件名称
|
|
359
|
-
var applyingPluginName =
|
|
347
|
+
var applyingPluginName = '';
|
|
360
348
|
// 整体渲染引擎 并且 提供发布订阅能力
|
|
361
349
|
var Engine = /*#__PURE__*/ function(Watcher) {
|
|
362
350
|
"use strict";
|
|
363
351
|
_inherits(Engine, Watcher);
|
|
364
|
-
var _super = _create_super(Engine);
|
|
365
352
|
function Engine(props) {
|
|
366
353
|
_class_call_check(this, Engine);
|
|
367
354
|
var _this;
|
|
368
|
-
_this =
|
|
369
|
-
_define_property(
|
|
370
|
-
_define_property(_assert_this_initialized(_this), "rawStore", {});
|
|
371
|
-
_define_property(_assert_this_initialized(_this), "parent", void 0);
|
|
372
|
-
// 提供注册运行态控件以及实例化控件的能力
|
|
373
|
-
_define_property(_assert_this_initialized(_this), "runtime", void 0);
|
|
374
|
-
// 提供子线程处理脚本以及修改数据的能力
|
|
355
|
+
_this = _call_super(this, Engine), _define_property(_this, "store", void 0), _define_property(_this, "rawStore", {}), _define_property(_this, "parent", void 0), // 提供注册运行态控件以及实例化控件的能力
|
|
356
|
+
_define_property(_this, "runtime", void 0), // 提供子线程处理脚本以及修改数据的能力
|
|
375
357
|
// public worker: OkWorker
|
|
376
|
-
_define_property(
|
|
377
|
-
_define_property(
|
|
378
|
-
_define_property(_assert_this_initialized(_this), "externalParams", void 0);
|
|
379
|
-
// 提供外部注册插件,在不同的hooks触发时执行固定函数的能力
|
|
380
|
-
_define_property(_assert_this_initialized(_this), "__plugins", void 0);
|
|
381
|
-
_define_property(_assert_this_initialized(_this), "__pluginsApplied", false);
|
|
382
|
-
_define_property(_assert_this_initialized(_this), "$options", void 0);
|
|
383
|
-
_define_property(_assert_this_initialized(_this), "actionManager", new ActionManager());
|
|
384
|
-
_define_property(_assert_this_initialized(_this), "dataManager", void 0);
|
|
385
|
-
_define_property(_assert_this_initialized(_this), "_jobTasks", []);
|
|
386
|
-
_define_property(_assert_this_initialized(_this), "createControlInstance", _this.createInstance);
|
|
358
|
+
_define_property(_this, "isMounted", false), _define_property(_this, "id", genNonDuplicateId(8)), _define_property(_this, "externalParams", void 0), // 提供外部注册插件,在不同的hooks触发时执行固定函数的能力
|
|
359
|
+
_define_property(_this, "__plugins", void 0), _define_property(_this, "__pluginsApplied", false), _define_property(_this, "$options", void 0), _define_property(_this, "actionManager", new ActionManager()), _define_property(_this, "dataManager", void 0), _define_property(_this, "_jobTasks", []), _define_property(_this, "createControlInstance", _this.createInstance);
|
|
387
360
|
_this.$options = Object.freeze(props);
|
|
388
361
|
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,
|
|
389
362
|
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;
|
|
@@ -397,7 +370,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
397
370
|
_this.store = new Store({
|
|
398
371
|
instance: _this.runtime.instance
|
|
399
372
|
});
|
|
400
|
-
_this.debugLog(
|
|
373
|
+
_this.debugLog('engine is Instantiation complete');
|
|
401
374
|
// 自动执行挂载完成,也可以手动调用mount方法
|
|
402
375
|
autoMount && _this.mount();
|
|
403
376
|
return _this;
|
|
@@ -444,7 +417,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
444
417
|
// 触发所有控件的默认值的change事件
|
|
445
418
|
this.setStates(this.getState());
|
|
446
419
|
this.debugLog("engine的mount方法调用结束");
|
|
447
|
-
if (this.debug && typeof window !==
|
|
420
|
+
if (this.debug && typeof window !== 'undefined') {
|
|
448
421
|
// @ts-ignore
|
|
449
422
|
window.engines[this.id] = this;
|
|
450
423
|
}
|
|
@@ -453,7 +426,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
453
426
|
{
|
|
454
427
|
key: "destroy",
|
|
455
428
|
value: function destroy() {
|
|
456
|
-
if (this.debug && typeof window !==
|
|
429
|
+
if (this.debug && typeof window !== 'undefined') {
|
|
457
430
|
// @ts-ignore
|
|
458
431
|
delete window.engines[this.id];
|
|
459
432
|
}
|
|
@@ -494,7 +467,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
494
467
|
checkerSubtableValue(fieldTypeMap, row, emptyState));
|
|
495
468
|
});
|
|
496
469
|
}
|
|
497
|
-
var keys = key.split(
|
|
470
|
+
var keys = key.split('.');
|
|
498
471
|
var lastKey = keys[keys.length - 1];
|
|
499
472
|
try {
|
|
500
473
|
return checkerValue(instance.fieldType, lastKey, newValue, oldValue);
|
|
@@ -527,7 +500,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
527
500
|
var newRows = [];
|
|
528
501
|
for(var i = 0; i < len; i++){
|
|
529
502
|
// @ts-ignore
|
|
530
|
-
var row = _this.listControlCreateRow(subtable,
|
|
503
|
+
var row = _this.listControlCreateRow(subtable, 'subtable-row');
|
|
531
504
|
row && newRows.push(row);
|
|
532
505
|
}
|
|
533
506
|
// @ts-ignore
|
|
@@ -542,8 +515,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
542
515
|
if (type && args) {
|
|
543
516
|
// const subtableOldLength = subtable.children.length
|
|
544
517
|
switch(type){
|
|
545
|
-
case
|
|
546
|
-
case
|
|
518
|
+
case 'push':
|
|
519
|
+
case 'unshift':
|
|
547
520
|
var _subtable_children;
|
|
548
521
|
var newRowLengths = args.length;
|
|
549
522
|
createdNewRows = createRows(newRowLengths);
|
|
@@ -551,7 +524,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
551
524
|
(_subtable_children = subtable.children)[type].apply(_subtable_children, _to_consumable_array(createdNewRows));
|
|
552
525
|
this.runtime.getFlatInstances();
|
|
553
526
|
break;
|
|
554
|
-
case
|
|
527
|
+
case 'splice':
|
|
555
528
|
if (args.length > 2) {
|
|
556
529
|
var // @ts-ignore
|
|
557
530
|
_subtable_children1;
|
|
@@ -593,11 +566,11 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
593
566
|
this.runtime.getFlatInstances();
|
|
594
567
|
break;
|
|
595
568
|
}
|
|
596
|
-
if (type ===
|
|
569
|
+
if (type === 'splice') {
|
|
597
570
|
deleted = result;
|
|
598
571
|
} else if ([
|
|
599
|
-
|
|
600
|
-
|
|
572
|
+
'pop',
|
|
573
|
+
'shift'
|
|
601
574
|
].includes(type)) {
|
|
602
575
|
deleted = [
|
|
603
576
|
result
|
|
@@ -605,7 +578,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
605
578
|
}
|
|
606
579
|
var subtableData = this.getState(subtable.id);
|
|
607
580
|
this._handlerSubtableUpdateUid(subtableData);
|
|
608
|
-
this.emit(
|
|
581
|
+
this.emit('list-change', {
|
|
609
582
|
instance: subtable,
|
|
610
583
|
value: subtableData,
|
|
611
584
|
options: Object.assign({}, options, {
|
|
@@ -626,10 +599,11 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
626
599
|
{
|
|
627
600
|
key: "_handlerSubtableUpdateUid",
|
|
628
601
|
value: function _handlerSubtableUpdateUid(subtableData) {
|
|
602
|
+
;
|
|
629
603
|
subtableData.forEach(function(item) {
|
|
630
604
|
if (!item.uid) {
|
|
631
605
|
Object.assign(item, {
|
|
632
|
-
uid:
|
|
606
|
+
uid: 'new:' + buildUUID('uid')
|
|
633
607
|
});
|
|
634
608
|
}
|
|
635
609
|
});
|
|
@@ -654,7 +628,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
654
628
|
var newRows = [];
|
|
655
629
|
for(var i = 0; i < newValue.length; i++){
|
|
656
630
|
// @ts-ignore
|
|
657
|
-
var row = this.listControlCreateRow(instance,
|
|
631
|
+
var row = this.listControlCreateRow(instance, 'subtable-row');
|
|
658
632
|
row && newRows.push(row);
|
|
659
633
|
}
|
|
660
634
|
(_instance_children = instance.children).push.apply(_instance_children, _to_consumable_array(newRows));
|
|
@@ -668,7 +642,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
668
642
|
deleted = [];
|
|
669
643
|
}
|
|
670
644
|
this._handlerSubtableUpdateUid(newValue);
|
|
671
|
-
this.emit(
|
|
645
|
+
this.emit('list-change', {
|
|
672
646
|
instance: instance,
|
|
673
647
|
value: value,
|
|
674
648
|
options: _object_spread_props(_object_spread({}, options), {
|
|
@@ -677,12 +651,12 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
677
651
|
data: newValue,
|
|
678
652
|
deleted: deleted,
|
|
679
653
|
// deleted: oldValue ?? [],
|
|
680
|
-
type:
|
|
654
|
+
type: 'push',
|
|
681
655
|
jsonValue: JSON.stringify(newValue)
|
|
682
656
|
})
|
|
683
657
|
});
|
|
684
658
|
} else {
|
|
685
|
-
this.emit(
|
|
659
|
+
this.emit('change', {
|
|
686
660
|
instance: instance,
|
|
687
661
|
value: this.getState(instance.id, index),
|
|
688
662
|
rowIndex: index,
|
|
@@ -706,7 +680,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
706
680
|
} catch (e) {
|
|
707
681
|
error("".concat(applyingPluginName, " Plugin apply Error \n ").concat(e));
|
|
708
682
|
} finally{
|
|
709
|
-
applyingPluginName =
|
|
683
|
+
applyingPluginName = '';
|
|
710
684
|
}
|
|
711
685
|
});
|
|
712
686
|
this.__pluginsApplied = true;
|
|
@@ -716,20 +690,20 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
716
690
|
key: "listControlCreateRow",
|
|
717
691
|
value: function listControlCreateRow(instance, rowType) {
|
|
718
692
|
var row;
|
|
719
|
-
if (rowType ===
|
|
693
|
+
if (rowType === 'subtable-row') {
|
|
720
694
|
row = {
|
|
721
695
|
children: [],
|
|
722
696
|
controlType: CONTROL_BASE_TYPE.LAYOUT,
|
|
723
697
|
id: genNonDuplicateId(),
|
|
724
|
-
type:
|
|
698
|
+
type: 'subtable-row',
|
|
725
699
|
props: {
|
|
726
|
-
caption:
|
|
700
|
+
caption: '',
|
|
727
701
|
isHide: false,
|
|
728
702
|
style: {
|
|
729
|
-
height:
|
|
730
|
-
heightConfig:
|
|
731
|
-
width:
|
|
732
|
-
widthConfig:
|
|
703
|
+
height: '',
|
|
704
|
+
heightConfig: 'fill',
|
|
705
|
+
width: '',
|
|
706
|
+
widthConfig: 'fill'
|
|
733
707
|
}
|
|
734
708
|
},
|
|
735
709
|
fieldType: undefined,
|
|
@@ -783,7 +757,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
783
757
|
key: "listControlAddRow",
|
|
784
758
|
value: function listControlAddRow(instance) {
|
|
785
759
|
var // @ts-ignore
|
|
786
|
-
rowType = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] :
|
|
760
|
+
rowType = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 'subtable-row';
|
|
787
761
|
var row = this.listControlCreateRow(instance, rowType);
|
|
788
762
|
if (!row) return;
|
|
789
763
|
instance.children.push(row);
|
|
@@ -802,12 +776,12 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
802
776
|
return _ts_generator(this, function(_state) {
|
|
803
777
|
switch(_state.label){
|
|
804
778
|
case 0:
|
|
805
|
-
if (!(eventKey ===
|
|
779
|
+
if (!(eventKey === 'engine-mounted')) return [
|
|
806
780
|
3,
|
|
807
781
|
3
|
|
808
782
|
];
|
|
809
783
|
if (_this1.isMounted) {
|
|
810
|
-
warn(
|
|
784
|
+
warn('The engine-mounted life cycle can only be triggered once');
|
|
811
785
|
return [
|
|
812
786
|
2,
|
|
813
787
|
Promise.resolve([])
|
|
@@ -817,7 +791,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
817
791
|
3,
|
|
818
792
|
2
|
|
819
793
|
];
|
|
820
|
-
console.time(
|
|
794
|
+
console.time('engine-mounted need wait');
|
|
821
795
|
needWait = _to_consumable_array(_this1._jobTasks);
|
|
822
796
|
return [
|
|
823
797
|
4,
|
|
@@ -825,7 +799,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
825
799
|
];
|
|
826
800
|
case 1:
|
|
827
801
|
_state.sent();
|
|
828
|
-
console.timeEnd(
|
|
802
|
+
console.timeEnd('engine-mounted need wait');
|
|
829
803
|
_state.label = 2;
|
|
830
804
|
case 2:
|
|
831
805
|
_this1.isMounted = true;
|
|
@@ -978,9 +952,9 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
978
952
|
}
|
|
979
953
|
},
|
|
980
954
|
{
|
|
981
|
-
/**
|
|
982
|
-
* 设置payload的options,提供在不是使用标准api修改state的时候可以传递options,会在本次任务执行完成之后清空
|
|
983
|
-
* @param options 需要携带的options
|
|
955
|
+
/**
|
|
956
|
+
* 设置payload的options,提供在不是使用标准api修改state的时候可以传递options,会在本次任务执行完成之后清空
|
|
957
|
+
* @param options 需要携带的options
|
|
984
958
|
* */ key: "setPayloadOptions",
|
|
985
959
|
value: function setPayloadOptions(options) {
|
|
986
960
|
eventOptionsTemp = options;
|
|
@@ -990,16 +964,16 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
990
964
|
key: "setState",
|
|
991
965
|
value: function setState(controlId, value, rowIndex, options) {
|
|
992
966
|
eventOptionsTemp = options;
|
|
993
|
-
this.debugLog(
|
|
967
|
+
this.debugLog('[%o]: 触发setState, 修改的值为%o, rowIndex=%o, options=%o', controlId, value, rowIndex, options);
|
|
994
968
|
this.store.setState(controlId, value, rowIndex);
|
|
995
|
-
this.debugLog(
|
|
969
|
+
this.debugLog('[%o]: setState完成, 修改的值为%o, rowIndex=%o', controlId, value, rowIndex);
|
|
996
970
|
eventOptionsTemp = null;
|
|
997
971
|
}
|
|
998
972
|
},
|
|
999
973
|
{
|
|
1000
|
-
/**
|
|
1001
|
-
* 向Store设置一组值,明细表必须全量赋值,并触发事件(触发事件是根据组件在页面中的顺序逐个触发)
|
|
1002
|
-
* @param states
|
|
974
|
+
/**
|
|
975
|
+
* 向Store设置一组值,明细表必须全量赋值,并触发事件(触发事件是根据组件在页面中的顺序逐个触发)
|
|
976
|
+
* @param states
|
|
1003
977
|
*/ key: "setStates",
|
|
1004
978
|
value: function setStates(states, rowIndex, options) {
|
|
1005
979
|
var _this = this;
|
|
@@ -1026,11 +1000,11 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1026
1000
|
}
|
|
1027
1001
|
},
|
|
1028
1002
|
{
|
|
1029
|
-
/**
|
|
1030
|
-
* 通过dataCode和fieldCode来获取控件的值
|
|
1031
|
-
* @param dataCode 模型编码 - 如果是主表的话就是主表的模型编码,明细子表的话就是子表的模型编码
|
|
1032
|
-
* @param fieldCode 字段编码 - 控件绑定的数据项的编码
|
|
1033
|
-
* @param rowIndex 行下标 - 如果是明细子表中的控件需要提供
|
|
1003
|
+
/**
|
|
1004
|
+
* 通过dataCode和fieldCode来获取控件的值
|
|
1005
|
+
* @param dataCode 模型编码 - 如果是主表的话就是主表的模型编码,明细子表的话就是子表的模型编码
|
|
1006
|
+
* @param fieldCode 字段编码 - 控件绑定的数据项的编码
|
|
1007
|
+
* @param rowIndex 行下标 - 如果是明细子表中的控件需要提供
|
|
1034
1008
|
* */ key: "getField",
|
|
1035
1009
|
value: function getField(dataCode, fieldCode, rowIndex) {
|
|
1036
1010
|
if (!fieldCode) {
|
|
@@ -1079,7 +1053,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1079
1053
|
var _controlIdMapping_controlId_children_key_dataBind, _controlIdMapping_controlId_children_key, _controlIdMapping_controlId;
|
|
1080
1054
|
var fieldCode = (_controlIdMapping_controlId = controlIdMapping[controlId]) === null || _controlIdMapping_controlId === void 0 ? void 0 : (_controlIdMapping_controlId_children_key = _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;
|
|
1081
1055
|
//未绑定字段的控件,直接抛弃
|
|
1082
|
-
if (fieldCode !==
|
|
1056
|
+
if (fieldCode !== '') {
|
|
1083
1057
|
var _controlIdMapping_controlId1;
|
|
1084
1058
|
if (fieldCode) {
|
|
1085
1059
|
obj[fieldCode] = item[key];
|
|
@@ -1110,7 +1084,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1110
1084
|
var _controlIdMapping_key_children_keyChi;
|
|
1111
1085
|
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;
|
|
1112
1086
|
//未绑定字段的控件,直接抛弃
|
|
1113
|
-
if (fieldCode !==
|
|
1087
|
+
if (fieldCode !== '') {
|
|
1114
1088
|
if (fieldCode) {
|
|
1115
1089
|
objChi[fieldCode] = item[keyChi];
|
|
1116
1090
|
} else {
|
|
@@ -1141,13 +1115,13 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1141
1115
|
}
|
|
1142
1116
|
},
|
|
1143
1117
|
{
|
|
1144
|
-
/**
|
|
1145
|
-
* 通过dataCode和fieldCode来设置控件的值
|
|
1146
|
-
* @param dataCode 模型编码 - 如果是主表的话就是主表的模型编码,明细子表的话就是子表的模型编码
|
|
1147
|
-
* @param fieldCode 字段编码 - 控件绑定的数据项的编码
|
|
1148
|
-
* @param value 修改的值
|
|
1149
|
-
* @param rowIndex 行下标 - 如果是明细子表中的控件需要提供
|
|
1150
|
-
* @param options 触发事件携带的参数
|
|
1118
|
+
/**
|
|
1119
|
+
* 通过dataCode和fieldCode来设置控件的值
|
|
1120
|
+
* @param dataCode 模型编码 - 如果是主表的话就是主表的模型编码,明细子表的话就是子表的模型编码
|
|
1121
|
+
* @param fieldCode 字段编码 - 控件绑定的数据项的编码
|
|
1122
|
+
* @param value 修改的值
|
|
1123
|
+
* @param rowIndex 行下标 - 如果是明细子表中的控件需要提供
|
|
1124
|
+
* @param options 触发事件携带的参数
|
|
1151
1125
|
* */ key: "setField",
|
|
1152
1126
|
value: function setField(dataCode, fieldCode, value, rowIndex, options) {
|
|
1153
1127
|
var dataBindMapping = this.getDataBindMapping(dataCode, fieldCode);
|
|
@@ -1175,12 +1149,12 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1175
1149
|
}
|
|
1176
1150
|
},
|
|
1177
1151
|
{
|
|
1178
|
-
/**
|
|
1179
|
-
* 通过dataCode和 state来给一组控件赋值,并触发事件携带options
|
|
1180
|
-
* @param dataCode 需要赋值的目标模型
|
|
1181
|
-
* @param state 赋值对象,以fieldCode为key组成的对象
|
|
1182
|
-
* @param rowIndex 行下标,给明细子表赋值时指定赋值某行
|
|
1183
|
-
* @param options 触发事件携带的参数
|
|
1152
|
+
/**
|
|
1153
|
+
* 通过dataCode和 state来给一组控件赋值,并触发事件携带options
|
|
1154
|
+
* @param dataCode 需要赋值的目标模型
|
|
1155
|
+
* @param state 赋值对象,以fieldCode为key组成的对象
|
|
1156
|
+
* @param rowIndex 行下标,给明细子表赋值时指定赋值某行
|
|
1157
|
+
* @param options 触发事件携带的参数
|
|
1184
1158
|
* */ key: "setFields",
|
|
1185
1159
|
value: function setFields(dataCode, state, rowIndex, options) {
|
|
1186
1160
|
var _this = this;
|
|
@@ -1221,10 +1195,10 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1221
1195
|
}
|
|
1222
1196
|
},
|
|
1223
1197
|
{
|
|
1224
|
-
/**
|
|
1225
|
-
* 通过dataCode来将state转化为标准的state结构
|
|
1226
|
-
* @param dataCode 需要转换的目标模型code
|
|
1227
|
-
* @param state 值对象,以fieldCode为key组成的对象
|
|
1198
|
+
/**
|
|
1199
|
+
* 通过dataCode来将state转化为标准的state结构
|
|
1200
|
+
* @param dataCode 需要转换的目标模型code
|
|
1201
|
+
* @param state 值对象,以fieldCode为key组成的对象
|
|
1228
1202
|
* */ key: "buildFields",
|
|
1229
1203
|
value: function buildFields(dataCode, state) {
|
|
1230
1204
|
var _this = this;
|
|
@@ -1265,10 +1239,10 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1265
1239
|
}
|
|
1266
1240
|
},
|
|
1267
1241
|
{
|
|
1268
|
-
/**
|
|
1269
|
-
* 向Store设置一组值,并触发事件携带options
|
|
1270
|
-
* @param dataSet
|
|
1271
|
-
* @options 传递给关联事件中 EventPayload中的options,一般在plugin中监听使用
|
|
1242
|
+
/**
|
|
1243
|
+
* 向Store设置一组值,并触发事件携带options
|
|
1244
|
+
* @param dataSet
|
|
1245
|
+
* @options 传递给关联事件中 EventPayload中的options,一般在plugin中监听使用
|
|
1272
1246
|
*/ key: "setData",
|
|
1273
1247
|
value: function setData(dataSet, options) {
|
|
1274
1248
|
var _this = this;
|
|
@@ -1331,9 +1305,9 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1331
1305
|
});
|
|
1332
1306
|
newRow[fieldMapping.controlId] = objValue;
|
|
1333
1307
|
}
|
|
1334
|
-
} else if (fieldCode ===
|
|
1308
|
+
} else if (fieldCode === 'uid' && row.uid !== undefined) {
|
|
1335
1309
|
newRow.uid = row.uid;
|
|
1336
|
-
} else if (fieldCode ===
|
|
1310
|
+
} else if (fieldCode === 'virtualStore' && row.virtualStore !== undefined) {
|
|
1337
1311
|
newRow.virtualStore = Object.freeze(row.virtualStore);
|
|
1338
1312
|
}
|
|
1339
1313
|
});
|
|
@@ -1385,7 +1359,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1385
1359
|
var _newState_newMapping_controlId;
|
|
1386
1360
|
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 : {});
|
|
1387
1361
|
mappingKeys === null || mappingKeys === void 0 ? void 0 : mappingKeys.forEach(function(key) {
|
|
1388
|
-
if (!mainStateKeys.includes(key) && key !==
|
|
1362
|
+
if (!mainStateKeys.includes(key) && key !== 'uid' && newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId]) {
|
|
1389
1363
|
if (Object.keys(newState).length) {
|
|
1390
1364
|
Object.assign(newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId], _define_property({}, key, mappingValue[key]));
|
|
1391
1365
|
} else {
|
|
@@ -1405,19 +1379,19 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1405
1379
|
}
|
|
1406
1380
|
},
|
|
1407
1381
|
{
|
|
1408
|
-
/**
|
|
1409
|
-
* 获取控件的dataBind
|
|
1410
|
-
* @param controlId
|
|
1382
|
+
/**
|
|
1383
|
+
* 获取控件的dataBind
|
|
1384
|
+
* @param controlId
|
|
1411
1385
|
* */ key: "getDataBind",
|
|
1412
1386
|
value: function getDataBind(controlId) {
|
|
1413
1387
|
return this.store.getDataBind(controlId);
|
|
1414
1388
|
}
|
|
1415
1389
|
},
|
|
1416
1390
|
{
|
|
1417
|
-
/**
|
|
1418
|
-
* 获取组件实例,传入rowIndex代表获取明细表内的控件实例,rowIndex传入-1代表获取表头内的实例
|
|
1419
|
-
* @param controlId
|
|
1420
|
-
* @param rowIndex
|
|
1391
|
+
/**
|
|
1392
|
+
* 获取组件实例,传入rowIndex代表获取明细表内的控件实例,rowIndex传入-1代表获取表头内的实例
|
|
1393
|
+
* @param controlId
|
|
1394
|
+
* @param rowIndex
|
|
1421
1395
|
*/ key: "getInstance",
|
|
1422
1396
|
value: function getInstance(controlId, rowIndex) {
|
|
1423
1397
|
var instances = this.getInstances(controlId, rowIndex === -1);
|
|
@@ -1436,10 +1410,10 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1436
1410
|
}
|
|
1437
1411
|
},
|
|
1438
1412
|
{
|
|
1439
|
-
/**
|
|
1440
|
-
* 获取组件实例,明细表中的组件将会得到数组, 第二个参数为(false/不传入)则获取到的是明细表内不包含表头内实例的所有控件实例,传入true则获取到包含表头内实例的所有控件实例,表头内实例永远在下标0的位置
|
|
1441
|
-
* @param controlId
|
|
1442
|
-
* @param header 明细表内是否获取表头的控件
|
|
1413
|
+
/**
|
|
1414
|
+
* 获取组件实例,明细表中的组件将会得到数组, 第二个参数为(false/不传入)则获取到的是明细表内不包含表头内实例的所有控件实例,传入true则获取到包含表头内实例的所有控件实例,表头内实例永远在下标0的位置
|
|
1415
|
+
* @param controlId
|
|
1416
|
+
* @param header 明细表内是否获取表头的控件
|
|
1443
1417
|
*/ // getInstances(
|
|
1444
1418
|
// controlId?: string,
|
|
1445
1419
|
// header: boolean = false
|
|
@@ -1522,14 +1496,14 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1522
1496
|
value: function setInstance(instance, props, value, rowIndex) {
|
|
1523
1497
|
var _this = this;
|
|
1524
1498
|
try {
|
|
1525
|
-
if (typeof instance ===
|
|
1499
|
+
if (typeof instance === 'string' && rowIndex === -1) {
|
|
1526
1500
|
//修改明细表整列属性的逻辑
|
|
1527
1501
|
var instances = this.getInstances(instance, rowIndex === -1);
|
|
1528
1502
|
instances.map(function(_instance) {
|
|
1529
1503
|
if (_instance) {
|
|
1530
1504
|
_this.debugLog("[%o]: 修改instance: %o的%o属性,修改的值为%o。", _instance.id, _instance, props, value);
|
|
1531
1505
|
updateValueFromKeys(_instance.props, props, value);
|
|
1532
|
-
_this.schemaEvent(
|
|
1506
|
+
_this.schemaEvent('schema-change', {
|
|
1533
1507
|
instance: _instance,
|
|
1534
1508
|
props: props,
|
|
1535
1509
|
value: value,
|
|
@@ -1539,7 +1513,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1539
1513
|
});
|
|
1540
1514
|
} else {
|
|
1541
1515
|
var _instance;
|
|
1542
|
-
if (typeof instance ===
|
|
1516
|
+
if (typeof instance === 'string') {
|
|
1543
1517
|
_instance = this.getInstance(instance, rowIndex);
|
|
1544
1518
|
} else {
|
|
1545
1519
|
_instance = instance;
|
|
@@ -1549,7 +1523,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1549
1523
|
}
|
|
1550
1524
|
this.debugLog("[%o]: 修改instance: %o的%o属性,修改的值为%o。", _instance.id, _instance, props, value);
|
|
1551
1525
|
updateValueFromKeys(_instance.props, props, value);
|
|
1552
|
-
this.schemaEvent(
|
|
1526
|
+
this.schemaEvent('schema-change', {
|
|
1553
1527
|
instance: _instance,
|
|
1554
1528
|
props: props,
|
|
1555
1529
|
value: value,
|
|
@@ -1611,27 +1585,27 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1611
1585
|
},
|
|
1612
1586
|
{
|
|
1613
1587
|
key: "assertInstance",
|
|
1614
|
-
value: /**
|
|
1615
|
-
* 判断控件的类型,返回当前控件的正确类型
|
|
1588
|
+
value: /**
|
|
1589
|
+
* 判断控件的类型,返回当前控件的正确类型
|
|
1616
1590
|
* */ function assertInstance(instance, types) {
|
|
1617
1591
|
return isString(types) ? instance.type === types : types.includes(instance.type);
|
|
1618
1592
|
}
|
|
1619
1593
|
},
|
|
1620
1594
|
{
|
|
1621
1595
|
key: "assertInstanceIsCustomControl",
|
|
1622
|
-
value: /**
|
|
1623
|
-
* 判断控件或控件类型是一个自定义控件
|
|
1596
|
+
value: /**
|
|
1597
|
+
* 判断控件或控件类型是一个自定义控件
|
|
1624
1598
|
* */ function assertInstanceIsCustomControl(instance) {
|
|
1625
1599
|
return !isBuiltInControls(isString(instance) ? instance : instance.type);
|
|
1626
1600
|
}
|
|
1627
1601
|
},
|
|
1628
1602
|
{
|
|
1629
1603
|
key: "getInstanceRowIndex",
|
|
1630
|
-
value: /**
|
|
1631
|
-
* 获取控件在明细子表中的行下标,
|
|
1632
|
-
* 如果控件在表头内,则返回-1
|
|
1633
|
-
* 如果控件在表内,则返回行下标
|
|
1634
|
-
* 如果控件不在明细表内,则返回undefined
|
|
1604
|
+
value: /**
|
|
1605
|
+
* 获取控件在明细子表中的行下标,
|
|
1606
|
+
* 如果控件在表头内,则返回-1
|
|
1607
|
+
* 如果控件在表内,则返回行下标
|
|
1608
|
+
* 如果控件不在明细表内,则返回undefined
|
|
1635
1609
|
* */ // public getInstanceRowIndex(
|
|
1636
1610
|
// instance: ControlRuntimeInstance<ControlsKeys> | RuntimeControl
|
|
1637
1611
|
// ) {
|
|
@@ -1676,7 +1650,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1676
1650
|
CONTROL_TYPE.SUBTABLE_COLUMN);
|
|
1677
1651
|
if (isColumnChild) {
|
|
1678
1652
|
var instanceList = this.runtime.instanceMap[instance.id];
|
|
1679
|
-
if (Object.prototype.toString.call(instanceList) ===
|
|
1653
|
+
if (Object.prototype.toString.call(instanceList) === '[object Array]') {
|
|
1680
1654
|
var index = instanceList.findIndex(function(item) {
|
|
1681
1655
|
return item === instance;
|
|
1682
1656
|
});
|
|
@@ -1782,7 +1756,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1782
1756
|
key: "register",
|
|
1783
1757
|
value: // 注册外部控件
|
|
1784
1758
|
function register(control) {
|
|
1785
|
-
return Runtime.register(control,
|
|
1759
|
+
return Runtime.register(control, 'Runtime');
|
|
1786
1760
|
}
|
|
1787
1761
|
},
|
|
1788
1762
|
{
|