@byteluck-fe/model-driven-engine 2.2.7 → 2.2.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 +114 -79
- package/dist/esm/common/DataManager.js +80 -39
- package/dist/esm/common/Engine.js +1106 -931
- package/dist/esm/common/OkWorker.js +121 -76
- package/dist/esm/common/Plugin.js +2 -2
- package/dist/esm/common/Runtime.js +61 -44
- package/dist/esm/common/Store.js +145 -113
- package/dist/esm/common/checkerValue.js +367 -292
- package/dist/esm/common/proxyState.js +11 -11
- package/dist/esm/plugins/CalcPlugin.js +405 -317
- 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/index.umd.js +8 -8
- 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,
|
|
@@ -29,145 +43,163 @@ import { loopDataViewControl, loopFormControl } from "../utils/runtimeUtils";
|
|
|
29
43
|
var Store = /*#__PURE__*/ function() {
|
|
30
44
|
"use strict";
|
|
31
45
|
function Store(props) {
|
|
32
|
-
|
|
46
|
+
_class_call_check(this, Store);
|
|
47
|
+
_define_property(this, "emptyState", void 0);
|
|
48
|
+
_define_property(this, "state", void 0);
|
|
49
|
+
_define_property(this, "dataBindMapping", void 0 // 主要提供给二开使用
|
|
50
|
+
);
|
|
51
|
+
_define_property(this, "controlIdMapping", void 0);
|
|
33
52
|
var _init = init(props.instance), state = _init.state, emptyState = _init.emptyState, databindMapping = _init.databindMapping, controlidMapping = _init.controlidMapping;
|
|
34
53
|
this.emptyState = emptyState;
|
|
35
54
|
this.state = state;
|
|
36
55
|
this.dataBindMapping = databindMapping;
|
|
37
56
|
this.controlIdMapping = controlidMapping;
|
|
38
57
|
}
|
|
39
|
-
|
|
40
|
-
|
|
58
|
+
_create_class(Store, [
|
|
59
|
+
{
|
|
60
|
+
/**
|
|
41
61
|
* 使用该方法仅改变数据,不会表单触发事件。明细表可全量赋值也可根据rowIndex进行单独设置
|
|
42
62
|
* @param controlId 组件ID
|
|
43
63
|
* @param value
|
|
44
|
-
*/
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
*/ key: "setState",
|
|
65
|
+
value: function setState(controlId, value, rowIndex) {
|
|
66
|
+
var _this = this;
|
|
67
|
+
var controlInfo = this.controlIdMapping[controlId];
|
|
68
|
+
if (controlInfo !== undefined) {
|
|
69
|
+
//qiyu 按照对象赋值,Object.assign会触发多次key的change事件
|
|
70
|
+
this.state[controlInfo.dataView][controlId] = value;
|
|
71
|
+
// if (
|
|
72
|
+
// controlInfo.dataBind instanceof ObjectDataBind &&
|
|
73
|
+
// isPlainObject(value)
|
|
74
|
+
// ) {
|
|
75
|
+
// Object.assign(this.state[controlInfo.dataView][controlId], value)
|
|
76
|
+
// } else {
|
|
77
|
+
// this.state[controlInfo.dataView][controlId] = value
|
|
78
|
+
// }
|
|
79
|
+
} else {
|
|
80
|
+
if (rowIndex !== undefined) {
|
|
81
|
+
//TODO 目前只找了一层明细表,没有递归
|
|
82
|
+
Object.keys(this.controlIdMapping).map(function(subtableId) {
|
|
83
|
+
var dataView = _this.controlIdMapping[subtableId].dataView;
|
|
84
|
+
var children = _this.controlIdMapping[subtableId].children;
|
|
85
|
+
if (children !== undefined) {
|
|
86
|
+
Object.keys(children).map(function(childControlId) {
|
|
87
|
+
if (childControlId === controlId) {
|
|
88
|
+
_this.state[dataView][subtableId][rowIndex][controlId] = value;
|
|
89
|
+
}
|
|
90
|
+
});
|
|
68
91
|
}
|
|
69
92
|
});
|
|
93
|
+
} else {
|
|
94
|
+
//不存在的 controlId,直接被挂载到外部key
|
|
95
|
+
this.state[controlId] = value;
|
|
70
96
|
}
|
|
71
|
-
}
|
|
72
|
-
} else {
|
|
73
|
-
//不存在的 controlId,直接被挂载到外部key
|
|
74
|
-
this.state[controlId] = value;
|
|
97
|
+
}
|
|
75
98
|
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
key: "getState",
|
|
102
|
+
value: function getState(controlId, rowIndex) {
|
|
103
|
+
var _this = this;
|
|
104
|
+
//qiyu 由于header的数据是后补充的,所以从state获取第一层值。
|
|
105
|
+
// const controlInfo = this.controlIdMapping[controlId]
|
|
106
|
+
var detection = this.state[controlId];
|
|
107
|
+
if (detection !== undefined) {
|
|
108
|
+
return this.state[controlId];
|
|
109
|
+
} else {
|
|
110
|
+
var controlInfo = this.controlIdMapping[controlId];
|
|
111
|
+
if (controlInfo !== undefined) {
|
|
112
|
+
return this.state[controlInfo.dataView][controlId];
|
|
113
|
+
} else {
|
|
114
|
+
if (rowIndex !== undefined) {
|
|
115
|
+
var state;
|
|
116
|
+
//TODO 目前只找了一层明细表,没有递归
|
|
117
|
+
Object.keys(this.controlIdMapping).map(function(subtableId) {
|
|
118
|
+
var dataViewId = _this.controlIdMapping[subtableId].dataView;
|
|
119
|
+
var children = _this.controlIdMapping[subtableId].children;
|
|
120
|
+
if (children !== undefined) {
|
|
121
|
+
Object.keys(children).map(function(childControlId) {
|
|
122
|
+
if (childControlId === controlId) {
|
|
123
|
+
var _this_state_dataViewId_subtableId_rowIndex;
|
|
124
|
+
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];
|
|
125
|
+
}
|
|
126
|
+
});
|
|
101
127
|
}
|
|
102
128
|
});
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
129
|
+
return state;
|
|
130
|
+
} else {
|
|
131
|
+
var states = [];
|
|
132
|
+
Object.keys(this.controlIdMapping).map(function(subtableId) {
|
|
133
|
+
var dataViewId = _this.controlIdMapping[subtableId].dataView;
|
|
134
|
+
var children = _this.controlIdMapping[subtableId].children;
|
|
135
|
+
if (children !== undefined) {
|
|
136
|
+
Object.keys(children).map(function(childControlId) {
|
|
137
|
+
if (childControlId === controlId) {
|
|
138
|
+
_this.state[dataViewId][subtableId].map(function(item) {
|
|
139
|
+
states.push(item[controlId]);
|
|
140
|
+
});
|
|
141
|
+
}
|
|
116
142
|
});
|
|
117
143
|
}
|
|
118
144
|
});
|
|
145
|
+
return states;
|
|
119
146
|
}
|
|
120
|
-
}
|
|
121
|
-
return states;
|
|
147
|
+
}
|
|
122
148
|
}
|
|
123
149
|
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
key: "getEmptyState",
|
|
153
|
+
value: function getEmptyState(controlId) {
|
|
154
|
+
var _this = this;
|
|
155
|
+
var detection = this.emptyState[controlId];
|
|
156
|
+
if (detection !== undefined) {
|
|
157
|
+
return this.emptyState[controlId];
|
|
158
|
+
} else {
|
|
159
|
+
var controlInfo = this.controlIdMapping[controlId];
|
|
160
|
+
if (controlInfo !== undefined) {
|
|
161
|
+
return this.emptyState[controlInfo.dataView][controlId];
|
|
162
|
+
} else {
|
|
163
|
+
var state;
|
|
164
|
+
//TODO 目前只找了一层明细表,没有递归
|
|
165
|
+
Object.keys(this.controlIdMapping).map(function(subtableId) {
|
|
166
|
+
var dataViewId = _this.controlIdMapping[subtableId].dataView;
|
|
167
|
+
var children = _this.controlIdMapping[subtableId].children;
|
|
168
|
+
if (children !== undefined) {
|
|
169
|
+
Object.keys(children).map(function(childControlId) {
|
|
170
|
+
if (childControlId === controlId) {
|
|
171
|
+
state = _this.emptyState[dataViewId][subtableId][controlId];
|
|
172
|
+
}
|
|
173
|
+
});
|
|
145
174
|
}
|
|
146
175
|
});
|
|
176
|
+
return state;
|
|
147
177
|
}
|
|
148
|
-
}
|
|
149
|
-
return state;
|
|
178
|
+
}
|
|
150
179
|
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
key: "getDataBind",
|
|
183
|
+
value: function getDataBind(controlId) {
|
|
184
|
+
var result = this.controlIdMapping[controlId];
|
|
185
|
+
if (result) {
|
|
186
|
+
return result.dataBind;
|
|
187
|
+
}
|
|
188
|
+
wrapperFor: for(var id in this.controlIdMapping){
|
|
189
|
+
var dataBindMapping = this.controlIdMapping[id];
|
|
190
|
+
if (dataBindMapping.children) {
|
|
191
|
+
for(var subId in dataBindMapping.children){
|
|
192
|
+
if (subId === controlId) {
|
|
193
|
+
result = dataBindMapping.children[subId];
|
|
194
|
+
break wrapperFor;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
165
197
|
}
|
|
166
198
|
}
|
|
199
|
+
return result === null || result === void 0 ? void 0 : result.dataBind;
|
|
167
200
|
}
|
|
168
201
|
}
|
|
169
|
-
|
|
170
|
-
};
|
|
202
|
+
]);
|
|
171
203
|
return Store;
|
|
172
204
|
}();
|
|
173
205
|
function init(instance) {
|
|
@@ -328,7 +360,7 @@ item) {
|
|
|
328
360
|
loopFormSchema(item.props.headers, function(formControl) {
|
|
329
361
|
var _data_item_id;
|
|
330
362
|
var _data_item_id_children;
|
|
331
|
-
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 : {},
|
|
363
|
+
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, {
|
|
332
364
|
dataBind: formControl.props.dataBind
|
|
333
365
|
}));
|
|
334
366
|
});
|