@byteluck-fe/model-driven-engine 2.7.0-beta → 2.8.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.
- package/dist/esm/common/Engine.js +73 -34
- package/dist/esm/common/OkWorker.js +4 -4
- package/dist/esm/common/Runtime.js +5 -1
- package/dist/esm/common/Store.js +9 -16
- package/dist/esm/common/checkerValue.js +28 -23
- package/dist/esm/common/proxyState.js +15 -16
- package/dist/esm/plugins/CalcPlugin.js +18 -11
- package/dist/esm/plugins/ControlsEventPlugin.js +1 -1
- package/dist/esm/utils/runtimeUtils.js +4 -5
- package/dist/index.umd.js +7 -7
- package/dist/types/common/Engine.d.ts +5 -1
- package/package.json +4 -4
|
@@ -59,12 +59,12 @@ import { CONTROL_TYPE, CALC_TOKEN_TYPE, CALC_AGGREGATE_TYPE } from "@byteluck-fe
|
|
|
59
59
|
import { format } from "mathjs";
|
|
60
60
|
var DisplayType;
|
|
61
61
|
(function(DisplayType) {
|
|
62
|
-
|
|
62
|
+
/**
|
|
63
63
|
* 完全等于
|
|
64
|
-
*/ "EQ"] = "EQ";
|
|
65
|
-
|
|
64
|
+
*/ DisplayType["EQ"] = "EQ";
|
|
65
|
+
/**
|
|
66
66
|
* 包含
|
|
67
|
-
* */ "IN"] = "IN";
|
|
67
|
+
* */ DisplayType["IN"] = "IN";
|
|
68
68
|
})(DisplayType || (DisplayType = {}));
|
|
69
69
|
export var CalcPlugin = /*#__PURE__*/ function() {
|
|
70
70
|
"use strict";
|
|
@@ -156,7 +156,7 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
156
156
|
if (control.props.isHide) {
|
|
157
157
|
return true;
|
|
158
158
|
}
|
|
159
|
-
if (control.parent === null) {
|
|
159
|
+
if (control.parent === null || control.parent === undefined) {
|
|
160
160
|
return false;
|
|
161
161
|
}
|
|
162
162
|
return this.getControlIsHide(control.parent);
|
|
@@ -167,12 +167,14 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
167
167
|
value: function apply(engine) {
|
|
168
168
|
var _this = this;
|
|
169
169
|
this.engine = engine;
|
|
170
|
-
this.resetDependencies();
|
|
171
170
|
this.watchControlChange();
|
|
172
171
|
this.watchSubtableChange();
|
|
173
172
|
this.watchSchemaHideChange();
|
|
174
173
|
this.engine.on("engine-mounted", function() {
|
|
175
|
-
|
|
174
|
+
requestAnimationFrame(function() {
|
|
175
|
+
_this.resetDependencies();
|
|
176
|
+
_this.allCalcControlComputed();
|
|
177
|
+
});
|
|
176
178
|
});
|
|
177
179
|
}
|
|
178
180
|
},
|
|
@@ -194,7 +196,9 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
194
196
|
* */ function allCalcControlComputed() {
|
|
195
197
|
var _this = this;
|
|
196
198
|
this.calcControls.forEach(function(item) {
|
|
197
|
-
|
|
199
|
+
if (item.props.dataBind.result.fieldCode === null || item.props.dataBind.result.fieldCode === undefined) {
|
|
200
|
+
_this.computedCalcValue(item);
|
|
201
|
+
}
|
|
198
202
|
});
|
|
199
203
|
}
|
|
200
204
|
},
|
|
@@ -287,6 +291,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
287
291
|
var _this = this;
|
|
288
292
|
this.engine.on("list-change", function(payload) {
|
|
289
293
|
var _payload_options;
|
|
294
|
+
// 初始化前是批量操作。不做处理
|
|
295
|
+
if (_this.engine.isMounted === false) return;
|
|
290
296
|
_this.resetDependencies();
|
|
291
297
|
var _payload_options_changed;
|
|
292
298
|
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 : [];
|
|
@@ -312,6 +318,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
312
318
|
* */ function watchControlChange() {
|
|
313
319
|
var _this = this;
|
|
314
320
|
this.engine.on("change", function(payload) {
|
|
321
|
+
// 初始化前是批量操作。不做处理
|
|
322
|
+
if (_this.engine.isMounted === false) return;
|
|
315
323
|
var instance = payload.instance;
|
|
316
324
|
if (!_this.dependenciesTriggerMap.has(instance.id)) {
|
|
317
325
|
return;
|
|
@@ -355,7 +363,6 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
355
363
|
* */ // @ts-ignore
|
|
356
364
|
function computedCalcValue(control) {
|
|
357
365
|
var _this = this;
|
|
358
|
-
var _oldValue, _oldValue1;
|
|
359
366
|
var scriptEcho = control.props.scriptEcho;
|
|
360
367
|
if (!scriptEcho || scriptEcho.length === 0) {
|
|
361
368
|
return;
|
|
@@ -430,13 +437,13 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
430
437
|
var oldValue = this.engine.getState(control.id, rowIndex);
|
|
431
438
|
var result = !value || value === Infinity || value === -Infinity ? 0 : control.props.precision === "" ? value : Number(value.toFixed(control.props.precision));
|
|
432
439
|
// 如果值没变的话,不触发修改
|
|
433
|
-
if (result === (
|
|
440
|
+
if (result === (oldValue === null || oldValue === void 0 ? void 0 : oldValue.result)) {
|
|
434
441
|
return;
|
|
435
442
|
}
|
|
436
443
|
var _oldValue_unit;
|
|
437
444
|
this.engine.setState(control.id, {
|
|
438
445
|
result: result,
|
|
439
|
-
unit: (_oldValue_unit =
|
|
446
|
+
unit: (_oldValue_unit = oldValue === null || oldValue === void 0 ? void 0 : oldValue.unit) !== null && _oldValue_unit !== void 0 ? _oldValue_unit : ""
|
|
440
447
|
}, rowIndex);
|
|
441
448
|
}
|
|
442
449
|
},
|
|
@@ -213,7 +213,7 @@ export var ControlsEventPlugin = /*#__PURE__*/ function() {
|
|
|
213
213
|
switch(_state.label){
|
|
214
214
|
case 0:
|
|
215
215
|
// 初始化state的时候不触发change事件,必须在engine mounted以后才触发
|
|
216
|
-
if (
|
|
216
|
+
if (eventKey === "change" && !_this.engine.isMounted) {
|
|
217
217
|
return [
|
|
218
218
|
2
|
|
219
219
|
];
|
|
@@ -8,11 +8,11 @@ export function loopFormControl(control, callback) {
|
|
|
8
8
|
//TODO 此处需要再抽象一层 datagrid/datalist
|
|
9
9
|
if (item.type === CONTROL_TYPE.SUBTABLE) {
|
|
10
10
|
// @ts-ignore
|
|
11
|
-
var children = item.getChildrenFormControl()
|
|
11
|
+
var children = []//item.getChildrenFormControl() as RuntimeFormControl[]
|
|
12
|
+
;
|
|
12
13
|
callback(item, children);
|
|
13
14
|
} else if (hasChildrenControl(item)) {
|
|
14
|
-
|
|
15
|
-
loopFormControl((_item = item) === null || _item === void 0 ? void 0 : _item.children, callback);
|
|
15
|
+
loopFormControl(item === null || item === void 0 ? void 0 : item.children, callback);
|
|
16
16
|
// @ts-ignore
|
|
17
17
|
} else if (item.controlType === CONTROL_BASE_TYPE.FORM) {
|
|
18
18
|
callback(item);
|
|
@@ -27,9 +27,8 @@ callback) {
|
|
|
27
27
|
if (item.type === CONTROL_TYPE.DATA_VIEW || item.type === CONTROL_TYPE.SIMPLE_SEARCH) {
|
|
28
28
|
callback(item);
|
|
29
29
|
} else if (hasChildrenControl(item)) {
|
|
30
|
-
var _item;
|
|
31
30
|
// @ts-ignore
|
|
32
|
-
loopDataViewControl(
|
|
31
|
+
loopDataViewControl(item === null || item === void 0 ? void 0 : item.children, callback);
|
|
33
32
|
}
|
|
34
33
|
});
|
|
35
34
|
}
|