@byteluck-fe/model-driven-engine 2.8.2-beta.1 → 2.8.2-beta.13
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.
- package/README.md +30 -30
- package/dist/esm/common/ActionManager.js +10 -9
- package/dist/esm/common/DataManager.js +2 -2
- package/dist/esm/common/Engine.js +120 -146
- package/dist/esm/common/OkWorker.js +8 -8
- package/dist/esm/common/Runtime.js +29 -45
- package/dist/esm/common/Store.js +16 -13
- package/dist/esm/common/checkerValue.js +39 -59
- package/dist/esm/common/index.js +2 -2
- package/dist/esm/common/proxyState.js +56 -52
- package/dist/esm/index.js +3 -3
- package/dist/esm/plugins/CalcPlugin.js +61 -57
- package/dist/esm/plugins/ControlsEventPlugin.js +4 -4
- package/dist/esm/plugins/ES6ModulePlugin.js +6 -6
- package/dist/esm/plugins/LifecycleEventPlugin.js +7 -6
- package/dist/esm/plugins/StylePlugin.js +14 -13
- package/dist/esm/plugins/index.js +5 -5
- package/dist/esm/utils/index.js +1 -1
- package/dist/esm/utils/runtimeUtils.js +4 -4
- package/dist/index.umd.js +6 -11
- package/dist/types/common/ActionManager.d.ts +14 -14
- package/dist/types/common/DataManager.d.ts +10 -10
- package/dist/types/common/Engine.d.ts +194 -194
- package/dist/types/common/OkWorker.d.ts +13 -13
- package/dist/types/common/Plugin.d.ts +6 -6
- package/dist/types/common/Runtime.d.ts +31 -31
- package/dist/types/common/Store.d.ts +54 -54
- package/dist/types/common/checkerValue.d.ts +3 -3
- package/dist/types/common/index.d.ts +2 -2
- package/dist/types/common/proxyState.d.ts +30 -30
- package/dist/types/index.d.ts +3 -3
- package/dist/types/plugins/CalcPlugin.d.ts +121 -121
- package/dist/types/plugins/ControlsEventPlugin.d.ts +15 -15
- package/dist/types/plugins/ES6ModulePlugin.d.ts +27 -27
- package/dist/types/plugins/LifecycleEventPlugin.d.ts +15 -14
- package/dist/types/plugins/StylePlugin.d.ts +12 -12
- package/dist/types/plugins/index.d.ts +5 -5
- package/dist/types/utils/index.d.ts +1 -1
- package/dist/types/utils/runtimeUtils.d.ts +5 -5
- package/package.json +4 -4
|
@@ -15,6 +15,10 @@ function _non_iterable_spread() {
|
|
|
15
15
|
function _to_consumable_array(arr) {
|
|
16
16
|
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
17
17
|
}
|
|
18
|
+
function _type_of(obj) {
|
|
19
|
+
"@swc/helpers - typeof";
|
|
20
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
21
|
+
}
|
|
18
22
|
function _unsupported_iterable_to_array(o, minLen) {
|
|
19
23
|
if (!o) return;
|
|
20
24
|
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
@@ -24,21 +28,21 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
24
28
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
25
29
|
}
|
|
26
30
|
var cc = console;
|
|
27
|
-
import { CONTROL_BASE_TYPE, error, logerror, JSONCopy } from
|
|
31
|
+
import { CONTROL_BASE_TYPE, error, logerror, JSONCopy } from '@byteluck-fe/model-driven-shared';
|
|
28
32
|
var proxyArrayApi = [
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
'splice',
|
|
34
|
+
'push',
|
|
35
|
+
'shift',
|
|
36
|
+
'pop',
|
|
37
|
+
'unshift',
|
|
38
|
+
'reverse'
|
|
35
39
|
];
|
|
36
|
-
export var engineProxyFlag = Symbol(
|
|
37
|
-
export var engineTargetKey = Symbol(
|
|
38
|
-
export var engineArrayBeforeSetCallbackFlag = Symbol(
|
|
39
|
-
export var engineProxyThisKey = Symbol(
|
|
40
|
+
export var engineProxyFlag = Symbol('__engineProxy__');
|
|
41
|
+
export var engineTargetKey = Symbol('__engineTarget__');
|
|
42
|
+
export var engineArrayBeforeSetCallbackFlag = Symbol('__engineArrayBeforeSetCallbackFlag__');
|
|
43
|
+
export var engineProxyThisKey = Symbol('__engineProxyThisKey__');
|
|
40
44
|
var currentHandlerState = {
|
|
41
|
-
type:
|
|
45
|
+
type: '',
|
|
42
46
|
args: [],
|
|
43
47
|
callback: emptyFn
|
|
44
48
|
};
|
|
@@ -55,16 +59,16 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
|
|
|
55
59
|
// 操作下标
|
|
56
60
|
// Number(propertyKey) > target.length 说明当前操作的下标已经超过了安全范围(数组的运行长度,比如[1,2,3],它的长度为3,可操作的下标为0,1,2,3,如果操作4将会产生一个empty index)
|
|
57
61
|
if (index > target.length) {
|
|
58
|
-
error("Wrong array operations may cause unknown errors. It is recommended to use APIs such as ".concat(proxyArrayApi.join(
|
|
62
|
+
error("Wrong array operations may cause unknown errors. It is recommended to use APIs such as ".concat(proxyArrayApi.join(','), " for array operations"));
|
|
59
63
|
return;
|
|
60
64
|
}
|
|
61
65
|
// 不是操作下标,而是直接操作length或者自定义属性等
|
|
62
66
|
var isNotHandlerIndex = Number.isNaN(index);
|
|
63
|
-
if (isNotHandlerIndex && propertyKey !==
|
|
67
|
+
if (isNotHandlerIndex && propertyKey !== 'length') {
|
|
64
68
|
return;
|
|
65
69
|
}
|
|
66
70
|
// 直接操作length
|
|
67
|
-
if (propertyKey ===
|
|
71
|
+
if (propertyKey === 'length') {
|
|
68
72
|
var newLength = value;
|
|
69
73
|
var oldLength = target.length;
|
|
70
74
|
if (newLength > target.length) {
|
|
@@ -76,7 +80,7 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
|
|
|
76
80
|
}
|
|
77
81
|
// 通过操作length删除旧的行
|
|
78
82
|
return function() {
|
|
79
|
-
return callback.call(null, target, thisKey,
|
|
83
|
+
return callback.call(null, target, thisKey, 'splice', [
|
|
80
84
|
newLength,
|
|
81
85
|
oldLength - newLength
|
|
82
86
|
]);
|
|
@@ -86,13 +90,13 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
|
|
|
86
90
|
// 正常操作
|
|
87
91
|
if (index === target.length) {
|
|
88
92
|
return function() {
|
|
89
|
-
return callback.call(null, target, thisKey,
|
|
93
|
+
return callback.call(null, target, thisKey, 'push', [
|
|
90
94
|
value
|
|
91
95
|
]);
|
|
92
96
|
};
|
|
93
97
|
} else {
|
|
94
98
|
return function() {
|
|
95
|
-
return callback.call(null, target, thisKey,
|
|
99
|
+
return callback.call(null, target, thisKey, 'splice', [
|
|
96
100
|
index,
|
|
97
101
|
1,
|
|
98
102
|
value
|
|
@@ -101,11 +105,11 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
|
|
|
101
105
|
}
|
|
102
106
|
}
|
|
103
107
|
}
|
|
104
|
-
/**
|
|
105
|
-
* 返回proxy操作对象
|
|
106
|
-
* @param thisKey 当前对象在上级中的key
|
|
107
|
-
* @param callback 需要在修改的时候,触发的回调函数
|
|
108
|
-
* @param beforeSetCallback 需要在修改之前触发的回调函数,可以进行校验和对值的修改等等,最终的返回值不为undefined就会使用
|
|
108
|
+
/**
|
|
109
|
+
* 返回proxy操作对象
|
|
110
|
+
* @param thisKey 当前对象在上级中的key
|
|
111
|
+
* @param callback 需要在修改的时候,触发的回调函数
|
|
112
|
+
* @param beforeSetCallback 需要在修改之前触发的回调函数,可以进行校验和对值的修改等等,最终的返回值不为undefined就会使用
|
|
109
113
|
* */ function handler(thisKey, callback, beforeSetCallback) {
|
|
110
114
|
return {
|
|
111
115
|
__engineProxy__: true,
|
|
@@ -128,9 +132,9 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
|
|
|
128
132
|
var newValue = JSONCopy(value);
|
|
129
133
|
// @ts-ignore
|
|
130
134
|
var oldValue = target[propertyKey];
|
|
131
|
-
var concatKey = thisKey ===
|
|
135
|
+
var concatKey = thisKey === '' ? propertyKey : thisKey + '.' + propertyKey;
|
|
132
136
|
function reProxyState(value) {
|
|
133
|
-
if (typeof value === "
|
|
137
|
+
if ((typeof value === "undefined" ? "undefined" : _type_of(value)) === 'object' && value !== null) {
|
|
134
138
|
// @ts-ignore
|
|
135
139
|
if (value[engineProxyFlag] !== true) {
|
|
136
140
|
return proxyState(value, callback, beforeSetCallback, concatKey);
|
|
@@ -179,22 +183,22 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
|
|
|
179
183
|
}
|
|
180
184
|
};
|
|
181
185
|
}
|
|
182
|
-
/**
|
|
183
|
-
* 代理state数据
|
|
184
|
-
* @param state 数据对象
|
|
185
|
-
* @param callback 触发set时候的回调函数
|
|
186
|
-
* @param beforeSetCallback
|
|
187
|
-
* @param prevKey 递归对象的key
|
|
186
|
+
/**
|
|
187
|
+
* 代理state数据
|
|
188
|
+
* @param state 数据对象
|
|
189
|
+
* @param callback 触发set时候的回调函数
|
|
190
|
+
* @param beforeSetCallback
|
|
191
|
+
* @param prevKey 递归对象的key
|
|
188
192
|
* */ export function proxyState(state, callback, beforeSetCallback) {
|
|
189
|
-
var prevKey = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] :
|
|
193
|
+
var prevKey = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : '';
|
|
190
194
|
// 冻结的对象不需要再执行proxy,否则会报错
|
|
191
195
|
if (Object.isFrozen(state)) {
|
|
192
196
|
return state;
|
|
193
197
|
}
|
|
194
198
|
for(var key in state){
|
|
195
|
-
var concatKey = prevKey ===
|
|
199
|
+
var concatKey = prevKey === '' ? key : prevKey + '.' + key;
|
|
196
200
|
var obj = state[key];
|
|
197
|
-
if (typeof obj === "
|
|
201
|
+
if ((typeof obj === "undefined" ? "undefined" : _type_of(obj)) === 'object' && obj !== null) {
|
|
198
202
|
// @ts-ignore
|
|
199
203
|
state[key] = proxyState(obj, callback, beforeSetCallback, concatKey);
|
|
200
204
|
}
|
|
@@ -205,20 +209,20 @@ function flatInstanceForChildren(controls) {
|
|
|
205
209
|
var result = [];
|
|
206
210
|
controls.forEach(function(item) {
|
|
207
211
|
result.push(item);
|
|
208
|
-
if (item.controlType ===
|
|
212
|
+
if (item.controlType === 'layout' || item.controlType === 'wrap') {
|
|
209
213
|
var _result;
|
|
210
214
|
(_result = result).push.apply(_result, _to_consumable_array(flatInstanceForChildren(item.children)));
|
|
211
215
|
}
|
|
212
216
|
});
|
|
213
217
|
return result;
|
|
214
218
|
}
|
|
215
|
-
/**
|
|
216
|
-
* 在flatInstance中通过key查找出对应的instance
|
|
217
|
-
* @param flatInstance 拍平的instance数组
|
|
218
|
-
* @param key 操作的数据在state的key - 可以是深层次的 subtable.0.input等
|
|
219
|
+
/**
|
|
220
|
+
* 在flatInstance中通过key查找出对应的instance
|
|
221
|
+
* @param flatInstance 拍平的instance数组
|
|
222
|
+
* @param key 操作的数据在state的key - 可以是深层次的 subtable.0.input等
|
|
219
223
|
* */ export function findItem(flatInstance, key, instanceMap) {
|
|
220
|
-
if (key ===
|
|
221
|
-
var keys = key.split(
|
|
224
|
+
if (key === '') return undefined;
|
|
225
|
+
var keys = key.split('.');
|
|
222
226
|
if (keys.length === 0) return undefined;
|
|
223
227
|
var oneKey = keys[0];
|
|
224
228
|
var otherKeys = keys.slice(1);
|
|
@@ -253,28 +257,28 @@ function flatInstanceForChildren(controls) {
|
|
|
253
257
|
}
|
|
254
258
|
function getArrayNewValue(type, args) {
|
|
255
259
|
if ([
|
|
256
|
-
|
|
257
|
-
|
|
260
|
+
'push',
|
|
261
|
+
'unshift'
|
|
258
262
|
].includes(type)) {
|
|
259
263
|
return args;
|
|
260
|
-
} else if (type ===
|
|
264
|
+
} else if (type === 'splice') {
|
|
261
265
|
return args.slice(2);
|
|
262
266
|
}
|
|
263
267
|
return [];
|
|
264
268
|
}
|
|
265
269
|
function getArrayNewArgs(type, args, value) {
|
|
266
270
|
if ([
|
|
267
|
-
|
|
268
|
-
|
|
271
|
+
'push',
|
|
272
|
+
'unshift'
|
|
269
273
|
].includes(type)) {
|
|
270
274
|
return value;
|
|
271
|
-
} else if (type ===
|
|
275
|
+
} else if (type === 'splice') {
|
|
272
276
|
return args.slice(0, 2).concat(value);
|
|
273
277
|
}
|
|
274
278
|
}
|
|
275
|
-
/**
|
|
276
|
-
* TODO 数组劫持操作需要模仿vue3进行重构,不再直接劫持原生property
|
|
277
|
-
* 劫持数组api,达到操作数组api的时候,可以同步操作instance
|
|
279
|
+
/**
|
|
280
|
+
* TODO 数组劫持操作需要模仿vue3进行重构,不再直接劫持原生property
|
|
281
|
+
* 劫持数组api,达到操作数组api的时候,可以同步操作instance
|
|
278
282
|
* */ function hijackArrayProperty() {
|
|
279
283
|
proxyArrayApi.forEach(function(key) {
|
|
280
284
|
var oldApiHandler = Array.prototype[key];
|
|
@@ -303,8 +307,8 @@ function getArrayNewArgs(type, args, value) {
|
|
|
303
307
|
// @ts-ignore
|
|
304
308
|
result = oldApiHandler.apply(this, args);
|
|
305
309
|
}
|
|
306
|
-
typeof currentHandlerState.callback ===
|
|
307
|
-
currentHandlerState.type =
|
|
310
|
+
typeof currentHandlerState.callback === 'function' && currentHandlerState.callback(key, args, result);
|
|
311
|
+
currentHandlerState.type = '';
|
|
308
312
|
currentHandlerState.args = [];
|
|
309
313
|
currentHandlerState.callback = emptyFn;
|
|
310
314
|
return result;
|
package/dist/esm/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
1
|
+
export * from './common';
|
|
2
|
+
export * from './plugins';
|
|
3
|
+
export * from './utils';
|
|
@@ -47,6 +47,10 @@ function _non_iterable_spread() {
|
|
|
47
47
|
function _to_consumable_array(arr) {
|
|
48
48
|
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
49
49
|
}
|
|
50
|
+
function _type_of(obj) {
|
|
51
|
+
"@swc/helpers - typeof";
|
|
52
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
53
|
+
}
|
|
50
54
|
function _unsupported_iterable_to_array(o, minLen) {
|
|
51
55
|
if (!o) return;
|
|
52
56
|
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
@@ -55,15 +59,15 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
55
59
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
56
60
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
57
61
|
}
|
|
58
|
-
import { CONTROL_TYPE, CALC_TOKEN_TYPE, CALC_AGGREGATE_TYPE } from
|
|
59
|
-
import { format } from
|
|
62
|
+
import { CONTROL_TYPE, CALC_TOKEN_TYPE, CALC_AGGREGATE_TYPE } from '@byteluck-fe/model-driven-shared';
|
|
63
|
+
import { format } from 'mathjs';
|
|
60
64
|
var DisplayType;
|
|
61
65
|
(function(DisplayType) {
|
|
62
|
-
/**
|
|
63
|
-
* 完全等于
|
|
66
|
+
/**
|
|
67
|
+
* 完全等于
|
|
64
68
|
*/ DisplayType["EQ"] = "EQ";
|
|
65
|
-
/**
|
|
66
|
-
* 包含
|
|
69
|
+
/**
|
|
70
|
+
* 包含
|
|
67
71
|
* */ DisplayType["IN"] = "IN";
|
|
68
72
|
})(DisplayType || (DisplayType = {}));
|
|
69
73
|
export var CalcPlugin = /*#__PURE__*/ function() {
|
|
@@ -72,16 +76,16 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
72
76
|
_class_call_check(this, CalcPlugin);
|
|
73
77
|
_define_property(this, "engine", void 0);
|
|
74
78
|
_define_property(this, "options", void 0);
|
|
75
|
-
/**
|
|
76
|
-
* 所有的计算公式控件
|
|
79
|
+
/**
|
|
80
|
+
* 所有的计算公式控件
|
|
77
81
|
* */ // @ts-ignore
|
|
78
82
|
_define_property(this, "calcControls", []);
|
|
79
|
-
/**
|
|
80
|
-
* key=控件id value=控件修改后需要触发重新计算的计算公式控件组成的数组
|
|
81
|
-
* 存储为一个Map,用于在控件change的时候,重新计算依赖的calc
|
|
83
|
+
/**
|
|
84
|
+
* key=控件id value=控件修改后需要触发重新计算的计算公式控件组成的数组
|
|
85
|
+
* 存储为一个Map,用于在控件change的时候,重新计算依赖的calc
|
|
82
86
|
* */ _define_property(this, "dependenciesTriggerMap", new Map());
|
|
83
|
-
/**
|
|
84
|
-
* 隐藏以后需要被计算的控件
|
|
87
|
+
/**
|
|
88
|
+
* 隐藏以后需要被计算的控件
|
|
85
89
|
* */ _define_property(this, "hideNotRememberControlIds", []);
|
|
86
90
|
_define_property(this, "dontHasPermissionControlIds", []);
|
|
87
91
|
_define_property(this, "cacheComputedResult", {});
|
|
@@ -92,8 +96,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
92
96
|
_create_class(CalcPlugin, [
|
|
93
97
|
{
|
|
94
98
|
key: "getNeedHideRememberControlIds",
|
|
95
|
-
value: /**
|
|
96
|
-
* @description 获取显隐控制的需要被记住值的控件id
|
|
99
|
+
value: /**
|
|
100
|
+
* @description 获取显隐控制的需要被记住值的控件id
|
|
97
101
|
* */ function getNeedHideRememberControlIds() {
|
|
98
102
|
var _this_options;
|
|
99
103
|
if (!((_this_options = this.options) === null || _this_options === void 0 ? void 0 : _this_options.displayBoList)) {
|
|
@@ -110,8 +114,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
110
114
|
},
|
|
111
115
|
{
|
|
112
116
|
key: "getDontHasPermissionControlIds",
|
|
113
|
-
value: /**
|
|
114
|
-
* @description 获取权限控制的隐藏的字段,不需要参与计算
|
|
117
|
+
value: /**
|
|
118
|
+
* @description 获取权限控制的隐藏的字段,不需要参与计算
|
|
115
119
|
* */ function getDontHasPermissionControlIds() {
|
|
116
120
|
var _this_options;
|
|
117
121
|
if (!((_this_options = this.options) === null || _this_options === void 0 ? void 0 : _this_options.behavior)) {
|
|
@@ -127,9 +131,9 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
127
131
|
},
|
|
128
132
|
{
|
|
129
133
|
key: "controlNeedComputedValue",
|
|
130
|
-
value: /**
|
|
131
|
-
* @description 判断控件是否需要被计算
|
|
132
|
-
* @param control 控件
|
|
134
|
+
value: /**
|
|
135
|
+
* @description 判断控件是否需要被计算
|
|
136
|
+
* @param control 控件
|
|
133
137
|
* */ function controlNeedComputedValue(control) {
|
|
134
138
|
if (!control) {
|
|
135
139
|
return false;
|
|
@@ -149,9 +153,9 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
149
153
|
},
|
|
150
154
|
{
|
|
151
155
|
key: "getControlIsHide",
|
|
152
|
-
value: /**
|
|
153
|
-
* @description 获取控件是否被隐藏
|
|
154
|
-
* @param control 控件
|
|
156
|
+
value: /**
|
|
157
|
+
* @description 获取控件是否被隐藏
|
|
158
|
+
* @param control 控件
|
|
155
159
|
* */ function getControlIsHide(control) {
|
|
156
160
|
if (control.props.isHide) {
|
|
157
161
|
return true;
|
|
@@ -170,7 +174,7 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
170
174
|
this.watchControlChange();
|
|
171
175
|
this.watchSubtableChange();
|
|
172
176
|
this.watchSchemaHideChange();
|
|
173
|
-
this.engine.on(
|
|
177
|
+
this.engine.on('engine-mounted', function() {
|
|
174
178
|
requestAnimationFrame(function() {
|
|
175
179
|
_this.resetDependencies();
|
|
176
180
|
_this.allCalcControlComputed();
|
|
@@ -180,8 +184,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
180
184
|
},
|
|
181
185
|
{
|
|
182
186
|
key: "resetDependencies",
|
|
183
|
-
value: /**
|
|
184
|
-
* @description 重置依赖,获取所有的计算公式控件,并根据计算公式获取控件依赖关系
|
|
187
|
+
value: /**
|
|
188
|
+
* @description 重置依赖,获取所有的计算公式控件,并根据计算公式获取控件依赖关系
|
|
185
189
|
* */ function resetDependencies() {
|
|
186
190
|
this.calcControls = [];
|
|
187
191
|
this.dependenciesTriggerMap.clear();
|
|
@@ -191,8 +195,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
191
195
|
},
|
|
192
196
|
{
|
|
193
197
|
key: "allCalcControlComputed",
|
|
194
|
-
value: /**
|
|
195
|
-
* @description 执行所有计算公式控件的计算
|
|
198
|
+
value: /**
|
|
199
|
+
* @description 执行所有计算公式控件的计算
|
|
196
200
|
* */ function allCalcControlComputed() {
|
|
197
201
|
var _this = this;
|
|
198
202
|
this.calcControls.forEach(function(item) {
|
|
@@ -206,8 +210,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
206
210
|
},
|
|
207
211
|
{
|
|
208
212
|
key: "getAllCalcControl",
|
|
209
|
-
value: /**
|
|
210
|
-
* @description 获取所有的计算公式控件
|
|
213
|
+
value: /**
|
|
214
|
+
* @description 获取所有的计算公式控件
|
|
211
215
|
* */ function getAllCalcControl() {
|
|
212
216
|
this.calcControls = this.engine.runtime.flatInstances.filter(// @ts-ignore
|
|
213
217
|
function(item) {
|
|
@@ -217,8 +221,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
217
221
|
},
|
|
218
222
|
{
|
|
219
223
|
key: "getCalcDependencies",
|
|
220
|
-
value: /**
|
|
221
|
-
* @description 获取计算公式控件依赖,组成 依赖=>[计算公式] 的Map结构
|
|
224
|
+
value: /**
|
|
225
|
+
* @description 获取计算公式控件依赖,组成 依赖=>[计算公式] 的Map结构
|
|
222
226
|
* */ function getCalcDependencies() {
|
|
223
227
|
var _this = this;
|
|
224
228
|
this.calcControls.forEach(function(item) {
|
|
@@ -270,12 +274,12 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
270
274
|
},
|
|
271
275
|
{
|
|
272
276
|
key: "watchSchemaHideChange",
|
|
273
|
-
value: /**
|
|
274
|
-
* @description 监听控件的显隐事件,把显隐会影响的控件触发一遍计算
|
|
277
|
+
value: /**
|
|
278
|
+
* @description 监听控件的显隐事件,把显隐会影响的控件触发一遍计算
|
|
275
279
|
* */ function watchSchemaHideChange() {
|
|
276
280
|
var _this = this;
|
|
277
|
-
this.engine.on(
|
|
278
|
-
if (payload.props ===
|
|
281
|
+
this.engine.on('schema-change', function(payload) {
|
|
282
|
+
if (payload.props === 'isHide') {
|
|
279
283
|
var _this_dependenciesTriggerMap_get;
|
|
280
284
|
var calcControls = (_this_dependenciesTriggerMap_get = _this.dependenciesTriggerMap.get(payload.instance.id)) !== null && _this_dependenciesTriggerMap_get !== void 0 ? _this_dependenciesTriggerMap_get : [];
|
|
281
285
|
calcControls.forEach(function(calc) {
|
|
@@ -287,11 +291,11 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
287
291
|
},
|
|
288
292
|
{
|
|
289
293
|
key: "watchSubtableChange",
|
|
290
|
-
value: /**
|
|
291
|
-
* @description 监听明细子表的change事件,把明细表会影响的控件触发一遍计算
|
|
294
|
+
value: /**
|
|
295
|
+
* @description 监听明细子表的change事件,把明细表会影响的控件触发一遍计算
|
|
292
296
|
* */ function watchSubtableChange() {
|
|
293
297
|
var _this = this;
|
|
294
|
-
this.engine.on(
|
|
298
|
+
this.engine.on('list-change', function(payload) {
|
|
295
299
|
var _payload_options;
|
|
296
300
|
// 初始化前是批量操作。不做处理
|
|
297
301
|
if (_this.engine.isMounted === false) return;
|
|
@@ -315,11 +319,11 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
315
319
|
},
|
|
316
320
|
{
|
|
317
321
|
key: "watchControlChange",
|
|
318
|
-
value: /**
|
|
319
|
-
* @description 监听控件的change事件,当控件change的时候,取到控件会影响的计算公式,然后执行对应的计算
|
|
322
|
+
value: /**
|
|
323
|
+
* @description 监听控件的change事件,当控件change的时候,取到控件会影响的计算公式,然后执行对应的计算
|
|
320
324
|
* */ function watchControlChange() {
|
|
321
325
|
var _this = this;
|
|
322
|
-
this.engine.on(
|
|
326
|
+
this.engine.on('change', function(payload) {
|
|
323
327
|
// 初始化前是批量操作。不做处理
|
|
324
328
|
if (_this.engine.isMounted === false) return;
|
|
325
329
|
var instance = payload.instance;
|
|
@@ -351,8 +355,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
351
355
|
},
|
|
352
356
|
{
|
|
353
357
|
key: "controlInSubtable",
|
|
354
|
-
value: /**
|
|
355
|
-
* @description 控件在明细子表内
|
|
358
|
+
value: /**
|
|
359
|
+
* @description 控件在明细子表内
|
|
356
360
|
* */ function controlInSubtable(control) {
|
|
357
361
|
var _control_parent;
|
|
358
362
|
return ((_control_parent = control.parent) === null || _control_parent === void 0 ? void 0 : _control_parent.type) === CONTROL_TYPE.SUBTABLE_COLUMN;
|
|
@@ -360,8 +364,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
360
364
|
},
|
|
361
365
|
{
|
|
362
366
|
key: "computedCalcValue",
|
|
363
|
-
value: /**
|
|
364
|
-
* @description 执行计算公式的计算
|
|
367
|
+
value: /**
|
|
368
|
+
* @description 执行计算公式的计算
|
|
365
369
|
* */ // @ts-ignore
|
|
366
370
|
function computedCalcValue(control) {
|
|
367
371
|
var _this = this;
|
|
@@ -416,7 +420,7 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
416
420
|
result += 0;
|
|
417
421
|
}
|
|
418
422
|
return result;
|
|
419
|
-
},
|
|
423
|
+
}, '');
|
|
420
424
|
var value;
|
|
421
425
|
// 有缓存的话取缓存,没有缓存再执行eval
|
|
422
426
|
if (this.cacheComputedResult[scriptText] !== undefined) {
|
|
@@ -437,7 +441,7 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
437
441
|
}
|
|
438
442
|
}
|
|
439
443
|
var oldValue = this.engine.getState(control.id, rowIndex);
|
|
440
|
-
var result = !value || value === Infinity || value === -Infinity ? 0 : control.props.precision ===
|
|
444
|
+
var result = !value || value === Infinity || value === -Infinity ? 0 : control.props.precision === '' ? value : Number(value.toFixed(control.props.precision));
|
|
441
445
|
// 如果值没变的话,不触发修改
|
|
442
446
|
if (result === (oldValue === null || oldValue === void 0 ? void 0 : oldValue.result)) {
|
|
443
447
|
return;
|
|
@@ -445,23 +449,23 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
445
449
|
var _oldValue_unit;
|
|
446
450
|
this.engine.setState(control.id, {
|
|
447
451
|
result: result,
|
|
448
|
-
unit: (_oldValue_unit = oldValue === null || oldValue === void 0 ? void 0 : oldValue.unit) !== null && _oldValue_unit !== void 0 ? _oldValue_unit :
|
|
452
|
+
unit: (_oldValue_unit = oldValue === null || oldValue === void 0 ? void 0 : oldValue.unit) !== null && _oldValue_unit !== void 0 ? _oldValue_unit : ''
|
|
449
453
|
}, rowIndex);
|
|
450
454
|
}
|
|
451
455
|
},
|
|
452
456
|
{
|
|
453
457
|
key: "getNumberValue",
|
|
454
|
-
value: /**
|
|
455
|
-
* @description 获取数字值,因为计算公式可以依赖计算公式和金额,所以需要从value中取到对应的值
|
|
458
|
+
value: /**
|
|
459
|
+
* @description 获取数字值,因为计算公式可以依赖计算公式和金额,所以需要从value中取到对应的值
|
|
456
460
|
* */ function getNumberValue(value) {
|
|
457
|
-
if (typeof value === "
|
|
458
|
-
if (
|
|
461
|
+
if ((typeof value === "undefined" ? "undefined" : _type_of(value)) === 'object' && value) {
|
|
462
|
+
if ('result' in value) {
|
|
459
463
|
return value.result;
|
|
460
|
-
} else if (
|
|
464
|
+
} else if ('amount' in value) {
|
|
461
465
|
return value.amount;
|
|
462
466
|
}
|
|
463
467
|
}
|
|
464
|
-
if (typeof value ===
|
|
468
|
+
if (typeof value === 'number') {
|
|
465
469
|
return value;
|
|
466
470
|
}
|
|
467
471
|
return 0;
|
|
@@ -469,8 +473,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
469
473
|
},
|
|
470
474
|
{
|
|
471
475
|
key: "getAggregateTypeValue",
|
|
472
|
-
value: /**
|
|
473
|
-
* 计算明细子表最大值最小值平均值总和
|
|
476
|
+
value: /**
|
|
477
|
+
* 计算明细子表最大值最小值平均值总和
|
|
474
478
|
* */ function getAggregateTypeValue(values, type) {
|
|
475
479
|
if (!type || !values || !values.length) return 0;
|
|
476
480
|
switch(type){
|
|
@@ -154,7 +154,7 @@ function _ts_generator(thisArg, body) {
|
|
|
154
154
|
};
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
|
-
import { EventLogic } from
|
|
157
|
+
import { EventLogic } from '@byteluck-fe/model-driven-shared';
|
|
158
158
|
// type EventKeyMap = {
|
|
159
159
|
// [eventKey in EventKeys]?: string
|
|
160
160
|
// }
|
|
@@ -207,13 +207,13 @@ export var ControlsEventPlugin = /*#__PURE__*/ function() {
|
|
|
207
207
|
key: "engineAddEventListener",
|
|
208
208
|
value: function engineAddEventListener(eventKey, controlEventKey) {
|
|
209
209
|
var _this = this;
|
|
210
|
-
this.engine.on(eventKey, function() {
|
|
210
|
+
this.engine.on(eventKey, /*#__PURE__*/ function() {
|
|
211
211
|
var _ref = _async_to_generator(function(payload) {
|
|
212
212
|
return _ts_generator(this, function(_state) {
|
|
213
213
|
switch(_state.label){
|
|
214
214
|
case 0:
|
|
215
215
|
// 初始化state的时候不触发change事件,必须在engine mounted以后才触发
|
|
216
|
-
if ((eventKey ===
|
|
216
|
+
if ((eventKey === 'change' || eventKey === 'list-change') && !_this.engine.isMounted) {
|
|
217
217
|
return [
|
|
218
218
|
2
|
|
219
219
|
];
|
|
@@ -262,7 +262,7 @@ export var ControlsEventPlugin = /*#__PURE__*/ function() {
|
|
|
262
262
|
}
|
|
263
263
|
return [
|
|
264
264
|
4,
|
|
265
|
-
Promise.all(events[name].map(function() {
|
|
265
|
+
Promise.all(events[name].map(/*#__PURE__*/ function() {
|
|
266
266
|
var _ref = _async_to_generator(function(eventName) {
|
|
267
267
|
var execResult;
|
|
268
268
|
return _ts_generator(this, function(_state) {
|
|
@@ -76,7 +76,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
76
76
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
77
77
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
78
78
|
}
|
|
79
|
-
import { error } from
|
|
79
|
+
import { error } from '@byteluck-fe/model-driven-shared';
|
|
80
80
|
export var ES6ModulePlugin = /*#__PURE__*/ function() {
|
|
81
81
|
"use strict";
|
|
82
82
|
function ES6ModulePlugin(config, env, eventJs) {
|
|
@@ -170,11 +170,11 @@ export function parseModule(action, engine, env) {
|
|
|
170
170
|
}
|
|
171
171
|
};
|
|
172
172
|
try {
|
|
173
|
-
new Function(
|
|
173
|
+
new Function('module', 'exports', compiled).call(module, module, module.exports);
|
|
174
174
|
} catch (e) {
|
|
175
|
-
error(e.message +
|
|
176
|
-
if (process.env.NODE_ENV !==
|
|
177
|
-
error(
|
|
175
|
+
error(e.message + '. fail to parse the module');
|
|
176
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
177
|
+
error('fail to parse the module');
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
var funcMap = {};
|
|
@@ -183,7 +183,7 @@ export function parseModule(action, engine, env) {
|
|
|
183
183
|
try {
|
|
184
184
|
for(var _iterator = Object.entries(module.exports)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
185
185
|
var _step_value = _sliced_to_array(_step.value, 2), key = _step_value[0], value = _step_value[1];
|
|
186
|
-
if (typeof value ===
|
|
186
|
+
if (typeof value === 'function') {
|
|
187
187
|
funcMap[key] = value;
|
|
188
188
|
} else {
|
|
189
189
|
variables[key] = value;
|
|
@@ -201,10 +201,11 @@ function _ts_generator(thisArg, body) {
|
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
203
|
var LifecycleEventKeyMap = {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
204
|
+
'engine-initialized': 'did_init',
|
|
205
|
+
'engine-mounted': 'did_mount',
|
|
206
|
+
'engine-submit': 'will_submit',
|
|
207
|
+
'engine-submit-params': 'do_submit',
|
|
208
|
+
'engine-submitted': 'did_submit'
|
|
208
209
|
};
|
|
209
210
|
export var LifecycleEventPlugin = /*#__PURE__*/ function() {
|
|
210
211
|
"use strict";
|
|
@@ -223,7 +224,7 @@ export var LifecycleEventPlugin = /*#__PURE__*/ function() {
|
|
|
223
224
|
Object.entries(LifecycleEventKeyMap).forEach(function(param) {
|
|
224
225
|
var _param = _sliced_to_array(param, 2), engineKey = _param[0], lifecycleKey = _param[1];
|
|
225
226
|
var _this1 = _this;
|
|
226
|
-
engine.on(engineKey, function() {
|
|
227
|
+
engine.on(engineKey, /*#__PURE__*/ function() {
|
|
227
228
|
var _ref = _async_to_generator(function(payload) {
|
|
228
229
|
var result;
|
|
229
230
|
return _ts_generator(this, function(_state) {
|
|
@@ -277,7 +278,7 @@ export var LifecycleEventPlugin = /*#__PURE__*/ function() {
|
|
|
277
278
|
}
|
|
278
279
|
return [
|
|
279
280
|
4,
|
|
280
|
-
Promise.all(events[name].map(function() {
|
|
281
|
+
Promise.all(events[name].map(/*#__PURE__*/ function() {
|
|
281
282
|
var _ref = _async_to_generator(function(eventName) {
|
|
282
283
|
var execResult;
|
|
283
284
|
return _ts_generator(this, function(_state) {
|