@byteluck-fe/model-driven-engine 2.4.1-beta.6 → 2.4.1-beta.7
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 +221 -341
- package/dist/esm/common/OkWorker.js +13 -27
- package/dist/esm/common/Runtime.js +11 -26
- package/dist/esm/common/Store.js +48 -49
- package/dist/esm/common/checkerValue.js +40 -40
- 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 +64 -72
- 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 +8 -8
- 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 +2 -2
|
@@ -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);
|
|
@@ -264,7 +249,7 @@ item) {
|
|
|
264
249
|
} else if (item.type === CONTROL_TYPE.SUBTABLE) {
|
|
265
250
|
data[item.id] = item.rules;
|
|
266
251
|
var itemRules = {
|
|
267
|
-
type:
|
|
252
|
+
type: 'array',
|
|
268
253
|
fields: {}
|
|
269
254
|
};
|
|
270
255
|
item.children.forEach(function(row, index) {
|
|
@@ -272,7 +257,7 @@ item) {
|
|
|
272
257
|
if (itemRules.fields) {
|
|
273
258
|
if (!itemRules.fields[index]) {
|
|
274
259
|
itemRules.fields[index] = {
|
|
275
|
-
type:
|
|
260
|
+
type: 'object',
|
|
276
261
|
required: true,
|
|
277
262
|
fields: {}
|
|
278
263
|
};
|
package/dist/esm/common/Store.js
CHANGED
|
@@ -32,25 +32,19 @@ function _defineProperty(obj, key, value) {
|
|
|
32
32
|
}
|
|
33
33
|
function _instanceof(left, right) {
|
|
34
34
|
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
35
|
-
return
|
|
35
|
+
return right[Symbol.hasInstance](left);
|
|
36
36
|
} else {
|
|
37
37
|
return left instanceof right;
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
import { DataBind, ObjectDataBind } from
|
|
41
|
-
import { loopFormSchema, JSONCopy, warn, CONTROL_TYPE, CONTROL_BASE_TYPE } from
|
|
42
|
-
import { loopDataViewControl, loopFormControl, buildUUID } from
|
|
40
|
+
import { DataBind, ObjectDataBind } from '@byteluck-fe/model-driven-core';
|
|
41
|
+
import { loopFormSchema, JSONCopy, warn, CONTROL_TYPE, CONTROL_BASE_TYPE } from '@byteluck-fe/model-driven-shared';
|
|
42
|
+
import { loopDataViewControl, loopFormControl, buildUUID } from '../utils/runtimeUtils';
|
|
43
43
|
var Store = /*#__PURE__*/ function() {
|
|
44
44
|
"use strict";
|
|
45
45
|
function Store(props) {
|
|
46
46
|
_classCallCheck(this, Store);
|
|
47
|
-
|
|
48
|
-
_defineProperty(this, "state", void 0);
|
|
49
|
-
_defineProperty(this, "dataBindMapping", void 0 // 主要提供给二开使用
|
|
50
|
-
);
|
|
51
|
-
_defineProperty(this, "controlIdMapping", void 0);
|
|
52
|
-
_defineProperty(this, "defaultState", void 0);
|
|
53
|
-
var _init = init(props.instance), state = _init.state, emptyState = _init.emptyState, databindMapping = _init.databindMapping, controlidMapping = _init.controlidMapping, defaultState = _init.defaultState;
|
|
47
|
+
var ref = init(props.instance), state = ref.state, emptyState = ref.emptyState, databindMapping = ref.databindMapping, controlidMapping = ref.controlidMapping, defaultState = ref.defaultState;
|
|
54
48
|
this.emptyState = emptyState;
|
|
55
49
|
this.state = state;
|
|
56
50
|
this.dataBindMapping = databindMapping;
|
|
@@ -65,7 +59,6 @@ var Store = /*#__PURE__*/ function() {
|
|
|
65
59
|
* @param value
|
|
66
60
|
*/ key: "setState",
|
|
67
61
|
value: function setState(controlId, value, rowIndex) {
|
|
68
|
-
var _this = this;
|
|
69
62
|
var controlInfo = this.controlIdMapping[controlId];
|
|
70
63
|
if (controlInfo !== undefined) {
|
|
71
64
|
//qiyu 按照对象赋值,Object.assign会触发多次key的change事件
|
|
@@ -80,14 +73,16 @@ var Store = /*#__PURE__*/ function() {
|
|
|
80
73
|
// }
|
|
81
74
|
} else {
|
|
82
75
|
if (rowIndex !== undefined) {
|
|
76
|
+
var _this = this;
|
|
83
77
|
//TODO 目前只找了一层明细表,没有递归 如果是添加uid
|
|
84
78
|
Object.keys(this.controlIdMapping).map(function(subtableId) {
|
|
85
79
|
var dataView = _this.controlIdMapping[subtableId].dataView;
|
|
86
80
|
var children = _this.controlIdMapping[subtableId].children;
|
|
87
81
|
if (children !== undefined) {
|
|
82
|
+
var _this1 = _this;
|
|
88
83
|
Object.keys(children).map(function(childControlId) {
|
|
89
84
|
if (childControlId === controlId) {
|
|
90
|
-
|
|
85
|
+
_this1.state[dataView][subtableId][rowIndex][controlId] = value;
|
|
91
86
|
}
|
|
92
87
|
});
|
|
93
88
|
}
|
|
@@ -102,7 +97,6 @@ var Store = /*#__PURE__*/ function() {
|
|
|
102
97
|
{
|
|
103
98
|
key: "getState",
|
|
104
99
|
value: function getState(controlId, rowIndex) {
|
|
105
|
-
var _this = this;
|
|
106
100
|
//qiyu 由于header的数据是后补充的,所以从state获取第一层值。
|
|
107
101
|
// const controlInfo = this.controlIdMapping[controlId]
|
|
108
102
|
var detection = this.state[controlId];
|
|
@@ -114,27 +108,31 @@ var Store = /*#__PURE__*/ function() {
|
|
|
114
108
|
return this.state[controlInfo.dataView][controlId];
|
|
115
109
|
} else {
|
|
116
110
|
if (rowIndex !== undefined) {
|
|
111
|
+
var _this = this;
|
|
117
112
|
var state;
|
|
118
113
|
//TODO 目前只找了一层明细表,没有递归
|
|
119
114
|
Object.keys(this.controlIdMapping).map(function(subtableId) {
|
|
120
115
|
var dataViewId = _this.controlIdMapping[subtableId].dataView;
|
|
121
116
|
var children = _this.controlIdMapping[subtableId].children;
|
|
122
117
|
if (children !== undefined) {
|
|
118
|
+
var _this3 = _this;
|
|
123
119
|
Object.keys(children).map(function(childControlId) {
|
|
124
120
|
if (childControlId === controlId) {
|
|
125
|
-
var
|
|
126
|
-
state = (
|
|
121
|
+
var ref;
|
|
122
|
+
state = (ref = _this3.state[dataViewId][subtableId][rowIndex]) === null || ref === void 0 ? void 0 : ref[controlId];
|
|
127
123
|
}
|
|
128
124
|
});
|
|
129
125
|
}
|
|
130
126
|
});
|
|
131
127
|
return state;
|
|
132
128
|
} else {
|
|
129
|
+
var _this2 = this;
|
|
133
130
|
var states = [];
|
|
134
131
|
Object.keys(this.controlIdMapping).map(function(subtableId) {
|
|
135
|
-
var dataViewId =
|
|
136
|
-
var children =
|
|
132
|
+
var dataViewId = _this2.controlIdMapping[subtableId].dataView;
|
|
133
|
+
var children = _this2.controlIdMapping[subtableId].children;
|
|
137
134
|
if (children !== undefined) {
|
|
135
|
+
var _this = _this2;
|
|
138
136
|
Object.keys(children).map(function(childControlId) {
|
|
139
137
|
if (childControlId === controlId) {
|
|
140
138
|
_this.state[dataViewId][subtableId].map(function(item) {
|
|
@@ -153,7 +151,6 @@ var Store = /*#__PURE__*/ function() {
|
|
|
153
151
|
{
|
|
154
152
|
key: "getEmptyState",
|
|
155
153
|
value: function getEmptyState(controlId) {
|
|
156
|
-
var _this = this;
|
|
157
154
|
var detection = this.emptyState[controlId];
|
|
158
155
|
if (detection !== undefined) {
|
|
159
156
|
return this.emptyState[controlId];
|
|
@@ -162,22 +159,24 @@ var Store = /*#__PURE__*/ function() {
|
|
|
162
159
|
if (controlInfo !== undefined) {
|
|
163
160
|
var state = this.emptyState[controlInfo.dataView][controlId];
|
|
164
161
|
//判断找到的是否是明细表的控件
|
|
165
|
-
if (
|
|
162
|
+
if ('children' in controlInfo) {
|
|
166
163
|
Object.assign(state, {
|
|
167
|
-
uid:
|
|
164
|
+
uid: 'new:' + buildUUID('uid')
|
|
168
165
|
});
|
|
169
166
|
}
|
|
170
167
|
return state;
|
|
171
168
|
} else {
|
|
169
|
+
var _this = this;
|
|
172
170
|
var state1;
|
|
173
171
|
//TODO 目前只找了一层明细表,没有递归
|
|
174
172
|
Object.keys(this.controlIdMapping).map(function(subtableId) {
|
|
175
173
|
var dataViewId = _this.controlIdMapping[subtableId].dataView;
|
|
176
174
|
var children = _this.controlIdMapping[subtableId].children;
|
|
177
175
|
if (children !== undefined) {
|
|
176
|
+
var _this4 = _this;
|
|
178
177
|
Object.keys(children).map(function(childControlId) {
|
|
179
178
|
if (childControlId === controlId) {
|
|
180
|
-
state1 =
|
|
179
|
+
state1 = _this4.emptyState[dataViewId][subtableId][controlId];
|
|
181
180
|
}
|
|
182
181
|
});
|
|
183
182
|
}
|
|
@@ -256,34 +255,34 @@ item) {
|
|
|
256
255
|
loopFormSchema(item.props.headers, function(headerItem) {
|
|
257
256
|
emptyTemplate[headerItem.id] = JSONCopy(headerItem.props.defaultValue);
|
|
258
257
|
});
|
|
259
|
-
var
|
|
260
|
-
dataViewState[item.id] = new Array((
|
|
258
|
+
var _defaultRows;
|
|
259
|
+
dataViewState[item.id] = new Array((_defaultRows = item.props.defaultRows) !== null && _defaultRows !== void 0 ? _defaultRows : 1).fill(0).map(function() {
|
|
261
260
|
return JSONCopy(emptyTemplate);
|
|
262
261
|
});
|
|
263
262
|
emptyDataViewState[item.id] = emptyTemplate;
|
|
264
263
|
}
|
|
265
264
|
}
|
|
266
265
|
function buildDataBindMapping(data, dataViewId, // @ts-ignore
|
|
267
|
-
|
|
266
|
+
item1) {
|
|
268
267
|
// if (item instanceof RuntimeFormControl) {
|
|
269
|
-
if (
|
|
270
|
-
var
|
|
271
|
-
if (_instanceof(
|
|
268
|
+
if (item1.controlType === CONTROL_BASE_TYPE.FORM) {
|
|
269
|
+
var ref, ref1;
|
|
270
|
+
if (_instanceof(item1.props.dataBind, ObjectDataBind)) {
|
|
272
271
|
// 特殊的dataBind,比如:金额是currency+amount两个key组成的,日期区间,继承自ObjectDataBind的需要通过Object.keys拿到多个databind
|
|
273
|
-
Object.keys(
|
|
274
|
-
var dataBind =
|
|
272
|
+
Object.keys(item1.props.dataBind).map(function(key) {
|
|
273
|
+
var dataBind = item1.props.dataBind;
|
|
275
274
|
var dataCode = dataBind[key].dataCode;
|
|
276
275
|
if (dataCode !== undefined) {
|
|
277
276
|
if (data[dataCode] === undefined) {
|
|
278
277
|
data[dataCode] = {
|
|
279
|
-
controlId:
|
|
278
|
+
controlId: item1.id,
|
|
280
279
|
fields: [],
|
|
281
280
|
dataViewId: dataViewId
|
|
282
281
|
};
|
|
283
282
|
}
|
|
284
283
|
data[dataCode].fields.push({
|
|
285
284
|
fieldCode: dataBind[key].fieldCode,
|
|
286
|
-
controlId:
|
|
285
|
+
controlId: item1.id,
|
|
287
286
|
dataBind: dataBind,
|
|
288
287
|
dataViewId: [
|
|
289
288
|
dataViewId
|
|
@@ -291,38 +290,38 @@ item) {
|
|
|
291
290
|
});
|
|
292
291
|
}
|
|
293
292
|
});
|
|
294
|
-
} else if (((
|
|
293
|
+
} else if (((ref = item1.props) === null || ref === void 0 ? void 0 : (ref1 = ref.dataBind) === null || ref1 === void 0 ? void 0 : ref1.dataCode) === undefined) {
|
|
295
294
|
//qiyu 2023-2-27 为空跳过。form自定义组件加载失败时,hack的组件props为空。
|
|
296
295
|
} else {
|
|
297
|
-
if (data[
|
|
298
|
-
data[
|
|
296
|
+
if (data[item1.props.dataBind.dataCode] === undefined) {
|
|
297
|
+
data[item1.props.dataBind.dataCode] = {
|
|
299
298
|
controlId: dataViewId,
|
|
300
299
|
fields: [],
|
|
301
300
|
dataViewId: dataViewId
|
|
302
301
|
};
|
|
303
302
|
}
|
|
304
|
-
data[
|
|
305
|
-
fieldCode:
|
|
306
|
-
controlId:
|
|
307
|
-
dataBind:
|
|
303
|
+
data[item1.props.dataBind.dataCode].fields.push({
|
|
304
|
+
fieldCode: item1.props.dataBind.fieldCode,
|
|
305
|
+
controlId: item1.id,
|
|
306
|
+
dataBind: item1.props.dataBind,
|
|
308
307
|
dataViewId: [
|
|
309
308
|
dataViewId
|
|
310
309
|
]
|
|
311
310
|
});
|
|
312
311
|
}
|
|
313
312
|
} else {
|
|
314
|
-
if (
|
|
313
|
+
if (item1.props.datasourceBind.dataCode === '') {
|
|
315
314
|
//敏捷依赖后端生成dataCode,预览的时候没有
|
|
316
|
-
warn("datasourceBind.dataCode is empty! maybe in preview mode, control:".concat(
|
|
315
|
+
warn("datasourceBind.dataCode is empty! maybe in preview mode, control:".concat(item1.id, " type:").concat(item1.type));
|
|
317
316
|
return;
|
|
318
317
|
}
|
|
319
|
-
data[
|
|
320
|
-
controlId:
|
|
318
|
+
data[item1.props.datasourceBind.dataCode] = {
|
|
319
|
+
controlId: item1.id,
|
|
321
320
|
fields: [],
|
|
322
321
|
dataViewId: dataViewId
|
|
323
322
|
};
|
|
324
|
-
var subtableId =
|
|
325
|
-
loopFormSchema(
|
|
323
|
+
var subtableId = item1.id;
|
|
324
|
+
loopFormSchema(item1.props.headers, function(item) {
|
|
326
325
|
if (_instanceof(item.props.dataBind, ObjectDataBind)) {
|
|
327
326
|
Object.keys(item.props.dataBind).map(function(key) {
|
|
328
327
|
var dataBind = item.props.dataBind;
|
|
@@ -364,16 +363,16 @@ item) {
|
|
|
364
363
|
data[item.id] = {
|
|
365
364
|
dataBind: new DataBind({
|
|
366
365
|
dataCode: item.props.datasourceBind.dataCode,
|
|
367
|
-
fieldCode:
|
|
366
|
+
fieldCode: ''
|
|
368
367
|
}),
|
|
369
368
|
dataView: dataViewId,
|
|
370
369
|
children: {},
|
|
371
370
|
options: []
|
|
372
371
|
};
|
|
373
372
|
loopFormSchema(item.props.headers, function(formControl) {
|
|
374
|
-
var
|
|
375
|
-
var
|
|
376
|
-
Object.assign((
|
|
373
|
+
var ref;
|
|
374
|
+
var ref2;
|
|
375
|
+
Object.assign((ref2 = (ref = data[item.id]) === null || ref === void 0 ? void 0 : ref.children) !== null && ref2 !== void 0 ? ref2 : {}, _defineProperty({}, formControl.id, {
|
|
377
376
|
dataBind: formControl.props.dataBind
|
|
378
377
|
}));
|
|
379
378
|
});
|
|
@@ -65,7 +65,7 @@ function _inherits(subClass, superClass) {
|
|
|
65
65
|
}
|
|
66
66
|
function _instanceof(left, right) {
|
|
67
67
|
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
68
|
-
return
|
|
68
|
+
return right[Symbol.hasInstance](left);
|
|
69
69
|
} else {
|
|
70
70
|
return left instanceof right;
|
|
71
71
|
}
|
|
@@ -164,9 +164,9 @@ function _createSuper(Derived) {
|
|
|
164
164
|
return _possibleConstructorReturn(this, result);
|
|
165
165
|
};
|
|
166
166
|
}
|
|
167
|
-
import { isArray, isFunction, isString, isJSONArray, isJSONObject, isNumber, isNumberAndEmptyStringArray, isPlainObject, isStringArray, FieldTypes, isObject } from
|
|
168
|
-
import { AddressValue, AmountValue, CalcValue, RangeDateValue } from
|
|
169
|
-
import { camelizeKeys } from
|
|
167
|
+
import { isArray, isFunction, isString, isJSONArray, isJSONObject, isNumber, isNumberAndEmptyStringArray, isPlainObject, isStringArray, FieldTypes, isObject } from '@byteluck-fe/model-driven-shared';
|
|
168
|
+
import { AddressValue, AmountValue, CalcValue, RangeDateValue } from '@byteluck-fe/model-driven-core';
|
|
169
|
+
import { camelizeKeys } from 'humps';
|
|
170
170
|
var ValueChecker = function ValueChecker() {
|
|
171
171
|
"use strict";
|
|
172
172
|
_classCallCheck(this, ValueChecker);
|
|
@@ -190,7 +190,7 @@ var StringValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
190
190
|
key: "transform",
|
|
191
191
|
value: function transform(value) {
|
|
192
192
|
if (value === null || value === undefined) {
|
|
193
|
-
return
|
|
193
|
+
return '';
|
|
194
194
|
}
|
|
195
195
|
if (!isPlainObject(value) && !isFunction(value)) {
|
|
196
196
|
return String(value);
|
|
@@ -217,14 +217,14 @@ var NumberValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
217
217
|
// 数字类型允许是空字符串,用于置空数据
|
|
218
218
|
key: "validate",
|
|
219
219
|
value: function validate(value) {
|
|
220
|
-
return isNumber(value) || value ===
|
|
220
|
+
return isNumber(value) || value === '';
|
|
221
221
|
}
|
|
222
222
|
},
|
|
223
223
|
{
|
|
224
224
|
key: "transform",
|
|
225
225
|
value: function transform(value) {
|
|
226
226
|
if (value === null || value === undefined) {
|
|
227
|
-
return
|
|
227
|
+
return '';
|
|
228
228
|
}
|
|
229
229
|
var newValue = !isPlainObject(value) && !isFunction(value) ? Number(value) : undefined;
|
|
230
230
|
if (!Number.isNaN(newValue) && newValue !== undefined) {
|
|
@@ -253,28 +253,28 @@ var StringArrayValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
253
253
|
},
|
|
254
254
|
{
|
|
255
255
|
key: "transform",
|
|
256
|
-
value: function transform(
|
|
256
|
+
value: function transform(value1) {
|
|
257
257
|
var getStringValueArray = function getStringValueArray(value) {
|
|
258
258
|
return value.map(function(item) {
|
|
259
|
-
return !item ?
|
|
259
|
+
return !item ? '' : String(item);
|
|
260
260
|
});
|
|
261
261
|
};
|
|
262
|
-
if (
|
|
262
|
+
if (value1 === undefined || value1 === null) {
|
|
263
263
|
return [];
|
|
264
264
|
}
|
|
265
|
-
if (isArray(
|
|
266
|
-
return getStringValueArray(
|
|
265
|
+
if (isArray(value1)) {
|
|
266
|
+
return getStringValueArray(value1);
|
|
267
267
|
}
|
|
268
|
-
if (isString(
|
|
268
|
+
if (isString(value1) && isJSONArray(value1)) {
|
|
269
269
|
try {
|
|
270
|
-
var newValue = JSON.parse(
|
|
270
|
+
var newValue = JSON.parse(value1);
|
|
271
271
|
if (Array.isArray(newValue)) {
|
|
272
272
|
return getStringValueArray(newValue);
|
|
273
273
|
}
|
|
274
274
|
} catch (e) {}
|
|
275
275
|
}
|
|
276
276
|
return [
|
|
277
|
-
String(
|
|
277
|
+
String(value1)
|
|
278
278
|
];
|
|
279
279
|
}
|
|
280
280
|
}
|
|
@@ -298,31 +298,31 @@ var NumberArrayValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
298
298
|
},
|
|
299
299
|
{
|
|
300
300
|
key: "transform",
|
|
301
|
-
value: function transform(
|
|
301
|
+
value: function transform(value2) {
|
|
302
302
|
var getNumberValueArray = function getNumberValueArray(value) {
|
|
303
303
|
return value.map(function(item) {
|
|
304
|
-
return !item && item !== 0 ?
|
|
304
|
+
return !item && item !== 0 ? '' : Number(item);
|
|
305
305
|
}).filter(function(item) {
|
|
306
|
-
return item ===
|
|
306
|
+
return item === '' || !Number.isNaN(item);
|
|
307
307
|
});
|
|
308
308
|
};
|
|
309
|
-
if (
|
|
309
|
+
if (value2 === undefined || value2 === null) {
|
|
310
310
|
return [];
|
|
311
311
|
}
|
|
312
|
-
if (isArray(
|
|
313
|
-
return getNumberValueArray(
|
|
312
|
+
if (isArray(value2)) {
|
|
313
|
+
return getNumberValueArray(value2);
|
|
314
314
|
}
|
|
315
|
-
if (isString(
|
|
315
|
+
if (isString(value2) && isJSONArray(value2)) {
|
|
316
316
|
try {
|
|
317
|
-
var newValue = JSON.parse(
|
|
317
|
+
var newValue = JSON.parse(value2);
|
|
318
318
|
if (isArray(newValue)) {
|
|
319
319
|
return getNumberValueArray(newValue);
|
|
320
320
|
}
|
|
321
321
|
} catch (e) {}
|
|
322
322
|
}
|
|
323
|
-
var newValue1 = Number(
|
|
323
|
+
var newValue1 = Number(value2);
|
|
324
324
|
if (Number.isNaN(newValue1)) {
|
|
325
|
-
throw "".concat(
|
|
325
|
+
throw "".concat(value2, " is not a number array");
|
|
326
326
|
}
|
|
327
327
|
return [
|
|
328
328
|
newValue1
|
|
@@ -344,13 +344,13 @@ var MoneyValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
344
344
|
{
|
|
345
345
|
key: "validate",
|
|
346
346
|
value: function validate(value) {
|
|
347
|
-
return _instanceof(value, AmountValue) || isPlainObject(value) &&
|
|
347
|
+
return _instanceof(value, AmountValue) || isPlainObject(value) && 'amount' in value && isNumber(value.amount) && 'currency' in value && isString(value.currency);
|
|
348
348
|
}
|
|
349
349
|
},
|
|
350
350
|
{
|
|
351
351
|
key: "transform",
|
|
352
352
|
value: function transform(value, oldValue) {
|
|
353
|
-
if (value === undefined || value === null || value ===
|
|
353
|
+
if (value === undefined || value === null || value === '') {
|
|
354
354
|
return new AmountValue({
|
|
355
355
|
currency: oldValue === null || oldValue === void 0 ? void 0 : oldValue.currency
|
|
356
356
|
});
|
|
@@ -394,13 +394,13 @@ var TimeScopeValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
394
394
|
{
|
|
395
395
|
key: "validate",
|
|
396
396
|
value: function validate(value) {
|
|
397
|
-
return _instanceof(value, RangeDateValue) || isPlainObject(value) &&
|
|
397
|
+
return _instanceof(value, RangeDateValue) || isPlainObject(value) && 'min' in value && isString(value.min) && 'max' in value && isString(value.max);
|
|
398
398
|
}
|
|
399
399
|
},
|
|
400
400
|
{
|
|
401
401
|
key: "transform",
|
|
402
402
|
value: function transform(value, oldValue) {
|
|
403
|
-
if (value === undefined || value === null || value ===
|
|
403
|
+
if (value === undefined || value === null || value === '') {
|
|
404
404
|
return new RangeDateValue();
|
|
405
405
|
}
|
|
406
406
|
var result;
|
|
@@ -441,13 +441,13 @@ var CalcValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
441
441
|
{
|
|
442
442
|
key: "validate",
|
|
443
443
|
value: function validate(value) {
|
|
444
|
-
return _instanceof(value, CalcValue) || isPlainObject(value) &&
|
|
444
|
+
return _instanceof(value, CalcValue) || isPlainObject(value) && 'result' in value && isNumber(value.result) && 'unit' in value && isString(value.unit);
|
|
445
445
|
}
|
|
446
446
|
},
|
|
447
447
|
{
|
|
448
448
|
key: "transform",
|
|
449
449
|
value: function transform(value, oldValue) {
|
|
450
|
-
if (value === undefined || value === null || value ===
|
|
450
|
+
if (value === undefined || value === null || value === '') {
|
|
451
451
|
return new CalcValue({
|
|
452
452
|
unit: oldValue === null || oldValue === void 0 ? void 0 : oldValue.unit
|
|
453
453
|
});
|
|
@@ -497,7 +497,7 @@ var AddressValueChecker = /*#__PURE__*/ function(ValueChecker) {
|
|
|
497
497
|
{
|
|
498
498
|
key: "transform",
|
|
499
499
|
value: function transform(value, oldValue) {
|
|
500
|
-
if (value === undefined || value === null || value ===
|
|
500
|
+
if (value === undefined || value === null || value === '') {
|
|
501
501
|
return new AddressValue();
|
|
502
502
|
}
|
|
503
503
|
var result;
|
|
@@ -581,22 +581,22 @@ var ValueCheckerFactory = /*#__PURE__*/ function() {
|
|
|
581
581
|
}();
|
|
582
582
|
function getFieldTypeFromKey(key) {
|
|
583
583
|
if ([
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
584
|
+
'min',
|
|
585
|
+
'max',
|
|
586
|
+
'currency',
|
|
587
|
+
'unit'
|
|
588
588
|
].includes(key)) {
|
|
589
589
|
return FieldTypes.VARCHAR;
|
|
590
590
|
} else if ([
|
|
591
|
-
|
|
592
|
-
|
|
591
|
+
'result',
|
|
592
|
+
'amount'
|
|
593
593
|
].includes(key)) {
|
|
594
594
|
return FieldTypes.DECIMAL;
|
|
595
595
|
}
|
|
596
596
|
}
|
|
597
597
|
export function checkerValue(fieldType, key, value, oldValue) {
|
|
598
|
-
var
|
|
599
|
-
var getCheckerFieldType = (
|
|
598
|
+
var ref;
|
|
599
|
+
var getCheckerFieldType = (ref = getFieldTypeFromKey(key)) !== null && ref !== void 0 ? ref : fieldType;
|
|
600
600
|
var checker = ValueCheckerFactory.getValueChecker(getCheckerFieldType);
|
|
601
601
|
if (!checker || checker.validate(value)) {
|
|
602
602
|
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';
|