@byteluck-fe/model-driven-engine 2.7.0-beta → 2.7.0-beta.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.
@@ -481,7 +481,6 @@ var Engine = /*#__PURE__*/ function(Watcher) {
481
481
  }
482
482
  // @ts-ignore
483
483
  if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE)) {
484
- var _newValue;
485
484
  if (newValue === null) {
486
485
  return [];
487
486
  }
@@ -496,7 +495,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
496
495
  }, {});
497
496
  // @ts-ignore
498
497
  var emptyState = this.getEmptyState(instance.id);
499
- return (_newValue = newValue) === null || _newValue === void 0 ? void 0 : _newValue.map(function(row) {
498
+ return newValue === null || newValue === void 0 ? void 0 : newValue.map(function(row) {
500
499
  return(// @ts-ignore
501
500
  checkerSubtableValue(fieldTypeMap, row, emptyState));
502
501
  });
@@ -1252,20 +1251,17 @@ var Engine = /*#__PURE__*/ function(Watcher) {
1252
1251
  }
1253
1252
  var newMapping = _this.getDataBindMapping(dataCode);
1254
1253
  if (newMapping) {
1255
- var _newMapping_fields, _newMapping, _newMapping1, _newMapping2, _newState, _mappingKeys;
1256
- var mappingKeys = (_newMapping = newMapping) === null || _newMapping === void 0 ? void 0 : (_newMapping_fields = _newMapping.fields) === null || _newMapping_fields === void 0 ? void 0 : _newMapping_fields.map(function(item) {
1257
- var _item;
1258
- return (_item = item) === null || _item === void 0 ? void 0 : _item.controlId;
1254
+ var _newMapping_fields;
1255
+ var mappingKeys = newMapping === null || newMapping === void 0 ? void 0 : (_newMapping_fields = newMapping.fields) === null || _newMapping_fields === void 0 ? void 0 : _newMapping_fields.map(function(item) {
1256
+ return item === null || item === void 0 ? void 0 : item.controlId;
1259
1257
  });
1260
- var mappingValue = _this.getEmptyState((_newMapping1 = newMapping) === null || _newMapping1 === void 0 ? void 0 : _newMapping1.controlId);
1258
+ var mappingValue = _this.getEmptyState(newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId);
1261
1259
  var _newState_newMapping_controlId;
1262
- var mainStateKeys = Object.keys((_newState_newMapping_controlId = (_newState = newState) === null || _newState === void 0 ? void 0 : _newState[(_newMapping2 = newMapping) === null || _newMapping2 === void 0 ? void 0 : _newMapping2.controlId]) !== null && _newState_newMapping_controlId !== void 0 ? _newState_newMapping_controlId : {});
1263
- (_mappingKeys = mappingKeys) === null || _mappingKeys === void 0 ? void 0 : _mappingKeys.forEach(function(key) {
1264
- var _newMapping;
1265
- if (!mainStateKeys.includes(key) && key !== "uid" && newState[(_newMapping = newMapping) === null || _newMapping === void 0 ? void 0 : _newMapping.controlId]) {
1260
+ 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 : {});
1261
+ mappingKeys === null || mappingKeys === void 0 ? void 0 : mappingKeys.forEach(function(key) {
1262
+ if (!mainStateKeys.includes(key) && key !== "uid" && newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId]) {
1266
1263
  if (Object.keys(newState).length) {
1267
- var _newMapping1;
1268
- Object.assign(newState[(_newMapping1 = newMapping) === null || _newMapping1 === void 0 ? void 0 : _newMapping1.controlId], _define_property({}, key, mappingValue[key]));
1264
+ Object.assign(newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId], _define_property({}, key, mappingValue[key]));
1269
1265
  } else {
1270
1266
  Object.assign(newState, _define_property({}, newMapping.controlId, _define_property({}, key, mappingValue[key])));
1271
1267
  }
@@ -208,7 +208,6 @@ var Store = /*#__PURE__*/ function() {
208
208
  {
209
209
  key: "getDataBind",
210
210
  value: function getDataBind(controlId) {
211
- var _result;
212
211
  var result = this.controlIdMapping[controlId];
213
212
  if (result) {
214
213
  return result.dataBind;
@@ -224,7 +223,7 @@ var Store = /*#__PURE__*/ function() {
224
223
  }
225
224
  }
226
225
  }
227
- return (_result = result) === null || _result === void 0 ? void 0 : _result.dataBind;
226
+ return result === null || result === void 0 ? void 0 : result.dataBind;
228
227
  }
229
228
  }
230
229
  ]);
@@ -351,9 +351,8 @@ var MoneyValueChecker = /*#__PURE__*/ function(ValueChecker) {
351
351
  key: "transform",
352
352
  value: function transform(value, oldValue) {
353
353
  if (value === undefined || value === null || value === "") {
354
- var _oldValue;
355
354
  return new AmountValue({
356
- currency: (_oldValue = oldValue) === null || _oldValue === void 0 ? void 0 : _oldValue.currency
355
+ currency: oldValue === null || oldValue === void 0 ? void 0 : oldValue.currency
357
356
  });
358
357
  }
359
358
  var result;
@@ -449,9 +448,8 @@ var CalcValueChecker = /*#__PURE__*/ function(ValueChecker) {
449
448
  key: "transform",
450
449
  value: function transform(value, oldValue) {
451
450
  if (value === undefined || value === null || value === "") {
452
- var _oldValue;
453
451
  return new CalcValue({
454
- unit: (_oldValue = oldValue) === null || _oldValue === void 0 ? void 0 : _oldValue.unit
452
+ unit: oldValue === null || oldValue === void 0 ? void 0 : oldValue.unit
455
453
  });
456
454
  }
457
455
  var result;
@@ -237,18 +237,17 @@ function flatInstanceForChildren(controls) {
237
237
  var index = Number(key);
238
238
  var isNotIndex = Number.isNaN(index);
239
239
  if (isNotIndex && prevItem) {
240
- var _prevItem, _flatChildren;
241
- var flatChildren = ((_prevItem = prevItem) === null || _prevItem === void 0 ? void 0 : _prevItem.children) ? flatInstanceForChildren(prevItem.children) : undefined;
242
- var findEndItem = (_flatChildren = flatChildren) === null || _flatChildren === void 0 ? void 0 : _flatChildren.find(function(item) {
240
+ var flatChildren = (prevItem === null || prevItem === void 0 ? void 0 : prevItem.children) ? flatInstanceForChildren(prevItem.children) : undefined;
241
+ var findEndItem = flatChildren === null || flatChildren === void 0 ? void 0 : flatChildren.find(function(item) {
243
242
  return item.id === key;
244
243
  });
245
244
  // 最后一个key可能是值对象上边的key,比如金额的amount和currency,计算公式的result和unit,所以需要判断前一个控件是不是一个表单控件,是的话就返回最后一个表单控件
246
245
  return findEndItem ? findEndItem : prevItem.controlType === CONTROL_BASE_TYPE.FORM ? prevItem : undefined;
247
246
  } else {
248
- var _prevItem_children, _prevItem1;
247
+ var _prevItem_children;
249
248
  var _prevItem_children_index;
250
249
  // 如果有children,则取children中对应的下标,没有的话一直返回prevItem
251
- return (_prevItem_children_index = (_prevItem1 = prevItem) === null || _prevItem1 === void 0 ? void 0 : (_prevItem_children = _prevItem1.children) === null || _prevItem_children === void 0 ? void 0 : _prevItem_children[index]) !== null && _prevItem_children_index !== void 0 ? _prevItem_children_index : prevItem;
250
+ 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;
252
251
  }
253
252
  }, initInstance);
254
253
  }
@@ -355,7 +355,6 @@ export var CalcPlugin = /*#__PURE__*/ function() {
355
355
  * */ // @ts-ignore
356
356
  function computedCalcValue(control) {
357
357
  var _this = this;
358
- var _oldValue, _oldValue1;
359
358
  var scriptEcho = control.props.scriptEcho;
360
359
  if (!scriptEcho || scriptEcho.length === 0) {
361
360
  return;
@@ -430,13 +429,13 @@ export var CalcPlugin = /*#__PURE__*/ function() {
430
429
  var oldValue = this.engine.getState(control.id, rowIndex);
431
430
  var result = !value || value === Infinity || value === -Infinity ? 0 : control.props.precision === "" ? value : Number(value.toFixed(control.props.precision));
432
431
  // 如果值没变的话,不触发修改
433
- if (result === ((_oldValue = oldValue) === null || _oldValue === void 0 ? void 0 : _oldValue.result)) {
432
+ if (result === (oldValue === null || oldValue === void 0 ? void 0 : oldValue.result)) {
434
433
  return;
435
434
  }
436
435
  var _oldValue_unit;
437
436
  this.engine.setState(control.id, {
438
437
  result: result,
439
- unit: (_oldValue_unit = (_oldValue1 = oldValue) === null || _oldValue1 === void 0 ? void 0 : _oldValue1.unit) !== null && _oldValue_unit !== void 0 ? _oldValue_unit : ""
438
+ unit: (_oldValue_unit = oldValue === null || oldValue === void 0 ? void 0 : oldValue.unit) !== null && _oldValue_unit !== void 0 ? _oldValue_unit : ""
440
439
  }, rowIndex);
441
440
  }
442
441
  },
@@ -11,8 +11,7 @@ export function loopFormControl(control, callback) {
11
11
  var children = item.getChildrenFormControl();
12
12
  callback(item, children);
13
13
  } else if (hasChildrenControl(item)) {
14
- var _item;
15
- loopFormControl((_item = item) === null || _item === void 0 ? void 0 : _item.children, callback);
14
+ loopFormControl(item === null || item === void 0 ? void 0 : item.children, callback);
16
15
  // @ts-ignore
17
16
  } else if (item.controlType === CONTROL_BASE_TYPE.FORM) {
18
17
  callback(item);
@@ -27,9 +26,8 @@ callback) {
27
26
  if (item.type === CONTROL_TYPE.DATA_VIEW || item.type === CONTROL_TYPE.SIMPLE_SEARCH) {
28
27
  callback(item);
29
28
  } else if (hasChildrenControl(item)) {
30
- var _item;
31
29
  // @ts-ignore
32
- loopDataViewControl((_item = item) === null || _item === void 0 ? void 0 : _item.children, callback);
30
+ loopDataViewControl(item === null || item === void 0 ? void 0 : item.children, callback);
33
31
  }
34
32
  });
35
33
  }