@byteluck-fe/model-driven-engine 2.4.1-beta.7 → 2.4.1-beta.9

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.
@@ -860,8 +860,8 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
860
860
  return data;
861
861
  } else {
862
862
  var _loop = function(key1) {
863
- var ref19, ref8, ref9, ref10;
864
- if ((ref19 = controlIdMapping[key1]) === null || ref19 === void 0 ? void 0 : (ref8 = ref19.dataBind) === null || ref8 === void 0 ? void 0 : ref8.fieldCode) {
863
+ var ref17, ref8, ref9, ref10;
864
+ if ((ref17 = controlIdMapping[key1]) === null || ref17 === void 0 ? void 0 : (ref8 = ref17.dataBind) === null || ref8 === void 0 ? void 0 : ref8.fieldCode) {
865
865
  var ref11;
866
866
  obj1[(ref11 = controlIdMapping[key1]) === null || ref11 === void 0 ? void 0 : ref11.dataBind.fieldCode] = getFieldData[key1];
867
867
  } else if ((ref9 = controlIdMapping[key1]) === null || ref9 === void 0 ? void 0 : (ref10 = ref9.dataBind) === null || ref10 === void 0 ? void 0 : ref10.dataCode) {
@@ -873,18 +873,13 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
873
873
  var ref;
874
874
  if ((ref = controlIdMapping[key1].children[keyChi]) === null || ref === void 0 ? void 0 : ref.dataBind.fieldCode) {
875
875
  var ref15;
876
- var testKeyObject = objChi[(ref15 = controlIdMapping[key1].children[keyChi]) === null || ref15 === void 0 ? void 0 : ref15.dataBind.fieldCode];
877
- if (testKeyObject !== undefined) {
878
- var ref16;
879
- objChi[(ref16 = controlIdMapping[key1].children[keyChi]) === null || ref16 === void 0 ? void 0 : ref16.dataBind.fieldCode] = item[keyChi];
880
- }
876
+ objChi[(ref15 = controlIdMapping[key1].children[keyChi]) === null || ref15 === void 0 ? void 0 : ref15.dataBind.fieldCode] = item[keyChi];
881
877
  } else {
882
- for(var keyChi1 in item[keyChi]){
883
- var ref17;
884
- var testKeyObject1 = objChi[(ref17 = controlIdMapping[key1].children[keyChi]) === null || ref17 === void 0 ? void 0 : ref17.dataBind[keyChi1].fieldCode];
885
- if (testKeyObject1 !== undefined) {
886
- var ref18;
887
- objChi[(ref18 = controlIdMapping[key1].children[keyChi]) === null || ref18 === void 0 ? void 0 : ref18.dataBind[keyChi1].fieldCode] = item[keyChi][keyChi1];
878
+ //qiyu 2023-5-25 vue容器未绑定字段,item[keyChi]值会是undefined
879
+ if (item[keyChi] !== undefined) {
880
+ for(var keyChi1 in item[keyChi]){
881
+ var ref16;
882
+ objChi[(ref16 = controlIdMapping[key1].children[keyChi]) === null || ref16 === void 0 ? void 0 : ref16.dataBind[keyChi1].fieldCode] = item[keyChi][keyChi1];
888
883
  }
889
884
  }
890
885
  }
@@ -1036,20 +1031,20 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
1036
1031
  * @options 传递给关联事件中 EventPayload中的options,一般在plugin中监听使用
1037
1032
  */ key: "setData",
1038
1033
  value: function setData(dataSet, options) {
1039
- var _this6 = this;
1034
+ var _this7 = this;
1040
1035
  this.debugLog("engine setData方法执行,参数为%o,%o。", dataSet, options);
1041
1036
  var newState = {};
1042
1037
  Object.keys(dataSet).map(function(dataCode) {
1043
1038
  var entity = dataSet[dataCode];
1044
1039
  if (Array.isArray(entity)) {
1045
- var _this4 = _this6;
1040
+ var _this5 = _this7;
1046
1041
  entity.map(function(row) {
1047
- var _this = _this4;
1048
- var mapping = _this4.getDataBindMapping(dataCode);
1042
+ var _this = _this5;
1043
+ var mapping = _this5.getDataBindMapping(dataCode);
1049
1044
  if (!mapping) {
1050
1045
  return;
1051
1046
  }
1052
- var newRow = JSONCopy(_this4.store.emptyState[mapping.dataViewId][mapping.controlId]);
1047
+ var newRow = JSONCopy(_this5.store.emptyState[mapping.dataViewId][mapping.controlId]);
1053
1048
  var skipKey = [] //qiyu ObjectDataBind中会提前将相关key拿出来赋值,为了避免重复赋值,设置了此变量
1054
1049
  ;
1055
1050
  Object.keys(row).map(function(fieldCode) {
@@ -1089,16 +1084,28 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
1089
1084
  var ref24;
1090
1085
  var skipKey1 = [] //qiyu ObjectDataBind中会提前将相关key拿出来赋值,为了避免重复赋值,设置了此变量
1091
1086
  ;
1092
- var emptyState = JSONCopy(_this6.store.emptyState);
1087
+ var emptyState = JSONCopy(_this7.store.emptyState);
1093
1088
  if (!((ref24 = Object.keys(entity)) === null || ref24 === void 0 ? void 0 : ref24.length)) {
1094
- newState = _this6.store.defaultState;
1089
+ var _this3 = _this7;
1090
+ var ref18;
1091
+ //判断entity 为空对象就给表单赋值默认值
1092
+ newState = JSONCopy(emptyState);
1093
+ var ref19;
1094
+ var dataViewControlId = (ref19 = (ref18 = _this7.getDataBindMapping(dataCode)) === null || ref18 === void 0 ? void 0 : ref18.controlId) !== null && ref19 !== void 0 ? ref19 : '';
1095
+ var _dataViewControlId;
1096
+ var state = (_dataViewControlId = emptyState[dataViewControlId]) !== null && _dataViewControlId !== void 0 ? _dataViewControlId : {};
1097
+ Object.keys(state).map(function(key) {
1098
+ if (_this3.getControlIdMapping()[key].children !== undefined) {
1099
+ newState[dataViewControlId][key] = undefined;
1100
+ }
1101
+ });
1095
1102
  } else {
1096
- var _this3 = _this6;
1103
+ var _this4 = _this7;
1097
1104
  Object.keys(entity).map(function(fieldCode) {
1098
1105
  if (skipKey1.includes(fieldCode)) {
1099
1106
  return;
1100
1107
  }
1101
- var mapping = _this3.getDataBindMapping(dataCode, fieldCode);
1108
+ var mapping = _this4.getDataBindMapping(dataCode, fieldCode);
1102
1109
  if (mapping) {
1103
1110
  if (!newState[mapping.dataViewId[0]]) {
1104
1111
  newState[mapping.dataViewId[0]] = {};
@@ -1107,7 +1114,7 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
1107
1114
  newState[mapping.dataViewId[0]][mapping.controlId] = entity[fieldCode] !== undefined ? entity[fieldCode] : emptyState[mapping.dataViewId[0]][mapping.controlId];
1108
1115
  } else if (_instanceof(mapping.dataBind, ObjectDataBind)) {
1109
1116
  var ref;
1110
- var objValue = (ref = _this3.getEmptyState(mapping.controlId)) !== null && ref !== void 0 ? ref : {};
1117
+ var objValue = (ref = _this4.getEmptyState(mapping.controlId)) !== null && ref !== void 0 ? ref : {};
1111
1118
  Object.keys(mapping.dataBind).map(function(key) {
1112
1119
  var dataBind = mapping.dataBind[key];
1113
1120
  if (entity[dataBind.fieldCode] !== undefined) {
@@ -1120,13 +1127,13 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
1120
1127
  }
1121
1128
  });
1122
1129
  }
1123
- var newMapping = _this6.getDataBindMapping(dataCode);
1130
+ var newMapping = _this7.getDataBindMapping(dataCode);
1124
1131
  if (newMapping) {
1125
1132
  var ref20;
1126
1133
  var mappingKeys = newMapping === null || newMapping === void 0 ? void 0 : (ref20 = newMapping.fields) === null || ref20 === void 0 ? void 0 : ref20.map(function(item) {
1127
1134
  return item === null || item === void 0 ? void 0 : item.controlId;
1128
1135
  });
1129
- var mappingValue = _this6.getEmptyState(newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId);
1136
+ var mappingValue = _this7.getEmptyState(newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId);
1130
1137
  var ref21;
1131
1138
  var mainStateKeys = Object.keys((ref21 = newState === null || newState === void 0 ? void 0 : newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId]) !== null && ref21 !== void 0 ? ref21 : {});
1132
1139
  mappingKeys === null || mappingKeys === void 0 ? void 0 : mappingKeys.forEach(function(key) {
@@ -1138,7 +1145,7 @@ var Engine = // 整体渲染引擎 并且 提供发布订阅能力
1138
1145
  }
1139
1146
  }
1140
1147
  });
1141
- _this6.debugLog("engine setData方法默认值及表单数据组合完成,参数为%o。", newState);
1148
+ _this7.debugLog("engine setData方法默认值及表单数据组合完成,参数为%o。", newState);
1142
1149
  }
1143
1150
  }
1144
1151
  });
@@ -44,12 +44,11 @@ var Store = /*#__PURE__*/ function() {
44
44
  "use strict";
45
45
  function Store(props) {
46
46
  _classCallCheck(this, Store);
47
- var ref = init(props.instance), state = ref.state, emptyState = ref.emptyState, databindMapping = ref.databindMapping, controlidMapping = ref.controlidMapping, defaultState = ref.defaultState;
47
+ var ref = init(props.instance), state = ref.state, emptyState = ref.emptyState, databindMapping = ref.databindMapping, controlidMapping = ref.controlidMapping;
48
48
  this.emptyState = emptyState;
49
49
  this.state = state;
50
50
  this.dataBindMapping = databindMapping;
51
51
  this.controlIdMapping = controlidMapping;
52
- this.defaultState = defaultState;
53
52
  }
54
53
  _createClass(Store, [
55
54
  {
@@ -215,7 +214,6 @@ function init(instance) {
215
214
  var emptyState = {};
216
215
  var databindMapping = {};
217
216
  var controlidMapping = {};
218
- var defaultState = {};
219
217
  // loopFormControl(instance, (item, children) => {
220
218
  // })
221
219
  // @ts-ignore
@@ -231,13 +229,11 @@ function init(instance) {
231
229
  buildDataBindMapping(databindMapping, dvId, item);
232
230
  buildControlIdMapping(controlidMapping, dvId, item);
233
231
  });
234
- state[dvId] = {};
235
- defaultState[dvId] = dataViewState;
232
+ state[dvId] = dataViewState;
236
233
  emptyState[dvId] = emptyDataViewState;
237
234
  });
238
235
  return {
239
236
  state: state,
240
- defaultState: defaultState,
241
237
  emptyState: emptyState,
242
238
  databindMapping: databindMapping,
243
239
  controlidMapping: controlidMapping
@@ -248,7 +244,7 @@ item) {
248
244
  //if (item instanceof RuntimeFormControl) {
249
245
  if (item.controlType === CONTROL_BASE_TYPE.FORM) {
250
246
  // 2023-4-2 jiaqi 首次进入页面去除填充默认值
251
- dataViewState[item.id] = JSONCopy(item.props.defaultValue);
247
+ // dataViewState[item.id] = JSONCopy(item.props.defaultValue)
252
248
  emptyDataViewState[item.id] = JSONCopy(item.props.defaultValue);
253
249
  } else {
254
250
  var emptyTemplate = {};