@byteluck-fe/model-driven-engine 2.7.0-alpha.15a → 2.7.0-alpha.17
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 +157 -40
- package/dist/esm/common/DataManager.js +129 -20
- package/dist/esm/common/Engine.js +412 -322
- package/dist/esm/common/OkWorker.js +27 -13
- package/dist/esm/common/Runtime.js +54 -78
- package/dist/esm/common/Store.js +51 -50
- 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 +67 -59
- package/dist/esm/plugins/ControlsEventPlugin.js +191 -68
- package/dist/esm/plugins/ES6ModulePlugin.js +24 -8
- package/dist/esm/plugins/LifecycleEventPlugin.js +183 -64
- package/dist/esm/plugins/StylePlugin.js +22 -7
- package/dist/esm/plugins/index.js +5 -5
- package/dist/esm/utils/index.js +1 -1
- package/dist/esm/utils/runtimeUtils.js +5 -7
- package/dist/index.umd.js +8 -8
- package/dist/types/common/Engine.d.ts +9 -10
- package/dist/types/common/Runtime.d.ts +1 -2
- 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,11 +17,25 @@ function _createClass(Constructor, protoProps, staticProps) {
|
|
|
17
17
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
18
18
|
return Constructor;
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
function _defineProperty(obj, key, value) {
|
|
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";
|
|
21
34
|
var OkWorker = /*#__PURE__*/ function() {
|
|
22
35
|
"use strict";
|
|
23
36
|
function OkWorker() {
|
|
24
37
|
_classCallCheck(this, OkWorker);
|
|
38
|
+
_defineProperty(this, "worker", void 0);
|
|
25
39
|
}
|
|
26
40
|
_createClass(OkWorker, [
|
|
27
41
|
{
|
|
@@ -29,7 +43,7 @@ var OkWorker = /*#__PURE__*/ function() {
|
|
|
29
43
|
value: function run(initState) {
|
|
30
44
|
this.worker = OkWorker.createWorker();
|
|
31
45
|
this.postMessage({
|
|
32
|
-
action:
|
|
46
|
+
action: "init",
|
|
33
47
|
payload: initState
|
|
34
48
|
});
|
|
35
49
|
}
|
|
@@ -37,15 +51,15 @@ var OkWorker = /*#__PURE__*/ function() {
|
|
|
37
51
|
{
|
|
38
52
|
key: "destroy",
|
|
39
53
|
value: function destroy() {
|
|
40
|
-
var
|
|
41
|
-
(
|
|
54
|
+
var _this_worker;
|
|
55
|
+
(_this_worker = this.worker) === null || _this_worker === void 0 ? void 0 : _this_worker.terminate();
|
|
42
56
|
}
|
|
43
57
|
},
|
|
44
58
|
{
|
|
45
59
|
key: "postMessage",
|
|
46
60
|
value: function postMessage(message) {
|
|
47
|
-
var
|
|
48
|
-
(
|
|
61
|
+
var _this_worker;
|
|
62
|
+
(_this_worker = this.worker) === null || _this_worker === void 0 ? void 0 : _this_worker.postMessage(message);
|
|
49
63
|
}
|
|
50
64
|
}
|
|
51
65
|
], [
|
|
@@ -71,7 +85,7 @@ var OkWorker = /*#__PURE__*/ function() {
|
|
|
71
85
|
set: function set(target, key, value) {
|
|
72
86
|
if (parentKey) {
|
|
73
87
|
_self.postMessage({
|
|
74
|
-
action:
|
|
88
|
+
action: "update",
|
|
75
89
|
key: "".concat(parentKey, ".").concat(key)
|
|
76
90
|
});
|
|
77
91
|
}
|
|
@@ -79,7 +93,7 @@ var OkWorker = /*#__PURE__*/ function() {
|
|
|
79
93
|
}
|
|
80
94
|
};
|
|
81
95
|
};
|
|
82
|
-
log(
|
|
96
|
+
log("\uD83D\uDE80 worker running");
|
|
83
97
|
var _self = self;
|
|
84
98
|
// function createProxy(
|
|
85
99
|
// obj: Record<string, unknown> | Array<Record<string, unknown>>,
|
|
@@ -92,8 +106,8 @@ var OkWorker = /*#__PURE__*/ function() {
|
|
|
92
106
|
// }
|
|
93
107
|
// return new Proxy(obj, createHandler(parentKey))
|
|
94
108
|
// }
|
|
95
|
-
_self.addEventListener(
|
|
96
|
-
var
|
|
109
|
+
_self.addEventListener("message", function(event) {
|
|
110
|
+
var _event_data = event.data, action = _event_data.action, payload = _event_data.payload, fn = _event_data.fn;
|
|
97
111
|
log(action, payload);
|
|
98
112
|
// 通过proxy进行代理,每次修改的时候,自动向外抛出postMessage
|
|
99
113
|
// data.key1 = 1
|
|
@@ -104,10 +118,10 @@ var OkWorker = /*#__PURE__*/ function() {
|
|
|
104
118
|
//
|
|
105
119
|
// const result = fn(data, schema)
|
|
106
120
|
_self.postMessage({
|
|
107
|
-
action:
|
|
121
|
+
action: "delete",
|
|
108
122
|
payload: {
|
|
109
|
-
key:
|
|
110
|
-
value:
|
|
123
|
+
key: "key3[0].key1",
|
|
124
|
+
value: "index"
|
|
111
125
|
}
|
|
112
126
|
});
|
|
113
127
|
});
|
|
@@ -23,6 +23,19 @@ 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
|
+
}
|
|
26
39
|
function _getPrototypeOf(o) {
|
|
27
40
|
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
28
41
|
return o.__proto__ || Object.getPrototypeOf(o);
|
|
@@ -83,20 +96,21 @@ function _createSuper(Derived) {
|
|
|
83
96
|
return _possibleConstructorReturn(this, result);
|
|
84
97
|
};
|
|
85
98
|
}
|
|
86
|
-
import { RegisterControls } from
|
|
87
|
-
import { CONTROL_BASE_TYPE, CONTROL_TYPE,
|
|
88
|
-
import { hasChildrenControl, loopDataViewControl, loopFormControl } from
|
|
89
|
-
export var Runtime = /*#__PURE__*/ function(
|
|
99
|
+
import { RegisterControls } from "@byteluck-fe/model-driven-core";
|
|
100
|
+
import { CONTROL_BASE_TYPE, CONTROL_TYPE, loopFormSchema } from "@byteluck-fe/model-driven-shared";
|
|
101
|
+
import { hasChildrenControl, loopDataViewControl, loopFormControl } from "../utils/runtimeUtils";
|
|
102
|
+
export var Runtime = /*#__PURE__*/ function(RegisterControls) {
|
|
90
103
|
"use strict";
|
|
91
|
-
_inherits(Runtime,
|
|
104
|
+
_inherits(Runtime, RegisterControls);
|
|
92
105
|
var _super = _createSuper(Runtime);
|
|
93
106
|
function Runtime(props) {
|
|
94
107
|
_classCallCheck(this, Runtime);
|
|
95
108
|
var _this;
|
|
96
|
-
_this = _super.call(this,
|
|
97
|
-
_this
|
|
98
|
-
_this
|
|
99
|
-
_this
|
|
109
|
+
_this = _super.call(this, "Runtime");
|
|
110
|
+
_defineProperty(_assertThisInitialized(_this), "_schema", void 0);
|
|
111
|
+
_defineProperty(_assertThisInitialized(_this), "_instance", void 0);
|
|
112
|
+
_defineProperty(_assertThisInitialized(_this), "_flatInstances", []);
|
|
113
|
+
_defineProperty(_assertThisInitialized(_this), "_instanceMap", {});
|
|
100
114
|
var schema = props.schema;
|
|
101
115
|
_this._schema = schema;
|
|
102
116
|
_this._instance = _this.createControl(schema, props.beforeCreateInstance);
|
|
@@ -109,32 +123,19 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls1) {
|
|
|
109
123
|
value: function getFlatInstances() {
|
|
110
124
|
var instances = [];
|
|
111
125
|
var instanceMap = {};
|
|
112
|
-
|
|
113
|
-
loop(this._instance, '', function(item, parentId) {
|
|
126
|
+
loop(this._instance, function(item) {
|
|
114
127
|
// 3.4.1 避免将subtable-row 放到 _flatInstances 中
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
// return
|
|
118
|
-
// }
|
|
119
|
-
if (parentId) {
|
|
120
|
-
// @ts-ignore
|
|
121
|
-
controlParentIdMap[item.id] = parentId;
|
|
128
|
+
if (item.type === "subtable-row" || item.type === "subtable-column") {
|
|
129
|
+
return;
|
|
122
130
|
}
|
|
131
|
+
instances.push(item);
|
|
123
132
|
if (!instanceMap[item.id]) {
|
|
124
133
|
instanceMap[item.id] = [];
|
|
125
134
|
}
|
|
126
|
-
//不知为何subtable-column会多存一次
|
|
127
|
-
if (item.type === 'subtable-column') {
|
|
128
|
-
if (instanceMap[item.id].length > 0) {
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
instances.push(item);
|
|
133
135
|
instanceMap[item.id].push(item);
|
|
134
136
|
});
|
|
135
137
|
this._flatInstances = instances;
|
|
136
138
|
this._instanceMap = instanceMap;
|
|
137
|
-
this._controlParentIdMap = controlParentIdMap;
|
|
138
139
|
return this._flatInstances;
|
|
139
140
|
}
|
|
140
141
|
},
|
|
@@ -168,9 +169,8 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls1) {
|
|
|
168
169
|
var antdRules = {};
|
|
169
170
|
var ruleItems = {};
|
|
170
171
|
loopDataViewControl(this._instance, function(dataView) {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
antdRules[dataView.id] = JSONCopy(result[0]);
|
|
172
|
+
ruleItems[dataView.id] = dataView.rules[0];
|
|
173
|
+
antdRules[dataView.id] = dataView.rules[0];
|
|
174
174
|
loopFormControl(dataView.children, function(item) {
|
|
175
175
|
// if (
|
|
176
176
|
// item instanceof RuntimeFormControl ||
|
|
@@ -193,9 +193,7 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls1) {
|
|
|
193
193
|
get: function get() {
|
|
194
194
|
var ruleItems = {};
|
|
195
195
|
loopDataViewControl(this._instance, function(dataView) {
|
|
196
|
-
|
|
197
|
-
// ruleItems[dataView.id] = dataView.rules[0]
|
|
198
|
-
ruleItems[dataView.id] = result[0];
|
|
196
|
+
ruleItems[dataView.id] = dataView.rules[0];
|
|
199
197
|
loopFormControl(dataView.children, function(item) {
|
|
200
198
|
// if (
|
|
201
199
|
// item instanceof RuntimeFormControl ||
|
|
@@ -214,9 +212,7 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls1) {
|
|
|
214
212
|
get: function get() {
|
|
215
213
|
var antdRules = {};
|
|
216
214
|
loopDataViewControl(this._instance, function(dataView) {
|
|
217
|
-
|
|
218
|
-
// antdRules[dataView.id] = dataView.rules[0]
|
|
219
|
-
antdRules[dataView.id] = result[0];
|
|
215
|
+
antdRules[dataView.id] = dataView.rules[0];
|
|
220
216
|
loopFormControl(dataView.children, function(item) {
|
|
221
217
|
// if (
|
|
222
218
|
// item instanceof RuntimeFormControl ||
|
|
@@ -233,30 +229,22 @@ export var Runtime = /*#__PURE__*/ function(RegisterControls1) {
|
|
|
233
229
|
]);
|
|
234
230
|
return Runtime;
|
|
235
231
|
}(RegisterControls);
|
|
236
|
-
function loop(control,
|
|
237
|
-
|
|
238
|
-
control
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
232
|
+
function loop(control, callback) {
|
|
233
|
+
if (Array.isArray(control)) {
|
|
234
|
+
control.map(function(item) {
|
|
235
|
+
callback(item);
|
|
236
|
+
if (hasChildrenControl(item)) {
|
|
237
|
+
var ctl = item;
|
|
238
|
+
if (!ctl.children) {
|
|
239
|
+
ctl.children = [];
|
|
240
|
+
}
|
|
241
|
+
// @ts-ignore
|
|
242
|
+
loop(ctl.children, callback);
|
|
246
243
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
loop(item.props.headers, item.id, callback);
|
|
252
|
-
}
|
|
253
|
-
if (hasHeaderOrFooterControl(item, 'footers')) {
|
|
254
|
-
loop(item.props.footers, item.id, callback);
|
|
255
|
-
}
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
function hasHeaderOrFooterControl(control, checkType) {
|
|
259
|
-
return checkType in control.props && isArray(control.props[checkType]);
|
|
244
|
+
});
|
|
245
|
+
} else {
|
|
246
|
+
callback(control);
|
|
247
|
+
}
|
|
260
248
|
}
|
|
261
249
|
/**
|
|
262
250
|
* 控件是否在视图中隐藏,遍历查找所有parent
|
|
@@ -264,7 +252,7 @@ function hasHeaderOrFooterControl(control, checkType) {
|
|
|
264
252
|
if (control.props.isHide) {
|
|
265
253
|
return true;
|
|
266
254
|
}
|
|
267
|
-
if (control.parent === null
|
|
255
|
+
if (control.parent === null) {
|
|
268
256
|
return false;
|
|
269
257
|
}
|
|
270
258
|
return getControlIsHide(control.parent);
|
|
@@ -274,16 +262,13 @@ item) {
|
|
|
274
262
|
if (getControlIsHide(item)) {
|
|
275
263
|
return;
|
|
276
264
|
}
|
|
277
|
-
var result = Runtime.staticGetRules(item.type, item.props);
|
|
278
265
|
// if (item instanceof RuntimeFormControl) {
|
|
279
266
|
if (item.controlType === CONTROL_BASE_TYPE.FORM) {
|
|
280
|
-
|
|
281
|
-
data[item.id] = result;
|
|
267
|
+
data[item.id] = item.rules;
|
|
282
268
|
} else if (item.type === CONTROL_TYPE.SUBTABLE) {
|
|
283
|
-
|
|
284
|
-
data[item.id] = result;
|
|
269
|
+
data[item.id] = item.rules;
|
|
285
270
|
var itemRules = {
|
|
286
|
-
type:
|
|
271
|
+
type: "array",
|
|
287
272
|
fields: {}
|
|
288
273
|
};
|
|
289
274
|
item.children.forEach(function(row, index) {
|
|
@@ -291,18 +276,13 @@ item) {
|
|
|
291
276
|
if (itemRules.fields) {
|
|
292
277
|
if (!itemRules.fields[index]) {
|
|
293
278
|
itemRules.fields[index] = {
|
|
294
|
-
type:
|
|
279
|
+
type: "object",
|
|
295
280
|
required: true,
|
|
296
281
|
fields: {}
|
|
297
282
|
};
|
|
298
283
|
}
|
|
299
|
-
// // @ts-ignore
|
|
300
|
-
// itemRules.fields[index].fields[formControl.id] = (
|
|
301
|
-
// formControl as RuntimeFormControl
|
|
302
|
-
// ).rules
|
|
303
|
-
var childResult = Runtime.staticGetRules(formControl.type, formControl.props);
|
|
304
284
|
// @ts-ignore
|
|
305
|
-
itemRules.fields[index].fields[formControl.id] =
|
|
285
|
+
itemRules.fields[index].fields[formControl.id] = formControl.rules;
|
|
306
286
|
}
|
|
307
287
|
});
|
|
308
288
|
});
|
|
@@ -314,19 +294,15 @@ item) {
|
|
|
314
294
|
if (getControlIsHide(item)) {
|
|
315
295
|
return;
|
|
316
296
|
}
|
|
317
|
-
var result = Runtime.staticGetRules(item.type, item.props);
|
|
318
297
|
// if (item instanceof RuntimeFormControl) {
|
|
319
298
|
if (item.controlType === CONTROL_BASE_TYPE.FORM) {
|
|
320
|
-
|
|
321
|
-
antdRules[item.id] = result;
|
|
299
|
+
antdRules[item.id] = item.rules;
|
|
322
300
|
} else if (item.type === CONTROL_TYPE.SUBTABLE && item.children.length) {
|
|
323
301
|
antdRules[item.id] = [];
|
|
324
302
|
item.children.forEach(function(row) {
|
|
325
303
|
var rules = {};
|
|
326
304
|
loopFormSchema(row.children, function(formControl) {
|
|
327
|
-
|
|
328
|
-
var childResult = Runtime.staticGetRules(formControl.type, formControl.props);
|
|
329
|
-
rules[formControl.id] = childResult;
|
|
305
|
+
rules[formControl.id] = formControl.rules;
|
|
330
306
|
});
|
|
331
307
|
antdRules[item.id].push(rules);
|
|
332
308
|
});
|
package/dist/esm/common/Store.js
CHANGED
|
@@ -45,14 +45,20 @@ 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
|
-
|
|
55
|
+
_defineProperty(this, "emptyState", void 0);
|
|
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;
|
|
56
62
|
this.emptyState = emptyState;
|
|
57
63
|
this.state = state;
|
|
58
64
|
this.dataBindMapping = databindMapping;
|
|
@@ -67,6 +73,7 @@ var Store = /*#__PURE__*/ function() {
|
|
|
67
73
|
* @param value
|
|
68
74
|
*/ key: "setState",
|
|
69
75
|
value: function setState(controlId, value, rowIndex) {
|
|
76
|
+
var _this = this;
|
|
70
77
|
var controlInfo = this.controlIdMapping[controlId];
|
|
71
78
|
if (controlInfo !== undefined) {
|
|
72
79
|
//qiyu 按照对象赋值,Object.assign会触发多次key的change事件
|
|
@@ -81,17 +88,15 @@ var Store = /*#__PURE__*/ function() {
|
|
|
81
88
|
// }
|
|
82
89
|
} else {
|
|
83
90
|
if (rowIndex !== undefined) {
|
|
84
|
-
var _this = this;
|
|
85
91
|
//TODO 目前只找了一层明细表,没有递归 如果是添加uid
|
|
86
92
|
Object.keys(this.controlIdMapping).map(function(subtableId) {
|
|
87
93
|
var dataView = _this.controlIdMapping[subtableId].dataView;
|
|
88
94
|
var children = _this.controlIdMapping[subtableId].children;
|
|
89
95
|
if (children !== undefined) {
|
|
90
|
-
var _this1 = _this;
|
|
91
96
|
Object.keys(children).map(function(childControlId) {
|
|
92
97
|
if (childControlId === controlId) {
|
|
93
|
-
if (
|
|
94
|
-
|
|
98
|
+
if (_this.state[dataView][subtableId][rowIndex]) {
|
|
99
|
+
_this.state[dataView][subtableId][rowIndex][controlId] = value;
|
|
95
100
|
}
|
|
96
101
|
}
|
|
97
102
|
});
|
|
@@ -107,6 +112,7 @@ var Store = /*#__PURE__*/ function() {
|
|
|
107
112
|
{
|
|
108
113
|
key: "getState",
|
|
109
114
|
value: function getState(controlId, rowIndex) {
|
|
115
|
+
var _this = this;
|
|
110
116
|
//qiyu 由于header的数据是后补充的,所以从state获取第一层值。
|
|
111
117
|
// const controlInfo = this.controlIdMapping[controlId]
|
|
112
118
|
var detection = this.state[controlId];
|
|
@@ -118,31 +124,27 @@ var Store = /*#__PURE__*/ function() {
|
|
|
118
124
|
return this.state[controlInfo.dataView][controlId];
|
|
119
125
|
} else {
|
|
120
126
|
if (rowIndex !== undefined) {
|
|
121
|
-
var _this = this;
|
|
122
127
|
var state;
|
|
123
128
|
//TODO 目前只找了一层明细表,没有递归
|
|
124
129
|
Object.keys(this.controlIdMapping).map(function(subtableId) {
|
|
125
130
|
var dataViewId = _this.controlIdMapping[subtableId].dataView;
|
|
126
131
|
var children = _this.controlIdMapping[subtableId].children;
|
|
127
132
|
if (children !== undefined) {
|
|
128
|
-
var _this3 = _this;
|
|
129
133
|
Object.keys(children).map(function(childControlId) {
|
|
130
134
|
if (childControlId === controlId) {
|
|
131
|
-
var
|
|
132
|
-
state = (
|
|
135
|
+
var _this_state_dataViewId_subtableId_rowIndex;
|
|
136
|
+
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];
|
|
133
137
|
}
|
|
134
138
|
});
|
|
135
139
|
}
|
|
136
140
|
});
|
|
137
141
|
return state;
|
|
138
142
|
} else {
|
|
139
|
-
var _this2 = this;
|
|
140
143
|
var states = [];
|
|
141
144
|
Object.keys(this.controlIdMapping).map(function(subtableId) {
|
|
142
|
-
var dataViewId =
|
|
143
|
-
var children =
|
|
145
|
+
var dataViewId = _this.controlIdMapping[subtableId].dataView;
|
|
146
|
+
var children = _this.controlIdMapping[subtableId].children;
|
|
144
147
|
if (children !== undefined) {
|
|
145
|
-
var _this = _this2;
|
|
146
148
|
Object.keys(children).map(function(childControlId) {
|
|
147
149
|
if (childControlId === controlId) {
|
|
148
150
|
_this.state[dataViewId][subtableId].map(function(item) {
|
|
@@ -161,6 +163,7 @@ var Store = /*#__PURE__*/ function() {
|
|
|
161
163
|
{
|
|
162
164
|
key: "getEmptyState",
|
|
163
165
|
value: function getEmptyState(controlId) {
|
|
166
|
+
var _this = this;
|
|
164
167
|
var detection = this.emptyState[controlId];
|
|
165
168
|
if (detection !== undefined) {
|
|
166
169
|
return this.emptyState[controlId];
|
|
@@ -169,24 +172,22 @@ var Store = /*#__PURE__*/ function() {
|
|
|
169
172
|
if (controlInfo !== undefined) {
|
|
170
173
|
var state = this.emptyState[controlInfo.dataView][controlId];
|
|
171
174
|
//判断找到的是否是明细表的控件
|
|
172
|
-
if (
|
|
175
|
+
if ("children" in controlInfo) {
|
|
173
176
|
Object.assign(state, {
|
|
174
|
-
uid:
|
|
177
|
+
uid: "new:" + buildUUID("uid")
|
|
175
178
|
});
|
|
176
179
|
}
|
|
177
180
|
return state;
|
|
178
181
|
} else {
|
|
179
|
-
var _this = this;
|
|
180
182
|
var state1;
|
|
181
183
|
//TODO 目前只找了一层明细表,没有递归
|
|
182
184
|
Object.keys(this.controlIdMapping).map(function(subtableId) {
|
|
183
185
|
var dataViewId = _this.controlIdMapping[subtableId].dataView;
|
|
184
186
|
var children = _this.controlIdMapping[subtableId].children;
|
|
185
187
|
if (children !== undefined) {
|
|
186
|
-
var _this4 = _this;
|
|
187
188
|
Object.keys(children).map(function(childControlId) {
|
|
188
189
|
if (childControlId === controlId) {
|
|
189
|
-
state1 =
|
|
190
|
+
state1 = _this.emptyState[dataViewId][subtableId][controlId];
|
|
190
191
|
}
|
|
191
192
|
});
|
|
192
193
|
}
|
|
@@ -265,37 +266,37 @@ item) {
|
|
|
265
266
|
loopFormSchema(item.props.headers, function(headerItem) {
|
|
266
267
|
emptyTemplate[headerItem.id] = JSONCopy(headerItem.props.defaultValue);
|
|
267
268
|
});
|
|
268
|
-
var
|
|
269
|
-
dataViewState[item.id] = (
|
|
269
|
+
var _item_props_defaultRows, _fill_map;
|
|
270
|
+
dataViewState[item.id] = (_fill_map = new Array((_item_props_defaultRows = item.props.defaultRows) !== null && _item_props_defaultRows !== void 0 ? _item_props_defaultRows : 1).fill(0).map(function() {
|
|
270
271
|
return _objectSpread({
|
|
271
|
-
uid:
|
|
272
|
+
uid: "new:" + buildUUID("uid")
|
|
272
273
|
}, JSONCopy(emptyTemplate));
|
|
273
|
-
})) !== null &&
|
|
274
|
+
})) !== null && _fill_map !== void 0 ? _fill_map : [];
|
|
274
275
|
emptyDataViewState[item.id] = emptyTemplate;
|
|
275
276
|
}
|
|
276
277
|
}
|
|
277
278
|
function buildDataBindMapping(data, dataViewId, // @ts-ignore
|
|
278
|
-
|
|
279
|
+
item) {
|
|
279
280
|
// if (item instanceof RuntimeFormControl) {
|
|
280
|
-
if (
|
|
281
|
-
var
|
|
281
|
+
if (item.controlType === CONTROL_BASE_TYPE.FORM) {
|
|
282
|
+
var _item_props, _item_props_dataBind;
|
|
282
283
|
// if (item.props.dataBind instanceof ObjectDataBind) {
|
|
283
|
-
if (!isDataBind(
|
|
284
|
+
if (!isDataBind(item.props.dataBind)) {
|
|
284
285
|
// 特殊的dataBind,比如:金额是currency+amount两个key组成的,日期区间,继承自ObjectDataBind的需要通过Object.keys拿到多个databind
|
|
285
|
-
Object.keys(
|
|
286
|
-
var dataBind =
|
|
286
|
+
Object.keys(item.props.dataBind).map(function(key) {
|
|
287
|
+
var dataBind = item.props.dataBind;
|
|
287
288
|
var dataCode = dataBind[key].dataCode;
|
|
288
289
|
if (dataCode !== undefined) {
|
|
289
290
|
if (data[dataCode] === undefined) {
|
|
290
291
|
data[dataCode] = {
|
|
291
|
-
controlId:
|
|
292
|
+
controlId: item.id,
|
|
292
293
|
fields: [],
|
|
293
294
|
dataViewId: dataViewId
|
|
294
295
|
};
|
|
295
296
|
}
|
|
296
297
|
data[dataCode].fields.push({
|
|
297
298
|
fieldCode: dataBind[key].fieldCode,
|
|
298
|
-
controlId:
|
|
299
|
+
controlId: item.id,
|
|
299
300
|
dataBind: dataBind,
|
|
300
301
|
dataViewId: [
|
|
301
302
|
dataViewId
|
|
@@ -303,38 +304,38 @@ item1) {
|
|
|
303
304
|
});
|
|
304
305
|
}
|
|
305
306
|
});
|
|
306
|
-
} else if (((
|
|
307
|
+
} else if (((_item_props = item.props) === null || _item_props === void 0 ? void 0 : (_item_props_dataBind = _item_props.dataBind) === null || _item_props_dataBind === void 0 ? void 0 : _item_props_dataBind.dataCode) === undefined) {
|
|
307
308
|
//qiyu 2023-2-27 为空跳过。form自定义组件加载失败时,hack的组件props为空。
|
|
308
309
|
} else {
|
|
309
|
-
if (data[
|
|
310
|
-
data[
|
|
310
|
+
if (data[item.props.dataBind.dataCode] === undefined) {
|
|
311
|
+
data[item.props.dataBind.dataCode] = {
|
|
311
312
|
controlId: dataViewId,
|
|
312
313
|
fields: [],
|
|
313
314
|
dataViewId: dataViewId
|
|
314
315
|
};
|
|
315
316
|
}
|
|
316
|
-
data[
|
|
317
|
-
fieldCode:
|
|
318
|
-
controlId:
|
|
319
|
-
dataBind:
|
|
317
|
+
data[item.props.dataBind.dataCode].fields.push({
|
|
318
|
+
fieldCode: item.props.dataBind.fieldCode,
|
|
319
|
+
controlId: item.id,
|
|
320
|
+
dataBind: item.props.dataBind,
|
|
320
321
|
dataViewId: [
|
|
321
322
|
dataViewId
|
|
322
323
|
]
|
|
323
324
|
});
|
|
324
325
|
}
|
|
325
326
|
} else {
|
|
326
|
-
if (
|
|
327
|
+
if (item.props.datasourceBind.dataCode === "") {
|
|
327
328
|
//敏捷依赖后端生成dataCode,预览的时候没有
|
|
328
|
-
warn("datasourceBind.dataCode is empty! maybe in preview mode, control:".concat(
|
|
329
|
+
warn("datasourceBind.dataCode is empty! maybe in preview mode, control:".concat(item.id, " type:").concat(item.type));
|
|
329
330
|
return;
|
|
330
331
|
}
|
|
331
|
-
data[
|
|
332
|
-
controlId:
|
|
332
|
+
data[item.props.datasourceBind.dataCode] = {
|
|
333
|
+
controlId: item.id,
|
|
333
334
|
fields: [],
|
|
334
335
|
dataViewId: dataViewId
|
|
335
336
|
};
|
|
336
|
-
var subtableId =
|
|
337
|
-
loopFormSchema(
|
|
337
|
+
var subtableId = item.id;
|
|
338
|
+
loopFormSchema(item.props.headers, function(item) {
|
|
338
339
|
// if (item.props.dataBind instanceof ObjectDataBind) {
|
|
339
340
|
if (!isDataBind(item.props.dataBind)) {
|
|
340
341
|
Object.keys(item.props.dataBind).map(function(key) {
|
|
@@ -377,16 +378,16 @@ item) {
|
|
|
377
378
|
data[item.id] = {
|
|
378
379
|
dataBind: new DataBind({
|
|
379
380
|
dataCode: item.props.datasourceBind.dataCode,
|
|
380
|
-
fieldCode:
|
|
381
|
+
fieldCode: ""
|
|
381
382
|
}),
|
|
382
383
|
dataView: dataViewId,
|
|
383
384
|
children: {},
|
|
384
385
|
options: []
|
|
385
386
|
};
|
|
386
387
|
loopFormSchema(item.props.headers, function(formControl) {
|
|
387
|
-
var
|
|
388
|
-
var
|
|
389
|
-
Object.assign((
|
|
388
|
+
var _data_item_id;
|
|
389
|
+
var _data_item_id_children;
|
|
390
|
+
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 : {}, _defineProperty({}, formControl.id, {
|
|
390
391
|
dataBind: formControl.props.dataBind
|
|
391
392
|
}));
|
|
392
393
|
});
|