@byteluck-fe/model-driven-upgrade 1.3.0-beta.25 → 1.5.0-beta.2
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/VersionBuilder.js +117 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/upgrade/index.js +26 -0
- package/dist/esm/upgrade/v1_0.js +645 -0
- package/dist/esm/upgrade/v2_0.js +30 -0
- package/dist/esm/upgrade/v2_1.js +45 -0
- package/dist/esm/upgrade/v2_2.js +40 -0
- package/dist/esm/upgrade/v2_3.js +37 -0
- package/dist/esm/upgrade/v2_4.js +23 -0
- package/dist/esm/upgrade/v2_5.js +19 -0
- package/dist/esm/upgrade/v2_6.js +55 -0
- package/dist/esm/upgrade/v2_7.js +29 -0
- package/dist/esm/upgrade/v2_8.js +32 -0
- package/dist/index.umd.js +1 -0
- package/dist/types/VersionBuilder.d.ts +13 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/types.d.ts +11 -0
- package/dist/types/upgrade/index.d.ts +14 -0
- package/dist/types/upgrade/v1_0.d.ts +3 -0
- package/dist/types/upgrade/v2_0.d.ts +3 -0
- package/dist/types/upgrade/v2_1.d.ts +3 -0
- package/dist/types/upgrade/v2_2.d.ts +3 -0
- package/dist/types/upgrade/v2_3.d.ts +3 -0
- package/dist/types/upgrade/v2_4.d.ts +3 -0
- package/dist/types/upgrade/v2_5.d.ts +3 -0
- package/dist/types/upgrade/v2_6.d.ts +3 -0
- package/dist/types/upgrade/v2_7.d.ts +3 -0
- package/dist/types/upgrade/v2_8.d.ts +3 -0
- package/package.json +6 -6
- package/src/index.ts +0 -2
|
@@ -0,0 +1,645 @@
|
|
|
1
|
+
function _arrayLikeToArray(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 _arrayWithHoles(arr) {
|
|
7
|
+
if (Array.isArray(arr)) return arr;
|
|
8
|
+
}
|
|
9
|
+
function _arrayWithoutHoles(arr) {
|
|
10
|
+
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
11
|
+
}
|
|
12
|
+
function _iterableToArray(iter) {
|
|
13
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
14
|
+
}
|
|
15
|
+
function _iterableToArrayLimit(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 _nonIterableRest() {
|
|
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 _nonIterableSpread() {
|
|
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 _slicedToArray(arr, i) {
|
|
46
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
47
|
+
}
|
|
48
|
+
function _toConsumableArray(arr) {
|
|
49
|
+
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
50
|
+
}
|
|
51
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
52
|
+
if (!o) return;
|
|
53
|
+
if (typeof o === "string") return _arrayLikeToArray(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 _arrayLikeToArray(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 ref, ref1, ref2;
|
|
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 : (ref = item.props) === null || ref === void 0 ? void 0 : ref.caption)) {
|
|
126
|
+
new_item.props.caption = item.props.caption.zh;
|
|
127
|
+
}
|
|
128
|
+
if (isLanguageObject(item === null || item === void 0 ? void 0 : (ref1 = item.props) === null || ref1 === void 0 ? void 0 : ref1.placeholder)) {
|
|
129
|
+
new_item.props.placeholder = item.props.placeholder.zh;
|
|
130
|
+
}
|
|
131
|
+
if (isLanguageObject(item === null || item === void 0 ? void 0 : (ref2 = item.props) === null || ref2 === void 0 ? void 0 : ref2.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 ref3;
|
|
150
|
+
new_item.type = "attachment";
|
|
151
|
+
new_item.props.attachmentAccept = (ref3 = item.attachment_format) === null || ref3 === void 0 ? void 0 : ref3.split(",");
|
|
152
|
+
new_item.props.showType = item.props.show_type === "title" ? "default" : "table";
|
|
153
|
+
}
|
|
154
|
+
if (item.type === "image") {
|
|
155
|
+
var ref4;
|
|
156
|
+
new_item.props.attachmentAccept = (ref4 = item.attachment_format) === null || ref4 === void 0 ? void 0 : ref4.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 ref5;
|
|
195
|
+
// 转换打开方式
|
|
196
|
+
var entryType = new_item.props.entry_type || new_item.props.entryType;
|
|
197
|
+
new_item.props.openType = entryType === "subpage" ? "modal" : "default";
|
|
198
|
+
if (((ref5 = new_item.children[0]) === null || ref5 === void 0 ? void 0 : ref5.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 = item.header_width_config === "1" ? "auto" : "px";
|
|
203
|
+
subtableColumn.props.width = item.header_width === "" ? 200 : Number(item.header_width);
|
|
204
|
+
subtableColumn.props.caption = isLanguageObject(item.field_name) ? item.field_name["zh"] : item.field_name;
|
|
205
|
+
var schema = subtableColumn.toSchema();
|
|
206
|
+
schema.id = item.header_id;
|
|
207
|
+
var child = new_item.children[0].children[index].children[0];
|
|
208
|
+
!!child && (schema.children = [
|
|
209
|
+
child
|
|
210
|
+
]);
|
|
211
|
+
return schema;
|
|
212
|
+
});
|
|
213
|
+
new_item.children = [];
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
if (new_item.type === "subtable-cell") {
|
|
218
|
+
new_item.type = "subtable-column";
|
|
219
|
+
}
|
|
220
|
+
var optionsControl = [
|
|
221
|
+
"radio",
|
|
222
|
+
"checkbox",
|
|
223
|
+
"select",
|
|
224
|
+
"select-multiple"
|
|
225
|
+
];
|
|
226
|
+
//radio / checkbox 中 options text 的 zh 属性保留 国际化资源丢弃
|
|
227
|
+
if (optionsControl.includes(item.type)) {
|
|
228
|
+
item.props.options.map(function(option) {
|
|
229
|
+
option.label = isLanguageObject(option.text) ? option.text.zh : option.text;
|
|
230
|
+
option.id = option.id || option.opt_id || option.optId || option.data_id;
|
|
231
|
+
});
|
|
232
|
+
new_item = item;
|
|
233
|
+
}
|
|
234
|
+
// grid-row 更改type,并且添加col控件
|
|
235
|
+
if (item.type === "grid-row") {
|
|
236
|
+
var span = 24 / new_item.children.length;
|
|
237
|
+
new_item.children = new_item.children.map(function(child) {
|
|
238
|
+
var newCol = new Col.Designer();
|
|
239
|
+
newCol.props.span = span;
|
|
240
|
+
var schema = newCol.toSchema();
|
|
241
|
+
schema.children.push(child);
|
|
242
|
+
return schema;
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
// grid-layout-row 更改type
|
|
246
|
+
if (item.type === "grid-layout-row") {
|
|
247
|
+
new_item.type = "row";
|
|
248
|
+
}
|
|
249
|
+
if (item.type === "grid-layout-col") {
|
|
250
|
+
new_item.type = "col";
|
|
251
|
+
}
|
|
252
|
+
if (item.type === "group-panel") {
|
|
253
|
+
new_item.type = "card-group";
|
|
254
|
+
new_item.props.collapse = new_item.props.flod === "no" ? "none" : new_item.props.flod;
|
|
255
|
+
}
|
|
256
|
+
// tabs-pane => tab-pane
|
|
257
|
+
if (item.type === "tabs-pane") {
|
|
258
|
+
new_item.type = "tab-pane";
|
|
259
|
+
}
|
|
260
|
+
if (item.type === "calc") {
|
|
261
|
+
var calcValue = new_item === null || new_item === void 0 ? void 0 : new_item.children[0];
|
|
262
|
+
var calcUnit = new_item === null || new_item === void 0 ? void 0 : new_item.children[1];
|
|
263
|
+
var newDataBind = {};
|
|
264
|
+
if (calcValue) {
|
|
265
|
+
conversionDisplayBoListAndBehaviors(new_item, payload);
|
|
266
|
+
newDataBind.result = calcValue.props.data_bind;
|
|
267
|
+
new_item.id = calcValue.id;
|
|
268
|
+
new_item.props = calcValue.props;
|
|
269
|
+
new_item.props.script_src = calcValue.props.script_src;
|
|
270
|
+
new_item.props.script_echo = calcValue.props.script_echo;
|
|
271
|
+
new_item.props.precision = calcValue.props.precision;
|
|
272
|
+
new_item.props.micrometer = calcValue.props.is_show_money;
|
|
273
|
+
new_item.props.showUpperCase = calcValue.props.is_show_chn;
|
|
274
|
+
}
|
|
275
|
+
if (calcUnit) {
|
|
276
|
+
newDataBind.unit = calcUnit.props.data_bind;
|
|
277
|
+
new_item.props.default_value = {
|
|
278
|
+
unit: calcUnit.props.value
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
new_item.props.dataBind = newDataBind;
|
|
282
|
+
delete new_item.children;
|
|
283
|
+
}
|
|
284
|
+
if (item.type === "amount-currency") {
|
|
285
|
+
new_item.type = "amount";
|
|
286
|
+
new_item.controlType = "form";
|
|
287
|
+
var amount = new_item === null || new_item === void 0 ? void 0 : new_item.children[0];
|
|
288
|
+
var currency = new_item === null || new_item === void 0 ? void 0 : new_item.children[1];
|
|
289
|
+
var newDataBind1 = {};
|
|
290
|
+
var defaultValue = {};
|
|
291
|
+
// new_item.
|
|
292
|
+
if (amount) {
|
|
293
|
+
conversionDisplayBoListAndBehaviors(new_item, payload);
|
|
294
|
+
new_item.id = amount.id;
|
|
295
|
+
newDataBind1.amount = amount.props.data_bind;
|
|
296
|
+
new_item.props.range_min = toNumberOrEmpty(amount.props.range_min);
|
|
297
|
+
new_item.props.range_max = toNumberOrEmpty(amount.props.range_max);
|
|
298
|
+
defaultValue.amount = toNumberOrEmpty(amount.props.value);
|
|
299
|
+
new_item.props.required = amount.props.required;
|
|
300
|
+
new_item.props.is_hide = amount.props.is_hide;
|
|
301
|
+
new_item.props.default_state = amount.props.default_state;
|
|
302
|
+
new_item.props.caption = isLanguageObject(amount.props.caption) ? amount.props.caption.zh : amount.props.caption;
|
|
303
|
+
new_item.props.is_hide_caption = amount.props.is_hide_caption;
|
|
304
|
+
new_item.props.showUpperCase = amount.props.is_show_chn;
|
|
305
|
+
}
|
|
306
|
+
if (currency) {
|
|
307
|
+
newDataBind1.currency = currency.props.data_bind;
|
|
308
|
+
defaultValue.currency = currency.props.value;
|
|
309
|
+
new_item.props.datasourceBind = currency.props.datasource_bind;
|
|
310
|
+
new_item.props.options = currency.props.options.map(function(item) {
|
|
311
|
+
return {
|
|
312
|
+
label: item.text,
|
|
313
|
+
value: item.value
|
|
314
|
+
};
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
new_item.props.dataBind = newDataBind1;
|
|
318
|
+
new_item.props.defaultValue = defaultValue;
|
|
319
|
+
delete new_item.children;
|
|
320
|
+
}
|
|
321
|
+
if (item.type === "date-range") {
|
|
322
|
+
new_item.controlType = "form";
|
|
323
|
+
var min = new_item === null || new_item === void 0 ? void 0 : new_item.children[0];
|
|
324
|
+
var max = new_item === null || new_item === void 0 ? void 0 : new_item.children[1];
|
|
325
|
+
new_item.props.placeholderStart = isLanguageObject(item.props.placeholder) ? item.props.placeholder.zh : item.props.placeholder;
|
|
326
|
+
new_item.props.caption = isLanguageObject(item.props.caption) ? item.props.caption.zh : item.props.caption;
|
|
327
|
+
var newDataBind2 = {};
|
|
328
|
+
if (min) {
|
|
329
|
+
newDataBind2.min = min.props.data_bind;
|
|
330
|
+
}
|
|
331
|
+
if (max) {
|
|
332
|
+
newDataBind2.max = max.props.data_bind;
|
|
333
|
+
}
|
|
334
|
+
new_item.props.dataBind = newDataBind2;
|
|
335
|
+
delete new_item.children;
|
|
336
|
+
}
|
|
337
|
+
if (item.type === "score") {
|
|
338
|
+
new_item.props.defaultValue = new_item.props.value * 1;
|
|
339
|
+
}
|
|
340
|
+
if ([
|
|
341
|
+
"input",
|
|
342
|
+
"textarea"
|
|
343
|
+
].includes(item.type)) {
|
|
344
|
+
new_item.props.defaultValue = isLanguageObject(item.props.value) ? item.props.value.zh : item.props.value;
|
|
345
|
+
}
|
|
346
|
+
if (item.type === "number") {
|
|
347
|
+
new_item.props.range_min = toNumberOrEmpty(item.props.range_min);
|
|
348
|
+
new_item.props.range_max = toNumberOrEmpty(item.props.range_max);
|
|
349
|
+
new_item.props.defaultValue = toNumberOrEmpty(item.props.value);
|
|
350
|
+
}
|
|
351
|
+
if (item.type === "list-page-btn-custom-button") {
|
|
352
|
+
item.type = "button";
|
|
353
|
+
}
|
|
354
|
+
if (item.type === "button") {
|
|
355
|
+
if (item.props.button_type === "dashed") {
|
|
356
|
+
new_item.props.buttonType = "default";
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
conversionControlEvents(new_item, payload === null || payload === void 0 ? void 0 : payload.control_events);
|
|
360
|
+
return new_item;
|
|
361
|
+
}
|
|
362
|
+
function conversionDisplayBoListAndBehaviors(control, payload) {
|
|
363
|
+
if (!payload) return;
|
|
364
|
+
var _displayBoList = payload.displayBoList, displayBoList = _displayBoList === void 0 ? [] : _displayBoList, _behaviors = payload.behaviors, behaviors = _behaviors === void 0 ? [] : _behaviors;
|
|
365
|
+
var controlId = control.id;
|
|
366
|
+
var newId = control.children[0].id;
|
|
367
|
+
displayBoList.forEach(function(item) {
|
|
368
|
+
if (item.id === controlId) {
|
|
369
|
+
item.id = newId;
|
|
370
|
+
}
|
|
371
|
+
var showIndex = item.show_controls.findIndex(function(id) {
|
|
372
|
+
return id === controlId;
|
|
373
|
+
});
|
|
374
|
+
var hideIndex = item.hide_controls.findIndex(function(id) {
|
|
375
|
+
return id === controlId;
|
|
376
|
+
});
|
|
377
|
+
if (showIndex > -1) {
|
|
378
|
+
item.show_controls.splice(showIndex, 1, newId);
|
|
379
|
+
}
|
|
380
|
+
if (hideIndex > -1) {
|
|
381
|
+
item.hide_controls.splice(hideIndex, 1, newId);
|
|
382
|
+
}
|
|
383
|
+
});
|
|
384
|
+
behaviors.forEach(function(item) {
|
|
385
|
+
if (item.ctrl_id === controlId) {
|
|
386
|
+
item.id = newId;
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
function conversionDataViewPage(controlArray) {
|
|
391
|
+
if (!Array.isArray(controlArray)) {
|
|
392
|
+
return controlArray;
|
|
393
|
+
}
|
|
394
|
+
var grid = controlArray.find(function(item) {
|
|
395
|
+
return item.type === "grid";
|
|
396
|
+
});
|
|
397
|
+
if (!grid) {
|
|
398
|
+
return controlArray;
|
|
399
|
+
}
|
|
400
|
+
var dataView = new DataView.Designer();
|
|
401
|
+
var schema = dataView.toSchema();
|
|
402
|
+
schema.children = controlArray;
|
|
403
|
+
return [
|
|
404
|
+
schema
|
|
405
|
+
];
|
|
406
|
+
}
|
|
407
|
+
function conversionGroupPanel(controlArray) {
|
|
408
|
+
controlArray.forEach(function(item) {
|
|
409
|
+
if (item.children) {
|
|
410
|
+
groupPanelHandler(item.children);
|
|
411
|
+
}
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
// 如果是分组,明细子表,标签页,就把外围的grid-row去掉
|
|
415
|
+
function conversionLayoutControl(schemArray) {
|
|
416
|
+
schemArray.forEach(function(item) {
|
|
417
|
+
if (!(item && item.children)) return;
|
|
418
|
+
var controlArray = item.children;
|
|
419
|
+
for(var i = 0; i < controlArray.length; i++){
|
|
420
|
+
var ref, ref1;
|
|
421
|
+
var control = controlArray[i];
|
|
422
|
+
var child = (ref = controlArray[i]) === null || ref === void 0 ? void 0 : (ref1 = ref.children) === null || ref1 === void 0 ? void 0 : ref1[0];
|
|
423
|
+
if (control.type === "grid-row" && child && [
|
|
424
|
+
"group-panel",
|
|
425
|
+
"subtable",
|
|
426
|
+
"tab"
|
|
427
|
+
].includes(child.type)) {
|
|
428
|
+
controlArray.splice(i, 1, child);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
function conversionListPage(controlArray, payload) {
|
|
434
|
+
var ref, ref1, ref2, ref3, ref4;
|
|
435
|
+
if (!(Array.isArray(controlArray) && controlArray.length === 1)) {
|
|
436
|
+
return controlArray;
|
|
437
|
+
}
|
|
438
|
+
var listPage = controlArray[0];
|
|
439
|
+
if (listPage.type !== "list-page") {
|
|
440
|
+
return controlArray;
|
|
441
|
+
}
|
|
442
|
+
// children = search + toolbox + table
|
|
443
|
+
var listPageProps = listPage.props, children = listPage.children;
|
|
444
|
+
var _children = _slicedToArray(children, 3), search = _children[0], toolbox = _children[1], table = _children[2];
|
|
445
|
+
conversionSearch(search);
|
|
446
|
+
table.props.is_fixed_header = listPageProps === null || listPageProps === void 0 ? void 0 : (ref = listPageProps.source_config) === null || ref === void 0 ? void 0 : ref.is_fixed_header;
|
|
447
|
+
// table.props.datasource_bind = new DataSourceBind({
|
|
448
|
+
// dataCode: listPageProps?.source_config?data_code,
|
|
449
|
+
// svcCode: listPageProps?.source_config?svc_code,
|
|
450
|
+
// orders: camelizeKeys(listPageProps?.source_config?orders) as any[],
|
|
451
|
+
// })
|
|
452
|
+
conversionGridTable(table, toolbox);
|
|
453
|
+
var ref5;
|
|
454
|
+
var dataCode = (ref5 = listPageProps === null || listPageProps === void 0 ? void 0 : (ref1 = listPageProps.source_config) === null || ref1 === void 0 ? void 0 : ref1.data_code) !== null && ref5 !== void 0 ? ref5 : payload === null || payload === void 0 ? void 0 : payload.dataCode;
|
|
455
|
+
var ref6;
|
|
456
|
+
var svcCode = ((ref6 = listPageProps === null || listPageProps === void 0 ? void 0 : (ref2 = listPageProps.source_config) === null || ref2 === void 0 ? void 0 : ref2.svc_code) !== null && ref6 !== void 0 ? ref6 : dataCode) ? "".concat(dataCode, "_selectMore") : undefined;
|
|
457
|
+
var ref7;
|
|
458
|
+
var orders = (ref7 = listPageProps === null || listPageProps === void 0 ? void 0 : (ref3 = listPageProps.source_config) === null || ref3 === void 0 ? void 0 : ref3.orders) !== null && ref7 !== void 0 ? ref7 : [];
|
|
459
|
+
var listView = new ListView.Designer();
|
|
460
|
+
listView.props.datasourceBind = new DataSourceBind({
|
|
461
|
+
dataCode: dataCode,
|
|
462
|
+
svcCode: svcCode,
|
|
463
|
+
orders: camelizeKeys(orders)
|
|
464
|
+
});
|
|
465
|
+
listView.props.isShowSubList = listPageProps.is_show_sublist;
|
|
466
|
+
listView.props.triggerType = listPageProps.timing_type;
|
|
467
|
+
listView.props.triggerFieldCode = listPageProps.ctrl_field_code;
|
|
468
|
+
listPageProps === null || listPageProps === void 0 ? void 0 : (ref4 = listPageProps.sublist_page) === null || ref4 === void 0 ? void 0 : ref4.sublists.forEach(function(item) {
|
|
469
|
+
item.title = isLanguageObject(item.title) ? item.title.zh : item.title;
|
|
470
|
+
});
|
|
471
|
+
listView.props.sublistPage = listPageProps.sublist_page;
|
|
472
|
+
var listViewSchema = listView.toSchema();
|
|
473
|
+
listViewSchema.children.push(search, table);
|
|
474
|
+
return [
|
|
475
|
+
listViewSchema
|
|
476
|
+
];
|
|
477
|
+
}
|
|
478
|
+
function conversionSearch(searchControl) {
|
|
479
|
+
searchControl.type = "simple-search";
|
|
480
|
+
searchControl.control_type = "search-view";
|
|
481
|
+
searchControl.children.forEach(function(item) {
|
|
482
|
+
var placeholder = isLanguageObject(item.placeholder) ? item.placeholder["zh"] : item.placeholder;
|
|
483
|
+
if (item.type === "number-range") {
|
|
484
|
+
item.type = "search-number-range";
|
|
485
|
+
item.placeholderStart = placeholder;
|
|
486
|
+
item.placeholderEnd = placeholder;
|
|
487
|
+
}
|
|
488
|
+
if (item.type === "date-pick") {
|
|
489
|
+
var ref, ref1;
|
|
490
|
+
item.type = "search-date-range";
|
|
491
|
+
item.placeholderStart = placeholder;
|
|
492
|
+
item.placeholderEnd = placeholder;
|
|
493
|
+
item.dateType = (ref = item.dateType) === null || ref === void 0 ? void 0 : (ref1 = ref.replace) === null || ref1 === void 0 ? void 0 : ref1.call(ref, /range$/);
|
|
494
|
+
}
|
|
495
|
+
if (item.type === "automatic-number" || item.type === "auto-number") {
|
|
496
|
+
item.type = "search-input";
|
|
497
|
+
item.props.defaultValue = "";
|
|
498
|
+
}
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
function conversionGridTable(tableControl, toolbox) {
|
|
502
|
+
// 去掉了'list-page-btn-custom-head'按钮控件
|
|
503
|
+
tableControl.children = toolbox.children.filter(function(item) {
|
|
504
|
+
return item.type !== "list-page-btn-custom-head";
|
|
505
|
+
});
|
|
506
|
+
tableControl.type = "grid-table";
|
|
507
|
+
if (tableControl.props.sublist_page) {
|
|
508
|
+
tableControl.props.sublist_page.form_bind = {
|
|
509
|
+
data_code: tableControl.props.sublist_page.data_code,
|
|
510
|
+
form_key: tableControl.props.sublist_page.form_key
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
if (Array.isArray(tableControl.props.headers)) {
|
|
514
|
+
tableControl.props.headers = tableControl.props.headers.map(function(item) {
|
|
515
|
+
var obj = {
|
|
516
|
+
type: "",
|
|
517
|
+
control_type: "column",
|
|
518
|
+
props: {
|
|
519
|
+
widthType: "px",
|
|
520
|
+
width: 50,
|
|
521
|
+
caption: "",
|
|
522
|
+
field_code: item.field_code,
|
|
523
|
+
field_name: isLanguageObject(item.field_name) ? item.field_name["zh"] : item.field_name
|
|
524
|
+
}
|
|
525
|
+
};
|
|
526
|
+
obj.props.caption = isLanguageObject(item.field_name) ? item.field_name["zh"] : item.field_name;
|
|
527
|
+
obj.props.filter_tags = item.is_filter_tags;
|
|
528
|
+
obj.props.fixed = item.fixed;
|
|
529
|
+
obj.props.display_bo_list = item.display_bo_list;
|
|
530
|
+
obj.props.date_type = item.date_type;
|
|
531
|
+
obj.props.optionConfig = "none";
|
|
532
|
+
if (item.header_width_config) {
|
|
533
|
+
obj.props.widthType = item.header_width_config === "1" ? "auto" : "px";
|
|
534
|
+
}
|
|
535
|
+
if (obj.props.widthType === "px" && item.header_width) {
|
|
536
|
+
obj.props.width = Number(item.header_width);
|
|
537
|
+
}
|
|
538
|
+
if (item.table_header_type === "order") {
|
|
539
|
+
obj.type = "order-column";
|
|
540
|
+
obj.props.fixed = true;
|
|
541
|
+
} else if (item.table_header_type === "operation") {
|
|
542
|
+
obj.type = "operation-column";
|
|
543
|
+
var _check;
|
|
544
|
+
obj.props.check = (_check = item.check) !== null && _check !== void 0 ? _check : {};
|
|
545
|
+
obj.props.check.openType = "window";
|
|
546
|
+
var _delete;
|
|
547
|
+
obj.props.delete = (_delete = item.delete) !== null && _delete !== void 0 ? _delete : {};
|
|
548
|
+
obj.props.delete.openType = "window";
|
|
549
|
+
var _edit;
|
|
550
|
+
obj.props.edit = (_edit = item.edit) !== null && _edit !== void 0 ? _edit : {};
|
|
551
|
+
obj.props.edit.openType = "window";
|
|
552
|
+
obj.props.fixed = true;
|
|
553
|
+
} else {
|
|
554
|
+
obj.type = item.field_type + "-column";
|
|
555
|
+
if (item.field_type === "auto_number") {
|
|
556
|
+
obj.type = "auto-number-column";
|
|
557
|
+
}
|
|
558
|
+
if (item.field_type === "relation") {
|
|
559
|
+
obj.type = "varchar-column";
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
if (item.convert_switch) {
|
|
563
|
+
obj.props.optionConfig = item.convert_type === 1 ? "datasource" : "custom";
|
|
564
|
+
}
|
|
565
|
+
if (obj.props.optionConfig === "datasource") {
|
|
566
|
+
obj.props.datasource_bind = new DataSourceBind({
|
|
567
|
+
svcCode: item.svc_code,
|
|
568
|
+
displayBoList: item.display_bo_list,
|
|
569
|
+
valueFieldCode: item.field_match,
|
|
570
|
+
dataCode: item.field_source
|
|
571
|
+
});
|
|
572
|
+
} else if (obj.props.optionConfig === "custom") {
|
|
573
|
+
obj.props.options = item.custom_match_bo_list;
|
|
574
|
+
}
|
|
575
|
+
return obj;
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
function groupPanelHandler(controlArray) {
|
|
580
|
+
var group = null;
|
|
581
|
+
for(var i = 0; i < controlArray.length; i++){
|
|
582
|
+
var ref;
|
|
583
|
+
var item = controlArray[i];
|
|
584
|
+
if (!item) {
|
|
585
|
+
continue;
|
|
586
|
+
}
|
|
587
|
+
if (item.children && ((ref = item.children[0]) === null || ref === void 0 ? void 0 : ref.type) === "group-panel") {
|
|
588
|
+
group = item.children[0];
|
|
589
|
+
continue;
|
|
590
|
+
}
|
|
591
|
+
if (group) {
|
|
592
|
+
group.children.push(item);
|
|
593
|
+
controlArray.splice(i, 1);
|
|
594
|
+
i--;
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
function conversionPageEvents(events) {
|
|
599
|
+
if (!events) {
|
|
600
|
+
return;
|
|
601
|
+
}
|
|
602
|
+
events.did_mount = events.did_mount.map(function(item) {
|
|
603
|
+
return item.name;
|
|
604
|
+
});
|
|
605
|
+
events.will_submit = events.will_submit.map(function(item) {
|
|
606
|
+
return item.name;
|
|
607
|
+
});
|
|
608
|
+
events.did_submit = events.did_submit.map(function(item) {
|
|
609
|
+
return item.name;
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
function conversionControlEvents(control, controlEvents) {
|
|
613
|
+
var ref;
|
|
614
|
+
if (!controlEvents || !control.props.events) {
|
|
615
|
+
return;
|
|
616
|
+
}
|
|
617
|
+
var eventKeys = Object.keys(control.props.events);
|
|
618
|
+
if (!eventKeys.length) {
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
eventKeys.forEach(function(eventKey) {
|
|
622
|
+
var _eventKey;
|
|
623
|
+
if (!control.props.events[eventKey].length) {
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
626
|
+
if (!controlEvents[control.id]) {
|
|
627
|
+
controlEvents[control.id] = {};
|
|
628
|
+
}
|
|
629
|
+
if (!controlEvents[control.id][eventKey]) {
|
|
630
|
+
controlEvents[control.id][eventKey] = [];
|
|
631
|
+
}
|
|
632
|
+
(_eventKey = controlEvents[control.id][eventKey]).push.apply(_eventKey, _toConsumableArray(control.props.events[eventKey].map(function(item) {
|
|
633
|
+
return item.name;
|
|
634
|
+
})));
|
|
635
|
+
});
|
|
636
|
+
// 将失焦事件转换为change事件
|
|
637
|
+
if ((ref = controlEvents[control.id]) === null || ref === void 0 ? void 0 : ref.on_blur) {
|
|
638
|
+
var _on_change;
|
|
639
|
+
if (!controlEvents[control.id].on_change) {
|
|
640
|
+
controlEvents[control.id].on_change = [];
|
|
641
|
+
}
|
|
642
|
+
(_on_change = controlEvents[control.id].on_change).push.apply(_on_change, _toConsumableArray(controlEvents[control.id].on_blur));
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
export { dataCleaner };
|
|
@@ -0,0 +1,30 @@
|
|
|
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 };
|