@byteluck-fe/model-driven-driven 2.8.1-beta1 → 2.8.2-beta.10
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 +17 -17
- package/dist/esm/Designer.js +19 -34
- package/dist/esm/Driven.js +65 -91
- package/dist/esm/EventLogic.js +1 -1
- package/dist/esm/Store.js +39 -37
- package/dist/esm/constants.js +7 -7
- package/dist/esm/designerUtils.js +4 -4
- package/dist/esm/index.js +6 -6
- package/dist/esm/utils.js +33 -32
- package/dist/index.umd.js +3 -3
- package/dist/types/Builder.d.ts +8 -8
- package/dist/types/Designer.d.ts +36 -36
- package/dist/types/Driven.d.ts +112 -112
- 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 -5
- package/dist/types/index.d.ts +8 -8
- package/dist/types/utils.d.ts +55 -55
- package/package.json +6 -6
package/dist/esm/Store.js
CHANGED
|
@@ -88,50 +88,50 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
88
88
|
if (n === "Map" || n === "Set") return Array.from(n);
|
|
89
89
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
90
90
|
}
|
|
91
|
-
import { isDataBind } from
|
|
92
|
-
import { hasChildrenControl, hasFooterControl, hasHeaderControl } from
|
|
93
|
-
import { CONTROL_BASE_TYPE, CONTROL_TYPE } from
|
|
91
|
+
import { isDataBind } from '@byteluck-fe/model-driven-core';
|
|
92
|
+
import { hasChildrenControl, hasFooterControl, hasHeaderControl } from './designerUtils';
|
|
93
|
+
import { CONTROL_BASE_TYPE, CONTROL_TYPE } from '@byteluck-fe/model-driven-shared';
|
|
94
94
|
// 维护当前selected,。。 selectedControlSetting
|
|
95
95
|
export var Store = /*#__PURE__*/ function() {
|
|
96
96
|
"use strict";
|
|
97
97
|
function Store(options) {
|
|
98
98
|
_class_call_check(this, Store);
|
|
99
|
-
/**
|
|
100
|
-
* 页面控件实例树
|
|
99
|
+
/**
|
|
100
|
+
* 页面控件实例树
|
|
101
101
|
* */ _define_property(this, "instance", void 0);
|
|
102
|
-
/**
|
|
103
|
-
* 拍平的控件数组
|
|
102
|
+
/**
|
|
103
|
+
* 拍平的控件数组
|
|
104
104
|
* */ _define_property(this, "flatInstances", void 0);
|
|
105
|
-
/**
|
|
106
|
-
* 控件id组成的map
|
|
105
|
+
/**
|
|
106
|
+
* 控件id组成的map
|
|
107
107
|
* */ _define_property(this, "instanceIdMap", void 0);
|
|
108
|
-
/**
|
|
109
|
-
* dataCode和fieldCode组成的map
|
|
110
|
-
* {
|
|
111
|
-
* [主表dataCode]: {
|
|
112
|
-
* [fieldCode]: 控件
|
|
113
|
-
* },
|
|
114
|
-
* [子表dataCode]: {
|
|
115
|
-
* [fieldCode]: 控件
|
|
116
|
-
* }
|
|
117
|
-
* }
|
|
108
|
+
/**
|
|
109
|
+
* dataCode和fieldCode组成的map
|
|
110
|
+
* {
|
|
111
|
+
* [主表dataCode]: {
|
|
112
|
+
* [fieldCode]: 控件
|
|
113
|
+
* },
|
|
114
|
+
* [子表dataCode]: {
|
|
115
|
+
* [fieldCode]: 控件
|
|
116
|
+
* }
|
|
117
|
+
* }
|
|
118
118
|
* */ _define_property(this, "dataFieldCodeMap", void 0);
|
|
119
|
-
/**
|
|
120
|
-
* 当前选中的控件
|
|
119
|
+
/**
|
|
120
|
+
* 当前选中的控件
|
|
121
121
|
* */ _define_property(this, "selected", null);
|
|
122
|
-
/**
|
|
123
|
-
* 当前选中的数据作用域控件
|
|
122
|
+
/**
|
|
123
|
+
* 当前选中的数据作用域控件
|
|
124
124
|
* */ _define_property(this, "selectedInstanceDataScopeParent", null);
|
|
125
125
|
_define_property(this, "selectedDataScopeFlatInstances", []);
|
|
126
|
-
/**
|
|
127
|
-
* 当前选中控件的setting
|
|
126
|
+
/**
|
|
127
|
+
* 当前选中控件的setting
|
|
128
128
|
* */ _define_property(this, "selectedInstanceSetting", []);
|
|
129
129
|
_define_property(this, "selectedInstanceSettingItems", []);
|
|
130
|
-
/**
|
|
131
|
-
* 当前选中控件的数据模型
|
|
130
|
+
/**
|
|
131
|
+
* 当前选中控件的数据模型
|
|
132
132
|
* */ _define_property(this, "selectedFieldItem", null);
|
|
133
|
-
/**
|
|
134
|
-
* 扩展字段,比如appId,dataCode等
|
|
133
|
+
/**
|
|
134
|
+
* 扩展字段,比如appId,dataCode等
|
|
135
135
|
* */ _define_property(this, "external", {});
|
|
136
136
|
_define_property(this, "movingInstance", null);
|
|
137
137
|
_define_property(this, "movingInstanceOldParent", null);
|
|
@@ -147,8 +147,8 @@ export var Store = /*#__PURE__*/ function() {
|
|
|
147
147
|
_create_class(Store, [
|
|
148
148
|
{
|
|
149
149
|
key: "selectedRules",
|
|
150
|
-
get: /**
|
|
151
|
-
* 当前选中控件的rules
|
|
150
|
+
get: /**
|
|
151
|
+
* 当前选中控件的rules
|
|
152
152
|
* */ function get() {
|
|
153
153
|
if (!this.selected) {
|
|
154
154
|
return null;
|
|
@@ -158,8 +158,8 @@ export var Store = /*#__PURE__*/ function() {
|
|
|
158
158
|
},
|
|
159
159
|
{
|
|
160
160
|
key: "selectedAntdRules",
|
|
161
|
-
get: /**
|
|
162
|
-
* 当前选中控件的antd rules
|
|
161
|
+
get: /**
|
|
162
|
+
* 当前选中控件的antd rules
|
|
163
163
|
* */ function get() {
|
|
164
164
|
var rules = this.selectedRules;
|
|
165
165
|
if (!rules) {
|
|
@@ -200,7 +200,7 @@ export var Store = /*#__PURE__*/ function() {
|
|
|
200
200
|
key: "getSettingItems",
|
|
201
201
|
value: function getSettingItems(group) {
|
|
202
202
|
// return group instanceof Group
|
|
203
|
-
return group.type ===
|
|
203
|
+
return group.type === 'group' ? group.items : group.items.reduce(function(result, curr) {
|
|
204
204
|
var _result;
|
|
205
205
|
(_result = result).push.apply(_result, _to_consumable_array(curr.items));
|
|
206
206
|
return result;
|
|
@@ -294,9 +294,11 @@ function setInstanceInDataFieldCodeMap(instance, dataFieldCodeMap) {
|
|
|
294
294
|
if (isDataBind(dataBind)) {
|
|
295
295
|
setDataFieldCodeMap(dataFieldCodeMap, dataBind, instance);
|
|
296
296
|
} else {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
297
|
+
if (dataBind) {
|
|
298
|
+
Object.values(dataBind).forEach(function(subDataBind) {
|
|
299
|
+
setDataFieldCodeMap(dataFieldCodeMap, subDataBind, instance);
|
|
300
|
+
});
|
|
301
|
+
}
|
|
300
302
|
}
|
|
301
303
|
}
|
|
302
304
|
}
|
package/dist/esm/constants.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CONTROL_TYPE, FieldTypes } from
|
|
1
|
+
import { CONTROL_TYPE, FieldTypes } from '@byteluck-fe/model-driven-shared';
|
|
2
2
|
// 使用ObjectDataBind 的控件
|
|
3
3
|
export var objectDataBindControlTypes = [
|
|
4
4
|
CONTROL_TYPE.AMOUNT,
|
|
@@ -7,27 +7,27 @@ export var objectDataBindControlTypes = [
|
|
|
7
7
|
];
|
|
8
8
|
export var objectDataBindKeyToFieldType = {
|
|
9
9
|
amount: {
|
|
10
|
-
caption:
|
|
10
|
+
caption: '金额',
|
|
11
11
|
fieldType: FieldTypes.DECIMAL
|
|
12
12
|
},
|
|
13
13
|
currency: {
|
|
14
|
-
caption:
|
|
14
|
+
caption: '币种',
|
|
15
15
|
fieldType: FieldTypes.VARCHAR
|
|
16
16
|
},
|
|
17
17
|
result: {
|
|
18
|
-
caption:
|
|
18
|
+
caption: '结果',
|
|
19
19
|
fieldType: FieldTypes.DECIMAL
|
|
20
20
|
},
|
|
21
21
|
unit: {
|
|
22
|
-
caption:
|
|
22
|
+
caption: '单位',
|
|
23
23
|
fieldType: FieldTypes.VARCHAR
|
|
24
24
|
},
|
|
25
25
|
min: {
|
|
26
|
-
caption:
|
|
26
|
+
caption: '开始时间',
|
|
27
27
|
fieldType: FieldTypes.TIMESTAMP
|
|
28
28
|
},
|
|
29
29
|
max: {
|
|
30
|
-
caption:
|
|
30
|
+
caption: '结束时间',
|
|
31
31
|
fieldType: FieldTypes.TIMESTAMP
|
|
32
32
|
}
|
|
33
33
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { CONTROL_BASE_TYPE, CONTROL_TYPE, isArray } from
|
|
1
|
+
import { CONTROL_BASE_TYPE, CONTROL_TYPE, isArray } from '@byteluck-fe/model-driven-shared';
|
|
2
2
|
export function hasChildrenControl(instance) {
|
|
3
|
-
return
|
|
3
|
+
return 'children' in instance && isArray(instance.children);
|
|
4
4
|
}
|
|
5
5
|
export function hasHeaderControl(instance) {
|
|
6
|
-
return
|
|
6
|
+
return 'headers' in instance.props && isArray(instance.props.headers);
|
|
7
7
|
}
|
|
8
8
|
export function hasFooterControl(instance) {
|
|
9
|
-
return
|
|
9
|
+
return 'footers' in instance.props && isArray(instance.props.footers);
|
|
10
10
|
}
|
|
11
11
|
export function loopFormControl(control, callback) {
|
|
12
12
|
if (Array.isArray(control)) {
|
package/dist/esm/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import Designer from
|
|
1
|
+
import Designer from './Designer';
|
|
2
2
|
export { Designer };
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
3
|
+
export * from './utils';
|
|
4
|
+
export * from './Builder';
|
|
5
|
+
export * from './designerUtils';
|
|
6
|
+
export * from './Driven';
|
|
7
|
+
export * from './Store';
|
package/dist/esm/utils.js
CHANGED
|
@@ -180,10 +180,10 @@ function _ts_generator(thisArg, body) {
|
|
|
180
180
|
};
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
|
-
import { loopFormControl } from
|
|
184
|
-
import { CONTROL_BASE_TYPE, CONTROL_TYPE, FieldTypeToColumnType, isArray } from
|
|
185
|
-
import Designer from
|
|
186
|
-
import { objectDataBindControlTypes, objectDataBindKeyToFieldType } from
|
|
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';
|
|
187
187
|
export function getMasterFormControls(controls) {
|
|
188
188
|
var formctls = [];
|
|
189
189
|
// @ts-ignore
|
|
@@ -195,11 +195,11 @@ export function getMasterFormControls(controls) {
|
|
|
195
195
|
});
|
|
196
196
|
return formctls;
|
|
197
197
|
}
|
|
198
|
-
/**
|
|
199
|
-
* @description 给modelBindInfoList中填充fieldCode和dataCode
|
|
200
|
-
* @description 我们生成fieldCode的规则是:DataBind的控件,取`field_${id}`,ObjectDataBind的控件,取`field_${id}_${key}`, key指的是ObjectDataBind.keys()
|
|
198
|
+
/**
|
|
199
|
+
* @description 给modelBindInfoList中填充fieldCode和dataCode
|
|
200
|
+
* @description 我们生成fieldCode的规则是:DataBind的控件,取`field_${id}`,ObjectDataBind的控件,取`field_${id}_${key}`, key指的是ObjectDataBind.keys()
|
|
201
201
|
* */ export function fillModelBindInfoListFieldCode(modelBindInfoList) {
|
|
202
|
-
var dataCode = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] :
|
|
202
|
+
var dataCode = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : '';
|
|
203
203
|
if (!modelBindInfoList || !Array.isArray(modelBindInfoList)) return [];
|
|
204
204
|
return modelBindInfoList.map(function(item) {
|
|
205
205
|
if (!item.dataBind) return item;
|
|
@@ -210,11 +210,12 @@ export function getMasterFormControls(controls) {
|
|
|
210
210
|
Object.keys(objectDataBind).forEach(function(key) {
|
|
211
211
|
var dataBind = objectDataBind[key];
|
|
212
212
|
// 如果是ObjectDataBind的话,需要将id拼接当前的key作为元素的fieldCode
|
|
213
|
-
var fieldCode = item.controlId +
|
|
213
|
+
var fieldCode = item.controlId + '_' + key;
|
|
214
214
|
dataBind.fieldCode = fieldCodeBeforeAddPrefix(fieldCode);
|
|
215
215
|
dataBind.dataCode = dataCode;
|
|
216
216
|
});
|
|
217
217
|
} else {
|
|
218
|
+
;
|
|
218
219
|
item.dataBind.fieldCode = fieldCodeBeforeAddPrefix(item.controlId);
|
|
219
220
|
item.dataBind.dataCode = dataCode;
|
|
220
221
|
}
|
|
@@ -222,19 +223,19 @@ export function getMasterFormControls(controls) {
|
|
|
222
223
|
});
|
|
223
224
|
}
|
|
224
225
|
function fieldCodeBeforeAddPrefix(fieldCode) {
|
|
225
|
-
var prefix =
|
|
226
|
+
var prefix = 'field_';
|
|
226
227
|
if (fieldCode.startsWith(prefix)) {
|
|
227
228
|
return fieldCode;
|
|
228
229
|
}
|
|
229
230
|
return prefix + fieldCode;
|
|
230
231
|
}
|
|
231
|
-
/**
|
|
232
|
-
* @description 通过fieldType获取列表表头的type
|
|
232
|
+
/**
|
|
233
|
+
* @description 通过fieldType获取列表表头的type
|
|
233
234
|
* */ export function getColumnTypeFromFiledType(fieldType) {
|
|
234
235
|
return FieldTypeToColumnType[fieldType];
|
|
235
236
|
}
|
|
236
|
-
/**
|
|
237
|
-
* @description 通过modelBindInfoList生成多个columns
|
|
237
|
+
/**
|
|
238
|
+
* @description 通过modelBindInfoList生成多个columns
|
|
238
239
|
* */ export function getColumnsFromModelBindInfoList(modelBindInfoList) {
|
|
239
240
|
var designer = new Designer();
|
|
240
241
|
var columns = [];
|
|
@@ -252,7 +253,7 @@ function fieldCodeBeforeAddPrefix(fieldCode) {
|
|
|
252
253
|
// 当前key对应的fieldType
|
|
253
254
|
var fieldType = objectDataBindKeyToFieldType[key].fieldType;
|
|
254
255
|
// 拼接当前列的caption
|
|
255
|
-
var caption = item.caption +
|
|
256
|
+
var caption = item.caption + '_' + objectDataBindKeyToFieldType[key].caption;
|
|
256
257
|
// 通过fieldType获取列类型
|
|
257
258
|
var controlType = getColumnTypeFromFiledType(fieldType);
|
|
258
259
|
if (!controlType) return;
|
|
@@ -260,8 +261,8 @@ function fieldCodeBeforeAddPrefix(fieldCode) {
|
|
|
260
261
|
caption: caption,
|
|
261
262
|
dataBind: dataBind
|
|
262
263
|
};
|
|
263
|
-
if (key ===
|
|
264
|
-
props.optionConfig =
|
|
264
|
+
if (key === 'currency') {
|
|
265
|
+
props.optionConfig = 'datasource';
|
|
265
266
|
props.datasourceBind = datasourceBind;
|
|
266
267
|
}
|
|
267
268
|
// @ts-ignore
|
|
@@ -389,16 +390,16 @@ var cannotEditControlTypes = [
|
|
|
389
390
|
// 列表操作列单独处理三个按钮的权限
|
|
390
391
|
var LIST_OPERATION_BUTTON_PERMISSIONS_MAPS = {
|
|
391
392
|
check: {
|
|
392
|
-
id:
|
|
393
|
-
caption:
|
|
393
|
+
id: 'listPageCheckBtnId',
|
|
394
|
+
caption: '查看'
|
|
394
395
|
},
|
|
395
396
|
edit: {
|
|
396
|
-
id:
|
|
397
|
-
caption:
|
|
397
|
+
id: 'listPageEditBtnId',
|
|
398
|
+
caption: '编辑'
|
|
398
399
|
},
|
|
399
400
|
delete: {
|
|
400
|
-
id:
|
|
401
|
-
caption:
|
|
401
|
+
id: 'listPageDeleteBtnId',
|
|
402
|
+
caption: '删除'
|
|
402
403
|
}
|
|
403
404
|
};
|
|
404
405
|
// 生成权限字段
|
|
@@ -424,11 +425,11 @@ function generatePermissions(controls, parent) {
|
|
|
424
425
|
canEdit: !cannotEditControlTypes.includes(type),
|
|
425
426
|
canRead: true,
|
|
426
427
|
canHide: true,
|
|
427
|
-
group:
|
|
428
|
+
group: 'element'
|
|
428
429
|
};
|
|
429
430
|
if (parent && parent.type === CONTROL_TYPE.SUBTABLE) {
|
|
430
431
|
// 如果有parent,则利用下划线拼接caption
|
|
431
|
-
permissionItem.caption = parent.caption +
|
|
432
|
+
permissionItem.caption = parent.caption + '_' + permissionItem.caption;
|
|
432
433
|
}
|
|
433
434
|
if (type === CONTROL_TYPE.VUE_FORM_ITEM) {
|
|
434
435
|
permissionItem.caption = controls.props.controlExportName || controls.name;
|
|
@@ -441,19 +442,19 @@ function generatePermissions(controls, parent) {
|
|
|
441
442
|
var //@ts-ignore
|
|
442
443
|
_controls_props_dataBind, _controls_props1, //@ts-ignore
|
|
443
444
|
_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 =
|
|
445
|
+
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) !== '') {
|
|
446
|
+
permissionItem.group = 'field';
|
|
446
447
|
}
|
|
447
448
|
}
|
|
448
449
|
result.push(permissionItem);
|
|
449
450
|
//追加vue容器权限
|
|
450
451
|
if (type === CONTROL_TYPE.VUE_FORM_ITEM) {
|
|
451
452
|
var _controls_props_dataBind2, _controls_props3, _controls_props_dataBind3, _controls_props4;
|
|
452
|
-
var vueFormItemGroup =
|
|
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 =
|
|
453
|
+
var vueFormItemGroup = 'element';
|
|
454
|
+
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) !== '') {
|
|
455
|
+
vueFormItemGroup = 'field';
|
|
455
456
|
}
|
|
456
|
-
var permissions = controls.props[
|
|
457
|
+
var permissions = controls.props['permissions'];
|
|
457
458
|
permissions === null || permissions === void 0 ? void 0 : permissions.map(function(item) {
|
|
458
459
|
var _controls_id;
|
|
459
460
|
permissionItem = {
|
|
@@ -487,7 +488,7 @@ function generatePermissions(controls, parent) {
|
|
|
487
488
|
canEdit: false,
|
|
488
489
|
canRead: false,
|
|
489
490
|
canHide: true,
|
|
490
|
-
group:
|
|
491
|
+
group: 'element'
|
|
491
492
|
});
|
|
492
493
|
}
|
|
493
494
|
return result;
|