@byteluck-fe/model-driven-driven 4.69.0-lx0 → 4.69.0-lx2
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/README.md +13 -13
- package/dist/esm/Builder.js +31 -46
- package/dist/esm/Designer.js +14 -9
- package/dist/esm/Driven.js +27 -28
- package/dist/esm/Store.js +40 -40
- package/dist/esm/constants.js +6 -7
- package/dist/esm/designerUtils.js +3 -8
- package/dist/esm/utils.js +99 -32
- package/dist/index.umd.js +3 -3
- package/dist/types/Builder.d.ts +8 -9
- package/dist/types/Designer.d.ts +36 -36
- package/dist/types/Driven.d.ts +112 -114
- package/dist/types/EventLogic.d.ts +2 -2
- package/dist/types/Plugin.d.ts +6 -6
- package/dist/types/Store.d.ts +82 -82
- package/dist/types/constants.d.ts +6 -6
- package/dist/types/designerUtils.d.ts +5 -4
- package/dist/types/index.d.ts +8 -8
- package/dist/types/utils.d.ts +55 -41
- package/package.json +3 -3
package/dist/esm/utils.js
CHANGED
|
@@ -86,7 +86,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
86
86
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
87
87
|
}
|
|
88
88
|
function _ts_generator(thisArg, body) {
|
|
89
|
-
var f, y, t,
|
|
89
|
+
var f, y, t, _ = {
|
|
90
90
|
label: 0,
|
|
91
91
|
sent: function() {
|
|
92
92
|
if (t[0] & 1) throw t[1];
|
|
@@ -94,13 +94,17 @@ function _ts_generator(thisArg, body) {
|
|
|
94
94
|
},
|
|
95
95
|
trys: [],
|
|
96
96
|
ops: []
|
|
97
|
-
};
|
|
98
|
-
return g
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
},
|
|
103
|
-
|
|
97
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
98
|
+
return d(g, "next", {
|
|
99
|
+
value: verb(0)
|
|
100
|
+
}), d(g, "throw", {
|
|
101
|
+
value: verb(1)
|
|
102
|
+
}), d(g, "return", {
|
|
103
|
+
value: verb(2)
|
|
104
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
105
|
+
value: function() {
|
|
106
|
+
return this;
|
|
107
|
+
}
|
|
104
108
|
}), g;
|
|
105
109
|
function verb(n) {
|
|
106
110
|
return function(v) {
|
|
@@ -112,7 +116,7 @@ function _ts_generator(thisArg, body) {
|
|
|
112
116
|
}
|
|
113
117
|
function step(op) {
|
|
114
118
|
if (f) throw new TypeError("Generator is already executing.");
|
|
115
|
-
while(_)try {
|
|
119
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
116
120
|
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
121
|
if (y = 0, t) op = [
|
|
118
122
|
op[0] & 2,
|
|
@@ -181,11 +185,9 @@ function _ts_generator(thisArg, body) {
|
|
|
181
185
|
}
|
|
182
186
|
}
|
|
183
187
|
import { loopFormControl } from './designerUtils';
|
|
184
|
-
import { CONTROL_BASE_TYPE, CONTROL_TYPE,
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
import { objectDataBindControlTypes } from './constants';
|
|
188
|
-
import { getLocaleText } from '@byteluck-fe/locale-message';
|
|
188
|
+
import { CONTROL_BASE_TYPE, CONTROL_TYPE, FieldTypeToColumnType, isArray } from '@byteluck-fe/model-driven-shared';
|
|
189
|
+
import Designer from './Designer';
|
|
190
|
+
import { objectDataBindControlTypes, objectDataBindKeyToFieldType } from './constants';
|
|
189
191
|
export function getMasterFormControls(controls) {
|
|
190
192
|
var formctls = [];
|
|
191
193
|
// @ts-ignore
|
|
@@ -197,9 +199,9 @@ export function getMasterFormControls(controls) {
|
|
|
197
199
|
});
|
|
198
200
|
return formctls;
|
|
199
201
|
}
|
|
200
|
-
/**
|
|
201
|
-
* @description 给modelBindInfoList中填充fieldCode和dataCode
|
|
202
|
-
* @description 我们生成fieldCode的规则是:DataBind的控件,取`field_${id}`,ObjectDataBind的控件,取`field_${id}_${key}`, key指的是ObjectDataBind.keys()
|
|
202
|
+
/**
|
|
203
|
+
* @description 给modelBindInfoList中填充fieldCode和dataCode
|
|
204
|
+
* @description 我们生成fieldCode的规则是:DataBind的控件,取`field_${id}`,ObjectDataBind的控件,取`field_${id}_${key}`, key指的是ObjectDataBind.keys()
|
|
203
205
|
* */ export function fillModelBindInfoListFieldCode(modelBindInfoList) {
|
|
204
206
|
var dataCode = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : '';
|
|
205
207
|
if (!modelBindInfoList || !Array.isArray(modelBindInfoList)) return [];
|
|
@@ -231,6 +233,75 @@ function fieldCodeBeforeAddPrefix(fieldCode) {
|
|
|
231
233
|
}
|
|
232
234
|
return prefix + fieldCode;
|
|
233
235
|
}
|
|
236
|
+
/**
|
|
237
|
+
* @description 通过fieldType获取列表表头的type
|
|
238
|
+
* */ export function getColumnTypeFromFiledType(fieldType) {
|
|
239
|
+
return FieldTypeToColumnType[fieldType];
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* @description 通过modelBindInfoList生成多个columns
|
|
243
|
+
* */ export function getColumnsFromModelBindInfoList(modelBindInfoList) {
|
|
244
|
+
var designer = new Designer();
|
|
245
|
+
var columns = [];
|
|
246
|
+
modelBindInfoList.forEach(function(item) {
|
|
247
|
+
// 控件在明细子表内或者没有dataBind的话 不做生成
|
|
248
|
+
if (item.parentId || !item.dataBind) return;
|
|
249
|
+
// 如果是对象形式的dataBind的话
|
|
250
|
+
if (objectDataBindControlTypes.includes(item.type)) {
|
|
251
|
+
var objectDataBind = item.dataBind;
|
|
252
|
+
var datasourceBind = item.datasourceBind;
|
|
253
|
+
// 对象的每一个key生成一个column
|
|
254
|
+
Object.keys(objectDataBind).forEach(function(key) {
|
|
255
|
+
// 对应的dataBind
|
|
256
|
+
var dataBind = objectDataBind[key];
|
|
257
|
+
// 当前key对应的fieldType
|
|
258
|
+
var fieldType = objectDataBindKeyToFieldType[key].fieldType;
|
|
259
|
+
// 拼接当前列的caption
|
|
260
|
+
var caption = item.caption + '_' + objectDataBindKeyToFieldType[key].caption;
|
|
261
|
+
// 通过fieldType获取列类型
|
|
262
|
+
var controlType = getColumnTypeFromFiledType(fieldType);
|
|
263
|
+
if (!controlType) return;
|
|
264
|
+
var props = {
|
|
265
|
+
caption: caption,
|
|
266
|
+
dataBind: dataBind
|
|
267
|
+
};
|
|
268
|
+
if (key === 'currency') {
|
|
269
|
+
props.optionConfig = 'datasource';
|
|
270
|
+
props.datasourceBind = datasourceBind;
|
|
271
|
+
}
|
|
272
|
+
// @ts-ignore
|
|
273
|
+
var column = designer.createControlInstance(controlType, {
|
|
274
|
+
props: props
|
|
275
|
+
});
|
|
276
|
+
column && columns.push(column);
|
|
277
|
+
});
|
|
278
|
+
} else {
|
|
279
|
+
var controlType = getColumnTypeFromFiledType(item.fieldType);
|
|
280
|
+
if (!controlType) return;
|
|
281
|
+
// @ts-ignore
|
|
282
|
+
var column = designer.createControlInstance(controlType, {
|
|
283
|
+
props: {
|
|
284
|
+
caption: item.caption,
|
|
285
|
+
dataBind: item.dataBind,
|
|
286
|
+
datasourceBind: item.datasourceBind
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
column && columns.push(column);
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
return columns;
|
|
293
|
+
}
|
|
294
|
+
export function getColumnsFromFiledType(fieldTypes) {
|
|
295
|
+
var designer = new Designer();
|
|
296
|
+
var fieldTypesMap = Array.isArray(fieldTypes) ? fieldTypes : [
|
|
297
|
+
fieldTypes
|
|
298
|
+
];
|
|
299
|
+
var result = fieldTypesMap.map(function(fieldType) {
|
|
300
|
+
var columnType = getColumnTypeFromFiledType(fieldType);
|
|
301
|
+
return designer.createControlInstance(columnType);
|
|
302
|
+
});
|
|
303
|
+
return Array.isArray(fieldTypes) ? result : result[0];
|
|
304
|
+
}
|
|
234
305
|
function toSchema(schema) {
|
|
235
306
|
if (Array.isArray(schema)) {
|
|
236
307
|
return schema.map(function(item) {
|
|
@@ -251,10 +322,7 @@ function getModelBindInfoList(controls) {
|
|
|
251
322
|
return controls.toDataBindModel();
|
|
252
323
|
}
|
|
253
324
|
function checkSchema(controls, messages, ignore) {
|
|
254
|
-
return
|
|
255
|
-
}
|
|
256
|
-
function _checkSchema() {
|
|
257
|
-
_checkSchema = _async_to_generator(function(controls, messages, ignore) {
|
|
325
|
+
return _async_to_generator(function() {
|
|
258
326
|
var result;
|
|
259
327
|
return _ts_generator(this, function(_state) {
|
|
260
328
|
switch(_state.label){
|
|
@@ -289,8 +357,7 @@ function _checkSchema() {
|
|
|
289
357
|
];
|
|
290
358
|
}
|
|
291
359
|
});
|
|
292
|
-
});
|
|
293
|
-
return _checkSchema.apply(this, arguments);
|
|
360
|
+
})();
|
|
294
361
|
}
|
|
295
362
|
// 不可以被权限控制的控件
|
|
296
363
|
var PermissionExcludeControlTypes = [
|
|
@@ -324,15 +391,15 @@ var cannotEditControlTypes = [
|
|
|
324
391
|
var LIST_OPERATION_BUTTON_PERMISSIONS_MAPS = {
|
|
325
392
|
check: {
|
|
326
393
|
id: 'listPageCheckBtnId',
|
|
327
|
-
caption:
|
|
394
|
+
caption: '查看'
|
|
328
395
|
},
|
|
329
396
|
edit: {
|
|
330
397
|
id: 'listPageEditBtnId',
|
|
331
|
-
caption:
|
|
398
|
+
caption: '编辑'
|
|
332
399
|
},
|
|
333
400
|
delete: {
|
|
334
401
|
id: 'listPageDeleteBtnId',
|
|
335
|
-
caption:
|
|
402
|
+
caption: '删除'
|
|
336
403
|
}
|
|
337
404
|
};
|
|
338
405
|
// 生成权限字段
|
|
@@ -345,16 +412,16 @@ function generatePermissions(controls, parent) {
|
|
|
345
412
|
}).flat()));
|
|
346
413
|
} else {
|
|
347
414
|
var type = controls.type;
|
|
348
|
-
var _controls_props = controls.props, caption = _controls_props.caption, content = _controls_props.content
|
|
415
|
+
var _controls_props = controls.props, caption = _controls_props.caption, content = _controls_props.content;
|
|
349
416
|
var permissionItem;
|
|
350
417
|
if (!PermissionExcludeControlTypes.includes(type)) {
|
|
351
|
-
var
|
|
418
|
+
var _ref;
|
|
352
419
|
permissionItem = {
|
|
353
420
|
controlId: controls.id,
|
|
354
|
-
caption: caption || content ||
|
|
421
|
+
caption: caption || content || controls.name,
|
|
355
422
|
type: controls.type,
|
|
356
423
|
controlType: controls.controlType,
|
|
357
|
-
parentId: (
|
|
424
|
+
parentId: (_ref = parent === null || parent === void 0 ? void 0 : parent.controlId) !== null && _ref !== void 0 ? _ref : null,
|
|
358
425
|
canEdit: !cannotEditControlTypes.includes(type),
|
|
359
426
|
canRead: true,
|
|
360
427
|
canHide: true,
|
|
@@ -410,14 +477,14 @@ function generatePermissions(controls, parent) {
|
|
|
410
477
|
var _param = _sliced_to_array(param, 2), key = _param[0], _param_ = _param[1], caption = _param_.caption, controlId = _param_.id;
|
|
411
478
|
var operationItem = controls.props[key];
|
|
412
479
|
if (operationItem && operationItem.isShow) {
|
|
413
|
-
var
|
|
480
|
+
var _ref;
|
|
414
481
|
// 只能控制是否显示
|
|
415
482
|
result.push({
|
|
416
483
|
controlId: controlId,
|
|
417
484
|
caption: caption,
|
|
418
485
|
type: controls.type,
|
|
419
486
|
controlType: controls.controlType,
|
|
420
|
-
parentId: (
|
|
487
|
+
parentId: (_ref = parent === null || parent === void 0 ? void 0 : parent.controlId) !== null && _ref !== void 0 ? _ref : null,
|
|
421
488
|
canEdit: false,
|
|
422
489
|
canRead: false,
|
|
423
490
|
canHide: true,
|