@byteluck-fe/model-driven-engine 2.3.4 → 2.3.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.
@@ -1213,34 +1213,40 @@ 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;
1216
1217
  var skipKey = [] //qiyu ObjectDataBind中会提前将相关key拿出来赋值,为了避免重复赋值,设置了此变量
1217
1218
  ;
1218
1219
  var emptyState = JSONCopy(_this.store.emptyState);
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]] = {};
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;
1227
1227
  }
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;
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
+ }
1241
1247
  }
1242
- }
1243
- });
1248
+ });
1249
+ }
1244
1250
  var newMapping = _this.getDataBindMapping(dataCode);
1245
1251
  if (newMapping) {
1246
1252
  var _newMapping_fields;