@byteluck-fe/model-driven-engine 2.7.0-beta.4 → 2.8.0-alpha.10
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 +229 -52
- package/dist/esm/common/OkWorker.js +4 -4
- package/dist/esm/common/Runtime.js +69 -26
- package/dist/esm/common/Store.js +14 -15
- package/dist/esm/common/checkerValue.js +26 -19
- package/dist/esm/common/proxyState.js +11 -11
- package/dist/esm/plugins/CalcPlugin.js +18 -8
- package/dist/esm/plugins/ControlsEventPlugin.js +1 -1
- package/dist/esm/plugins/ES6ModulePlugin.js +47 -18
- package/dist/esm/utils/runtimeUtils.js +2 -1
- package/dist/index.umd.js +7 -7
- package/dist/types/common/Engine.d.ts +10 -5
- package/dist/types/common/Runtime.d.ts +1 -0
- package/dist/types/common/Store.d.ts +1 -1
- package/dist/types/plugins/ES6ModulePlugin.d.ts +2 -1
- package/package.json +4 -4
|
@@ -97,7 +97,7 @@ function _create_super(Derived) {
|
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
99
|
import { RegisterControls } from "@byteluck-fe/model-driven-core";
|
|
100
|
-
import { CONTROL_BASE_TYPE, CONTROL_TYPE, loopFormSchema } from "@byteluck-fe/model-driven-shared";
|
|
100
|
+
import { CONTROL_BASE_TYPE, CONTROL_TYPE, JSONCopy, loopFormSchema, isArray } from "@byteluck-fe/model-driven-shared";
|
|
101
101
|
import { hasChildrenControl, loopDataViewControl, loopFormControl } from "../utils/runtimeUtils";
|
|
102
102
|
export var Runtime = /*#__PURE__*/ function(RegisterControls) {
|
|
103
103
|
"use strict";
|
|
@@ -111,6 +111,7 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls) {
|
|
|
111
111
|
_define_property(_assert_this_initialized(_this), "_instance", void 0);
|
|
112
112
|
_define_property(_assert_this_initialized(_this), "_flatInstances", []);
|
|
113
113
|
_define_property(_assert_this_initialized(_this), "_instanceMap", {});
|
|
114
|
+
_define_property(_assert_this_initialized(_this), "_controlParentIdMap", {});
|
|
114
115
|
var schema = props.schema;
|
|
115
116
|
_this._schema = schema;
|
|
116
117
|
_this._instance = _this.createControl(schema, props.beforeCreateInstance);
|
|
@@ -123,19 +124,32 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls) {
|
|
|
123
124
|
value: function getFlatInstances() {
|
|
124
125
|
var instances = [];
|
|
125
126
|
var instanceMap = {};
|
|
126
|
-
|
|
127
|
+
var controlParentIdMap = {};
|
|
128
|
+
loop(this._instance, "", function(item, parentId) {
|
|
127
129
|
// 3.4.1 避免将subtable-row 放到 _flatInstances 中
|
|
128
|
-
|
|
129
|
-
|
|
130
|
+
//4.3.0-lh2 将自处注释掉,为使instance.parent能取到父级
|
|
131
|
+
// if (item.type === 'subtable-row' || item.type === 'subtable-column') {
|
|
132
|
+
// return
|
|
133
|
+
// }
|
|
134
|
+
if (parentId) {
|
|
135
|
+
// @ts-ignore
|
|
136
|
+
controlParentIdMap[item.id] = parentId;
|
|
130
137
|
}
|
|
131
|
-
instances.push(item);
|
|
132
138
|
if (!instanceMap[item.id]) {
|
|
133
139
|
instanceMap[item.id] = [];
|
|
134
140
|
}
|
|
141
|
+
//不知为何subtable-column会多存一次
|
|
142
|
+
if (item.type === "subtable-column") {
|
|
143
|
+
if (instanceMap[item.id].length > 0) {
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
instances.push(item);
|
|
135
148
|
instanceMap[item.id].push(item);
|
|
136
149
|
});
|
|
137
150
|
this._flatInstances = instances;
|
|
138
151
|
this._instanceMap = instanceMap;
|
|
152
|
+
this._controlParentIdMap = controlParentIdMap;
|
|
139
153
|
return this._flatInstances;
|
|
140
154
|
}
|
|
141
155
|
},
|
|
@@ -169,8 +183,9 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls) {
|
|
|
169
183
|
var antdRules = {};
|
|
170
184
|
var ruleItems = {};
|
|
171
185
|
loopDataViewControl(this._instance, function(dataView) {
|
|
172
|
-
|
|
173
|
-
|
|
186
|
+
var result = Runtime.staticGetRules(dataView.type, dataView.props);
|
|
187
|
+
ruleItems[dataView.id] = JSONCopy(result[0]);
|
|
188
|
+
antdRules[dataView.id] = JSONCopy(result[0]);
|
|
174
189
|
loopFormControl(dataView.children, function(item) {
|
|
175
190
|
// if (
|
|
176
191
|
// item instanceof RuntimeFormControl ||
|
|
@@ -193,7 +208,9 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls) {
|
|
|
193
208
|
get: function get() {
|
|
194
209
|
var ruleItems = {};
|
|
195
210
|
loopDataViewControl(this._instance, function(dataView) {
|
|
196
|
-
|
|
211
|
+
var result = Runtime.staticGetRules(dataView.type, dataView.props);
|
|
212
|
+
// ruleItems[dataView.id] = dataView.rules[0]
|
|
213
|
+
ruleItems[dataView.id] = result[0];
|
|
197
214
|
loopFormControl(dataView.children, function(item) {
|
|
198
215
|
// if (
|
|
199
216
|
// item instanceof RuntimeFormControl ||
|
|
@@ -212,7 +229,9 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls) {
|
|
|
212
229
|
get: function get() {
|
|
213
230
|
var antdRules = {};
|
|
214
231
|
loopDataViewControl(this._instance, function(dataView) {
|
|
215
|
-
|
|
232
|
+
var result = Runtime.staticGetRules(dataView.type, dataView.props);
|
|
233
|
+
// antdRules[dataView.id] = dataView.rules[0]
|
|
234
|
+
antdRules[dataView.id] = result[0];
|
|
216
235
|
loopFormControl(dataView.children, function(item) {
|
|
217
236
|
// if (
|
|
218
237
|
// item instanceof RuntimeFormControl ||
|
|
@@ -229,18 +248,30 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls) {
|
|
|
229
248
|
]);
|
|
230
249
|
return Runtime;
|
|
231
250
|
}(RegisterControls);
|
|
232
|
-
function loop(control, callback) {
|
|
233
|
-
|
|
234
|
-
control
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
251
|
+
function loop(control, parentId, callback) {
|
|
252
|
+
var _instances = Array.isArray(control) ? control : [
|
|
253
|
+
control
|
|
254
|
+
];
|
|
255
|
+
_instances.map(function(item) {
|
|
256
|
+
callback(item, parentId);
|
|
257
|
+
if (hasChildrenControl(item)) {
|
|
258
|
+
var ctl = item;
|
|
259
|
+
if (!ctl.children) {
|
|
260
|
+
ctl.children = [];
|
|
239
261
|
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
262
|
+
// @ts-ignore
|
|
263
|
+
loop(ctl.children, ctl.id, callback);
|
|
264
|
+
}
|
|
265
|
+
if (hasHeaderOrFooterControl(item, "headers")) {
|
|
266
|
+
loop(item.props.headers, item.id, callback);
|
|
267
|
+
}
|
|
268
|
+
if (hasHeaderOrFooterControl(item, "footers")) {
|
|
269
|
+
loop(item.props.footers, item.id, callback);
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
function hasHeaderOrFooterControl(control, checkType) {
|
|
274
|
+
return checkType in control.props && isArray(control.props[checkType]);
|
|
244
275
|
}
|
|
245
276
|
/**
|
|
246
277
|
* 控件是否在视图中隐藏,遍历查找所有parent
|
|
@@ -248,7 +279,7 @@ function loop(control, callback) {
|
|
|
248
279
|
if (control.props.isHide) {
|
|
249
280
|
return true;
|
|
250
281
|
}
|
|
251
|
-
if (control.parent === null) {
|
|
282
|
+
if (control.parent === null || control.parent === undefined) {
|
|
252
283
|
return false;
|
|
253
284
|
}
|
|
254
285
|
return getControlIsHide(control.parent);
|
|
@@ -258,11 +289,14 @@ item) {
|
|
|
258
289
|
if (getControlIsHide(item)) {
|
|
259
290
|
return;
|
|
260
291
|
}
|
|
292
|
+
var result = Runtime.staticGetRules(item.type, item.props);
|
|
261
293
|
// if (item instanceof RuntimeFormControl) {
|
|
262
294
|
if (item.controlType === CONTROL_BASE_TYPE.FORM) {
|
|
263
|
-
data[item.id] = item.rules
|
|
295
|
+
// data[item.id] = item.rules
|
|
296
|
+
data[item.id] = result;
|
|
264
297
|
} else if (item.type === CONTROL_TYPE.SUBTABLE) {
|
|
265
|
-
data[item.id] = item.rules
|
|
298
|
+
// data[item.id] = item.rules
|
|
299
|
+
data[item.id] = result;
|
|
266
300
|
var itemRules = {
|
|
267
301
|
type: "array",
|
|
268
302
|
fields: {}
|
|
@@ -277,8 +311,13 @@ item) {
|
|
|
277
311
|
fields: {}
|
|
278
312
|
};
|
|
279
313
|
}
|
|
314
|
+
// // @ts-ignore
|
|
315
|
+
// itemRules.fields[index].fields[formControl.id] = (
|
|
316
|
+
// formControl as RuntimeFormControl
|
|
317
|
+
// ).rules
|
|
318
|
+
var childResult = Runtime.staticGetRules(formControl.type, formControl.props);
|
|
280
319
|
// @ts-ignore
|
|
281
|
-
itemRules.fields[index].fields[formControl.id] =
|
|
320
|
+
itemRules.fields[index].fields[formControl.id] = childResult;
|
|
282
321
|
}
|
|
283
322
|
});
|
|
284
323
|
});
|
|
@@ -290,15 +329,19 @@ item) {
|
|
|
290
329
|
if (getControlIsHide(item)) {
|
|
291
330
|
return;
|
|
292
331
|
}
|
|
332
|
+
var result = Runtime.staticGetRules(item.type, item.props);
|
|
293
333
|
// if (item instanceof RuntimeFormControl) {
|
|
294
334
|
if (item.controlType === CONTROL_BASE_TYPE.FORM) {
|
|
295
|
-
antdRules[item.id] = item.rules
|
|
335
|
+
// antdRules[item.id] = item.rules
|
|
336
|
+
antdRules[item.id] = result;
|
|
296
337
|
} else if (item.type === CONTROL_TYPE.SUBTABLE && item.children.length) {
|
|
297
338
|
antdRules[item.id] = [];
|
|
298
339
|
item.children.forEach(function(row) {
|
|
299
340
|
var rules = {};
|
|
300
341
|
loopFormSchema(row.children, function(formControl) {
|
|
301
|
-
rules[formControl.id] = formControl.rules
|
|
342
|
+
// rules[formControl.id] = (formControl as RuntimeFormControl).rules
|
|
343
|
+
var childResult = Runtime.staticGetRules(formControl.type, formControl.props);
|
|
344
|
+
rules[formControl.id] = childResult;
|
|
302
345
|
});
|
|
303
346
|
antdRules[item.id].push(rules);
|
|
304
347
|
});
|
package/dist/esm/common/Store.js
CHANGED
|
@@ -30,13 +30,6 @@ function _define_property(obj, key, value) {
|
|
|
30
30
|
}
|
|
31
31
|
return obj;
|
|
32
32
|
}
|
|
33
|
-
function _instanceof(left, right) {
|
|
34
|
-
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
35
|
-
return !!right[Symbol.hasInstance](left);
|
|
36
|
-
} else {
|
|
37
|
-
return left instanceof right;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
33
|
function _object_spread(target) {
|
|
41
34
|
for(var i = 1; i < arguments.length; i++){
|
|
42
35
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
@@ -52,7 +45,7 @@ function _object_spread(target) {
|
|
|
52
45
|
}
|
|
53
46
|
return target;
|
|
54
47
|
}
|
|
55
|
-
import { DataBind,
|
|
48
|
+
import { DataBind, isDataBind } from "@byteluck-fe/model-driven-core";
|
|
56
49
|
import { loopFormSchema, JSONCopy, warn, CONTROL_TYPE, CONTROL_BASE_TYPE } from "@byteluck-fe/model-driven-shared";
|
|
57
50
|
import { loopDataViewControl, loopFormControl, buildUUID } from "../utils/runtimeUtils";
|
|
58
51
|
var Store = /*#__PURE__*/ function() {
|
|
@@ -82,10 +75,9 @@ var Store = /*#__PURE__*/ function() {
|
|
|
82
75
|
value: function setState(controlId, value, rowIndex) {
|
|
83
76
|
var _this = this;
|
|
84
77
|
var controlInfo = this.controlIdMapping[controlId];
|
|
85
|
-
var noProxyValue = JSONCopy(value);
|
|
86
78
|
if (controlInfo !== undefined) {
|
|
87
79
|
//qiyu 按照对象赋值,Object.assign会触发多次key的change事件
|
|
88
|
-
this.state[controlInfo.dataView][controlId] =
|
|
80
|
+
this.state[controlInfo.dataView][controlId] = value;
|
|
89
81
|
// if (
|
|
90
82
|
// controlInfo.dataBind instanceof ObjectDataBind &&
|
|
91
83
|
// isPlainObject(value)
|
|
@@ -104,7 +96,7 @@ var Store = /*#__PURE__*/ function() {
|
|
|
104
96
|
Object.keys(children).map(function(childControlId) {
|
|
105
97
|
if (childControlId === controlId) {
|
|
106
98
|
if (_this.state[dataView][subtableId][rowIndex]) {
|
|
107
|
-
_this.state[dataView][subtableId][rowIndex][controlId] =
|
|
99
|
+
_this.state[dataView][subtableId][rowIndex][controlId] = value;
|
|
108
100
|
}
|
|
109
101
|
}
|
|
110
102
|
});
|
|
@@ -112,7 +104,7 @@ var Store = /*#__PURE__*/ function() {
|
|
|
112
104
|
});
|
|
113
105
|
} else {
|
|
114
106
|
//不存在的 controlId,直接被挂载到外部key
|
|
115
|
-
this.state[controlId] =
|
|
107
|
+
this.state[controlId] = value;
|
|
116
108
|
}
|
|
117
109
|
}
|
|
118
110
|
}
|
|
@@ -129,7 +121,12 @@ var Store = /*#__PURE__*/ function() {
|
|
|
129
121
|
} else {
|
|
130
122
|
var controlInfo = this.controlIdMapping[controlId];
|
|
131
123
|
if (controlInfo !== undefined) {
|
|
132
|
-
|
|
124
|
+
var data = this.state[controlInfo.dataView][controlId];
|
|
125
|
+
if (rowIndex !== undefined) {
|
|
126
|
+
return data[rowIndex];
|
|
127
|
+
} else {
|
|
128
|
+
return data;
|
|
129
|
+
}
|
|
133
130
|
} else {
|
|
134
131
|
if (rowIndex !== undefined) {
|
|
135
132
|
var state;
|
|
@@ -288,7 +285,8 @@ item) {
|
|
|
288
285
|
// if (item instanceof RuntimeFormControl) {
|
|
289
286
|
if (item.controlType === CONTROL_BASE_TYPE.FORM) {
|
|
290
287
|
var _item_props_dataBind, _item_props;
|
|
291
|
-
if (
|
|
288
|
+
// if (item.props.dataBind instanceof ObjectDataBind) {
|
|
289
|
+
if (!isDataBind(item.props.dataBind)) {
|
|
292
290
|
// 特殊的dataBind,比如:金额是currency+amount两个key组成的,日期区间,继承自ObjectDataBind的需要通过Object.keys拿到多个databind
|
|
293
291
|
Object.keys(item.props.dataBind).map(function(key) {
|
|
294
292
|
var dataBind = item.props.dataBind;
|
|
@@ -343,7 +341,8 @@ item) {
|
|
|
343
341
|
};
|
|
344
342
|
var subtableId = item.id;
|
|
345
343
|
loopFormSchema(item.props.headers, function(item) {
|
|
346
|
-
if (
|
|
344
|
+
// if (item.props.dataBind instanceof ObjectDataBind) {
|
|
345
|
+
if (!isDataBind(item.props.dataBind)) {
|
|
347
346
|
Object.keys(item.props.dataBind).map(function(key) {
|
|
348
347
|
var dataBind = item.props.dataBind;
|
|
349
348
|
var dataCode = dataBind[key].dataCode;
|
|
@@ -63,13 +63,6 @@ function _inherits(subClass, superClass) {
|
|
|
63
63
|
});
|
|
64
64
|
if (superClass) _set_prototype_of(subClass, superClass);
|
|
65
65
|
}
|
|
66
|
-
function _instanceof(left, right) {
|
|
67
|
-
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
68
|
-
return !!right[Symbol.hasInstance](left);
|
|
69
|
-
} else {
|
|
70
|
-
return left instanceof right;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
66
|
function _iterable_to_array_limit(arr, i) {
|
|
74
67
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
75
68
|
if (_i == null) return;
|
|
@@ -254,13 +247,13 @@ var StringArrayValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
254
247
|
{
|
|
255
248
|
key: "transform",
|
|
256
249
|
value: function transform(value) {
|
|
257
|
-
|
|
250
|
+
if (value === undefined || value === null) {
|
|
251
|
+
return [];
|
|
252
|
+
}
|
|
253
|
+
function getStringValueArray(value) {
|
|
258
254
|
return value.map(function(item) {
|
|
259
255
|
return !item ? "" : String(item);
|
|
260
256
|
});
|
|
261
|
-
};
|
|
262
|
-
if (value === undefined || value === null) {
|
|
263
|
-
return [];
|
|
264
257
|
}
|
|
265
258
|
if (isArray(value)) {
|
|
266
259
|
return getStringValueArray(value);
|
|
@@ -299,15 +292,15 @@ var NumberArrayValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
299
292
|
{
|
|
300
293
|
key: "transform",
|
|
301
294
|
value: function transform(value) {
|
|
302
|
-
|
|
295
|
+
if (value === undefined || value === null) {
|
|
296
|
+
return [];
|
|
297
|
+
}
|
|
298
|
+
function getNumberValueArray(value) {
|
|
303
299
|
return value.map(function(item) {
|
|
304
300
|
return !item && item !== 0 ? "" : Number(item);
|
|
305
301
|
}).filter(function(item) {
|
|
306
302
|
return item === "" || !Number.isNaN(item);
|
|
307
303
|
});
|
|
308
|
-
};
|
|
309
|
-
if (value === undefined || value === null) {
|
|
310
|
-
return [];
|
|
311
304
|
}
|
|
312
305
|
if (isArray(value)) {
|
|
313
306
|
return getNumberValueArray(value);
|
|
@@ -344,7 +337,8 @@ var MoneyValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
344
337
|
{
|
|
345
338
|
key: "validate",
|
|
346
339
|
value: function validate(value) {
|
|
347
|
-
return
|
|
340
|
+
return(// value instanceof AmountValue ||
|
|
341
|
+
isPlainObject(value) && "amount" in value && isNumber(value.amount) && "currency" in value && isString(value.currency));
|
|
348
342
|
}
|
|
349
343
|
},
|
|
350
344
|
{
|
|
@@ -394,7 +388,8 @@ var TimeScopeValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
394
388
|
{
|
|
395
389
|
key: "validate",
|
|
396
390
|
value: function validate(value) {
|
|
397
|
-
return
|
|
391
|
+
return(// value instanceof RangeDateValue ||
|
|
392
|
+
isPlainObject(value) && "min" in value && isString(value.min) && "max" in value && isString(value.max));
|
|
398
393
|
}
|
|
399
394
|
},
|
|
400
395
|
{
|
|
@@ -441,7 +436,8 @@ var CalcValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
441
436
|
{
|
|
442
437
|
key: "validate",
|
|
443
438
|
value: function validate(value) {
|
|
444
|
-
return
|
|
439
|
+
return(// value instanceof CalcValue ||
|
|
440
|
+
isPlainObject(value) && "result" in value && isNumber(value.result) && "unit" in value && isString(value.unit));
|
|
445
441
|
}
|
|
446
442
|
},
|
|
447
443
|
{
|
|
@@ -491,7 +487,18 @@ var AddressValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
491
487
|
{
|
|
492
488
|
key: "validate",
|
|
493
489
|
value: function validate(value) {
|
|
494
|
-
return
|
|
490
|
+
// return value instanceof AddressValue
|
|
491
|
+
if (isPlainObject(value)) {
|
|
492
|
+
// city?: string;
|
|
493
|
+
// cityDisplay?: string;
|
|
494
|
+
// district?: string;
|
|
495
|
+
// districtDisplay?: string;
|
|
496
|
+
// province?: string;
|
|
497
|
+
// provinceDisplay?: string
|
|
498
|
+
return true;
|
|
499
|
+
} else {
|
|
500
|
+
return false;
|
|
501
|
+
}
|
|
495
502
|
}
|
|
496
503
|
},
|
|
497
504
|
{
|
|
@@ -24,7 +24,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
24
24
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
25
25
|
}
|
|
26
26
|
var cc = console;
|
|
27
|
-
import { CONTROL_BASE_TYPE, error, logerror
|
|
27
|
+
import { CONTROL_BASE_TYPE, error, logerror } from "@byteluck-fe/model-driven-shared";
|
|
28
28
|
var proxyArrayApi = [
|
|
29
29
|
"splice",
|
|
30
30
|
"push",
|
|
@@ -125,7 +125,11 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
|
|
|
125
125
|
return Reflect.get(target, propertyKey, receiver);
|
|
126
126
|
},
|
|
127
127
|
set: function set(target, propertyKey, value, receiver) {
|
|
128
|
-
var
|
|
128
|
+
var newValue = value;
|
|
129
|
+
// @ts-ignore
|
|
130
|
+
var oldValue = target[propertyKey];
|
|
131
|
+
var concatKey = thisKey === "" ? propertyKey : thisKey + "." + propertyKey;
|
|
132
|
+
function reProxyState(value) {
|
|
129
133
|
if (typeof value === "object" && value !== null) {
|
|
130
134
|
// @ts-ignore
|
|
131
135
|
if (value[engineProxyFlag] !== true) {
|
|
@@ -136,20 +140,16 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
|
|
|
136
140
|
value[engineTargetKey], callback, beforeSetCallback, concatKey);
|
|
137
141
|
}
|
|
138
142
|
}
|
|
139
|
-
}
|
|
140
|
-
var newValue = JSONCopy(value);
|
|
141
|
-
// @ts-ignore
|
|
142
|
-
var oldValue = target[propertyKey];
|
|
143
|
-
var concatKey = thisKey === "" ? propertyKey : thisKey + "." + propertyKey;
|
|
143
|
+
}
|
|
144
144
|
var _reProxyState;
|
|
145
|
-
newValue = (_reProxyState = reProxyState(
|
|
145
|
+
newValue = (_reProxyState = reProxyState(value)) !== null && _reProxyState !== void 0 ? _reProxyState : 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,
|
|
152
|
+
var nextHandler = ArrayHandler(target, propertyKey, value, 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,
|
|
174
|
+
callback.call(null, target, concatKey, value, oldValue);
|
|
175
175
|
}
|
|
176
176
|
// 不返回falsy 值(即 false、0、null、undefined、空字符串等)
|
|
177
177
|
//fix: TypeError: Proxy object's 'set' trap returned falsy value for property 'length'
|
|
@@ -205,7 +205,7 @@ function flatInstanceForChildren(controls) {
|
|
|
205
205
|
var result = [];
|
|
206
206
|
controls.forEach(function(item) {
|
|
207
207
|
result.push(item);
|
|
208
|
-
if (item.controlType === "layout") {
|
|
208
|
+
if (item.controlType === "layout" || item.controlType === "wrap") {
|
|
209
209
|
var _result;
|
|
210
210
|
(_result = result).push.apply(_result, _to_consumable_array(flatInstanceForChildren(item.children)));
|
|
211
211
|
}
|
|
@@ -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,11 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
194
196
|
* */ function allCalcControlComputed() {
|
|
195
197
|
var _this = this;
|
|
196
198
|
this.calcControls.forEach(function(item) {
|
|
197
|
-
|
|
199
|
+
// this.engine.getState(item.id)
|
|
200
|
+
if (item.props.dataBind.result.fieldCode === null || item.props.dataBind.result.fieldCode === undefined) {
|
|
201
|
+
// formEngineModel在custom:beforeEngineMounted时调用二开赋值,表单值 set 了却没有做计算。但这个是正常的
|
|
202
|
+
_this.computedCalcValue(item);
|
|
203
|
+
}
|
|
198
204
|
});
|
|
199
205
|
}
|
|
200
206
|
},
|
|
@@ -287,6 +293,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
287
293
|
var _this = this;
|
|
288
294
|
this.engine.on("list-change", function(payload) {
|
|
289
295
|
var _payload_options;
|
|
296
|
+
// 初始化前是批量操作。不做处理
|
|
297
|
+
if (_this.engine.isMounted === false) return;
|
|
290
298
|
_this.resetDependencies();
|
|
291
299
|
var _payload_options_changed;
|
|
292
300
|
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 +320,8 @@ export var CalcPlugin = /*#__PURE__*/ function() {
|
|
|
312
320
|
* */ function watchControlChange() {
|
|
313
321
|
var _this = this;
|
|
314
322
|
this.engine.on("change", function(payload) {
|
|
323
|
+
// 初始化前是批量操作。不做处理
|
|
324
|
+
if (_this.engine.isMounted === false) return;
|
|
315
325
|
var instance = payload.instance;
|
|
316
326
|
if (!_this.dependenciesTriggerMap.has(instance.id)) {
|
|
317
327
|
return;
|
|
@@ -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
|
];
|
|
@@ -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
|
}
|
|
@@ -8,7 +8,8 @@ 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 === null || item === void 0 ? void 0 : item.children, callback);
|