@byteluck-fe/model-driven-engine 2.7.0-alpha.15 → 2.7.0-alpha.16
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 +40 -157
- package/dist/esm/common/DataManager.js +20 -129
- package/dist/esm/common/Engine.js +211 -338
- package/dist/esm/common/OkWorker.js +13 -27
- package/dist/esm/common/Runtime.js +11 -26
- package/dist/esm/common/Store.js +50 -51
- package/dist/esm/common/checkerValue.js +39 -39
- 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 +59 -67
- package/dist/esm/plugins/ControlsEventPlugin.js +68 -191
- package/dist/esm/plugins/ES6ModulePlugin.js +8 -24
- package/dist/esm/plugins/LifecycleEventPlugin.js +64 -183
- package/dist/esm/plugins/StylePlugin.js +7 -22
- 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 +10 -10
- package/dist/types/common/Engine.d.ts +6 -6
- 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
|
@@ -17,25 +17,11 @@ function _createClass(Constructor, protoProps, staticProps) {
|
|
|
17
17
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
18
18
|
return Constructor;
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
if (key in obj) {
|
|
22
|
-
Object.defineProperty(obj, key, {
|
|
23
|
-
value: value,
|
|
24
|
-
enumerable: true,
|
|
25
|
-
configurable: true,
|
|
26
|
-
writable: true
|
|
27
|
-
});
|
|
28
|
-
} else {
|
|
29
|
-
obj[key] = value;
|
|
30
|
-
}
|
|
31
|
-
return obj;
|
|
32
|
-
}
|
|
33
|
-
import { log } from "@byteluck-fe/model-driven-shared";
|
|
20
|
+
import { log } from '@byteluck-fe/model-driven-shared';
|
|
34
21
|
var OkWorker = /*#__PURE__*/ function() {
|
|
35
22
|
"use strict";
|
|
36
23
|
function OkWorker() {
|
|
37
24
|
_classCallCheck(this, OkWorker);
|
|
38
|
-
_defineProperty(this, "worker", void 0);
|
|
39
25
|
}
|
|
40
26
|
_createClass(OkWorker, [
|
|
41
27
|
{
|
|
@@ -43,7 +29,7 @@ var OkWorker = /*#__PURE__*/ function() {
|
|
|
43
29
|
value: function run(initState) {
|
|
44
30
|
this.worker = OkWorker.createWorker();
|
|
45
31
|
this.postMessage({
|
|
46
|
-
action:
|
|
32
|
+
action: 'init',
|
|
47
33
|
payload: initState
|
|
48
34
|
});
|
|
49
35
|
}
|
|
@@ -51,15 +37,15 @@ var OkWorker = /*#__PURE__*/ function() {
|
|
|
51
37
|
{
|
|
52
38
|
key: "destroy",
|
|
53
39
|
value: function destroy() {
|
|
54
|
-
var
|
|
55
|
-
(
|
|
40
|
+
var ref;
|
|
41
|
+
(ref = this.worker) === null || ref === void 0 ? void 0 : ref.terminate();
|
|
56
42
|
}
|
|
57
43
|
},
|
|
58
44
|
{
|
|
59
45
|
key: "postMessage",
|
|
60
46
|
value: function postMessage(message) {
|
|
61
|
-
var
|
|
62
|
-
(
|
|
47
|
+
var ref;
|
|
48
|
+
(ref = this.worker) === null || ref === void 0 ? void 0 : ref.postMessage(message);
|
|
63
49
|
}
|
|
64
50
|
}
|
|
65
51
|
], [
|
|
@@ -85,7 +71,7 @@ var OkWorker = /*#__PURE__*/ function() {
|
|
|
85
71
|
set: function set(target, key, value) {
|
|
86
72
|
if (parentKey) {
|
|
87
73
|
_self.postMessage({
|
|
88
|
-
action:
|
|
74
|
+
action: 'update',
|
|
89
75
|
key: "".concat(parentKey, ".").concat(key)
|
|
90
76
|
});
|
|
91
77
|
}
|
|
@@ -93,7 +79,7 @@ var OkWorker = /*#__PURE__*/ function() {
|
|
|
93
79
|
}
|
|
94
80
|
};
|
|
95
81
|
};
|
|
96
|
-
log(
|
|
82
|
+
log('🚀 worker running');
|
|
97
83
|
var _self = self;
|
|
98
84
|
// function createProxy(
|
|
99
85
|
// obj: Record<string, unknown> | Array<Record<string, unknown>>,
|
|
@@ -106,8 +92,8 @@ var OkWorker = /*#__PURE__*/ function() {
|
|
|
106
92
|
// }
|
|
107
93
|
// return new Proxy(obj, createHandler(parentKey))
|
|
108
94
|
// }
|
|
109
|
-
_self.addEventListener(
|
|
110
|
-
var
|
|
95
|
+
_self.addEventListener('message', function(event) {
|
|
96
|
+
var _data = event.data, action = _data.action, payload = _data.payload, fn = _data.fn;
|
|
111
97
|
log(action, payload);
|
|
112
98
|
// 通过proxy进行代理,每次修改的时候,自动向外抛出postMessage
|
|
113
99
|
// data.key1 = 1
|
|
@@ -118,10 +104,10 @@ var OkWorker = /*#__PURE__*/ function() {
|
|
|
118
104
|
//
|
|
119
105
|
// const result = fn(data, schema)
|
|
120
106
|
_self.postMessage({
|
|
121
|
-
action:
|
|
107
|
+
action: 'delete',
|
|
122
108
|
payload: {
|
|
123
|
-
key:
|
|
124
|
-
value:
|
|
109
|
+
key: 'key3[0].key1',
|
|
110
|
+
value: 'index'
|
|
125
111
|
}
|
|
126
112
|
});
|
|
127
113
|
});
|
|
@@ -23,19 +23,6 @@ function _createClass(Constructor, protoProps, staticProps) {
|
|
|
23
23
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
24
24
|
return Constructor;
|
|
25
25
|
}
|
|
26
|
-
function _defineProperty(obj, key, value) {
|
|
27
|
-
if (key in obj) {
|
|
28
|
-
Object.defineProperty(obj, key, {
|
|
29
|
-
value: value,
|
|
30
|
-
enumerable: true,
|
|
31
|
-
configurable: true,
|
|
32
|
-
writable: true
|
|
33
|
-
});
|
|
34
|
-
} else {
|
|
35
|
-
obj[key] = value;
|
|
36
|
-
}
|
|
37
|
-
return obj;
|
|
38
|
-
}
|
|
39
26
|
function _getPrototypeOf(o) {
|
|
40
27
|
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
41
28
|
return o.__proto__ || Object.getPrototypeOf(o);
|
|
@@ -96,21 +83,19 @@ function _createSuper(Derived) {
|
|
|
96
83
|
return _possibleConstructorReturn(this, result);
|
|
97
84
|
};
|
|
98
85
|
}
|
|
99
|
-
import { RegisterControls } from
|
|
100
|
-
import { CONTROL_BASE_TYPE, CONTROL_TYPE, loopFormSchema } from
|
|
101
|
-
import { hasChildrenControl, loopDataViewControl, loopFormControl } from
|
|
102
|
-
export var Runtime = /*#__PURE__*/ function(
|
|
86
|
+
import { RegisterControls } from '@byteluck-fe/model-driven-core';
|
|
87
|
+
import { CONTROL_BASE_TYPE, CONTROL_TYPE, loopFormSchema } from '@byteluck-fe/model-driven-shared';
|
|
88
|
+
import { hasChildrenControl, loopDataViewControl, loopFormControl } from '../utils/runtimeUtils';
|
|
89
|
+
export var Runtime = /*#__PURE__*/ function(RegisterControls1) {
|
|
103
90
|
"use strict";
|
|
104
|
-
_inherits(Runtime,
|
|
91
|
+
_inherits(Runtime, RegisterControls1);
|
|
105
92
|
var _super = _createSuper(Runtime);
|
|
106
93
|
function Runtime(props) {
|
|
107
94
|
_classCallCheck(this, Runtime);
|
|
108
95
|
var _this;
|
|
109
|
-
_this = _super.call(this,
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
_defineProperty(_assertThisInitialized(_this), "_flatInstances", []);
|
|
113
|
-
_defineProperty(_assertThisInitialized(_this), "_instanceMap", {});
|
|
96
|
+
_this = _super.call(this, 'Runtime');
|
|
97
|
+
_this._flatInstances = [];
|
|
98
|
+
_this._instanceMap = {};
|
|
114
99
|
var schema = props.schema;
|
|
115
100
|
_this._schema = schema;
|
|
116
101
|
_this._instance = _this.createControl(schema, props.beforeCreateInstance);
|
|
@@ -125,7 +110,7 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls) {
|
|
|
125
110
|
var instanceMap = {};
|
|
126
111
|
loop(this._instance, function(item) {
|
|
127
112
|
// 3.4.1 避免将subtable-row 放到 _flatInstances 中
|
|
128
|
-
if (item.type ===
|
|
113
|
+
if (item.type === 'subtable-row' || item.type === 'subtable-column') {
|
|
129
114
|
return;
|
|
130
115
|
}
|
|
131
116
|
instances.push(item);
|
|
@@ -268,7 +253,7 @@ item) {
|
|
|
268
253
|
} else if (item.type === CONTROL_TYPE.SUBTABLE) {
|
|
269
254
|
data[item.id] = item.rules;
|
|
270
255
|
var itemRules = {
|
|
271
|
-
type:
|
|
256
|
+
type: 'array',
|
|
272
257
|
fields: {}
|
|
273
258
|
};
|
|
274
259
|
item.children.forEach(function(row, index) {
|
|
@@ -276,7 +261,7 @@ item) {
|
|
|
276
261
|
if (itemRules.fields) {
|
|
277
262
|
if (!itemRules.fields[index]) {
|
|
278
263
|
itemRules.fields[index] = {
|
|
279
|
-
type:
|
|
264
|
+
type: 'object',
|
|
280
265
|
required: true,
|
|
281
266
|
fields: {}
|
|
282
267
|
};
|
package/dist/esm/common/Store.js
CHANGED
|
@@ -45,20 +45,14 @@ function _objectSpread(target) {
|
|
|
45
45
|
}
|
|
46
46
|
return target;
|
|
47
47
|
}
|
|
48
|
-
import { DataBind, isDataBind } from
|
|
49
|
-
import { loopFormSchema, JSONCopy, warn, CONTROL_TYPE, CONTROL_BASE_TYPE } from
|
|
50
|
-
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';
|
|
51
51
|
var Store = /*#__PURE__*/ function() {
|
|
52
52
|
"use strict";
|
|
53
53
|
function Store(props) {
|
|
54
54
|
_classCallCheck(this, Store);
|
|
55
|
-
|
|
56
|
-
_defineProperty(this, "state", void 0);
|
|
57
|
-
_defineProperty(this, "dataBindMapping", void 0 // 主要提供给二开使用
|
|
58
|
-
);
|
|
59
|
-
_defineProperty(this, "controlIdMapping", void 0);
|
|
60
|
-
_defineProperty(this, "defaultState", void 0);
|
|
61
|
-
var _init = init(props.instance), state = _init.state, emptyState = _init.emptyState, databindMapping = _init.databindMapping, controlidMapping = _init.controlidMapping, defaultState = _init.defaultState;
|
|
55
|
+
var ref = init(props.instance), state = ref.state, emptyState = ref.emptyState, databindMapping = ref.databindMapping, controlidMapping = ref.controlidMapping, defaultState = ref.defaultState;
|
|
62
56
|
this.emptyState = emptyState;
|
|
63
57
|
this.state = state;
|
|
64
58
|
this.dataBindMapping = databindMapping;
|
|
@@ -73,7 +67,6 @@ var Store = /*#__PURE__*/ function() {
|
|
|
73
67
|
* @param value
|
|
74
68
|
*/ key: "setState",
|
|
75
69
|
value: function setState(controlId, value, rowIndex) {
|
|
76
|
-
var _this = this;
|
|
77
70
|
var controlInfo = this.controlIdMapping[controlId];
|
|
78
71
|
if (controlInfo !== undefined) {
|
|
79
72
|
//qiyu 按照对象赋值,Object.assign会触发多次key的change事件
|
|
@@ -88,15 +81,17 @@ var Store = /*#__PURE__*/ function() {
|
|
|
88
81
|
// }
|
|
89
82
|
} else {
|
|
90
83
|
if (rowIndex !== undefined) {
|
|
84
|
+
var _this = this;
|
|
91
85
|
//TODO 目前只找了一层明细表,没有递归 如果是添加uid
|
|
92
86
|
Object.keys(this.controlIdMapping).map(function(subtableId) {
|
|
93
87
|
var dataView = _this.controlIdMapping[subtableId].dataView;
|
|
94
88
|
var children = _this.controlIdMapping[subtableId].children;
|
|
95
89
|
if (children !== undefined) {
|
|
90
|
+
var _this1 = _this;
|
|
96
91
|
Object.keys(children).map(function(childControlId) {
|
|
97
92
|
if (childControlId === controlId) {
|
|
98
|
-
if (
|
|
99
|
-
|
|
93
|
+
if (_this1.state[dataView][subtableId][rowIndex]) {
|
|
94
|
+
_this1.state[dataView][subtableId][rowIndex][controlId] = value;
|
|
100
95
|
}
|
|
101
96
|
}
|
|
102
97
|
});
|
|
@@ -112,7 +107,6 @@ var Store = /*#__PURE__*/ function() {
|
|
|
112
107
|
{
|
|
113
108
|
key: "getState",
|
|
114
109
|
value: function getState(controlId, rowIndex) {
|
|
115
|
-
var _this = this;
|
|
116
110
|
//qiyu 由于header的数据是后补充的,所以从state获取第一层值。
|
|
117
111
|
// const controlInfo = this.controlIdMapping[controlId]
|
|
118
112
|
var detection = this.state[controlId];
|
|
@@ -124,27 +118,31 @@ var Store = /*#__PURE__*/ function() {
|
|
|
124
118
|
return this.state[controlInfo.dataView][controlId];
|
|
125
119
|
} else {
|
|
126
120
|
if (rowIndex !== undefined) {
|
|
121
|
+
var _this = this;
|
|
127
122
|
var state;
|
|
128
123
|
//TODO 目前只找了一层明细表,没有递归
|
|
129
124
|
Object.keys(this.controlIdMapping).map(function(subtableId) {
|
|
130
125
|
var dataViewId = _this.controlIdMapping[subtableId].dataView;
|
|
131
126
|
var children = _this.controlIdMapping[subtableId].children;
|
|
132
127
|
if (children !== undefined) {
|
|
128
|
+
var _this3 = _this;
|
|
133
129
|
Object.keys(children).map(function(childControlId) {
|
|
134
130
|
if (childControlId === controlId) {
|
|
135
|
-
var
|
|
136
|
-
state = (
|
|
131
|
+
var ref;
|
|
132
|
+
state = (ref = _this3.state[dataViewId][subtableId][rowIndex]) === null || ref === void 0 ? void 0 : ref[controlId];
|
|
137
133
|
}
|
|
138
134
|
});
|
|
139
135
|
}
|
|
140
136
|
});
|
|
141
137
|
return state;
|
|
142
138
|
} else {
|
|
139
|
+
var _this2 = this;
|
|
143
140
|
var states = [];
|
|
144
141
|
Object.keys(this.controlIdMapping).map(function(subtableId) {
|
|
145
|
-
var dataViewId =
|
|
146
|
-
var children =
|
|
142
|
+
var dataViewId = _this2.controlIdMapping[subtableId].dataView;
|
|
143
|
+
var children = _this2.controlIdMapping[subtableId].children;
|
|
147
144
|
if (children !== undefined) {
|
|
145
|
+
var _this = _this2;
|
|
148
146
|
Object.keys(children).map(function(childControlId) {
|
|
149
147
|
if (childControlId === controlId) {
|
|
150
148
|
_this.state[dataViewId][subtableId].map(function(item) {
|
|
@@ -163,7 +161,6 @@ var Store = /*#__PURE__*/ function() {
|
|
|
163
161
|
{
|
|
164
162
|
key: "getEmptyState",
|
|
165
163
|
value: function getEmptyState(controlId) {
|
|
166
|
-
var _this = this;
|
|
167
164
|
var detection = this.emptyState[controlId];
|
|
168
165
|
if (detection !== undefined) {
|
|
169
166
|
return this.emptyState[controlId];
|
|
@@ -172,22 +169,24 @@ var Store = /*#__PURE__*/ function() {
|
|
|
172
169
|
if (controlInfo !== undefined) {
|
|
173
170
|
var state = this.emptyState[controlInfo.dataView][controlId];
|
|
174
171
|
//判断找到的是否是明细表的控件
|
|
175
|
-
if (
|
|
172
|
+
if ('children' in controlInfo) {
|
|
176
173
|
Object.assign(state, {
|
|
177
|
-
uid:
|
|
174
|
+
uid: 'new:' + buildUUID('uid')
|
|
178
175
|
});
|
|
179
176
|
}
|
|
180
177
|
return state;
|
|
181
178
|
} else {
|
|
179
|
+
var _this = this;
|
|
182
180
|
var state1;
|
|
183
181
|
//TODO 目前只找了一层明细表,没有递归
|
|
184
182
|
Object.keys(this.controlIdMapping).map(function(subtableId) {
|
|
185
183
|
var dataViewId = _this.controlIdMapping[subtableId].dataView;
|
|
186
184
|
var children = _this.controlIdMapping[subtableId].children;
|
|
187
185
|
if (children !== undefined) {
|
|
186
|
+
var _this4 = _this;
|
|
188
187
|
Object.keys(children).map(function(childControlId) {
|
|
189
188
|
if (childControlId === controlId) {
|
|
190
|
-
state1 =
|
|
189
|
+
state1 = _this4.emptyState[dataViewId][subtableId][controlId];
|
|
191
190
|
}
|
|
192
191
|
});
|
|
193
192
|
}
|
|
@@ -266,37 +265,37 @@ item) {
|
|
|
266
265
|
loopFormSchema(item.props.headers, function(headerItem) {
|
|
267
266
|
emptyTemplate[headerItem.id] = JSONCopy(headerItem.props.defaultValue);
|
|
268
267
|
});
|
|
269
|
-
var
|
|
270
|
-
dataViewState[item.id] = (
|
|
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() {
|
|
271
270
|
return _objectSpread({
|
|
272
|
-
uid:
|
|
271
|
+
uid: 'new:' + buildUUID('uid')
|
|
273
272
|
}, JSONCopy(emptyTemplate));
|
|
274
|
-
})) !== null &&
|
|
273
|
+
})) !== null && ref !== void 0 ? ref : [];
|
|
275
274
|
emptyDataViewState[item.id] = emptyTemplate;
|
|
276
275
|
}
|
|
277
276
|
}
|
|
278
277
|
function buildDataBindMapping(data, dataViewId, // @ts-ignore
|
|
279
|
-
|
|
278
|
+
item1) {
|
|
280
279
|
// if (item instanceof RuntimeFormControl) {
|
|
281
|
-
if (
|
|
282
|
-
var
|
|
280
|
+
if (item1.controlType === CONTROL_BASE_TYPE.FORM) {
|
|
281
|
+
var ref, ref1;
|
|
283
282
|
// if (item.props.dataBind instanceof ObjectDataBind) {
|
|
284
|
-
if (!isDataBind(
|
|
283
|
+
if (!isDataBind(item1.props.dataBind)) {
|
|
285
284
|
// 特殊的dataBind,比如:金额是currency+amount两个key组成的,日期区间,继承自ObjectDataBind的需要通过Object.keys拿到多个databind
|
|
286
|
-
Object.keys(
|
|
287
|
-
var dataBind =
|
|
285
|
+
Object.keys(item1.props.dataBind).map(function(key) {
|
|
286
|
+
var dataBind = item1.props.dataBind;
|
|
288
287
|
var dataCode = dataBind[key].dataCode;
|
|
289
288
|
if (dataCode !== undefined) {
|
|
290
289
|
if (data[dataCode] === undefined) {
|
|
291
290
|
data[dataCode] = {
|
|
292
|
-
controlId:
|
|
291
|
+
controlId: item1.id,
|
|
293
292
|
fields: [],
|
|
294
293
|
dataViewId: dataViewId
|
|
295
294
|
};
|
|
296
295
|
}
|
|
297
296
|
data[dataCode].fields.push({
|
|
298
297
|
fieldCode: dataBind[key].fieldCode,
|
|
299
|
-
controlId:
|
|
298
|
+
controlId: item1.id,
|
|
300
299
|
dataBind: dataBind,
|
|
301
300
|
dataViewId: [
|
|
302
301
|
dataViewId
|
|
@@ -304,38 +303,38 @@ item) {
|
|
|
304
303
|
});
|
|
305
304
|
}
|
|
306
305
|
});
|
|
307
|
-
} 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) {
|
|
308
307
|
//qiyu 2023-2-27 为空跳过。form自定义组件加载失败时,hack的组件props为空。
|
|
309
308
|
} else {
|
|
310
|
-
if (data[
|
|
311
|
-
data[
|
|
309
|
+
if (data[item1.props.dataBind.dataCode] === undefined) {
|
|
310
|
+
data[item1.props.dataBind.dataCode] = {
|
|
312
311
|
controlId: dataViewId,
|
|
313
312
|
fields: [],
|
|
314
313
|
dataViewId: dataViewId
|
|
315
314
|
};
|
|
316
315
|
}
|
|
317
|
-
data[
|
|
318
|
-
fieldCode:
|
|
319
|
-
controlId:
|
|
320
|
-
dataBind:
|
|
316
|
+
data[item1.props.dataBind.dataCode].fields.push({
|
|
317
|
+
fieldCode: item1.props.dataBind.fieldCode,
|
|
318
|
+
controlId: item1.id,
|
|
319
|
+
dataBind: item1.props.dataBind,
|
|
321
320
|
dataViewId: [
|
|
322
321
|
dataViewId
|
|
323
322
|
]
|
|
324
323
|
});
|
|
325
324
|
}
|
|
326
325
|
} else {
|
|
327
|
-
if (
|
|
326
|
+
if (item1.props.datasourceBind.dataCode === '') {
|
|
328
327
|
//敏捷依赖后端生成dataCode,预览的时候没有
|
|
329
|
-
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));
|
|
330
329
|
return;
|
|
331
330
|
}
|
|
332
|
-
data[
|
|
333
|
-
controlId:
|
|
331
|
+
data[item1.props.datasourceBind.dataCode] = {
|
|
332
|
+
controlId: item1.id,
|
|
334
333
|
fields: [],
|
|
335
334
|
dataViewId: dataViewId
|
|
336
335
|
};
|
|
337
|
-
var subtableId =
|
|
338
|
-
loopFormSchema(
|
|
336
|
+
var subtableId = item1.id;
|
|
337
|
+
loopFormSchema(item1.props.headers, function(item) {
|
|
339
338
|
// if (item.props.dataBind instanceof ObjectDataBind) {
|
|
340
339
|
if (!isDataBind(item.props.dataBind)) {
|
|
341
340
|
Object.keys(item.props.dataBind).map(function(key) {
|
|
@@ -378,16 +377,16 @@ item) {
|
|
|
378
377
|
data[item.id] = {
|
|
379
378
|
dataBind: new DataBind({
|
|
380
379
|
dataCode: item.props.datasourceBind.dataCode,
|
|
381
|
-
fieldCode:
|
|
380
|
+
fieldCode: ''
|
|
382
381
|
}),
|
|
383
382
|
dataView: dataViewId,
|
|
384
383
|
children: {},
|
|
385
384
|
options: []
|
|
386
385
|
};
|
|
387
386
|
loopFormSchema(item.props.headers, function(formControl) {
|
|
388
|
-
var
|
|
389
|
-
var
|
|
390
|
-
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, {
|
|
391
390
|
dataBind: formControl.props.dataBind
|
|
392
391
|
}));
|
|
393
392
|
});
|
|
@@ -157,9 +157,9 @@ function _createSuper(Derived) {
|
|
|
157
157
|
return _possibleConstructorReturn(this, result);
|
|
158
158
|
};
|
|
159
159
|
}
|
|
160
|
-
import { isArray, isFunction, isString, isJSONArray, isJSONObject, isNumber, isNumberAndEmptyStringArray, isPlainObject, isStringArray, FieldTypes, isObject } from
|
|
161
|
-
import { AddressValue, AmountValue, CalcValue, RangeDateValue } from
|
|
162
|
-
import { camelizeKeys } from
|
|
160
|
+
import { isArray, isFunction, isString, isJSONArray, isJSONObject, isNumber, isNumberAndEmptyStringArray, isPlainObject, isStringArray, FieldTypes, isObject } from '@byteluck-fe/model-driven-shared';
|
|
161
|
+
import { AddressValue, AmountValue, CalcValue, RangeDateValue } from '@byteluck-fe/model-driven-core';
|
|
162
|
+
import { camelizeKeys } from 'humps';
|
|
163
163
|
var ValueChecker = function ValueChecker() {
|
|
164
164
|
"use strict";
|
|
165
165
|
_classCallCheck(this, ValueChecker);
|
|
@@ -183,7 +183,7 @@ var StringValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
183
183
|
key: "transform",
|
|
184
184
|
value: function transform(value) {
|
|
185
185
|
if (value === null || value === undefined) {
|
|
186
|
-
return
|
|
186
|
+
return '';
|
|
187
187
|
}
|
|
188
188
|
if (!isPlainObject(value) && !isFunction(value)) {
|
|
189
189
|
return String(value);
|
|
@@ -210,14 +210,14 @@ var NumberValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
210
210
|
// 数字类型允许是空字符串,用于置空数据
|
|
211
211
|
key: "validate",
|
|
212
212
|
value: function validate(value) {
|
|
213
|
-
return isNumber(value) || value ===
|
|
213
|
+
return isNumber(value) || value === '';
|
|
214
214
|
}
|
|
215
215
|
},
|
|
216
216
|
{
|
|
217
217
|
key: "transform",
|
|
218
218
|
value: function transform(value) {
|
|
219
219
|
if (value === null || value === undefined) {
|
|
220
|
-
return
|
|
220
|
+
return '';
|
|
221
221
|
}
|
|
222
222
|
var newValue = !isPlainObject(value) && !isFunction(value) ? Number(value) : undefined;
|
|
223
223
|
if (!Number.isNaN(newValue) && newValue !== undefined) {
|
|
@@ -246,28 +246,28 @@ var StringArrayValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
246
246
|
},
|
|
247
247
|
{
|
|
248
248
|
key: "transform",
|
|
249
|
-
value: function transform(
|
|
249
|
+
value: function transform(value1) {
|
|
250
250
|
var getStringValueArray = function getStringValueArray(value) {
|
|
251
251
|
return value.map(function(item) {
|
|
252
|
-
return !item ?
|
|
252
|
+
return !item ? '' : String(item);
|
|
253
253
|
});
|
|
254
254
|
};
|
|
255
|
-
if (
|
|
255
|
+
if (value1 === undefined || value1 === null) {
|
|
256
256
|
return [];
|
|
257
257
|
}
|
|
258
|
-
if (isArray(
|
|
259
|
-
return getStringValueArray(
|
|
258
|
+
if (isArray(value1)) {
|
|
259
|
+
return getStringValueArray(value1);
|
|
260
260
|
}
|
|
261
|
-
if (isString(
|
|
261
|
+
if (isString(value1) && isJSONArray(value1)) {
|
|
262
262
|
try {
|
|
263
|
-
var newValue = JSON.parse(
|
|
263
|
+
var newValue = JSON.parse(value1);
|
|
264
264
|
if (Array.isArray(newValue)) {
|
|
265
265
|
return getStringValueArray(newValue);
|
|
266
266
|
}
|
|
267
267
|
} catch (e) {}
|
|
268
268
|
}
|
|
269
269
|
return [
|
|
270
|
-
String(
|
|
270
|
+
String(value1)
|
|
271
271
|
];
|
|
272
272
|
}
|
|
273
273
|
}
|
|
@@ -291,31 +291,31 @@ var NumberArrayValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
291
291
|
},
|
|
292
292
|
{
|
|
293
293
|
key: "transform",
|
|
294
|
-
value: function transform(
|
|
294
|
+
value: function transform(value2) {
|
|
295
295
|
var getNumberValueArray = function getNumberValueArray(value) {
|
|
296
296
|
return value.map(function(item) {
|
|
297
|
-
return !item && item !== 0 ?
|
|
297
|
+
return !item && item !== 0 ? '' : Number(item);
|
|
298
298
|
}).filter(function(item) {
|
|
299
|
-
return item ===
|
|
299
|
+
return item === '' || !Number.isNaN(item);
|
|
300
300
|
});
|
|
301
301
|
};
|
|
302
|
-
if (
|
|
302
|
+
if (value2 === undefined || value2 === null) {
|
|
303
303
|
return [];
|
|
304
304
|
}
|
|
305
|
-
if (isArray(
|
|
306
|
-
return getNumberValueArray(
|
|
305
|
+
if (isArray(value2)) {
|
|
306
|
+
return getNumberValueArray(value2);
|
|
307
307
|
}
|
|
308
|
-
if (isString(
|
|
308
|
+
if (isString(value2) && isJSONArray(value2)) {
|
|
309
309
|
try {
|
|
310
|
-
var newValue = JSON.parse(
|
|
310
|
+
var newValue = JSON.parse(value2);
|
|
311
311
|
if (isArray(newValue)) {
|
|
312
312
|
return getNumberValueArray(newValue);
|
|
313
313
|
}
|
|
314
314
|
} catch (e) {}
|
|
315
315
|
}
|
|
316
|
-
var newValue1 = Number(
|
|
316
|
+
var newValue1 = Number(value2);
|
|
317
317
|
if (Number.isNaN(newValue1)) {
|
|
318
|
-
throw "".concat(
|
|
318
|
+
throw "".concat(value2, " is not a number array");
|
|
319
319
|
}
|
|
320
320
|
return [
|
|
321
321
|
newValue1
|
|
@@ -338,13 +338,13 @@ var MoneyValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
338
338
|
key: "validate",
|
|
339
339
|
value: function validate(value) {
|
|
340
340
|
return(// value instanceof AmountValue ||
|
|
341
|
-
isPlainObject(value) &&
|
|
341
|
+
(isPlainObject(value) && 'amount' in value && isNumber(value.amount) && 'currency' in value && isString(value.currency)));
|
|
342
342
|
}
|
|
343
343
|
},
|
|
344
344
|
{
|
|
345
345
|
key: "transform",
|
|
346
346
|
value: function transform(value, oldValue) {
|
|
347
|
-
if (value === undefined || value === null || value ===
|
|
347
|
+
if (value === undefined || value === null || value === '') {
|
|
348
348
|
return new AmountValue({
|
|
349
349
|
currency: oldValue === null || oldValue === void 0 ? void 0 : oldValue.currency
|
|
350
350
|
});
|
|
@@ -389,13 +389,13 @@ var TimeScopeValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
389
389
|
key: "validate",
|
|
390
390
|
value: function validate(value) {
|
|
391
391
|
return(// value instanceof RangeDateValue ||
|
|
392
|
-
isPlainObject(value) &&
|
|
392
|
+
(isPlainObject(value) && 'min' in value && isString(value.min) && 'max' in value && isString(value.max)));
|
|
393
393
|
}
|
|
394
394
|
},
|
|
395
395
|
{
|
|
396
396
|
key: "transform",
|
|
397
397
|
value: function transform(value, oldValue) {
|
|
398
|
-
if (value === undefined || value === null || value ===
|
|
398
|
+
if (value === undefined || value === null || value === '') {
|
|
399
399
|
return new RangeDateValue();
|
|
400
400
|
}
|
|
401
401
|
var result;
|
|
@@ -437,13 +437,13 @@ var CalcValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
437
437
|
key: "validate",
|
|
438
438
|
value: function validate(value) {
|
|
439
439
|
return(// value instanceof CalcValue ||
|
|
440
|
-
isPlainObject(value) &&
|
|
440
|
+
(isPlainObject(value) && 'result' in value && isNumber(value.result) && 'unit' in value && isString(value.unit)));
|
|
441
441
|
}
|
|
442
442
|
},
|
|
443
443
|
{
|
|
444
444
|
key: "transform",
|
|
445
445
|
value: function transform(value, oldValue) {
|
|
446
|
-
if (value === undefined || value === null || value ===
|
|
446
|
+
if (value === undefined || value === null || value === '') {
|
|
447
447
|
return new CalcValue({
|
|
448
448
|
unit: oldValue === null || oldValue === void 0 ? void 0 : oldValue.unit
|
|
449
449
|
});
|
|
@@ -504,7 +504,7 @@ var AddressValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
504
504
|
{
|
|
505
505
|
key: "transform",
|
|
506
506
|
value: function transform(value, oldValue) {
|
|
507
|
-
if (value === undefined || value === null || value ===
|
|
507
|
+
if (value === undefined || value === null || value === '') {
|
|
508
508
|
return new AddressValue();
|
|
509
509
|
}
|
|
510
510
|
var result;
|
|
@@ -588,22 +588,22 @@ var ValueCheckerFactory = /*#__PURE__*/ function() {
|
|
|
588
588
|
}();
|
|
589
589
|
function getFieldTypeFromKey(key) {
|
|
590
590
|
if ([
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
591
|
+
'min',
|
|
592
|
+
'max',
|
|
593
|
+
'currency',
|
|
594
|
+
'unit'
|
|
595
595
|
].includes(key)) {
|
|
596
596
|
return FieldTypes.VARCHAR;
|
|
597
597
|
} else if ([
|
|
598
|
-
|
|
599
|
-
|
|
598
|
+
'result',
|
|
599
|
+
'amount'
|
|
600
600
|
].includes(key)) {
|
|
601
601
|
return FieldTypes.DECIMAL;
|
|
602
602
|
}
|
|
603
603
|
}
|
|
604
604
|
export function checkerValue(fieldType, key, value, oldValue) {
|
|
605
|
-
var
|
|
606
|
-
var getCheckerFieldType = (
|
|
605
|
+
var ref;
|
|
606
|
+
var getCheckerFieldType = (ref = getFieldTypeFromKey(key)) !== null && ref !== void 0 ? ref : fieldType;
|
|
607
607
|
var checker = ValueCheckerFactory.getValueChecker(getCheckerFieldType);
|
|
608
608
|
if (!checker || checker.validate(value)) {
|
|
609
609
|
return value;
|
package/dist/esm/common/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from './Engine';
|
|
2
|
+
export * from './Plugin';
|