@byteluck-fe/model-driven-driven 2.7.0-alpha.31 → 2.7.0-alpha.31b

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 _array_like_to_array(arr, len) {
1
+ function _arrayLikeToArray(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 _array_with_holes(arr) {
6
+ function _arrayWithHoles(arr) {
7
7
  if (Array.isArray(arr)) return arr;
8
8
  }
9
- function _array_without_holes(arr) {
10
- if (Array.isArray(arr)) return _array_like_to_array(arr);
9
+ function _arrayWithoutHoles(arr) {
10
+ if (Array.isArray(arr)) return _arrayLikeToArray(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 _async_to_generator(fn) {
26
+ function _asyncToGenerator(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 _async_to_generator(fn) {
38
38
  });
39
39
  };
40
40
  }
41
- function _iterable_to_array(iter) {
41
+ function _iterableToArray(iter) {
42
42
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
43
43
  }
44
- function _iterable_to_array_limit(arr, i) {
44
+ function _iterableToArrayLimit(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,125 +65,31 @@ function _iterable_to_array_limit(arr, i) {
65
65
  }
66
66
  return _arr;
67
67
  }
68
- function _non_iterable_rest() {
68
+ function _nonIterableRest() {
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 _non_iterable_spread() {
71
+ function _nonIterableSpread() {
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 _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();
74
+ function _slicedToArray(arr, i) {
75
+ return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
76
76
  }
77
- function _to_consumable_array(arr) {
78
- return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
77
+ function _toConsumableArray(arr) {
78
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
79
79
  }
80
- function _unsupported_iterable_to_array(o, minLen) {
80
+ function _unsupportedIterableToArray(o, minLen) {
81
81
  if (!o) return;
82
- if (typeof o === "string") return _array_like_to_array(o, minLen);
82
+ if (typeof o === "string") return _arrayLikeToArray(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 _array_like_to_array(o, minLen);
86
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
87
87
  }
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";
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
@@ -195,11 +101,11 @@ export function getMasterFormControls(controls) {
195
101
  });
196
102
  return formctls;
197
103
  }
198
- /**
199
- * @description 给modelBindInfoList中填充fieldCode和dataCode
200
- * @description 我们生成fieldCode的规则是:DataBind的控件,取`field_${id}`,ObjectDataBind的控件,取`field_${id}_${key}`, key指的是ObjectDataBind.keys()
104
+ /**
105
+ * @description 给modelBindInfoList中填充fieldCode和dataCode
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 + "_" + key;
119
+ var fieldCode = item.controlId + '_' + key;
214
120
  dataBind.fieldCode = fieldCodeBeforeAddPrefix(fieldCode);
215
121
  dataBind.dataCode = dataCode;
216
122
  });
@@ -222,19 +128,19 @@ export function getMasterFormControls(controls) {
222
128
  });
223
129
  }
224
130
  function fieldCodeBeforeAddPrefix(fieldCode) {
225
- var prefix = "field_";
131
+ var prefix = 'field_';
226
132
  if (fieldCode.startsWith(prefix)) {
227
133
  return fieldCode;
228
134
  }
229
135
  return prefix + fieldCode;
230
136
  }
231
- /**
232
- * @description 通过fieldType获取列表表头的type
137
+ /**
138
+ * @description 通过fieldType获取列表表头的type
233
139
  * */ export function getColumnTypeFromFiledType(fieldType) {
234
140
  return FieldTypeToColumnType[fieldType];
235
141
  }
236
- /**
237
- * @description 通过modelBindInfoList生成多个columns
142
+ /**
143
+ * @description 通过modelBindInfoList生成多个columns
238
144
  * */ export function getColumnsFromModelBindInfoList(modelBindInfoList) {
239
145
  var designer = new Designer();
240
146
  var columns = [];
@@ -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 + "_" + objectDataBindKeyToFieldType[key].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 === "currency") {
264
- props.optionConfig = "datasource";
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 controlType = getColumnTypeFromFiledType(item.fieldType);
275
- if (!controlType) return;
180
+ var controlType1 = getColumnTypeFromFiledType(item.fieldType);
181
+ if (!controlType1) return;
276
182
  // @ts-ignore
277
- var column = designer.createControlInstance(controlType, {
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
- column && columns.push(column);
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 = _async_to_generator(function(controls, messages, ignore) {
229
+ _checkSchema = _asyncToGenerator(regeneratorRuntime.mark(function _callee(controls, messages, ignore) {
324
230
  var result;
325
- return _ts_generator(this, function(_state) {
326
- switch(_state.label){
231
+ return regeneratorRuntime.wrap(function _callee$(_ctx) {
232
+ while(1)switch(_ctx.prev = _ctx.next){
327
233
  case 0:
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
- ];
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
- return [
353
- 2,
354
- _state.sent()
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
  // 不可以被权限控制的控件
@@ -389,46 +288,46 @@ var cannotEditControlTypes = [
389
288
  // 列表操作列单独处理三个按钮的权限
390
289
  var LIST_OPERATION_BUTTON_PERMISSIONS_MAPS = {
391
290
  check: {
392
- id: "listPageCheckBtnId",
393
- caption: "查看"
291
+ id: 'listPageCheckBtnId',
292
+ caption: '查看'
394
293
  },
395
294
  edit: {
396
- id: "listPageEditBtnId",
397
- caption: "编辑"
295
+ id: 'listPageEditBtnId',
296
+ caption: '编辑'
398
297
  },
399
298
  delete: {
400
- id: "listPageDeleteBtnId",
401
- caption: "删除"
299
+ id: 'listPageDeleteBtnId',
300
+ caption: '删除'
402
301
  }
403
302
  };
404
303
  // 生成权限字段
405
304
  function generatePermissions(controls, parent) {
406
- var result = [];
305
+ var result1 = [];
407
306
  if (isArray(controls)) {
408
307
  var _result;
409
- (_result = result).push.apply(_result, _to_consumable_array(controls.map(function(item) {
308
+ (_result = result1).push.apply(_result, _toConsumableArray(controls.map(function(item) {
410
309
  return generatePermissions(item, parent);
411
310
  }).flat()));
412
311
  } else {
413
312
  var type = controls.type;
414
- var _controls_props = controls.props, caption = _controls_props.caption, content = _controls_props.content;
313
+ var _props = controls.props, caption1 = _props.caption, content = _props.content;
415
314
  var permissionItem;
416
315
  if (!PermissionExcludeControlTypes.includes(type)) {
417
- var _parent_controlId;
316
+ var ref;
418
317
  permissionItem = {
419
318
  controlId: controls.id,
420
- caption: caption || content || controls.name,
319
+ caption: caption1 || content || controls.name,
421
320
  type: controls.type,
422
321
  controlType: controls.controlType,
423
- parentId: (_parent_controlId = parent === null || parent === void 0 ? void 0 : parent.controlId) !== null && _parent_controlId !== void 0 ? _parent_controlId : null,
322
+ parentId: (ref = parent === null || parent === void 0 ? void 0 : parent.controlId) !== null && ref !== void 0 ? ref : null,
424
323
  canEdit: !cannotEditControlTypes.includes(type),
425
324
  canRead: true,
426
325
  canHide: true,
427
- group: "element"
326
+ group: 'element'
428
327
  };
429
328
  if (parent && parent.type === CONTROL_TYPE.SUBTABLE) {
430
329
  // 如果有parent,则利用下划线拼接caption
431
- permissionItem.caption = parent.caption + "_" + permissionItem.caption;
330
+ permissionItem.caption = parent.caption + '_' + permissionItem.caption;
432
331
  }
433
332
  if (type === CONTROL_TYPE.VUE_FORM_ITEM) {
434
333
  permissionItem.caption = controls.props.controlExportName || controls.name;
@@ -439,59 +338,59 @@ function generatePermissions(controls, parent) {
439
338
  // ) {
440
339
  if (controls.controlType === CONTROL_BASE_TYPE.FORM || controls.controlType === CONTROL_BASE_TYPE.COLUMN) {
441
340
  var //@ts-ignore
442
- _controls_props_dataBind, _controls_props1, //@ts-ignore
443
- _controls_props_dataBind1, _controls_props2;
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";
341
+ ref1, ref2, //@ts-ignore
342
+ ref3, ref4;
343
+ 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) !== '') {
344
+ permissionItem.group = 'field';
446
345
  }
447
346
  }
448
- result.push(permissionItem);
347
+ result1.push(permissionItem);
449
348
  //追加vue容器权限
450
349
  if (type === CONTROL_TYPE.VUE_FORM_ITEM) {
451
- var _controls_props_dataBind2, _controls_props3, _controls_props_dataBind3, _controls_props4;
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";
350
+ var ref5, ref6, ref7, ref8;
351
+ var vueFormItemGroup = 'element';
352
+ 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) !== '') {
353
+ vueFormItemGroup = 'field';
455
354
  }
456
- var permissions = controls.props["permissions"];
355
+ var permissions = controls.props['permissions'];
457
356
  permissions === null || permissions === void 0 ? void 0 : permissions.map(function(item) {
458
- var _controls_id;
357
+ var _id;
459
358
  permissionItem = {
460
359
  controlId: item.key,
461
360
  caption: item.caption,
462
361
  type: controls.type,
463
362
  controlType: controls.controlType,
464
- parentId: (_controls_id = controls.id) !== null && _controls_id !== void 0 ? _controls_id : null,
363
+ parentId: (_id = controls.id) !== null && _id !== void 0 ? _id : null,
465
364
  canEdit: true,
466
365
  canRead: true,
467
366
  canHide: true,
468
367
  group: vueFormItemGroup
469
368
  };
470
- result.push(permissionItem);
369
+ result1.push(permissionItem);
471
370
  });
472
371
  }
473
372
  } else if (type === CONTROL_TYPE.OPERATION_COLUMN) {
474
373
  // 列表的操作列单独处理
475
374
  Object.entries(LIST_OPERATION_BUTTON_PERMISSIONS_MAPS).reduce(function(result, param) {
476
- var _param = _sliced_to_array(param, 2), key = _param[0], _param_ = _param[1], caption = _param_.caption, controlId = _param_.id;
375
+ var _param = _slicedToArray(param, 2), key = _param[0], ref = _param[1], caption = ref.caption, controlId = ref.id;
477
376
  var operationItem = controls.props[key];
478
377
  if (operationItem && operationItem.isShow) {
479
- var _parent_controlId;
378
+ var ref9;
480
379
  // 只能控制是否显示
481
380
  result.push({
482
381
  controlId: controlId,
483
382
  caption: caption,
484
383
  type: controls.type,
485
384
  controlType: controls.controlType,
486
- parentId: (_parent_controlId = parent === null || parent === void 0 ? void 0 : parent.controlId) !== null && _parent_controlId !== void 0 ? _parent_controlId : null,
385
+ parentId: (ref9 = parent === null || parent === void 0 ? void 0 : parent.controlId) !== null && ref9 !== void 0 ? ref9 : null,
487
386
  canEdit: false,
488
387
  canRead: false,
489
388
  canHide: true,
490
- group: "element"
389
+ group: 'element'
491
390
  });
492
391
  }
493
392
  return result;
494
- }, result);
393
+ }, result1);
495
394
  }
496
395
  // else if (type === CONTROL_TYPE.CUSTOM_COLUMN) {
497
396
  // //追加自定义列上的vue容器权限
@@ -515,7 +414,7 @@ function generatePermissions(controls, parent) {
515
414
  // }
516
415
  if (controls.children) {
517
416
  var _result1;
518
- (_result1 = result).push.apply(_result1, _to_consumable_array(controls.children.map(function(item) {
417
+ (_result1 = result1).push.apply(_result1, _toConsumableArray(controls.children.map(function(item) {
519
418
  return generatePermissions(item, parent);
520
419
  }).flat()));
521
420
  }
@@ -523,11 +422,11 @@ function generatePermissions(controls, parent) {
523
422
  if (controls.controlType === CONTROL_BASE_TYPE.LIST) {
524
423
  var // 明细子表和列表的需要给parentId
525
424
  _result2;
526
- (_result2 = result).push.apply(_result2, _to_consumable_array(controls.props.headers.map(function(item) {
425
+ (_result2 = result1).push.apply(_result2, _toConsumableArray(controls.props.headers.map(function(item) {
527
426
  return generatePermissions(item, permissionItem);
528
427
  }).flat()));
529
428
  }
530
429
  }
531
- return result;
430
+ return result1;
532
431
  }
533
432
  export { toSchema, getModelBindInfoList, checkSchema, generatePermissions };