@byteluck-fe/model-driven-upgrade 3.0.0-beta.5 → 3.0.0-beta.6
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/package.json +5 -5
- package/dist/esm/VersionBuilder.js +0 -133
- package/dist/esm/index.js +0 -2
- package/dist/esm/types.js +0 -1
- package/dist/esm/upgrade/index.js +0 -54
- package/dist/esm/upgrade/v1_0.js +0 -647
- package/dist/esm/upgrade/v2_0.js +0 -30
- package/dist/esm/upgrade/v2_1.js +0 -45
- package/dist/esm/upgrade/v2_10.js +0 -53
- package/dist/esm/upgrade/v2_2.js +0 -40
- package/dist/esm/upgrade/v2_3.js +0 -37
- package/dist/esm/upgrade/v2_4.js +0 -23
- package/dist/esm/upgrade/v2_5.js +0 -19
- package/dist/esm/upgrade/v2_6.js +0 -55
- package/dist/esm/upgrade/v2_7.js +0 -29
- package/dist/esm/upgrade/v2_8.js +0 -32
- package/dist/esm/upgrade/v2_9.js +0 -60
- package/dist/esm/upgrade/v3_0.js +0 -147
- package/dist/esm/upgrade/v3_1.js +0 -261
- package/dist/esm/upgrade/v3_10.js +0 -71
- package/dist/esm/upgrade/v3_11.js +0 -50
- package/dist/esm/upgrade/v3_12.js +0 -31
- package/dist/esm/upgrade/v3_2.js +0 -77
- package/dist/esm/upgrade/v3_3.js +0 -83
- package/dist/esm/upgrade/v3_4.js +0 -78
- package/dist/esm/upgrade/v3_5.js +0 -89
- package/dist/esm/upgrade/v3_6.js +0 -59
- package/dist/esm/upgrade/v3_7.js +0 -53
- package/dist/esm/upgrade/v3_8.js +0 -201
- package/dist/index.umd.js +0 -1
- package/dist/types/VersionBuilder.d.ts +0 -11
- package/dist/types/index.d.ts +0 -2
- package/dist/types/types.d.ts +0 -18
- package/dist/types/upgrade/index.d.ts +0 -28
- package/dist/types/upgrade/v1_0.d.ts +0 -3
- package/dist/types/upgrade/v2_0.d.ts +0 -3
- package/dist/types/upgrade/v2_1.d.ts +0 -3
- package/dist/types/upgrade/v2_10.d.ts +0 -3
- package/dist/types/upgrade/v2_2.d.ts +0 -3
- package/dist/types/upgrade/v2_3.d.ts +0 -3
- package/dist/types/upgrade/v2_4.d.ts +0 -3
- package/dist/types/upgrade/v2_5.d.ts +0 -3
- package/dist/types/upgrade/v2_6.d.ts +0 -3
- package/dist/types/upgrade/v2_7.d.ts +0 -3
- package/dist/types/upgrade/v2_8.d.ts +0 -3
- package/dist/types/upgrade/v2_9.d.ts +0 -3
- package/dist/types/upgrade/v3_0.d.ts +0 -3
- package/dist/types/upgrade/v3_1.d.ts +0 -3
- package/dist/types/upgrade/v3_10.d.ts +0 -3
- package/dist/types/upgrade/v3_11.d.ts +0 -3
- package/dist/types/upgrade/v3_12.d.ts +0 -3
- package/dist/types/upgrade/v3_2.d.ts +0 -3
- package/dist/types/upgrade/v3_3.d.ts +0 -3
- package/dist/types/upgrade/v3_4.d.ts +0 -3
- package/dist/types/upgrade/v3_5.d.ts +0 -3
- package/dist/types/upgrade/v3_6.d.ts +0 -3
- package/dist/types/upgrade/v3_7.d.ts +0 -3
- package/dist/types/upgrade/v3_8.d.ts +0 -3
package/dist/esm/upgrade/v1_0.js
DELETED
|
@@ -1,647 +0,0 @@
|
|
|
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_with_holes(arr) {
|
|
7
|
-
if (Array.isArray(arr)) return arr;
|
|
8
|
-
}
|
|
9
|
-
function _array_without_holes(arr) {
|
|
10
|
-
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
11
|
-
}
|
|
12
|
-
function _iterable_to_array(iter) {
|
|
13
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
14
|
-
}
|
|
15
|
-
function _iterable_to_array_limit(arr, i) {
|
|
16
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
17
|
-
if (_i == null) return;
|
|
18
|
-
var _arr = [];
|
|
19
|
-
var _n = true;
|
|
20
|
-
var _d = false;
|
|
21
|
-
var _s, _e;
|
|
22
|
-
try {
|
|
23
|
-
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
24
|
-
_arr.push(_s.value);
|
|
25
|
-
if (i && _arr.length === i) break;
|
|
26
|
-
}
|
|
27
|
-
} catch (err) {
|
|
28
|
-
_d = true;
|
|
29
|
-
_e = err;
|
|
30
|
-
} finally{
|
|
31
|
-
try {
|
|
32
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
33
|
-
} finally{
|
|
34
|
-
if (_d) throw _e;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return _arr;
|
|
38
|
-
}
|
|
39
|
-
function _non_iterable_rest() {
|
|
40
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
41
|
-
}
|
|
42
|
-
function _non_iterable_spread() {
|
|
43
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
44
|
-
}
|
|
45
|
-
function _sliced_to_array(arr, i) {
|
|
46
|
-
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
47
|
-
}
|
|
48
|
-
function _to_consumable_array(arr) {
|
|
49
|
-
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
50
|
-
}
|
|
51
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
52
|
-
if (!o) return;
|
|
53
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
54
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
55
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
56
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
57
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
58
|
-
}
|
|
59
|
-
import { loop, toNumberOrEmpty, isLanguageObject, camelizeKeys, decamelizeKeys, CONTROL_TYPE } from '@byteluck-fe/model-driven-shared';
|
|
60
|
-
import { DataSourceBind } from '@byteluck-fe/model-driven-core';
|
|
61
|
-
import { Col, SubTableColumn, ListView, DataView } from '@byteluck-fe/model-driven-controls';
|
|
62
|
-
var dataCleaner = function(schemaItems, payload) {
|
|
63
|
-
var isArray = Array.isArray(schemaItems);
|
|
64
|
-
var schemaArray = isArray ? schemaItems : [
|
|
65
|
-
schemaItems
|
|
66
|
-
];
|
|
67
|
-
conversionPageEvents(payload === null || payload === void 0 ? void 0 : payload.events);
|
|
68
|
-
conversionGroupPanel(schemaArray);
|
|
69
|
-
conversionLayoutControl(schemaArray);
|
|
70
|
-
var dataView = conversionDataViewPage(schemaArray);
|
|
71
|
-
var gridTable = conversionListPage(dataView, payload);
|
|
72
|
-
var new_schema = decamelizeKeys(loop(gridTable, function(item) {
|
|
73
|
-
return conversion(item, payload);
|
|
74
|
-
}));
|
|
75
|
-
return isArray ? new_schema : new_schema[0];
|
|
76
|
-
};
|
|
77
|
-
var baseControlKeys = [
|
|
78
|
-
CONTROL_TYPE.DIVIDER,
|
|
79
|
-
CONTROL_TYPE.TEXT,
|
|
80
|
-
CONTROL_TYPE.TITLE,
|
|
81
|
-
CONTROL_TYPE.LINK,
|
|
82
|
-
CONTROL_TYPE.BUTTON,
|
|
83
|
-
'list-btn-export-list',
|
|
84
|
-
'list-btn-export-record'
|
|
85
|
-
];
|
|
86
|
-
var listControlKeys = [
|
|
87
|
-
'subtable',
|
|
88
|
-
'grid-table'
|
|
89
|
-
];
|
|
90
|
-
var searchViewControlKeys = [
|
|
91
|
-
'simple-search'
|
|
92
|
-
];
|
|
93
|
-
function conversion(item, payload) {
|
|
94
|
-
var _item_props, _item_props1, _item_props2;
|
|
95
|
-
var new_item = item;
|
|
96
|
-
if (!new_item.controlType) {
|
|
97
|
-
if (new_item.is_layout_control === true) {
|
|
98
|
-
new_item.controlType = 'layout';
|
|
99
|
-
} else if (baseControlKeys.includes(new_item.type)) {
|
|
100
|
-
new_item.controlType = 'base';
|
|
101
|
-
} else {
|
|
102
|
-
new_item.controlType = 'form';
|
|
103
|
-
}
|
|
104
|
-
// 放在这个位置,而不是else if是因为原来的subtable是一个form控件
|
|
105
|
-
if (listControlKeys.includes(new_item.type)) {
|
|
106
|
-
new_item.controlType = 'list';
|
|
107
|
-
}
|
|
108
|
-
if (searchViewControlKeys.includes(new_item.type)) {
|
|
109
|
-
new_item.controlType = 'search-view';
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
delete new_item.is_layout_control;
|
|
113
|
-
if (item.props.lable_position) {
|
|
114
|
-
item.props.labelPosition = item.props.lable_position;
|
|
115
|
-
}
|
|
116
|
-
// 排列方式
|
|
117
|
-
if (item.props.select_mode) {
|
|
118
|
-
item.props.optionsFormat = item.props.select_mode;
|
|
119
|
-
}
|
|
120
|
-
// 默认值
|
|
121
|
-
if (item.props.value) {
|
|
122
|
-
item.props.defaultValue = item.props.value;
|
|
123
|
-
}
|
|
124
|
-
//caption/placeholder/placeholder_end 的 zh 属性将被保留,国际化资源都丢弃,放到外部
|
|
125
|
-
if (isLanguageObject(item === null || item === void 0 ? void 0 : (_item_props = item.props) === null || _item_props === void 0 ? void 0 : _item_props.caption)) {
|
|
126
|
-
new_item.props.caption = item.props.caption.zh;
|
|
127
|
-
}
|
|
128
|
-
if (isLanguageObject(item === null || item === void 0 ? void 0 : (_item_props1 = item.props) === null || _item_props1 === void 0 ? void 0 : _item_props1.placeholder)) {
|
|
129
|
-
new_item.props.placeholder = item.props.placeholder.zh;
|
|
130
|
-
}
|
|
131
|
-
if (isLanguageObject(item === null || item === void 0 ? void 0 : (_item_props2 = item.props) === null || _item_props2 === void 0 ? void 0 : _item_props2.placeholder_end)) {
|
|
132
|
-
new_item.props.placeholder_end = item.props.placeholder_end.zh;
|
|
133
|
-
}
|
|
134
|
-
// 部门组件
|
|
135
|
-
if (item.type === 'department-search') {
|
|
136
|
-
new_item.type = 'department';
|
|
137
|
-
if (item.props.value.length) {
|
|
138
|
-
new_item.props.default_value = item.props.value;
|
|
139
|
-
}
|
|
140
|
-
new_item.props.showType = item.props.show_tree ? 'tree' : 'default';
|
|
141
|
-
new_item.props.rangeOptions = item.props.department_list;
|
|
142
|
-
}
|
|
143
|
-
if (item.type === 'automatic-number') {
|
|
144
|
-
new_item.type = 'auto-number';
|
|
145
|
-
new_item.props.defaultValue = item.props.value;
|
|
146
|
-
}
|
|
147
|
-
// 附件类型转换
|
|
148
|
-
if (item.type === 'file') {
|
|
149
|
-
var _item_attachment_format;
|
|
150
|
-
new_item.type = 'attachment';
|
|
151
|
-
new_item.props.attachmentAccept = (_item_attachment_format = item.attachment_format) === null || _item_attachment_format === void 0 ? void 0 : _item_attachment_format.split(',');
|
|
152
|
-
new_item.props.showType = item.props.show_type === 'title' ? 'default' : 'table';
|
|
153
|
-
}
|
|
154
|
-
if (item.type === 'image') {
|
|
155
|
-
var _item_attachment_format1;
|
|
156
|
-
new_item.props.attachmentAccept = (_item_attachment_format1 = item.attachment_format) === null || _item_attachment_format1 === void 0 ? void 0 : _item_attachment_format1.split(',');
|
|
157
|
-
}
|
|
158
|
-
// 日期选择转换
|
|
159
|
-
if (item.type === 'date-pick') {
|
|
160
|
-
new_item.type = 'date-picker';
|
|
161
|
-
}
|
|
162
|
-
if (item.type === 'rich-text') {
|
|
163
|
-
if (isLanguageObject(item.props.value)) {
|
|
164
|
-
new_item.props.defaultValue = item.props.value.zh;
|
|
165
|
-
} else {
|
|
166
|
-
new_item.props.defaultValue = item.props.value;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
if ([
|
|
170
|
-
'link',
|
|
171
|
-
'text',
|
|
172
|
-
'button'
|
|
173
|
-
].includes(item.type)) {
|
|
174
|
-
if (isLanguageObject(item.props.value)) {
|
|
175
|
-
new_item.props.content = item.props.value.zh;
|
|
176
|
-
} else {
|
|
177
|
-
new_item.props.content = item.props.value;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
if (item.type === 'text') {
|
|
181
|
-
if (item.props.showState === 'iconText') {
|
|
182
|
-
new_item.props.showState = 'image';
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
if (item.type === 'user-search') {
|
|
186
|
-
new_item.type = 'employee';
|
|
187
|
-
new_item.props.defaultValue = item.props.value;
|
|
188
|
-
}
|
|
189
|
-
if (item.type === 'address') {
|
|
190
|
-
new_item.props.addressType = item.props.address_type_value;
|
|
191
|
-
}
|
|
192
|
-
//明细子表去掉 subtable-row,保留 subtable-column
|
|
193
|
-
if (new_item.type === 'subtable') {
|
|
194
|
-
var _new_item_children_;
|
|
195
|
-
// 转换打开方式
|
|
196
|
-
var entryType = new_item.props.entry_type || new_item.props.entryType;
|
|
197
|
-
new_item.props.openType = entryType === 'subpage' ? 'modal' : 'default';
|
|
198
|
-
if (((_new_item_children_ = new_item.children[0]) === null || _new_item_children_ === void 0 ? void 0 : _new_item_children_.type) === 'subtable-row') {
|
|
199
|
-
if (new_item.props.headers) {
|
|
200
|
-
new_item.props.headers = new_item.props.headers.map(function(item, index) {
|
|
201
|
-
var subtableColumn = new SubTableColumn.Designer();
|
|
202
|
-
// subtableColumn.props.widthType =
|
|
203
|
-
// item.header_width_config === '1' ? 'auto' : 'px'
|
|
204
|
-
// subtableColumn.props.width =
|
|
205
|
-
// item.header_width === '' ? 200 : Number(item.header_width)
|
|
206
|
-
subtableColumn.props.caption = isLanguageObject(item.field_name) ? item.field_name['zh'] : item.field_name;
|
|
207
|
-
var schema = subtableColumn.toSchema();
|
|
208
|
-
schema.id = item.header_id;
|
|
209
|
-
var child = new_item.children[0].children[index].children[0];
|
|
210
|
-
!!child && (schema.children = [
|
|
211
|
-
child
|
|
212
|
-
]);
|
|
213
|
-
return schema;
|
|
214
|
-
});
|
|
215
|
-
new_item.children = [];
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
if (new_item.type === 'subtable-cell') {
|
|
220
|
-
new_item.type = 'subtable-column';
|
|
221
|
-
}
|
|
222
|
-
var optionsControl = [
|
|
223
|
-
'radio',
|
|
224
|
-
'checkbox',
|
|
225
|
-
'select',
|
|
226
|
-
'select-multiple'
|
|
227
|
-
];
|
|
228
|
-
//radio / checkbox 中 options text 的 zh 属性保留 国际化资源丢弃
|
|
229
|
-
if (optionsControl.includes(item.type)) {
|
|
230
|
-
item.props.options.map(function(option) {
|
|
231
|
-
option.label = isLanguageObject(option.text) ? option.text.zh : option.text;
|
|
232
|
-
option.id = option.id || option.opt_id || option.optId || option.data_id;
|
|
233
|
-
});
|
|
234
|
-
new_item = item;
|
|
235
|
-
}
|
|
236
|
-
// grid-row 更改type,并且添加col控件
|
|
237
|
-
if (item.type === 'grid-row') {
|
|
238
|
-
var span = 24 / new_item.children.length;
|
|
239
|
-
new_item.children = new_item.children.map(function(child) {
|
|
240
|
-
var newCol = new Col.Designer();
|
|
241
|
-
newCol.props.span = span;
|
|
242
|
-
var schema = newCol.toSchema();
|
|
243
|
-
schema.children.push(child);
|
|
244
|
-
return schema;
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
// grid-layout-row 更改type
|
|
248
|
-
if (item.type === 'grid-layout-row') {
|
|
249
|
-
new_item.type = 'row';
|
|
250
|
-
}
|
|
251
|
-
if (item.type === 'grid-layout-col') {
|
|
252
|
-
new_item.type = 'col';
|
|
253
|
-
}
|
|
254
|
-
if (item.type === 'group-panel') {
|
|
255
|
-
new_item.type = 'card-group';
|
|
256
|
-
new_item.props.collapse = new_item.props.flod === 'no' ? 'none' : new_item.props.flod;
|
|
257
|
-
}
|
|
258
|
-
// tabs-pane => tab-pane
|
|
259
|
-
if (item.type === 'tabs-pane') {
|
|
260
|
-
new_item.type = 'tab-pane';
|
|
261
|
-
}
|
|
262
|
-
if (item.type === 'calc') {
|
|
263
|
-
var calcValue = new_item === null || new_item === void 0 ? void 0 : new_item.children[0];
|
|
264
|
-
var calcUnit = new_item === null || new_item === void 0 ? void 0 : new_item.children[1];
|
|
265
|
-
var newDataBind = {};
|
|
266
|
-
if (calcValue) {
|
|
267
|
-
conversionDisplayBoListAndBehaviors(new_item, payload);
|
|
268
|
-
newDataBind.result = calcValue.props.data_bind;
|
|
269
|
-
new_item.id = calcValue.id;
|
|
270
|
-
new_item.props = calcValue.props;
|
|
271
|
-
new_item.props.script_src = calcValue.props.script_src;
|
|
272
|
-
new_item.props.script_echo = calcValue.props.script_echo;
|
|
273
|
-
new_item.props.precision = calcValue.props.precision;
|
|
274
|
-
new_item.props.micrometer = calcValue.props.is_show_money;
|
|
275
|
-
new_item.props.showUpperCase = calcValue.props.is_show_chn;
|
|
276
|
-
}
|
|
277
|
-
if (calcUnit) {
|
|
278
|
-
newDataBind.unit = calcUnit.props.data_bind;
|
|
279
|
-
new_item.props.default_value = {
|
|
280
|
-
unit: calcUnit.props.value
|
|
281
|
-
};
|
|
282
|
-
}
|
|
283
|
-
new_item.props.dataBind = newDataBind;
|
|
284
|
-
delete new_item.children;
|
|
285
|
-
}
|
|
286
|
-
if (item.type === 'amount-currency') {
|
|
287
|
-
new_item.type = 'amount';
|
|
288
|
-
new_item.controlType = 'form';
|
|
289
|
-
var amount = new_item === null || new_item === void 0 ? void 0 : new_item.children[0];
|
|
290
|
-
var currency = new_item === null || new_item === void 0 ? void 0 : new_item.children[1];
|
|
291
|
-
var newDataBind1 = {};
|
|
292
|
-
var defaultValue = {};
|
|
293
|
-
// new_item.
|
|
294
|
-
if (amount) {
|
|
295
|
-
conversionDisplayBoListAndBehaviors(new_item, payload);
|
|
296
|
-
new_item.id = amount.id;
|
|
297
|
-
newDataBind1.amount = amount.props.data_bind;
|
|
298
|
-
new_item.props.range_min = toNumberOrEmpty(amount.props.range_min);
|
|
299
|
-
new_item.props.range_max = toNumberOrEmpty(amount.props.range_max);
|
|
300
|
-
defaultValue.amount = toNumberOrEmpty(amount.props.value);
|
|
301
|
-
new_item.props.required = amount.props.required;
|
|
302
|
-
new_item.props.is_hide = amount.props.is_hide;
|
|
303
|
-
new_item.props.default_state = amount.props.default_state;
|
|
304
|
-
new_item.props.caption = isLanguageObject(amount.props.caption) ? amount.props.caption.zh : amount.props.caption;
|
|
305
|
-
new_item.props.is_hide_caption = amount.props.is_hide_caption;
|
|
306
|
-
new_item.props.showUpperCase = amount.props.is_show_chn;
|
|
307
|
-
}
|
|
308
|
-
if (currency) {
|
|
309
|
-
newDataBind1.currency = currency.props.data_bind;
|
|
310
|
-
defaultValue.currency = currency.props.value;
|
|
311
|
-
new_item.props.datasourceBind = currency.props.datasource_bind;
|
|
312
|
-
new_item.props.options = currency.props.options.map(function(item) {
|
|
313
|
-
return {
|
|
314
|
-
label: item.text,
|
|
315
|
-
value: item.value
|
|
316
|
-
};
|
|
317
|
-
});
|
|
318
|
-
}
|
|
319
|
-
new_item.props.dataBind = newDataBind1;
|
|
320
|
-
new_item.props.defaultValue = defaultValue;
|
|
321
|
-
delete new_item.children;
|
|
322
|
-
}
|
|
323
|
-
if (item.type === 'date-range') {
|
|
324
|
-
new_item.controlType = 'form';
|
|
325
|
-
var min = new_item === null || new_item === void 0 ? void 0 : new_item.children[0];
|
|
326
|
-
var max = new_item === null || new_item === void 0 ? void 0 : new_item.children[1];
|
|
327
|
-
new_item.props.placeholderStart = isLanguageObject(item.props.placeholder) ? item.props.placeholder.zh : item.props.placeholder;
|
|
328
|
-
new_item.props.caption = isLanguageObject(item.props.caption) ? item.props.caption.zh : item.props.caption;
|
|
329
|
-
var newDataBind2 = {};
|
|
330
|
-
if (min) {
|
|
331
|
-
newDataBind2.min = min.props.data_bind;
|
|
332
|
-
}
|
|
333
|
-
if (max) {
|
|
334
|
-
newDataBind2.max = max.props.data_bind;
|
|
335
|
-
}
|
|
336
|
-
new_item.props.dataBind = newDataBind2;
|
|
337
|
-
delete new_item.children;
|
|
338
|
-
}
|
|
339
|
-
if (item.type === 'score') {
|
|
340
|
-
new_item.props.defaultValue = new_item.props.value * 1;
|
|
341
|
-
}
|
|
342
|
-
if ([
|
|
343
|
-
'input',
|
|
344
|
-
'textarea'
|
|
345
|
-
].includes(item.type)) {
|
|
346
|
-
new_item.props.defaultValue = isLanguageObject(item.props.value) ? item.props.value.zh : item.props.value;
|
|
347
|
-
}
|
|
348
|
-
if (item.type === 'number') {
|
|
349
|
-
new_item.props.range_min = toNumberOrEmpty(item.props.range_min);
|
|
350
|
-
new_item.props.range_max = toNumberOrEmpty(item.props.range_max);
|
|
351
|
-
new_item.props.defaultValue = toNumberOrEmpty(item.props.value);
|
|
352
|
-
}
|
|
353
|
-
if (item.type === 'list-page-btn-custom-button') {
|
|
354
|
-
item.type = 'button';
|
|
355
|
-
}
|
|
356
|
-
if (item.type === 'button') {
|
|
357
|
-
if (item.props.button_type === 'dashed') {
|
|
358
|
-
new_item.props.buttonType = 'default';
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
conversionControlEvents(new_item, payload === null || payload === void 0 ? void 0 : payload.control_events);
|
|
362
|
-
return new_item;
|
|
363
|
-
}
|
|
364
|
-
function conversionDisplayBoListAndBehaviors(control, payload) {
|
|
365
|
-
if (!payload) return;
|
|
366
|
-
var _payload_displayBoList = payload.displayBoList, displayBoList = _payload_displayBoList === void 0 ? [] : _payload_displayBoList, _payload_behaviors = payload.behaviors, behaviors = _payload_behaviors === void 0 ? [] : _payload_behaviors;
|
|
367
|
-
var controlId = control.id;
|
|
368
|
-
var newId = control.children[0].id;
|
|
369
|
-
displayBoList.forEach(function(item) {
|
|
370
|
-
if (item.id === controlId) {
|
|
371
|
-
item.id = newId;
|
|
372
|
-
}
|
|
373
|
-
var showIndex = item.show_controls.findIndex(function(id) {
|
|
374
|
-
return id === controlId;
|
|
375
|
-
});
|
|
376
|
-
var hideIndex = item.hide_controls.findIndex(function(id) {
|
|
377
|
-
return id === controlId;
|
|
378
|
-
});
|
|
379
|
-
if (showIndex > -1) {
|
|
380
|
-
item.show_controls.splice(showIndex, 1, newId);
|
|
381
|
-
}
|
|
382
|
-
if (hideIndex > -1) {
|
|
383
|
-
item.hide_controls.splice(hideIndex, 1, newId);
|
|
384
|
-
}
|
|
385
|
-
});
|
|
386
|
-
behaviors.forEach(function(item) {
|
|
387
|
-
if (item.ctrl_id === controlId) {
|
|
388
|
-
item.id = newId;
|
|
389
|
-
}
|
|
390
|
-
});
|
|
391
|
-
}
|
|
392
|
-
function conversionDataViewPage(controlArray) {
|
|
393
|
-
if (!Array.isArray(controlArray)) {
|
|
394
|
-
return controlArray;
|
|
395
|
-
}
|
|
396
|
-
var grid = controlArray.find(function(item) {
|
|
397
|
-
return item.type === 'grid';
|
|
398
|
-
});
|
|
399
|
-
if (!grid) {
|
|
400
|
-
return controlArray;
|
|
401
|
-
}
|
|
402
|
-
var dataView = new DataView.Designer();
|
|
403
|
-
var schema = dataView.toSchema();
|
|
404
|
-
schema.children = controlArray;
|
|
405
|
-
return [
|
|
406
|
-
schema
|
|
407
|
-
];
|
|
408
|
-
}
|
|
409
|
-
function conversionGroupPanel(controlArray) {
|
|
410
|
-
controlArray.forEach(function(item) {
|
|
411
|
-
if (item.children) {
|
|
412
|
-
groupPanelHandler(item.children);
|
|
413
|
-
}
|
|
414
|
-
});
|
|
415
|
-
}
|
|
416
|
-
// 如果是分组,明细子表,标签页,就把外围的grid-row去掉
|
|
417
|
-
function conversionLayoutControl(schemArray) {
|
|
418
|
-
schemArray.forEach(function(item) {
|
|
419
|
-
if (!(item && item.children)) return;
|
|
420
|
-
var controlArray = item.children;
|
|
421
|
-
for(var i = 0; i < controlArray.length; i++){
|
|
422
|
-
var _controlArray_i_children, _controlArray_i;
|
|
423
|
-
var control = controlArray[i];
|
|
424
|
-
var child = (_controlArray_i = controlArray[i]) === null || _controlArray_i === void 0 ? void 0 : (_controlArray_i_children = _controlArray_i.children) === null || _controlArray_i_children === void 0 ? void 0 : _controlArray_i_children[0];
|
|
425
|
-
if (control.type === 'grid-row' && child && [
|
|
426
|
-
'group-panel',
|
|
427
|
-
'subtable',
|
|
428
|
-
'tab'
|
|
429
|
-
].includes(child.type)) {
|
|
430
|
-
controlArray.splice(i, 1, child);
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
});
|
|
434
|
-
}
|
|
435
|
-
function conversionListPage(controlArray, payload) {
|
|
436
|
-
var _listPageProps_source_config, _listPageProps_source_config1, _listPageProps_source_config2, _listPageProps_source_config3, _listPageProps_sublist_page;
|
|
437
|
-
if (!(Array.isArray(controlArray) && controlArray.length === 1)) {
|
|
438
|
-
return controlArray;
|
|
439
|
-
}
|
|
440
|
-
var listPage = controlArray[0];
|
|
441
|
-
if (listPage.type !== 'list-page') {
|
|
442
|
-
return controlArray;
|
|
443
|
-
}
|
|
444
|
-
// children = search + toolbox + table
|
|
445
|
-
var listPageProps = listPage.props, children = listPage.children;
|
|
446
|
-
var _children = _sliced_to_array(children, 3), search = _children[0], toolbox = _children[1], table = _children[2];
|
|
447
|
-
conversionSearch(search);
|
|
448
|
-
table.props.is_fixed_header = listPageProps === null || listPageProps === void 0 ? void 0 : (_listPageProps_source_config = listPageProps.source_config) === null || _listPageProps_source_config === void 0 ? void 0 : _listPageProps_source_config.is_fixed_header;
|
|
449
|
-
// table.props.datasource_bind = new DataSourceBind({
|
|
450
|
-
// dataCode: listPageProps?.source_config?data_code,
|
|
451
|
-
// svcCode: listPageProps?.source_config?svc_code,
|
|
452
|
-
// orders: camelizeKeys(listPageProps?.source_config?orders) as any[],
|
|
453
|
-
// })
|
|
454
|
-
conversionGridTable(table, toolbox);
|
|
455
|
-
var _listPageProps_source_config_data_code;
|
|
456
|
-
var dataCode = (_listPageProps_source_config_data_code = listPageProps === null || listPageProps === void 0 ? void 0 : (_listPageProps_source_config1 = listPageProps.source_config) === null || _listPageProps_source_config1 === void 0 ? void 0 : _listPageProps_source_config1.data_code) !== null && _listPageProps_source_config_data_code !== void 0 ? _listPageProps_source_config_data_code : payload === null || payload === void 0 ? void 0 : payload.dataCode;
|
|
457
|
-
var _listPageProps_source_config_svc_code;
|
|
458
|
-
var svcCode = ((_listPageProps_source_config_svc_code = listPageProps === null || listPageProps === void 0 ? void 0 : (_listPageProps_source_config2 = listPageProps.source_config) === null || _listPageProps_source_config2 === void 0 ? void 0 : _listPageProps_source_config2.svc_code) !== null && _listPageProps_source_config_svc_code !== void 0 ? _listPageProps_source_config_svc_code : dataCode) ? "".concat(dataCode, "_selectMore") : undefined;
|
|
459
|
-
var _listPageProps_source_config_orders;
|
|
460
|
-
var orders = (_listPageProps_source_config_orders = listPageProps === null || listPageProps === void 0 ? void 0 : (_listPageProps_source_config3 = listPageProps.source_config) === null || _listPageProps_source_config3 === void 0 ? void 0 : _listPageProps_source_config3.orders) !== null && _listPageProps_source_config_orders !== void 0 ? _listPageProps_source_config_orders : [];
|
|
461
|
-
var listView = new ListView.Designer();
|
|
462
|
-
listView.props.datasourceBind = new DataSourceBind({
|
|
463
|
-
dataCode: dataCode,
|
|
464
|
-
svcCode: svcCode,
|
|
465
|
-
orders: camelizeKeys(orders)
|
|
466
|
-
});
|
|
467
|
-
listView.props.isShowSubList = listPageProps.is_show_sublist;
|
|
468
|
-
listView.props.triggerType = listPageProps.timing_type;
|
|
469
|
-
listView.props.triggerFieldCode = listPageProps.ctrl_field_code;
|
|
470
|
-
listPageProps === null || listPageProps === void 0 ? void 0 : (_listPageProps_sublist_page = listPageProps.sublist_page) === null || _listPageProps_sublist_page === void 0 ? void 0 : _listPageProps_sublist_page.sublists.forEach(function(item) {
|
|
471
|
-
item.title = isLanguageObject(item.title) ? item.title.zh : item.title;
|
|
472
|
-
});
|
|
473
|
-
listView.props.sublistPage = listPageProps.sublist_page;
|
|
474
|
-
var listViewSchema = listView.toSchema();
|
|
475
|
-
listViewSchema.children.push(search, table);
|
|
476
|
-
return [
|
|
477
|
-
listViewSchema
|
|
478
|
-
];
|
|
479
|
-
}
|
|
480
|
-
function conversionSearch(searchControl) {
|
|
481
|
-
searchControl.type = 'simple-search';
|
|
482
|
-
searchControl.control_type = 'search-view';
|
|
483
|
-
searchControl.children.forEach(function(item) {
|
|
484
|
-
var placeholder = isLanguageObject(item.placeholder) ? item.placeholder['zh'] : item.placeholder;
|
|
485
|
-
if (item.type === 'number-range') {
|
|
486
|
-
item.type = 'search-number-range';
|
|
487
|
-
item.placeholderStart = placeholder;
|
|
488
|
-
item.placeholderEnd = placeholder;
|
|
489
|
-
}
|
|
490
|
-
if (item.type === 'date-pick') {
|
|
491
|
-
var _item_dateType_replace, _item_dateType;
|
|
492
|
-
item.type = 'search-date-range';
|
|
493
|
-
item.placeholderStart = placeholder;
|
|
494
|
-
item.placeholderEnd = placeholder;
|
|
495
|
-
item.dateType = (_item_dateType = item.dateType) === null || _item_dateType === void 0 ? void 0 : (_item_dateType_replace = _item_dateType.replace) === null || _item_dateType_replace === void 0 ? void 0 : _item_dateType_replace.call(_item_dateType, /range$/);
|
|
496
|
-
}
|
|
497
|
-
if (item.type === 'automatic-number' || item.type === 'auto-number') {
|
|
498
|
-
item.type = 'search-input';
|
|
499
|
-
item.props.defaultValue = '';
|
|
500
|
-
}
|
|
501
|
-
});
|
|
502
|
-
}
|
|
503
|
-
function conversionGridTable(tableControl, toolbox) {
|
|
504
|
-
// 去掉了'list-page-btn-custom-head'按钮控件
|
|
505
|
-
tableControl.children = toolbox.children.filter(function(item) {
|
|
506
|
-
return item.type !== 'list-page-btn-custom-head';
|
|
507
|
-
});
|
|
508
|
-
tableControl.type = 'grid-table';
|
|
509
|
-
if (tableControl.props.sublist_page) {
|
|
510
|
-
tableControl.props.sublist_page.form_bind = {
|
|
511
|
-
data_code: tableControl.props.sublist_page.data_code,
|
|
512
|
-
form_key: tableControl.props.sublist_page.form_key
|
|
513
|
-
};
|
|
514
|
-
}
|
|
515
|
-
if (Array.isArray(tableControl.props.headers)) {
|
|
516
|
-
tableControl.props.headers = tableControl.props.headers.map(function(item) {
|
|
517
|
-
var obj = {
|
|
518
|
-
type: '',
|
|
519
|
-
control_type: 'column',
|
|
520
|
-
props: {
|
|
521
|
-
widthType: 'px',
|
|
522
|
-
width: 50,
|
|
523
|
-
caption: '',
|
|
524
|
-
field_code: item.field_code,
|
|
525
|
-
field_name: isLanguageObject(item.field_name) ? item.field_name['zh'] : item.field_name
|
|
526
|
-
}
|
|
527
|
-
};
|
|
528
|
-
obj.props.caption = isLanguageObject(item.field_name) ? item.field_name['zh'] : item.field_name;
|
|
529
|
-
obj.props.filter_tags = item.is_filter_tags;
|
|
530
|
-
obj.props.fixed = item.fixed;
|
|
531
|
-
obj.props.display_bo_list = item.display_bo_list;
|
|
532
|
-
obj.props.date_type = item.date_type;
|
|
533
|
-
obj.props.optionConfig = 'none';
|
|
534
|
-
if (item.header_width_config) {
|
|
535
|
-
obj.props.widthType = item.header_width_config === '1' ? 'auto' : 'px';
|
|
536
|
-
}
|
|
537
|
-
if (obj.props.widthType === 'px' && item.header_width) {
|
|
538
|
-
obj.props.width = Number(item.header_width);
|
|
539
|
-
}
|
|
540
|
-
if (item.table_header_type === 'order') {
|
|
541
|
-
obj.type = 'order-column';
|
|
542
|
-
obj.props.fixed = true;
|
|
543
|
-
} else if (item.table_header_type === 'operation') {
|
|
544
|
-
obj.type = 'operation-column';
|
|
545
|
-
var _item_check;
|
|
546
|
-
obj.props.check = (_item_check = item.check) !== null && _item_check !== void 0 ? _item_check : {};
|
|
547
|
-
obj.props.check.openType = 'window';
|
|
548
|
-
var _item_delete;
|
|
549
|
-
obj.props.delete = (_item_delete = item.delete) !== null && _item_delete !== void 0 ? _item_delete : {};
|
|
550
|
-
obj.props.delete.openType = 'window';
|
|
551
|
-
var _item_edit;
|
|
552
|
-
obj.props.edit = (_item_edit = item.edit) !== null && _item_edit !== void 0 ? _item_edit : {};
|
|
553
|
-
obj.props.edit.openType = 'window';
|
|
554
|
-
obj.props.fixed = true;
|
|
555
|
-
} else {
|
|
556
|
-
obj.type = item.field_type + '-column';
|
|
557
|
-
if (item.field_type === 'auto_number') {
|
|
558
|
-
obj.type = 'auto-number-column';
|
|
559
|
-
}
|
|
560
|
-
if (item.field_type === 'relation') {
|
|
561
|
-
obj.type = 'varchar-column';
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
if (item.convert_switch) {
|
|
565
|
-
obj.props.optionConfig = item.convert_type === 1 ? 'datasource' : 'custom';
|
|
566
|
-
}
|
|
567
|
-
if (obj.props.optionConfig === 'datasource') {
|
|
568
|
-
obj.props.datasource_bind = new DataSourceBind({
|
|
569
|
-
svcCode: item.svc_code,
|
|
570
|
-
displayBoList: item.display_bo_list,
|
|
571
|
-
valueFieldCode: item.field_match,
|
|
572
|
-
dataCode: item.field_source
|
|
573
|
-
});
|
|
574
|
-
} else if (obj.props.optionConfig === 'custom') {
|
|
575
|
-
obj.props.options = item.custom_match_bo_list;
|
|
576
|
-
}
|
|
577
|
-
return obj;
|
|
578
|
-
});
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
function groupPanelHandler(controlArray) {
|
|
582
|
-
var group = null;
|
|
583
|
-
for(var i = 0; i < controlArray.length; i++){
|
|
584
|
-
var _item_children_;
|
|
585
|
-
var item = controlArray[i];
|
|
586
|
-
if (!item) {
|
|
587
|
-
continue;
|
|
588
|
-
}
|
|
589
|
-
if (item.children && ((_item_children_ = item.children[0]) === null || _item_children_ === void 0 ? void 0 : _item_children_.type) === 'group-panel') {
|
|
590
|
-
group = item.children[0];
|
|
591
|
-
continue;
|
|
592
|
-
}
|
|
593
|
-
if (group) {
|
|
594
|
-
group.children.push(item);
|
|
595
|
-
controlArray.splice(i, 1);
|
|
596
|
-
i--;
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
}
|
|
600
|
-
function conversionPageEvents(events) {
|
|
601
|
-
if (!events) {
|
|
602
|
-
return;
|
|
603
|
-
}
|
|
604
|
-
events.did_mount = events.did_mount.map(function(item) {
|
|
605
|
-
return item.name;
|
|
606
|
-
});
|
|
607
|
-
events.will_submit = events.will_submit.map(function(item) {
|
|
608
|
-
return item.name;
|
|
609
|
-
});
|
|
610
|
-
events.did_submit = events.did_submit.map(function(item) {
|
|
611
|
-
return item.name;
|
|
612
|
-
});
|
|
613
|
-
}
|
|
614
|
-
function conversionControlEvents(control, controlEvents) {
|
|
615
|
-
var _controlEvents_control_id;
|
|
616
|
-
if (!controlEvents || !control.props.events) {
|
|
617
|
-
return;
|
|
618
|
-
}
|
|
619
|
-
var eventKeys = Object.keys(control.props.events);
|
|
620
|
-
if (!eventKeys.length) {
|
|
621
|
-
return;
|
|
622
|
-
}
|
|
623
|
-
eventKeys.forEach(function(eventKey) {
|
|
624
|
-
var _controlEvents_control_id_eventKey;
|
|
625
|
-
if (!control.props.events[eventKey].length) {
|
|
626
|
-
return;
|
|
627
|
-
}
|
|
628
|
-
if (!controlEvents[control.id]) {
|
|
629
|
-
controlEvents[control.id] = {};
|
|
630
|
-
}
|
|
631
|
-
if (!controlEvents[control.id][eventKey]) {
|
|
632
|
-
controlEvents[control.id][eventKey] = [];
|
|
633
|
-
}
|
|
634
|
-
(_controlEvents_control_id_eventKey = controlEvents[control.id][eventKey]).push.apply(_controlEvents_control_id_eventKey, _to_consumable_array(control.props.events[eventKey].map(function(item) {
|
|
635
|
-
return item.name;
|
|
636
|
-
})));
|
|
637
|
-
});
|
|
638
|
-
// 将失焦事件转换为change事件
|
|
639
|
-
if ((_controlEvents_control_id = controlEvents[control.id]) === null || _controlEvents_control_id === void 0 ? void 0 : _controlEvents_control_id.on_blur) {
|
|
640
|
-
var _controlEvents_control_id_on_change;
|
|
641
|
-
if (!controlEvents[control.id].on_change) {
|
|
642
|
-
controlEvents[control.id].on_change = [];
|
|
643
|
-
}
|
|
644
|
-
(_controlEvents_control_id_on_change = controlEvents[control.id].on_change).push.apply(_controlEvents_control_id_on_change, _to_consumable_array(controlEvents[control.id].on_blur));
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
export { dataCleaner };
|
package/dist/esm/upgrade/v2_0.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { decamelizeKeys, loop, CONTROL_TYPE } from '@byteluck-fe/model-driven-shared';
|
|
2
|
-
import { DataBind } from '@byteluck-fe/model-driven-core';
|
|
3
|
-
var dataCleaner = function(schemaItems, payload) {
|
|
4
|
-
var isArray = Array.isArray(schemaItems);
|
|
5
|
-
var schemaArray = isArray ? schemaItems : [
|
|
6
|
-
schemaItems
|
|
7
|
-
];
|
|
8
|
-
var new_schema = decamelizeKeys(loop(schemaArray, function(item) {
|
|
9
|
-
return conversion(item, payload);
|
|
10
|
-
}));
|
|
11
|
-
return isArray ? new_schema : new_schema[0];
|
|
12
|
-
};
|
|
13
|
-
function conversion(schema, payload) {
|
|
14
|
-
// 列表页表格的头,添加dataBind属性
|
|
15
|
-
if (schema.type === CONTROL_TYPE.LIST_VIEW) {
|
|
16
|
-
var gridTable = schema.children.find(function(item) {
|
|
17
|
-
return item.type === CONTROL_TYPE.GRID_TABLE;
|
|
18
|
-
});
|
|
19
|
-
gridTable.props.headers.forEach(function(column) {
|
|
20
|
-
if (!column.props.data_bind && column.props.field_code) {
|
|
21
|
-
column.props.data_bind = new DataBind({
|
|
22
|
-
dataCode: schema.props.datasource_bind.data_code,
|
|
23
|
-
fieldCode: column.props.field_code
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
return schema;
|
|
29
|
-
}
|
|
30
|
-
export { dataCleaner };
|