@byteluck-fe/model-driven-engine 2.22.2-beta.1 → 2.22.2-beta.2
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 +7 -7
- package/dist/esm/common/DataManager.js +2 -2
- package/dist/esm/common/Engine.js +109 -107
- package/dist/esm/common/OkWorker.js +8 -8
- package/dist/esm/common/Runtime.js +17 -17
- package/dist/esm/common/Store.js +13 -13
- package/dist/esm/common/checkerValue.js +22 -22
- package/dist/esm/common/index.js +2 -2
- package/dist/esm/common/proxyState.js +52 -56
- package/dist/esm/index.js +3 -3
- package/dist/esm/plugins/CalcPlugin.js +57 -61
- package/dist/esm/plugins/ControlsEventPlugin.js +4 -4
- package/dist/esm/plugins/ES6ModulePlugin.js +6 -6
- package/dist/esm/plugins/LifecycleEventPlugin.js +5 -5
- package/dist/esm/plugins/StylePlugin.js +10 -10
- package/dist/esm/plugins/index.js +5 -5
- package/dist/esm/utils/index.js +1 -1
- package/dist/esm/utils/runtimeUtils.js +3 -3
- package/dist/index.umd.js +25 -25
- 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 +201 -195
- 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 +17 -17
- package/dist/types/plugins/ES6ModulePlugin.d.ts +27 -27
- package/dist/types/plugins/LifecycleEventPlugin.d.ts +15 -15
- package/dist/types/plugins/StylePlugin.d.ts +13 -13
- 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 +2 -2
|
@@ -340,23 +340,23 @@ function _ts_generator(thisArg, body) {
|
|
|
340
340
|
};
|
|
341
341
|
}
|
|
342
342
|
}
|
|
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 !==
|
|
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, isBuiltInControls } 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
|
+
import { buildUUID } from "../utils/runtimeUtils";
|
|
352
|
+
if (typeof window !== "undefined") {
|
|
353
353
|
// @ts-ignore
|
|
354
354
|
window.engines = {};
|
|
355
355
|
}
|
|
356
356
|
// setState的时候,存储options中转变量
|
|
357
357
|
var eventOptionsTemp = null;
|
|
358
358
|
// 当前正在注册的插件名称
|
|
359
|
-
var applyingPluginName =
|
|
359
|
+
var applyingPluginName = "";
|
|
360
360
|
// 整体渲染引擎 并且 提供发布订阅能力
|
|
361
361
|
var Engine = /*#__PURE__*/ function(Watcher) {
|
|
362
362
|
"use strict";
|
|
@@ -376,6 +376,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
376
376
|
_define_property(_assert_this_initialized(_this), "isMounted", false);
|
|
377
377
|
_define_property(_assert_this_initialized(_this), "id", genNonDuplicateId(8));
|
|
378
378
|
_define_property(_assert_this_initialized(_this), "externalParams", void 0);
|
|
379
|
+
_define_property(_assert_this_initialized(_this), "children", void 0);
|
|
379
380
|
// 提供外部注册插件,在不同的hooks触发时执行固定函数的能力
|
|
380
381
|
_define_property(_assert_this_initialized(_this), "__plugins", void 0);
|
|
381
382
|
_define_property(_assert_this_initialized(_this), "__pluginsApplied", false);
|
|
@@ -386,7 +387,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
386
387
|
_define_property(_assert_this_initialized(_this), "createControlInstance", _this.createInstance);
|
|
387
388
|
_this.$options = Object.freeze(props);
|
|
388
389
|
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
|
-
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, messagesI18n = _this_$options.messagesI18n;
|
|
390
|
+
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, messagesI18n = _this_$options.messagesI18n, children = _this_$options.children;
|
|
390
391
|
RulesMessage.setLocale(language, messagesI18n);
|
|
391
392
|
_this.debug = debug;
|
|
392
393
|
_this.runtime = new Runtime({
|
|
@@ -394,10 +395,11 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
394
395
|
beforeCreateInstance: beforeCreateInstance
|
|
395
396
|
});
|
|
396
397
|
_this.externalParams = externalParams;
|
|
398
|
+
_this.children = children;
|
|
397
399
|
_this.store = new Store({
|
|
398
400
|
instance: _this.runtime.instance
|
|
399
401
|
});
|
|
400
|
-
_this.debugLog(
|
|
402
|
+
_this.debugLog("engine is Instantiation complete");
|
|
401
403
|
// 自动执行挂载完成,也可以手动调用mount方法
|
|
402
404
|
autoMount && _this.mount();
|
|
403
405
|
return _this;
|
|
@@ -444,7 +446,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
444
446
|
// 触发所有控件的默认值的change事件
|
|
445
447
|
this.setStates(this.getState());
|
|
446
448
|
this.debugLog("engine的mount方法调用结束");
|
|
447
|
-
if (this.debug && typeof window !==
|
|
449
|
+
if (this.debug && typeof window !== "undefined") {
|
|
448
450
|
// @ts-ignore
|
|
449
451
|
window.engines[this.id] = this;
|
|
450
452
|
}
|
|
@@ -453,7 +455,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
453
455
|
{
|
|
454
456
|
key: "destroy",
|
|
455
457
|
value: function destroy() {
|
|
456
|
-
if (this.debug && typeof window !==
|
|
458
|
+
if (this.debug && typeof window !== "undefined") {
|
|
457
459
|
// @ts-ignore
|
|
458
460
|
delete window.engines[this.id];
|
|
459
461
|
}
|
|
@@ -494,7 +496,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
494
496
|
checkerSubtableValue(fieldTypeMap, row, emptyState));
|
|
495
497
|
});
|
|
496
498
|
}
|
|
497
|
-
var keys = key.split(
|
|
499
|
+
var keys = key.split(".");
|
|
498
500
|
var lastKey = keys[keys.length - 1];
|
|
499
501
|
try {
|
|
500
502
|
return checkerValue(instance.fieldType, lastKey, newValue, oldValue);
|
|
@@ -527,7 +529,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
527
529
|
var newRows = [];
|
|
528
530
|
for(var i = 0; i < len; i++){
|
|
529
531
|
// @ts-ignore
|
|
530
|
-
var row = _this.listControlCreateRow(subtable,
|
|
532
|
+
var row = _this.listControlCreateRow(subtable, "subtable-row");
|
|
531
533
|
row && newRows.push(row);
|
|
532
534
|
}
|
|
533
535
|
// @ts-ignore
|
|
@@ -542,15 +544,15 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
542
544
|
if (type && args) {
|
|
543
545
|
// const subtableOldLength = subtable.children.length
|
|
544
546
|
switch(type){
|
|
545
|
-
case
|
|
546
|
-
case
|
|
547
|
+
case "push":
|
|
548
|
+
case "unshift":
|
|
547
549
|
var _subtable_children;
|
|
548
550
|
var newRowLengths = args.length;
|
|
549
551
|
createdNewRows = createRows(newRowLengths);
|
|
550
552
|
createdNewRowsData = args;
|
|
551
553
|
(_subtable_children = subtable.children)[type].apply(_subtable_children, _to_consumable_array(createdNewRows));
|
|
552
554
|
break;
|
|
553
|
-
case
|
|
555
|
+
case "splice":
|
|
554
556
|
if (args.length > 2) {
|
|
555
557
|
var // @ts-ignore
|
|
556
558
|
_subtable_children1;
|
|
@@ -589,11 +591,11 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
589
591
|
(_subtable_children3 = subtable.children)[type].apply(_subtable_children3, _to_consumable_array(args));
|
|
590
592
|
break;
|
|
591
593
|
}
|
|
592
|
-
if (type ===
|
|
594
|
+
if (type === "splice") {
|
|
593
595
|
deleted = result;
|
|
594
596
|
} else if ([
|
|
595
|
-
|
|
596
|
-
|
|
597
|
+
"pop",
|
|
598
|
+
"shift"
|
|
597
599
|
].includes(type)) {
|
|
598
600
|
deleted = [
|
|
599
601
|
result
|
|
@@ -602,7 +604,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
602
604
|
var subtableData = this.getState(subtable.id);
|
|
603
605
|
this._handlerSubtableUpdateUid(subtableData);
|
|
604
606
|
this.runtime.getFlatInstances();
|
|
605
|
-
this.emit(
|
|
607
|
+
this.emit("list-change", {
|
|
606
608
|
instance: subtable,
|
|
607
609
|
value: subtableData,
|
|
608
610
|
options: Object.assign({}, options, {
|
|
@@ -626,7 +628,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
626
628
|
subtableData.forEach(function(item) {
|
|
627
629
|
if (!item.uid) {
|
|
628
630
|
Object.assign(item, {
|
|
629
|
-
uid:
|
|
631
|
+
uid: "new:" + buildUUID("uid")
|
|
630
632
|
});
|
|
631
633
|
}
|
|
632
634
|
});
|
|
@@ -651,7 +653,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
651
653
|
var newRows = [];
|
|
652
654
|
for(var i = 0; i < newValue.length; i++){
|
|
653
655
|
// @ts-ignore
|
|
654
|
-
var row = this.listControlCreateRow(instance,
|
|
656
|
+
var row = this.listControlCreateRow(instance, "subtable-row");
|
|
655
657
|
row && newRows.push(row);
|
|
656
658
|
}
|
|
657
659
|
(_instance_children = instance.children).push.apply(_instance_children, _to_consumable_array(newRows));
|
|
@@ -666,7 +668,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
666
668
|
this.runtime.getFlatInstances();
|
|
667
669
|
}
|
|
668
670
|
this._handlerSubtableUpdateUid(newValue);
|
|
669
|
-
this.emit(
|
|
671
|
+
this.emit("list-change", {
|
|
670
672
|
instance: instance,
|
|
671
673
|
value: value,
|
|
672
674
|
options: _object_spread_props(_object_spread({}, options), {
|
|
@@ -675,12 +677,12 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
675
677
|
data: newValue,
|
|
676
678
|
deleted: deleted,
|
|
677
679
|
// deleted: oldValue ?? [],
|
|
678
|
-
type:
|
|
680
|
+
type: "push",
|
|
679
681
|
jsonValue: JSON.stringify(newValue)
|
|
680
682
|
})
|
|
681
683
|
});
|
|
682
684
|
} else {
|
|
683
|
-
this.emit(
|
|
685
|
+
this.emit("change", {
|
|
684
686
|
instance: instance,
|
|
685
687
|
value: this.getState(instance.id, index),
|
|
686
688
|
rowIndex: index,
|
|
@@ -704,7 +706,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
704
706
|
} catch (e) {
|
|
705
707
|
error("".concat(applyingPluginName, " Plugin apply Error \n ").concat(e));
|
|
706
708
|
} finally{
|
|
707
|
-
applyingPluginName =
|
|
709
|
+
applyingPluginName = "";
|
|
708
710
|
}
|
|
709
711
|
});
|
|
710
712
|
this.__pluginsApplied = true;
|
|
@@ -714,20 +716,20 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
714
716
|
key: "listControlCreateRow",
|
|
715
717
|
value: function listControlCreateRow(instance, rowType) {
|
|
716
718
|
var row;
|
|
717
|
-
if (rowType ===
|
|
719
|
+
if (rowType === "subtable-row") {
|
|
718
720
|
row = {
|
|
719
721
|
children: [],
|
|
720
722
|
controlType: CONTROL_BASE_TYPE.LAYOUT,
|
|
721
723
|
id: genNonDuplicateId(),
|
|
722
|
-
type:
|
|
724
|
+
type: "subtable-row",
|
|
723
725
|
props: {
|
|
724
|
-
caption:
|
|
726
|
+
caption: "",
|
|
725
727
|
isHide: false,
|
|
726
728
|
style: {
|
|
727
|
-
height:
|
|
728
|
-
heightConfig:
|
|
729
|
-
width:
|
|
730
|
-
widthConfig:
|
|
729
|
+
height: "",
|
|
730
|
+
heightConfig: "fill",
|
|
731
|
+
width: "",
|
|
732
|
+
widthConfig: "fill"
|
|
731
733
|
}
|
|
732
734
|
},
|
|
733
735
|
fieldType: undefined,
|
|
@@ -781,7 +783,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
781
783
|
key: "listControlAddRow",
|
|
782
784
|
value: function listControlAddRow(instance) {
|
|
783
785
|
var // @ts-ignore
|
|
784
|
-
rowType = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] :
|
|
786
|
+
rowType = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "subtable-row";
|
|
785
787
|
var row = this.listControlCreateRow(instance, rowType);
|
|
786
788
|
if (!row) return;
|
|
787
789
|
instance.children.push(row);
|
|
@@ -800,12 +802,12 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
800
802
|
return _ts_generator(this, function(_state) {
|
|
801
803
|
switch(_state.label){
|
|
802
804
|
case 0:
|
|
803
|
-
if (!(eventKey ===
|
|
805
|
+
if (!(eventKey === "engine-mounted")) return [
|
|
804
806
|
3,
|
|
805
807
|
3
|
|
806
808
|
];
|
|
807
809
|
if (_this1.isMounted) {
|
|
808
|
-
warn(
|
|
810
|
+
warn("The engine-mounted life cycle can only be triggered once");
|
|
809
811
|
return [
|
|
810
812
|
2,
|
|
811
813
|
Promise.resolve([])
|
|
@@ -815,7 +817,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
815
817
|
3,
|
|
816
818
|
2
|
|
817
819
|
];
|
|
818
|
-
console.time(
|
|
820
|
+
console.time("engine-mounted need wait");
|
|
819
821
|
needWait = _to_consumable_array(_this1._jobTasks);
|
|
820
822
|
return [
|
|
821
823
|
4,
|
|
@@ -823,7 +825,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
823
825
|
];
|
|
824
826
|
case 1:
|
|
825
827
|
_state.sent();
|
|
826
|
-
console.timeEnd(
|
|
828
|
+
console.timeEnd("engine-mounted need wait");
|
|
827
829
|
_state.label = 2;
|
|
828
830
|
case 2:
|
|
829
831
|
_this1.isMounted = true;
|
|
@@ -976,9 +978,9 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
976
978
|
}
|
|
977
979
|
},
|
|
978
980
|
{
|
|
979
|
-
/**
|
|
980
|
-
* 设置payload的options,提供在不是使用标准api修改state的时候可以传递options,会在本次任务执行完成之后清空
|
|
981
|
-
* @param options 需要携带的options
|
|
981
|
+
/**
|
|
982
|
+
* 设置payload的options,提供在不是使用标准api修改state的时候可以传递options,会在本次任务执行完成之后清空
|
|
983
|
+
* @param options 需要携带的options
|
|
982
984
|
* */ key: "setPayloadOptions",
|
|
983
985
|
value: function setPayloadOptions(options) {
|
|
984
986
|
eventOptionsTemp = options;
|
|
@@ -988,16 +990,16 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
988
990
|
key: "setState",
|
|
989
991
|
value: function setState(controlId, value, rowIndex, options) {
|
|
990
992
|
eventOptionsTemp = options;
|
|
991
|
-
this.debugLog(
|
|
993
|
+
this.debugLog("[%o]: 触发setState, 修改的值为%o, rowIndex=%o, options=%o", controlId, value, rowIndex, options);
|
|
992
994
|
this.store.setState(controlId, value, rowIndex);
|
|
993
|
-
this.debugLog(
|
|
995
|
+
this.debugLog("[%o]: setState完成, 修改的值为%o, rowIndex=%o", controlId, value, rowIndex);
|
|
994
996
|
eventOptionsTemp = null;
|
|
995
997
|
}
|
|
996
998
|
},
|
|
997
999
|
{
|
|
998
|
-
/**
|
|
999
|
-
* 向Store设置一组值,明细表必须全量赋值,并触发事件(触发事件是根据组件在页面中的顺序逐个触发)
|
|
1000
|
-
* @param states
|
|
1000
|
+
/**
|
|
1001
|
+
* 向Store设置一组值,明细表必须全量赋值,并触发事件(触发事件是根据组件在页面中的顺序逐个触发)
|
|
1002
|
+
* @param states
|
|
1001
1003
|
*/ key: "setStates",
|
|
1002
1004
|
value: function setStates(states, rowIndex, options) {
|
|
1003
1005
|
var _this = this;
|
|
@@ -1024,11 +1026,11 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1024
1026
|
}
|
|
1025
1027
|
},
|
|
1026
1028
|
{
|
|
1027
|
-
/**
|
|
1028
|
-
* 通过dataCode和fieldCode来获取控件的值
|
|
1029
|
-
* @param dataCode 模型编码 - 如果是主表的话就是主表的模型编码,明细子表的话就是子表的模型编码
|
|
1030
|
-
* @param fieldCode 字段编码 - 控件绑定的数据项的编码
|
|
1031
|
-
* @param rowIndex 行下标 - 如果是明细子表中的控件需要提供
|
|
1029
|
+
/**
|
|
1030
|
+
* 通过dataCode和fieldCode来获取控件的值
|
|
1031
|
+
* @param dataCode 模型编码 - 如果是主表的话就是主表的模型编码,明细子表的话就是子表的模型编码
|
|
1032
|
+
* @param fieldCode 字段编码 - 控件绑定的数据项的编码
|
|
1033
|
+
* @param rowIndex 行下标 - 如果是明细子表中的控件需要提供
|
|
1032
1034
|
* */ key: "getField",
|
|
1033
1035
|
value: function getField(dataCode, fieldCode, rowIndex) {
|
|
1034
1036
|
if (!fieldCode) {
|
|
@@ -1077,7 +1079,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1077
1079
|
var _controlIdMapping_controlId_children_key_dataBind, _controlIdMapping_controlId_children_key, _controlIdMapping_controlId;
|
|
1078
1080
|
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;
|
|
1079
1081
|
//未绑定字段的控件,直接抛弃
|
|
1080
|
-
if (fieldCode !==
|
|
1082
|
+
if (fieldCode !== "") {
|
|
1081
1083
|
var _controlIdMapping_controlId1;
|
|
1082
1084
|
if (fieldCode) {
|
|
1083
1085
|
obj[fieldCode] = item[key];
|
|
@@ -1108,7 +1110,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1108
1110
|
var _controlIdMapping_key_children_keyChi;
|
|
1109
1111
|
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;
|
|
1110
1112
|
//未绑定字段的控件,直接抛弃
|
|
1111
|
-
if (fieldCode !==
|
|
1113
|
+
if (fieldCode !== "") {
|
|
1112
1114
|
if (fieldCode) {
|
|
1113
1115
|
objChi[fieldCode] = item[keyChi];
|
|
1114
1116
|
} else {
|
|
@@ -1139,13 +1141,13 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1139
1141
|
}
|
|
1140
1142
|
},
|
|
1141
1143
|
{
|
|
1142
|
-
/**
|
|
1143
|
-
* 通过dataCode和fieldCode来设置控件的值
|
|
1144
|
-
* @param dataCode 模型编码 - 如果是主表的话就是主表的模型编码,明细子表的话就是子表的模型编码
|
|
1145
|
-
* @param fieldCode 字段编码 - 控件绑定的数据项的编码
|
|
1146
|
-
* @param value 修改的值
|
|
1147
|
-
* @param rowIndex 行下标 - 如果是明细子表中的控件需要提供
|
|
1148
|
-
* @param options 触发事件携带的参数
|
|
1144
|
+
/**
|
|
1145
|
+
* 通过dataCode和fieldCode来设置控件的值
|
|
1146
|
+
* @param dataCode 模型编码 - 如果是主表的话就是主表的模型编码,明细子表的话就是子表的模型编码
|
|
1147
|
+
* @param fieldCode 字段编码 - 控件绑定的数据项的编码
|
|
1148
|
+
* @param value 修改的值
|
|
1149
|
+
* @param rowIndex 行下标 - 如果是明细子表中的控件需要提供
|
|
1150
|
+
* @param options 触发事件携带的参数
|
|
1149
1151
|
* */ key: "setField",
|
|
1150
1152
|
value: function setField(dataCode, fieldCode, value, rowIndex, options) {
|
|
1151
1153
|
var dataBindMapping = this.getDataBindMapping(dataCode, fieldCode);
|
|
@@ -1173,12 +1175,12 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1173
1175
|
}
|
|
1174
1176
|
},
|
|
1175
1177
|
{
|
|
1176
|
-
/**
|
|
1177
|
-
* 通过dataCode和 state来给一组控件赋值,并触发事件携带options
|
|
1178
|
-
* @param dataCode 需要赋值的目标模型
|
|
1179
|
-
* @param state 赋值对象,以fieldCode为key组成的对象
|
|
1180
|
-
* @param rowIndex 行下标,给明细子表赋值时指定赋值某行
|
|
1181
|
-
* @param options 触发事件携带的参数
|
|
1178
|
+
/**
|
|
1179
|
+
* 通过dataCode和 state来给一组控件赋值,并触发事件携带options
|
|
1180
|
+
* @param dataCode 需要赋值的目标模型
|
|
1181
|
+
* @param state 赋值对象,以fieldCode为key组成的对象
|
|
1182
|
+
* @param rowIndex 行下标,给明细子表赋值时指定赋值某行
|
|
1183
|
+
* @param options 触发事件携带的参数
|
|
1182
1184
|
* */ key: "setFields",
|
|
1183
1185
|
value: function setFields(dataCode, state, rowIndex, options) {
|
|
1184
1186
|
var _this = this;
|
|
@@ -1219,10 +1221,10 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1219
1221
|
}
|
|
1220
1222
|
},
|
|
1221
1223
|
{
|
|
1222
|
-
/**
|
|
1223
|
-
* 通过dataCode来将state转化为标准的state结构
|
|
1224
|
-
* @param dataCode 需要转换的目标模型code
|
|
1225
|
-
* @param state 值对象,以fieldCode为key组成的对象
|
|
1224
|
+
/**
|
|
1225
|
+
* 通过dataCode来将state转化为标准的state结构
|
|
1226
|
+
* @param dataCode 需要转换的目标模型code
|
|
1227
|
+
* @param state 值对象,以fieldCode为key组成的对象
|
|
1226
1228
|
* */ key: "buildFields",
|
|
1227
1229
|
value: function buildFields(dataCode, state) {
|
|
1228
1230
|
var _this = this;
|
|
@@ -1263,10 +1265,10 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1263
1265
|
}
|
|
1264
1266
|
},
|
|
1265
1267
|
{
|
|
1266
|
-
/**
|
|
1267
|
-
* 向Store设置一组值,并触发事件携带options
|
|
1268
|
-
* @param dataSet
|
|
1269
|
-
* @options 传递给关联事件中 EventPayload中的options,一般在plugin中监听使用
|
|
1268
|
+
/**
|
|
1269
|
+
* 向Store设置一组值,并触发事件携带options
|
|
1270
|
+
* @param dataSet
|
|
1271
|
+
* @options 传递给关联事件中 EventPayload中的options,一般在plugin中监听使用
|
|
1270
1272
|
*/ key: "setData",
|
|
1271
1273
|
value: function setData(dataSet, options) {
|
|
1272
1274
|
var _this = this;
|
|
@@ -1329,9 +1331,9 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1329
1331
|
});
|
|
1330
1332
|
newRow[fieldMapping.controlId] = objValue;
|
|
1331
1333
|
}
|
|
1332
|
-
} else if (fieldCode ===
|
|
1334
|
+
} else if (fieldCode === "uid" && row.uid !== undefined) {
|
|
1333
1335
|
newRow.uid = row.uid;
|
|
1334
|
-
} else if (fieldCode ===
|
|
1336
|
+
} else if (fieldCode === "virtualStore" && row.virtualStore !== undefined) {
|
|
1335
1337
|
newRow.virtualStore = Object.freeze(row.virtualStore);
|
|
1336
1338
|
}
|
|
1337
1339
|
});
|
|
@@ -1383,7 +1385,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1383
1385
|
var _newState_newMapping_controlId;
|
|
1384
1386
|
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 : {});
|
|
1385
1387
|
mappingKeys === null || mappingKeys === void 0 ? void 0 : mappingKeys.forEach(function(key) {
|
|
1386
|
-
if (!mainStateKeys.includes(key) && key !==
|
|
1388
|
+
if (!mainStateKeys.includes(key) && key !== "uid" && newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId]) {
|
|
1387
1389
|
if (Object.keys(newState).length) {
|
|
1388
1390
|
Object.assign(newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId], _define_property({}, key, mappingValue[key]));
|
|
1389
1391
|
} else {
|
|
@@ -1404,19 +1406,19 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1404
1406
|
}
|
|
1405
1407
|
},
|
|
1406
1408
|
{
|
|
1407
|
-
/**
|
|
1408
|
-
* 获取控件的dataBind
|
|
1409
|
-
* @param controlId
|
|
1409
|
+
/**
|
|
1410
|
+
* 获取控件的dataBind
|
|
1411
|
+
* @param controlId
|
|
1410
1412
|
* */ key: "getDataBind",
|
|
1411
1413
|
value: function getDataBind(controlId) {
|
|
1412
1414
|
return this.store.getDataBind(controlId);
|
|
1413
1415
|
}
|
|
1414
1416
|
},
|
|
1415
1417
|
{
|
|
1416
|
-
/**
|
|
1417
|
-
* 获取组件实例,传入rowIndex代表获取明细表内的控件实例,rowIndex传入-1代表获取表头内的实例
|
|
1418
|
-
* @param controlId
|
|
1419
|
-
* @param rowIndex
|
|
1418
|
+
/**
|
|
1419
|
+
* 获取组件实例,传入rowIndex代表获取明细表内的控件实例,rowIndex传入-1代表获取表头内的实例
|
|
1420
|
+
* @param controlId
|
|
1421
|
+
* @param rowIndex
|
|
1420
1422
|
*/ key: "getInstance",
|
|
1421
1423
|
value: function getInstance(controlId, rowIndex) {
|
|
1422
1424
|
var instances = this.getInstances(controlId, rowIndex === -1);
|
|
@@ -1435,10 +1437,10 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1435
1437
|
}
|
|
1436
1438
|
},
|
|
1437
1439
|
{
|
|
1438
|
-
/**
|
|
1439
|
-
* 获取组件实例,明细表中的组件将会得到数组, 第二个参数为(false/不传入)则获取到的是明细表内不包含表头内实例的所有控件实例,传入true则获取到包含表头内实例的所有控件实例,表头内实例永远在下标0的位置
|
|
1440
|
-
* @param controlId
|
|
1441
|
-
* @param header 明细表内是否获取表头的控件
|
|
1440
|
+
/**
|
|
1441
|
+
* 获取组件实例,明细表中的组件将会得到数组, 第二个参数为(false/不传入)则获取到的是明细表内不包含表头内实例的所有控件实例,传入true则获取到包含表头内实例的所有控件实例,表头内实例永远在下标0的位置
|
|
1442
|
+
* @param controlId
|
|
1443
|
+
* @param header 明细表内是否获取表头的控件
|
|
1442
1444
|
*/ // getInstances(
|
|
1443
1445
|
// controlId?: string,
|
|
1444
1446
|
// header: boolean = false
|
|
@@ -1525,14 +1527,14 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1525
1527
|
value: function setInstance(instance, props, value, rowIndex) {
|
|
1526
1528
|
var _this = this;
|
|
1527
1529
|
try {
|
|
1528
|
-
if (typeof instance ===
|
|
1530
|
+
if (typeof instance === "string" && rowIndex === -1) {
|
|
1529
1531
|
//修改明细表整列属性的逻辑
|
|
1530
1532
|
var instances = this.getInstances(instance, rowIndex === -1);
|
|
1531
1533
|
instances.map(function(_instance) {
|
|
1532
1534
|
if (_instance) {
|
|
1533
1535
|
_this.debugLog("[%o]: 修改instance: %o的%o属性,修改的值为%o。", _instance.id, _instance, props, value);
|
|
1534
1536
|
updateValueFromKeys(_instance.props, props, value);
|
|
1535
|
-
_this.schemaEvent(
|
|
1537
|
+
_this.schemaEvent("schema-change", {
|
|
1536
1538
|
instance: _instance,
|
|
1537
1539
|
props: props,
|
|
1538
1540
|
value: value,
|
|
@@ -1542,7 +1544,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1542
1544
|
});
|
|
1543
1545
|
} else {
|
|
1544
1546
|
var _instance;
|
|
1545
|
-
if (typeof instance ===
|
|
1547
|
+
if (typeof instance === "string") {
|
|
1546
1548
|
_instance = this.getInstance(instance, rowIndex);
|
|
1547
1549
|
} else {
|
|
1548
1550
|
_instance = instance;
|
|
@@ -1552,7 +1554,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1552
1554
|
}
|
|
1553
1555
|
this.debugLog("[%o]: 修改instance: %o的%o属性,修改的值为%o。", _instance.id, _instance, props, value);
|
|
1554
1556
|
updateValueFromKeys(_instance.props, props, value);
|
|
1555
|
-
this.schemaEvent(
|
|
1557
|
+
this.schemaEvent("schema-change", {
|
|
1556
1558
|
instance: _instance,
|
|
1557
1559
|
props: props,
|
|
1558
1560
|
value: value,
|
|
@@ -1614,27 +1616,27 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1614
1616
|
},
|
|
1615
1617
|
{
|
|
1616
1618
|
key: "assertInstance",
|
|
1617
|
-
value: /**
|
|
1618
|
-
* 判断控件的类型,返回当前控件的正确类型
|
|
1619
|
+
value: /**
|
|
1620
|
+
* 判断控件的类型,返回当前控件的正确类型
|
|
1619
1621
|
* */ function assertInstance(instance, types) {
|
|
1620
1622
|
return isString(types) ? instance.type === types : types.includes(instance.type);
|
|
1621
1623
|
}
|
|
1622
1624
|
},
|
|
1623
1625
|
{
|
|
1624
1626
|
key: "assertInstanceIsCustomControl",
|
|
1625
|
-
value: /**
|
|
1626
|
-
* 判断控件或控件类型是一个自定义控件
|
|
1627
|
+
value: /**
|
|
1628
|
+
* 判断控件或控件类型是一个自定义控件
|
|
1627
1629
|
* */ function assertInstanceIsCustomControl(instance) {
|
|
1628
1630
|
return !isBuiltInControls(isString(instance) ? instance : instance.type);
|
|
1629
1631
|
}
|
|
1630
1632
|
},
|
|
1631
1633
|
{
|
|
1632
1634
|
key: "getInstanceRowIndex",
|
|
1633
|
-
value: /**
|
|
1634
|
-
* 获取控件在明细子表中的行下标,
|
|
1635
|
-
* 如果控件在表头内,则返回-1
|
|
1636
|
-
* 如果控件在表内,则返回行下标
|
|
1637
|
-
* 如果控件不在明细表内,则返回undefined
|
|
1635
|
+
value: /**
|
|
1636
|
+
* 获取控件在明细子表中的行下标,
|
|
1637
|
+
* 如果控件在表头内,则返回-1
|
|
1638
|
+
* 如果控件在表内,则返回行下标
|
|
1639
|
+
* 如果控件不在明细表内,则返回undefined
|
|
1638
1640
|
* */ // public getInstanceRowIndex(
|
|
1639
1641
|
// instance: ControlRuntimeInstance<ControlsKeys> | RuntimeControl
|
|
1640
1642
|
// ) {
|
|
@@ -1679,7 +1681,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1679
1681
|
CONTROL_TYPE.SUBTABLE_COLUMN);
|
|
1680
1682
|
if (isColumnChild) {
|
|
1681
1683
|
var instanceList = this.runtime.instanceMap[instance.id];
|
|
1682
|
-
if (Object.prototype.toString.call(instanceList) ===
|
|
1684
|
+
if (Object.prototype.toString.call(instanceList) === "[object Array]") {
|
|
1683
1685
|
var index = instanceList.findIndex(function(item) {
|
|
1684
1686
|
return item === instance;
|
|
1685
1687
|
});
|
|
@@ -1785,7 +1787,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1785
1787
|
key: "register",
|
|
1786
1788
|
value: // 注册外部控件
|
|
1787
1789
|
function register(control) {
|
|
1788
|
-
return Runtime.register(control,
|
|
1790
|
+
return Runtime.register(control, "Runtime");
|
|
1789
1791
|
}
|
|
1790
1792
|
},
|
|
1791
1793
|
{
|
|
@@ -30,7 +30,7 @@ function _define_property(obj, key, value) {
|
|
|
30
30
|
}
|
|
31
31
|
return obj;
|
|
32
32
|
}
|
|
33
|
-
import { log } from
|
|
33
|
+
import { log } from "@byteluck-fe/model-driven-shared";
|
|
34
34
|
var OkWorker = /*#__PURE__*/ function() {
|
|
35
35
|
"use strict";
|
|
36
36
|
function OkWorker() {
|
|
@@ -43,7 +43,7 @@ var OkWorker = /*#__PURE__*/ function() {
|
|
|
43
43
|
value: function run(initState) {
|
|
44
44
|
this.worker = OkWorker.createWorker();
|
|
45
45
|
this.postMessage({
|
|
46
|
-
action:
|
|
46
|
+
action: "init",
|
|
47
47
|
payload: initState
|
|
48
48
|
});
|
|
49
49
|
}
|
|
@@ -77,7 +77,7 @@ var OkWorker = /*#__PURE__*/ function() {
|
|
|
77
77
|
key: "createWorkerFunction",
|
|
78
78
|
value: function createWorkerFunction() {
|
|
79
79
|
return function() {
|
|
80
|
-
log(
|
|
80
|
+
log("\uD83D\uDE80 worker running");
|
|
81
81
|
var _self = self;
|
|
82
82
|
function createHandler(parentKey) {
|
|
83
83
|
return {
|
|
@@ -87,7 +87,7 @@ var OkWorker = /*#__PURE__*/ function() {
|
|
|
87
87
|
set: function set(target, key, value) {
|
|
88
88
|
if (parentKey) {
|
|
89
89
|
_self.postMessage({
|
|
90
|
-
action:
|
|
90
|
+
action: "update",
|
|
91
91
|
key: "".concat(parentKey, ".").concat(key)
|
|
92
92
|
});
|
|
93
93
|
}
|
|
@@ -106,7 +106,7 @@ var OkWorker = /*#__PURE__*/ function() {
|
|
|
106
106
|
// }
|
|
107
107
|
// return new Proxy(obj, createHandler(parentKey))
|
|
108
108
|
// }
|
|
109
|
-
_self.addEventListener(
|
|
109
|
+
_self.addEventListener("message", function(event) {
|
|
110
110
|
var _event_data = event.data, action = _event_data.action, payload = _event_data.payload, fn = _event_data.fn;
|
|
111
111
|
log(action, payload);
|
|
112
112
|
// 通过proxy进行代理,每次修改的时候,自动向外抛出postMessage
|
|
@@ -118,10 +118,10 @@ var OkWorker = /*#__PURE__*/ function() {
|
|
|
118
118
|
//
|
|
119
119
|
// const result = fn(data, schema)
|
|
120
120
|
_self.postMessage({
|
|
121
|
-
action:
|
|
121
|
+
action: "delete",
|
|
122
122
|
payload: {
|
|
123
|
-
key:
|
|
124
|
-
value:
|
|
123
|
+
key: "key3[0].key1",
|
|
124
|
+
value: "index"
|
|
125
125
|
}
|
|
126
126
|
});
|
|
127
127
|
});
|