@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.
@@ -173,7 +173,7 @@ export var ActionManager = /*#__PURE__*/ function() {
173
173
  }
174
174
  var _this = this;
175
175
  return _asyncToGenerator(function() {
176
- var action, _func, result, e;
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
- (_func = action.func).call.apply(_func, [
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 _$options = _this.$options, _autoMount = _$options.autoMount, autoMount = _autoMount === void 0 ? true : _autoMount, schema = _$options.schema, beforeCreateInstance = _$options.beforeCreateInstance, externalParams = _$options.externalParams, _language = _$options.// fieldModel,
371
- language, language = _language === void 0 ? DEFAULT_LOCALE : _language, _debug = _$options.debug, debug = _debug === void 0 ? false : _debug;
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 _runtime;
406
- (_runtime = this.runtime).register.apply(_runtime, _toConsumableArray(arg));
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 _$options = this.$options, _plugins = _$options.plugins, plugins = _plugins === void 0 ? [] : _plugins;
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 _children;
499
+ var _subtable_children;
500
500
  var newRowLengths = args.length;
501
501
  createdNewRows = createRows(newRowLengths);
502
502
  createdNewRowsData = args;
503
- (_children = subtable.children)[type].apply(_children, _toConsumableArray(createdNewRows));
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
- _children1;
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
- (_children1 = subtable.children)[type].apply(_children1, [
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
- _children2;
530
- (_children2 = subtable.children)[type].apply(_children2, _toConsumableArray(args));
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
- _children3;
537
- (_children3 = subtable.children)[type].apply(_children3, _toConsumableArray(args));
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
- _children;
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
- (_children = instance.children).push.apply(_children, _toConsumableArray(newRows));
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 _pluginName;
616
- applyingPluginName = (_pluginName = plugin.pluginName) !== null && _pluginName !== void 0 ? _pluginName : plugin.constructor.name;
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 _children;
630
+ var _row_children;
631
631
  var template = JSONCopy(instance.props.headers);
632
632
  // @ts-ignore
633
633
  var columns = this.createControl(template);
634
- (_children = row.children).push.apply(_children, _toConsumableArray(columns));
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 _runtime;
722
- return (_runtime = this.runtime).createControl.apply(_runtime, _toConsumableArray(args));
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 ref;
738
- return (ref = this.runtime.rules[controlId]) === null || ref === void 0 ? void 0 : ref.fields;
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 ref;
746
- return (ref = this.runtime.antdRules[controlId]) === null || ref === void 0 ? void 0 : ref.fields;
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
- var dataBindMapping = this.getDataBindMapping(dataCode);
845
- if (dataBindMapping) {
846
- var controlId = dataBindMapping.controlId;
847
- return this.getFieldCodeState(controlId);
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 ref;
867
- var oldState = (ref = JSONCopy(this.getState(controlId, rowIndex))) !== null && ref !== void 0 ? ref : this.getEmptyState(controlId);
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 ref;
906
- var oldState = (ref = JSONCopy(_this.getState(controlId, rowIndex))) !== null && ref !== void 0 ? ref : _this.getEmptyState(controlId);
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 ref, ref1;
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 = (ref = _this.store.dataBindMapping[dataCode]) === null || ref === void 0 ? void 0 : (ref1 = ref.fields) === null || ref1 === void 0 ? void 0 : ref1.find(function(i) {
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 ref2;
996
- var objValue = JSONCopy((ref2 = _this.getEmptyState(fieldMapping.controlId)) !== null && ref2 !== void 0 ? ref2 : {});
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 ref;
1032
- var objValue = JSONCopy((ref = _this.getEmptyState(mapping.controlId)) !== null && ref !== void 0 ? ref : {});
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 ref;
1101
- var ref1 = _slicedToArray((ref = Object.entries(controlIdMapping).find(function(param) {
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 && ref !== void 0 ? ref : [], 1), subtableId = ref1[0];
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 _runtime;
1259
- return (_runtime = this.runtime).registerControlConfig.apply(_runtime, _toConsumableArray(args));
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 ref;
22
- (ref = this.worker) === null || ref === void 0 ? void 0 : ref.terminate();
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 ref;
26
- (ref = this.worker) === null || ref === void 0 ? void 0 : ref.postMessage(message);
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 _data = event.data, action = _data.action, payload = _data.payload, fn = _data.fn;
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
@@ -30,10 +30,9 @@ var Store = /*#__PURE__*/ function() {
30
30
  "use strict";
31
31
  function Store(props) {
32
32
  _classCallCheck(this, Store);
33
- var ref = init(props.instance), state = ref.state, emptyState = ref.emptyState, databindMapping = ref.databindMapping, controlidMapping = ref.controlidMapping, fieldCodeState = ref.fieldCodeState;
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 ref;
101
- state = (ref = _this.state[dataViewId][subtableId][rowIndex]) === null || ref === void 0 ? void 0 : ref[controlId];
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, dataViewFieldCodeState, emptyDataViewFieldCodeState, item);
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, dataViewFieldCodeState, emptyDataViewFieldCodeState, // @ts-ignore
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 _defaultRows;
267
- dataViewState[item.id] = new Array((_defaultRows = item.props.defaultRows) !== null && _defaultRows !== void 0 ? _defaultRows : 1).fill(0).map(function() {
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 ref;
383
- var ref1;
384
- Object.assign((ref1 = (ref = data[item.id]) === null || ref === void 0 ? void 0 : ref.children) !== null && ref1 !== void 0 ? ref1 : {}, _defineProperty({}, formControl.id, {
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 ref;
524
- var getCheckerFieldType = (ref = getFieldTypeFromKey(key)) !== null && ref !== void 0 ? ref : fieldType;
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 ref;
152
- newValue = (ref = reProxyState(value)) !== null && ref !== void 0 ? ref : 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 ref;
247
- var ref1;
246
+ var _prevItem_children;
247
+ var _prevItem_children_index;
248
248
  // 如果有children,则取children中对应的下标,没有的话一直返回prevItem
249
- return (ref1 = prevItem === null || prevItem === void 0 ? void 0 : (ref = prevItem.children) === null || ref === void 0 ? void 0 : ref[index]) !== null && ref1 !== void 0 ? ref1 : prevItem;
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 _obj, ref;
289
+ var _this, _this_engineArrayBeforeSetCallbackFlag;
290
290
  // @ts-ignore
291
- var newValue = (ref = (_obj = this)[engineArrayBeforeSetCallbackFlag]) === null || ref === void 0 ? void 0 : ref.call(_obj, // @ts-ignore
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);