@byteluck-fe/model-driven-driven 3.0.0-beta.6 → 3.0.0-beta.7

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.
@@ -0,0 +1,187 @@
1
+ function _class_call_check(instance, Constructor) {
2
+ if (!(instance instanceof Constructor)) {
3
+ throw new TypeError("Cannot call a class as a function");
4
+ }
5
+ }
6
+ function _defineProperties(target, props) {
7
+ for(var i = 0; i < props.length; i++){
8
+ var descriptor = props[i];
9
+ descriptor.enumerable = descriptor.enumerable || false;
10
+ descriptor.configurable = true;
11
+ if ("value" in descriptor) descriptor.writable = true;
12
+ Object.defineProperty(target, descriptor.key, descriptor);
13
+ }
14
+ }
15
+ function _create_class(Constructor, protoProps, staticProps) {
16
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
17
+ if (staticProps) _defineProperties(Constructor, staticProps);
18
+ return Constructor;
19
+ }
20
+ function _define_property(obj, key, value) {
21
+ if (key in obj) {
22
+ Object.defineProperty(obj, key, {
23
+ value: value,
24
+ enumerable: true,
25
+ configurable: true,
26
+ writable: true
27
+ });
28
+ } else {
29
+ obj[key] = value;
30
+ }
31
+ return obj;
32
+ }
33
+ import { getLocaleText } from '@byteluck-fe/locale-message';
34
+ import Designer from './Designer';
35
+ import { CONTROL_TYPE } from '@byteluck-fe/model-driven-shared';
36
+ export var Builder = /*#__PURE__*/ function() {
37
+ "use strict";
38
+ function Builder() {
39
+ _class_call_check(this, Builder);
40
+ _define_property(this, "designer", new Designer());
41
+ }
42
+ _create_class(Builder, [
43
+ {
44
+ key: "ListPageBuilder",
45
+ value: // @ts-ignore
46
+ function ListPageBuilder() {
47
+ var listview = this.designer.createControlInstance(// @ts-ignore
48
+ CONTROL_TYPE.LIST_VIEW);
49
+ var simpleSearch = this.designer.createControlInstance(// @ts-ignore
50
+ CONTROL_TYPE.SIMPLE_SEARCH);
51
+ var gridTable = this.designer.createControlInstance(// @ts-ignore
52
+ CONTROL_TYPE.GRID_TABLE);
53
+ var createBtn = this.designer.createControlInstance(// @ts-ignore
54
+ CONTROL_TYPE.CREATE_FORM_LIST_BUTTON);
55
+ var importBtn = this.designer.createControlInstance(// @ts-ignore
56
+ CONTROL_TYPE.IMPORT_RECORD_LIST_BUTTON);
57
+ var exportBtn = this.designer.createControlInstance(// @ts-ignore
58
+ CONTROL_TYPE.EXPORT_LIST_BUTTON);
59
+ var exportRecordBtn = this.designer.createControlInstance(// @ts-ignore
60
+ CONTROL_TYPE.EXPORT_RECORD_LIST_BUTTON);
61
+ // @ts-ignore
62
+ gridTable.children.push(createBtn);
63
+ // @ts-ignore
64
+ gridTable.children.push(importBtn);
65
+ // @ts-ignore
66
+ gridTable.children.push(exportBtn);
67
+ // @ts-ignore
68
+ gridTable.children.push(exportRecordBtn);
69
+ // @ts-ignore
70
+ listview.children.push(simpleSearch);
71
+ // @ts-ignore
72
+ listview.children.push(gridTable);
73
+ return listview;
74
+ }
75
+ },
76
+ {
77
+ key: "ProListPageBuilder",
78
+ value: // @ts-ignore
79
+ function ProListPageBuilder() {
80
+ // @ts-ignore
81
+ var listview = this.designer.createControlInstance(// @ts-ignore
82
+ CONTROL_TYPE.LIST_VIEW);
83
+ listview.props.countType = 'async';
84
+ var simpleSearch = this.designer.createControlInstance(// @ts-ignore
85
+ CONTROL_TYPE.SIMPLE_SEARCH);
86
+ var gridTable = this.designer.createControlInstance(// @ts-ignore
87
+ CONTROL_TYPE.GRID_TABLE);
88
+ // @ts-ignore
89
+ var exportBtn = this.designer.createControlInstance(// @ts-ignore
90
+ CONTROL_TYPE.EXPORT_LIST_BUTTON);
91
+ var exportRecordBtn = this.designer.createControlInstance(// @ts-ignore
92
+ CONTROL_TYPE.EXPORT_RECORD_LIST_BUTTON);
93
+ // @ts-ignore
94
+ gridTable.children.push(exportBtn);
95
+ // @ts-ignore
96
+ gridTable.children.push(exportRecordBtn);
97
+ // @ts-ignore
98
+ listview.children.push(simpleSearch);
99
+ // @ts-ignore
100
+ listview.children.push(gridTable);
101
+ listview.props.rowStyle = {
102
+ type: 'rules',
103
+ "interval": {
104
+ "color": ""
105
+ },
106
+ rules: [
107
+ {
108
+ id: 'default',
109
+ name: getLocaleText('CMD.approvedDocuments', null, '审批通过单据'),
110
+ color: 'theme',
111
+ filters: [
112
+ {
113
+ ruleId: 1,
114
+ symbol: 'op_equal',
115
+ leftVariableBo: {
116
+ type: 'varchar',
117
+ value: 'process_status',
118
+ name: getLocaleText('CMD.processStatus', null, '流程状态')
119
+ },
120
+ checked: false,
121
+ describe: 'ruleLine',
122
+ type: 'condition',
123
+ rightVariableBo: {
124
+ type: 'custom',
125
+ value: [
126
+ 'COMPLETE'
127
+ ],
128
+ displayBos: []
129
+ },
130
+ isLowPerformance: false,
131
+ isMoreRelation: false
132
+ }
133
+ ],
134
+ "settings": [
135
+ {
136
+ "color": "theme",
137
+ "field_codes": [
138
+ "process_status"
139
+ ],
140
+ "type": "fontColor",
141
+ "scope": "col"
142
+ }
143
+ ],
144
+ script: "(SpecialMatch(data,sys,'process_status','varchar','op_equal','COMPLETE'))"
145
+ }
146
+ ]
147
+ };
148
+ return listview;
149
+ }
150
+ },
151
+ {
152
+ key: "FormPageBuilder",
153
+ value: // @ts-ignore
154
+ function FormPageBuilder() {
155
+ var dataView = this.designer.createControlInstance(// @ts-ignore
156
+ CONTROL_TYPE.DATA_VIEW);
157
+ // @ts-ignore
158
+ var title = this.designer.createControlInstance(CONTROL_TYPE.TITLE);
159
+ // @ts-ignore
160
+ var grid = this.designer.createControlInstance(CONTROL_TYPE.GRID);
161
+ // @ts-ignore
162
+ dataView.children.push(title);
163
+ // @ts-ignore
164
+ dataView.children.push(grid);
165
+ return dataView;
166
+ }
167
+ },
168
+ {
169
+ key: "VuePageBuilder",
170
+ value: // @ts-ignore
171
+ function VuePageBuilder() {
172
+ var grid = this.designer.createControlInstance(// @ts-ignore
173
+ CONTROL_TYPE.GRID);
174
+ var vueFormItem = this.designer.createControlInstance(// @ts-ignore
175
+ CONTROL_TYPE.VUE_PAGE);
176
+ // @ts-ignore
177
+ vueFormItem.props.isHideCaption = true;
178
+ // @ts-ignore
179
+ vueFormItem.props.controlExportName = 'VuePage';
180
+ // @ts-ignore
181
+ grid.children.push(vueFormItem);
182
+ return grid;
183
+ }
184
+ }
185
+ ]);
186
+ return Builder;
187
+ }();
@@ -0,0 +1,359 @@
1
+ function _array_like_to_array(arr, len) {
2
+ if (len == null || len > arr.length) len = arr.length;
3
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
+ return arr2;
5
+ }
6
+ function _array_without_holes(arr) {
7
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
8
+ }
9
+ function _assert_this_initialized(self) {
10
+ if (self === void 0) {
11
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
12
+ }
13
+ return self;
14
+ }
15
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
16
+ try {
17
+ var info = gen[key](arg);
18
+ var value = info.value;
19
+ } catch (error) {
20
+ reject(error);
21
+ return;
22
+ }
23
+ if (info.done) {
24
+ resolve(value);
25
+ } else {
26
+ Promise.resolve(value).then(_next, _throw);
27
+ }
28
+ }
29
+ function _async_to_generator(fn) {
30
+ return function() {
31
+ var self = this, args = arguments;
32
+ return new Promise(function(resolve, reject) {
33
+ var gen = fn.apply(self, args);
34
+ function _next(value) {
35
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
36
+ }
37
+ function _throw(err) {
38
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
39
+ }
40
+ _next(undefined);
41
+ });
42
+ };
43
+ }
44
+ function _call_super(_this, derived, args) {
45
+ derived = _get_prototype_of(derived);
46
+ return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
47
+ }
48
+ function _class_call_check(instance, Constructor) {
49
+ if (!(instance instanceof Constructor)) {
50
+ throw new TypeError("Cannot call a class as a function");
51
+ }
52
+ }
53
+ function _defineProperties(target, props) {
54
+ for(var i = 0; i < props.length; i++){
55
+ var descriptor = props[i];
56
+ descriptor.enumerable = descriptor.enumerable || false;
57
+ descriptor.configurable = true;
58
+ if ("value" in descriptor) descriptor.writable = true;
59
+ Object.defineProperty(target, descriptor.key, descriptor);
60
+ }
61
+ }
62
+ function _create_class(Constructor, protoProps, staticProps) {
63
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
64
+ if (staticProps) _defineProperties(Constructor, staticProps);
65
+ return Constructor;
66
+ }
67
+ function _define_property(obj, key, value) {
68
+ if (key in obj) {
69
+ Object.defineProperty(obj, key, {
70
+ value: value,
71
+ enumerable: true,
72
+ configurable: true,
73
+ writable: true
74
+ });
75
+ } else {
76
+ obj[key] = value;
77
+ }
78
+ return obj;
79
+ }
80
+ function _get_prototype_of(o) {
81
+ _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
82
+ return o.__proto__ || Object.getPrototypeOf(o);
83
+ };
84
+ return _get_prototype_of(o);
85
+ }
86
+ function _inherits(subClass, superClass) {
87
+ if (typeof superClass !== "function" && superClass !== null) {
88
+ throw new TypeError("Super expression must either be null or a function");
89
+ }
90
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
91
+ constructor: {
92
+ value: subClass,
93
+ writable: true,
94
+ configurable: true
95
+ }
96
+ });
97
+ if (superClass) _set_prototype_of(subClass, superClass);
98
+ }
99
+ function _instanceof(left, right) {
100
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
101
+ return !!right[Symbol.hasInstance](left);
102
+ } else {
103
+ return left instanceof right;
104
+ }
105
+ }
106
+ function _iterable_to_array(iter) {
107
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
108
+ }
109
+ function _non_iterable_spread() {
110
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
111
+ }
112
+ function _possible_constructor_return(self, call) {
113
+ if (call && (_type_of(call) === "object" || typeof call === "function")) {
114
+ return call;
115
+ }
116
+ return _assert_this_initialized(self);
117
+ }
118
+ function _set_prototype_of(o, p) {
119
+ _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
120
+ o.__proto__ = p;
121
+ return o;
122
+ };
123
+ return _set_prototype_of(o, p);
124
+ }
125
+ function _to_consumable_array(arr) {
126
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
127
+ }
128
+ function _type_of(obj) {
129
+ "@swc/helpers - typeof";
130
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
131
+ }
132
+ function _unsupported_iterable_to_array(o, minLen) {
133
+ if (!o) return;
134
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
135
+ var n = Object.prototype.toString.call(o).slice(8, -1);
136
+ if (n === "Object" && o.constructor) n = o.constructor.name;
137
+ if (n === "Map" || n === "Set") return Array.from(n);
138
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
139
+ }
140
+ function _is_native_reflect_construct() {
141
+ try {
142
+ var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
143
+ } catch (_) {}
144
+ return (_is_native_reflect_construct = function() {
145
+ return !!result;
146
+ })();
147
+ }
148
+ function _ts_generator(thisArg, body) {
149
+ var f, y, t, _ = {
150
+ label: 0,
151
+ sent: function() {
152
+ if (t[0] & 1) throw t[1];
153
+ return t[1];
154
+ },
155
+ trys: [],
156
+ ops: []
157
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
158
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
159
+ return this;
160
+ }), g;
161
+ function verb(n) {
162
+ return function(v) {
163
+ return step([
164
+ n,
165
+ v
166
+ ]);
167
+ };
168
+ }
169
+ function step(op) {
170
+ if (f) throw new TypeError("Generator is already executing.");
171
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
172
+ 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;
173
+ if (y = 0, t) op = [
174
+ op[0] & 2,
175
+ t.value
176
+ ];
177
+ switch(op[0]){
178
+ case 0:
179
+ case 1:
180
+ t = op;
181
+ break;
182
+ case 4:
183
+ _.label++;
184
+ return {
185
+ value: op[1],
186
+ done: false
187
+ };
188
+ case 5:
189
+ _.label++;
190
+ y = op[1];
191
+ op = [
192
+ 0
193
+ ];
194
+ continue;
195
+ case 7:
196
+ op = _.ops.pop();
197
+ _.trys.pop();
198
+ continue;
199
+ default:
200
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
201
+ _ = 0;
202
+ continue;
203
+ }
204
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
205
+ _.label = op[1];
206
+ break;
207
+ }
208
+ if (op[0] === 6 && _.label < t[1]) {
209
+ _.label = t[1];
210
+ t = op;
211
+ break;
212
+ }
213
+ if (t && _.label < t[2]) {
214
+ _.label = t[2];
215
+ _.ops.push(op);
216
+ break;
217
+ }
218
+ if (t[2]) _.ops.pop();
219
+ _.trys.pop();
220
+ continue;
221
+ }
222
+ op = body.call(thisArg, _);
223
+ } catch (e) {
224
+ op = [
225
+ 6,
226
+ e
227
+ ];
228
+ y = 0;
229
+ } finally{
230
+ f = t = 0;
231
+ }
232
+ if (op[0] & 5) throw op[1];
233
+ return {
234
+ value: op[0] ? op[1] : void 0,
235
+ done: true
236
+ };
237
+ }
238
+ }
239
+ import { RegisterControls, controlHooksEmitter } from '@byteluck-fe/model-driven-core';
240
+ import EventLogic from './EventLogic';
241
+ import { FieldTypes } from '@byteluck-fe/model-driven-shared';
242
+ import { toSchema, getModelBindInfoList, checkSchema } from './utils';
243
+ var Designer = /*#__PURE__*/ function _target(RegisterControls) {
244
+ "use strict";
245
+ _inherits(Designer, RegisterControls);
246
+ function Designer() {
247
+ _class_call_check(this, Designer);
248
+ var _this;
249
+ _this = _call_super(this, Designer, [
250
+ 'Designer'
251
+ ]), _define_property(_this, "toolbox", []), _define_property(_this, "services", {}), _define_property(_this, "eventLogic", new EventLogic()), _define_property(_this, "fieldTypes", FieldTypes), _define_property(_this, "controlSettingMap", new Map());
252
+ (_instanceof(this, Designer) ? this.constructor : void 0).staticControls.forEach(function(control) {
253
+ var _$Designer = control.Designer, Setting = control.Setting;
254
+ _this.controlSettingMap.set(_$Designer.controlType, Setting);
255
+ });
256
+ return _this;
257
+ }
258
+ _create_class(Designer, [
259
+ {
260
+ key: "registerControl",
261
+ value: function registerControl(control) {
262
+ ;
263
+ this.constructor.register(control, 'Designer');
264
+ var DesignerClass = control.Designer, Setting = control.Setting;
265
+ this.register(DesignerClass);
266
+ this.registeredControlTypes.add(DesignerClass.controlType);
267
+ this.controlSettingMap.set(DesignerClass.controlType, Setting);
268
+ }
269
+ },
270
+ {
271
+ key: "getControlSetting",
272
+ value: function getControlSetting(type) {
273
+ var setting = this.controlSettingMap.get(type);
274
+ if (!setting) {
275
+ return null;
276
+ }
277
+ return setting;
278
+ }
279
+ },
280
+ {
281
+ key: "setInstance",
282
+ value: function setInstance(instance, props, value) {
283
+ try {
284
+ if (!instance) {
285
+ return;
286
+ }
287
+ // @ts-ignore
288
+ instance.updateProps(props, value);
289
+ } catch (e) {
290
+ throw e;
291
+ }
292
+ }
293
+ },
294
+ {
295
+ key: "eachControls",
296
+ value: function eachControls(callback) {
297
+ this.getControls().forEach(callback);
298
+ }
299
+ },
300
+ {
301
+ key: "getInitControl",
302
+ value: // 获取初始化的数据模型
303
+ function getInitControl() {
304
+ // @ts-ignore
305
+ return [
306
+ this.createControlInstance('grid')
307
+ ];
308
+ }
309
+ },
310
+ {
311
+ key: "checkSchema",
312
+ value: function checkSchema1() {
313
+ for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
314
+ args[_key] = arguments[_key];
315
+ }
316
+ return _async_to_generator(function() {
317
+ return _ts_generator(this, function(_state) {
318
+ return [
319
+ 2,
320
+ checkSchema.apply(void 0, _to_consumable_array(args))
321
+ ];
322
+ });
323
+ })();
324
+ }
325
+ },
326
+ {
327
+ key: "getModelBindInfoList",
328
+ value: function getModelBindInfoList1() {
329
+ for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
330
+ args[_key] = arguments[_key];
331
+ }
332
+ return getModelBindInfoList.apply(void 0, _to_consumable_array(args));
333
+ }
334
+ },
335
+ {
336
+ key: "getSchema",
337
+ value: function getSchema() {
338
+ for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
339
+ args[_key] = arguments[_key];
340
+ }
341
+ return toSchema.apply(void 0, _to_consumable_array(args));
342
+ }
343
+ },
344
+ {
345
+ key: "listenControlHook",
346
+ value: function listenControlHook() {
347
+ for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
348
+ args[_key] = arguments[_key];
349
+ }
350
+ var _controlHooksEmitter;
351
+ return (_controlHooksEmitter = controlHooksEmitter).on.apply(_controlHooksEmitter, _to_consumable_array(args));
352
+ }
353
+ }
354
+ ]);
355
+ return Designer;
356
+ }(RegisterControls);
357
+ _define_property(Designer, "EventLogic", EventLogic);
358
+ export { Designer as default };
359
+ export { Designer };