@byteluck-fe/model-driven-engine 2.7.0-alpha.15 → 2.7.0-alpha.16

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.
@@ -23,22 +23,22 @@ function _unsupportedIterableToArray(o, minLen) {
23
23
  if (n === "Map" || n === "Set") return Array.from(n);
24
24
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
25
25
  }
26
+ import { CONTROL_BASE_TYPE, error, logerror } from '@byteluck-fe/model-driven-shared';
26
27
  var cc = console;
27
- import { CONTROL_BASE_TYPE, error, logerror } from "@byteluck-fe/model-driven-shared";
28
28
  var proxyArrayApi = [
29
- "splice",
30
- "push",
31
- "shift",
32
- "pop",
33
- "unshift",
34
- "reverse"
29
+ 'splice',
30
+ 'push',
31
+ 'shift',
32
+ 'pop',
33
+ 'unshift',
34
+ 'reverse',
35
35
  ];
36
- export var engineProxyFlag = Symbol("__engineProxy__");
37
- export var engineTargetKey = Symbol("__engineTarget__");
38
- export var engineArrayBeforeSetCallbackFlag = Symbol("__engineArrayBeforeSetCallbackFlag__");
39
- export var engineProxyThisKey = Symbol("__engineProxyThisKey__");
36
+ export var engineProxyFlag = Symbol('__engineProxy__');
37
+ export var engineTargetKey = Symbol('__engineTarget__');
38
+ export var engineArrayBeforeSetCallbackFlag = Symbol('__engineArrayBeforeSetCallbackFlag__');
39
+ export var engineProxyThisKey = Symbol('__engineProxyThisKey__');
40
40
  var currentHandlerState = {
41
- type: "",
41
+ type: '',
42
42
  args: [],
43
43
  callback: emptyFn
44
44
  };
@@ -55,16 +55,16 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
55
55
  // 操作下标
56
56
  // Number(propertyKey) > target.length 说明当前操作的下标已经超过了安全范围(数组的运行长度,比如[1,2,3],它的长度为3,可操作的下标为0,1,2,3,如果操作4将会产生一个empty index)
57
57
  if (index > target.length) {
58
- error("Wrong array operations may cause unknown errors. It is recommended to use APIs such as ".concat(proxyArrayApi.join(","), " for array operations"));
58
+ error("Wrong array operations may cause unknown errors. It is recommended to use APIs such as ".concat(proxyArrayApi.join(','), " for array operations"));
59
59
  return;
60
60
  }
61
61
  // 不是操作下标,而是直接操作length或者自定义属性等
62
62
  var isNotHandlerIndex = Number.isNaN(index);
63
- if (isNotHandlerIndex && propertyKey !== "length") {
63
+ if (isNotHandlerIndex && propertyKey !== 'length') {
64
64
  return;
65
65
  }
66
66
  // 直接操作length
67
- if (propertyKey === "length") {
67
+ if (propertyKey === 'length') {
68
68
  var newLength = value;
69
69
  var oldLength = target.length;
70
70
  if (newLength > target.length) {
@@ -76,9 +76,9 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
76
76
  }
77
77
  // 通过操作length删除旧的行
78
78
  return function() {
79
- return callback.call(null, target, thisKey, "splice", [
79
+ return callback.call(null, target, thisKey, 'splice', [
80
80
  newLength,
81
- oldLength - newLength
81
+ oldLength - newLength,
82
82
  ]);
83
83
  };
84
84
  // 直接操作下标
@@ -86,13 +86,13 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
86
86
  // 正常操作
87
87
  if (index === target.length) {
88
88
  return function() {
89
- return callback.call(null, target, thisKey, "push", [
89
+ return callback.call(null, target, thisKey, 'push', [
90
90
  value
91
91
  ]);
92
92
  };
93
93
  } else {
94
94
  return function() {
95
- return callback.call(null, target, thisKey, "splice", [
95
+ return callback.call(null, target, thisKey, 'splice', [
96
96
  index,
97
97
  1,
98
98
  value
@@ -124,9 +124,9 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
124
124
  }
125
125
  return Reflect.get(target, propertyKey, receiver);
126
126
  },
127
- set: function set(target, propertyKey, value, receiver) {
127
+ set: function set(target, propertyKey, value1, receiver) {
128
128
  var reProxyState = function reProxyState(value) {
129
- if (typeof value === "object" && value !== null) {
129
+ if (typeof value === 'object' && value !== null) {
130
130
  // @ts-ignore
131
131
  if (value[engineProxyFlag] !== true) {
132
132
  return proxyState(value, callback, beforeSetCallback, concatKey);
@@ -137,19 +137,19 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
137
137
  }
138
138
  }
139
139
  };
140
- var newValue = value;
140
+ var newValue = value1;
141
141
  // @ts-ignore
142
142
  var oldValue = target[propertyKey];
143
- var concatKey = thisKey === "" ? propertyKey : thisKey + "." + propertyKey;
144
- var _reProxyState;
145
- newValue = (_reProxyState = reProxyState(value)) !== null && _reProxyState !== void 0 ? _reProxyState : newValue;
143
+ var concatKey = thisKey === '' ? propertyKey : thisKey + '.' + propertyKey;
144
+ var ref;
145
+ newValue = (ref = reProxyState(value1)) !== null && ref !== void 0 ? ref : newValue;
146
146
  // 先设置值,然后再进行触发回调,确保回调内拿到的是最新的值
147
147
  var setResult;
148
148
  // TODO 数组拦截操作需要重构,优化现有逻辑
149
149
  // TODO 直接操作下标改动明细表时,没有对行数据进行checker
150
150
  if (Array.isArray(target)) {
151
151
  // 操作数组的时候,不需要使用拼接的thisKey,先判断执行的是否是违规操作,违规操作的话会报错,不允许继续执行,正常操作的话,返回一个回调函数,用于在值修改完之后触发
152
- var nextHandler = ArrayHandler(target, propertyKey, value, thisKey, callback);
152
+ var nextHandler = ArrayHandler(target, propertyKey, value1, thisKey, callback);
153
153
  setResult = Reflect.set(target, propertyKey, newValue, receiver);
154
154
  if (nextHandler) {
155
155
  nextHandler();
@@ -171,7 +171,7 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
171
171
  return true;
172
172
  }
173
173
  setResult = Reflect.set(target, propertyKey, newValue, receiver);
174
- callback.call(null, target, concatKey, value, oldValue);
174
+ callback.call(null, target, concatKey, value1, oldValue);
175
175
  }
176
176
  return setResult;
177
177
  }
@@ -184,15 +184,15 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
184
184
  * @param beforeSetCallback
185
185
  * @param prevKey 递归对象的key
186
186
  * */ export function proxyState(state, callback, beforeSetCallback) {
187
- var prevKey = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : "";
187
+ var prevKey = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : '';
188
188
  // 冻结的对象不需要再执行proxy,否则会报错
189
189
  if (Object.isFrozen(state)) {
190
190
  return state;
191
191
  }
192
192
  for(var key in state){
193
- var concatKey = prevKey === "" ? key : prevKey + "." + key;
193
+ var concatKey = prevKey === '' ? key : prevKey + '.' + key;
194
194
  var obj = state[key];
195
- if (typeof obj === "object" && obj !== null) {
195
+ if (typeof obj === 'object' && obj !== null) {
196
196
  // @ts-ignore
197
197
  state[key] = proxyState(obj, callback, beforeSetCallback, concatKey);
198
198
  }
@@ -203,7 +203,7 @@ function flatInstanceForChildren(controls) {
203
203
  var result = [];
204
204
  controls.forEach(function(item) {
205
205
  result.push(item);
206
- if (item.controlType === "layout" || item.controlType === "wrap") {
206
+ if (item.controlType === 'layout' || item.controlType === 'wrap') {
207
207
  var _result;
208
208
  (_result = result).push.apply(_result, _toConsumableArray(flatInstanceForChildren(item.children)));
209
209
  }
@@ -214,9 +214,9 @@ function flatInstanceForChildren(controls) {
214
214
  * 在flatInstance中通过key查找出对应的instance
215
215
  * @param flatInstance 拍平的instance数组
216
216
  * @param key 操作的数据在state的key - 可以是深层次的 subtable.0.input等
217
- * */ export function findItem(flatInstance, key, instanceMap) {
218
- if (key === "") return undefined;
219
- var keys = key.split(".");
217
+ * */ export function findItem(flatInstance, key1, instanceMap) {
218
+ if (key1 === '') return undefined;
219
+ var keys = key1.split('.');
220
220
  if (keys.length === 0) return undefined;
221
221
  var oneKey = keys[0];
222
222
  var otherKeys = keys.slice(1);
@@ -242,31 +242,31 @@ function flatInstanceForChildren(controls) {
242
242
  // 最后一个key可能是值对象上边的key,比如金额的amount和currency,计算公式的result和unit,所以需要判断前一个控件是不是一个表单控件,是的话就返回最后一个表单控件
243
243
  return findEndItem ? findEndItem : prevItem.controlType === CONTROL_BASE_TYPE.FORM ? prevItem : undefined;
244
244
  } else {
245
- var _prevItem_children;
246
- var _prevItem_children_index;
245
+ var ref;
246
+ var ref1;
247
247
  // 如果有children,则取children中对应的下标,没有的话一直返回prevItem
248
- 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;
248
+ return (ref1 = prevItem === null || prevItem === void 0 ? void 0 : (ref = prevItem.children) === null || ref === void 0 ? void 0 : ref[index]) !== null && ref1 !== void 0 ? ref1 : prevItem;
249
249
  }
250
250
  }, initInstance);
251
251
  }
252
252
  function getArrayNewValue(type, args) {
253
253
  if ([
254
- "push",
255
- "unshift"
254
+ 'push',
255
+ 'unshift'
256
256
  ].includes(type)) {
257
257
  return args;
258
- } else if (type === "splice") {
258
+ } else if (type === 'splice') {
259
259
  return args.slice(2);
260
260
  }
261
261
  return [];
262
262
  }
263
263
  function getArrayNewArgs(type, args, value) {
264
264
  if ([
265
- "push",
266
- "unshift"
265
+ 'push',
266
+ 'unshift'
267
267
  ].includes(type)) {
268
268
  return value;
269
- } else if (type === "splice") {
269
+ } else if (type === 'splice') {
270
270
  return args.slice(0, 2).concat(value);
271
271
  }
272
272
  }
@@ -285,9 +285,9 @@ function getArrayNewArgs(type, args, value) {
285
285
  var result;
286
286
  var addValue = getArrayNewValue(key, args);
287
287
  if (addValue.length) {
288
- var _this, _this_engineArrayBeforeSetCallbackFlag;
288
+ var _obj, ref;
289
289
  // @ts-ignore
290
- var newValue = (_this_engineArrayBeforeSetCallbackFlag = (_this = this)[engineArrayBeforeSetCallbackFlag]) === null || _this_engineArrayBeforeSetCallbackFlag === void 0 ? void 0 : _this_engineArrayBeforeSetCallbackFlag.call(_this, // @ts-ignore
290
+ var newValue = (ref = (_obj = this)[engineArrayBeforeSetCallbackFlag]) === null || ref === void 0 ? void 0 : ref.call(_obj, // @ts-ignore
291
291
  this[engineTargetKey], // @ts-ignore
292
292
  this[engineProxyThisKey], addValue);
293
293
  var newArgs = getArrayNewArgs(key, args, newValue);
@@ -301,8 +301,8 @@ function getArrayNewArgs(type, args, value) {
301
301
  // @ts-ignore
302
302
  result = oldApiHandler.apply(this, args);
303
303
  }
304
- typeof currentHandlerState.callback === "function" && currentHandlerState.callback(key, args, result);
305
- currentHandlerState.type = "";
304
+ typeof currentHandlerState.callback === 'function' && currentHandlerState.callback(key, args, result);
305
+ currentHandlerState.type = '';
306
306
  currentHandlerState.args = [];
307
307
  currentHandlerState.callback = emptyFn;
308
308
  return result;
package/dist/esm/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export * from "./common";
2
- export * from "./plugins";
3
- export * from "./utils";
1
+ export * from './common';
2
+ export * from './plugins';
3
+ export * from './utils';
@@ -25,19 +25,6 @@ function _createClass(Constructor, protoProps, staticProps) {
25
25
  if (staticProps) _defineProperties(Constructor, staticProps);
26
26
  return Constructor;
27
27
  }
28
- function _defineProperty(obj, key, value) {
29
- if (key in obj) {
30
- Object.defineProperty(obj, key, {
31
- value: value,
32
- enumerable: true,
33
- configurable: true,
34
- writable: true
35
- });
36
- } else {
37
- obj[key] = value;
38
- }
39
- return obj;
40
- }
41
28
  function _iterableToArray(iter) {
42
29
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
43
30
  }
@@ -55,8 +42,8 @@ function _unsupportedIterableToArray(o, minLen) {
55
42
  if (n === "Map" || n === "Set") return Array.from(n);
56
43
  if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
57
44
  }
58
- import { CONTROL_TYPE, CALC_TOKEN_TYPE, CALC_AGGREGATE_TYPE } from "@byteluck-fe/model-driven-shared";
59
- import { format } from "mathjs";
45
+ import { CONTROL_TYPE, CALC_TOKEN_TYPE, CALC_AGGREGATE_TYPE } from '@byteluck-fe/model-driven-shared';
46
+ import { format } from 'mathjs';
60
47
  var DisplayType;
61
48
  (function(DisplayType) {
62
49
  DisplayType[/**
@@ -70,21 +57,19 @@ export var CalcPlugin = /*#__PURE__*/ function() {
70
57
  "use strict";
71
58
  function CalcPlugin(options) {
72
59
  _classCallCheck(this, CalcPlugin);
73
- _defineProperty(this, "engine", void 0);
74
- _defineProperty(this, "options", void 0);
75
60
  /**
76
61
  * 所有的计算公式控件
77
62
  * */ // @ts-ignore
78
- _defineProperty(this, "calcControls", []);
63
+ this.calcControls = [];
79
64
  /**
80
65
  * key=控件id value=控件修改后需要触发重新计算的计算公式控件组成的数组
81
66
  * 存储为一个Map,用于在控件change的时候,重新计算依赖的calc
82
- * */ _defineProperty(this, "dependenciesTriggerMap", new Map());
67
+ * */ this.dependenciesTriggerMap = new Map();
83
68
  /**
84
69
  * 隐藏以后需要被计算的控件
85
- * */ _defineProperty(this, "hideNotRememberControlIds", []);
86
- _defineProperty(this, "dontHasPermissionControlIds", []);
87
- _defineProperty(this, "cacheComputedResult", {});
70
+ * */ this.hideNotRememberControlIds = [];
71
+ this.dontHasPermissionControlIds = [];
72
+ this.cacheComputedResult = {};
88
73
  this.options = options;
89
74
  this.getDontHasPermissionControlIds();
90
75
  this.getNeedHideRememberControlIds();
@@ -95,8 +80,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
95
80
  value: /**
96
81
  * @description 获取显隐控制的需要被记住值的控件id
97
82
  * */ function getNeedHideRememberControlIds() {
98
- var _this_options;
99
- if (!((_this_options = this.options) === null || _this_options === void 0 ? void 0 : _this_options.displayBoList)) {
83
+ var ref;
84
+ if (!((ref = this.options) === null || ref === void 0 ? void 0 : ref.displayBoList)) {
100
85
  return;
101
86
  }
102
87
  this.hideNotRememberControlIds = this.options.displayBoList.reduce(function(result, current) {
@@ -113,8 +98,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
113
98
  value: /**
114
99
  * @description 获取权限控制的隐藏的字段,不需要参与计算
115
100
  * */ function getDontHasPermissionControlIds() {
116
- var _this_options;
117
- if (!((_this_options = this.options) === null || _this_options === void 0 ? void 0 : _this_options.behavior)) {
101
+ var ref;
102
+ if (!((ref = this.options) === null || ref === void 0 ? void 0 : ref.behavior)) {
118
103
  return;
119
104
  }
120
105
  this.dontHasPermissionControlIds = this.options.behavior.reduce(function(result, current) {
@@ -171,7 +156,7 @@ export var CalcPlugin = /*#__PURE__*/ function() {
171
156
  this.watchControlChange();
172
157
  this.watchSubtableChange();
173
158
  this.watchSchemaHideChange();
174
- this.engine.on("engine-mounted", function() {
159
+ this.engine.on('engine-mounted', function() {
175
160
  _this.allCalcControlComputed();
176
161
  });
177
162
  }
@@ -216,15 +201,16 @@ export var CalcPlugin = /*#__PURE__*/ function() {
216
201
  * */ function getCalcDependencies() {
217
202
  var _this = this;
218
203
  this.calcControls.forEach(function(item) {
204
+ var _this1 = _this;
219
205
  var scriptEcho = item.props.scriptEcho;
220
206
  scriptEcho.forEach(function(scriptItem) {
221
207
  if (scriptItem.type === CALC_TOKEN_TYPE.VariableInMainTable || scriptItem.type === CALC_TOKEN_TYPE.VariableInCurrentSubTable || scriptItem.type === CALC_TOKEN_TYPE.VariableInOtherSubTable) {
222
208
  // 当前是一个变量,存储依赖于当前变量的计算公式
223
- _this.setDependenciesTriggerMapItem(scriptItem.id, item);
209
+ _this1.setDependenciesTriggerMapItem(scriptItem.id, item);
224
210
  }
225
211
  // 依赖明细子表的计算公式控件,不收集自己表内的,而是主表或者其他明细子表的控件
226
212
  if (scriptItem.type === CALC_TOKEN_TYPE.VariableInOtherSubTable && scriptItem.subTableId) {
227
- _this.setDependenciesTriggerMapItem(scriptItem.subTableId, item);
213
+ _this1.setDependenciesTriggerMapItem(scriptItem.subTableId, item);
228
214
  }
229
215
  });
230
216
  });
@@ -249,11 +235,12 @@ export var CalcPlugin = /*#__PURE__*/ function() {
249
235
  subtableRows) {
250
236
  var _this = this;
251
237
  return subtableRows.reduce(function(result, current) {
238
+ var _this2 = _this;
252
239
  // @ts-ignore
253
240
  current.children.forEach(function(item) {
254
241
  var control = item.children[0];
255
242
  // @ts-ignore
256
- if (control && _this.engine.assertInstance(control, CONTROL_TYPE.CALC)) {
243
+ if (control && _this2.engine.assertInstance(control, CONTROL_TYPE.CALC)) {
257
244
  result.push(control);
258
245
  }
259
246
  });
@@ -268,12 +255,13 @@ export var CalcPlugin = /*#__PURE__*/ function() {
268
255
  * @description 监听控件的显隐事件,把显隐会影响的控件触发一遍计算
269
256
  * */ function watchSchemaHideChange() {
270
257
  var _this = this;
271
- this.engine.on("schema-change", function(payload) {
272
- if (payload.props === "isHide") {
273
- var _this_dependenciesTriggerMap_get;
274
- var calcControls = (_this_dependenciesTriggerMap_get = _this.dependenciesTriggerMap.get(payload.instance.id)) !== null && _this_dependenciesTriggerMap_get !== void 0 ? _this_dependenciesTriggerMap_get : [];
258
+ this.engine.on('schema-change', function(payload) {
259
+ if (payload.props === 'isHide') {
260
+ var _this3 = _this;
261
+ var ref;
262
+ var calcControls = (ref = _this.dependenciesTriggerMap.get(payload.instance.id)) !== null && ref !== void 0 ? ref : [];
275
263
  calcControls.forEach(function(calc) {
276
- _this.computedCalcValue(calc);
264
+ _this3.computedCalcValue(calc);
277
265
  });
278
266
  }
279
267
  });
@@ -285,22 +273,23 @@ export var CalcPlugin = /*#__PURE__*/ function() {
285
273
  * @description 监听明细子表的change事件,把明细表会影响的控件触发一遍计算
286
274
  * */ function watchSubtableChange() {
287
275
  var _this = this;
288
- this.engine.on("list-change", function(payload) {
289
- var _payload_options;
276
+ this.engine.on('list-change', function(payload) {
277
+ var _this5 = _this;
278
+ var ref;
290
279
  _this.resetDependencies();
291
- var _payload_options_changed;
292
- var changedRows = (_payload_options_changed = (_payload_options = payload.options) === null || _payload_options === void 0 ? void 0 : _payload_options.changed) !== null && _payload_options_changed !== void 0 ? _payload_options_changed : [];
280
+ var ref1;
281
+ var changedRows = (ref1 = (ref = payload.options) === null || ref === void 0 ? void 0 : ref.changed) !== null && ref1 !== void 0 ? ref1 : [];
293
282
  // 对发生改变的行进行重新计算
294
283
  var changedCalc = _this.getCalcControlsFromSubtableRows(changedRows);
295
284
  // @ts-ignore
296
285
  changedCalc.forEach(function(calcControl) {
297
- _this.computedCalcValue(calcControl);
286
+ _this5.computedCalcValue(calcControl);
298
287
  });
299
- var _this_dependenciesTriggerMap_get;
300
- var calcControls = (_this_dependenciesTriggerMap_get = _this.dependenciesTriggerMap.get(payload.instance.id)) !== null && _this_dependenciesTriggerMap_get !== void 0 ? _this_dependenciesTriggerMap_get : [];
288
+ var ref2;
289
+ var calcControls = (ref2 = _this.dependenciesTriggerMap.get(payload.instance.id)) !== null && ref2 !== void 0 ? ref2 : [];
301
290
  // @ts-ignore
302
291
  calcControls.forEach(function(calcControl) {
303
- _this.computedCalcValue(calcControl);
292
+ _this5.computedCalcValue(calcControl);
304
293
  });
305
294
  });
306
295
  }
@@ -311,29 +300,31 @@ export var CalcPlugin = /*#__PURE__*/ function() {
311
300
  * @description 监听控件的change事件,当控件change的时候,取到控件会影响的计算公式,然后执行对应的计算
312
301
  * */ function watchControlChange() {
313
302
  var _this = this;
314
- this.engine.on("change", function(payload) {
303
+ this.engine.on('change', function(payload) {
315
304
  var instance = payload.instance;
316
305
  if (!_this.dependenciesTriggerMap.has(instance.id)) {
317
306
  return;
318
307
  }
319
- var _this_dependenciesTriggerMap_get;
320
- var calcControls = (_this_dependenciesTriggerMap_get = _this.dependenciesTriggerMap.get(instance.id)) !== null && _this_dependenciesTriggerMap_get !== void 0 ? _this_dependenciesTriggerMap_get : [];
308
+ var ref;
309
+ var calcControls = (ref = _this.dependenciesTriggerMap.get(instance.id)) !== null && ref !== void 0 ? ref : [];
321
310
  // 在明细子表中的控件,如果计算公式也在明细子表,那只触发同一行的计算公式的计算
322
311
  if (payload.rowIndex !== undefined && payload.rowIndex > -1) {
312
+ var _this7 = _this;
323
313
  // @ts-ignore
324
314
  calcControls.forEach(function(calcControl) {
325
- if (_this.controlInSubtable(calcControl)) {
326
- var calcIndex = _this.engine.getInstanceRowIndex(calcControl);
315
+ if (_this7.controlInSubtable(calcControl)) {
316
+ var calcIndex = _this7.engine.getInstanceRowIndex(calcControl);
327
317
  if (calcIndex !== payload.rowIndex) {
328
318
  return;
329
319
  }
330
320
  }
331
- _this.computedCalcValue(calcControl);
321
+ _this7.computedCalcValue(calcControl);
332
322
  });
333
323
  } else {
324
+ var _this6 = _this;
334
325
  // @ts-ignore
335
326
  calcControls.forEach(function(calcControl) {
336
- _this.computedCalcValue(calcControl);
327
+ _this6.computedCalcValue(calcControl);
337
328
  });
338
329
  }
339
330
  });
@@ -344,8 +335,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
344
335
  value: /**
345
336
  * @description 控件在明细子表内
346
337
  * */ function controlInSubtable(control) {
347
- var _control_parent;
348
- return ((_control_parent = control.parent) === null || _control_parent === void 0 ? void 0 : _control_parent.type) === CONTROL_TYPE.SUBTABLE_COLUMN;
338
+ var ref;
339
+ return ((ref = control.parent) === null || ref === void 0 ? void 0 : ref.type) === CONTROL_TYPE.SUBTABLE_COLUMN;
349
340
  }
350
341
  },
351
342
  {
@@ -389,9 +380,10 @@ export var CalcPlugin = /*#__PURE__*/ function() {
389
380
  }
390
381
  case CALC_TOKEN_TYPE.VariableInOtherSubTable:
391
382
  {
383
+ var _this8 = _this;
392
384
  var states = _this.engine.getState(current.id);
393
385
  var values = Array.isArray(states) ? states.map(function(item) {
394
- return _this.getNumberValue(item);
386
+ return _this8.getNumberValue(item);
395
387
  }) : [];
396
388
  var value2 = _this.getAggregateTypeValue(values, current.aggregateType);
397
389
  instance = _this.engine.getInstance(current.subTableId);
@@ -406,17 +398,17 @@ export var CalcPlugin = /*#__PURE__*/ function() {
406
398
  result += 0;
407
399
  }
408
400
  return result;
409
- }, "");
410
- var value;
401
+ }, '');
402
+ var value3;
411
403
  // 有缓存的话取缓存,没有缓存再执行eval
412
404
  if (this.cacheComputedResult[scriptText] !== undefined) {
413
- value = this.cacheComputedResult[scriptText];
405
+ value3 = this.cacheComputedResult[scriptText];
414
406
  } else {
415
407
  // 解决js精准度问题
416
- value = Number(format(new Function("return ".concat(scriptText))(), {
408
+ value3 = Number(format(new Function("return ".concat(scriptText))(), {
417
409
  precision: 16
418
410
  }));
419
- this.cacheComputedResult[scriptText] = value;
411
+ this.cacheComputedResult[scriptText] = value3;
420
412
  }
421
413
  // let rowIndex = undefined
422
414
  if (this.controlInSubtable(control)) {
@@ -427,15 +419,15 @@ export var CalcPlugin = /*#__PURE__*/ function() {
427
419
  }
428
420
  }
429
421
  var oldValue = this.engine.getState(control.id, rowIndex);
430
- var result = !value || value === Infinity || value === -Infinity ? 0 : control.props.precision === "" ? value : Number(value.toFixed(control.props.precision));
422
+ var result1 = !value3 || value3 === Infinity || value3 === -Infinity ? 0 : control.props.precision === '' ? value3 : Number(value3.toFixed(control.props.precision));
431
423
  // 如果值没变的话,不触发修改
432
- if (result === (oldValue === null || oldValue === void 0 ? void 0 : oldValue.result)) {
424
+ if (result1 === (oldValue === null || oldValue === void 0 ? void 0 : oldValue.result)) {
433
425
  return;
434
426
  }
435
- var _oldValue_unit;
427
+ var ref;
436
428
  this.engine.setState(control.id, {
437
- result: result,
438
- unit: (_oldValue_unit = oldValue === null || oldValue === void 0 ? void 0 : oldValue.unit) !== null && _oldValue_unit !== void 0 ? _oldValue_unit : ""
429
+ result: result1,
430
+ unit: (ref = oldValue === null || oldValue === void 0 ? void 0 : oldValue.unit) !== null && ref !== void 0 ? ref : ''
439
431
  }, rowIndex);
440
432
  }
441
433
  },
@@ -444,14 +436,14 @@ export var CalcPlugin = /*#__PURE__*/ function() {
444
436
  value: /**
445
437
  * @description 获取数字值,因为计算公式可以依赖计算公式和金额,所以需要从value中取到对应的值
446
438
  * */ function getNumberValue(value) {
447
- if (typeof value === "object" && value) {
448
- if ("result" in value) {
439
+ if (typeof value === 'object' && value) {
440
+ if ('result' in value) {
449
441
  return value.result;
450
- } else if ("amount" in value) {
442
+ } else if ('amount' in value) {
451
443
  return value.amount;
452
444
  }
453
445
  }
454
- if (typeof value === "number") {
446
+ if (typeof value === 'number') {
455
447
  return value;
456
448
  }
457
449
  return 0;