@byteluck-fe/model-driven-engine 2.8.1-alpha.8 → 2.8.1-beta.9
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/Runtime.js +46 -15
- package/dist/esm/common/Store.js +4 -3
- package/dist/esm/common/proxyState.js +5 -5
- package/dist/esm/plugins/ControlsEventPlugin.js +1 -1
- package/dist/esm/plugins/StylePlugin.js +7 -1
- package/dist/index.umd.js +8 -8
- package/dist/types/common/Engine.d.ts +7 -0
- package/dist/types/common/Runtime.d.ts +4 -0
- package/package.json +4 -4
|
@@ -180,26 +180,33 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls) {
|
|
|
180
180
|
{
|
|
181
181
|
key: "allRules",
|
|
182
182
|
get: function get() {
|
|
183
|
-
var
|
|
184
|
-
var
|
|
183
|
+
var defaultAntdRules = {};
|
|
184
|
+
var defaultRule = {};
|
|
185
|
+
var defaultFieldRules = {};
|
|
185
186
|
loopDataViewControl(this._instance, function(dataView) {
|
|
186
187
|
var result = Runtime.staticGetRules(dataView.type, dataView.props);
|
|
187
|
-
|
|
188
|
-
|
|
188
|
+
defaultRule[dataView.id] = JSONCopy(result[0]);
|
|
189
|
+
defaultAntdRules[dataView.id] = JSONCopy(result[0]);
|
|
190
|
+
defaultFieldRules[dataView.id] = JSONCopy(result[0]);
|
|
189
191
|
loopFormControl(dataView.children, function(item) {
|
|
190
192
|
// if (
|
|
191
193
|
// item instanceof RuntimeFormControl ||
|
|
192
194
|
// item instanceof RuntimeListControl
|
|
193
195
|
// ) {
|
|
194
196
|
if (item.controlType === CONTROL_BASE_TYPE.FORM || item.controlType === CONTROL_BASE_TYPE.LIST) {
|
|
195
|
-
buildControlRules(
|
|
196
|
-
buildControlAntdRules(
|
|
197
|
+
buildControlRules(defaultRule[dataView.id].fields, item, true);
|
|
198
|
+
buildControlAntdRules(defaultAntdRules[dataView.id].fields, item, true);
|
|
199
|
+
buildFieldCodeRules(defaultFieldRules[dataView.id].fields, item, true);
|
|
197
200
|
}
|
|
198
201
|
});
|
|
199
202
|
});
|
|
200
203
|
return {
|
|
201
|
-
rules:
|
|
202
|
-
antdRules: antdRules
|
|
204
|
+
rules: this.rules,
|
|
205
|
+
antdRules: this.antdRules,
|
|
206
|
+
fieldCodeRules: this.fieldCodeRules,
|
|
207
|
+
defaultAntdRules: defaultAntdRules,
|
|
208
|
+
defaultRule: defaultRule,
|
|
209
|
+
defaultFieldRules: defaultFieldRules
|
|
203
210
|
};
|
|
204
211
|
}
|
|
205
212
|
},
|
|
@@ -307,6 +314,7 @@ function hasHeaderOrFooterControl(control, checkType) {
|
|
|
307
314
|
}
|
|
308
315
|
function buildControlRules(data, // @ts-ignore
|
|
309
316
|
item) {
|
|
317
|
+
var isSubtableDefaultRules = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
|
|
310
318
|
if (getControlIsHide(item)) {
|
|
311
319
|
return;
|
|
312
320
|
}
|
|
@@ -322,7 +330,11 @@ item) {
|
|
|
322
330
|
type: "array",
|
|
323
331
|
fields: {}
|
|
324
332
|
};
|
|
325
|
-
|
|
333
|
+
(isSubtableDefaultRules === true ? [
|
|
334
|
+
{
|
|
335
|
+
children: item.props.headers
|
|
336
|
+
}
|
|
337
|
+
] : item.children).forEach(function(row, index) {
|
|
326
338
|
loopFormSchema(row.children, function(formControl) {
|
|
327
339
|
if (itemRules.fields) {
|
|
328
340
|
if (!itemRules.fields[index]) {
|
|
@@ -347,6 +359,7 @@ item) {
|
|
|
347
359
|
}
|
|
348
360
|
function buildFieldCodeRules(data, // @ts-ignore
|
|
349
361
|
item) {
|
|
362
|
+
var isSubtableDefaultRules = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
|
|
350
363
|
if (getControlIsHide(item)) {
|
|
351
364
|
return;
|
|
352
365
|
}
|
|
@@ -365,9 +378,9 @@ item) {
|
|
|
365
378
|
// @ts-ignore
|
|
366
379
|
if (((_item_props_dataBind_dataBindKey = item.props.dataBind[dataBindKey]) === null || _item_props_dataBind_dataBindKey === void 0 ? void 0 : _item_props_dataBind_dataBindKey.fieldCode) != "") {
|
|
367
380
|
var // @ts-ignore
|
|
368
|
-
_item_props_dataBind_dataBindKey1;
|
|
381
|
+
_item_props_dataBind_dataBindKey1, _findFields;
|
|
369
382
|
// @ts-ignore
|
|
370
|
-
data[(_item_props_dataBind_dataBindKey1 = item.props.dataBind[dataBindKey]) === null || _item_props_dataBind_dataBindKey1 === void 0 ? void 0 : _item_props_dataBind_dataBindKey1.fieldCode] = result
|
|
383
|
+
data[(_item_props_dataBind_dataBindKey1 = item.props.dataBind[dataBindKey]) === null || _item_props_dataBind_dataBindKey1 === void 0 ? void 0 : _item_props_dataBind_dataBindKey1.fieldCode] = ((_findFields = findFields(result)) === null || _findFields === void 0 ? void 0 : _findFields[dataBindKey]) || [];
|
|
371
384
|
}
|
|
372
385
|
}
|
|
373
386
|
}
|
|
@@ -378,7 +391,11 @@ item) {
|
|
|
378
391
|
type: "array",
|
|
379
392
|
fields: {}
|
|
380
393
|
};
|
|
381
|
-
|
|
394
|
+
(isSubtableDefaultRules === true ? [
|
|
395
|
+
{
|
|
396
|
+
children: item.props.headers
|
|
397
|
+
}
|
|
398
|
+
] : item.children).forEach(function(row, index) {
|
|
382
399
|
loopFormSchema(row.children, function(formControl) {
|
|
383
400
|
if (itemRules.fields) {
|
|
384
401
|
if (!itemRules.fields[index]) {
|
|
@@ -394,10 +411,10 @@ item) {
|
|
|
394
411
|
var _formControl_props_dataBind_dataBindKey;
|
|
395
412
|
// @ts-ignore
|
|
396
413
|
if (((_formControl_props_dataBind_dataBindKey = formControl.props.dataBind[dataBindKey]) === null || _formControl_props_dataBind_dataBindKey === void 0 ? void 0 : _formControl_props_dataBind_dataBindKey.fieldCode) != "") {
|
|
397
|
-
var
|
|
414
|
+
var _findFields;
|
|
398
415
|
// @ts-ignore
|
|
399
416
|
itemRules.fields[index].fields[// @ts-ignore
|
|
400
|
-
formControl.props.dataBind[dataBindKey].fieldCode] = (
|
|
417
|
+
formControl.props.dataBind[dataBindKey].fieldCode] = ((_findFields = findFields(childResult)) === null || _findFields === void 0 ? void 0 : _findFields[dataBindKey]) || [];
|
|
401
418
|
}
|
|
402
419
|
}
|
|
403
420
|
} else {
|
|
@@ -414,8 +431,18 @@ item) {
|
|
|
414
431
|
data[(_item_props_datasourceBind1 = item.props.datasourceBind) === null || _item_props_datasourceBind1 === void 0 ? void 0 : _item_props_datasourceBind1.dataCode].push(itemRules);
|
|
415
432
|
}
|
|
416
433
|
}
|
|
434
|
+
function findFields(childResult) {
|
|
435
|
+
var ruleItem = {};
|
|
436
|
+
childResult.map(function(item) {
|
|
437
|
+
if (item.fields) {
|
|
438
|
+
ruleItem = item;
|
|
439
|
+
}
|
|
440
|
+
});
|
|
441
|
+
return ruleItem === null || ruleItem === void 0 ? void 0 : ruleItem.fields;
|
|
442
|
+
}
|
|
417
443
|
function buildControlAntdRules(antdRules, // @ts-ignore
|
|
418
444
|
item) {
|
|
445
|
+
var isSubtableDefaultRules = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : false;
|
|
419
446
|
if (getControlIsHide(item)) {
|
|
420
447
|
return;
|
|
421
448
|
}
|
|
@@ -426,7 +453,11 @@ item) {
|
|
|
426
453
|
antdRules[item.id] = result;
|
|
427
454
|
} else if (item.type === CONTROL_TYPE.SUBTABLE && item.children.length) {
|
|
428
455
|
antdRules[item.id] = [];
|
|
429
|
-
|
|
456
|
+
(isSubtableDefaultRules === true ? [
|
|
457
|
+
{
|
|
458
|
+
children: item.props.headers
|
|
459
|
+
}
|
|
460
|
+
] : item.children).forEach(function(row) {
|
|
430
461
|
var rules = {};
|
|
431
462
|
loopFormSchema(row.children, function(formControl) {
|
|
432
463
|
// rules[formControl.id] = (formControl as RuntimeFormControl).rules
|
package/dist/esm/common/Store.js
CHANGED
|
@@ -77,9 +77,10 @@ var Store = /*#__PURE__*/ function() {
|
|
|
77
77
|
value: function setState(controlId, value, rowIndex) {
|
|
78
78
|
var _this = this;
|
|
79
79
|
var controlInfo = this.controlIdMapping[controlId];
|
|
80
|
+
var noProxyValue = JSONCopy(value);
|
|
80
81
|
if (controlInfo !== undefined) {
|
|
81
82
|
//qiyu 按照对象赋值,Object.assign会触发多次key的change事件
|
|
82
|
-
this.state[controlInfo.dataView][controlId] =
|
|
83
|
+
this.state[controlInfo.dataView][controlId] = noProxyValue;
|
|
83
84
|
// if (
|
|
84
85
|
// controlInfo.dataBind instanceof ObjectDataBind &&
|
|
85
86
|
// isPlainObject(value)
|
|
@@ -98,7 +99,7 @@ var Store = /*#__PURE__*/ function() {
|
|
|
98
99
|
Object.keys(children).map(function(childControlId) {
|
|
99
100
|
if (childControlId === controlId) {
|
|
100
101
|
if (_this.state[dataView][subtableId][rowIndex]) {
|
|
101
|
-
_this.state[dataView][subtableId][rowIndex][controlId] =
|
|
102
|
+
_this.state[dataView][subtableId][rowIndex][controlId] = noProxyValue;
|
|
102
103
|
}
|
|
103
104
|
}
|
|
104
105
|
});
|
|
@@ -106,7 +107,7 @@ var Store = /*#__PURE__*/ function() {
|
|
|
106
107
|
});
|
|
107
108
|
} else {
|
|
108
109
|
//不存在的 controlId,直接被挂载到外部key
|
|
109
|
-
this.state[controlId] =
|
|
110
|
+
this.state[controlId] = noProxyValue;
|
|
110
111
|
}
|
|
111
112
|
}
|
|
112
113
|
}
|
|
@@ -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 } from "@byteluck-fe/model-driven-shared";
|
|
27
|
+
import { CONTROL_BASE_TYPE, error, logerror, JSONCopy } from "@byteluck-fe/model-driven-shared";
|
|
28
28
|
var proxyArrayApi = [
|
|
29
29
|
"splice",
|
|
30
30
|
"push",
|
|
@@ -125,7 +125,7 @@ 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 newValue = value;
|
|
128
|
+
var newValue = JSONCopy(value);
|
|
129
129
|
// @ts-ignore
|
|
130
130
|
var oldValue = target[propertyKey];
|
|
131
131
|
var concatKey = thisKey === "" ? propertyKey : thisKey + "." + propertyKey;
|
|
@@ -142,14 +142,14 @@ function ArrayHandler(target, propertyKey, value, thisKey, callback) {
|
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
var _reProxyState;
|
|
145
|
-
newValue = (_reProxyState = reProxyState(
|
|
145
|
+
newValue = (_reProxyState = reProxyState(newValue)) !== 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, newValue, 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, newValue, 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'
|
|
@@ -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 (eventKey === "change" && !_this.engine.isMounted) {
|
|
216
|
+
if ((eventKey === "change" || eventKey === "list-change") && !_this.engine.isMounted) {
|
|
217
217
|
return [
|
|
218
218
|
2
|
|
219
219
|
];
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
/*
|
|
2
|
+
* @Author: zhaoxiaoyang zhaoxiaoyang@byteluck.com
|
|
3
|
+
* @Date: 2022-04-15 14:06:03
|
|
4
|
+
* @LastEditors: zhaoxiaoyang zhaoxiaoyang@byteluck.com
|
|
5
|
+
* @LastEditTime: 2023-11-30 16:38:47
|
|
6
|
+
* @FilePath: /model-driven/packages/engine/src/plugins/StylePlugin.ts
|
|
7
|
+
*/ function _class_call_check(instance, Constructor) {
|
|
2
8
|
if (!(instance instanceof Constructor)) {
|
|
3
9
|
throw new TypeError("Cannot call a class as a function");
|
|
4
10
|
}
|