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