@byteluck-fe/model-driven-engine 2.7.0-alpha.1 → 2.7.0-alpha.11
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 +72 -154
- package/dist/esm/common/DataManager.js +60 -128
- package/dist/esm/common/Engine.js +1145 -1066
- package/dist/esm/common/OkWorker.js +106 -75
- package/dist/esm/common/Runtime.js +34 -28
- package/dist/esm/common/Store.js +186 -157
- package/dist/esm/common/checkerValue.js +341 -259
- package/dist/esm/common/index.js +2 -2
- package/dist/esm/common/proxyState.js +47 -47
- package/dist/esm/index.js +3 -3
- package/dist/esm/plugins/CalcPlugin.js +382 -306
- package/dist/esm/plugins/ControlsEventPlugin.js +141 -225
- package/dist/esm/plugins/ES6ModulePlugin.js +56 -38
- package/dist/esm/plugins/LifecycleEventPlugin.js +107 -190
- package/dist/esm/plugins/StylePlugin.js +31 -13
- package/dist/esm/plugins/index.js +5 -5
- package/dist/esm/utils/index.js +1 -1
- package/dist/esm/utils/runtimeUtils.js +9 -6
- package/dist/index.umd.js +11 -11
- package/dist/types/common/Engine.d.ts +7 -7
- package/dist/types/common/Runtime.d.ts +1 -1
- package/dist/types/common/Store.d.ts +5 -5
- package/dist/types/common/proxyState.d.ts +3 -3
- package/dist/types/plugins/ControlsEventPlugin.d.ts +1 -1
- package/dist/types/plugins/ES6ModulePlugin.d.ts +4 -4
- package/dist/types/plugins/LifecycleEventPlugin.d.ts +1 -1
- package/dist/types/plugins/StylePlugin.d.ts +1 -1
- package/package.json +4 -4
package/dist/esm/common/Store.js
CHANGED
|
@@ -3,6 +3,20 @@ function _classCallCheck(instance, Constructor) {
|
|
|
3
3
|
throw new TypeError("Cannot call a class as a function");
|
|
4
4
|
}
|
|
5
5
|
}
|
|
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 _createClass(Constructor, protoProps, staticProps) {
|
|
16
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
17
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
18
|
+
return Constructor;
|
|
19
|
+
}
|
|
6
20
|
function _defineProperty(obj, key, value) {
|
|
7
21
|
if (key in obj) {
|
|
8
22
|
Object.defineProperty(obj, key, {
|
|
@@ -16,13 +30,6 @@ function _defineProperty(obj, key, value) {
|
|
|
16
30
|
}
|
|
17
31
|
return obj;
|
|
18
32
|
}
|
|
19
|
-
function _instanceof(left, right) {
|
|
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
33
|
function _objectSpread(target) {
|
|
27
34
|
for(var i = 1; i < arguments.length; i++){
|
|
28
35
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
@@ -38,159 +45,179 @@ function _objectSpread(target) {
|
|
|
38
45
|
}
|
|
39
46
|
return target;
|
|
40
47
|
}
|
|
41
|
-
import { DataBind,
|
|
42
|
-
import { loopFormSchema, JSONCopy, warn, CONTROL_TYPE, CONTROL_BASE_TYPE } from
|
|
43
|
-
import { loopDataViewControl, loopFormControl, buildUUID } from
|
|
48
|
+
import { DataBind, isDataBind } from '@byteluck-fe/model-driven-core';
|
|
49
|
+
import { loopFormSchema, JSONCopy, warn, CONTROL_TYPE, CONTROL_BASE_TYPE } from '@byteluck-fe/model-driven-shared';
|
|
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
|
_classCallCheck(this, Store);
|
|
48
|
-
var
|
|
55
|
+
var ref = init(props.instance), state = ref.state, emptyState = ref.emptyState, databindMapping = ref.databindMapping, controlidMapping = ref.controlidMapping, defaultState = ref.defaultState;
|
|
49
56
|
this.emptyState = emptyState;
|
|
50
57
|
this.state = state;
|
|
51
58
|
this.dataBindMapping = databindMapping;
|
|
52
59
|
this.controlIdMapping = controlidMapping;
|
|
53
60
|
this.defaultState = defaultState;
|
|
54
61
|
}
|
|
55
|
-
|
|
56
|
-
|
|
62
|
+
_createClass(Store, [
|
|
63
|
+
{
|
|
64
|
+
/**
|
|
57
65
|
* 使用该方法仅改变数据,不会表单触发事件。明细表可全量赋值也可根据rowIndex进行单独设置
|
|
58
66
|
* @param controlId 组件ID
|
|
59
67
|
* @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
|
-
|
|
68
|
+
*/ key: "setState",
|
|
69
|
+
value: function setState(controlId, value, rowIndex) {
|
|
70
|
+
var controlInfo = this.controlIdMapping[controlId];
|
|
71
|
+
if (controlInfo !== undefined) {
|
|
72
|
+
//qiyu 按照对象赋值,Object.assign会触发多次key的change事件
|
|
73
|
+
this.state[controlInfo.dataView][controlId] = value;
|
|
74
|
+
// if (
|
|
75
|
+
// controlInfo.dataBind instanceof ObjectDataBind &&
|
|
76
|
+
// isPlainObject(value)
|
|
77
|
+
// ) {
|
|
78
|
+
// Object.assign(this.state[controlInfo.dataView][controlId], value)
|
|
79
|
+
// } else {
|
|
80
|
+
// this.state[controlInfo.dataView][controlId] = value
|
|
81
|
+
// }
|
|
82
|
+
} else {
|
|
83
|
+
if (rowIndex !== undefined) {
|
|
84
|
+
var _this = this;
|
|
85
|
+
//TODO 目前只找了一层明细表,没有递归 如果是添加uid
|
|
86
|
+
Object.keys(this.controlIdMapping).map(function(subtableId) {
|
|
87
|
+
var dataView = _this.controlIdMapping[subtableId].dataView;
|
|
88
|
+
var children = _this.controlIdMapping[subtableId].children;
|
|
89
|
+
if (children !== undefined) {
|
|
90
|
+
var _this1 = _this;
|
|
91
|
+
Object.keys(children).map(function(childControlId) {
|
|
92
|
+
if (childControlId === controlId) {
|
|
93
|
+
if (_this1.state[dataView][subtableId][rowIndex]) {
|
|
94
|
+
_this1.state[dataView][subtableId][rowIndex][controlId] = value;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
});
|
|
84
98
|
}
|
|
85
99
|
});
|
|
100
|
+
} else {
|
|
101
|
+
//不存在的 controlId,直接被挂载到外部key
|
|
102
|
+
this.state[controlId] = value;
|
|
86
103
|
}
|
|
87
|
-
}
|
|
88
|
-
} else {
|
|
89
|
-
//不存在的 controlId,直接被挂载到外部key
|
|
90
|
-
this.state[controlId] = value;
|
|
104
|
+
}
|
|
91
105
|
}
|
|
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
|
-
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
key: "getState",
|
|
109
|
+
value: function getState(controlId, rowIndex) {
|
|
110
|
+
//qiyu 由于header的数据是后补充的,所以从state获取第一层值。
|
|
111
|
+
// const controlInfo = this.controlIdMapping[controlId]
|
|
112
|
+
var detection = this.state[controlId];
|
|
113
|
+
if (detection !== undefined) {
|
|
114
|
+
return this.state[controlId];
|
|
115
|
+
} else {
|
|
116
|
+
var controlInfo = this.controlIdMapping[controlId];
|
|
117
|
+
if (controlInfo !== undefined) {
|
|
118
|
+
return this.state[controlInfo.dataView][controlId];
|
|
119
|
+
} else {
|
|
120
|
+
if (rowIndex !== undefined) {
|
|
121
|
+
var _this = this;
|
|
122
|
+
var state;
|
|
123
|
+
//TODO 目前只找了一层明细表,没有递归
|
|
124
|
+
Object.keys(this.controlIdMapping).map(function(subtableId) {
|
|
125
|
+
var dataViewId = _this.controlIdMapping[subtableId].dataView;
|
|
126
|
+
var children = _this.controlIdMapping[subtableId].children;
|
|
127
|
+
if (children !== undefined) {
|
|
128
|
+
var _this3 = _this;
|
|
129
|
+
Object.keys(children).map(function(childControlId) {
|
|
130
|
+
if (childControlId === controlId) {
|
|
131
|
+
var ref;
|
|
132
|
+
state = (ref = _this3.state[dataViewId][subtableId][rowIndex]) === null || ref === void 0 ? void 0 : ref[controlId];
|
|
133
|
+
}
|
|
134
|
+
});
|
|
117
135
|
}
|
|
118
136
|
});
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
137
|
+
return state;
|
|
138
|
+
} else {
|
|
139
|
+
var _this2 = this;
|
|
140
|
+
var states = [];
|
|
141
|
+
Object.keys(this.controlIdMapping).map(function(subtableId) {
|
|
142
|
+
var dataViewId = _this2.controlIdMapping[subtableId].dataView;
|
|
143
|
+
var children = _this2.controlIdMapping[subtableId].children;
|
|
144
|
+
if (children !== undefined) {
|
|
145
|
+
var _this = _this2;
|
|
146
|
+
Object.keys(children).map(function(childControlId) {
|
|
147
|
+
if (childControlId === controlId) {
|
|
148
|
+
_this.state[dataViewId][subtableId].map(function(item) {
|
|
149
|
+
states.push(item[controlId]);
|
|
150
|
+
});
|
|
151
|
+
}
|
|
132
152
|
});
|
|
133
153
|
}
|
|
134
154
|
});
|
|
155
|
+
return states;
|
|
135
156
|
}
|
|
136
|
-
}
|
|
137
|
-
return states;
|
|
157
|
+
}
|
|
138
158
|
}
|
|
139
159
|
}
|
|
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
|
-
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
key: "getEmptyState",
|
|
163
|
+
value: function getEmptyState(controlId) {
|
|
164
|
+
var detection = this.emptyState[controlId];
|
|
165
|
+
if (detection !== undefined) {
|
|
166
|
+
return this.emptyState[controlId];
|
|
167
|
+
} else {
|
|
168
|
+
var controlInfo = this.controlIdMapping[controlId];
|
|
169
|
+
if (controlInfo !== undefined) {
|
|
170
|
+
var state = this.emptyState[controlInfo.dataView][controlId];
|
|
171
|
+
//判断找到的是否是明细表的控件
|
|
172
|
+
if ('children' in controlInfo) {
|
|
173
|
+
Object.assign(state, {
|
|
174
|
+
uid: 'new:' + buildUUID('uid')
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
return state;
|
|
178
|
+
} else {
|
|
179
|
+
var _this = this;
|
|
180
|
+
var state1;
|
|
181
|
+
//TODO 目前只找了一层明细表,没有递归
|
|
182
|
+
Object.keys(this.controlIdMapping).map(function(subtableId) {
|
|
183
|
+
var dataViewId = _this.controlIdMapping[subtableId].dataView;
|
|
184
|
+
var children = _this.controlIdMapping[subtableId].children;
|
|
185
|
+
if (children !== undefined) {
|
|
186
|
+
var _this4 = _this;
|
|
187
|
+
Object.keys(children).map(function(childControlId) {
|
|
188
|
+
if (childControlId === controlId) {
|
|
189
|
+
state1 = _this4.emptyState[dataViewId][subtableId][controlId];
|
|
190
|
+
}
|
|
191
|
+
});
|
|
168
192
|
}
|
|
169
193
|
});
|
|
194
|
+
return state1;
|
|
170
195
|
}
|
|
171
|
-
}
|
|
172
|
-
return state1;
|
|
196
|
+
}
|
|
173
197
|
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
key: "getDataBind",
|
|
201
|
+
value: function getDataBind(controlId) {
|
|
202
|
+
var result = this.controlIdMapping[controlId];
|
|
203
|
+
if (result) {
|
|
204
|
+
return result.dataBind;
|
|
205
|
+
}
|
|
206
|
+
wrapperFor: for(var id in this.controlIdMapping){
|
|
207
|
+
var dataBindMapping = this.controlIdMapping[id];
|
|
208
|
+
if (dataBindMapping.children) {
|
|
209
|
+
for(var subId in dataBindMapping.children){
|
|
210
|
+
if (subId === controlId) {
|
|
211
|
+
result = dataBindMapping.children[subId];
|
|
212
|
+
break wrapperFor;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
188
215
|
}
|
|
189
216
|
}
|
|
217
|
+
return result === null || result === void 0 ? void 0 : result.dataBind;
|
|
190
218
|
}
|
|
191
219
|
}
|
|
192
|
-
|
|
193
|
-
};
|
|
220
|
+
]);
|
|
194
221
|
return Store;
|
|
195
222
|
}();
|
|
196
223
|
function init(instance) {
|
|
@@ -238,36 +265,37 @@ item) {
|
|
|
238
265
|
loopFormSchema(item.props.headers, function(headerItem) {
|
|
239
266
|
emptyTemplate[headerItem.id] = JSONCopy(headerItem.props.defaultValue);
|
|
240
267
|
});
|
|
241
|
-
var
|
|
242
|
-
dataViewState[item.id] = new Array((
|
|
268
|
+
var _defaultRows, ref;
|
|
269
|
+
dataViewState[item.id] = (ref = new Array((_defaultRows = item.props.defaultRows) !== null && _defaultRows !== void 0 ? _defaultRows : 1).fill(0).map(function() {
|
|
243
270
|
return _objectSpread({
|
|
244
|
-
uid:
|
|
271
|
+
uid: 'new:' + buildUUID('uid')
|
|
245
272
|
}, JSONCopy(emptyTemplate));
|
|
246
|
-
});
|
|
273
|
+
})) !== null && ref !== void 0 ? ref : [];
|
|
247
274
|
emptyDataViewState[item.id] = emptyTemplate;
|
|
248
275
|
}
|
|
249
276
|
}
|
|
250
277
|
function buildDataBindMapping(data, dataViewId, // @ts-ignore
|
|
251
|
-
|
|
278
|
+
item1) {
|
|
252
279
|
// if (item instanceof RuntimeFormControl) {
|
|
253
|
-
if (
|
|
254
|
-
var
|
|
255
|
-
if (
|
|
280
|
+
if (item1.controlType === CONTROL_BASE_TYPE.FORM) {
|
|
281
|
+
var ref, ref1;
|
|
282
|
+
// if (item.props.dataBind instanceof ObjectDataBind) {
|
|
283
|
+
if (!isDataBind(item1.props.dataBind)) {
|
|
256
284
|
// 特殊的dataBind,比如:金额是currency+amount两个key组成的,日期区间,继承自ObjectDataBind的需要通过Object.keys拿到多个databind
|
|
257
|
-
Object.keys(
|
|
258
|
-
var dataBind =
|
|
285
|
+
Object.keys(item1.props.dataBind).map(function(key) {
|
|
286
|
+
var dataBind = item1.props.dataBind;
|
|
259
287
|
var dataCode = dataBind[key].dataCode;
|
|
260
288
|
if (dataCode !== undefined) {
|
|
261
289
|
if (data[dataCode] === undefined) {
|
|
262
290
|
data[dataCode] = {
|
|
263
|
-
controlId:
|
|
291
|
+
controlId: item1.id,
|
|
264
292
|
fields: [],
|
|
265
293
|
dataViewId: dataViewId
|
|
266
294
|
};
|
|
267
295
|
}
|
|
268
296
|
data[dataCode].fields.push({
|
|
269
297
|
fieldCode: dataBind[key].fieldCode,
|
|
270
|
-
controlId:
|
|
298
|
+
controlId: item1.id,
|
|
271
299
|
dataBind: dataBind,
|
|
272
300
|
dataViewId: [
|
|
273
301
|
dataViewId
|
|
@@ -275,39 +303,40 @@ item) {
|
|
|
275
303
|
});
|
|
276
304
|
}
|
|
277
305
|
});
|
|
278
|
-
} else if (((
|
|
306
|
+
} else if (((ref = item1.props) === null || ref === void 0 ? void 0 : (ref1 = ref.dataBind) === null || ref1 === void 0 ? void 0 : ref1.dataCode) === undefined) {
|
|
279
307
|
//qiyu 2023-2-27 为空跳过。form自定义组件加载失败时,hack的组件props为空。
|
|
280
308
|
} else {
|
|
281
|
-
if (data[
|
|
282
|
-
data[
|
|
309
|
+
if (data[item1.props.dataBind.dataCode] === undefined) {
|
|
310
|
+
data[item1.props.dataBind.dataCode] = {
|
|
283
311
|
controlId: dataViewId,
|
|
284
312
|
fields: [],
|
|
285
313
|
dataViewId: dataViewId
|
|
286
314
|
};
|
|
287
315
|
}
|
|
288
|
-
data[
|
|
289
|
-
fieldCode:
|
|
290
|
-
controlId:
|
|
291
|
-
dataBind:
|
|
316
|
+
data[item1.props.dataBind.dataCode].fields.push({
|
|
317
|
+
fieldCode: item1.props.dataBind.fieldCode,
|
|
318
|
+
controlId: item1.id,
|
|
319
|
+
dataBind: item1.props.dataBind,
|
|
292
320
|
dataViewId: [
|
|
293
321
|
dataViewId
|
|
294
322
|
]
|
|
295
323
|
});
|
|
296
324
|
}
|
|
297
325
|
} else {
|
|
298
|
-
if (
|
|
326
|
+
if (item1.props.datasourceBind.dataCode === '') {
|
|
299
327
|
//敏捷依赖后端生成dataCode,预览的时候没有
|
|
300
|
-
warn("datasourceBind.dataCode is empty! maybe in preview mode, control:".concat(
|
|
328
|
+
warn("datasourceBind.dataCode is empty! maybe in preview mode, control:".concat(item1.id, " type:").concat(item1.type));
|
|
301
329
|
return;
|
|
302
330
|
}
|
|
303
|
-
data[
|
|
304
|
-
controlId:
|
|
331
|
+
data[item1.props.datasourceBind.dataCode] = {
|
|
332
|
+
controlId: item1.id,
|
|
305
333
|
fields: [],
|
|
306
334
|
dataViewId: dataViewId
|
|
307
335
|
};
|
|
308
|
-
var subtableId =
|
|
309
|
-
loopFormSchema(
|
|
310
|
-
if (
|
|
336
|
+
var subtableId = item1.id;
|
|
337
|
+
loopFormSchema(item1.props.headers, function(item) {
|
|
338
|
+
// if (item.props.dataBind instanceof ObjectDataBind) {
|
|
339
|
+
if (!isDataBind(item.props.dataBind)) {
|
|
311
340
|
Object.keys(item.props.dataBind).map(function(key) {
|
|
312
341
|
var dataBind = item.props.dataBind;
|
|
313
342
|
var dataCode = dataBind[key].dataCode;
|
|
@@ -348,16 +377,16 @@ item) {
|
|
|
348
377
|
data[item.id] = {
|
|
349
378
|
dataBind: new DataBind({
|
|
350
379
|
dataCode: item.props.datasourceBind.dataCode,
|
|
351
|
-
fieldCode:
|
|
380
|
+
fieldCode: ''
|
|
352
381
|
}),
|
|
353
382
|
dataView: dataViewId,
|
|
354
383
|
children: {},
|
|
355
384
|
options: []
|
|
356
385
|
};
|
|
357
386
|
loopFormSchema(item.props.headers, function(formControl) {
|
|
358
|
-
var
|
|
359
|
-
var
|
|
360
|
-
Object.assign((
|
|
387
|
+
var ref;
|
|
388
|
+
var ref2;
|
|
389
|
+
Object.assign((ref2 = (ref = data[item.id]) === null || ref === void 0 ? void 0 : ref.children) !== null && ref2 !== void 0 ? ref2 : {}, _defineProperty({}, formControl.id, {
|
|
361
390
|
dataBind: formControl.props.dataBind
|
|
362
391
|
}));
|
|
363
392
|
});
|