@byteluck-fe/model-driven-engine 2.7.0-alpha.2 → 2.7.0-alpha.21
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/ActionManager.js +114 -79
- package/dist/esm/common/DataManager.js +80 -39
- package/dist/esm/common/Engine.js +1205 -985
- package/dist/esm/common/OkWorker.js +121 -76
- package/dist/esm/common/Plugin.js +2 -2
- package/dist/esm/common/Runtime.js +66 -45
- package/dist/esm/common/Store.js +168 -137
- package/dist/esm/common/checkerValue.js +383 -299
- package/dist/esm/common/proxyState.js +18 -17
- package/dist/esm/plugins/CalcPlugin.js +406 -321
- package/dist/esm/plugins/ControlsEventPlugin.js +174 -135
- package/dist/esm/plugins/ES6ModulePlugin.js +77 -43
- package/dist/esm/plugins/LifecycleEventPlugin.js +134 -98
- package/dist/esm/plugins/StylePlugin.js +48 -15
- package/dist/esm/utils/runtimeUtils.js +6 -3
- package/dist/index.umd.js +11 -11
- package/dist/types/common/Engine.d.ts +1 -1
- package/package.json +4 -4
package/dist/esm/common/Store.js
CHANGED
|
@@ -1,9 +1,23 @@
|
|
|
1
|
-
function
|
|
1
|
+
function _class_call_check(instance, Constructor) {
|
|
2
2
|
if (!(instance instanceof Constructor)) {
|
|
3
3
|
throw new TypeError("Cannot call a class as a function");
|
|
4
4
|
}
|
|
5
5
|
}
|
|
6
|
-
function
|
|
6
|
+
function _defineProperties(target, props) {
|
|
7
|
+
for(var i = 0; i < props.length; i++){
|
|
8
|
+
var descriptor = props[i];
|
|
9
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
10
|
+
descriptor.configurable = true;
|
|
11
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
12
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
16
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
17
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
18
|
+
return Constructor;
|
|
19
|
+
}
|
|
20
|
+
function _define_property(obj, key, value) {
|
|
7
21
|
if (key in obj) {
|
|
8
22
|
Object.defineProperty(obj, key, {
|
|
9
23
|
value: value,
|
|
@@ -16,14 +30,7 @@ function _defineProperty(obj, key, value) {
|
|
|
16
30
|
}
|
|
17
31
|
return obj;
|
|
18
32
|
}
|
|
19
|
-
function
|
|
20
|
-
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
21
|
-
return !!right[Symbol.hasInstance](left);
|
|
22
|
-
} else {
|
|
23
|
-
return left instanceof right;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
function _objectSpread(target) {
|
|
33
|
+
function _object_spread(target) {
|
|
27
34
|
for(var i = 1; i < arguments.length; i++){
|
|
28
35
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
29
36
|
var ownKeys = Object.keys(source);
|
|
@@ -33,18 +40,24 @@ function _objectSpread(target) {
|
|
|
33
40
|
}));
|
|
34
41
|
}
|
|
35
42
|
ownKeys.forEach(function(key) {
|
|
36
|
-
|
|
43
|
+
_define_property(target, key, source[key]);
|
|
37
44
|
});
|
|
38
45
|
}
|
|
39
46
|
return target;
|
|
40
47
|
}
|
|
41
|
-
import { DataBind,
|
|
48
|
+
import { DataBind, isDataBind } from "@byteluck-fe/model-driven-core";
|
|
42
49
|
import { loopFormSchema, JSONCopy, warn, CONTROL_TYPE, CONTROL_BASE_TYPE } from "@byteluck-fe/model-driven-shared";
|
|
43
50
|
import { loopDataViewControl, loopFormControl, buildUUID } from "../utils/runtimeUtils";
|
|
44
51
|
var Store = /*#__PURE__*/ function() {
|
|
45
52
|
"use strict";
|
|
46
53
|
function Store(props) {
|
|
47
|
-
|
|
54
|
+
_class_call_check(this, Store);
|
|
55
|
+
_define_property(this, "emptyState", void 0);
|
|
56
|
+
_define_property(this, "state", void 0);
|
|
57
|
+
_define_property(this, "dataBindMapping", void 0 // 主要提供给二开使用
|
|
58
|
+
);
|
|
59
|
+
_define_property(this, "controlIdMapping", void 0);
|
|
60
|
+
_define_property(this, "defaultState", void 0);
|
|
48
61
|
var _init = init(props.instance), state = _init.state, emptyState = _init.emptyState, databindMapping = _init.databindMapping, controlidMapping = _init.controlidMapping, defaultState = _init.defaultState;
|
|
49
62
|
this.emptyState = emptyState;
|
|
50
63
|
this.state = state;
|
|
@@ -52,145 +65,161 @@ var Store = /*#__PURE__*/ function() {
|
|
|
52
65
|
this.controlIdMapping = controlidMapping;
|
|
53
66
|
this.defaultState = defaultState;
|
|
54
67
|
}
|
|
55
|
-
|
|
56
|
-
|
|
68
|
+
_create_class(Store, [
|
|
69
|
+
{
|
|
70
|
+
/**
|
|
57
71
|
* 使用该方法仅改变数据,不会表单触发事件。明细表可全量赋值也可根据rowIndex进行单独设置
|
|
58
72
|
* @param controlId 组件ID
|
|
59
73
|
* @param value
|
|
60
|
-
*/
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
74
|
+
*/ key: "setState",
|
|
75
|
+
value: function setState(controlId, value, rowIndex) {
|
|
76
|
+
var _this = this;
|
|
77
|
+
var controlInfo = this.controlIdMapping[controlId];
|
|
78
|
+
if (controlInfo !== undefined) {
|
|
79
|
+
//qiyu 按照对象赋值,Object.assign会触发多次key的change事件
|
|
80
|
+
this.state[controlInfo.dataView][controlId] = value;
|
|
81
|
+
// if (
|
|
82
|
+
// controlInfo.dataBind instanceof ObjectDataBind &&
|
|
83
|
+
// isPlainObject(value)
|
|
84
|
+
// ) {
|
|
85
|
+
// Object.assign(this.state[controlInfo.dataView][controlId], value)
|
|
86
|
+
// } else {
|
|
87
|
+
// this.state[controlInfo.dataView][controlId] = value
|
|
88
|
+
// }
|
|
89
|
+
} else {
|
|
90
|
+
if (rowIndex !== undefined) {
|
|
91
|
+
//TODO 目前只找了一层明细表,没有递归 如果是添加uid
|
|
92
|
+
Object.keys(this.controlIdMapping).map(function(subtableId) {
|
|
93
|
+
var dataView = _this.controlIdMapping[subtableId].dataView;
|
|
94
|
+
var children = _this.controlIdMapping[subtableId].children;
|
|
95
|
+
if (children !== undefined) {
|
|
96
|
+
Object.keys(children).map(function(childControlId) {
|
|
97
|
+
if (childControlId === controlId) {
|
|
98
|
+
if (_this.state[dataView][subtableId][rowIndex]) {
|
|
99
|
+
_this.state[dataView][subtableId][rowIndex][controlId] = value;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
});
|
|
84
103
|
}
|
|
85
104
|
});
|
|
105
|
+
} else {
|
|
106
|
+
//不存在的 controlId,直接被挂载到外部key
|
|
107
|
+
this.state[controlId] = value;
|
|
86
108
|
}
|
|
87
|
-
}
|
|
88
|
-
} else {
|
|
89
|
-
//不存在的 controlId,直接被挂载到外部key
|
|
90
|
-
this.state[controlId] = value;
|
|
109
|
+
}
|
|
91
110
|
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
key: "getState",
|
|
114
|
+
value: function getState(controlId, rowIndex) {
|
|
115
|
+
var _this = this;
|
|
116
|
+
//qiyu 由于header的数据是后补充的,所以从state获取第一层值。
|
|
117
|
+
// const controlInfo = this.controlIdMapping[controlId]
|
|
118
|
+
var detection = this.state[controlId];
|
|
119
|
+
if (detection !== undefined) {
|
|
120
|
+
return this.state[controlId];
|
|
121
|
+
} else {
|
|
122
|
+
var controlInfo = this.controlIdMapping[controlId];
|
|
123
|
+
if (controlInfo !== undefined) {
|
|
124
|
+
return this.state[controlInfo.dataView][controlId];
|
|
125
|
+
} else {
|
|
126
|
+
if (rowIndex !== undefined) {
|
|
127
|
+
var state;
|
|
128
|
+
//TODO 目前只找了一层明细表,没有递归
|
|
129
|
+
Object.keys(this.controlIdMapping).map(function(subtableId) {
|
|
130
|
+
var dataViewId = _this.controlIdMapping[subtableId].dataView;
|
|
131
|
+
var children = _this.controlIdMapping[subtableId].children;
|
|
132
|
+
if (children !== undefined) {
|
|
133
|
+
Object.keys(children).map(function(childControlId) {
|
|
134
|
+
if (childControlId === controlId) {
|
|
135
|
+
var _this_state_dataViewId_subtableId_rowIndex;
|
|
136
|
+
state = (_this_state_dataViewId_subtableId_rowIndex = _this.state[dataViewId][subtableId][rowIndex]) === null || _this_state_dataViewId_subtableId_rowIndex === void 0 ? void 0 : _this_state_dataViewId_subtableId_rowIndex[controlId];
|
|
137
|
+
}
|
|
138
|
+
});
|
|
117
139
|
}
|
|
118
140
|
});
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
141
|
+
return state;
|
|
142
|
+
} else {
|
|
143
|
+
var states = [];
|
|
144
|
+
Object.keys(this.controlIdMapping).map(function(subtableId) {
|
|
145
|
+
var dataViewId = _this.controlIdMapping[subtableId].dataView;
|
|
146
|
+
var children = _this.controlIdMapping[subtableId].children;
|
|
147
|
+
if (children !== undefined) {
|
|
148
|
+
Object.keys(children).map(function(childControlId) {
|
|
149
|
+
if (childControlId === controlId) {
|
|
150
|
+
_this.state[dataViewId][subtableId].map(function(item) {
|
|
151
|
+
states.push(item[controlId]);
|
|
152
|
+
});
|
|
153
|
+
}
|
|
132
154
|
});
|
|
133
155
|
}
|
|
134
156
|
});
|
|
157
|
+
return states;
|
|
135
158
|
}
|
|
136
|
-
}
|
|
137
|
-
return states;
|
|
159
|
+
}
|
|
138
160
|
}
|
|
139
161
|
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
key: "getEmptyState",
|
|
165
|
+
value: function getEmptyState(controlId) {
|
|
166
|
+
var _this = this;
|
|
167
|
+
var detection = this.emptyState[controlId];
|
|
168
|
+
if (detection !== undefined) {
|
|
169
|
+
return this.emptyState[controlId];
|
|
170
|
+
} else {
|
|
171
|
+
var controlInfo = this.controlIdMapping[controlId];
|
|
172
|
+
if (controlInfo !== undefined) {
|
|
173
|
+
var state = this.emptyState[controlInfo.dataView][controlId];
|
|
174
|
+
//判断找到的是否是明细表的控件
|
|
175
|
+
if ("children" in controlInfo) {
|
|
176
|
+
Object.assign(state, {
|
|
177
|
+
uid: "new:" + buildUUID("uid")
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
return state;
|
|
181
|
+
} else {
|
|
182
|
+
var state1;
|
|
183
|
+
//TODO 目前只找了一层明细表,没有递归
|
|
184
|
+
Object.keys(this.controlIdMapping).map(function(subtableId) {
|
|
185
|
+
var dataViewId = _this.controlIdMapping[subtableId].dataView;
|
|
186
|
+
var children = _this.controlIdMapping[subtableId].children;
|
|
187
|
+
if (children !== undefined) {
|
|
188
|
+
Object.keys(children).map(function(childControlId) {
|
|
189
|
+
if (childControlId === controlId) {
|
|
190
|
+
state1 = _this.emptyState[dataViewId][subtableId][controlId];
|
|
191
|
+
}
|
|
192
|
+
});
|
|
168
193
|
}
|
|
169
194
|
});
|
|
195
|
+
return state1;
|
|
170
196
|
}
|
|
171
|
-
}
|
|
172
|
-
return state1;
|
|
197
|
+
}
|
|
173
198
|
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
if (
|
|
186
|
-
|
|
187
|
-
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
key: "getDataBind",
|
|
202
|
+
value: function getDataBind(controlId) {
|
|
203
|
+
var _result;
|
|
204
|
+
var result = this.controlIdMapping[controlId];
|
|
205
|
+
if (result) {
|
|
206
|
+
return result.dataBind;
|
|
207
|
+
}
|
|
208
|
+
wrapperFor: for(var id in this.controlIdMapping){
|
|
209
|
+
var dataBindMapping = this.controlIdMapping[id];
|
|
210
|
+
if (dataBindMapping.children) {
|
|
211
|
+
for(var subId in dataBindMapping.children){
|
|
212
|
+
if (subId === controlId) {
|
|
213
|
+
result = dataBindMapping.children[subId];
|
|
214
|
+
break wrapperFor;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
188
217
|
}
|
|
189
218
|
}
|
|
219
|
+
return (_result = result) === null || _result === void 0 ? void 0 : _result.dataBind;
|
|
190
220
|
}
|
|
191
221
|
}
|
|
192
|
-
|
|
193
|
-
};
|
|
222
|
+
]);
|
|
194
223
|
return Store;
|
|
195
224
|
}();
|
|
196
225
|
function init(instance) {
|
|
@@ -238,12 +267,12 @@ item) {
|
|
|
238
267
|
loopFormSchema(item.props.headers, function(headerItem) {
|
|
239
268
|
emptyTemplate[headerItem.id] = JSONCopy(headerItem.props.defaultValue);
|
|
240
269
|
});
|
|
241
|
-
var _item_props_defaultRows;
|
|
242
|
-
dataViewState[item.id] = new Array((_item_props_defaultRows = item.props.defaultRows) !== null && _item_props_defaultRows !== void 0 ? _item_props_defaultRows : 1).fill(0).map(function() {
|
|
243
|
-
return
|
|
270
|
+
var _item_props_defaultRows, _fill_map;
|
|
271
|
+
dataViewState[item.id] = (_fill_map = new Array((_item_props_defaultRows = item.props.defaultRows) !== null && _item_props_defaultRows !== void 0 ? _item_props_defaultRows : 1).fill(0).map(function() {
|
|
272
|
+
return _object_spread({
|
|
244
273
|
uid: "new:" + buildUUID("uid")
|
|
245
274
|
}, JSONCopy(emptyTemplate));
|
|
246
|
-
});
|
|
275
|
+
})) !== null && _fill_map !== void 0 ? _fill_map : [];
|
|
247
276
|
emptyDataViewState[item.id] = emptyTemplate;
|
|
248
277
|
}
|
|
249
278
|
}
|
|
@@ -251,8 +280,9 @@ function buildDataBindMapping(data, dataViewId, // @ts-ignore
|
|
|
251
280
|
item) {
|
|
252
281
|
// if (item instanceof RuntimeFormControl) {
|
|
253
282
|
if (item.controlType === CONTROL_BASE_TYPE.FORM) {
|
|
254
|
-
var
|
|
255
|
-
if (
|
|
283
|
+
var _item_props_dataBind, _item_props;
|
|
284
|
+
// if (item.props.dataBind instanceof ObjectDataBind) {
|
|
285
|
+
if (!isDataBind(item.props.dataBind)) {
|
|
256
286
|
// 特殊的dataBind,比如:金额是currency+amount两个key组成的,日期区间,继承自ObjectDataBind的需要通过Object.keys拿到多个databind
|
|
257
287
|
Object.keys(item.props.dataBind).map(function(key) {
|
|
258
288
|
var dataBind = item.props.dataBind;
|
|
@@ -307,7 +337,8 @@ item) {
|
|
|
307
337
|
};
|
|
308
338
|
var subtableId = item.id;
|
|
309
339
|
loopFormSchema(item.props.headers, function(item) {
|
|
310
|
-
if (
|
|
340
|
+
// if (item.props.dataBind instanceof ObjectDataBind) {
|
|
341
|
+
if (!isDataBind(item.props.dataBind)) {
|
|
311
342
|
Object.keys(item.props.dataBind).map(function(key) {
|
|
312
343
|
var dataBind = item.props.dataBind;
|
|
313
344
|
var dataCode = dataBind[key].dataCode;
|
|
@@ -357,7 +388,7 @@ item) {
|
|
|
357
388
|
loopFormSchema(item.props.headers, function(formControl) {
|
|
358
389
|
var _data_item_id;
|
|
359
390
|
var _data_item_id_children;
|
|
360
|
-
Object.assign((_data_item_id_children = (_data_item_id = data[item.id]) === null || _data_item_id === void 0 ? void 0 : _data_item_id.children) !== null && _data_item_id_children !== void 0 ? _data_item_id_children : {},
|
|
391
|
+
Object.assign((_data_item_id_children = (_data_item_id = data[item.id]) === null || _data_item_id === void 0 ? void 0 : _data_item_id.children) !== null && _data_item_id_children !== void 0 ? _data_item_id_children : {}, _define_property({}, formControl.id, {
|
|
361
392
|
dataBind: formControl.props.dataBind
|
|
362
393
|
}));
|
|
363
394
|
});
|