@byteluck-fe/model-driven-driven 2.7.0-alpha.1 → 2.7.0-alpha.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/Builder.js +113 -86
- package/dist/esm/Designer.js +128 -177
- package/dist/esm/Driven.js +569 -406
- package/dist/esm/EventLogic.js +1 -1
- package/dist/esm/Store.js +118 -96
- package/dist/esm/constants.js +8 -8
- package/dist/esm/designerUtils.js +9 -5
- package/dist/esm/index.js +6 -6
- package/dist/esm/utils.js +75 -176
- package/dist/index.umd.js +3 -3
- package/dist/types/Driven.d.ts +6 -6
- package/dist/types/Store.d.ts +1 -1
- package/dist/types/designerUtils.d.ts +1 -0
- package/package.json +6 -6
package/dist/esm/utils.js
CHANGED
|
@@ -85,105 +85,11 @@ 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
|
-
|
|
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";
|
|
88
|
+
import regeneratorRuntime from "regenerator-runtime";
|
|
89
|
+
import { loopFormControl } from './designerUtils';
|
|
90
|
+
import { CONTROL_BASE_TYPE, CONTROL_TYPE, FieldTypeToColumnType, isArray } from '@byteluck-fe/model-driven-shared';
|
|
91
|
+
import Designer from './Designer';
|
|
92
|
+
import { objectDataBindControlTypes, objectDataBindKeyToFieldType } from './constants';
|
|
187
93
|
export function getMasterFormControls(controls) {
|
|
188
94
|
var formctls = [];
|
|
189
95
|
// @ts-ignore
|
|
@@ -199,7 +105,7 @@ export function getMasterFormControls(controls) {
|
|
|
199
105
|
* @description 给modelBindInfoList中填充fieldCode和dataCode
|
|
200
106
|
* @description 我们生成fieldCode的规则是:DataBind的控件,取`field_${id}`,ObjectDataBind的控件,取`field_${id}_${key}`, key指的是ObjectDataBind.keys()
|
|
201
107
|
* */ export function fillModelBindInfoListFieldCode(modelBindInfoList) {
|
|
202
|
-
var dataCode = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] :
|
|
108
|
+
var dataCode = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : '';
|
|
203
109
|
if (!modelBindInfoList || !Array.isArray(modelBindInfoList)) return [];
|
|
204
110
|
return modelBindInfoList.map(function(item) {
|
|
205
111
|
if (!item.dataBind) return item;
|
|
@@ -210,7 +116,7 @@ export function getMasterFormControls(controls) {
|
|
|
210
116
|
Object.keys(objectDataBind).forEach(function(key) {
|
|
211
117
|
var dataBind = objectDataBind[key];
|
|
212
118
|
// 如果是ObjectDataBind的话,需要将id拼接当前的key作为元素的fieldCode
|
|
213
|
-
var fieldCode = item.controlId +
|
|
119
|
+
var fieldCode = item.controlId + '_' + key;
|
|
214
120
|
dataBind.fieldCode = fieldCodeBeforeAddPrefix(fieldCode);
|
|
215
121
|
dataBind.dataCode = dataCode;
|
|
216
122
|
});
|
|
@@ -222,7 +128,7 @@ export function getMasterFormControls(controls) {
|
|
|
222
128
|
});
|
|
223
129
|
}
|
|
224
130
|
function fieldCodeBeforeAddPrefix(fieldCode) {
|
|
225
|
-
var prefix =
|
|
131
|
+
var prefix = 'field_';
|
|
226
132
|
if (fieldCode.startsWith(prefix)) {
|
|
227
133
|
return fieldCode;
|
|
228
134
|
}
|
|
@@ -252,7 +158,7 @@ function fieldCodeBeforeAddPrefix(fieldCode) {
|
|
|
252
158
|
// 当前key对应的fieldType
|
|
253
159
|
var fieldType = objectDataBindKeyToFieldType[key].fieldType;
|
|
254
160
|
// 拼接当前列的caption
|
|
255
|
-
var caption = item.caption +
|
|
161
|
+
var caption = item.caption + '_' + objectDataBindKeyToFieldType[key].caption;
|
|
256
162
|
// 通过fieldType获取列类型
|
|
257
163
|
var controlType = getColumnTypeFromFiledType(fieldType);
|
|
258
164
|
if (!controlType) return;
|
|
@@ -260,8 +166,8 @@ function fieldCodeBeforeAddPrefix(fieldCode) {
|
|
|
260
166
|
caption: caption,
|
|
261
167
|
dataBind: dataBind
|
|
262
168
|
};
|
|
263
|
-
if (key ===
|
|
264
|
-
props.optionConfig =
|
|
169
|
+
if (key === 'currency') {
|
|
170
|
+
props.optionConfig = 'datasource';
|
|
265
171
|
props.datasourceBind = datasourceBind;
|
|
266
172
|
}
|
|
267
173
|
// @ts-ignore
|
|
@@ -271,17 +177,17 @@ function fieldCodeBeforeAddPrefix(fieldCode) {
|
|
|
271
177
|
column && columns.push(column);
|
|
272
178
|
});
|
|
273
179
|
} else {
|
|
274
|
-
var
|
|
275
|
-
if (!
|
|
180
|
+
var controlType1 = getColumnTypeFromFiledType(item.fieldType);
|
|
181
|
+
if (!controlType1) return;
|
|
276
182
|
// @ts-ignore
|
|
277
|
-
var
|
|
183
|
+
var column1 = designer.createControlInstance(controlType1, {
|
|
278
184
|
props: {
|
|
279
185
|
caption: item.caption,
|
|
280
186
|
dataBind: item.dataBind,
|
|
281
187
|
datasourceBind: item.datasourceBind
|
|
282
188
|
}
|
|
283
189
|
});
|
|
284
|
-
|
|
190
|
+
column1 && columns.push(column1);
|
|
285
191
|
}
|
|
286
192
|
});
|
|
287
193
|
return columns;
|
|
@@ -320,42 +226,35 @@ function checkSchema(controls, messages, ignore) {
|
|
|
320
226
|
return _checkSchema.apply(this, arguments);
|
|
321
227
|
}
|
|
322
228
|
function _checkSchema() {
|
|
323
|
-
_checkSchema = _asyncToGenerator(function(controls, messages, ignore) {
|
|
229
|
+
_checkSchema = _asyncToGenerator(regeneratorRuntime.mark(function _callee(controls, messages, ignore) {
|
|
324
230
|
var result;
|
|
325
|
-
return
|
|
326
|
-
switch(
|
|
231
|
+
return regeneratorRuntime.wrap(function _callee$(_ctx) {
|
|
232
|
+
while(1)switch(_ctx.prev = _ctx.next){
|
|
327
233
|
case 0:
|
|
328
|
-
if (!Array.isArray(controls))
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
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
|
-
];
|
|
234
|
+
if (!Array.isArray(controls)) {
|
|
235
|
+
_ctx.next = 5;
|
|
236
|
+
break;
|
|
237
|
+
}
|
|
238
|
+
_ctx.next = 3;
|
|
239
|
+
return Promise.all(controls.map(function(control) {
|
|
240
|
+
return control.validate(messages, ignore);
|
|
241
|
+
}));
|
|
351
242
|
case 3:
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
243
|
+
result = _ctx.sent;
|
|
244
|
+
return _ctx.abrupt("return", result.every(function(state) {
|
|
245
|
+
return state;
|
|
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();
|
|
356
255
|
}
|
|
357
|
-
});
|
|
358
|
-
});
|
|
256
|
+
}, _callee);
|
|
257
|
+
}));
|
|
359
258
|
return _checkSchema.apply(this, arguments);
|
|
360
259
|
}
|
|
361
260
|
// 不可以被权限控制的控件
|
|
@@ -387,46 +286,46 @@ var cannotEditControlTypes = [
|
|
|
387
286
|
// 列表操作列单独处理三个按钮的权限
|
|
388
287
|
var LIST_OPERATION_BUTTON_PERMISSIONS_MAPS = {
|
|
389
288
|
check: {
|
|
390
|
-
id:
|
|
391
|
-
caption:
|
|
289
|
+
id: 'listPageCheckBtnId',
|
|
290
|
+
caption: '查看'
|
|
392
291
|
},
|
|
393
292
|
edit: {
|
|
394
|
-
id:
|
|
395
|
-
caption:
|
|
293
|
+
id: 'listPageEditBtnId',
|
|
294
|
+
caption: '编辑'
|
|
396
295
|
},
|
|
397
296
|
delete: {
|
|
398
|
-
id:
|
|
399
|
-
caption:
|
|
297
|
+
id: 'listPageDeleteBtnId',
|
|
298
|
+
caption: '删除'
|
|
400
299
|
}
|
|
401
300
|
};
|
|
402
301
|
// 生成权限字段
|
|
403
302
|
function generatePermissions(controls, parent) {
|
|
404
|
-
var
|
|
303
|
+
var result1 = [];
|
|
405
304
|
if (isArray(controls)) {
|
|
406
305
|
var _result;
|
|
407
|
-
(_result =
|
|
306
|
+
(_result = result1).push.apply(_result, _toConsumableArray(controls.map(function(item) {
|
|
408
307
|
return generatePermissions(item, parent);
|
|
409
308
|
}).flat()));
|
|
410
309
|
} else {
|
|
411
310
|
var type = controls.type;
|
|
412
|
-
var
|
|
311
|
+
var _props = controls.props, caption1 = _props.caption, content = _props.content;
|
|
413
312
|
var permissionItem;
|
|
414
313
|
if (!PermissionExcludeControlTypes.includes(type)) {
|
|
415
|
-
var
|
|
314
|
+
var ref;
|
|
416
315
|
permissionItem = {
|
|
417
316
|
controlId: controls.id,
|
|
418
|
-
caption:
|
|
317
|
+
caption: caption1 || content || controls.name,
|
|
419
318
|
type: controls.type,
|
|
420
319
|
controlType: controls.controlType,
|
|
421
|
-
parentId: (
|
|
320
|
+
parentId: (ref = parent === null || parent === void 0 ? void 0 : parent.controlId) !== null && ref !== void 0 ? ref : null,
|
|
422
321
|
canEdit: !cannotEditControlTypes.includes(type),
|
|
423
322
|
canRead: true,
|
|
424
323
|
canHide: true,
|
|
425
|
-
group:
|
|
324
|
+
group: 'element'
|
|
426
325
|
};
|
|
427
326
|
if (parent && parent.type === CONTROL_TYPE.SUBTABLE) {
|
|
428
327
|
// 如果有parent,则利用下划线拼接caption
|
|
429
|
-
permissionItem.caption = parent.caption +
|
|
328
|
+
permissionItem.caption = parent.caption + '_' + permissionItem.caption;
|
|
430
329
|
}
|
|
431
330
|
if (type === CONTROL_TYPE.VUE_FORM_ITEM) {
|
|
432
331
|
permissionItem.caption = controls.props.controlExportName || controls.name;
|
|
@@ -437,59 +336,59 @@ function generatePermissions(controls, parent) {
|
|
|
437
336
|
// ) {
|
|
438
337
|
if (controls.controlType === CONTROL_BASE_TYPE.FORM || controls.controlType === CONTROL_BASE_TYPE.COLUMN) {
|
|
439
338
|
var //@ts-ignore
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
if (((
|
|
443
|
-
permissionItem.group =
|
|
339
|
+
ref1, ref2, //@ts-ignore
|
|
340
|
+
ref3, ref4;
|
|
341
|
+
if (((ref1 = controls.props) === null || ref1 === void 0 ? void 0 : (ref2 = ref1.dataBind) === null || ref2 === void 0 ? void 0 : ref2.fieldCode) !== undefined && ((ref3 = controls.props) === null || ref3 === void 0 ? void 0 : (ref4 = ref3.dataBind) === null || ref4 === void 0 ? void 0 : ref4.fieldCode) !== '') {
|
|
342
|
+
permissionItem.group = 'field';
|
|
444
343
|
}
|
|
445
344
|
}
|
|
446
|
-
|
|
345
|
+
result1.push(permissionItem);
|
|
447
346
|
//追加vue容器权限
|
|
448
347
|
if (type === CONTROL_TYPE.VUE_FORM_ITEM) {
|
|
449
|
-
var
|
|
450
|
-
var vueFormItemGroup =
|
|
451
|
-
if (((
|
|
452
|
-
vueFormItemGroup =
|
|
348
|
+
var ref5, ref6, ref7, ref8;
|
|
349
|
+
var vueFormItemGroup = 'element';
|
|
350
|
+
if (((ref5 = controls.props) === null || ref5 === void 0 ? void 0 : (ref6 = ref5.dataBind) === null || ref6 === void 0 ? void 0 : ref6.fieldCode) !== undefined && ((ref7 = controls.props) === null || ref7 === void 0 ? void 0 : (ref8 = ref7.dataBind) === null || ref8 === void 0 ? void 0 : ref8.fieldCode) !== '') {
|
|
351
|
+
vueFormItemGroup = 'field';
|
|
453
352
|
}
|
|
454
|
-
var permissions = controls.props[
|
|
353
|
+
var permissions = controls.props['permissions'];
|
|
455
354
|
permissions === null || permissions === void 0 ? void 0 : permissions.map(function(item) {
|
|
456
|
-
var
|
|
355
|
+
var _id;
|
|
457
356
|
permissionItem = {
|
|
458
357
|
controlId: item.key,
|
|
459
358
|
caption: item.caption,
|
|
460
359
|
type: controls.type,
|
|
461
360
|
controlType: controls.controlType,
|
|
462
|
-
parentId: (
|
|
361
|
+
parentId: (_id = controls.id) !== null && _id !== void 0 ? _id : null,
|
|
463
362
|
canEdit: true,
|
|
464
363
|
canRead: true,
|
|
465
364
|
canHide: true,
|
|
466
365
|
group: vueFormItemGroup
|
|
467
366
|
};
|
|
468
|
-
|
|
367
|
+
result1.push(permissionItem);
|
|
469
368
|
});
|
|
470
369
|
}
|
|
471
370
|
} else if (type === CONTROL_TYPE.OPERATION_COLUMN) {
|
|
472
371
|
// 列表的操作列单独处理
|
|
473
372
|
Object.entries(LIST_OPERATION_BUTTON_PERMISSIONS_MAPS).reduce(function(result, param) {
|
|
474
|
-
var _param = _slicedToArray(param, 2), key = _param[0],
|
|
373
|
+
var _param = _slicedToArray(param, 2), key = _param[0], ref = _param[1], caption = ref.caption, controlId = ref.id;
|
|
475
374
|
var operationItem = controls.props[key];
|
|
476
375
|
if (operationItem && operationItem.isShow) {
|
|
477
|
-
var
|
|
376
|
+
var ref9;
|
|
478
377
|
// 只能控制是否显示
|
|
479
378
|
result.push({
|
|
480
379
|
controlId: controlId,
|
|
481
380
|
caption: caption,
|
|
482
381
|
type: controls.type,
|
|
483
382
|
controlType: controls.controlType,
|
|
484
|
-
parentId: (
|
|
383
|
+
parentId: (ref9 = parent === null || parent === void 0 ? void 0 : parent.controlId) !== null && ref9 !== void 0 ? ref9 : null,
|
|
485
384
|
canEdit: false,
|
|
486
385
|
canRead: false,
|
|
487
386
|
canHide: true,
|
|
488
|
-
group:
|
|
387
|
+
group: 'element'
|
|
489
388
|
});
|
|
490
389
|
}
|
|
491
390
|
return result;
|
|
492
|
-
},
|
|
391
|
+
}, result1);
|
|
493
392
|
}
|
|
494
393
|
// else if (type === CONTROL_TYPE.CUSTOM_COLUMN) {
|
|
495
394
|
// //追加自定义列上的vue容器权限
|
|
@@ -513,7 +412,7 @@ function generatePermissions(controls, parent) {
|
|
|
513
412
|
// }
|
|
514
413
|
if (controls.children) {
|
|
515
414
|
var _result1;
|
|
516
|
-
(_result1 =
|
|
415
|
+
(_result1 = result1).push.apply(_result1, _toConsumableArray(controls.children.map(function(item) {
|
|
517
416
|
return generatePermissions(item, parent);
|
|
518
417
|
}).flat()));
|
|
519
418
|
}
|
|
@@ -521,11 +420,11 @@ function generatePermissions(controls, parent) {
|
|
|
521
420
|
if (controls.controlType === CONTROL_BASE_TYPE.LIST) {
|
|
522
421
|
var // 明细子表和列表的需要给parentId
|
|
523
422
|
_result2;
|
|
524
|
-
(_result2 =
|
|
423
|
+
(_result2 = result1).push.apply(_result2, _toConsumableArray(controls.props.headers.map(function(item) {
|
|
525
424
|
return generatePermissions(item, permissionItem);
|
|
526
425
|
}).flat()));
|
|
527
426
|
}
|
|
528
427
|
}
|
|
529
|
-
return
|
|
428
|
+
return result1;
|
|
530
429
|
}
|
|
531
430
|
export { toSchema, getModelBindInfoList, checkSchema, generatePermissions };
|