@byteluck-fe/model-driven-engine 2.3.6 → 2.5.0-alpha.1

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.
@@ -1213,40 +1213,34 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1213
1213
  newState[mapping.dataViewId][mapping.controlId].push(newRow);
1214
1214
  });
1215
1215
  } else if (entity) {
1216
- var _Object_keys;
1217
1216
  var skipKey = [] //qiyu ObjectDataBind中会提前将相关key拿出来赋值,为了避免重复赋值,设置了此变量
1218
1217
  ;
1219
1218
  var emptyState = JSONCopy(_this.store.emptyState);
1220
- if (!((_Object_keys = Object.keys(entity)) === null || _Object_keys === void 0 ? void 0 : _Object_keys.length)) {
1221
- //判断entity 为空对象就给表单赋值默认值
1222
- newState = JSONCopy(emptyState);
1223
- } else {
1224
- Object.keys(entity).map(function(fieldCode) {
1225
- if (skipKey.includes(fieldCode)) {
1226
- 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]] = {};
1227
1227
  }
1228
- var mapping = _this.getDataBindMapping(dataCode, fieldCode);
1229
- if (mapping) {
1230
- if (!newState[mapping.dataViewId[0]]) {
1231
- newState[mapping.dataViewId[0]] = {};
1232
- }
1233
- if (_instanceof(mapping.dataBind, DataBind) && entity[fieldCode] !== undefined) {
1234
- newState[mapping.dataViewId[0]][mapping.controlId] = entity[fieldCode] !== undefined ? entity[fieldCode] : emptyState[mapping.dataViewId[0]][mapping.controlId];
1235
- } else if (_instanceof(mapping.dataBind, ObjectDataBind)) {
1236
- var _this_getEmptyState;
1237
- var objValue = (_this_getEmptyState = _this.getEmptyState(mapping.controlId)) !== null && _this_getEmptyState !== void 0 ? _this_getEmptyState : {};
1238
- Object.keys(mapping.dataBind).map(function(key) {
1239
- var dataBind = mapping.dataBind[key];
1240
- if (entity[dataBind.fieldCode] !== undefined) {
1241
- objValue[key] = entity[dataBind.fieldCode];
1242
- }
1243
- skipKey.push(dataBind.fieldCode);
1244
- });
1245
- newState[mapping.dataViewId[0]][mapping.controlId] = objValue;
1246
- }
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;
1247
1241
  }
1248
- });
1249
- }
1242
+ }
1243
+ });
1250
1244
  var newMapping = _this.getDataBindMapping(dataCode);
1251
1245
  if (newMapping) {
1252
1246
  var _newMapping_fields;
@@ -1257,8 +1251,8 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1257
1251
  var _newState_newMapping_controlId;
1258
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 : {});
1259
1253
  mappingKeys === null || mappingKeys === void 0 ? void 0 : mappingKeys.forEach(function(key) {
1260
- if (!mainStateKeys.includes(key) && key !== "uid" && newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId]) {
1261
- 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]) {
1262
1256
  Object.assign(newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId], _defineProperty({}, key, mappingValue[key]));
1263
1257
  } else {
1264
1258
  Object.assign(newState, _defineProperty({}, newMapping.controlId, _defineProperty({}, key, mappingValue[key])));