@byteluck-fe/model-driven-driven 2.7.0-alpha.9 → 2.7.0-beta

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/utils.js CHANGED
@@ -1,13 +1,13 @@
1
- function _arrayLikeToArray(arr, len) {
1
+ function _array_like_to_array(arr, len) {
2
2
  if (len == null || len > arr.length) len = arr.length;
3
3
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
4
  return arr2;
5
5
  }
6
- function _arrayWithHoles(arr) {
6
+ function _array_with_holes(arr) {
7
7
  if (Array.isArray(arr)) return arr;
8
8
  }
9
- function _arrayWithoutHoles(arr) {
10
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
9
+ function _array_without_holes(arr) {
10
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
11
11
  }
12
12
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
13
13
  try {
@@ -23,7 +23,7 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
23
23
  Promise.resolve(value).then(_next, _throw);
24
24
  }
25
25
  }
26
- function _asyncToGenerator(fn) {
26
+ function _async_to_generator(fn) {
27
27
  return function() {
28
28
  var self = this, args = arguments;
29
29
  return new Promise(function(resolve, reject) {
@@ -38,10 +38,10 @@ function _asyncToGenerator(fn) {
38
38
  });
39
39
  };
40
40
  }
41
- function _iterableToArray(iter) {
41
+ function _iterable_to_array(iter) {
42
42
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
43
43
  }
44
- function _iterableToArrayLimit(arr, i) {
44
+ function _iterable_to_array_limit(arr, i) {
45
45
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
46
46
  if (_i == null) return;
47
47
  var _arr = [];
@@ -65,31 +65,125 @@ function _iterableToArrayLimit(arr, i) {
65
65
  }
66
66
  return _arr;
67
67
  }
68
- function _nonIterableRest() {
68
+ function _non_iterable_rest() {
69
69
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
70
70
  }
71
- function _nonIterableSpread() {
71
+ function _non_iterable_spread() {
72
72
  throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
73
73
  }
74
- function _slicedToArray(arr, i) {
75
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
74
+ function _sliced_to_array(arr, i) {
75
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
76
76
  }
77
- function _toConsumableArray(arr) {
78
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
77
+ function _to_consumable_array(arr) {
78
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
79
79
  }
80
- function _unsupportedIterableToArray(o, minLen) {
80
+ function _unsupported_iterable_to_array(o, minLen) {
81
81
  if (!o) return;
82
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
82
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
83
83
  var n = Object.prototype.toString.call(o).slice(8, -1);
84
84
  if (n === "Object" && o.constructor) n = o.constructor.name;
85
85
  if (n === "Map" || n === "Set") return Array.from(n);
86
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
86
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
87
87
  }
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';
88
+ function _ts_generator(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 + '_' + key;
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 = 'field_';
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 + '_' + objectDataBindKeyToFieldType[key].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 === 'currency') {
170
- props.optionConfig = 'datasource';
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 controlType1 = getColumnTypeFromFiledType(item.fieldType);
181
- if (!controlType1) return;
274
+ var controlType = getColumnTypeFromFiledType(item.fieldType);
275
+ if (!controlType) return;
182
276
  // @ts-ignore
183
- var column1 = designer.createControlInstance(controlType1, {
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
- column1 && columns.push(column1);
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(regeneratorRuntime.mark(function _callee(controls, messages, ignore) {
323
+ _checkSchema = _async_to_generator(function(controls, messages, ignore) {
230
324
  var result;
231
- return regeneratorRuntime.wrap(function _callee$(_ctx) {
232
- while(1)switch(_ctx.prev = _ctx.next){
325
+ return _ts_generator(this, function(_state) {
326
+ switch(_state.label){
233
327
  case 0:
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
- }));
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
- 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();
352
+ return [
353
+ 2,
354
+ _state.sent()
355
+ ];
255
356
  }
256
- }, _callee);
257
- }));
357
+ });
358
+ });
258
359
  return _checkSchema.apply(this, arguments);
259
360
  }
260
361
  // 不可以被权限控制的控件
@@ -276,8 +377,7 @@ var PermissionExcludeControlTypes = [
276
377
  // 暂时不能控制权限
277
378
  CONTROL_TYPE.TAB_PANE,
278
379
  CONTROL_TYPE.TAB,
279
- CONTROL_TYPE.CARD_GROUP,
280
- CONTROL_TYPE.ACTION_BAR
380
+ CONTROL_TYPE.CARD_GROUP
281
381
  ];
282
382
  // 不可以编辑的控件
283
383
  var cannotEditControlTypes = [
@@ -286,46 +386,47 @@ var cannotEditControlTypes = [
286
386
  // 列表操作列单独处理三个按钮的权限
287
387
  var LIST_OPERATION_BUTTON_PERMISSIONS_MAPS = {
288
388
  check: {
289
- id: 'listPageCheckBtnId',
290
- caption: '查看'
389
+ id: "listPageCheckBtnId",
390
+ caption: "查看"
291
391
  },
292
392
  edit: {
293
- id: 'listPageEditBtnId',
294
- caption: '编辑'
393
+ id: "listPageEditBtnId",
394
+ caption: "编辑"
295
395
  },
296
396
  delete: {
297
- id: 'listPageDeleteBtnId',
298
- caption: '删除'
397
+ id: "listPageDeleteBtnId",
398
+ caption: "删除"
299
399
  }
300
400
  };
301
401
  // 生成权限字段
302
402
  function generatePermissions(controls, parent) {
303
- var result1 = [];
403
+ var result = [];
304
404
  if (isArray(controls)) {
305
405
  var _result;
306
- (_result = result1).push.apply(_result, _toConsumableArray(controls.map(function(item) {
406
+ (_result = result).push.apply(_result, _to_consumable_array(controls.map(function(item) {
307
407
  return generatePermissions(item, parent);
308
408
  }).flat()));
309
409
  } else {
310
410
  var type = controls.type;
311
- var _props = controls.props, caption1 = _props.caption, content = _props.content;
411
+ var _controls_props = controls.props, caption = _controls_props.caption, content = _controls_props.content;
312
412
  var permissionItem;
313
413
  if (!PermissionExcludeControlTypes.includes(type)) {
314
- var ref;
414
+ var _parent;
415
+ var _parent_controlId;
315
416
  permissionItem = {
316
417
  controlId: controls.id,
317
- caption: caption1 || content || controls.name,
418
+ caption: caption || content || controls.name,
318
419
  type: controls.type,
319
420
  controlType: controls.controlType,
320
- parentId: (ref = parent === null || parent === void 0 ? void 0 : parent.controlId) !== null && ref !== void 0 ? ref : null,
421
+ parentId: (_parent_controlId = (_parent = parent) === null || _parent === void 0 ? void 0 : _parent.controlId) !== null && _parent_controlId !== void 0 ? _parent_controlId : null,
321
422
  canEdit: !cannotEditControlTypes.includes(type),
322
423
  canRead: true,
323
424
  canHide: true,
324
- group: 'element'
425
+ group: "element"
325
426
  };
326
427
  if (parent && parent.type === CONTROL_TYPE.SUBTABLE) {
327
428
  // 如果有parent,则利用下划线拼接caption
328
- permissionItem.caption = parent.caption + '_' + permissionItem.caption;
429
+ permissionItem.caption = parent.caption + "_" + permissionItem.caption;
329
430
  }
330
431
  if (type === CONTROL_TYPE.VUE_FORM_ITEM) {
331
432
  permissionItem.caption = controls.props.controlExportName || controls.name;
@@ -336,59 +437,60 @@ function generatePermissions(controls, parent) {
336
437
  // ) {
337
438
  if (controls.controlType === CONTROL_BASE_TYPE.FORM || controls.controlType === CONTROL_BASE_TYPE.COLUMN) {
338
439
  var //@ts-ignore
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';
440
+ _controls_props_dataBind, _controls_props1, //@ts-ignore
441
+ _controls_props_dataBind1, _controls_props2;
442
+ 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) !== "") {
443
+ permissionItem.group = "field";
343
444
  }
344
445
  }
345
- result1.push(permissionItem);
446
+ result.push(permissionItem);
346
447
  //追加vue容器权限
347
448
  if (type === CONTROL_TYPE.VUE_FORM_ITEM) {
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';
449
+ var _controls_props_dataBind2, _controls_props3, _controls_props_dataBind3, _controls_props4, _permissions;
450
+ var vueFormItemGroup = "element";
451
+ 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) !== "") {
452
+ vueFormItemGroup = "field";
352
453
  }
353
- var permissions = controls.props['permissions'];
354
- permissions === null || permissions === void 0 ? void 0 : permissions.map(function(item) {
355
- var _id;
454
+ var permissions = controls.props["permissions"];
455
+ (_permissions = permissions) === null || _permissions === void 0 ? void 0 : _permissions.map(function(item) {
456
+ var _controls_id;
356
457
  permissionItem = {
357
458
  controlId: item.key,
358
459
  caption: item.caption,
359
460
  type: controls.type,
360
461
  controlType: controls.controlType,
361
- parentId: (_id = controls.id) !== null && _id !== void 0 ? _id : null,
462
+ parentId: (_controls_id = controls.id) !== null && _controls_id !== void 0 ? _controls_id : null,
362
463
  canEdit: true,
363
464
  canRead: true,
364
465
  canHide: true,
365
466
  group: vueFormItemGroup
366
467
  };
367
- result1.push(permissionItem);
468
+ result.push(permissionItem);
368
469
  });
369
470
  }
370
471
  } else if (type === CONTROL_TYPE.OPERATION_COLUMN) {
371
472
  // 列表的操作列单独处理
372
473
  Object.entries(LIST_OPERATION_BUTTON_PERMISSIONS_MAPS).reduce(function(result, param) {
373
- var _param = _slicedToArray(param, 2), key = _param[0], ref = _param[1], caption = ref.caption, controlId = ref.id;
474
+ var _param = _sliced_to_array(param, 2), key = _param[0], _param_ = _param[1], caption = _param_.caption, controlId = _param_.id;
374
475
  var operationItem = controls.props[key];
375
476
  if (operationItem && operationItem.isShow) {
376
- var ref9;
477
+ var _parent;
478
+ var _parent_controlId;
377
479
  // 只能控制是否显示
378
480
  result.push({
379
481
  controlId: controlId,
380
482
  caption: caption,
381
483
  type: controls.type,
382
484
  controlType: controls.controlType,
383
- parentId: (ref9 = parent === null || parent === void 0 ? void 0 : parent.controlId) !== null && ref9 !== void 0 ? ref9 : null,
485
+ parentId: (_parent_controlId = (_parent = parent) === null || _parent === void 0 ? void 0 : _parent.controlId) !== null && _parent_controlId !== void 0 ? _parent_controlId : null,
384
486
  canEdit: false,
385
487
  canRead: false,
386
488
  canHide: true,
387
- group: 'element'
489
+ group: "element"
388
490
  });
389
491
  }
390
492
  return result;
391
- }, result1);
493
+ }, result);
392
494
  }
393
495
  // else if (type === CONTROL_TYPE.CUSTOM_COLUMN) {
394
496
  // //追加自定义列上的vue容器权限
@@ -412,7 +514,7 @@ function generatePermissions(controls, parent) {
412
514
  // }
413
515
  if (controls.children) {
414
516
  var _result1;
415
- (_result1 = result1).push.apply(_result1, _toConsumableArray(controls.children.map(function(item) {
517
+ (_result1 = result).push.apply(_result1, _to_consumable_array(controls.children.map(function(item) {
416
518
  return generatePermissions(item, parent);
417
519
  }).flat()));
418
520
  }
@@ -420,11 +522,11 @@ function generatePermissions(controls, parent) {
420
522
  if (controls.controlType === CONTROL_BASE_TYPE.LIST) {
421
523
  var // 明细子表和列表的需要给parentId
422
524
  _result2;
423
- (_result2 = result1).push.apply(_result2, _toConsumableArray(controls.props.headers.map(function(item) {
525
+ (_result2 = result).push.apply(_result2, _to_consumable_array(controls.props.headers.map(function(item) {
424
526
  return generatePermissions(item, permissionItem);
425
527
  }).flat()));
426
528
  }
427
529
  }
428
- return result1;
530
+ return result;
429
531
  }
430
532
  export { toSchema, getModelBindInfoList, checkSchema, generatePermissions };