@byteluck-fe/model-driven-engine 2.3.11 → 2.3.13
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 +56 -173
- package/dist/esm/common/DataManager.js +25 -134
- package/dist/esm/common/Engine.js +281 -407
- package/dist/esm/common/OkWorker.js +17 -31
- package/dist/esm/common/Plugin.js +2 -2
- package/dist/esm/common/Runtime.js +35 -50
- package/dist/esm/common/Store.js +53 -53
- package/dist/esm/common/checkerValue.js +109 -109
- package/dist/esm/common/index.js +2 -2
- package/dist/esm/common/proxyState.js +58 -58
- package/dist/esm/index.js +3 -3
- package/dist/esm/plugins/CalcPlugin.js +83 -87
- package/dist/esm/plugins/ControlsEventPlugin.js +73 -196
- package/dist/esm/plugins/ES6ModulePlugin.js +21 -37
- package/dist/esm/plugins/LifecycleEventPlugin.js +79 -198
- package/dist/esm/plugins/StylePlugin.js +11 -26
- 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 +4 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function
|
|
1
|
+
function _classCallCheck(instance, Constructor) {
|
|
2
2
|
if (!(instance instanceof Constructor)) {
|
|
3
3
|
throw new TypeError("Cannot call a class as a function");
|
|
4
4
|
}
|
|
@@ -12,38 +12,24 @@ function _defineProperties(target, props) {
|
|
|
12
12
|
Object.defineProperty(target, descriptor.key, descriptor);
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
16
16
|
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
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
|
-
|
|
38
|
-
_define_property(this, "worker", void 0);
|
|
24
|
+
_classCallCheck(this, OkWorker);
|
|
39
25
|
}
|
|
40
|
-
|
|
26
|
+
_createClass(OkWorker, [
|
|
41
27
|
{
|
|
42
28
|
key: "run",
|
|
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
|
});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
function
|
|
1
|
+
function _classCallCheck(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
6
|
var Plugin = function Plugin() {
|
|
7
7
|
"use strict";
|
|
8
|
-
|
|
8
|
+
_classCallCheck(this, Plugin);
|
|
9
9
|
};
|
|
10
10
|
export { Plugin };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
function
|
|
1
|
+
function _assertThisInitialized(self) {
|
|
2
2
|
if (self === void 0) {
|
|
3
3
|
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
4
4
|
}
|
|
5
5
|
return self;
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function _classCallCheck(instance, Constructor) {
|
|
8
8
|
if (!(instance instanceof Constructor)) {
|
|
9
9
|
throw new TypeError("Cannot call a class as a function");
|
|
10
10
|
}
|
|
@@ -18,29 +18,16 @@ function _defineProperties(target, props) {
|
|
|
18
18
|
Object.defineProperty(target, descriptor.key, descriptor);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
22
22
|
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
23
23
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
24
24
|
return Constructor;
|
|
25
25
|
}
|
|
26
|
-
function
|
|
27
|
-
|
|
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
|
-
function _get_prototype_of(o) {
|
|
40
|
-
_get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
26
|
+
function _getPrototypeOf(o) {
|
|
27
|
+
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
41
28
|
return o.__proto__ || Object.getPrototypeOf(o);
|
|
42
29
|
};
|
|
43
|
-
return
|
|
30
|
+
return _getPrototypeOf(o);
|
|
44
31
|
}
|
|
45
32
|
function _inherits(subClass, superClass) {
|
|
46
33
|
if (typeof superClass !== "function" && superClass !== null) {
|
|
@@ -53,26 +40,26 @@ function _inherits(subClass, superClass) {
|
|
|
53
40
|
configurable: true
|
|
54
41
|
}
|
|
55
42
|
});
|
|
56
|
-
if (superClass)
|
|
43
|
+
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
57
44
|
}
|
|
58
|
-
function
|
|
59
|
-
if (call && (
|
|
45
|
+
function _possibleConstructorReturn(self, call) {
|
|
46
|
+
if (call && (_typeof(call) === "object" || typeof call === "function")) {
|
|
60
47
|
return call;
|
|
61
48
|
}
|
|
62
|
-
return
|
|
49
|
+
return _assertThisInitialized(self);
|
|
63
50
|
}
|
|
64
|
-
function
|
|
65
|
-
|
|
51
|
+
function _setPrototypeOf(o, p) {
|
|
52
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
66
53
|
o.__proto__ = p;
|
|
67
54
|
return o;
|
|
68
55
|
};
|
|
69
|
-
return
|
|
56
|
+
return _setPrototypeOf(o, p);
|
|
70
57
|
}
|
|
71
|
-
function
|
|
58
|
+
var _typeof = function(obj) {
|
|
72
59
|
"@swc/helpers - typeof";
|
|
73
60
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
74
|
-
}
|
|
75
|
-
function
|
|
61
|
+
};
|
|
62
|
+
function _isNativeReflectConstruct() {
|
|
76
63
|
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
|
77
64
|
if (Reflect.construct.sham) return false;
|
|
78
65
|
if (typeof Proxy === "function") return true;
|
|
@@ -83,41 +70,39 @@ function _is_native_reflect_construct() {
|
|
|
83
70
|
return false;
|
|
84
71
|
}
|
|
85
72
|
}
|
|
86
|
-
function
|
|
87
|
-
var hasNativeReflectConstruct =
|
|
73
|
+
function _createSuper(Derived) {
|
|
74
|
+
var hasNativeReflectConstruct = _isNativeReflectConstruct();
|
|
88
75
|
return function _createSuperInternal() {
|
|
89
|
-
var Super =
|
|
76
|
+
var Super = _getPrototypeOf(Derived), result;
|
|
90
77
|
if (hasNativeReflectConstruct) {
|
|
91
|
-
var NewTarget =
|
|
78
|
+
var NewTarget = _getPrototypeOf(this).constructor;
|
|
92
79
|
result = Reflect.construct(Super, arguments, NewTarget);
|
|
93
80
|
} else {
|
|
94
81
|
result = Super.apply(this, arguments);
|
|
95
82
|
}
|
|
96
|
-
return
|
|
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,
|
|
105
|
-
var _super =
|
|
91
|
+
_inherits(Runtime, RegisterControls1);
|
|
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
|
-
_define_property(_assert_this_initialized(_this), "_flatInstances", []);
|
|
113
|
-
_define_property(_assert_this_initialized(_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);
|
|
117
102
|
_this.getFlatInstances();
|
|
118
103
|
return _this;
|
|
119
104
|
}
|
|
120
|
-
|
|
105
|
+
_createClass(Runtime, [
|
|
121
106
|
{
|
|
122
107
|
key: "getFlatInstances",
|
|
123
108
|
value: function getFlatInstances() {
|
|
@@ -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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
function
|
|
1
|
+
function _classCallCheck(instance, Constructor) {
|
|
2
2
|
if (!(instance instanceof Constructor)) {
|
|
3
3
|
throw new TypeError("Cannot call a class as a function");
|
|
4
4
|
}
|
|
@@ -12,12 +12,12 @@ function _defineProperties(target, props) {
|
|
|
12
12
|
Object.defineProperty(target, descriptor.key, descriptor);
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
|
-
function
|
|
15
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
16
16
|
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
17
17
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
18
18
|
return Constructor;
|
|
19
19
|
}
|
|
20
|
-
function
|
|
20
|
+
function _defineProperty(obj, key, value) {
|
|
21
21
|
if (key in obj) {
|
|
22
22
|
Object.defineProperty(obj, key, {
|
|
23
23
|
value: value,
|
|
@@ -32,30 +32,25 @@ function _define_property(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
|
-
|
|
47
|
-
|
|
48
|
-
_define_property(this, "state", void 0);
|
|
49
|
-
_define_property(this, "dataBindMapping", void 0 // 主要提供给二开使用
|
|
50
|
-
);
|
|
51
|
-
_define_property(this, "controlIdMapping", void 0);
|
|
52
|
-
var _init = init(props.instance), state = _init.state, emptyState = _init.emptyState, databindMapping = _init.databindMapping, controlidMapping = _init.controlidMapping;
|
|
46
|
+
_classCallCheck(this, Store);
|
|
47
|
+
var ref = init(props.instance), state = ref.state, emptyState = ref.emptyState, databindMapping = ref.databindMapping, controlidMapping = ref.controlidMapping;
|
|
53
48
|
this.emptyState = emptyState;
|
|
54
49
|
this.state = state;
|
|
55
50
|
this.dataBindMapping = databindMapping;
|
|
56
51
|
this.controlIdMapping = controlidMapping;
|
|
57
52
|
}
|
|
58
|
-
|
|
53
|
+
_createClass(Store, [
|
|
59
54
|
{
|
|
60
55
|
/**
|
|
61
56
|
* 使用该方法仅改变数据,不会表单触发事件。明细表可全量赋值也可根据rowIndex进行单独设置
|
|
@@ -63,7 +58,6 @@ var Store = /*#__PURE__*/ function() {
|
|
|
63
58
|
* @param value
|
|
64
59
|
*/ key: "setState",
|
|
65
60
|
value: function setState(controlId, value, rowIndex) {
|
|
66
|
-
var _this = this;
|
|
67
61
|
var controlInfo = this.controlIdMapping[controlId];
|
|
68
62
|
if (controlInfo !== undefined) {
|
|
69
63
|
//qiyu 按照对象赋值,Object.assign会触发多次key的change事件
|
|
@@ -78,14 +72,16 @@ var Store = /*#__PURE__*/ function() {
|
|
|
78
72
|
// }
|
|
79
73
|
} else {
|
|
80
74
|
if (rowIndex !== undefined) {
|
|
75
|
+
var _this = this;
|
|
81
76
|
//TODO 目前只找了一层明细表,没有递归 如果是添加uid
|
|
82
77
|
Object.keys(this.controlIdMapping).map(function(subtableId) {
|
|
83
78
|
var dataView = _this.controlIdMapping[subtableId].dataView;
|
|
84
79
|
var children = _this.controlIdMapping[subtableId].children;
|
|
85
80
|
if (children !== undefined) {
|
|
81
|
+
var _this1 = _this;
|
|
86
82
|
Object.keys(children).map(function(childControlId) {
|
|
87
83
|
if (childControlId === controlId) {
|
|
88
|
-
|
|
84
|
+
_this1.state[dataView][subtableId][rowIndex][controlId] = value;
|
|
89
85
|
}
|
|
90
86
|
});
|
|
91
87
|
}
|
|
@@ -100,7 +96,6 @@ var Store = /*#__PURE__*/ function() {
|
|
|
100
96
|
{
|
|
101
97
|
key: "getState",
|
|
102
98
|
value: function getState(controlId, rowIndex) {
|
|
103
|
-
var _this = this;
|
|
104
99
|
//qiyu 由于header的数据是后补充的,所以从state获取第一层值。
|
|
105
100
|
// const controlInfo = this.controlIdMapping[controlId]
|
|
106
101
|
var detection = this.state[controlId];
|
|
@@ -112,27 +107,31 @@ var Store = /*#__PURE__*/ function() {
|
|
|
112
107
|
return this.state[controlInfo.dataView][controlId];
|
|
113
108
|
} else {
|
|
114
109
|
if (rowIndex !== undefined) {
|
|
110
|
+
var _this = this;
|
|
115
111
|
var state;
|
|
116
112
|
//TODO 目前只找了一层明细表,没有递归
|
|
117
113
|
Object.keys(this.controlIdMapping).map(function(subtableId) {
|
|
118
114
|
var dataViewId = _this.controlIdMapping[subtableId].dataView;
|
|
119
115
|
var children = _this.controlIdMapping[subtableId].children;
|
|
120
116
|
if (children !== undefined) {
|
|
117
|
+
var _this3 = _this;
|
|
121
118
|
Object.keys(children).map(function(childControlId) {
|
|
122
119
|
if (childControlId === controlId) {
|
|
123
|
-
var
|
|
124
|
-
state = (
|
|
120
|
+
var ref;
|
|
121
|
+
state = (ref = _this3.state[dataViewId][subtableId][rowIndex]) === null || ref === void 0 ? void 0 : ref[controlId];
|
|
125
122
|
}
|
|
126
123
|
});
|
|
127
124
|
}
|
|
128
125
|
});
|
|
129
126
|
return state;
|
|
130
127
|
} else {
|
|
128
|
+
var _this2 = this;
|
|
131
129
|
var states = [];
|
|
132
130
|
Object.keys(this.controlIdMapping).map(function(subtableId) {
|
|
133
|
-
var dataViewId =
|
|
134
|
-
var children =
|
|
131
|
+
var dataViewId = _this2.controlIdMapping[subtableId].dataView;
|
|
132
|
+
var children = _this2.controlIdMapping[subtableId].children;
|
|
135
133
|
if (children !== undefined) {
|
|
134
|
+
var _this = _this2;
|
|
136
135
|
Object.keys(children).map(function(childControlId) {
|
|
137
136
|
if (childControlId === controlId) {
|
|
138
137
|
_this.state[dataViewId][subtableId].map(function(item) {
|
|
@@ -151,7 +150,6 @@ var Store = /*#__PURE__*/ function() {
|
|
|
151
150
|
{
|
|
152
151
|
key: "getEmptyState",
|
|
153
152
|
value: function getEmptyState(controlId) {
|
|
154
|
-
var _this = this;
|
|
155
153
|
var detection = this.emptyState[controlId];
|
|
156
154
|
if (detection !== undefined) {
|
|
157
155
|
return this.emptyState[controlId];
|
|
@@ -160,22 +158,24 @@ var Store = /*#__PURE__*/ function() {
|
|
|
160
158
|
if (controlInfo !== undefined) {
|
|
161
159
|
var state = this.emptyState[controlInfo.dataView][controlId];
|
|
162
160
|
//判断找到的是否是明细表的控件
|
|
163
|
-
if (
|
|
161
|
+
if ('children' in controlInfo) {
|
|
164
162
|
Object.assign(state, {
|
|
165
|
-
uid:
|
|
163
|
+
uid: 'new:' + buildUUID('uid')
|
|
166
164
|
});
|
|
167
165
|
}
|
|
168
166
|
return state;
|
|
169
167
|
} else {
|
|
168
|
+
var _this = this;
|
|
170
169
|
var state1;
|
|
171
170
|
//TODO 目前只找了一层明细表,没有递归
|
|
172
171
|
Object.keys(this.controlIdMapping).map(function(subtableId) {
|
|
173
172
|
var dataViewId = _this.controlIdMapping[subtableId].dataView;
|
|
174
173
|
var children = _this.controlIdMapping[subtableId].children;
|
|
175
174
|
if (children !== undefined) {
|
|
175
|
+
var _this4 = _this;
|
|
176
176
|
Object.keys(children).map(function(childControlId) {
|
|
177
177
|
if (childControlId === controlId) {
|
|
178
|
-
state1 =
|
|
178
|
+
state1 = _this4.emptyState[dataViewId][subtableId][controlId];
|
|
179
179
|
}
|
|
180
180
|
});
|
|
181
181
|
}
|
|
@@ -251,34 +251,34 @@ item) {
|
|
|
251
251
|
loopFormSchema(item.props.headers, function(headerItem) {
|
|
252
252
|
emptyTemplate[headerItem.id] = JSONCopy(headerItem.props.defaultValue);
|
|
253
253
|
});
|
|
254
|
-
var
|
|
255
|
-
dataViewState[item.id] = new Array((
|
|
254
|
+
var _defaultRows;
|
|
255
|
+
dataViewState[item.id] = new Array((_defaultRows = item.props.defaultRows) !== null && _defaultRows !== void 0 ? _defaultRows : 1).fill(0).map(function() {
|
|
256
256
|
return JSONCopy(emptyTemplate);
|
|
257
257
|
});
|
|
258
258
|
emptyDataViewState[item.id] = emptyTemplate;
|
|
259
259
|
}
|
|
260
260
|
}
|
|
261
261
|
function buildDataBindMapping(data, dataViewId, // @ts-ignore
|
|
262
|
-
|
|
262
|
+
item1) {
|
|
263
263
|
// if (item instanceof RuntimeFormControl) {
|
|
264
|
-
if (
|
|
265
|
-
var
|
|
266
|
-
if (_instanceof(
|
|
264
|
+
if (item1.controlType === CONTROL_BASE_TYPE.FORM) {
|
|
265
|
+
var ref, ref1;
|
|
266
|
+
if (_instanceof(item1.props.dataBind, ObjectDataBind)) {
|
|
267
267
|
// 特殊的dataBind,比如:金额是currency+amount两个key组成的,日期区间,继承自ObjectDataBind的需要通过Object.keys拿到多个databind
|
|
268
|
-
Object.keys(
|
|
269
|
-
var dataBind =
|
|
268
|
+
Object.keys(item1.props.dataBind).map(function(key) {
|
|
269
|
+
var dataBind = item1.props.dataBind;
|
|
270
270
|
var dataCode = dataBind[key].dataCode;
|
|
271
271
|
if (dataCode !== undefined) {
|
|
272
272
|
if (data[dataCode] === undefined) {
|
|
273
273
|
data[dataCode] = {
|
|
274
|
-
controlId:
|
|
274
|
+
controlId: item1.id,
|
|
275
275
|
fields: [],
|
|
276
276
|
dataViewId: dataViewId
|
|
277
277
|
};
|
|
278
278
|
}
|
|
279
279
|
data[dataCode].fields.push({
|
|
280
280
|
fieldCode: dataBind[key].fieldCode,
|
|
281
|
-
controlId:
|
|
281
|
+
controlId: item1.id,
|
|
282
282
|
dataBind: dataBind,
|
|
283
283
|
dataViewId: [
|
|
284
284
|
dataViewId
|
|
@@ -286,38 +286,38 @@ item) {
|
|
|
286
286
|
});
|
|
287
287
|
}
|
|
288
288
|
});
|
|
289
|
-
} else if (((
|
|
289
|
+
} else if (((ref = item1.props) === null || ref === void 0 ? void 0 : (ref1 = ref.dataBind) === null || ref1 === void 0 ? void 0 : ref1.dataCode) === undefined) {
|
|
290
290
|
//qiyu 2023-2-27 为空跳过。form自定义组件加载失败时,hack的组件props为空。
|
|
291
291
|
} else {
|
|
292
|
-
if (data[
|
|
293
|
-
data[
|
|
292
|
+
if (data[item1.props.dataBind.dataCode] === undefined) {
|
|
293
|
+
data[item1.props.dataBind.dataCode] = {
|
|
294
294
|
controlId: dataViewId,
|
|
295
295
|
fields: [],
|
|
296
296
|
dataViewId: dataViewId
|
|
297
297
|
};
|
|
298
298
|
}
|
|
299
|
-
data[
|
|
300
|
-
fieldCode:
|
|
301
|
-
controlId:
|
|
302
|
-
dataBind:
|
|
299
|
+
data[item1.props.dataBind.dataCode].fields.push({
|
|
300
|
+
fieldCode: item1.props.dataBind.fieldCode,
|
|
301
|
+
controlId: item1.id,
|
|
302
|
+
dataBind: item1.props.dataBind,
|
|
303
303
|
dataViewId: [
|
|
304
304
|
dataViewId
|
|
305
305
|
]
|
|
306
306
|
});
|
|
307
307
|
}
|
|
308
308
|
} else {
|
|
309
|
-
if (
|
|
309
|
+
if (item1.props.datasourceBind.dataCode === '') {
|
|
310
310
|
//敏捷依赖后端生成dataCode,预览的时候没有
|
|
311
|
-
warn("datasourceBind.dataCode is empty! maybe in preview mode, control:".concat(
|
|
311
|
+
warn("datasourceBind.dataCode is empty! maybe in preview mode, control:".concat(item1.id, " type:").concat(item1.type));
|
|
312
312
|
return;
|
|
313
313
|
}
|
|
314
|
-
data[
|
|
315
|
-
controlId:
|
|
314
|
+
data[item1.props.datasourceBind.dataCode] = {
|
|
315
|
+
controlId: item1.id,
|
|
316
316
|
fields: [],
|
|
317
317
|
dataViewId: dataViewId
|
|
318
318
|
};
|
|
319
|
-
var subtableId =
|
|
320
|
-
loopFormSchema(
|
|
319
|
+
var subtableId = item1.id;
|
|
320
|
+
loopFormSchema(item1.props.headers, function(item) {
|
|
321
321
|
if (_instanceof(item.props.dataBind, ObjectDataBind)) {
|
|
322
322
|
Object.keys(item.props.dataBind).map(function(key) {
|
|
323
323
|
var dataBind = item.props.dataBind;
|
|
@@ -359,16 +359,16 @@ item) {
|
|
|
359
359
|
data[item.id] = {
|
|
360
360
|
dataBind: new DataBind({
|
|
361
361
|
dataCode: item.props.datasourceBind.dataCode,
|
|
362
|
-
fieldCode:
|
|
362
|
+
fieldCode: ''
|
|
363
363
|
}),
|
|
364
364
|
dataView: dataViewId,
|
|
365
365
|
children: {},
|
|
366
366
|
options: []
|
|
367
367
|
};
|
|
368
368
|
loopFormSchema(item.props.headers, function(formControl) {
|
|
369
|
-
var
|
|
370
|
-
var
|
|
371
|
-
Object.assign((
|
|
369
|
+
var ref;
|
|
370
|
+
var ref2;
|
|
371
|
+
Object.assign((ref2 = (ref = data[item.id]) === null || ref === void 0 ? void 0 : ref.children) !== null && ref2 !== void 0 ? ref2 : {}, _defineProperty({}, formControl.id, {
|
|
372
372
|
dataBind: formControl.props.dataBind
|
|
373
373
|
}));
|
|
374
374
|
});
|