@byteluck-fe/model-driven-driven 2.7.0-alpha.16 → 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/Builder.js +18 -5
- package/dist/esm/Designer.js +141 -37
- package/dist/esm/Driven.js +80 -64
- package/dist/esm/EventLogic.js +1 -1
- package/dist/esm/Store.js +57 -23
- package/dist/esm/constants.js +8 -8
- package/dist/esm/designerUtils.js +6 -7
- package/dist/esm/index.js +6 -6
- package/dist/esm/utils.js +179 -76
- package/dist/index.umd.js +3 -3
- package/dist/types/Driven.d.ts +2 -2
- package/dist/types/Store.d.ts +1 -1
- package/package.json +6 -6
package/dist/esm/Store.js
CHANGED
|
@@ -28,6 +28,19 @@ function _createClass(Constructor, protoProps, staticProps) {
|
|
|
28
28
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
29
29
|
return Constructor;
|
|
30
30
|
}
|
|
31
|
+
function _defineProperty(obj, key, value) {
|
|
32
|
+
if (key in obj) {
|
|
33
|
+
Object.defineProperty(obj, key, {
|
|
34
|
+
value: value,
|
|
35
|
+
enumerable: true,
|
|
36
|
+
configurable: true,
|
|
37
|
+
writable: true
|
|
38
|
+
});
|
|
39
|
+
} else {
|
|
40
|
+
obj[key] = value;
|
|
41
|
+
}
|
|
42
|
+
return obj;
|
|
43
|
+
}
|
|
31
44
|
function _iterableToArray(iter) {
|
|
32
45
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
33
46
|
}
|
|
@@ -75,36 +88,57 @@ function _unsupportedIterableToArray(o, minLen) {
|
|
|
75
88
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
76
89
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
77
90
|
}
|
|
78
|
-
import { isDataBind } from
|
|
79
|
-
import { hasChildrenControl, hasFooterControl, hasHeaderControl } from
|
|
80
|
-
import { CONTROL_BASE_TYPE, CONTROL_TYPE } from
|
|
91
|
+
import { isDataBind } from "@byteluck-fe/model-driven-core";
|
|
92
|
+
import { hasChildrenControl, hasFooterControl, hasHeaderControl } from "./designerUtils";
|
|
93
|
+
import { CONTROL_BASE_TYPE, CONTROL_TYPE } from "@byteluck-fe/model-driven-shared";
|
|
81
94
|
// 维护当前selected,。。 selectedControlSetting
|
|
82
95
|
export var Store = /*#__PURE__*/ function() {
|
|
83
96
|
"use strict";
|
|
84
97
|
function Store(options) {
|
|
85
98
|
_classCallCheck(this, Store);
|
|
86
99
|
/**
|
|
100
|
+
* 页面控件实例树
|
|
101
|
+
* */ _defineProperty(this, "instance", void 0);
|
|
102
|
+
/**
|
|
103
|
+
* 拍平的控件数组
|
|
104
|
+
* */ _defineProperty(this, "flatInstances", void 0);
|
|
105
|
+
/**
|
|
106
|
+
* 控件id组成的map
|
|
107
|
+
* */ _defineProperty(this, "instanceIdMap", void 0);
|
|
108
|
+
/**
|
|
109
|
+
* dataCode和fieldCode组成的map
|
|
110
|
+
* {
|
|
111
|
+
* [主表dataCode]: {
|
|
112
|
+
* [fieldCode]: 控件
|
|
113
|
+
* },
|
|
114
|
+
* [子表dataCode]: {
|
|
115
|
+
* [fieldCode]: 控件
|
|
116
|
+
* }
|
|
117
|
+
* }
|
|
118
|
+
* */ _defineProperty(this, "dataFieldCodeMap", void 0);
|
|
119
|
+
/**
|
|
87
120
|
* 当前选中的控件
|
|
88
|
-
* */ this
|
|
121
|
+
* */ _defineProperty(this, "selected", null);
|
|
89
122
|
/**
|
|
90
123
|
* 当前选中的数据作用域控件
|
|
91
|
-
* */ this
|
|
92
|
-
this
|
|
124
|
+
* */ _defineProperty(this, "selectedInstanceDataScopeParent", null);
|
|
125
|
+
_defineProperty(this, "selectedDataScopeFlatInstances", []);
|
|
93
126
|
/**
|
|
94
127
|
* 当前选中控件的setting
|
|
95
|
-
* */ this
|
|
96
|
-
this
|
|
128
|
+
* */ _defineProperty(this, "selectedInstanceSetting", []);
|
|
129
|
+
_defineProperty(this, "selectedInstanceSettingItems", []);
|
|
97
130
|
/**
|
|
98
131
|
* 当前选中控件的数据模型
|
|
99
|
-
* */ this
|
|
132
|
+
* */ _defineProperty(this, "selectedFieldItem", null);
|
|
100
133
|
/**
|
|
101
134
|
* 扩展字段,比如appId,dataCode等
|
|
102
|
-
* */ this
|
|
103
|
-
this
|
|
104
|
-
this
|
|
105
|
-
this
|
|
106
|
-
|
|
107
|
-
|
|
135
|
+
* */ _defineProperty(this, "external", {});
|
|
136
|
+
_defineProperty(this, "movingInstance", null);
|
|
137
|
+
_defineProperty(this, "movingInstanceOldParent", null);
|
|
138
|
+
_defineProperty(this, "movingInstanceOldDataScopeParent", null);
|
|
139
|
+
_defineProperty(this, "getParentBeforeInstanceMove", void 0);
|
|
140
|
+
var _options_getParentBeforeInstanceMove;
|
|
141
|
+
this.getParentBeforeInstanceMove = (_options_getParentBeforeInstanceMove = options.getParentBeforeInstanceMove) !== null && _options_getParentBeforeInstanceMove !== void 0 ? _options_getParentBeforeInstanceMove : function(instance) {
|
|
108
142
|
return instance.parent;
|
|
109
143
|
};
|
|
110
144
|
this.instance = options.instance;
|
|
@@ -157,8 +191,8 @@ export var Store = /*#__PURE__*/ function() {
|
|
|
157
191
|
this.selectedInstanceSetting = settings;
|
|
158
192
|
this.selectedInstanceSettingItems = [];
|
|
159
193
|
this.selectedInstanceSetting.forEach(function(group) {
|
|
160
|
-
var
|
|
161
|
-
(
|
|
194
|
+
var _this_selectedInstanceSettingItems;
|
|
195
|
+
(_this_selectedInstanceSettingItems = _this.selectedInstanceSettingItems).push.apply(_this_selectedInstanceSettingItems, _toConsumableArray(_this.getSettingItems(group)));
|
|
162
196
|
});
|
|
163
197
|
}
|
|
164
198
|
},
|
|
@@ -166,7 +200,7 @@ export var Store = /*#__PURE__*/ function() {
|
|
|
166
200
|
key: "getSettingItems",
|
|
167
201
|
value: function getSettingItems(group) {
|
|
168
202
|
// return group instanceof Group
|
|
169
|
-
return group.type ===
|
|
203
|
+
return group.type === "group" ? group.items : group.items.reduce(function(result, curr) {
|
|
170
204
|
var _result;
|
|
171
205
|
(_result = result).push.apply(_result, _toConsumableArray(curr.items));
|
|
172
206
|
return result;
|
|
@@ -201,7 +235,7 @@ export var Store = /*#__PURE__*/ function() {
|
|
|
201
235
|
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
202
236
|
try {
|
|
203
237
|
for(var _iterator = map.entries()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
204
|
-
var
|
|
238
|
+
var _step_value = _slicedToArray(_step.value, 2), key = _step_value[0], value = _step_value[1];
|
|
205
239
|
if (value.id === instance.id) {
|
|
206
240
|
map.delete(key);
|
|
207
241
|
break;
|
|
@@ -279,9 +313,9 @@ export function loop(instances, callback) {
|
|
|
279
313
|
loop(item.props.headers, callback);
|
|
280
314
|
}
|
|
281
315
|
if (hasFooterControl(item)) {
|
|
282
|
-
var
|
|
283
|
-
var
|
|
284
|
-
loop((
|
|
316
|
+
var _item_props;
|
|
317
|
+
var _item_props_footers;
|
|
318
|
+
loop((_item_props_footers = (_item_props = item.props) === null || _item_props === void 0 ? void 0 : _item_props.footers) !== null && _item_props_footers !== void 0 ? _item_props_footers : [], callback);
|
|
285
319
|
}
|
|
286
320
|
});
|
|
287
321
|
}
|
|
@@ -289,7 +323,7 @@ export function isDataScopeInstance(instance) {
|
|
|
289
323
|
return [
|
|
290
324
|
CONTROL_TYPE.SUBTABLE,
|
|
291
325
|
CONTROL_TYPE.DATA_VIEW,
|
|
292
|
-
CONTROL_TYPE.LIST_VIEW
|
|
326
|
+
CONTROL_TYPE.LIST_VIEW
|
|
293
327
|
].includes(instance.type);
|
|
294
328
|
}
|
|
295
329
|
export function findInstanceDataScopeParent(instance) {
|
package/dist/esm/constants.js
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { CONTROL_TYPE, FieldTypes } from
|
|
1
|
+
import { CONTROL_TYPE, FieldTypes } from "@byteluck-fe/model-driven-shared";
|
|
2
2
|
// 使用ObjectDataBind 的控件
|
|
3
3
|
export var objectDataBindControlTypes = [
|
|
4
4
|
CONTROL_TYPE.AMOUNT,
|
|
5
5
|
CONTROL_TYPE.CALC,
|
|
6
|
-
CONTROL_TYPE.DATE_RANGE
|
|
6
|
+
CONTROL_TYPE.DATE_RANGE
|
|
7
7
|
];
|
|
8
8
|
export var objectDataBindKeyToFieldType = {
|
|
9
9
|
amount: {
|
|
10
|
-
caption:
|
|
10
|
+
caption: "金额",
|
|
11
11
|
fieldType: FieldTypes.DECIMAL
|
|
12
12
|
},
|
|
13
13
|
currency: {
|
|
14
|
-
caption:
|
|
14
|
+
caption: "币种",
|
|
15
15
|
fieldType: FieldTypes.VARCHAR
|
|
16
16
|
},
|
|
17
17
|
result: {
|
|
18
|
-
caption:
|
|
18
|
+
caption: "结果",
|
|
19
19
|
fieldType: FieldTypes.DECIMAL
|
|
20
20
|
},
|
|
21
21
|
unit: {
|
|
22
|
-
caption:
|
|
22
|
+
caption: "单位",
|
|
23
23
|
fieldType: FieldTypes.VARCHAR
|
|
24
24
|
},
|
|
25
25
|
min: {
|
|
26
|
-
caption:
|
|
26
|
+
caption: "开始时间",
|
|
27
27
|
fieldType: FieldTypes.TIMESTAMP
|
|
28
28
|
},
|
|
29
29
|
max: {
|
|
30
|
-
caption:
|
|
30
|
+
caption: "结束时间",
|
|
31
31
|
fieldType: FieldTypes.TIMESTAMP
|
|
32
32
|
}
|
|
33
33
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { CONTROL_BASE_TYPE, CONTROL_TYPE, isArray } from
|
|
1
|
+
import { CONTROL_BASE_TYPE, CONTROL_TYPE, isArray } from "@byteluck-fe/model-driven-shared";
|
|
2
2
|
export function hasChildrenControl(instance) {
|
|
3
|
-
return
|
|
3
|
+
return "children" in instance && isArray(instance.children);
|
|
4
4
|
}
|
|
5
5
|
export function hasHeaderControl(instance) {
|
|
6
|
-
return
|
|
6
|
+
return "headers" in instance.props && isArray(instance.props.headers);
|
|
7
7
|
}
|
|
8
8
|
export function hasFooterControl(instance) {
|
|
9
|
-
return
|
|
9
|
+
return "footers" in instance.props && isArray(instance.props.footers);
|
|
10
10
|
}
|
|
11
11
|
export function loopFormControl(control, callback) {
|
|
12
12
|
if (Array.isArray(control)) {
|
|
@@ -17,9 +17,8 @@ export function loopFormControl(control, callback) {
|
|
|
17
17
|
// @ts-ignore
|
|
18
18
|
loopFormControl(item.props.headers, callback);
|
|
19
19
|
} else if (hasChildrenControl(item)) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
loopFormControl((ref = (item)) === null || ref === void 0 ? void 0 : ref.children, callback);
|
|
20
|
+
loopFormControl(// @ts-ignore
|
|
21
|
+
item === null || item === void 0 ? void 0 : item.children, callback);
|
|
23
22
|
// @ts-ignore
|
|
24
23
|
// } else if (item instanceof DesignerFormControl) {
|
|
25
24
|
} else if (item.controlType === CONTROL_BASE_TYPE.FORM) {
|
package/dist/esm/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import Designer from
|
|
1
|
+
import Designer from "./Designer";
|
|
2
2
|
export { Designer };
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
3
|
+
export * from "./utils";
|
|
4
|
+
export * from "./Builder";
|
|
5
|
+
export * from "./designerUtils";
|
|
6
|
+
export * from "./Driven";
|
|
7
|
+
export * from "./Store";
|
package/dist/esm/utils.js
CHANGED
|
@@ -85,11 +85,105 @@ function _unsupportedIterableToArray(o, minLen) {
|
|
|
85
85
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
86
86
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
87
87
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
88
|
+
var __generator = this && this.__generator || function(thisArg, body) {
|
|
89
|
+
var f, y, t, g, _ = {
|
|
90
|
+
label: 0,
|
|
91
|
+
sent: function() {
|
|
92
|
+
if (t[0] & 1) throw t[1];
|
|
93
|
+
return t[1];
|
|
94
|
+
},
|
|
95
|
+
trys: [],
|
|
96
|
+
ops: []
|
|
97
|
+
};
|
|
98
|
+
return g = {
|
|
99
|
+
next: verb(0),
|
|
100
|
+
"throw": verb(1),
|
|
101
|
+
"return": verb(2)
|
|
102
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
103
|
+
return this;
|
|
104
|
+
}), g;
|
|
105
|
+
function verb(n) {
|
|
106
|
+
return function(v) {
|
|
107
|
+
return step([
|
|
108
|
+
n,
|
|
109
|
+
v
|
|
110
|
+
]);
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function step(op) {
|
|
114
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
115
|
+
while(_)try {
|
|
116
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
117
|
+
if (y = 0, t) op = [
|
|
118
|
+
op[0] & 2,
|
|
119
|
+
t.value
|
|
120
|
+
];
|
|
121
|
+
switch(op[0]){
|
|
122
|
+
case 0:
|
|
123
|
+
case 1:
|
|
124
|
+
t = op;
|
|
125
|
+
break;
|
|
126
|
+
case 4:
|
|
127
|
+
_.label++;
|
|
128
|
+
return {
|
|
129
|
+
value: op[1],
|
|
130
|
+
done: false
|
|
131
|
+
};
|
|
132
|
+
case 5:
|
|
133
|
+
_.label++;
|
|
134
|
+
y = op[1];
|
|
135
|
+
op = [
|
|
136
|
+
0
|
|
137
|
+
];
|
|
138
|
+
continue;
|
|
139
|
+
case 7:
|
|
140
|
+
op = _.ops.pop();
|
|
141
|
+
_.trys.pop();
|
|
142
|
+
continue;
|
|
143
|
+
default:
|
|
144
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
145
|
+
_ = 0;
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
149
|
+
_.label = op[1];
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
153
|
+
_.label = t[1];
|
|
154
|
+
t = op;
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
if (t && _.label < t[2]) {
|
|
158
|
+
_.label = t[2];
|
|
159
|
+
_.ops.push(op);
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
if (t[2]) _.ops.pop();
|
|
163
|
+
_.trys.pop();
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
op = body.call(thisArg, _);
|
|
167
|
+
} catch (e) {
|
|
168
|
+
op = [
|
|
169
|
+
6,
|
|
170
|
+
e
|
|
171
|
+
];
|
|
172
|
+
y = 0;
|
|
173
|
+
} finally{
|
|
174
|
+
f = t = 0;
|
|
175
|
+
}
|
|
176
|
+
if (op[0] & 5) throw op[1];
|
|
177
|
+
return {
|
|
178
|
+
value: op[0] ? op[1] : void 0,
|
|
179
|
+
done: true
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
import { loopFormControl } from "./designerUtils";
|
|
184
|
+
import { CONTROL_BASE_TYPE, CONTROL_TYPE, FieldTypeToColumnType, isArray } from "@byteluck-fe/model-driven-shared";
|
|
185
|
+
import Designer from "./Designer";
|
|
186
|
+
import { objectDataBindControlTypes, objectDataBindKeyToFieldType } from "./constants";
|
|
93
187
|
export function getMasterFormControls(controls) {
|
|
94
188
|
var formctls = [];
|
|
95
189
|
// @ts-ignore
|
|
@@ -105,7 +199,7 @@ export function getMasterFormControls(controls) {
|
|
|
105
199
|
* @description 给modelBindInfoList中填充fieldCode和dataCode
|
|
106
200
|
* @description 我们生成fieldCode的规则是:DataBind的控件,取`field_${id}`,ObjectDataBind的控件,取`field_${id}_${key}`, key指的是ObjectDataBind.keys()
|
|
107
201
|
* */ export function fillModelBindInfoListFieldCode(modelBindInfoList) {
|
|
108
|
-
var dataCode = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] :
|
|
202
|
+
var dataCode = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
|
|
109
203
|
if (!modelBindInfoList || !Array.isArray(modelBindInfoList)) return [];
|
|
110
204
|
return modelBindInfoList.map(function(item) {
|
|
111
205
|
if (!item.dataBind) return item;
|
|
@@ -116,7 +210,7 @@ export function getMasterFormControls(controls) {
|
|
|
116
210
|
Object.keys(objectDataBind).forEach(function(key) {
|
|
117
211
|
var dataBind = objectDataBind[key];
|
|
118
212
|
// 如果是ObjectDataBind的话,需要将id拼接当前的key作为元素的fieldCode
|
|
119
|
-
var fieldCode = item.controlId +
|
|
213
|
+
var fieldCode = item.controlId + "_" + key;
|
|
120
214
|
dataBind.fieldCode = fieldCodeBeforeAddPrefix(fieldCode);
|
|
121
215
|
dataBind.dataCode = dataCode;
|
|
122
216
|
});
|
|
@@ -128,7 +222,7 @@ export function getMasterFormControls(controls) {
|
|
|
128
222
|
});
|
|
129
223
|
}
|
|
130
224
|
function fieldCodeBeforeAddPrefix(fieldCode) {
|
|
131
|
-
var prefix =
|
|
225
|
+
var prefix = "field_";
|
|
132
226
|
if (fieldCode.startsWith(prefix)) {
|
|
133
227
|
return fieldCode;
|
|
134
228
|
}
|
|
@@ -158,7 +252,7 @@ function fieldCodeBeforeAddPrefix(fieldCode) {
|
|
|
158
252
|
// 当前key对应的fieldType
|
|
159
253
|
var fieldType = objectDataBindKeyToFieldType[key].fieldType;
|
|
160
254
|
// 拼接当前列的caption
|
|
161
|
-
var caption = item.caption +
|
|
255
|
+
var caption = item.caption + "_" + objectDataBindKeyToFieldType[key].caption;
|
|
162
256
|
// 通过fieldType获取列类型
|
|
163
257
|
var controlType = getColumnTypeFromFiledType(fieldType);
|
|
164
258
|
if (!controlType) return;
|
|
@@ -166,8 +260,8 @@ function fieldCodeBeforeAddPrefix(fieldCode) {
|
|
|
166
260
|
caption: caption,
|
|
167
261
|
dataBind: dataBind
|
|
168
262
|
};
|
|
169
|
-
if (key ===
|
|
170
|
-
props.optionConfig =
|
|
263
|
+
if (key === "currency") {
|
|
264
|
+
props.optionConfig = "datasource";
|
|
171
265
|
props.datasourceBind = datasourceBind;
|
|
172
266
|
}
|
|
173
267
|
// @ts-ignore
|
|
@@ -177,17 +271,17 @@ function fieldCodeBeforeAddPrefix(fieldCode) {
|
|
|
177
271
|
column && columns.push(column);
|
|
178
272
|
});
|
|
179
273
|
} else {
|
|
180
|
-
var
|
|
181
|
-
if (!
|
|
274
|
+
var controlType = getColumnTypeFromFiledType(item.fieldType);
|
|
275
|
+
if (!controlType) return;
|
|
182
276
|
// @ts-ignore
|
|
183
|
-
var
|
|
277
|
+
var column = designer.createControlInstance(controlType, {
|
|
184
278
|
props: {
|
|
185
279
|
caption: item.caption,
|
|
186
280
|
dataBind: item.dataBind,
|
|
187
281
|
datasourceBind: item.datasourceBind
|
|
188
282
|
}
|
|
189
283
|
});
|
|
190
|
-
|
|
284
|
+
column && columns.push(column);
|
|
191
285
|
}
|
|
192
286
|
});
|
|
193
287
|
return columns;
|
|
@@ -226,35 +320,42 @@ function checkSchema(controls, messages, ignore) {
|
|
|
226
320
|
return _checkSchema.apply(this, arguments);
|
|
227
321
|
}
|
|
228
322
|
function _checkSchema() {
|
|
229
|
-
_checkSchema = _asyncToGenerator(
|
|
323
|
+
_checkSchema = _asyncToGenerator(function(controls, messages, ignore) {
|
|
230
324
|
var result;
|
|
231
|
-
return
|
|
232
|
-
|
|
325
|
+
return __generator(this, function(_state) {
|
|
326
|
+
switch(_state.label){
|
|
233
327
|
case 0:
|
|
234
|
-
if (!Array.isArray(controls))
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
328
|
+
if (!Array.isArray(controls)) return [
|
|
329
|
+
3,
|
|
330
|
+
2
|
|
331
|
+
];
|
|
332
|
+
return [
|
|
333
|
+
4,
|
|
334
|
+
Promise.all(controls.map(function(control) {
|
|
335
|
+
return control.validate(messages, ignore);
|
|
336
|
+
}))
|
|
337
|
+
];
|
|
338
|
+
case 1:
|
|
339
|
+
result = _state.sent();
|
|
340
|
+
return [
|
|
341
|
+
2,
|
|
342
|
+
result.every(function(state) {
|
|
343
|
+
return state;
|
|
344
|
+
})
|
|
345
|
+
];
|
|
346
|
+
case 2:
|
|
347
|
+
return [
|
|
348
|
+
4,
|
|
349
|
+
controls.validate(messages, ignore)
|
|
350
|
+
];
|
|
242
351
|
case 3:
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
case 5:
|
|
248
|
-
_ctx.next = 7;
|
|
249
|
-
return controls.validate(messages, ignore);
|
|
250
|
-
case 7:
|
|
251
|
-
return _ctx.abrupt("return", _ctx.sent);
|
|
252
|
-
case 8:
|
|
253
|
-
case "end":
|
|
254
|
-
return _ctx.stop();
|
|
352
|
+
return [
|
|
353
|
+
2,
|
|
354
|
+
_state.sent()
|
|
355
|
+
];
|
|
255
356
|
}
|
|
256
|
-
}
|
|
257
|
-
})
|
|
357
|
+
});
|
|
358
|
+
});
|
|
258
359
|
return _checkSchema.apply(this, arguments);
|
|
259
360
|
}
|
|
260
361
|
// 不可以被权限控制的控件
|
|
@@ -277,7 +378,9 @@ var PermissionExcludeControlTypes = [
|
|
|
277
378
|
CONTROL_TYPE.TAB_PANE,
|
|
278
379
|
CONTROL_TYPE.TAB,
|
|
279
380
|
CONTROL_TYPE.CARD_GROUP,
|
|
280
|
-
CONTROL_TYPE.ACTION_BAR
|
|
381
|
+
CONTROL_TYPE.ACTION_BAR,
|
|
382
|
+
CONTROL_TYPE.GRID_LAYOUT_CONTAINER,
|
|
383
|
+
CONTROL_TYPE.GRID_LAYOUT_WRAP
|
|
281
384
|
];
|
|
282
385
|
// 不可以编辑的控件
|
|
283
386
|
var cannotEditControlTypes = [
|
|
@@ -286,46 +389,46 @@ var cannotEditControlTypes = [
|
|
|
286
389
|
// 列表操作列单独处理三个按钮的权限
|
|
287
390
|
var LIST_OPERATION_BUTTON_PERMISSIONS_MAPS = {
|
|
288
391
|
check: {
|
|
289
|
-
id:
|
|
290
|
-
caption:
|
|
392
|
+
id: "listPageCheckBtnId",
|
|
393
|
+
caption: "查看"
|
|
291
394
|
},
|
|
292
395
|
edit: {
|
|
293
|
-
id:
|
|
294
|
-
caption:
|
|
396
|
+
id: "listPageEditBtnId",
|
|
397
|
+
caption: "编辑"
|
|
295
398
|
},
|
|
296
399
|
delete: {
|
|
297
|
-
id:
|
|
298
|
-
caption:
|
|
400
|
+
id: "listPageDeleteBtnId",
|
|
401
|
+
caption: "删除"
|
|
299
402
|
}
|
|
300
403
|
};
|
|
301
404
|
// 生成权限字段
|
|
302
405
|
function generatePermissions(controls, parent) {
|
|
303
|
-
var
|
|
406
|
+
var result = [];
|
|
304
407
|
if (isArray(controls)) {
|
|
305
408
|
var _result;
|
|
306
|
-
(_result =
|
|
409
|
+
(_result = result).push.apply(_result, _toConsumableArray(controls.map(function(item) {
|
|
307
410
|
return generatePermissions(item, parent);
|
|
308
411
|
}).flat()));
|
|
309
412
|
} else {
|
|
310
413
|
var type = controls.type;
|
|
311
|
-
var
|
|
414
|
+
var _controls_props = controls.props, caption = _controls_props.caption, content = _controls_props.content;
|
|
312
415
|
var permissionItem;
|
|
313
416
|
if (!PermissionExcludeControlTypes.includes(type)) {
|
|
314
|
-
var
|
|
417
|
+
var _parent_controlId;
|
|
315
418
|
permissionItem = {
|
|
316
419
|
controlId: controls.id,
|
|
317
|
-
caption:
|
|
420
|
+
caption: caption || content || controls.name,
|
|
318
421
|
type: controls.type,
|
|
319
422
|
controlType: controls.controlType,
|
|
320
|
-
parentId: (
|
|
423
|
+
parentId: (_parent_controlId = parent === null || parent === void 0 ? void 0 : parent.controlId) !== null && _parent_controlId !== void 0 ? _parent_controlId : null,
|
|
321
424
|
canEdit: !cannotEditControlTypes.includes(type),
|
|
322
425
|
canRead: true,
|
|
323
426
|
canHide: true,
|
|
324
|
-
group:
|
|
427
|
+
group: "element"
|
|
325
428
|
};
|
|
326
429
|
if (parent && parent.type === CONTROL_TYPE.SUBTABLE) {
|
|
327
430
|
// 如果有parent,则利用下划线拼接caption
|
|
328
|
-
permissionItem.caption = parent.caption +
|
|
431
|
+
permissionItem.caption = parent.caption + "_" + permissionItem.caption;
|
|
329
432
|
}
|
|
330
433
|
if (type === CONTROL_TYPE.VUE_FORM_ITEM) {
|
|
331
434
|
permissionItem.caption = controls.props.controlExportName || controls.name;
|
|
@@ -336,59 +439,59 @@ function generatePermissions(controls, parent) {
|
|
|
336
439
|
// ) {
|
|
337
440
|
if (controls.controlType === CONTROL_BASE_TYPE.FORM || controls.controlType === CONTROL_BASE_TYPE.COLUMN) {
|
|
338
441
|
var //@ts-ignore
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
if (((
|
|
342
|
-
permissionItem.group =
|
|
442
|
+
_controls_props1, _controls_props_dataBind, //@ts-ignore
|
|
443
|
+
_controls_props2, _controls_props_dataBind1;
|
|
444
|
+
if (((_controls_props1 = controls.props) === null || _controls_props1 === void 0 ? void 0 : (_controls_props_dataBind = _controls_props1.dataBind) === null || _controls_props_dataBind === void 0 ? void 0 : _controls_props_dataBind.fieldCode) !== undefined && ((_controls_props2 = controls.props) === null || _controls_props2 === void 0 ? void 0 : (_controls_props_dataBind1 = _controls_props2.dataBind) === null || _controls_props_dataBind1 === void 0 ? void 0 : _controls_props_dataBind1.fieldCode) !== "") {
|
|
445
|
+
permissionItem.group = "field";
|
|
343
446
|
}
|
|
344
447
|
}
|
|
345
|
-
|
|
448
|
+
result.push(permissionItem);
|
|
346
449
|
//追加vue容器权限
|
|
347
450
|
if (type === CONTROL_TYPE.VUE_FORM_ITEM) {
|
|
348
|
-
var
|
|
349
|
-
var vueFormItemGroup =
|
|
350
|
-
if (((
|
|
351
|
-
vueFormItemGroup =
|
|
451
|
+
var _controls_props3, _controls_props_dataBind2, _controls_props4, _controls_props_dataBind3;
|
|
452
|
+
var vueFormItemGroup = "element";
|
|
453
|
+
if (((_controls_props3 = controls.props) === null || _controls_props3 === void 0 ? void 0 : (_controls_props_dataBind2 = _controls_props3.dataBind) === null || _controls_props_dataBind2 === void 0 ? void 0 : _controls_props_dataBind2.fieldCode) !== undefined && ((_controls_props4 = controls.props) === null || _controls_props4 === void 0 ? void 0 : (_controls_props_dataBind3 = _controls_props4.dataBind) === null || _controls_props_dataBind3 === void 0 ? void 0 : _controls_props_dataBind3.fieldCode) !== "") {
|
|
454
|
+
vueFormItemGroup = "field";
|
|
352
455
|
}
|
|
353
|
-
var permissions = controls.props[
|
|
456
|
+
var permissions = controls.props["permissions"];
|
|
354
457
|
permissions === null || permissions === void 0 ? void 0 : permissions.map(function(item) {
|
|
355
|
-
var
|
|
458
|
+
var _controls_id;
|
|
356
459
|
permissionItem = {
|
|
357
460
|
controlId: item.key,
|
|
358
461
|
caption: item.caption,
|
|
359
462
|
type: controls.type,
|
|
360
463
|
controlType: controls.controlType,
|
|
361
|
-
parentId: (
|
|
464
|
+
parentId: (_controls_id = controls.id) !== null && _controls_id !== void 0 ? _controls_id : null,
|
|
362
465
|
canEdit: true,
|
|
363
466
|
canRead: true,
|
|
364
467
|
canHide: true,
|
|
365
468
|
group: vueFormItemGroup
|
|
366
469
|
};
|
|
367
|
-
|
|
470
|
+
result.push(permissionItem);
|
|
368
471
|
});
|
|
369
472
|
}
|
|
370
473
|
} else if (type === CONTROL_TYPE.OPERATION_COLUMN) {
|
|
371
474
|
// 列表的操作列单独处理
|
|
372
475
|
Object.entries(LIST_OPERATION_BUTTON_PERMISSIONS_MAPS).reduce(function(result, param) {
|
|
373
|
-
var _param = _slicedToArray(param, 2), key = _param[0],
|
|
476
|
+
var _param = _slicedToArray(param, 2), key = _param[0], _param_ = _param[1], caption = _param_.caption, controlId = _param_.id;
|
|
374
477
|
var operationItem = controls.props[key];
|
|
375
478
|
if (operationItem && operationItem.isShow) {
|
|
376
|
-
var
|
|
479
|
+
var _parent_controlId;
|
|
377
480
|
// 只能控制是否显示
|
|
378
481
|
result.push({
|
|
379
482
|
controlId: controlId,
|
|
380
483
|
caption: caption,
|
|
381
484
|
type: controls.type,
|
|
382
485
|
controlType: controls.controlType,
|
|
383
|
-
parentId: (
|
|
486
|
+
parentId: (_parent_controlId = parent === null || parent === void 0 ? void 0 : parent.controlId) !== null && _parent_controlId !== void 0 ? _parent_controlId : null,
|
|
384
487
|
canEdit: false,
|
|
385
488
|
canRead: false,
|
|
386
489
|
canHide: true,
|
|
387
|
-
group:
|
|
490
|
+
group: "element"
|
|
388
491
|
});
|
|
389
492
|
}
|
|
390
493
|
return result;
|
|
391
|
-
},
|
|
494
|
+
}, result);
|
|
392
495
|
}
|
|
393
496
|
// else if (type === CONTROL_TYPE.CUSTOM_COLUMN) {
|
|
394
497
|
// //追加自定义列上的vue容器权限
|
|
@@ -412,7 +515,7 @@ function generatePermissions(controls, parent) {
|
|
|
412
515
|
// }
|
|
413
516
|
if (controls.children) {
|
|
414
517
|
var _result1;
|
|
415
|
-
(_result1 =
|
|
518
|
+
(_result1 = result).push.apply(_result1, _toConsumableArray(controls.children.map(function(item) {
|
|
416
519
|
return generatePermissions(item, parent);
|
|
417
520
|
}).flat()));
|
|
418
521
|
}
|
|
@@ -420,11 +523,11 @@ function generatePermissions(controls, parent) {
|
|
|
420
523
|
if (controls.controlType === CONTROL_BASE_TYPE.LIST) {
|
|
421
524
|
var // 明细子表和列表的需要给parentId
|
|
422
525
|
_result2;
|
|
423
|
-
(_result2 =
|
|
526
|
+
(_result2 = result).push.apply(_result2, _toConsumableArray(controls.props.headers.map(function(item) {
|
|
424
527
|
return generatePermissions(item, permissionItem);
|
|
425
528
|
}).flat()));
|
|
426
529
|
}
|
|
427
530
|
}
|
|
428
|
-
return
|
|
531
|
+
return result;
|
|
429
532
|
}
|
|
430
533
|
export { toSchema, getModelBindInfoList, checkSchema, generatePermissions };
|