@byteluck-fe/model-driven-engine 1.7.5 → 1.7.6
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 +2 -2
- package/dist/esm/common/Engine.js +104 -52
- package/dist/esm/common/OkWorker.js +5 -5
- package/dist/esm/common/Store.js +11 -70
- package/dist/esm/common/checkerValue.js +2 -2
- package/dist/esm/common/proxyState.js +7 -7
- package/dist/esm/plugins/CalcPlugin.js +17 -17
- package/dist/esm/plugins/ES6ModulePlugin.js +2 -2
- package/dist/esm/plugins/StylePlugin.js +3 -3
- package/dist/index.umd.js +7 -7
- package/dist/types/common/Engine.d.ts +12 -6
- package/dist/types/common/Runtime.d.ts +1 -1
- package/dist/types/common/Store.d.ts +5 -7
- 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 +2 -2
|
@@ -173,7 +173,7 @@ export var ActionManager = /*#__PURE__*/ function() {
|
|
|
173
173
|
}
|
|
174
174
|
var _this = this;
|
|
175
175
|
return _asyncToGenerator(function() {
|
|
176
|
-
var action,
|
|
176
|
+
var action, _action_func, result, e;
|
|
177
177
|
return __generator(this, function(_state) {
|
|
178
178
|
switch(_state.label){
|
|
179
179
|
case 0:
|
|
@@ -193,7 +193,7 @@ export var ActionManager = /*#__PURE__*/ function() {
|
|
|
193
193
|
]);
|
|
194
194
|
return [
|
|
195
195
|
4,
|
|
196
|
-
(
|
|
196
|
+
(_action_func = action.func).call.apply(_action_func, [
|
|
197
197
|
null,
|
|
198
198
|
context
|
|
199
199
|
].concat(_toConsumableArray(args)))
|
|
@@ -367,8 +367,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
367
367
|
_this._jobTasks = [];
|
|
368
368
|
_this.createControlInstance = _this.createInstance;
|
|
369
369
|
_this.$options = Object.freeze(props);
|
|
370
|
-
var
|
|
371
|
-
language, language =
|
|
370
|
+
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,
|
|
371
|
+
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;
|
|
372
372
|
RulesMessage.setLocale(language);
|
|
373
373
|
_this.debug = debug;
|
|
374
374
|
_this.runtime = new Runtime({
|
|
@@ -402,13 +402,13 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
402
402
|
for(var _len = arguments.length, arg = new Array(_len), _key = 0; _key < _len; _key++){
|
|
403
403
|
arg[_key] = arguments[_key];
|
|
404
404
|
}
|
|
405
|
-
var
|
|
406
|
-
(
|
|
405
|
+
var _this_runtime;
|
|
406
|
+
(_this_runtime = this.runtime).register.apply(_this_runtime, _toConsumableArray(arg));
|
|
407
407
|
return this;
|
|
408
408
|
};
|
|
409
409
|
_proto.mount = function mount() {
|
|
410
410
|
this.debugLog("engine的mount方法开始调用");
|
|
411
|
-
var
|
|
411
|
+
var _this_$options = this.$options, _this_$options_plugins = _this_$options.plugins, plugins = _this_$options_plugins === void 0 ? [] : _this_$options_plugins;
|
|
412
412
|
this._handlerProxyState();
|
|
413
413
|
this.__plugins = plugins;
|
|
414
414
|
this.applyPlugins();
|
|
@@ -496,17 +496,17 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
496
496
|
switch(type){
|
|
497
497
|
case "push":
|
|
498
498
|
case "unshift":
|
|
499
|
-
var
|
|
499
|
+
var _subtable_children;
|
|
500
500
|
var newRowLengths = args.length;
|
|
501
501
|
createdNewRows = createRows(newRowLengths);
|
|
502
502
|
createdNewRowsData = args;
|
|
503
|
-
(
|
|
503
|
+
(_subtable_children = subtable.children)[type].apply(_subtable_children, _toConsumableArray(createdNewRows));
|
|
504
504
|
this.runtime.getFlatInstances();
|
|
505
505
|
break;
|
|
506
506
|
case "splice":
|
|
507
507
|
if (args.length > 2) {
|
|
508
508
|
var // @ts-ignore
|
|
509
|
-
|
|
509
|
+
_subtable_children1;
|
|
510
510
|
var newRowLengths1 = args.length - 2;
|
|
511
511
|
var newValues = args.slice(2);
|
|
512
512
|
createdNewRows = createRows(newRowLengths1);
|
|
@@ -515,7 +515,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
515
515
|
var start = args[0];
|
|
516
516
|
// 替换几个
|
|
517
517
|
var replace = args[1];
|
|
518
|
-
(
|
|
518
|
+
(_subtable_children1 = subtable.children)[type].apply(_subtable_children1, [
|
|
519
519
|
start,
|
|
520
520
|
replace
|
|
521
521
|
].concat(_toConsumableArray(createdNewRows)));
|
|
@@ -526,15 +526,15 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
526
526
|
// })
|
|
527
527
|
} else {
|
|
528
528
|
var // @ts-ignore
|
|
529
|
-
|
|
530
|
-
(
|
|
529
|
+
_subtable_children2;
|
|
530
|
+
(_subtable_children2 = subtable.children)[type].apply(_subtable_children2, _toConsumableArray(args));
|
|
531
531
|
this.runtime.getFlatInstances();
|
|
532
532
|
}
|
|
533
533
|
break;
|
|
534
534
|
default:
|
|
535
535
|
var // @ts-ignore
|
|
536
|
-
|
|
537
|
-
(
|
|
536
|
+
_subtable_children3;
|
|
537
|
+
(_subtable_children3 = subtable.children)[type].apply(_subtable_children3, _toConsumableArray(args));
|
|
538
538
|
this.runtime.getFlatInstances();
|
|
539
539
|
break;
|
|
540
540
|
}
|
|
@@ -570,7 +570,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
570
570
|
var options = eventOptionsTemp || {};
|
|
571
571
|
if (_instanceof(instance, RuntimeListControl)) {
|
|
572
572
|
var // @ts-ignore
|
|
573
|
-
|
|
573
|
+
_instance_children;
|
|
574
574
|
instance.children.length = 0;
|
|
575
575
|
var newValue = value;
|
|
576
576
|
// @ts-ignore
|
|
@@ -580,7 +580,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
580
580
|
var row = this.listControlCreateRow(instance, "subtable-row");
|
|
581
581
|
row && newRows.push(row);
|
|
582
582
|
}
|
|
583
|
-
(
|
|
583
|
+
(_instance_children = instance.children).push.apply(_instance_children, _toConsumableArray(newRows));
|
|
584
584
|
this.runtime.getFlatInstances();
|
|
585
585
|
// 这里已经能拿到控件实例,所以在这里触发setStates,触发每一行每一个控件的change事件
|
|
586
586
|
// for (let i = 0; i < newValue.length; i++) {
|
|
@@ -612,8 +612,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
612
612
|
if (this.__pluginsApplied) return;
|
|
613
613
|
this.__plugins.forEach(function(plugin) {
|
|
614
614
|
try {
|
|
615
|
-
var
|
|
616
|
-
applyingPluginName = (
|
|
615
|
+
var _plugin_pluginName;
|
|
616
|
+
applyingPluginName = (_plugin_pluginName = plugin.pluginName) !== null && _plugin_pluginName !== void 0 ? _plugin_pluginName : plugin.constructor.name;
|
|
617
617
|
plugin.apply(_this);
|
|
618
618
|
} catch (e) {
|
|
619
619
|
error("".concat(applyingPluginName, " Plugin apply Error \n ").concat(e));
|
|
@@ -627,11 +627,11 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
627
627
|
var row = this.runtime.createControlInstance(rowType);
|
|
628
628
|
if (!row) return;
|
|
629
629
|
if (_instanceof(row, RuntimeLayoutControl)) {
|
|
630
|
-
var
|
|
630
|
+
var _row_children;
|
|
631
631
|
var template = JSONCopy(instance.props.headers);
|
|
632
632
|
// @ts-ignore
|
|
633
633
|
var columns = this.createControl(template);
|
|
634
|
-
(
|
|
634
|
+
(_row_children = row.children).push.apply(_row_children, _toConsumableArray(columns));
|
|
635
635
|
}
|
|
636
636
|
return row;
|
|
637
637
|
};
|
|
@@ -718,8 +718,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
718
718
|
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
719
719
|
args[_key] = arguments[_key];
|
|
720
720
|
}
|
|
721
|
-
var
|
|
722
|
-
return (
|
|
721
|
+
var _this_runtime;
|
|
722
|
+
return (_this_runtime = this.runtime).createControl.apply(_this_runtime, _toConsumableArray(args));
|
|
723
723
|
};
|
|
724
724
|
_proto.createInstance = function createInstance(type, initSchema) {
|
|
725
725
|
return this.runtime.createControlInstance(type, initSchema);
|
|
@@ -734,16 +734,16 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
734
734
|
if (controlId === undefined) {
|
|
735
735
|
return this.runtime.rules;
|
|
736
736
|
} else {
|
|
737
|
-
var
|
|
738
|
-
return (
|
|
737
|
+
var _this_runtime_rules_controlId;
|
|
738
|
+
return (_this_runtime_rules_controlId = this.runtime.rules[controlId]) === null || _this_runtime_rules_controlId === void 0 ? void 0 : _this_runtime_rules_controlId.fields;
|
|
739
739
|
}
|
|
740
740
|
};
|
|
741
741
|
_proto.getAntdRules = function getAntdRules(controlId) {
|
|
742
742
|
if (controlId === undefined) {
|
|
743
743
|
return this.runtime.antdRules;
|
|
744
744
|
} else {
|
|
745
|
-
var
|
|
746
|
-
return (
|
|
745
|
+
var _this_runtime_antdRules_controlId;
|
|
746
|
+
return (_this_runtime_antdRules_controlId = this.runtime.antdRules[controlId]) === null || _this_runtime_antdRules_controlId === void 0 ? void 0 : _this_runtime_antdRules_controlId.fields;
|
|
747
747
|
}
|
|
748
748
|
};
|
|
749
749
|
_proto.getState = function getState(controlId, rowIndex) {
|
|
@@ -753,13 +753,6 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
753
753
|
return this.store.getState(controlId, rowIndex);
|
|
754
754
|
}
|
|
755
755
|
};
|
|
756
|
-
_proto.getFieldCodeState = function getFieldCodeState(controlId) {
|
|
757
|
-
if (controlId === undefined) {
|
|
758
|
-
return this.store.fieldCodeState;
|
|
759
|
-
} else {
|
|
760
|
-
return this.store.getFieldCodeState(controlId);
|
|
761
|
-
}
|
|
762
|
-
};
|
|
763
756
|
_proto.getEmptyState = function getEmptyState(controlId) {
|
|
764
757
|
if (controlId === undefined) {
|
|
765
758
|
return JSONCopy(this.store.emptyState);
|
|
@@ -840,11 +833,70 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
840
833
|
}
|
|
841
834
|
};
|
|
842
835
|
_proto.getData = function getData(dataCode) {
|
|
843
|
-
if (dataCode)
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
836
|
+
if (!dataCode) return;
|
|
837
|
+
var dataBindMapping = this.getDataBindMapping(dataCode);
|
|
838
|
+
var controlIdMapping = this.getControlIdMapping();
|
|
839
|
+
if (dataBindMapping) {
|
|
840
|
+
var controlId = dataBindMapping.controlId;
|
|
841
|
+
var getFieldData = this.getField(dataCode);
|
|
842
|
+
// 明细子表值
|
|
843
|
+
if (Array.isArray(getFieldData)) {
|
|
844
|
+
var data = getFieldData.map(function(item) {
|
|
845
|
+
var obj = {};
|
|
846
|
+
for(var key in item){
|
|
847
|
+
var _controlIdMapping_controlId_children_key, _controlIdMapping_controlId, _controlIdMapping_controlId_children_key_dataBind, _controlIdMapping_controlId1;
|
|
848
|
+
if ((_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) {
|
|
849
|
+
var _controlIdMapping_controlId_children_key1;
|
|
850
|
+
obj[(_controlIdMapping_controlId_children_key1 = controlIdMapping[controlId].children[key]) === null || _controlIdMapping_controlId_children_key1 === void 0 ? void 0 : _controlIdMapping_controlId_children_key1.dataBind.fieldCode] = item[key];
|
|
851
|
+
} else if ((_controlIdMapping_controlId1 = controlIdMapping[controlId]) === null || _controlIdMapping_controlId1 === void 0 ? void 0 : _controlIdMapping_controlId1.children[key]) {
|
|
852
|
+
// 兼容一个控件需要绑定多个字段的情况
|
|
853
|
+
for(var keyChi in item[key]){
|
|
854
|
+
var _controlIdMapping_controlId_children_key2, _controlIdMapping_controlId2;
|
|
855
|
+
obj[(_controlIdMapping_controlId_children_key2 = (_controlIdMapping_controlId2 = controlIdMapping[controlId]) === null || _controlIdMapping_controlId2 === void 0 ? void 0 : _controlIdMapping_controlId2.children[key]) === null || _controlIdMapping_controlId_children_key2 === void 0 ? void 0 : _controlIdMapping_controlId_children_key2.dataBind[keyChi].fieldCode] = item[key][keyChi];
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
}
|
|
859
|
+
return obj;
|
|
860
|
+
});
|
|
861
|
+
return data;
|
|
862
|
+
} else {
|
|
863
|
+
var _loop = function(key) {
|
|
864
|
+
var _controlIdMapping_key, _controlIdMapping_key_dataBind, _controlIdMapping_key1, _controlIdMapping_key_dataBind1;
|
|
865
|
+
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) {
|
|
866
|
+
var _controlIdMapping_key2;
|
|
867
|
+
obj[(_controlIdMapping_key2 = controlIdMapping[key]) === null || _controlIdMapping_key2 === void 0 ? void 0 : _controlIdMapping_key2.dataBind.fieldCode] = getFieldData[key];
|
|
868
|
+
} 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) {
|
|
869
|
+
var _controlIdMapping_key3;
|
|
870
|
+
// 明细字表只循环一层明细子表未递归
|
|
871
|
+
obj[(_controlIdMapping_key3 = controlIdMapping[key]) === null || _controlIdMapping_key3 === void 0 ? void 0 : _controlIdMapping_key3.dataBind.dataCode] = getFieldData[key].map(function(item) {
|
|
872
|
+
var objChi = {};
|
|
873
|
+
for(var keyChi in item){
|
|
874
|
+
var _controlIdMapping_key_children_keyChi;
|
|
875
|
+
if ((_controlIdMapping_key_children_keyChi = controlIdMapping[key].children[keyChi]) === null || _controlIdMapping_key_children_keyChi === void 0 ? void 0 : _controlIdMapping_key_children_keyChi.dataBind.fieldCode) {
|
|
876
|
+
var _controlIdMapping_key_children_keyChi1;
|
|
877
|
+
objChi[(_controlIdMapping_key_children_keyChi1 = controlIdMapping[key].children[keyChi]) === null || _controlIdMapping_key_children_keyChi1 === void 0 ? void 0 : _controlIdMapping_key_children_keyChi1.dataBind.fieldCode] = item[keyChi];
|
|
878
|
+
} else {
|
|
879
|
+
for(var keyChi1 in item[keyChi]){
|
|
880
|
+
var _controlIdMapping_key_children_keyChi2;
|
|
881
|
+
objChi[(_controlIdMapping_key_children_keyChi2 = controlIdMapping[key].children[keyChi]) === null || _controlIdMapping_key_children_keyChi2 === void 0 ? void 0 : _controlIdMapping_key_children_keyChi2.dataBind[keyChi1].fieldCode] = item[keyChi][keyChi1];
|
|
882
|
+
//
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
return objChi;
|
|
887
|
+
});
|
|
888
|
+
} else if (controlIdMapping[key]) {
|
|
889
|
+
// 兼容一个控件需要绑定多个字段的情况
|
|
890
|
+
for(var keyChi in getFieldData[key]){
|
|
891
|
+
var _controlIdMapping_key_dataBind_keyChi, _controlIdMapping_key4;
|
|
892
|
+
obj[(_controlIdMapping_key_dataBind_keyChi = (_controlIdMapping_key4 = controlIdMapping[key]) === null || _controlIdMapping_key4 === void 0 ? void 0 : _controlIdMapping_key4.dataBind[keyChi]) === null || _controlIdMapping_key_dataBind_keyChi === void 0 ? void 0 : _controlIdMapping_key_dataBind_keyChi.fieldCode] = getFieldData[key][keyChi];
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
};
|
|
896
|
+
// 主表
|
|
897
|
+
var obj = {};
|
|
898
|
+
for(var key in getFieldData)_loop(key);
|
|
899
|
+
return obj;
|
|
848
900
|
}
|
|
849
901
|
}
|
|
850
902
|
return;
|
|
@@ -863,8 +915,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
863
915
|
}
|
|
864
916
|
var dataBind = dataBindMapping.dataBind, controlId = dataBindMapping.controlId;
|
|
865
917
|
if (_instanceof(dataBind, ObjectDataBind)) {
|
|
866
|
-
var
|
|
867
|
-
var oldState = (
|
|
918
|
+
var _JSONCopy;
|
|
919
|
+
var oldState = (_JSONCopy = JSONCopy(this.getState(controlId, rowIndex))) !== null && _JSONCopy !== void 0 ? _JSONCopy : this.getEmptyState(controlId);
|
|
868
920
|
// fieldCode不代表是key,所以需要找到对应的key
|
|
869
921
|
var newState = Object.entries(dataBind).reduce(function(result, param) {
|
|
870
922
|
var _param = _slicedToArray(param, 2), key = _param[0], dataBind = _param[1];
|
|
@@ -902,8 +954,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
902
954
|
}
|
|
903
955
|
// 对象类型的值
|
|
904
956
|
if (_instanceof(dataBind, ObjectDataBind)) {
|
|
905
|
-
var
|
|
906
|
-
var oldState = (
|
|
957
|
+
var _JSONCopy;
|
|
958
|
+
var oldState = (_JSONCopy = JSONCopy(_this.getState(controlId, rowIndex))) !== null && _JSONCopy !== void 0 ? _JSONCopy : _this.getEmptyState(controlId);
|
|
907
959
|
// fieldCode不代表是key,所以需要找到对应的key
|
|
908
960
|
var newState = Object.entries(dataBind).reduce(function(result, param) {
|
|
909
961
|
var _param = _slicedToArray(param, 2), key = _param[0], dataBind = _param[1];
|
|
@@ -981,19 +1033,19 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
981
1033
|
var skipKey = [] //qiyu ObjectDataBind中会提前将相关key拿出来赋值,为了避免重复赋值,设置了此变量
|
|
982
1034
|
;
|
|
983
1035
|
Object.keys(row).map(function(fieldCode) {
|
|
984
|
-
var
|
|
1036
|
+
var _this_store_dataBindMapping_dataCode, _this_store_dataBindMapping_dataCode_fields;
|
|
985
1037
|
if (skipKey.includes(fieldCode)) {
|
|
986
1038
|
return;
|
|
987
1039
|
}
|
|
988
|
-
var fieldMapping = (
|
|
1040
|
+
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) {
|
|
989
1041
|
return i.fieldCode === fieldCode;
|
|
990
1042
|
});
|
|
991
1043
|
if (fieldMapping) {
|
|
992
1044
|
if (_instanceof(fieldMapping.dataBind, DataBind) && row[fieldCode] !== undefined) {
|
|
993
1045
|
newRow[fieldMapping.controlId] = row[fieldCode];
|
|
994
1046
|
} else if (_instanceof(fieldMapping.dataBind, ObjectDataBind)) {
|
|
995
|
-
var
|
|
996
|
-
var objValue = JSONCopy((
|
|
1047
|
+
var _this_getEmptyState;
|
|
1048
|
+
var objValue = JSONCopy((_this_getEmptyState = _this.getEmptyState(fieldMapping.controlId)) !== null && _this_getEmptyState !== void 0 ? _this_getEmptyState : {});
|
|
997
1049
|
Object.keys(fieldMapping.dataBind).map(function(key) {
|
|
998
1050
|
var dataBind = fieldMapping.dataBind[key];
|
|
999
1051
|
if (row[dataBind.fieldCode] !== undefined) {
|
|
@@ -1028,8 +1080,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1028
1080
|
if (_instanceof(mapping.dataBind, DataBind) && entity[fieldCode] !== undefined) {
|
|
1029
1081
|
newState[mapping.dataViewId[0]][mapping.controlId] = entity[fieldCode];
|
|
1030
1082
|
} else if (_instanceof(mapping.dataBind, ObjectDataBind)) {
|
|
1031
|
-
var
|
|
1032
|
-
var objValue = JSONCopy((
|
|
1083
|
+
var _this_getEmptyState;
|
|
1084
|
+
var objValue = JSONCopy((_this_getEmptyState = _this.getEmptyState(mapping.controlId)) !== null && _this_getEmptyState !== void 0 ? _this_getEmptyState : {});
|
|
1033
1085
|
Object.keys(mapping.dataBind).map(function(key) {
|
|
1034
1086
|
var dataBind = mapping.dataBind[key];
|
|
1035
1087
|
if (entity[dataBind.fieldCode] !== undefined) {
|
|
@@ -1097,11 +1149,11 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1097
1149
|
}
|
|
1098
1150
|
} else {
|
|
1099
1151
|
var controlIdMapping = this.getControlIdMapping();
|
|
1100
|
-
var
|
|
1101
|
-
var
|
|
1152
|
+
var _Object_entries_find;
|
|
1153
|
+
var _ref = _slicedToArray((_Object_entries_find = Object.entries(controlIdMapping).find(function(param) {
|
|
1102
1154
|
var _param = _slicedToArray(param, 2), _ = _param[0], mapping = _param[1];
|
|
1103
1155
|
return mapping.children && controlId in mapping.children;
|
|
1104
|
-
})) !== null &&
|
|
1156
|
+
})) !== null && _Object_entries_find !== void 0 ? _Object_entries_find : [], 1), subtableId = _ref[0];
|
|
1105
1157
|
if (subtableId) {
|
|
1106
1158
|
var subtable = this.getInstance(subtableId);
|
|
1107
1159
|
// @ts-ignore
|
|
@@ -1255,8 +1307,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1255
1307
|
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
1256
1308
|
args[_key] = arguments[_key];
|
|
1257
1309
|
}
|
|
1258
|
-
var
|
|
1259
|
-
return (
|
|
1310
|
+
var _this_runtime;
|
|
1311
|
+
return (_this_runtime = this.runtime).registerControlConfig.apply(_this_runtime, _toConsumableArray(args));
|
|
1260
1312
|
};
|
|
1261
1313
|
_proto.getControlConfig = function getControlConfig(control) {
|
|
1262
1314
|
return this.runtime.getControlConfig(control);
|
|
@@ -18,12 +18,12 @@ var OkWorker = /*#__PURE__*/ function() {
|
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
20
|
_proto.destroy = function destroy() {
|
|
21
|
-
var
|
|
22
|
-
(
|
|
21
|
+
var _this_worker;
|
|
22
|
+
(_this_worker = this.worker) === null || _this_worker === void 0 ? void 0 : _this_worker.terminate();
|
|
23
23
|
};
|
|
24
24
|
_proto.postMessage = function postMessage(message) {
|
|
25
|
-
var
|
|
26
|
-
(
|
|
25
|
+
var _this_worker;
|
|
26
|
+
(_this_worker = this.worker) === null || _this_worker === void 0 ? void 0 : _this_worker.postMessage(message);
|
|
27
27
|
};
|
|
28
28
|
OkWorker.createWorker = function createWorker() {
|
|
29
29
|
var blob = new Blob([
|
|
@@ -64,7 +64,7 @@ var OkWorker = /*#__PURE__*/ function() {
|
|
|
64
64
|
// return new Proxy(obj, createHandler(parentKey))
|
|
65
65
|
// }
|
|
66
66
|
_self.addEventListener("message", function(event) {
|
|
67
|
-
var
|
|
67
|
+
var _event_data = event.data, action = _event_data.action, payload = _event_data.payload, fn = _event_data.fn;
|
|
68
68
|
log(action, payload);
|
|
69
69
|
// 通过proxy进行代理,每次修改的时候,自动向外抛出postMessage
|
|
70
70
|
// data.key1 = 1
|
package/dist/esm/common/Store.js
CHANGED
|
@@ -30,10 +30,9 @@ var Store = /*#__PURE__*/ function() {
|
|
|
30
30
|
"use strict";
|
|
31
31
|
function Store(props) {
|
|
32
32
|
_classCallCheck(this, Store);
|
|
33
|
-
var
|
|
33
|
+
var _init = init(props.instance), state = _init.state, emptyState = _init.emptyState, databindMapping = _init.databindMapping, controlidMapping = _init.controlidMapping;
|
|
34
34
|
this.emptyState = emptyState;
|
|
35
35
|
this.state = state;
|
|
36
|
-
this.fieldCodeState = fieldCodeState;
|
|
37
36
|
this.dataBindMapping = databindMapping;
|
|
38
37
|
this.controlIdMapping = controlidMapping;
|
|
39
38
|
}
|
|
@@ -97,8 +96,8 @@ var Store = /*#__PURE__*/ function() {
|
|
|
97
96
|
if (children !== undefined) {
|
|
98
97
|
Object.keys(children).map(function(childControlId) {
|
|
99
98
|
if (childControlId === controlId) {
|
|
100
|
-
var
|
|
101
|
-
state = (
|
|
99
|
+
var _this_state_dataViewId_subtableId_rowIndex;
|
|
100
|
+
state = (_this_state_dataViewId_subtableId_rowIndex = _this.state[dataViewId][subtableId][rowIndex]) === null || _this_state_dataViewId_subtableId_rowIndex === void 0 ? void 0 : _this_state_dataViewId_subtableId_rowIndex[controlId];
|
|
102
101
|
}
|
|
103
102
|
});
|
|
104
103
|
}
|
|
@@ -124,25 +123,6 @@ var Store = /*#__PURE__*/ function() {
|
|
|
124
123
|
}
|
|
125
124
|
}
|
|
126
125
|
};
|
|
127
|
-
_proto.getFieldCodeState = function getFieldCodeState(controlId) {
|
|
128
|
-
//qiyu 由于header的数据是后补充的,所以从state获取第一层值。
|
|
129
|
-
// const controlInfo = this.controlIdMapping[controlId]
|
|
130
|
-
var detection = this.fieldCodeState[controlId];
|
|
131
|
-
if (detection !== undefined) {
|
|
132
|
-
return this.fieldCodeState[controlId];
|
|
133
|
-
} else {
|
|
134
|
-
var controlInfo = this.controlIdMapping[controlId];
|
|
135
|
-
var dataCode = controlInfo.dataBind.dataCode;
|
|
136
|
-
if (controlInfo !== undefined) {
|
|
137
|
-
if (controlInfo.dataView === controlId) {
|
|
138
|
-
return this.fieldCodeState[controlId];
|
|
139
|
-
} else {
|
|
140
|
-
var dataCode1 = controlInfo.dataBind.dataCode;
|
|
141
|
-
return this.fieldCodeState[controlInfo.dataView][dataCode1] || this.fieldCodeState[controlInfo.dataView];
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
126
|
_proto.getEmptyState = function getEmptyState(controlId) {
|
|
147
127
|
var _this = this;
|
|
148
128
|
var detection = this.emptyState[controlId];
|
|
@@ -193,8 +173,6 @@ var Store = /*#__PURE__*/ function() {
|
|
|
193
173
|
function init(instance) {
|
|
194
174
|
var state = {};
|
|
195
175
|
var emptyState = {};
|
|
196
|
-
var fieldCodeState = {};
|
|
197
|
-
var fieldCodeEmptyState = {};
|
|
198
176
|
var databindMapping = {};
|
|
199
177
|
var controlidMapping = {};
|
|
200
178
|
// loopFormControl(instance, (item, children) => {
|
|
@@ -204,76 +182,39 @@ function init(instance) {
|
|
|
204
182
|
var dvId = dataView.id;
|
|
205
183
|
var dataViewState = {};
|
|
206
184
|
var emptyDataViewState = {};
|
|
207
|
-
var dataViewFieldCodeState = {};
|
|
208
|
-
var emptyDataViewFieldCodeState = {};
|
|
209
185
|
// @ts-ignore
|
|
210
186
|
loopFormControl([
|
|
211
187
|
dataView
|
|
212
188
|
], function(item, children) {
|
|
213
|
-
buildState(dataViewState, emptyDataViewState,
|
|
189
|
+
buildState(dataViewState, emptyDataViewState, item);
|
|
214
190
|
buildDataBindMapping(databindMapping, dvId, item);
|
|
215
191
|
buildControlIdMapping(controlidMapping, dvId, item);
|
|
216
192
|
});
|
|
217
193
|
state[dvId] = dataViewState;
|
|
218
194
|
emptyState[dvId] = emptyDataViewState;
|
|
219
|
-
fieldCodeState[dvId] = dataViewFieldCodeState;
|
|
220
|
-
fieldCodeEmptyState[dvId] = emptyDataViewFieldCodeState;
|
|
221
195
|
});
|
|
222
196
|
return {
|
|
223
197
|
state: state,
|
|
224
198
|
emptyState: emptyState,
|
|
225
199
|
databindMapping: databindMapping,
|
|
226
|
-
controlidMapping: controlidMapping
|
|
227
|
-
fieldCodeState: fieldCodeState,
|
|
228
|
-
fieldCodeEmptyState: fieldCodeEmptyState
|
|
200
|
+
controlidMapping: controlidMapping
|
|
229
201
|
};
|
|
230
202
|
}
|
|
231
|
-
function buildState(dataViewState, emptyDataViewState,
|
|
203
|
+
function buildState(dataViewState, emptyDataViewState, // @ts-ignore
|
|
232
204
|
item) {
|
|
233
205
|
if (_instanceof(item, RuntimeFormControl)) {
|
|
234
206
|
dataViewState[item.id] = JSONCopy(item.props.defaultValue);
|
|
235
207
|
emptyDataViewState[item.id] = JSONCopy(item.props.defaultValue);
|
|
236
|
-
if (_instanceof(item.props.dataBind, ObjectDataBind)) {
|
|
237
|
-
// 特殊的dataBind,比如:金额是currency+amount两个key组成的,日期区间,继承自ObjectDataBind的需要通过Object.keys拿到多个databind
|
|
238
|
-
Object.keys(item.props.dataBind).forEach(function(key) {
|
|
239
|
-
var dataBind = item.props.dataBind;
|
|
240
|
-
var defaultValue = item.props.defaultValue;
|
|
241
|
-
var dataBindFieldCode = dataBind[key].fieldCode;
|
|
242
|
-
dataViewFieldCodeState[dataBindFieldCode] = JSONCopy(defaultValue[key]);
|
|
243
|
-
emptyDataViewFieldCodeState[dataBindFieldCode] = JSONCopy(defaultValue[key]);
|
|
244
|
-
});
|
|
245
|
-
} else {
|
|
246
|
-
var dataBindFieldCode = item.props.dataBind.fieldCode;
|
|
247
|
-
dataViewFieldCodeState[dataBindFieldCode] = JSONCopy(item.props.defaultValue);
|
|
248
|
-
emptyDataViewFieldCodeState[dataBindFieldCode] = JSONCopy(item.props.defaultValue);
|
|
249
|
-
}
|
|
250
208
|
} else {
|
|
251
209
|
var emptyTemplate = {};
|
|
252
|
-
var emptyFieldCodeTemplate = {};
|
|
253
210
|
loopFormSchema(item.props.headers, function(headerItem) {
|
|
254
211
|
emptyTemplate[headerItem.id] = JSONCopy(headerItem.props.defaultValue);
|
|
255
|
-
// 处理成fieldCode
|
|
256
|
-
var headerItemFieldCode = headerItem.props.dataBind.fieldCode;
|
|
257
|
-
if (_instanceof(headerItem.props.dataBind, ObjectDataBind)) {
|
|
258
|
-
// 特殊的dataBind,比如:金额是currency+amount两个key组成的,日期区间,继承自ObjectDataBind的需要通过Object.keys拿到多个databind
|
|
259
|
-
Object.keys(headerItem.props.dataBind).forEach(function(key) {
|
|
260
|
-
emptyFieldCodeTemplate[headerItem.props.dataBind[key].fieldCode] = JSONCopy(headerItem.props.defaultValue[key]);
|
|
261
|
-
});
|
|
262
|
-
} else {
|
|
263
|
-
emptyFieldCodeTemplate[headerItemFieldCode] = JSONCopy(headerItem.props.defaultValue);
|
|
264
|
-
}
|
|
265
212
|
});
|
|
266
|
-
var
|
|
267
|
-
dataViewState[item.id] = new Array((
|
|
213
|
+
var _item_props_defaultRows;
|
|
214
|
+
dataViewState[item.id] = new Array((_item_props_defaultRows = item.props.defaultRows) !== null && _item_props_defaultRows !== void 0 ? _item_props_defaultRows : 1).fill(0).map(function() {
|
|
268
215
|
return JSONCopy(emptyTemplate);
|
|
269
216
|
});
|
|
270
217
|
emptyDataViewState[item.id] = emptyTemplate;
|
|
271
|
-
var dataBindFieldCode1 = item.props.datasourceBind.dataCode;
|
|
272
|
-
var _defaultRows1;
|
|
273
|
-
dataViewFieldCodeState[dataBindFieldCode1] = new Array((_defaultRows1 = item.props.defaultRows) !== null && _defaultRows1 !== void 0 ? _defaultRows1 : 1).fill(0).map(function() {
|
|
274
|
-
return JSONCopy(emptyFieldCodeTemplate);
|
|
275
|
-
});
|
|
276
|
-
emptyDataViewFieldCodeState[dataBindFieldCode1] = emptyFieldCodeTemplate;
|
|
277
218
|
}
|
|
278
219
|
}
|
|
279
220
|
function buildDataBindMapping(data, dataViewId, // @ts-ignore
|
|
@@ -379,9 +320,9 @@ item) {
|
|
|
379
320
|
options: []
|
|
380
321
|
};
|
|
381
322
|
loopFormSchema(item.props.headers, function(formControl) {
|
|
382
|
-
var
|
|
383
|
-
var
|
|
384
|
-
Object.assign((
|
|
323
|
+
var _data_item_id;
|
|
324
|
+
var _data_item_id_children;
|
|
325
|
+
Object.assign((_data_item_id_children = (_data_item_id = data[item.id]) === null || _data_item_id === void 0 ? void 0 : _data_item_id.children) !== null && _data_item_id_children !== void 0 ? _data_item_id_children : {}, _defineProperty({}, formControl.id, {
|
|
385
326
|
dataBind: formControl.props.dataBind
|
|
386
327
|
}));
|
|
387
328
|
});
|
|
@@ -520,8 +520,8 @@ function getFieldTypeFromKey(key) {
|
|
|
520
520
|
}
|
|
521
521
|
}
|
|
522
522
|
export function checkerValue(fieldType, key, value, oldValue) {
|
|
523
|
-
var
|
|
524
|
-
var getCheckerFieldType = (
|
|
523
|
+
var _getFieldTypeFromKey;
|
|
524
|
+
var getCheckerFieldType = (_getFieldTypeFromKey = getFieldTypeFromKey(key)) !== null && _getFieldTypeFromKey !== void 0 ? _getFieldTypeFromKey : fieldType;
|
|
525
525
|
var checker = ValueCheckerFactory.getValueChecker(getCheckerFieldType);
|
|
526
526
|
if (!checker || checker.validate(value)) {
|
|
527
527
|
return value;
|
|
@@ -148,8 +148,8 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
|
|
|
148
148
|
// @ts-ignore
|
|
149
149
|
var oldValue = target[propertyKey];
|
|
150
150
|
var concatKey = thisKey === "" ? propertyKey : thisKey + "." + propertyKey;
|
|
151
|
-
var
|
|
152
|
-
newValue = (
|
|
151
|
+
var _reProxyState;
|
|
152
|
+
newValue = (_reProxyState = reProxyState(value)) !== null && _reProxyState !== void 0 ? _reProxyState : newValue;
|
|
153
153
|
// 先设置值,然后再进行触发回调,确保回调内拿到的是最新的值
|
|
154
154
|
var setResult;
|
|
155
155
|
// TODO 数组拦截操作需要重构,优化现有逻辑
|
|
@@ -243,10 +243,10 @@ function flatInstanceForChildren(controls) {
|
|
|
243
243
|
// 最后一个key可能是值对象上边的key,比如金额的amount和currency,计算公式的result和unit,所以需要判断前一个控件是不是一个表单控件,是的话就返回最后一个表单控件
|
|
244
244
|
return findEndItem ? findEndItem : _instanceof(prevItem, RuntimeFormControl) ? prevItem : undefined;
|
|
245
245
|
} else {
|
|
246
|
-
var
|
|
247
|
-
var
|
|
246
|
+
var _prevItem_children;
|
|
247
|
+
var _prevItem_children_index;
|
|
248
248
|
// 如果有children,则取children中对应的下标,没有的话一直返回prevItem
|
|
249
|
-
return (
|
|
249
|
+
return (_prevItem_children_index = prevItem === null || prevItem === void 0 ? void 0 : (_prevItem_children = prevItem.children) === null || _prevItem_children === void 0 ? void 0 : _prevItem_children[index]) !== null && _prevItem_children_index !== void 0 ? _prevItem_children_index : prevItem;
|
|
250
250
|
}
|
|
251
251
|
}, initInstance);
|
|
252
252
|
}
|
|
@@ -286,9 +286,9 @@ function getArrayNewArgs(type, args, value) {
|
|
|
286
286
|
var result;
|
|
287
287
|
var addValue = getArrayNewValue(key, args);
|
|
288
288
|
if (addValue.length) {
|
|
289
|
-
var
|
|
289
|
+
var _this, _this_engineArrayBeforeSetCallbackFlag;
|
|
290
290
|
// @ts-ignore
|
|
291
|
-
var newValue = (
|
|
291
|
+
var newValue = (_this_engineArrayBeforeSetCallbackFlag = (_this = this)[engineArrayBeforeSetCallbackFlag]) === null || _this_engineArrayBeforeSetCallbackFlag === void 0 ? void 0 : _this_engineArrayBeforeSetCallbackFlag.call(_this, // @ts-ignore
|
|
292
292
|
this[engineTargetKey], // @ts-ignore
|
|
293
293
|
this[engineProxyThisKey], addValue);
|
|
294
294
|
var newArgs = getArrayNewArgs(key, args, newValue);
|