@byteluck-fe/model-driven-engine 2.3.11 → 2.5.0-alpha.4

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.
@@ -495,7 +495,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
495
495
  }, {});
496
496
  // @ts-ignore
497
497
  var emptyState = this.getEmptyState(instance.id);
498
- return newValue === null || newValue === void 0 ? void 0 : newValue.map(function(row) {
498
+ return newValue.map(function(row) {
499
499
  return(// @ts-ignore
500
500
  checkerSubtableValue(fieldTypeMap, row, emptyState));
501
501
  });
@@ -901,7 +901,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
901
901
  */ key: "setStates",
902
902
  value: function setStates(states, rowIndex, options) {
903
903
  var _this = this;
904
- var newStates = states !== null && states !== void 0 ? states : {};
904
+ var newStates = states;
905
905
  Object.keys(newStates).forEach(function(stateId) {
906
906
  Object.entries(_this.store.controlIdMapping).forEach(function(param) {
907
907
  var _param = _sliced_to_array(param, 2), controlId = _param[0], controlIdMapping = _param[1];
@@ -1161,6 +1161,12 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1161
1161
  value: function setData(dataSet, options) {
1162
1162
  var _this = this;
1163
1163
  this.debugLog("engine setData方法执行,参数为%o,%o。", dataSet, options);
1164
+ var isEmpty = function(value) {
1165
+ if (isString(value) || Array.isArray(value)) {
1166
+ return value.length === 0;
1167
+ }
1168
+ return false;
1169
+ };
1164
1170
  var newState = {};
1165
1171
  Object.keys(dataSet).map(function(dataCode) {
1166
1172
  var entity = dataSet[dataCode];
@@ -1207,50 +1213,34 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1207
1213
  newState[mapping.dataViewId][mapping.controlId].push(newRow);
1208
1214
  });
1209
1215
  } else if (entity) {
1210
- var _Object_keys;
1211
1216
  var skipKey = [] //qiyu ObjectDataBind中会提前将相关key拿出来赋值,为了避免重复赋值,设置了此变量
1212
1217
  ;
1213
1218
  var emptyState = JSONCopy(_this.store.emptyState);
1214
- if (!((_Object_keys = Object.keys(entity)) === null || _Object_keys === void 0 ? void 0 : _Object_keys.length)) {
1215
- var _this_getDataBindMapping;
1216
- //判断entity 为空对象就给表单赋值默认值
1217
- newState = JSONCopy(emptyState);
1218
- var _this_getDataBindMapping_controlId;
1219
- var dataViewControlId = (_this_getDataBindMapping_controlId = (_this_getDataBindMapping = _this.getDataBindMapping(dataCode)) === null || _this_getDataBindMapping === void 0 ? void 0 : _this_getDataBindMapping.controlId) !== null && _this_getDataBindMapping_controlId !== void 0 ? _this_getDataBindMapping_controlId : "";
1220
- var _emptyState_dataViewControlId;
1221
- var state = (_emptyState_dataViewControlId = emptyState[dataViewControlId]) !== null && _emptyState_dataViewControlId !== void 0 ? _emptyState_dataViewControlId : {};
1222
- Object.keys(state).map(function(key) {
1223
- if (_this.getControlIdMapping()[key].children !== undefined) {
1224
- newState[dataViewControlId][key] = undefined;
1225
- }
1226
- });
1227
- } else {
1228
- Object.keys(entity).map(function(fieldCode) {
1229
- if (skipKey.includes(fieldCode)) {
1230
- return;
1219
+ Object.keys(entity).map(function(fieldCode) {
1220
+ if (skipKey.includes(fieldCode)) {
1221
+ return;
1222
+ }
1223
+ var mapping = _this.getDataBindMapping(dataCode, fieldCode);
1224
+ if (mapping) {
1225
+ if (!newState[mapping.dataViewId[0]]) {
1226
+ newState[mapping.dataViewId[0]] = {};
1231
1227
  }
1232
- var mapping = _this.getDataBindMapping(dataCode, fieldCode);
1233
- if (mapping) {
1234
- if (!newState[mapping.dataViewId[0]]) {
1235
- newState[mapping.dataViewId[0]] = {};
1236
- }
1237
- if (_instanceof(mapping.dataBind, DataBind) && entity[fieldCode] !== undefined) {
1238
- newState[mapping.dataViewId[0]][mapping.controlId] = entity[fieldCode] !== undefined ? entity[fieldCode] : emptyState[mapping.dataViewId[0]][mapping.controlId];
1239
- } else if (_instanceof(mapping.dataBind, ObjectDataBind)) {
1240
- var _this_getEmptyState;
1241
- var objValue = (_this_getEmptyState = _this.getEmptyState(mapping.controlId)) !== null && _this_getEmptyState !== void 0 ? _this_getEmptyState : {};
1242
- Object.keys(mapping.dataBind).map(function(key) {
1243
- var dataBind = mapping.dataBind[key];
1244
- if (entity[dataBind.fieldCode] !== undefined) {
1245
- objValue[key] = entity[dataBind.fieldCode];
1246
- }
1247
- skipKey.push(dataBind.fieldCode);
1248
- });
1249
- newState[mapping.dataViewId[0]][mapping.controlId] = objValue;
1250
- }
1228
+ if (_instanceof(mapping.dataBind, DataBind) && entity[fieldCode] !== undefined) {
1229
+ newState[mapping.dataViewId[0]][mapping.controlId] = entity[fieldCode] !== undefined ? entity[fieldCode] : emptyState[mapping.dataViewId[0]][mapping.controlId];
1230
+ } else if (_instanceof(mapping.dataBind, ObjectDataBind)) {
1231
+ var _this_getEmptyState;
1232
+ var objValue = (_this_getEmptyState = _this.getEmptyState(mapping.controlId)) !== null && _this_getEmptyState !== void 0 ? _this_getEmptyState : {};
1233
+ Object.keys(mapping.dataBind).map(function(key) {
1234
+ var dataBind = mapping.dataBind[key];
1235
+ if (entity[dataBind.fieldCode] !== undefined) {
1236
+ objValue[key] = entity[dataBind.fieldCode];
1237
+ }
1238
+ skipKey.push(dataBind.fieldCode);
1239
+ });
1240
+ newState[mapping.dataViewId[0]][mapping.controlId] = objValue;
1251
1241
  }
1252
- });
1253
- }
1242
+ }
1243
+ });
1254
1244
  var newMapping = _this.getDataBindMapping(dataCode);
1255
1245
  if (newMapping) {
1256
1246
  var _newMapping_fields;
@@ -1261,8 +1251,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1261
1251
  var _newState_newMapping_controlId;
1262
1252
  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 : {});
1263
1253
  mappingKeys === null || mappingKeys === void 0 ? void 0 : mappingKeys.forEach(function(key) {
1264
- if (!mainStateKeys.includes(key) && key !== "uid" && newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId]) {
1265
- if (Object.keys(newState).length) {
1254
+ if (!mainStateKeys.includes(key) && key !== "uid") {
1255
+ if (Object.keys(newState).length && newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId]) {
1266
1256
  Object.assign(newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId], _define_property({}, key, mappingValue[key]));
1267
1257
  } else {
1268
1258
  Object.assign(newState, _define_property({}, newMapping.controlId, _define_property({}, key, mappingValue[key])));
@@ -1336,8 +1326,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1336
1326
  }
1337
1327
  }
1338
1328
  } else {
1339
- var _this_getControlIdMapping;
1340
- var controlIdMapping = (_this_getControlIdMapping = this.getControlIdMapping()) !== null && _this_getControlIdMapping !== void 0 ? _this_getControlIdMapping : {};
1329
+ var controlIdMapping = this.getControlIdMapping();
1341
1330
  var _Object_entries_find;
1342
1331
  var _ref = _sliced_to_array((_Object_entries_find = Object.entries(controlIdMapping).find(function(param) {
1343
1332
  var _param = _sliced_to_array(param, 2), _ = _param[0], mapping = _param[1];
@@ -1562,8 +1551,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1562
1551
  {
1563
1552
  key: "inList",
1564
1553
  value: function inList(controlId) {
1565
- var _this_store_controlIdMapping;
1566
- var mapping = (_this_store_controlIdMapping = this.store.controlIdMapping) !== null && _this_store_controlIdMapping !== void 0 ? _this_store_controlIdMapping : {};
1554
+ var mapping = this.store.controlIdMapping;
1567
1555
  var result = Object.keys(mapping).some(function(key) {
1568
1556
  var _mapping_key, _mapping_key_children;
1569
1557
  return (_mapping_key = mapping[key]) === null || _mapping_key === void 0 ? void 0 : (_mapping_key_children = _mapping_key.children) === null || _mapping_key_children === void 0 ? void 0 : _mapping_key_children.hasOwnProperty(controlId);