@byteluck-fe/model-driven-engine 2.7.0-alpha.28a → 2.7.0-alpha.29a
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 +10 -15
- package/dist/esm/common/Store.js +1 -2
- package/dist/esm/common/checkerValue.js +2 -4
- package/dist/esm/common/proxyState.js +4 -5
- package/dist/esm/plugins/CalcPlugin.js +2 -3
- package/dist/esm/plugins/ES6ModulePlugin.js +47 -18
- package/dist/esm/utils/runtimeUtils.js +2 -4
- package/dist/index.umd.js +7 -8
- package/dist/types/plugins/ES6ModulePlugin.d.ts +2 -1
- package/package.json +2 -2
|
@@ -474,7 +474,6 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
474
474
|
}
|
|
475
475
|
// @ts-ignore
|
|
476
476
|
if (this.assertInstance(instance, CONTROL_TYPE.SUBTABLE)) {
|
|
477
|
-
var _newValue;
|
|
478
477
|
if (newValue === null) {
|
|
479
478
|
return [];
|
|
480
479
|
}
|
|
@@ -489,7 +488,7 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
489
488
|
}, {});
|
|
490
489
|
// @ts-ignore
|
|
491
490
|
var emptyState = this.getEmptyState(instance.id);
|
|
492
|
-
return
|
|
491
|
+
return newValue === null || newValue === void 0 ? void 0 : newValue.map(function(row) {
|
|
493
492
|
return(// @ts-ignore
|
|
494
493
|
checkerSubtableValue(fieldTypeMap, row, emptyState));
|
|
495
494
|
});
|
|
@@ -518,10 +517,9 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
518
517
|
key: "_handlerArrayUpdate",
|
|
519
518
|
value: function _handlerArrayUpdate(state, key, type, args, result) {
|
|
520
519
|
var _this = this;
|
|
521
|
-
var _subtable;
|
|
522
520
|
var subtable = findItem(this.runtime.flatInstances, key, this.runtime.instanceMap);
|
|
523
521
|
// if (!(subtable instanceof RuntimeListControl)) return
|
|
524
|
-
if (!((
|
|
522
|
+
if (!((subtable === null || subtable === void 0 ? void 0 : subtable.controlType) === CONTROL_BASE_TYPE.LIST)) return;
|
|
525
523
|
// 新增多行方法
|
|
526
524
|
var createRows = function(len) {
|
|
527
525
|
// @ts-ignore
|
|
@@ -1272,20 +1270,17 @@ var Engine = /*#__PURE__*/ function(Watcher) {
|
|
|
1272
1270
|
}
|
|
1273
1271
|
var newMapping = _this.getDataBindMapping(dataCode);
|
|
1274
1272
|
if (newMapping) {
|
|
1275
|
-
var _newMapping_fields
|
|
1276
|
-
var mappingKeys =
|
|
1277
|
-
|
|
1278
|
-
return (_item = item) === null || _item === void 0 ? void 0 : _item.controlId;
|
|
1273
|
+
var _newMapping_fields;
|
|
1274
|
+
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) {
|
|
1275
|
+
return item === null || item === void 0 ? void 0 : item.controlId;
|
|
1279
1276
|
});
|
|
1280
|
-
var mappingValue = _this.getEmptyState(
|
|
1277
|
+
var mappingValue = _this.getEmptyState(newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId);
|
|
1281
1278
|
var _newState_newMapping_controlId;
|
|
1282
|
-
var mainStateKeys = Object.keys((_newState_newMapping_controlId =
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
if (!mainStateKeys.includes(key) && key !== "uid" && newState[(_newMapping = newMapping) === null || _newMapping === void 0 ? void 0 : _newMapping.controlId]) {
|
|
1279
|
+
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 : {});
|
|
1280
|
+
mappingKeys === null || mappingKeys === void 0 ? void 0 : mappingKeys.forEach(function(key) {
|
|
1281
|
+
if (!mainStateKeys.includes(key) && key !== "uid" && newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId]) {
|
|
1286
1282
|
if (Object.keys(newState).length) {
|
|
1287
|
-
|
|
1288
|
-
Object.assign(newState[(_newMapping1 = newMapping) === null || _newMapping1 === void 0 ? void 0 : _newMapping1.controlId], _define_property({}, key, mappingValue[key]));
|
|
1283
|
+
Object.assign(newState[newMapping === null || newMapping === void 0 ? void 0 : newMapping.controlId], _define_property({}, key, mappingValue[key]));
|
|
1289
1284
|
} else {
|
|
1290
1285
|
Object.assign(newState, _define_property({}, newMapping.controlId, _define_property({}, key, mappingValue[key])));
|
|
1291
1286
|
}
|
package/dist/esm/common/Store.js
CHANGED
|
@@ -200,7 +200,6 @@ var Store = /*#__PURE__*/ function() {
|
|
|
200
200
|
{
|
|
201
201
|
key: "getDataBind",
|
|
202
202
|
value: function getDataBind(controlId) {
|
|
203
|
-
var _result;
|
|
204
203
|
var result = this.controlIdMapping[controlId];
|
|
205
204
|
if (result) {
|
|
206
205
|
return result.dataBind;
|
|
@@ -216,7 +215,7 @@ var Store = /*#__PURE__*/ function() {
|
|
|
216
215
|
}
|
|
217
216
|
}
|
|
218
217
|
}
|
|
219
|
-
return
|
|
218
|
+
return result === null || result === void 0 ? void 0 : result.dataBind;
|
|
220
219
|
}
|
|
221
220
|
}
|
|
222
221
|
]);
|
|
@@ -345,9 +345,8 @@ var MoneyValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
345
345
|
key: "transform",
|
|
346
346
|
value: function transform(value, oldValue) {
|
|
347
347
|
if (value === undefined || value === null || value === "") {
|
|
348
|
-
var _oldValue;
|
|
349
348
|
return new AmountValue({
|
|
350
|
-
currency:
|
|
349
|
+
currency: oldValue === null || oldValue === void 0 ? void 0 : oldValue.currency
|
|
351
350
|
});
|
|
352
351
|
}
|
|
353
352
|
var result;
|
|
@@ -445,9 +444,8 @@ var CalcValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
445
444
|
key: "transform",
|
|
446
445
|
value: function transform(value, oldValue) {
|
|
447
446
|
if (value === undefined || value === null || value === "") {
|
|
448
|
-
var _oldValue;
|
|
449
447
|
return new CalcValue({
|
|
450
|
-
unit:
|
|
448
|
+
unit: oldValue === null || oldValue === void 0 ? void 0 : oldValue.unit
|
|
451
449
|
});
|
|
452
450
|
}
|
|
453
451
|
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
|
|
241
|
-
var
|
|
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
|
|
247
|
+
var _prevItem_children;
|
|
249
248
|
var _prevItem_children_index;
|
|
250
249
|
// 如果有children,则取children中对应的下标,没有的话一直返回prevItem
|
|
251
|
-
return (_prevItem_children_index =
|
|
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 === (
|
|
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 =
|
|
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
|
},
|
|
@@ -79,13 +79,15 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
79
79
|
import { error } from "@byteluck-fe/model-driven-shared";
|
|
80
80
|
export var ES6ModulePlugin = /*#__PURE__*/ function() {
|
|
81
81
|
"use strict";
|
|
82
|
-
function ES6ModulePlugin(config, env) {
|
|
82
|
+
function ES6ModulePlugin(config, env, eventJs) {
|
|
83
83
|
_class_call_check(this, ES6ModulePlugin);
|
|
84
84
|
_define_property(this, "config", void 0);
|
|
85
85
|
_define_property(this, "engine", void 0);
|
|
86
86
|
_define_property(this, "env", void 0);
|
|
87
|
+
_define_property(this, "eventJs", void 0);
|
|
87
88
|
this.config = config;
|
|
88
89
|
this.env = env;
|
|
90
|
+
this.eventJs = eventJs;
|
|
89
91
|
}
|
|
90
92
|
_create_class(ES6ModulePlugin, [
|
|
91
93
|
{
|
|
@@ -96,28 +98,55 @@ export var ES6ModulePlugin = /*#__PURE__*/ function() {
|
|
|
96
98
|
if (!action) {
|
|
97
99
|
return;
|
|
98
100
|
}
|
|
99
|
-
var res = parseModule(action, engine, this.env);
|
|
100
|
-
if (!res) {
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
101
|
var actionManager = engine.getAction();
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
102
|
+
if (this.eventJs) {
|
|
103
|
+
this.eventJs.exportsFun({
|
|
104
|
+
ctx: engine,
|
|
105
|
+
utils: actionManager.actionUtils
|
|
106
|
+
});
|
|
107
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
108
|
+
try {
|
|
109
|
+
for(var _iterator = Object.entries(this.eventJs)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
110
|
+
var _step_value = _sliced_to_array(_step.value, 2), key = _step_value[0], value = _step_value[1];
|
|
111
|
+
actionManager.addAction(key, value);
|
|
112
|
+
}
|
|
113
|
+
} catch (err) {
|
|
114
|
+
_didIteratorError = true;
|
|
115
|
+
_iteratorError = err;
|
|
116
|
+
} finally{
|
|
117
|
+
try {
|
|
118
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
119
|
+
_iterator.return();
|
|
120
|
+
}
|
|
121
|
+
} finally{
|
|
122
|
+
if (_didIteratorError) {
|
|
123
|
+
throw _iteratorError;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
} else {
|
|
128
|
+
var res = parseModule(action, engine, this.env);
|
|
129
|
+
if (!res) {
|
|
130
|
+
return;
|
|
109
131
|
}
|
|
110
|
-
|
|
111
|
-
_didIteratorError = true;
|
|
112
|
-
_iteratorError = err;
|
|
113
|
-
} finally{
|
|
132
|
+
var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
|
|
114
133
|
try {
|
|
115
|
-
|
|
116
|
-
|
|
134
|
+
for(var _iterator1 = Object.entries(res.funcMap)[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
|
|
135
|
+
var _step_value1 = _sliced_to_array(_step1.value, 2), key1 = _step_value1[0], value1 = _step_value1[1];
|
|
136
|
+
actionManager.addAction(key1, value1);
|
|
117
137
|
}
|
|
138
|
+
} catch (err) {
|
|
139
|
+
_didIteratorError1 = true;
|
|
140
|
+
_iteratorError1 = err;
|
|
118
141
|
} finally{
|
|
119
|
-
|
|
120
|
-
|
|
142
|
+
try {
|
|
143
|
+
if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
|
|
144
|
+
_iterator1.return();
|
|
145
|
+
}
|
|
146
|
+
} finally{
|
|
147
|
+
if (_didIteratorError1) {
|
|
148
|
+
throw _iteratorError1;
|
|
149
|
+
}
|
|
121
150
|
}
|
|
122
151
|
}
|
|
123
152
|
}
|
|
@@ -12,8 +12,7 @@ export function loopFormControl(control, callback) {
|
|
|
12
12
|
;
|
|
13
13
|
callback(item, children);
|
|
14
14
|
} else if (hasChildrenControl(item)) {
|
|
15
|
-
|
|
16
|
-
loopFormControl((_item = item) === null || _item === void 0 ? void 0 : _item.children, callback);
|
|
15
|
+
loopFormControl(item === null || item === void 0 ? void 0 : item.children, callback);
|
|
17
16
|
// @ts-ignore
|
|
18
17
|
} else if (item.controlType === CONTROL_BASE_TYPE.FORM) {
|
|
19
18
|
callback(item);
|
|
@@ -28,9 +27,8 @@ callback) {
|
|
|
28
27
|
if (item.type === CONTROL_TYPE.DATA_VIEW || item.type === CONTROL_TYPE.SIMPLE_SEARCH) {
|
|
29
28
|
callback(item);
|
|
30
29
|
} else if (hasChildrenControl(item)) {
|
|
31
|
-
var _item;
|
|
32
30
|
// @ts-ignore
|
|
33
|
-
loopDataViewControl(
|
|
31
|
+
loopDataViewControl(item === null || item === void 0 ? void 0 : item.children, callback);
|
|
34
32
|
}
|
|
35
33
|
});
|
|
36
34
|
}
|