cloud-web-corejs 1.0.54-dev.756 → 1.0.54-dev.759
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 +1 -1
- package/src/components/jsonImport/mixins.js +350 -350
- package/src/components/langImport/mixins.js +502 -502
- package/src/components/wf/wf.js +2221 -2221
- package/src/components/xform/form-designer/designer.js +2027 -2027
- package/src/components/xform/form-designer/form-widget/dialog/importDialogMixin.js +1774 -1774
- package/src/components/xform/form-designer/setting-panel/form-setting.vue +1553 -1553
- package/src/components/xform/form-designer/setting-panel/indexMixin.js +370 -370
- package/src/components/xform/form-designer/toolbar-panel/indexMixin.js +655 -655
- package/src/components/xform/form-render/container-item/detail-h5-item.vue +173 -173
- package/src/components/xform/form-render/container-item/detail-item.vue +287 -287
- package/src/components/xform/form-render/indexMixin.js +23 -23
- package/src/components/xform/utils/util.js +5 -5
- package/src/index.js +17 -0
- package/src/layout/components/AppMain.vue +7 -0
- package/src/microRouter/index.js +83 -7
- package/src/store/modules/micro.js +5 -0
- package/src/store/modules/permission.js +46 -1
- package/src/views/user/home/default2.vue +1158 -1158
- package/src/views/user/login/indexMixin.js +661 -661
|
@@ -1,2027 +1,2027 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* author: vformAdmin
|
|
3
|
-
* email: vdpadmin@163.com
|
|
4
|
-
* website: https://www.vform666.com
|
|
5
|
-
* date: 2021.08.18
|
|
6
|
-
* remark: 如果要分发VForm源码,需在本文件顶部保留此文件头信息!!
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
deepClone,
|
|
11
|
-
generateId,
|
|
12
|
-
getDefaultFormConfig,
|
|
13
|
-
overwriteObj,
|
|
14
|
-
createUUID,
|
|
15
|
-
columnFormatMap,
|
|
16
|
-
} from "../../../components/xform/utils/util";
|
|
17
|
-
import {
|
|
18
|
-
containers,
|
|
19
|
-
advancedFields,
|
|
20
|
-
basicFields,
|
|
21
|
-
customFields,
|
|
22
|
-
businessFields,
|
|
23
|
-
} from "../../../components/xform/form-designer/widget-panel/widgetsConfig.js";
|
|
24
|
-
import { VARIANT_FORM_VERSION } from "../../../components/xform/utils/config";
|
|
25
|
-
import { keyNamePrefixMap } from "../../../components/xform/form-designer/widget-panel/widgetsConfig";
|
|
26
|
-
|
|
27
|
-
let createDesigner0;
|
|
28
|
-
const baseRefUtil = {
|
|
29
|
-
deepClone,
|
|
30
|
-
generateId,
|
|
31
|
-
getDefaultFormConfig,
|
|
32
|
-
overwriteObj,
|
|
33
|
-
containers,
|
|
34
|
-
advancedFields,
|
|
35
|
-
basicFields,
|
|
36
|
-
customFields,
|
|
37
|
-
VARIANT_FORM_VERSION,
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
let chartContainers = [],
|
|
41
|
-
chartWidgets = [];
|
|
42
|
-
|
|
43
|
-
(function () {
|
|
44
|
-
createDesigner0 = function (vueInstance) {
|
|
45
|
-
let defaultFormConfig = baseRefUtil.deepClone(
|
|
46
|
-
baseRefUtil.getDefaultFormConfig()
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
return {
|
|
50
|
-
widgetList: [],
|
|
51
|
-
formConfig: {
|
|
52
|
-
cssCode: "",
|
|
53
|
-
gridConfig: {
|
|
54
|
-
accessReturnType: 1,
|
|
55
|
-
isLoadDataByAccess: false,
|
|
56
|
-
},
|
|
57
|
-
scriptList: [],
|
|
58
|
-
formType: 0,
|
|
59
|
-
getConfig: {
|
|
60
|
-
accessType: "1",
|
|
61
|
-
accessUrl: null,
|
|
62
|
-
accessParam: null,
|
|
63
|
-
accessCallback: null,
|
|
64
|
-
scriptName: null,
|
|
65
|
-
scriptCode: null,
|
|
66
|
-
},
|
|
67
|
-
saveConfig: {
|
|
68
|
-
accessType: "1",
|
|
69
|
-
accessUrl: null,
|
|
70
|
-
accessParam: null,
|
|
71
|
-
accessCallback: null,
|
|
72
|
-
scriptName: null,
|
|
73
|
-
scriptCode: null,
|
|
74
|
-
},
|
|
75
|
-
editFormCode: null,
|
|
76
|
-
editFormName: null,
|
|
77
|
-
searchDialogNameField: null,
|
|
78
|
-
searchDialogUniqueField: null,
|
|
79
|
-
entity: null,
|
|
80
|
-
wfEnabled: false,
|
|
81
|
-
isLoadEntity: false,
|
|
82
|
-
formScriptCode: "getOne",
|
|
83
|
-
formScriptParam: null,
|
|
84
|
-
formScriptSuccess: null,
|
|
85
|
-
saveScriptCode: "saveUpdate",
|
|
86
|
-
wfConfig: null,
|
|
87
|
-
wfStartBindSave: false,
|
|
88
|
-
wfStartConfirmText: null,
|
|
89
|
-
wfAgreenBindSave: false,
|
|
90
|
-
wfAgreeConfigData: [],
|
|
91
|
-
wfConfigDataEnabled: false,
|
|
92
|
-
wfConfigData: [],
|
|
93
|
-
multiTabEnabled: false,
|
|
94
|
-
multiTabLabelField: null,
|
|
95
|
-
addTabEnabled: false, // 新增打开独立页签(不走「常规」页签)
|
|
96
|
-
submitBehavior: "refreshCurrent", // 提交后行为: refreshCurrent(默认,留在详情页) | closeToList
|
|
97
|
-
billNavEnabled: false, // 详情页签显示「上一单/下一单」翻单按钮
|
|
98
|
-
addFormCode: null,
|
|
99
|
-
addFormName: null,
|
|
100
|
-
wfTheme: null,
|
|
101
|
-
otherTabEnabled: false,
|
|
102
|
-
otherTabList: [],
|
|
103
|
-
hideNormalTab: false,
|
|
104
|
-
customListTabLabel: null,
|
|
105
|
-
globalConfig: null,
|
|
106
|
-
// 表单级动态字段规则
|
|
107
|
-
dynamicFieldEnabled: false,
|
|
108
|
-
dynamicFieldSourceType: "local",
|
|
109
|
-
dynamicFieldRules: [],
|
|
110
|
-
dynamicFieldScriptCode: null,
|
|
111
|
-
dynamicFieldScriptParam: null,
|
|
112
|
-
dynamicFieldTriggerFields: [],
|
|
113
|
-
},
|
|
114
|
-
dataSources: [], //数据源
|
|
115
|
-
|
|
116
|
-
selectedId: null,
|
|
117
|
-
selectedWidget: null,
|
|
118
|
-
selectedWidgetName: null, //选中组件名称(唯一)
|
|
119
|
-
vueInstance: vueInstance,
|
|
120
|
-
|
|
121
|
-
formWidget: null, //表单设计容器
|
|
122
|
-
|
|
123
|
-
cssClassList: [], //自定义样式列表
|
|
124
|
-
|
|
125
|
-
historyData: {
|
|
126
|
-
index: -1, //index: 0,
|
|
127
|
-
maxStep: 20,
|
|
128
|
-
steps: [],
|
|
129
|
-
},
|
|
130
|
-
|
|
131
|
-
initDesigner(resetFormJson) {
|
|
132
|
-
this.widgetList = [];
|
|
133
|
-
this.formConfig = baseRefUtil.deepClone(defaultFormConfig);
|
|
134
|
-
this.dataSources = [];
|
|
135
|
-
|
|
136
|
-
//输出版本信息和语雀链接
|
|
137
|
-
/* console.info(`%cVariantForm %cVer${baseRefUtil.VARIANT_FORM_VERSION} %chttps://www.yuque.com/visualdev/vform`,
|
|
138
|
-
"color:#409EFF;font-size: 22px;font-weight:bolder",
|
|
139
|
-
"color:#999;font-size: 12px",
|
|
140
|
-
"color:#333"
|
|
141
|
-
); */
|
|
142
|
-
|
|
143
|
-
/*if (!resetFormJson) {
|
|
144
|
-
this.initHistoryData();
|
|
145
|
-
}*/
|
|
146
|
-
},
|
|
147
|
-
|
|
148
|
-
clearDesigner(skipHistoryChange) {
|
|
149
|
-
let emptyWidgetListFlag = this.widgetList.length === 0;
|
|
150
|
-
this.widgetList = [];
|
|
151
|
-
this.selectedId = null;
|
|
152
|
-
this.selectedWidgetName = null;
|
|
153
|
-
this.selectedWidget = {}; //this.selectedWidget = null
|
|
154
|
-
baseRefUtil.overwriteObj(this.formConfig, defaultFormConfig); //
|
|
155
|
-
this.formConfig.gridConfig = defaultFormConfig.gridConfig;
|
|
156
|
-
|
|
157
|
-
if (!!skipHistoryChange) {
|
|
158
|
-
//什么也不做!!
|
|
159
|
-
} else if (!emptyWidgetListFlag) {
|
|
160
|
-
this.emitHistoryChange();
|
|
161
|
-
} else {
|
|
162
|
-
this.saveCurrentHistoryStep();
|
|
163
|
-
}
|
|
164
|
-
},
|
|
165
|
-
|
|
166
|
-
loadPresetCssCode(preCssCode) {
|
|
167
|
-
if (this.formConfig.cssCode === "" && !!preCssCode) {
|
|
168
|
-
this.formConfig.cssCode = preCssCode;
|
|
169
|
-
}
|
|
170
|
-
},
|
|
171
|
-
|
|
172
|
-
getLayoutType() {
|
|
173
|
-
return this.formConfig.layoutType || "PC";
|
|
174
|
-
},
|
|
175
|
-
|
|
176
|
-
changeLayoutType(newType) {
|
|
177
|
-
this.formConfig.layoutType = newType;
|
|
178
|
-
},
|
|
179
|
-
|
|
180
|
-
getImportTemplate() {
|
|
181
|
-
return {
|
|
182
|
-
widgetList: [],
|
|
183
|
-
// formConfig: baseRefUtil.deepClone(this.formConfig)
|
|
184
|
-
formConfig: baseRefUtil.deepClone(defaultFormConfig),
|
|
185
|
-
};
|
|
186
|
-
},
|
|
187
|
-
|
|
188
|
-
handleImportJson(formJson) {
|
|
189
|
-
let formConfig = formJson.formConfig;
|
|
190
|
-
if (formConfig.formCode === vueInstance?.reportTemplate?.formCode) {
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
let widgetArr = formJson.widgetList;
|
|
194
|
-
let itemFieldMap = {
|
|
195
|
-
grid: "cols",
|
|
196
|
-
table: "rows",
|
|
197
|
-
"table-cell": "widgetList",
|
|
198
|
-
"h5-table": "rows",
|
|
199
|
-
"h5-table-cell": "widgetList",
|
|
200
|
-
tab: "tabs",
|
|
201
|
-
"tab-pane": "widgetList",
|
|
202
|
-
"grid-col": "widgetList",
|
|
203
|
-
"vf-box": "widgetList",
|
|
204
|
-
card: "widgetList",
|
|
205
|
-
detail: "panes",
|
|
206
|
-
"detail-pane": "widgetList",
|
|
207
|
-
"detail-h5": "panes",
|
|
208
|
-
"h5-card": "panes",
|
|
209
|
-
"h5-card-pane": "widgetList",
|
|
210
|
-
};
|
|
211
|
-
let loopDo = (widgetList) => {
|
|
212
|
-
if (!widgetList) return;
|
|
213
|
-
widgetList.forEach((widget) => {
|
|
214
|
-
if (widget.type === "data-table" || widget.type === "list-h5") {
|
|
215
|
-
let vailColumns = widget.options.tableColumns.filter(
|
|
216
|
-
(item) => item.prop && item.label
|
|
217
|
-
);
|
|
218
|
-
vailColumns.forEach((item) => {
|
|
219
|
-
if (item.formatS === "editAttachment") {
|
|
220
|
-
let prop = item.prop;
|
|
221
|
-
let columnOption = item.columnOption;
|
|
222
|
-
let editColumnOption = item.editColumnOption;
|
|
223
|
-
|
|
224
|
-
let suffix = this.createAttachmentSuffix();
|
|
225
|
-
let keyName = this.createAttachmentKeyName(suffix);
|
|
226
|
-
if (columnOption) {
|
|
227
|
-
columnOption.keyName = keyName;
|
|
228
|
-
columnOption.keyNameSuffix = suffix;
|
|
229
|
-
}
|
|
230
|
-
if (editColumnOption) {
|
|
231
|
-
editColumnOption.keyName = keyName;
|
|
232
|
-
editColumnOption.keyNameSuffix = suffix;
|
|
233
|
-
}
|
|
234
|
-
item.prop = keyName;
|
|
235
|
-
}
|
|
236
|
-
});
|
|
237
|
-
} else if (
|
|
238
|
-
widget.type === "vabUpload" ||
|
|
239
|
-
widget.type === "baseAttachment"
|
|
240
|
-
) {
|
|
241
|
-
let suffix = this.createAttachmentSuffix();
|
|
242
|
-
let keyName = this.createAttachmentKeyName(suffix);
|
|
243
|
-
widget.options.keyName = keyName;
|
|
244
|
-
widget.options.keyNameSuffix = suffix;
|
|
245
|
-
} else {
|
|
246
|
-
if (widget.category === "container") {
|
|
247
|
-
let itemField = itemFieldMap[widget.type];
|
|
248
|
-
if (itemField) {
|
|
249
|
-
if ("table" === widget.type) {
|
|
250
|
-
widget[itemField].forEach((item) => {
|
|
251
|
-
loopDo(item.cols);
|
|
252
|
-
});
|
|
253
|
-
} else if ("h5-table" === widget.type) {
|
|
254
|
-
widget[itemField].forEach((item) => {
|
|
255
|
-
loopDo(item.cols);
|
|
256
|
-
});
|
|
257
|
-
} else {
|
|
258
|
-
loopDo(widget[itemField]);
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
});
|
|
264
|
-
};
|
|
265
|
-
loopDo(widgetArr);
|
|
266
|
-
},
|
|
267
|
-
loadFormJson(formJson) {
|
|
268
|
-
let modifiedFlag = false;
|
|
269
|
-
|
|
270
|
-
if (!!formJson && !!formJson.widgetList) {
|
|
271
|
-
this.widgetList = formJson.widgetList;
|
|
272
|
-
modifiedFlag = true;
|
|
273
|
-
}
|
|
274
|
-
if (!!formJson && !!formJson.formConfig) {
|
|
275
|
-
//this.formConfig = importObj.formConfig
|
|
276
|
-
baseRefUtil.overwriteObj(
|
|
277
|
-
this.formConfig,
|
|
278
|
-
formJson.formConfig
|
|
279
|
-
); /* 用=赋值,会导致inject依赖注入的formConfig属性变成非响应式 */
|
|
280
|
-
modifiedFlag = true;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
if (modifiedFlag) {
|
|
284
|
-
this.emitEvent("form-json-imported", []); // 通知其他组件
|
|
285
|
-
}
|
|
286
|
-
this.setSelected();
|
|
287
|
-
return modifiedFlag;
|
|
288
|
-
},
|
|
289
|
-
handleSelectedWidget(selected) {
|
|
290
|
-
//处理历史未定义的属性
|
|
291
|
-
if (selected.formItemFlag || selected.type === "data-table") {
|
|
292
|
-
if (selected.options.submitFlag === void 0) {
|
|
293
|
-
// selected.options.submitFlag = true;
|
|
294
|
-
this.vueInstance.$set(selected.options, "submitFlag", true);
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
this.handleKeyNameSuffix(selected);
|
|
298
|
-
},
|
|
299
|
-
handleKeyNameSuffix(selected) {
|
|
300
|
-
if (!selected) return;
|
|
301
|
-
let optionModel = selected.options;
|
|
302
|
-
let prefix = this.getKeyNamePrefix(selected.type);
|
|
303
|
-
if (
|
|
304
|
-
optionModel.keyNameEnabled &&
|
|
305
|
-
!!prefix &&
|
|
306
|
-
!optionModel.keyNameSuffix
|
|
307
|
-
) {
|
|
308
|
-
let keyName = optionModel.keyName;
|
|
309
|
-
if (keyName.startsWith(prefix)) {
|
|
310
|
-
this.vueInstance.$set(
|
|
311
|
-
optionModel,
|
|
312
|
-
"keyNameSuffix",
|
|
313
|
-
keyName.substring(prefix.length)
|
|
314
|
-
);
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
},
|
|
318
|
-
setSelected(selected) {
|
|
319
|
-
if (!selected) {
|
|
320
|
-
this.clearSelected();
|
|
321
|
-
return;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
//处理历史未定义的属性
|
|
325
|
-
this.handleSelectedWidget(selected);
|
|
326
|
-
|
|
327
|
-
this.selectedWidget = selected;
|
|
328
|
-
if (!!selected.id) {
|
|
329
|
-
this.selectedId = selected.id;
|
|
330
|
-
this.selectedWidgetName = selected.options.name;
|
|
331
|
-
if (!selected.category) {
|
|
332
|
-
this.emitEvent("canvas-select-field", selected.options.name);
|
|
333
|
-
} else {
|
|
334
|
-
this.emitEvent("canvas-select-container", selected.options.name);
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
},
|
|
338
|
-
|
|
339
|
-
updateSelectedWidgetNameAndLabel(selectedWidget, newName, newLabel) {
|
|
340
|
-
this.selectedWidgetName = newName;
|
|
341
|
-
//selectedWidget.options.name = newName //此行多余
|
|
342
|
-
if (
|
|
343
|
-
!!newLabel &&
|
|
344
|
-
Object.keys(selectedWidget.options).indexOf("label") > -1
|
|
345
|
-
) {
|
|
346
|
-
selectedWidget.options.label = newLabel;
|
|
347
|
-
}
|
|
348
|
-
},
|
|
349
|
-
|
|
350
|
-
clearSelected() {
|
|
351
|
-
this.selectedId = null;
|
|
352
|
-
this.selectedWidgetName = null;
|
|
353
|
-
this.selectedWidget = {}; //this.selectedWidget = null
|
|
354
|
-
},
|
|
355
|
-
|
|
356
|
-
checkWidgetMove(evt) {
|
|
357
|
-
/* Only field widget can be dragged into sub-form */
|
|
358
|
-
if (!!evt.draggedContext && !!evt.draggedContext.element) {
|
|
359
|
-
let wgCategory = evt.draggedContext.element.category;
|
|
360
|
-
let wgType = evt.draggedContext.element.type;
|
|
361
|
-
if (!!evt.to) {
|
|
362
|
-
if (
|
|
363
|
-
evt.to.className === "sub-form-table" &&
|
|
364
|
-
wgCategory === "container"
|
|
365
|
-
) {
|
|
366
|
-
//this.$message.info(this.vueInstance.i18nt('designer.hint.onlyFieldWidgetAcceptable'))
|
|
367
|
-
return false;
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
return true;
|
|
373
|
-
},
|
|
374
|
-
|
|
375
|
-
checkFieldMove(evt) {
|
|
376
|
-
if (!!evt.draggedContext && !!evt.draggedContext.element) {
|
|
377
|
-
let wgCategory = evt.draggedContext.element.category;
|
|
378
|
-
let wgType = evt.draggedContext.element.type + "";
|
|
379
|
-
//console.log('wgType======', wgType)
|
|
380
|
-
if (!!evt.to) {
|
|
381
|
-
if (evt.to.className === "sub-form-table" && wgType === "slot") {
|
|
382
|
-
//this.$message.info(this.vueInstance.i18nt('designer.hint.onlyFieldWidgetAcceptable'))
|
|
383
|
-
return false;
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
return true;
|
|
389
|
-
},
|
|
390
|
-
|
|
391
|
-
/**
|
|
392
|
-
* 追加表格新行
|
|
393
|
-
* @param widget
|
|
394
|
-
*/
|
|
395
|
-
appendTableRow(widget) {
|
|
396
|
-
let rowIdx = widget.rows.length; //确定插入行位置
|
|
397
|
-
let newRow = baseRefUtil.deepClone(widget.rows[widget.rows.length - 1]);
|
|
398
|
-
newRow.id = "table-row-" + baseRefUtil.generateId();
|
|
399
|
-
newRow.merged = false;
|
|
400
|
-
newRow.cols.forEach((col) => {
|
|
401
|
-
col.id = "table-cell-" + baseRefUtil.generateId();
|
|
402
|
-
col.options.name = col.id;
|
|
403
|
-
col.merged = false;
|
|
404
|
-
col.options.colspan = 1;
|
|
405
|
-
col.options.rowspan = 1;
|
|
406
|
-
col.widgetList.length = 0;
|
|
407
|
-
});
|
|
408
|
-
widget.rows.splice(rowIdx, 0, newRow);
|
|
409
|
-
|
|
410
|
-
this.emitHistoryChange();
|
|
411
|
-
},
|
|
412
|
-
|
|
413
|
-
/**
|
|
414
|
-
* 追加表格新列
|
|
415
|
-
* @param widget
|
|
416
|
-
*/
|
|
417
|
-
appendTableCol(widget) {
|
|
418
|
-
let colIdx = widget.rows[0].cols.length; //确定插入列位置
|
|
419
|
-
widget.rows.forEach((row) => {
|
|
420
|
-
let newCol = baseRefUtil.deepClone(
|
|
421
|
-
this.getContainerByType("table-cell")
|
|
422
|
-
);
|
|
423
|
-
newCol.id = "table-cell-" + baseRefUtil.generateId();
|
|
424
|
-
newCol.options.name = newCol.id;
|
|
425
|
-
newCol.merged = false;
|
|
426
|
-
newCol.options.colspan = 1;
|
|
427
|
-
newCol.options.rowspan = 1;
|
|
428
|
-
newCol.widgetList.length = 0;
|
|
429
|
-
row.cols.splice(colIdx, 0, newCol);
|
|
430
|
-
});
|
|
431
|
-
|
|
432
|
-
this.emitHistoryChange();
|
|
433
|
-
},
|
|
434
|
-
|
|
435
|
-
insertTableRow(widget, insertPos, cloneRowIdx, curCol, aboveFlag) {
|
|
436
|
-
let newRowIdx = !!aboveFlag ? insertPos : insertPos + 1; //初步确定插入行位置
|
|
437
|
-
if (!aboveFlag) {
|
|
438
|
-
//继续向下寻找同列第一个未被合并的单元格
|
|
439
|
-
let tmpRowIdx = newRowIdx;
|
|
440
|
-
let rowFoundFlag = false;
|
|
441
|
-
while (tmpRowIdx < widget.rows.length) {
|
|
442
|
-
if (!widget.rows[tmpRowIdx].cols[curCol].merged) {
|
|
443
|
-
newRowIdx = tmpRowIdx;
|
|
444
|
-
rowFoundFlag = true;
|
|
445
|
-
break;
|
|
446
|
-
} else {
|
|
447
|
-
tmpRowIdx++;
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
if (!rowFoundFlag) {
|
|
452
|
-
newRowIdx = widget.rows.length;
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
let newRow = baseRefUtil.deepClone(widget.rows[cloneRowIdx]);
|
|
457
|
-
newRow.id = "table-row-" + baseRefUtil.generateId();
|
|
458
|
-
newRow.merged = false;
|
|
459
|
-
newRow.cols.forEach((col) => {
|
|
460
|
-
col.id = "table-cell-" + baseRefUtil.generateId();
|
|
461
|
-
col.options.name = col.id;
|
|
462
|
-
col.merged = false;
|
|
463
|
-
col.options.colspan = 1;
|
|
464
|
-
col.options.rowspan = 1;
|
|
465
|
-
col.widgetList.length = 0;
|
|
466
|
-
});
|
|
467
|
-
widget.rows.splice(newRowIdx, 0, newRow);
|
|
468
|
-
|
|
469
|
-
let colNo = 0;
|
|
470
|
-
while (
|
|
471
|
-
newRowIdx < widget.rows.length - 1 &&
|
|
472
|
-
colNo < widget.rows[0].cols.length
|
|
473
|
-
) {
|
|
474
|
-
//越界判断
|
|
475
|
-
const cellOfNextRow = widget.rows[newRowIdx + 1].cols[colNo];
|
|
476
|
-
const rowMerged = cellOfNextRow.merged; //确定插入位置下一行的单元格是否为合并单元格
|
|
477
|
-
if (!!rowMerged) {
|
|
478
|
-
let rowArray = widget.rows;
|
|
479
|
-
let unMergedCell = {};
|
|
480
|
-
let startRowIndex = null;
|
|
481
|
-
for (let i = newRowIdx; i >= 0; i--) {
|
|
482
|
-
//查找该行已合并的主单元格
|
|
483
|
-
if (
|
|
484
|
-
!rowArray[i].cols[colNo].merged &&
|
|
485
|
-
rowArray[i].cols[colNo].options.rowspan > 1
|
|
486
|
-
) {
|
|
487
|
-
startRowIndex = i;
|
|
488
|
-
unMergedCell = rowArray[i].cols[colNo];
|
|
489
|
-
break;
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
if (!!unMergedCell.options) {
|
|
494
|
-
//如果有符合条件的unMergedCell
|
|
495
|
-
let newRowspan = unMergedCell.options.rowspan + 1;
|
|
496
|
-
this.setPropsOfMergedRows(
|
|
497
|
-
widget.rows,
|
|
498
|
-
startRowIndex,
|
|
499
|
-
colNo,
|
|
500
|
-
unMergedCell.options.colspan,
|
|
501
|
-
newRowspan
|
|
502
|
-
);
|
|
503
|
-
colNo += unMergedCell.options.colspan;
|
|
504
|
-
} else {
|
|
505
|
-
colNo += 1;
|
|
506
|
-
}
|
|
507
|
-
} else {
|
|
508
|
-
//colNo += 1
|
|
509
|
-
colNo += cellOfNextRow.options.colspan || 1;
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
this.emitHistoryChange();
|
|
514
|
-
},
|
|
515
|
-
|
|
516
|
-
insertTableCol(widget, insertPos, curRow, leftFlag) {
|
|
517
|
-
let newColIdx = !!leftFlag ? insertPos : insertPos + 1; //初步确定插入列位置
|
|
518
|
-
if (!leftFlag) {
|
|
519
|
-
//继续向右寻找同行第一个未被合并的单元格
|
|
520
|
-
let tmpColIdx = newColIdx;
|
|
521
|
-
let colFoundFlag = false;
|
|
522
|
-
while (tmpColIdx < widget.rows[curRow].cols.length) {
|
|
523
|
-
if (!widget.rows[curRow].cols[tmpColIdx].merged) {
|
|
524
|
-
newColIdx = tmpColIdx;
|
|
525
|
-
colFoundFlag = true;
|
|
526
|
-
break;
|
|
527
|
-
} else {
|
|
528
|
-
tmpColIdx++;
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
if (!colFoundFlag) {
|
|
532
|
-
newColIdx = widget.rows[curRow].cols.length;
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
widget.rows.forEach((row) => {
|
|
538
|
-
let newCol = baseRefUtil.deepClone(
|
|
539
|
-
this.getContainerByType("table-cell")
|
|
540
|
-
);
|
|
541
|
-
newCol.id = "table-cell-" + baseRefUtil.generateId();
|
|
542
|
-
newCol.options.name = newCol.id;
|
|
543
|
-
newCol.merged = false;
|
|
544
|
-
newCol.options.colspan = 1;
|
|
545
|
-
newCol.options.rowspan = 1;
|
|
546
|
-
newCol.widgetList.length = 0;
|
|
547
|
-
row.cols.splice(newColIdx, 0, newCol);
|
|
548
|
-
});
|
|
549
|
-
|
|
550
|
-
let rowNo = 0;
|
|
551
|
-
while (
|
|
552
|
-
newColIdx < widget.rows[0].cols.length - 1 &&
|
|
553
|
-
rowNo < widget.rows.length
|
|
554
|
-
) {
|
|
555
|
-
//越界判断
|
|
556
|
-
const cellOfNextCol = widget.rows[rowNo].cols[newColIdx + 1];
|
|
557
|
-
const colMerged = cellOfNextCol.merged; //确定插入位置右侧列的单元格是否为合并单元格
|
|
558
|
-
if (!!colMerged) {
|
|
559
|
-
let colArray = widget.rows[rowNo].cols;
|
|
560
|
-
let unMergedCell = {};
|
|
561
|
-
let startColIndex = null;
|
|
562
|
-
for (let i = newColIdx; i >= 0; i--) {
|
|
563
|
-
//查找该行已合并的主单元格
|
|
564
|
-
if (!colArray[i].merged && colArray[i].options.colspan > 1) {
|
|
565
|
-
startColIndex = i;
|
|
566
|
-
unMergedCell = colArray[i];
|
|
567
|
-
break;
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
if (!!unMergedCell.options) {
|
|
572
|
-
//如果有符合条件的unMergedCell
|
|
573
|
-
let newColspan = unMergedCell.options.colspan + 1;
|
|
574
|
-
this.setPropsOfMergedCols(
|
|
575
|
-
widget.rows,
|
|
576
|
-
rowNo,
|
|
577
|
-
startColIndex,
|
|
578
|
-
newColspan,
|
|
579
|
-
unMergedCell.options.rowspan
|
|
580
|
-
);
|
|
581
|
-
rowNo += unMergedCell.options.rowspan;
|
|
582
|
-
} else {
|
|
583
|
-
rowNo += 1;
|
|
584
|
-
}
|
|
585
|
-
} else {
|
|
586
|
-
//rowNo += 1
|
|
587
|
-
rowNo += cellOfNextCol.options.rowspan || 1;
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
|
|
591
|
-
this.emitHistoryChange();
|
|
592
|
-
},
|
|
593
|
-
insertH5TableCol(widget, insertPos, curRow, leftFlag) {
|
|
594
|
-
let newColIdx = !!leftFlag ? insertPos : insertPos + 1; //初步确定插入列位置
|
|
595
|
-
if (!leftFlag) {
|
|
596
|
-
//继续向右寻找同行第一个未被合并的单元格
|
|
597
|
-
let tmpColIdx = newColIdx;
|
|
598
|
-
let colFoundFlag = false;
|
|
599
|
-
while (tmpColIdx < widget.rows[curRow].cols.length) {
|
|
600
|
-
if (!widget.rows[curRow].cols[tmpColIdx].merged) {
|
|
601
|
-
newColIdx = tmpColIdx;
|
|
602
|
-
colFoundFlag = true;
|
|
603
|
-
break;
|
|
604
|
-
} else {
|
|
605
|
-
tmpColIdx++;
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
if (!colFoundFlag) {
|
|
609
|
-
newColIdx = widget.rows[curRow].cols.length;
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
widget.rows.forEach((row) => {
|
|
615
|
-
let newCol = baseRefUtil.deepClone(
|
|
616
|
-
this.getContainerByType("h5-table-cell")
|
|
617
|
-
);
|
|
618
|
-
newCol.id = "table-cell-" + baseRefUtil.generateId();
|
|
619
|
-
newCol.options.name = newCol.id;
|
|
620
|
-
newCol.merged = false;
|
|
621
|
-
newCol.options.colspan = 1;
|
|
622
|
-
newCol.options.rowspan = 1;
|
|
623
|
-
newCol.widgetList.length = 0;
|
|
624
|
-
row.cols.splice(newColIdx, 0, newCol);
|
|
625
|
-
});
|
|
626
|
-
|
|
627
|
-
let rowNo = 0;
|
|
628
|
-
while (
|
|
629
|
-
newColIdx < widget.rows[0].cols.length - 1 &&
|
|
630
|
-
rowNo < widget.rows.length
|
|
631
|
-
) {
|
|
632
|
-
//越界判断
|
|
633
|
-
const cellOfNextCol = widget.rows[rowNo].cols[newColIdx + 1];
|
|
634
|
-
const colMerged = cellOfNextCol.merged; //确定插入位置右侧列的单元格是否为合并单元格
|
|
635
|
-
if (!!colMerged) {
|
|
636
|
-
let colArray = widget.rows[rowNo].cols;
|
|
637
|
-
let unMergedCell = {};
|
|
638
|
-
let startColIndex = null;
|
|
639
|
-
for (let i = newColIdx; i >= 0; i--) {
|
|
640
|
-
//查找该行已合并的主单元格
|
|
641
|
-
if (!colArray[i].merged && colArray[i].options.colspan > 1) {
|
|
642
|
-
startColIndex = i;
|
|
643
|
-
unMergedCell = colArray[i];
|
|
644
|
-
break;
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
if (!!unMergedCell.options) {
|
|
649
|
-
//如果有符合条件的unMergedCell
|
|
650
|
-
let newColspan = unMergedCell.options.colspan + 1;
|
|
651
|
-
this.setPropsOfMergedCols(
|
|
652
|
-
widget.rows,
|
|
653
|
-
rowNo,
|
|
654
|
-
startColIndex,
|
|
655
|
-
newColspan,
|
|
656
|
-
unMergedCell.options.rowspan
|
|
657
|
-
);
|
|
658
|
-
rowNo += unMergedCell.options.rowspan;
|
|
659
|
-
} else {
|
|
660
|
-
rowNo += 1;
|
|
661
|
-
}
|
|
662
|
-
} else {
|
|
663
|
-
//rowNo += 1
|
|
664
|
-
rowNo += cellOfNextCol.options.rowspan || 1;
|
|
665
|
-
}
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
this.emitHistoryChange();
|
|
669
|
-
},
|
|
670
|
-
setPropsOfMergedCols(
|
|
671
|
-
rowArray,
|
|
672
|
-
startRowIndex,
|
|
673
|
-
startColIndex,
|
|
674
|
-
newColspan,
|
|
675
|
-
rowspan
|
|
676
|
-
) {
|
|
677
|
-
for (let i = startRowIndex; i < startRowIndex + rowspan; i++) {
|
|
678
|
-
for (let j = startColIndex; j < startColIndex + newColspan; j++) {
|
|
679
|
-
if (i === startRowIndex && j === startColIndex) {
|
|
680
|
-
rowArray[i].cols[j].options.colspan = newColspan; //合并后的主单元格
|
|
681
|
-
continue;
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
rowArray[i].cols[j].merged = true;
|
|
685
|
-
rowArray[i].cols[j].options.colspan = newColspan;
|
|
686
|
-
rowArray[i].cols[j].widgetList = [];
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
},
|
|
690
|
-
|
|
691
|
-
setPropsOfMergedRows(
|
|
692
|
-
rowArray,
|
|
693
|
-
startRowIndex,
|
|
694
|
-
startColIndex,
|
|
695
|
-
colspan,
|
|
696
|
-
newRowspan
|
|
697
|
-
) {
|
|
698
|
-
for (let i = startRowIndex; i < startRowIndex + newRowspan; i++) {
|
|
699
|
-
for (let j = startColIndex; j < startColIndex + colspan; j++) {
|
|
700
|
-
if (i === startRowIndex && j === startColIndex) {
|
|
701
|
-
rowArray[i].cols[j].options.rowspan = newRowspan;
|
|
702
|
-
continue;
|
|
703
|
-
}
|
|
704
|
-
|
|
705
|
-
rowArray[i].cols[j].merged = true;
|
|
706
|
-
rowArray[i].cols[j].options.rowspan = newRowspan;
|
|
707
|
-
rowArray[i].cols[j].widgetList = [];
|
|
708
|
-
}
|
|
709
|
-
}
|
|
710
|
-
},
|
|
711
|
-
|
|
712
|
-
setPropsOfSplitCol(
|
|
713
|
-
rowArray,
|
|
714
|
-
startRowIndex,
|
|
715
|
-
startColIndex,
|
|
716
|
-
colspan,
|
|
717
|
-
rowspan
|
|
718
|
-
) {
|
|
719
|
-
for (let i = startRowIndex; i < startRowIndex + rowspan; i++) {
|
|
720
|
-
for (let j = startColIndex; j < startColIndex + colspan; j++) {
|
|
721
|
-
rowArray[i].cols[j].merged = false;
|
|
722
|
-
rowArray[i].cols[j].options.rowspan = 1;
|
|
723
|
-
rowArray[i].cols[j].options.colspan = 1;
|
|
724
|
-
}
|
|
725
|
-
}
|
|
726
|
-
},
|
|
727
|
-
|
|
728
|
-
setPropsOfSplitRow(
|
|
729
|
-
rowArray,
|
|
730
|
-
startRowIndex,
|
|
731
|
-
startColIndex,
|
|
732
|
-
colspan,
|
|
733
|
-
rowspan
|
|
734
|
-
) {
|
|
735
|
-
for (let i = startRowIndex; i < startRowIndex + rowspan; i++) {
|
|
736
|
-
for (let j = startColIndex; j < startColIndex + colspan; j++) {
|
|
737
|
-
rowArray[i].cols[j].merged = false;
|
|
738
|
-
rowArray[i].cols[j].options.rowspan = 1;
|
|
739
|
-
rowArray[i].cols[j].options.colspan = 1;
|
|
740
|
-
}
|
|
741
|
-
}
|
|
742
|
-
},
|
|
743
|
-
|
|
744
|
-
mergeTableCol(rowArray, colArray, curRow, curCol, leftFlag, cellWidget) {
|
|
745
|
-
let mergedColIdx = !!leftFlag
|
|
746
|
-
? curCol
|
|
747
|
-
: curCol + colArray[curCol].options.colspan;
|
|
748
|
-
|
|
749
|
-
// let remainedColIdx = !!leftFlag ? curCol - colArray[curCol - 1].options.colspan : curCol
|
|
750
|
-
let remainedColIdx = !!leftFlag ? curCol - 1 : curCol;
|
|
751
|
-
if (!!leftFlag) {
|
|
752
|
-
//继续向左寻找同行未被合并的第一个单元格
|
|
753
|
-
let tmpColIdx = remainedColIdx;
|
|
754
|
-
while (tmpColIdx >= 0) {
|
|
755
|
-
if (!rowArray[curRow].cols[tmpColIdx].merged) {
|
|
756
|
-
remainedColIdx = tmpColIdx;
|
|
757
|
-
break;
|
|
758
|
-
} else {
|
|
759
|
-
tmpColIdx--;
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
|
-
}
|
|
763
|
-
|
|
764
|
-
if (
|
|
765
|
-
!!colArray[mergedColIdx].widgetList &&
|
|
766
|
-
colArray[mergedColIdx].widgetList.length > 0
|
|
767
|
-
) {
|
|
768
|
-
//保留widgetList
|
|
769
|
-
if (
|
|
770
|
-
!colArray[remainedColIdx].widgetList ||
|
|
771
|
-
colArray[remainedColIdx].widgetList.length === 0
|
|
772
|
-
) {
|
|
773
|
-
colArray[remainedColIdx].widgetList = baseRefUtil.deepClone(
|
|
774
|
-
colArray[mergedColIdx].widgetList
|
|
775
|
-
);
|
|
776
|
-
}
|
|
777
|
-
}
|
|
778
|
-
|
|
779
|
-
let newColspan =
|
|
780
|
-
colArray[mergedColIdx].options.colspan * 1 +
|
|
781
|
-
colArray[remainedColIdx].options.colspan * 1;
|
|
782
|
-
this.setPropsOfMergedCols(
|
|
783
|
-
rowArray,
|
|
784
|
-
curRow,
|
|
785
|
-
remainedColIdx,
|
|
786
|
-
newColspan,
|
|
787
|
-
cellWidget.options.rowspan
|
|
788
|
-
);
|
|
789
|
-
|
|
790
|
-
this.emitHistoryChange();
|
|
791
|
-
},
|
|
792
|
-
|
|
793
|
-
mergeTableWholeRow(rowArray, colArray, rowIndex, colIndex) {
|
|
794
|
-
//需要考虑操作的行存在已合并的单元格!!
|
|
795
|
-
//整行所有单元格行高不一致不可合并!!
|
|
796
|
-
let startRowspan = rowArray[rowIndex].cols[0].options.rowspan;
|
|
797
|
-
let unmatchedFlag = false;
|
|
798
|
-
for (let i = 1; i < rowArray[rowIndex].cols.length; i++) {
|
|
799
|
-
if (rowArray[rowIndex].cols[i].options.rowspan !== startRowspan) {
|
|
800
|
-
unmatchedFlag = true;
|
|
801
|
-
break;
|
|
802
|
-
}
|
|
803
|
-
}
|
|
804
|
-
if (unmatchedFlag) {
|
|
805
|
-
this.vueInstance.$message.info(
|
|
806
|
-
this.vueInstance.i18nt(
|
|
807
|
-
"designer.hint.rowspanNotConsistentForMergeEntireRow"
|
|
808
|
-
)
|
|
809
|
-
);
|
|
810
|
-
return;
|
|
811
|
-
}
|
|
812
|
-
|
|
813
|
-
let widgetListCols = colArray.filter((colItem) => {
|
|
814
|
-
return (
|
|
815
|
-
!colItem.merged &&
|
|
816
|
-
!!colItem.widgetList &&
|
|
817
|
-
colItem.widgetList.length > 0
|
|
818
|
-
);
|
|
819
|
-
});
|
|
820
|
-
if (!!widgetListCols && widgetListCols.length > 0) {
|
|
821
|
-
//保留widgetList
|
|
822
|
-
if (
|
|
823
|
-
widgetListCols[0].id !== colArray[0].id &&
|
|
824
|
-
(!colArray[0].widgetList || colArray[0].widgetList.length <= 0)
|
|
825
|
-
) {
|
|
826
|
-
colArray[0].widgetList = baseRefUtil.deepClone(
|
|
827
|
-
widgetListCols[0].widgetList
|
|
828
|
-
);
|
|
829
|
-
}
|
|
830
|
-
}
|
|
831
|
-
|
|
832
|
-
this.setPropsOfMergedCols(
|
|
833
|
-
rowArray,
|
|
834
|
-
rowIndex,
|
|
835
|
-
0,
|
|
836
|
-
colArray.length,
|
|
837
|
-
colArray[colIndex].options.rowspan
|
|
838
|
-
);
|
|
839
|
-
|
|
840
|
-
this.emitHistoryChange();
|
|
841
|
-
},
|
|
842
|
-
|
|
843
|
-
mergeTableRow(rowArray, curRow, curCol, aboveFlag, cellWidget) {
|
|
844
|
-
let mergedRowIdx = !!aboveFlag
|
|
845
|
-
? curRow
|
|
846
|
-
: curRow + cellWidget.options.rowspan;
|
|
847
|
-
|
|
848
|
-
//let remainedRowIdx = !!aboveFlag ? curRow - cellWidget.options.rowspan : curRow
|
|
849
|
-
let remainedRowIdx = !!aboveFlag ? curRow - 1 : curRow;
|
|
850
|
-
if (!!aboveFlag) {
|
|
851
|
-
//继续向上寻找同列未被合并的第一个单元格
|
|
852
|
-
let tmpRowIdx = remainedRowIdx;
|
|
853
|
-
while (tmpRowIdx >= 0) {
|
|
854
|
-
if (!rowArray[tmpRowIdx].cols[curCol].merged) {
|
|
855
|
-
remainedRowIdx = tmpRowIdx;
|
|
856
|
-
break;
|
|
857
|
-
} else {
|
|
858
|
-
tmpRowIdx--;
|
|
859
|
-
}
|
|
860
|
-
}
|
|
861
|
-
}
|
|
862
|
-
|
|
863
|
-
if (
|
|
864
|
-
!!rowArray[mergedRowIdx].cols[curCol].widgetList &&
|
|
865
|
-
rowArray[mergedRowIdx].cols[curCol].widgetList.length > 0
|
|
866
|
-
) {
|
|
867
|
-
//保留widgetList
|
|
868
|
-
if (
|
|
869
|
-
!rowArray[remainedRowIdx].cols[curCol].widgetList ||
|
|
870
|
-
rowArray[remainedRowIdx].cols[curCol].widgetList.length === 0
|
|
871
|
-
) {
|
|
872
|
-
rowArray[remainedRowIdx].cols[curCol].widgetList =
|
|
873
|
-
baseRefUtil.deepClone(
|
|
874
|
-
rowArray[mergedRowIdx].cols[curCol].widgetList
|
|
875
|
-
);
|
|
876
|
-
}
|
|
877
|
-
}
|
|
878
|
-
|
|
879
|
-
let newRowspan =
|
|
880
|
-
rowArray[mergedRowIdx].cols[curCol].options.rowspan * 1 +
|
|
881
|
-
rowArray[remainedRowIdx].cols[curCol].options.rowspan * 1;
|
|
882
|
-
this.setPropsOfMergedRows(
|
|
883
|
-
rowArray,
|
|
884
|
-
remainedRowIdx,
|
|
885
|
-
curCol,
|
|
886
|
-
cellWidget.options.colspan,
|
|
887
|
-
newRowspan
|
|
888
|
-
);
|
|
889
|
-
|
|
890
|
-
this.emitHistoryChange();
|
|
891
|
-
},
|
|
892
|
-
|
|
893
|
-
mergeTableWholeCol(rowArray, colArray, rowIndex, colIndex) {
|
|
894
|
-
//需要考虑操作的列存在已合并的单元格!!
|
|
895
|
-
//整列所有单元格列宽不一致不可合并!!
|
|
896
|
-
let startColspan = rowArray[0].cols[colIndex].options.colspan;
|
|
897
|
-
let unmatchedFlag = false;
|
|
898
|
-
for (let i = 1; i < rowArray.length; i++) {
|
|
899
|
-
if (rowArray[i].cols[colIndex].options.colspan !== startColspan) {
|
|
900
|
-
unmatchedFlag = true;
|
|
901
|
-
break;
|
|
902
|
-
}
|
|
903
|
-
}
|
|
904
|
-
if (unmatchedFlag) {
|
|
905
|
-
this.vueInstance.$message.info(
|
|
906
|
-
this.vueInstance.i18nt(
|
|
907
|
-
"designer.hint.colspanNotConsistentForMergeEntireColumn"
|
|
908
|
-
)
|
|
909
|
-
);
|
|
910
|
-
return;
|
|
911
|
-
}
|
|
912
|
-
|
|
913
|
-
let widgetListCols = [];
|
|
914
|
-
rowArray.forEach((rowItem) => {
|
|
915
|
-
let tempCell = rowItem.cols[colIndex];
|
|
916
|
-
if (
|
|
917
|
-
!tempCell.merged &&
|
|
918
|
-
!!tempCell.widgetList &&
|
|
919
|
-
tempCell.widgetList.length > 0
|
|
920
|
-
) {
|
|
921
|
-
widgetListCols.push(tempCell);
|
|
922
|
-
}
|
|
923
|
-
});
|
|
924
|
-
|
|
925
|
-
let firstCellOfCol = rowArray[0].cols[colIndex];
|
|
926
|
-
if (!!widgetListCols && widgetListCols.length > 0) {
|
|
927
|
-
//保留widgetList
|
|
928
|
-
if (
|
|
929
|
-
widgetListCols[0].id !== firstCellOfCol.id &&
|
|
930
|
-
(!firstCellOfCol.widgetList ||
|
|
931
|
-
firstCellOfCol.widgetList.length <= 0)
|
|
932
|
-
) {
|
|
933
|
-
firstCellOfCol.widgetList = baseRefUtil.deepClone(
|
|
934
|
-
widgetListCols[0].widgetList
|
|
935
|
-
);
|
|
936
|
-
}
|
|
937
|
-
}
|
|
938
|
-
|
|
939
|
-
this.setPropsOfMergedRows(
|
|
940
|
-
rowArray,
|
|
941
|
-
0,
|
|
942
|
-
colIndex,
|
|
943
|
-
firstCellOfCol.options.colspan,
|
|
944
|
-
rowArray.length
|
|
945
|
-
);
|
|
946
|
-
|
|
947
|
-
this.emitHistoryChange();
|
|
948
|
-
},
|
|
949
|
-
|
|
950
|
-
undoMergeTableCol(rowArray, rowIndex, colIndex, colspan, rowspan) {
|
|
951
|
-
this.setPropsOfSplitCol(rowArray, rowIndex, colIndex, colspan, rowspan);
|
|
952
|
-
|
|
953
|
-
this.emitHistoryChange();
|
|
954
|
-
},
|
|
955
|
-
|
|
956
|
-
undoMergeTableRow(rowArray, rowIndex, colIndex, colspan, rowspan) {
|
|
957
|
-
this.setPropsOfSplitRow(rowArray, rowIndex, colIndex, colspan, rowspan);
|
|
958
|
-
|
|
959
|
-
this.emitHistoryChange();
|
|
960
|
-
},
|
|
961
|
-
|
|
962
|
-
deleteTableWholeCol(rowArray, colIndex) {
|
|
963
|
-
//需考虑删除的是合并列!!
|
|
964
|
-
let onlyOneColFlag = true;
|
|
965
|
-
rowArray.forEach((ri) => {
|
|
966
|
-
if (ri.cols[0].options.colspan !== rowArray[0].cols.length) {
|
|
967
|
-
onlyOneColFlag = false;
|
|
968
|
-
}
|
|
969
|
-
});
|
|
970
|
-
//仅剩一列则不可删除!!
|
|
971
|
-
if (onlyOneColFlag) {
|
|
972
|
-
this.vueInstance.$message.info(
|
|
973
|
-
this.vueInstance.i18nt("designer.hint.lastColCannotBeDeleted")
|
|
974
|
-
);
|
|
975
|
-
return;
|
|
976
|
-
}
|
|
977
|
-
|
|
978
|
-
//整列所有单元格列宽不一致不可删除!!
|
|
979
|
-
let startColspan = rowArray[0].cols[colIndex].options.colspan;
|
|
980
|
-
let unmatchedFlag = false;
|
|
981
|
-
for (let i = 1; i < rowArray.length; i++) {
|
|
982
|
-
if (rowArray[i].cols[colIndex].options.colspan !== startColspan) {
|
|
983
|
-
unmatchedFlag = true;
|
|
984
|
-
break;
|
|
985
|
-
}
|
|
986
|
-
}
|
|
987
|
-
if (unmatchedFlag) {
|
|
988
|
-
this.vueInstance.$message.info(
|
|
989
|
-
this.vueInstance.i18nt(
|
|
990
|
-
"designer.hint.colspanNotConsistentForDeleteEntireColumn"
|
|
991
|
-
)
|
|
992
|
-
);
|
|
993
|
-
return;
|
|
994
|
-
}
|
|
995
|
-
|
|
996
|
-
rowArray.forEach((rItem) => {
|
|
997
|
-
rItem.cols.splice(colIndex, startColspan);
|
|
998
|
-
});
|
|
999
|
-
|
|
1000
|
-
this.emitHistoryChange();
|
|
1001
|
-
},
|
|
1002
|
-
|
|
1003
|
-
deleteTableWholeRow(rowArray, rowIndex) {
|
|
1004
|
-
//需考虑删除的是合并行!!
|
|
1005
|
-
let onlyOneRowFlag = true;
|
|
1006
|
-
rowArray[0].cols.forEach((ci) => {
|
|
1007
|
-
if (ci.options.rowspan !== rowArray.length) {
|
|
1008
|
-
onlyOneRowFlag = false;
|
|
1009
|
-
}
|
|
1010
|
-
});
|
|
1011
|
-
//仅剩一行则不可删除!!
|
|
1012
|
-
if (onlyOneRowFlag) {
|
|
1013
|
-
this.vueInstance.$message.info(
|
|
1014
|
-
this.vueInstance.i18nt("designer.hint.lastRowCannotBeDeleted")
|
|
1015
|
-
);
|
|
1016
|
-
return;
|
|
1017
|
-
}
|
|
1018
|
-
|
|
1019
|
-
//整行所有单元格行高不一致不可删除!!
|
|
1020
|
-
let startRowspan = rowArray[rowIndex].cols[0].options.rowspan;
|
|
1021
|
-
let unmatchedFlag = false;
|
|
1022
|
-
for (let i = 1; i < rowArray[rowIndex].cols.length; i++) {
|
|
1023
|
-
if (rowArray[rowIndex].cols[i].options.rowspan !== startRowspan) {
|
|
1024
|
-
unmatchedFlag = true;
|
|
1025
|
-
break;
|
|
1026
|
-
}
|
|
1027
|
-
}
|
|
1028
|
-
if (unmatchedFlag) {
|
|
1029
|
-
this.vueInstance.$message.info(
|
|
1030
|
-
this.vueInstance.i18nt(
|
|
1031
|
-
"designer.hint.rowspanNotConsistentForDeleteEntireRow"
|
|
1032
|
-
)
|
|
1033
|
-
);
|
|
1034
|
-
return;
|
|
1035
|
-
}
|
|
1036
|
-
|
|
1037
|
-
rowArray.splice(rowIndex, startRowspan);
|
|
1038
|
-
|
|
1039
|
-
this.emitHistoryChange();
|
|
1040
|
-
},
|
|
1041
|
-
|
|
1042
|
-
getContainerByType(typeName) {
|
|
1043
|
-
let allWidgets = [
|
|
1044
|
-
...baseRefUtil.containers,
|
|
1045
|
-
...baseRefUtil.basicFields,
|
|
1046
|
-
...baseRefUtil.advancedFields,
|
|
1047
|
-
...baseRefUtil.customFields,
|
|
1048
|
-
...businessFields,
|
|
1049
|
-
];
|
|
1050
|
-
let foundCon = null;
|
|
1051
|
-
allWidgets.forEach((con) => {
|
|
1052
|
-
if (!!con.category && !!con.type && con.type === typeName) {
|
|
1053
|
-
foundCon = con;
|
|
1054
|
-
}
|
|
1055
|
-
});
|
|
1056
|
-
|
|
1057
|
-
return foundCon;
|
|
1058
|
-
},
|
|
1059
|
-
|
|
1060
|
-
getFieldWidgetByType(typeName) {
|
|
1061
|
-
let allWidgets = [
|
|
1062
|
-
...baseRefUtil.containers,
|
|
1063
|
-
...baseRefUtil.basicFields,
|
|
1064
|
-
...baseRefUtil.advancedFields,
|
|
1065
|
-
...baseRefUtil.customFields,
|
|
1066
|
-
...chartContainers,
|
|
1067
|
-
...chartWidgets,
|
|
1068
|
-
...businessFields,
|
|
1069
|
-
];
|
|
1070
|
-
let foundWidget = null;
|
|
1071
|
-
allWidgets.forEach((widget) => {
|
|
1072
|
-
if (!!!widget.category && !!widget.type && widget.type === typeName) {
|
|
1073
|
-
foundWidget = widget;
|
|
1074
|
-
}
|
|
1075
|
-
});
|
|
1076
|
-
|
|
1077
|
-
return foundWidget;
|
|
1078
|
-
},
|
|
1079
|
-
|
|
1080
|
-
hasConfig(widget, configName) {
|
|
1081
|
-
let originalWidget = null;
|
|
1082
|
-
if (!!widget.category) {
|
|
1083
|
-
originalWidget = this.getContainerByType(widget.type);
|
|
1084
|
-
} else {
|
|
1085
|
-
originalWidget = this.getFieldWidgetByType(widget.type);
|
|
1086
|
-
}
|
|
1087
|
-
|
|
1088
|
-
if (!originalWidget || !originalWidget.options) {
|
|
1089
|
-
return false;
|
|
1090
|
-
}
|
|
1091
|
-
|
|
1092
|
-
return Object.keys(originalWidget.options).indexOf(configName) > -1;
|
|
1093
|
-
},
|
|
1094
|
-
/*upgradeWidgetConfig(oldWidget) {
|
|
1095
|
-
let newWidget = null;
|
|
1096
|
-
if (!!oldWidget.category) {
|
|
1097
|
-
newWidget = this.getContainerByType(oldWidget.type);
|
|
1098
|
-
} else {
|
|
1099
|
-
newWidget = this.getFieldWidgetByType(oldWidget.type);
|
|
1100
|
-
}
|
|
1101
|
-
|
|
1102
|
-
if (!newWidget || !newWidget.options) {
|
|
1103
|
-
return;
|
|
1104
|
-
}
|
|
1105
|
-
|
|
1106
|
-
Object.keys(newWidget.options).forEach(ck => {
|
|
1107
|
-
if (!oldWidget.options.hasOwnProperty(ck)) {
|
|
1108
|
-
oldWidget.options[ck] = baseRefUtil.deepClone(newWidget.options[ck]);
|
|
1109
|
-
}
|
|
1110
|
-
});
|
|
1111
|
-
},*/
|
|
1112
|
-
upgradeWidgetConfig(oldWidget) {
|
|
1113
|
-
let newWidget = null;
|
|
1114
|
-
if (!!oldWidget.category) {
|
|
1115
|
-
newWidget = this.getContainerByType(oldWidget.type);
|
|
1116
|
-
} else {
|
|
1117
|
-
newWidget = this.getFieldWidgetByType(oldWidget.type);
|
|
1118
|
-
}
|
|
1119
|
-
|
|
1120
|
-
if (!newWidget || !newWidget.options) {
|
|
1121
|
-
return;
|
|
1122
|
-
}
|
|
1123
|
-
|
|
1124
|
-
Object.keys(newWidget.options).forEach((ck) => {
|
|
1125
|
-
if (!oldWidget.options.hasOwnProperty(ck)) {
|
|
1126
|
-
let value = newWidget.options[ck];
|
|
1127
|
-
let nullValue = Array.isArray(value) ? [] : null;
|
|
1128
|
-
oldWidget.options[ck] = nullValue;
|
|
1129
|
-
}
|
|
1130
|
-
});
|
|
1131
|
-
},
|
|
1132
|
-
|
|
1133
|
-
upgradeFormConfig(oldFormConfig) {
|
|
1134
|
-
Object.keys(this.formConfig).forEach((fc) => {
|
|
1135
|
-
if (!oldFormConfig.hasOwnProperty(fc)) {
|
|
1136
|
-
let value = this.formConfig[fc];
|
|
1137
|
-
let nullValue = Array.isArray(value) ? [] : null;
|
|
1138
|
-
oldFormConfig[fc] = baseRefUtil.deepClone(nullValue);
|
|
1139
|
-
}
|
|
1140
|
-
});
|
|
1141
|
-
},
|
|
1142
|
-
|
|
1143
|
-
cloneGridCol(widget, parentWidget) {
|
|
1144
|
-
let newGridCol = baseRefUtil.deepClone(
|
|
1145
|
-
this.getContainerByType("grid-col")
|
|
1146
|
-
);
|
|
1147
|
-
newGridCol.options.span = widget.options.span;
|
|
1148
|
-
let tmpId = baseRefUtil.generateId();
|
|
1149
|
-
newGridCol.id = "grid-col-" + tmpId;
|
|
1150
|
-
newGridCol.options.name = "gridCol" + tmpId;
|
|
1151
|
-
|
|
1152
|
-
parentWidget.cols.push(newGridCol);
|
|
1153
|
-
},
|
|
1154
|
-
|
|
1155
|
-
cloneContainer(containWidget) {
|
|
1156
|
-
if (containWidget.type === "grid") {
|
|
1157
|
-
let newGrid = baseRefUtil.deepClone(this.getContainerByType("grid"));
|
|
1158
|
-
newGrid.id = newGrid.type + baseRefUtil.generateId();
|
|
1159
|
-
newGrid.options.name = newGrid.id;
|
|
1160
|
-
containWidget.cols.forEach((gridCol) => {
|
|
1161
|
-
let newGridCol = baseRefUtil.deepClone(
|
|
1162
|
-
this.getContainerByType("grid-col")
|
|
1163
|
-
);
|
|
1164
|
-
let tmpId = baseRefUtil.generateId();
|
|
1165
|
-
newGridCol.id = "grid-col-" + tmpId;
|
|
1166
|
-
newGridCol.options.name = "gridCol" + tmpId;
|
|
1167
|
-
newGridCol.options.span = gridCol.options.span;
|
|
1168
|
-
newGrid.cols.push(newGridCol);
|
|
1169
|
-
});
|
|
1170
|
-
|
|
1171
|
-
return newGrid;
|
|
1172
|
-
} else if (containWidget.type === "table") {
|
|
1173
|
-
let newTable = baseRefUtil.deepClone(
|
|
1174
|
-
this.getContainerByType("table")
|
|
1175
|
-
);
|
|
1176
|
-
newTable.id = newTable.type + baseRefUtil.generateId();
|
|
1177
|
-
newTable.options.name = newTable.id;
|
|
1178
|
-
containWidget.rows.forEach((tRow) => {
|
|
1179
|
-
let newRow = baseRefUtil.deepClone(tRow);
|
|
1180
|
-
newRow.id = "table-row-" + baseRefUtil.generateId();
|
|
1181
|
-
newRow.cols.forEach((col) => {
|
|
1182
|
-
col.id = "table-cell-" + baseRefUtil.generateId();
|
|
1183
|
-
col.options.name = col.id;
|
|
1184
|
-
col.widgetList = []; //清空组件列表
|
|
1185
|
-
});
|
|
1186
|
-
newTable.rows.push(newRow);
|
|
1187
|
-
});
|
|
1188
|
-
|
|
1189
|
-
return newTable;
|
|
1190
|
-
} else if (containWidget.type === "h5-table") {
|
|
1191
|
-
let newTable = baseRefUtil.deepClone(
|
|
1192
|
-
this.getContainerByType("h5-table")
|
|
1193
|
-
);
|
|
1194
|
-
newTable.id = newTable.type + baseRefUtil.generateId();
|
|
1195
|
-
newTable.options.name = newTable.id;
|
|
1196
|
-
containWidget.rows.forEach((tRow) => {
|
|
1197
|
-
let newRow = baseRefUtil.deepClone(tRow);
|
|
1198
|
-
newRow.id = "table-row-" + baseRefUtil.generateId();
|
|
1199
|
-
newRow.cols.forEach((col) => {
|
|
1200
|
-
col.id = "table-cell-" + baseRefUtil.generateId();
|
|
1201
|
-
col.options.name = col.id;
|
|
1202
|
-
col.widgetList = []; //清空组件列表
|
|
1203
|
-
});
|
|
1204
|
-
newTable.rows.push(newRow);
|
|
1205
|
-
});
|
|
1206
|
-
|
|
1207
|
-
return newTable;
|
|
1208
|
-
} else {
|
|
1209
|
-
//其他容器组件不支持clone操作
|
|
1210
|
-
return null;
|
|
1211
|
-
}
|
|
1212
|
-
},
|
|
1213
|
-
|
|
1214
|
-
moveUpWidget(parentList, indexOfParentList) {
|
|
1215
|
-
if (!!parentList) {
|
|
1216
|
-
if (indexOfParentList === 0) {
|
|
1217
|
-
this.vueInstance.$message(
|
|
1218
|
-
this.vueInstance.i18nt("designer.hint.moveUpFirstChildHint")
|
|
1219
|
-
);
|
|
1220
|
-
return;
|
|
1221
|
-
}
|
|
1222
|
-
|
|
1223
|
-
let tempWidget = parentList[indexOfParentList];
|
|
1224
|
-
parentList.splice(indexOfParentList, 1);
|
|
1225
|
-
parentList.splice(indexOfParentList - 1, 0, tempWidget);
|
|
1226
|
-
}
|
|
1227
|
-
},
|
|
1228
|
-
|
|
1229
|
-
moveDownWidget(parentList, indexOfParentList) {
|
|
1230
|
-
if (!!parentList) {
|
|
1231
|
-
if (indexOfParentList === parentList.length - 1) {
|
|
1232
|
-
this.vueInstance.$message(
|
|
1233
|
-
this.vueInstance.i18nt("designer.hint.moveDownLastChildHint")
|
|
1234
|
-
);
|
|
1235
|
-
return;
|
|
1236
|
-
}
|
|
1237
|
-
|
|
1238
|
-
let tempWidget = parentList[indexOfParentList];
|
|
1239
|
-
parentList.splice(indexOfParentList, 1);
|
|
1240
|
-
parentList.splice(indexOfParentList + 1, 0, tempWidget);
|
|
1241
|
-
}
|
|
1242
|
-
},
|
|
1243
|
-
copyNewFieldWidget(origin) {
|
|
1244
|
-
let newWidget = baseRefUtil.deepClone(origin);
|
|
1245
|
-
let sourceType = newWidget.type;
|
|
1246
|
-
newWidget.type = newWidget.targetType || newWidget.type;
|
|
1247
|
-
newWidget.sourceType = sourceType;
|
|
1248
|
-
let tempId = baseRefUtil.generateId();
|
|
1249
|
-
newWidget.id = newWidget.type.replace(/-/g, "") + tempId;
|
|
1250
|
-
if (newWidget.hasOwnProperty("tableField")) {
|
|
1251
|
-
newWidget.tableField = newWidget.id; //表字段
|
|
1252
|
-
}
|
|
1253
|
-
|
|
1254
|
-
// newWidget.options.name = newWidget.id;
|
|
1255
|
-
// newWidget.options.label = newWidget.options.label || newWidget.type.toLowerCase();
|
|
1256
|
-
|
|
1257
|
-
newWidget.nameReadonly
|
|
1258
|
-
? newWidget.options.label &&
|
|
1259
|
-
newWidget.options.label.indexOf(".") > -1 &&
|
|
1260
|
-
(newWidget.options.label = newWidget.options.label.substring(
|
|
1261
|
-
newWidget.options.label.indexOf(".") + 1
|
|
1262
|
-
))
|
|
1263
|
-
: ((newWidget.options.name = newWidget.id),
|
|
1264
|
-
(newWidget.options.label =
|
|
1265
|
-
newWidget.options.label || newWidget.type.toLowerCase()));
|
|
1266
|
-
delete newWidget.displayName;
|
|
1267
|
-
if (!newWidget.nameReadonly) {
|
|
1268
|
-
newWidget.options.keyNameEnabled = true;
|
|
1269
|
-
if (!newWidget.options.keyName)
|
|
1270
|
-
newWidget.options.keyName = newWidget.id;
|
|
1271
|
-
if (
|
|
1272
|
-
newWidget.type === "vabUpload" ||
|
|
1273
|
-
newWidget.type === "baseAttachment"
|
|
1274
|
-
) {
|
|
1275
|
-
let keyNameSuffix = this.createKeyNameSuffix(newWidget.type);
|
|
1276
|
-
// this.createKeyNameSuffix()
|
|
1277
|
-
newWidget.options.keyName = this.createKeyName(
|
|
1278
|
-
newWidget.type,
|
|
1279
|
-
keyNameSuffix
|
|
1280
|
-
);
|
|
1281
|
-
newWidget.options.keyNameSuffix = keyNameSuffix;
|
|
1282
|
-
}
|
|
1283
|
-
}
|
|
1284
|
-
if (newWidget.type === "dropdown") {
|
|
1285
|
-
let dropdownItem1 = this.copyNewFieldWidget(
|
|
1286
|
-
this.getFieldWidgetByType("dropdown-item")
|
|
1287
|
-
);
|
|
1288
|
-
dropdownItem1.options.label = "下拉按钮1";
|
|
1289
|
-
let dropdownItem2 = this.copyNewFieldWidget(
|
|
1290
|
-
this.getFieldWidgetByType("dropdown-item")
|
|
1291
|
-
);
|
|
1292
|
-
dropdownItem2.options.label = "下拉按钮2";
|
|
1293
|
-
newWidget.widgetList.push(dropdownItem1);
|
|
1294
|
-
newWidget.widgetList.push(dropdownItem2);
|
|
1295
|
-
}
|
|
1296
|
-
this.emitEvent("canvas-add-field", newWidget.options.name);
|
|
1297
|
-
return newWidget;
|
|
1298
|
-
},
|
|
1299
|
-
createKeyName(type, suffix) {
|
|
1300
|
-
let keyNameSuffix = suffix ? suffix : this.createKeyNameSuffix(type);
|
|
1301
|
-
let keyNamePrefix = this.getKeyNamePrefix(type);
|
|
1302
|
-
let keyName = null;
|
|
1303
|
-
if (keyNamePrefix) {
|
|
1304
|
-
keyName = keyNamePrefix + keyNameSuffix;
|
|
1305
|
-
} else {
|
|
1306
|
-
keyName = keyNameSuffix;
|
|
1307
|
-
}
|
|
1308
|
-
return keyName;
|
|
1309
|
-
},
|
|
1310
|
-
createKeyNameSuffix(type) {
|
|
1311
|
-
let suffix = createUUID();
|
|
1312
|
-
/*if (type === "vabUpload" || type === "baseAttachment") {
|
|
1313
|
-
let formCode = vueInstance.reportTemplate.formCode;
|
|
1314
|
-
suffix = formCode + "_" + suffix;
|
|
1315
|
-
}*/
|
|
1316
|
-
return suffix;
|
|
1317
|
-
},
|
|
1318
|
-
getKeyNamePrefix(type) {
|
|
1319
|
-
return keyNamePrefixMap[type] ?? null;
|
|
1320
|
-
},
|
|
1321
|
-
getFormCodePrefix(type) {
|
|
1322
|
-
let prefix = this.getKeyNamePrefix(type) || "";
|
|
1323
|
-
let attachmentPrefix =
|
|
1324
|
-
prefix + vueInstance.reportTemplate.formCode + "_";
|
|
1325
|
-
return attachmentPrefix;
|
|
1326
|
-
},
|
|
1327
|
-
createAttachmentSuffix() {
|
|
1328
|
-
let type = "vabUpload";
|
|
1329
|
-
return this.createKeyNameSuffix(type);
|
|
1330
|
-
},
|
|
1331
|
-
getAttachmentPrefix() {
|
|
1332
|
-
let type = "vabUpload";
|
|
1333
|
-
return this.getKeyNamePrefix(type);
|
|
1334
|
-
},
|
|
1335
|
-
getAttachmentFormCodePrefix() {
|
|
1336
|
-
let type = "vabUpload";
|
|
1337
|
-
let attachmentPrefix = this.getFormCodePrefix(type);
|
|
1338
|
-
return attachmentPrefix;
|
|
1339
|
-
},
|
|
1340
|
-
createAttachmentKeyName(suffix) {
|
|
1341
|
-
let type = "vabUpload";
|
|
1342
|
-
let keyName = this.createKeyName(type, suffix);
|
|
1343
|
-
return keyName;
|
|
1344
|
-
},
|
|
1345
|
-
copyNewContainerWidget(origin) {
|
|
1346
|
-
let newCon = baseRefUtil.deepClone(origin);
|
|
1347
|
-
let sourceType = newCon.type;
|
|
1348
|
-
newCon.type = newCon.targetType || newCon.type;
|
|
1349
|
-
newCon.sourceType = sourceType;
|
|
1350
|
-
newCon.id = newCon.type.replace(/-/g, "") + baseRefUtil.generateId();
|
|
1351
|
-
newCon.options.name = newCon.id;
|
|
1352
|
-
if ((newCon.options.keyNameEnabled = true)) {
|
|
1353
|
-
newCon.options.keyName = newCon.id;
|
|
1354
|
-
}
|
|
1355
|
-
if (newCon.hasOwnProperty("tableField")) {
|
|
1356
|
-
newCon.tableField = newCon.id; //表字段
|
|
1357
|
-
}
|
|
1358
|
-
if (newCon.type === "grid") {
|
|
1359
|
-
let newCol = baseRefUtil.deepClone(
|
|
1360
|
-
this.getContainerByType("grid-col")
|
|
1361
|
-
);
|
|
1362
|
-
let tmpId = baseRefUtil.generateId();
|
|
1363
|
-
newCol.id = "grid-col-" + tmpId;
|
|
1364
|
-
newCol.options.name = "gridCol" + tmpId;
|
|
1365
|
-
newCon.cols.push(newCol);
|
|
1366
|
-
//
|
|
1367
|
-
newCol = baseRefUtil.deepClone(newCol);
|
|
1368
|
-
tmpId = baseRefUtil.generateId();
|
|
1369
|
-
newCol.id = "grid-col-" + tmpId;
|
|
1370
|
-
newCol.options.name = "gridCol" + tmpId;
|
|
1371
|
-
newCon.cols.push(newCol);
|
|
1372
|
-
} else if (newCon.type === "table") {
|
|
1373
|
-
let newRow = {
|
|
1374
|
-
cols: [],
|
|
1375
|
-
};
|
|
1376
|
-
newRow.id = "table-row-" + baseRefUtil.generateId();
|
|
1377
|
-
newRow.merged = false;
|
|
1378
|
-
for (let i = 0; i < 4; i++) {
|
|
1379
|
-
let newCell = baseRefUtil.deepClone(
|
|
1380
|
-
this.getContainerByType("table-cell")
|
|
1381
|
-
);
|
|
1382
|
-
newCell.id = "table-cell-" + baseRefUtil.generateId();
|
|
1383
|
-
newCell.options.name = newCell.id;
|
|
1384
|
-
newCell.merged = false;
|
|
1385
|
-
newCell.options.colspan = 1;
|
|
1386
|
-
newCell.options.rowspan = 1;
|
|
1387
|
-
newRow.cols.push(newCell);
|
|
1388
|
-
}
|
|
1389
|
-
newCon.rows.push(newRow);
|
|
1390
|
-
} else if (newCon.type === "tab") {
|
|
1391
|
-
let newTabPane = baseRefUtil.deepClone(
|
|
1392
|
-
this.getContainerByType("tab-pane")
|
|
1393
|
-
);
|
|
1394
|
-
newTabPane.id = "tab-pane-" + baseRefUtil.generateId();
|
|
1395
|
-
newTabPane.options.name = "tab1";
|
|
1396
|
-
newTabPane.options.label = "tab 1";
|
|
1397
|
-
newCon.tabs.push(newTabPane);
|
|
1398
|
-
} else if (newCon.type === "data-table") {
|
|
1399
|
-
let add_button = this.copyNewFieldWidget(
|
|
1400
|
-
this.getFieldWidgetByType("add_button")
|
|
1401
|
-
);
|
|
1402
|
-
add_button.options.onClick =
|
|
1403
|
-
"this.getWidgetRef('" +
|
|
1404
|
-
newCon.options.name +
|
|
1405
|
-
"').openEditDialog();";
|
|
1406
|
-
newCon.buttons.push(add_button);
|
|
1407
|
-
} else if (newCon.type === "detail") {
|
|
1408
|
-
let buttonCon1 = this.copyNewFieldWidget(
|
|
1409
|
-
this.getFieldWidgetByType("reset_button")
|
|
1410
|
-
);
|
|
1411
|
-
// buttonCon1.options.label = "重置";
|
|
1412
|
-
|
|
1413
|
-
let buttonCon2 = this.copyNewFieldWidget(
|
|
1414
|
-
this.getFieldWidgetByType("save_button")
|
|
1415
|
-
);
|
|
1416
|
-
buttonCon2.options.label = "保存";
|
|
1417
|
-
|
|
1418
|
-
newCon.widgetList.push(buttonCon1);
|
|
1419
|
-
newCon.widgetList.push(buttonCon2);
|
|
1420
|
-
|
|
1421
|
-
let newCol = baseRefUtil.deepClone(
|
|
1422
|
-
this.getContainerByType("detail-pane")
|
|
1423
|
-
);
|
|
1424
|
-
let tmpId = baseRefUtil.generateId();
|
|
1425
|
-
newCol.id = "detail-pane-" + tmpId;
|
|
1426
|
-
newCol.options.name = "detailPane" + tmpId;
|
|
1427
|
-
newCol.options.label = "隐藏信息";
|
|
1428
|
-
newCol.options.hidden = true;
|
|
1429
|
-
|
|
1430
|
-
let tableCon = this.copyNewContainerWidget(
|
|
1431
|
-
this.getContainerByType("table")
|
|
1432
|
-
);
|
|
1433
|
-
newCol.widgetList.push(tableCon);
|
|
1434
|
-
newCon.panes.push(newCol);
|
|
1435
|
-
|
|
1436
|
-
newCol = baseRefUtil.deepClone(
|
|
1437
|
-
this.getContainerByType("detail-pane")
|
|
1438
|
-
);
|
|
1439
|
-
tmpId = baseRefUtil.generateId();
|
|
1440
|
-
newCol.id = "detail-pane-" + tmpId;
|
|
1441
|
-
newCol.options.name = "detailPane" + tmpId;
|
|
1442
|
-
newCol.options.label = "基础信息";
|
|
1443
|
-
|
|
1444
|
-
tableCon = this.copyNewContainerWidget(
|
|
1445
|
-
this.getContainerByType("table")
|
|
1446
|
-
);
|
|
1447
|
-
newCol.widgetList.push(tableCon);
|
|
1448
|
-
newCon.panes.push(newCol);
|
|
1449
|
-
//
|
|
1450
|
-
newCol = baseRefUtil.deepClone(
|
|
1451
|
-
this.getContainerByType("detail-pane")
|
|
1452
|
-
);
|
|
1453
|
-
tmpId = baseRefUtil.generateId();
|
|
1454
|
-
newCol.id = "detail-pane-" + tmpId;
|
|
1455
|
-
newCol.options.name = "detailPane" + tmpId;
|
|
1456
|
-
newCol.options.label = "明细信息";
|
|
1457
|
-
newCol.options.tableRef = tableCon.id;
|
|
1458
|
-
let dataTableCon = this.copyNewContainerWidget(
|
|
1459
|
-
this.getContainerByType("data-table")
|
|
1460
|
-
);
|
|
1461
|
-
newCol.widgetList.push(dataTableCon);
|
|
1462
|
-
newCol.options.tableRef = dataTableCon.id;
|
|
1463
|
-
|
|
1464
|
-
let buttonCon3 = this.copyNewFieldWidget(
|
|
1465
|
-
this.getFieldWidgetByType("button")
|
|
1466
|
-
);
|
|
1467
|
-
buttonCon3.options.label = "新增";
|
|
1468
|
-
buttonCon3.options.icon = "el-icon-search";
|
|
1469
|
-
// buttonCon3.options.onClick = "this.getWidgetRef('" + dataTableCon.options.name + "').addTableData();"
|
|
1470
|
-
buttonCon3.options.clickBindEvent = "2";
|
|
1471
|
-
Object.assign(buttonCon3.options.addTableDataConfig, {
|
|
1472
|
-
tableRef: dataTableCon.options.name,
|
|
1473
|
-
});
|
|
1474
|
-
|
|
1475
|
-
newCol.buttonWidgetList.push(buttonCon3);
|
|
1476
|
-
newCon.panes.push(newCol);
|
|
1477
|
-
|
|
1478
|
-
newCol = baseRefUtil.deepClone(
|
|
1479
|
-
this.getContainerByType("detail-pane")
|
|
1480
|
-
);
|
|
1481
|
-
tmpId = baseRefUtil.generateId();
|
|
1482
|
-
newCol.id = "detail-pane-" + tmpId;
|
|
1483
|
-
newCol.options.name = "detailPane" + tmpId;
|
|
1484
|
-
newCol.options.label = "附件信息";
|
|
1485
|
-
let vabUploadCon = this.copyNewFieldWidget(
|
|
1486
|
-
this.getFieldWidgetByType("vabUpload")
|
|
1487
|
-
); //vabUpload
|
|
1488
|
-
newCol.widgetList.push(vabUploadCon);
|
|
1489
|
-
newCon.panes.push(newCol);
|
|
1490
|
-
} else if (newCon.type === "table-column") {
|
|
1491
|
-
newCon.options.label = "tableColumn";
|
|
1492
|
-
} else if (newCon.type === "h5-card") {
|
|
1493
|
-
let newCol = baseRefUtil.deepClone(
|
|
1494
|
-
this.getContainerByType("h5-card-pane")
|
|
1495
|
-
);
|
|
1496
|
-
let tmpId = baseRefUtil.generateId();
|
|
1497
|
-
newCol.id = "h5-card-pane-" + tmpId;
|
|
1498
|
-
newCol.options.name = "h5CardPane" + tmpId;
|
|
1499
|
-
newCol.options.label = "基本信息";
|
|
1500
|
-
newCon.panes.push(newCol);
|
|
1501
|
-
} else if (newCon.type === "detail-h5") {
|
|
1502
|
-
/*let newTab = this.copyNewContainerWidget(this.getContainerByType('tab'));
|
|
1503
|
-
newCon.panes.push(newTab)
|
|
1504
|
-
|
|
1505
|
-
newTab.options.tabClass = "tab-box";
|
|
1506
|
-
let newTabPane = newTab.tabs[0];
|
|
1507
|
-
newTabPane.options.label = '基本信息';*/
|
|
1508
|
-
|
|
1509
|
-
//基本信息
|
|
1510
|
-
let newCard = this.copyNewContainerWidget(
|
|
1511
|
-
this.getContainerByType("h5-card")
|
|
1512
|
-
);
|
|
1513
|
-
// newTabPane.widgetList.push(newCard);
|
|
1514
|
-
newCon.panes.push(newCard);
|
|
1515
|
-
|
|
1516
|
-
//明细信息
|
|
1517
|
-
let newCardPane = this.copyNewContainerWidget(
|
|
1518
|
-
this.getContainerByType("h5-card-pane")
|
|
1519
|
-
);
|
|
1520
|
-
newCardPane.options.label = "明细信息";
|
|
1521
|
-
newCard.panes.push(newCardPane);
|
|
1522
|
-
|
|
1523
|
-
//列表
|
|
1524
|
-
let listH5 = this.copyNewContainerWidget(
|
|
1525
|
-
this.getContainerByType("list-h5")
|
|
1526
|
-
); //vabUpload
|
|
1527
|
-
newCardPane.widgetList.push(listH5);
|
|
1528
|
-
|
|
1529
|
-
//列表新增按钮
|
|
1530
|
-
let buttonCon = this.copyNewFieldWidget(
|
|
1531
|
-
this.getFieldWidgetByType("button")
|
|
1532
|
-
);
|
|
1533
|
-
buttonCon.options.label = "新增";
|
|
1534
|
-
buttonCon.options.icon = "el-icon-search";
|
|
1535
|
-
buttonCon.options.onClick =
|
|
1536
|
-
"this.getWidgetRef('" + listH5.options.name + "').addTableData();";
|
|
1537
|
-
newCardPane.buttonWidgetList.push(buttonCon);
|
|
1538
|
-
|
|
1539
|
-
//列表行查看按钮
|
|
1540
|
-
buttonCon = this.copyNewFieldWidget(
|
|
1541
|
-
this.getFieldWidgetByType("button")
|
|
1542
|
-
);
|
|
1543
|
-
buttonCon.options.rowFlag = true;
|
|
1544
|
-
buttonCon.options.label = "查看";
|
|
1545
|
-
buttonCon.options.icon = "el-icon-edit";
|
|
1546
|
-
buttonCon.options.onClick =
|
|
1547
|
-
"this.getWidgetRef('" +
|
|
1548
|
-
listH5.options.name +
|
|
1549
|
-
"').openRowDetailDialog(row);";
|
|
1550
|
-
listH5.lineButtons.push(buttonCon);
|
|
1551
|
-
|
|
1552
|
-
//附件信息
|
|
1553
|
-
newCardPane = this.copyNewContainerWidget(
|
|
1554
|
-
this.getContainerByType("h5-card-pane")
|
|
1555
|
-
);
|
|
1556
|
-
newCardPane.options.label = "附件信息";
|
|
1557
|
-
newCard.panes.push(newCardPane);
|
|
1558
|
-
|
|
1559
|
-
let vabUploadCon = this.copyNewFieldWidget(
|
|
1560
|
-
this.getFieldWidgetByType("vabUpload")
|
|
1561
|
-
); //vabUpload
|
|
1562
|
-
newCardPane.widgetList.push(vabUploadCon);
|
|
1563
|
-
} else if (newCon.type === "h5-table") {
|
|
1564
|
-
for (let i = 0; i < 4; i++) {
|
|
1565
|
-
let newRow = {
|
|
1566
|
-
cols: [],
|
|
1567
|
-
};
|
|
1568
|
-
newRow.id = "table-row-" + baseRefUtil.generateId();
|
|
1569
|
-
newRow.merged = false;
|
|
1570
|
-
|
|
1571
|
-
let newCell = baseRefUtil.deepClone(
|
|
1572
|
-
this.getContainerByType("h5-table-cell")
|
|
1573
|
-
);
|
|
1574
|
-
newCell.id = "table-cell-" + baseRefUtil.generateId();
|
|
1575
|
-
newCell.options.name = newCell.id;
|
|
1576
|
-
newCell.merged = false;
|
|
1577
|
-
newCell.options.colspan = 1;
|
|
1578
|
-
newCell.options.rowspan = 1;
|
|
1579
|
-
newRow.cols.push(newCell);
|
|
1580
|
-
|
|
1581
|
-
let newInput = this.copyNewFieldWidget(
|
|
1582
|
-
this.getFieldWidgetByType("input")
|
|
1583
|
-
);
|
|
1584
|
-
newCell.widgetList.push(newInput);
|
|
1585
|
-
|
|
1586
|
-
newCon.rows.push(newRow);
|
|
1587
|
-
}
|
|
1588
|
-
} else if (newCon.type === "tree-pane") {
|
|
1589
|
-
//初始化列表
|
|
1590
|
-
let dataTableCon = this.copyNewContainerWidget(
|
|
1591
|
-
this.getContainerByType("data-table")
|
|
1592
|
-
);
|
|
1593
|
-
dataTableCon.options.showPagination = true;
|
|
1594
|
-
dataTableCon.options.showSearchArea = true;
|
|
1595
|
-
dataTableCon.options.isQueryTable = true;
|
|
1596
|
-
dataTableCon.options.tableHeight = "auto";
|
|
1597
|
-
dataTableCon.options.accessReturnType = "2";
|
|
1598
|
-
|
|
1599
|
-
newCon.widgetList.push(dataTableCon);
|
|
1600
|
-
|
|
1601
|
-
let addButton = this.copyNewFieldWidget(
|
|
1602
|
-
this.getFieldWidgetByType("add_button")
|
|
1603
|
-
);
|
|
1604
|
-
addButton.options.onClick =
|
|
1605
|
-
"this.getWidgetRef('" +
|
|
1606
|
-
dataTableCon.options.name +
|
|
1607
|
-
"').openEditDialog();";
|
|
1608
|
-
dataTableCon.buttons.push(addButton);
|
|
1609
|
-
|
|
1610
|
-
let tableExportButton = this.copyNewFieldWidget(
|
|
1611
|
-
this.getFieldWidgetByType("table-export-button")
|
|
1612
|
-
);
|
|
1613
|
-
tableExportButton.options.tableExportParam =
|
|
1614
|
-
"return { title: '导出', targetRef: '" +
|
|
1615
|
-
dataTableCon.options.name +
|
|
1616
|
-
"'}";
|
|
1617
|
-
dataTableCon.buttons.push(tableExportButton);
|
|
1618
|
-
|
|
1619
|
-
let searchInput = this.copyNewFieldWidget(
|
|
1620
|
-
this.getFieldWidgetByType("input")
|
|
1621
|
-
);
|
|
1622
|
-
searchInput.options.disabled = true;
|
|
1623
|
-
searchInput.options.label = newCon.options.treeLabel;
|
|
1624
|
-
dataTableCon.widgetList.push(searchInput);
|
|
1625
|
-
|
|
1626
|
-
let searchIdInput = this.copyNewFieldWidget(
|
|
1627
|
-
this.getFieldWidgetByType("input")
|
|
1628
|
-
);
|
|
1629
|
-
searchIdInput.options.disabled = true;
|
|
1630
|
-
searchIdInput.options.hidden = true;
|
|
1631
|
-
searchIdInput.options.label = `隐藏${newCon.options.treeLabel}ID`;
|
|
1632
|
-
dataTableCon.widgetList.push(searchIdInput);
|
|
1633
|
-
|
|
1634
|
-
//列表重置的时候,忽略该字段
|
|
1635
|
-
dataTableCon.options.onResetTable = `this.resetEvent({\n ignoreFields:['${searchInput.options.name}', '${searchIdInput.options.name}']\n});`;
|
|
1636
|
-
|
|
1637
|
-
//初始化树
|
|
1638
|
-
let treeCon = this.copyNewContainerWidget(
|
|
1639
|
-
this.getContainerByType("tree")
|
|
1640
|
-
);
|
|
1641
|
-
treeCon.options.onNodeClick = `this.getWidgetRef('${searchInput.options.name}').setValue(data.label);\nthis.getWidgetRef('${searchIdInput.options.name}').setValue(data.id);\nthis.getWidgetRef('${dataTableCon.options.name}').searchEvent();`;
|
|
1642
|
-
|
|
1643
|
-
newCon.options.onTreeLabelClick = `this.getWidgetRef('${treeCon.options.name}').setCurrentKey();\nthis.getWidgetRef('${searchInput.options.name}').setValue(null);\nthis.getWidgetRef('${searchIdInput.options.name}').setValue(null);\nthis.getWidgetRef('${dataTableCon.options.name}').searchEvent();`;
|
|
1644
|
-
newCon.leftWidgetList.push(treeCon);
|
|
1645
|
-
}
|
|
1646
|
-
//newCon.options.customClass = []
|
|
1647
|
-
|
|
1648
|
-
delete newCon.displayName;
|
|
1649
|
-
return newCon;
|
|
1650
|
-
},
|
|
1651
|
-
|
|
1652
|
-
addContainerByDbClick(container) {
|
|
1653
|
-
let newCon = this.copyNewContainerWidget(container);
|
|
1654
|
-
this.widgetList.push(newCon);
|
|
1655
|
-
this.setSelected(newCon);
|
|
1656
|
-
},
|
|
1657
|
-
|
|
1658
|
-
addFieldByDbClick(widget) {
|
|
1659
|
-
let newWidget = this.copyNewFieldWidget(widget);
|
|
1660
|
-
if (!!this.selectedWidget && this.selectedWidget.type === "tab") {
|
|
1661
|
-
//获取当前激活的tabPane
|
|
1662
|
-
let activeTab = this.selectedWidget.tabs[0];
|
|
1663
|
-
this.selectedWidget.tabs.forEach((tabPane) => {
|
|
1664
|
-
if (!!tabPane.options.active) {
|
|
1665
|
-
activeTab = tabPane;
|
|
1666
|
-
}
|
|
1667
|
-
});
|
|
1668
|
-
|
|
1669
|
-
!!activeTab && activeTab.widgetList.push(newWidget);
|
|
1670
|
-
} else if (!!this.selectedWidget && !!this.selectedWidget.widgetList) {
|
|
1671
|
-
this.selectedWidget.widgetList.push(newWidget);
|
|
1672
|
-
} else {
|
|
1673
|
-
this.widgetList.push(newWidget);
|
|
1674
|
-
}
|
|
1675
|
-
|
|
1676
|
-
this.setSelected(newWidget);
|
|
1677
|
-
this.emitEvent("canvas-add-field", newWidget.options.name),
|
|
1678
|
-
this.emitHistoryChange();
|
|
1679
|
-
},
|
|
1680
|
-
deletePaneOfDetail(gridWidget, colIdx) {
|
|
1681
|
-
if (!!gridWidget && !!gridWidget.panes) {
|
|
1682
|
-
gridWidget.panes.splice(colIdx, 1);
|
|
1683
|
-
}
|
|
1684
|
-
},
|
|
1685
|
-
cloneDetailPane(widget, parentWidget) {
|
|
1686
|
-
let newGridCol = baseRefUtil.deepClone(
|
|
1687
|
-
this.getContainerByType("detail-pane")
|
|
1688
|
-
);
|
|
1689
|
-
let tmpId = baseRefUtil.generateId();
|
|
1690
|
-
newGridCol.id = "detail-pane-" + tmpId;
|
|
1691
|
-
newGridCol.options.name = "detailPane" + tmpId;
|
|
1692
|
-
newGridCol.options.label = widget.options.label;
|
|
1693
|
-
parentWidget.panes.push(newGridCol);
|
|
1694
|
-
},
|
|
1695
|
-
cloneH5CardPanePane(widget, parentWidget) {
|
|
1696
|
-
let newGridCol = baseRefUtil.deepClone(
|
|
1697
|
-
this.getContainerByType("h5-card-pane")
|
|
1698
|
-
);
|
|
1699
|
-
let tmpId = baseRefUtil.generateId();
|
|
1700
|
-
newGridCol.id = "h5-card-pane-" + tmpId;
|
|
1701
|
-
newGridCol.options.name = "h5CardPane" + tmpId;
|
|
1702
|
-
newGridCol.options.label = widget.options.label;
|
|
1703
|
-
parentWidget.panes.push(newGridCol);
|
|
1704
|
-
},
|
|
1705
|
-
|
|
1706
|
-
addNewPaneOfDetail(gridWidget) {
|
|
1707
|
-
const cols = gridWidget.panes;
|
|
1708
|
-
let newGridCol = baseRefUtil.deepClone(
|
|
1709
|
-
this.getContainerByType("detail-pane")
|
|
1710
|
-
);
|
|
1711
|
-
let tmpId = baseRefUtil.generateId();
|
|
1712
|
-
newGridCol.id = "detail-pane-" + tmpId;
|
|
1713
|
-
newGridCol.options.name = "detailPane" + tmpId;
|
|
1714
|
-
newGridCol.options.label = "detailPane" + tmpId;
|
|
1715
|
-
gridWidget.panes.push(newGridCol);
|
|
1716
|
-
},
|
|
1717
|
-
|
|
1718
|
-
deleteColOfGrid(gridWidget, colIdx) {
|
|
1719
|
-
if (!!gridWidget && !!gridWidget.cols) {
|
|
1720
|
-
gridWidget.cols.splice(colIdx, 1);
|
|
1721
|
-
}
|
|
1722
|
-
},
|
|
1723
|
-
|
|
1724
|
-
addNewColOfGrid(gridWidget) {
|
|
1725
|
-
const cols = gridWidget.cols;
|
|
1726
|
-
let newGridCol = baseRefUtil.deepClone(
|
|
1727
|
-
this.getContainerByType("grid-col")
|
|
1728
|
-
);
|
|
1729
|
-
let tmpId = baseRefUtil.generateId();
|
|
1730
|
-
newGridCol.id = "grid-col-" + tmpId;
|
|
1731
|
-
newGridCol.options.name = "gridCol" + tmpId;
|
|
1732
|
-
if (!!cols && cols.length > 0) {
|
|
1733
|
-
let spanSum = 0;
|
|
1734
|
-
cols.forEach((col) => {
|
|
1735
|
-
spanSum += col.options.span;
|
|
1736
|
-
});
|
|
1737
|
-
|
|
1738
|
-
if (spanSum >= 24) {
|
|
1739
|
-
//this.$message.info('列栅格之和超出24')
|
|
1740
|
-
console.log("列栅格之和超出24");
|
|
1741
|
-
gridWidget.cols.push(newGridCol);
|
|
1742
|
-
} else {
|
|
1743
|
-
newGridCol.options.span = 24 - spanSum > 12 ? 12 : 24 - spanSum;
|
|
1744
|
-
gridWidget.cols.push(newGridCol);
|
|
1745
|
-
}
|
|
1746
|
-
} else {
|
|
1747
|
-
gridWidget.cols = [newGridCol];
|
|
1748
|
-
}
|
|
1749
|
-
},
|
|
1750
|
-
|
|
1751
|
-
addTabPaneOfTabs(tabsWidget) {
|
|
1752
|
-
const tabPanes = tabsWidget.tabs;
|
|
1753
|
-
let newTabPane = baseRefUtil.deepClone(
|
|
1754
|
-
this.getContainerByType("tab-pane")
|
|
1755
|
-
);
|
|
1756
|
-
newTabPane.id = "tab-pane-" + baseRefUtil.generateId();
|
|
1757
|
-
newTabPane.options.name = newTabPane.id;
|
|
1758
|
-
newTabPane.options.label = "tab " + (tabPanes.length + 1);
|
|
1759
|
-
tabPanes.push(newTabPane);
|
|
1760
|
-
},
|
|
1761
|
-
|
|
1762
|
-
deleteTabPaneOfTabs(tabsWidget, tpIdx) {
|
|
1763
|
-
tabsWidget.tabs.splice(tpIdx, 1);
|
|
1764
|
-
},
|
|
1765
|
-
|
|
1766
|
-
addDropdownItem(tabsWidget) {
|
|
1767
|
-
const tabPanes = tabsWidget.widgetList;
|
|
1768
|
-
let newTabPane = baseRefUtil.deepClone(
|
|
1769
|
-
this.getFieldWidgetByType("dropdown-item")
|
|
1770
|
-
);
|
|
1771
|
-
newTabPane.id = "dropdown-item-" + baseRefUtil.generateId();
|
|
1772
|
-
newTabPane.options.name = newTabPane.id;
|
|
1773
|
-
newTabPane.options.label = "dropdown-item " + (tabPanes.length + 1);
|
|
1774
|
-
tabPanes.push(newTabPane);
|
|
1775
|
-
},
|
|
1776
|
-
|
|
1777
|
-
deleteDropdownItem(tabsWidget, tpIdx) {
|
|
1778
|
-
tabsWidget.widgetList.splice(tpIdx, 1);
|
|
1779
|
-
},
|
|
1780
|
-
|
|
1781
|
-
emitEvent(evtName, evtData) {
|
|
1782
|
-
//用于兄弟组件发射事件
|
|
1783
|
-
this.vueInstance.$emit(evtName, evtData);
|
|
1784
|
-
},
|
|
1785
|
-
|
|
1786
|
-
handleEvent(evtName, callback) {
|
|
1787
|
-
//用于兄弟组件接收事件
|
|
1788
|
-
this.vueInstance.$on(evtName, (data) => callback(data));
|
|
1789
|
-
},
|
|
1790
|
-
|
|
1791
|
-
setCssClassList(cssClassList) {
|
|
1792
|
-
this.cssClassList = cssClassList;
|
|
1793
|
-
},
|
|
1794
|
-
|
|
1795
|
-
getCssClassList() {
|
|
1796
|
-
return this.cssClassList;
|
|
1797
|
-
},
|
|
1798
|
-
|
|
1799
|
-
registerFormWidget(formWidget) {
|
|
1800
|
-
this.formWidget = formWidget;
|
|
1801
|
-
},
|
|
1802
|
-
|
|
1803
|
-
initHistoryData() {
|
|
1804
|
-
this.loadFormContentFromStorage();
|
|
1805
|
-
this.historyData.index++;
|
|
1806
|
-
this.historyData.steps[this.historyData.index] = {
|
|
1807
|
-
widgetList: baseRefUtil.deepClone(this.widgetList),
|
|
1808
|
-
formConfig: baseRefUtil.deepClone(this.formConfig),
|
|
1809
|
-
};
|
|
1810
|
-
},
|
|
1811
|
-
|
|
1812
|
-
emitHistoryChange() {
|
|
1813
|
-
//console.log('------------', 'Form history changed!')
|
|
1814
|
-
|
|
1815
|
-
if (this.historyData.index === this.historyData.maxStep - 1) {
|
|
1816
|
-
this.historyData.steps.shift();
|
|
1817
|
-
} else {
|
|
1818
|
-
this.historyData.index++;
|
|
1819
|
-
}
|
|
1820
|
-
|
|
1821
|
-
this.historyData.steps[this.historyData.index] = {
|
|
1822
|
-
widgetList: baseRefUtil.deepClone(this.widgetList),
|
|
1823
|
-
formConfig: baseRefUtil.deepClone(this.formConfig),
|
|
1824
|
-
};
|
|
1825
|
-
|
|
1826
|
-
this.saveFormContentToStorage();
|
|
1827
|
-
|
|
1828
|
-
if (this.historyData.index < this.historyData.steps.length - 1) {
|
|
1829
|
-
this.historyData.steps = this.historyData.steps.slice(
|
|
1830
|
-
0,
|
|
1831
|
-
this.historyData.index + 1
|
|
1832
|
-
);
|
|
1833
|
-
}
|
|
1834
|
-
|
|
1835
|
-
//console.log('history', this.historyData.index)
|
|
1836
|
-
},
|
|
1837
|
-
|
|
1838
|
-
saveCurrentHistoryStep() {
|
|
1839
|
-
this.historyData.steps[this.historyData.index] = baseRefUtil.deepClone({
|
|
1840
|
-
widgetList: this.widgetList,
|
|
1841
|
-
formConfig: this.formConfig,
|
|
1842
|
-
});
|
|
1843
|
-
|
|
1844
|
-
this.saveFormContentToStorage();
|
|
1845
|
-
},
|
|
1846
|
-
|
|
1847
|
-
undoHistoryStep() {
|
|
1848
|
-
if (this.historyData.index !== 0) {
|
|
1849
|
-
this.historyData.index--;
|
|
1850
|
-
}
|
|
1851
|
-
//console.log('undo', this.historyData.index)
|
|
1852
|
-
|
|
1853
|
-
this.widgetList = baseRefUtil.deepClone(
|
|
1854
|
-
this.historyData.steps[this.historyData.index].widgetList
|
|
1855
|
-
);
|
|
1856
|
-
this.formConfig = baseRefUtil.deepClone(
|
|
1857
|
-
this.historyData.steps[this.historyData.index].formConfig
|
|
1858
|
-
);
|
|
1859
|
-
},
|
|
1860
|
-
|
|
1861
|
-
redoHistoryStep() {
|
|
1862
|
-
if (this.historyData.index !== this.historyData.steps.length - 1) {
|
|
1863
|
-
this.historyData.index++;
|
|
1864
|
-
}
|
|
1865
|
-
//console.log('redo', this.historyData.index)
|
|
1866
|
-
|
|
1867
|
-
this.widgetList = baseRefUtil.deepClone(
|
|
1868
|
-
this.historyData.steps[this.historyData.index].widgetList
|
|
1869
|
-
);
|
|
1870
|
-
this.formConfig = baseRefUtil.deepClone(
|
|
1871
|
-
this.historyData.steps[this.historyData.index].formConfig
|
|
1872
|
-
);
|
|
1873
|
-
},
|
|
1874
|
-
|
|
1875
|
-
undoEnabled() {
|
|
1876
|
-
return this.historyData.index > 0 && this.historyData.steps.length > 0;
|
|
1877
|
-
},
|
|
1878
|
-
|
|
1879
|
-
redoEnabled() {
|
|
1880
|
-
return this.historyData.index < this.historyData.steps.length - 1;
|
|
1881
|
-
},
|
|
1882
|
-
|
|
1883
|
-
saveFormContentToStorage() {
|
|
1884
|
-
window.localStorage.setItem(
|
|
1885
|
-
"widget__list__backup",
|
|
1886
|
-
JSON.stringify(this.widgetList)
|
|
1887
|
-
);
|
|
1888
|
-
window.localStorage.setItem(
|
|
1889
|
-
"form__config__backup",
|
|
1890
|
-
JSON.stringify(this.formConfig)
|
|
1891
|
-
);
|
|
1892
|
-
},
|
|
1893
|
-
|
|
1894
|
-
loadFormContentFromStorage() {
|
|
1895
|
-
let widgetListBackup = window.localStorage.getItem(
|
|
1896
|
-
"widget__list__backup"
|
|
1897
|
-
);
|
|
1898
|
-
if (!!widgetListBackup) {
|
|
1899
|
-
this.widgetList = JSON.parse(widgetListBackup);
|
|
1900
|
-
}
|
|
1901
|
-
|
|
1902
|
-
let formConfigBackup = window.localStorage.getItem(
|
|
1903
|
-
"form__config__backup"
|
|
1904
|
-
);
|
|
1905
|
-
if (!!formConfigBackup) {
|
|
1906
|
-
//this.formConfig = JSON.parse(formConfigBackup)
|
|
1907
|
-
baseRefUtil.overwriteObj(
|
|
1908
|
-
this.formConfig,
|
|
1909
|
-
JSON.parse(formConfigBackup)
|
|
1910
|
-
); /* 用=赋值,会导致inject依赖注入的formConfig属性变成非响应式 */
|
|
1911
|
-
}
|
|
1912
|
-
},
|
|
1913
|
-
getColumnWidget(row, isEdit) {
|
|
1914
|
-
//获取
|
|
1915
|
-
let formatS = isEdit ? row.editFormatS : row.formatS;
|
|
1916
|
-
let type = columnFormatMap[formatS];
|
|
1917
|
-
if (!type) return null;
|
|
1918
|
-
if (isEdit) {
|
|
1919
|
-
if (row.editWidget) {
|
|
1920
|
-
return row.editWidget;
|
|
1921
|
-
}
|
|
1922
|
-
if (row.editColumnOption) {
|
|
1923
|
-
let fieldWidget = this.copyNewFieldWidget(
|
|
1924
|
-
this.getFieldWidgetByType(type)
|
|
1925
|
-
);
|
|
1926
|
-
fieldWidget.options = row.editColumnOption;
|
|
1927
|
-
return fieldWidget;
|
|
1928
|
-
}
|
|
1929
|
-
} else {
|
|
1930
|
-
if (row.widget) {
|
|
1931
|
-
return row.widget;
|
|
1932
|
-
}
|
|
1933
|
-
if (row.columnOption) {
|
|
1934
|
-
let fieldWidget = this.copyNewFieldWidget(
|
|
1935
|
-
this.getFieldWidgetByType(type)
|
|
1936
|
-
);
|
|
1937
|
-
fieldWidget.options = row.columnOption;
|
|
1938
|
-
return fieldWidget;
|
|
1939
|
-
}
|
|
1940
|
-
}
|
|
1941
|
-
return this.createColumnWidget(row, isEdit);
|
|
1942
|
-
},
|
|
1943
|
-
getIsFileWidget(type) {
|
|
1944
|
-
return type === "vabUpload" || type === "baseAttachment";
|
|
1945
|
-
},
|
|
1946
|
-
createColumnWidget(row, isEdit) {
|
|
1947
|
-
let formatS = isEdit ? row.editFormatS : row.formatS;
|
|
1948
|
-
let type = columnFormatMap[formatS];
|
|
1949
|
-
if (!type) return null;
|
|
1950
|
-
|
|
1951
|
-
let columnSelectedWidget = null;
|
|
1952
|
-
if (type) {
|
|
1953
|
-
columnSelectedWidget = this.copyNewFieldWidget(
|
|
1954
|
-
this.getFieldWidgetByType(type)
|
|
1955
|
-
);
|
|
1956
|
-
|
|
1957
|
-
if (columnSelectedWidget.options.hasOwnProperty("required")) {
|
|
1958
|
-
columnSelectedWidget.options.required = row.required || false;
|
|
1959
|
-
}
|
|
1960
|
-
|
|
1961
|
-
if ("editDelete" === formatS) {
|
|
1962
|
-
columnSelectedWidget.options.prefixIcon = "el-icon-delete";
|
|
1963
|
-
columnSelectedWidget.options.label = "删除";
|
|
1964
|
-
columnSelectedWidget.options.labelHidden = true;
|
|
1965
|
-
columnSelectedWidget.options.hiddenByWf = true;
|
|
1966
|
-
columnSelectedWidget.options.onClick =
|
|
1967
|
-
"let tableParam = this.tableParam;\nlet tableRef = this.getWidgetRef(this.parentWidget.options.name);\ntableRef.deleteRow(tableParam.row,tableParam.rowIndex);";
|
|
1968
|
-
} else if ("editButton" === formatS) {
|
|
1969
|
-
columnSelectedWidget.options.prefixIcon = "el-icon-edit";
|
|
1970
|
-
columnSelectedWidget.options.label = "查看";
|
|
1971
|
-
columnSelectedWidget.options.labelHidden = true;
|
|
1972
|
-
columnSelectedWidget.options.onClick =
|
|
1973
|
-
"let tableParam = this.tableParam;\nlet tableRef = this.getWidgetRef(this.parentWidget.options.name);\ntableRef.openEditDialog(tableParam.row)";
|
|
1974
|
-
} else if ("addSiblingEditRow" === formatS) {
|
|
1975
|
-
columnSelectedWidget.options.prefixIcon = "el-icon-plus";
|
|
1976
|
-
columnSelectedWidget.options.label = "新增兄弟节点";
|
|
1977
|
-
columnSelectedWidget.options.labelHidden = false;
|
|
1978
|
-
columnSelectedWidget.options.onClick =
|
|
1979
|
-
"let tableParam = this.tableParam;\nthis.getParentTarget().addSiblingTreeRow(null,tableParam);";
|
|
1980
|
-
} else if ("addChildTreeRow" === formatS) {
|
|
1981
|
-
columnSelectedWidget.options.prefixIcon = "el-icon-plus";
|
|
1982
|
-
columnSelectedWidget.options.label = "新增子节点";
|
|
1983
|
-
columnSelectedWidget.options.labelHidden = false;
|
|
1984
|
-
columnSelectedWidget.options.onClick =
|
|
1985
|
-
"let tableParam = this.tableParam;\nthis.getParentTarget().addChildTreeRow(null,tableParam);";
|
|
1986
|
-
} else if ("moveUpRow" === formatS) {
|
|
1987
|
-
columnSelectedWidget.options.label = "↑上移";
|
|
1988
|
-
columnSelectedWidget.options.labelHidden = false;
|
|
1989
|
-
columnSelectedWidget.options.onClick =
|
|
1990
|
-
"let tableParam = this.tableParam;\nthis.getParentTarget().moveUpRow(tableParam);";
|
|
1991
|
-
} else if ("moveDownRow" === formatS) {
|
|
1992
|
-
columnSelectedWidget.options.label = "↓下移";
|
|
1993
|
-
columnSelectedWidget.options.labelHidden = false;
|
|
1994
|
-
columnSelectedWidget.options.onClick =
|
|
1995
|
-
"let tableParam = this.tableParam;\nthis.getParentTarget().moveDownRow(tableParam);";
|
|
1996
|
-
} else if ("removeTreeRow" === formatS) {
|
|
1997
|
-
columnSelectedWidget.options.prefixIcon = "el-icon-delete";
|
|
1998
|
-
columnSelectedWidget.options.label = "删除";
|
|
1999
|
-
columnSelectedWidget.options.labelHidden = true;
|
|
2000
|
-
columnSelectedWidget.options.onClick =
|
|
2001
|
-
"let tableParam = this.tableParam;\nthis.getParentTarget().removeTreeRow(tableParam);";
|
|
2002
|
-
}
|
|
2003
|
-
|
|
2004
|
-
if (columnSelectedWidget.options.hasOwnProperty("keyName")) {
|
|
2005
|
-
if (!this.getIsFileWidget(type)) {
|
|
2006
|
-
columnSelectedWidget.options.keyName = row.prop;
|
|
2007
|
-
}
|
|
2008
|
-
|
|
2009
|
-
columnSelectedWidget.options.keyNameEnabled = true;
|
|
2010
|
-
} else {
|
|
2011
|
-
columnSelectedWidget.options.name = row.prop;
|
|
2012
|
-
}
|
|
2013
|
-
|
|
2014
|
-
if (type === "dropdown") {
|
|
2015
|
-
columnSelectedWidget.options.dropdownType = "link";
|
|
2016
|
-
} else if (type !== "button" && type !== "a-link") {
|
|
2017
|
-
columnSelectedWidget.options.label = row.label;
|
|
2018
|
-
columnSelectedWidget.options.labelHidden = true;
|
|
2019
|
-
}
|
|
2020
|
-
}
|
|
2021
|
-
return columnSelectedWidget;
|
|
2022
|
-
},
|
|
2023
|
-
};
|
|
2024
|
-
};
|
|
2025
|
-
})();
|
|
2026
|
-
|
|
2027
|
-
export const createDesigner = createDesigner0;
|
|
1
|
+
/**
|
|
2
|
+
* author: vformAdmin
|
|
3
|
+
* email: vdpadmin@163.com
|
|
4
|
+
* website: https://www.vform666.com
|
|
5
|
+
* date: 2021.08.18
|
|
6
|
+
* remark: 如果要分发VForm源码,需在本文件顶部保留此文件头信息!!
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
deepClone,
|
|
11
|
+
generateId,
|
|
12
|
+
getDefaultFormConfig,
|
|
13
|
+
overwriteObj,
|
|
14
|
+
createUUID,
|
|
15
|
+
columnFormatMap,
|
|
16
|
+
} from "../../../components/xform/utils/util";
|
|
17
|
+
import {
|
|
18
|
+
containers,
|
|
19
|
+
advancedFields,
|
|
20
|
+
basicFields,
|
|
21
|
+
customFields,
|
|
22
|
+
businessFields,
|
|
23
|
+
} from "../../../components/xform/form-designer/widget-panel/widgetsConfig.js";
|
|
24
|
+
import { VARIANT_FORM_VERSION } from "../../../components/xform/utils/config";
|
|
25
|
+
import { keyNamePrefixMap } from "../../../components/xform/form-designer/widget-panel/widgetsConfig";
|
|
26
|
+
|
|
27
|
+
let createDesigner0;
|
|
28
|
+
const baseRefUtil = {
|
|
29
|
+
deepClone,
|
|
30
|
+
generateId,
|
|
31
|
+
getDefaultFormConfig,
|
|
32
|
+
overwriteObj,
|
|
33
|
+
containers,
|
|
34
|
+
advancedFields,
|
|
35
|
+
basicFields,
|
|
36
|
+
customFields,
|
|
37
|
+
VARIANT_FORM_VERSION,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
let chartContainers = [],
|
|
41
|
+
chartWidgets = [];
|
|
42
|
+
|
|
43
|
+
(function () {
|
|
44
|
+
createDesigner0 = function (vueInstance) {
|
|
45
|
+
let defaultFormConfig = baseRefUtil.deepClone(
|
|
46
|
+
baseRefUtil.getDefaultFormConfig()
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
widgetList: [],
|
|
51
|
+
formConfig: {
|
|
52
|
+
cssCode: "",
|
|
53
|
+
gridConfig: {
|
|
54
|
+
accessReturnType: 1,
|
|
55
|
+
isLoadDataByAccess: false,
|
|
56
|
+
},
|
|
57
|
+
scriptList: [],
|
|
58
|
+
formType: 0,
|
|
59
|
+
getConfig: {
|
|
60
|
+
accessType: "1",
|
|
61
|
+
accessUrl: null,
|
|
62
|
+
accessParam: null,
|
|
63
|
+
accessCallback: null,
|
|
64
|
+
scriptName: null,
|
|
65
|
+
scriptCode: null,
|
|
66
|
+
},
|
|
67
|
+
saveConfig: {
|
|
68
|
+
accessType: "1",
|
|
69
|
+
accessUrl: null,
|
|
70
|
+
accessParam: null,
|
|
71
|
+
accessCallback: null,
|
|
72
|
+
scriptName: null,
|
|
73
|
+
scriptCode: null,
|
|
74
|
+
},
|
|
75
|
+
editFormCode: null,
|
|
76
|
+
editFormName: null,
|
|
77
|
+
searchDialogNameField: null,
|
|
78
|
+
searchDialogUniqueField: null,
|
|
79
|
+
entity: null,
|
|
80
|
+
wfEnabled: false,
|
|
81
|
+
isLoadEntity: false,
|
|
82
|
+
formScriptCode: "getOne",
|
|
83
|
+
formScriptParam: null,
|
|
84
|
+
formScriptSuccess: null,
|
|
85
|
+
saveScriptCode: "saveUpdate",
|
|
86
|
+
wfConfig: null,
|
|
87
|
+
wfStartBindSave: false,
|
|
88
|
+
wfStartConfirmText: null,
|
|
89
|
+
wfAgreenBindSave: false,
|
|
90
|
+
wfAgreeConfigData: [],
|
|
91
|
+
wfConfigDataEnabled: false,
|
|
92
|
+
wfConfigData: [],
|
|
93
|
+
multiTabEnabled: false,
|
|
94
|
+
multiTabLabelField: null,
|
|
95
|
+
addTabEnabled: false, // 新增打开独立页签(不走「常规」页签)
|
|
96
|
+
submitBehavior: "refreshCurrent", // 提交后行为: refreshCurrent(默认,留在详情页) | closeToList
|
|
97
|
+
billNavEnabled: false, // 详情页签显示「上一单/下一单」翻单按钮
|
|
98
|
+
addFormCode: null,
|
|
99
|
+
addFormName: null,
|
|
100
|
+
wfTheme: null,
|
|
101
|
+
otherTabEnabled: false,
|
|
102
|
+
otherTabList: [],
|
|
103
|
+
hideNormalTab: false,
|
|
104
|
+
customListTabLabel: null,
|
|
105
|
+
globalConfig: null,
|
|
106
|
+
// 表单级动态字段规则
|
|
107
|
+
dynamicFieldEnabled: false,
|
|
108
|
+
dynamicFieldSourceType: "local",
|
|
109
|
+
dynamicFieldRules: [],
|
|
110
|
+
dynamicFieldScriptCode: null,
|
|
111
|
+
dynamicFieldScriptParam: null,
|
|
112
|
+
dynamicFieldTriggerFields: [],
|
|
113
|
+
},
|
|
114
|
+
dataSources: [], //数据源
|
|
115
|
+
|
|
116
|
+
selectedId: null,
|
|
117
|
+
selectedWidget: null,
|
|
118
|
+
selectedWidgetName: null, //选中组件名称(唯一)
|
|
119
|
+
vueInstance: vueInstance,
|
|
120
|
+
|
|
121
|
+
formWidget: null, //表单设计容器
|
|
122
|
+
|
|
123
|
+
cssClassList: [], //自定义样式列表
|
|
124
|
+
|
|
125
|
+
historyData: {
|
|
126
|
+
index: -1, //index: 0,
|
|
127
|
+
maxStep: 20,
|
|
128
|
+
steps: [],
|
|
129
|
+
},
|
|
130
|
+
|
|
131
|
+
initDesigner(resetFormJson) {
|
|
132
|
+
this.widgetList = [];
|
|
133
|
+
this.formConfig = baseRefUtil.deepClone(defaultFormConfig);
|
|
134
|
+
this.dataSources = [];
|
|
135
|
+
|
|
136
|
+
//输出版本信息和语雀链接
|
|
137
|
+
/* console.info(`%cVariantForm %cVer${baseRefUtil.VARIANT_FORM_VERSION} %chttps://www.yuque.com/visualdev/vform`,
|
|
138
|
+
"color:#409EFF;font-size: 22px;font-weight:bolder",
|
|
139
|
+
"color:#999;font-size: 12px",
|
|
140
|
+
"color:#333"
|
|
141
|
+
); */
|
|
142
|
+
|
|
143
|
+
/*if (!resetFormJson) {
|
|
144
|
+
this.initHistoryData();
|
|
145
|
+
}*/
|
|
146
|
+
},
|
|
147
|
+
|
|
148
|
+
clearDesigner(skipHistoryChange) {
|
|
149
|
+
let emptyWidgetListFlag = this.widgetList.length === 0;
|
|
150
|
+
this.widgetList = [];
|
|
151
|
+
this.selectedId = null;
|
|
152
|
+
this.selectedWidgetName = null;
|
|
153
|
+
this.selectedWidget = {}; //this.selectedWidget = null
|
|
154
|
+
baseRefUtil.overwriteObj(this.formConfig, defaultFormConfig); //
|
|
155
|
+
this.formConfig.gridConfig = defaultFormConfig.gridConfig;
|
|
156
|
+
|
|
157
|
+
if (!!skipHistoryChange) {
|
|
158
|
+
//什么也不做!!
|
|
159
|
+
} else if (!emptyWidgetListFlag) {
|
|
160
|
+
this.emitHistoryChange();
|
|
161
|
+
} else {
|
|
162
|
+
this.saveCurrentHistoryStep();
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
|
|
166
|
+
loadPresetCssCode(preCssCode) {
|
|
167
|
+
if (this.formConfig.cssCode === "" && !!preCssCode) {
|
|
168
|
+
this.formConfig.cssCode = preCssCode;
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
|
|
172
|
+
getLayoutType() {
|
|
173
|
+
return this.formConfig.layoutType || "PC";
|
|
174
|
+
},
|
|
175
|
+
|
|
176
|
+
changeLayoutType(newType) {
|
|
177
|
+
this.formConfig.layoutType = newType;
|
|
178
|
+
},
|
|
179
|
+
|
|
180
|
+
getImportTemplate() {
|
|
181
|
+
return {
|
|
182
|
+
widgetList: [],
|
|
183
|
+
// formConfig: baseRefUtil.deepClone(this.formConfig)
|
|
184
|
+
formConfig: baseRefUtil.deepClone(defaultFormConfig),
|
|
185
|
+
};
|
|
186
|
+
},
|
|
187
|
+
|
|
188
|
+
handleImportJson(formJson) {
|
|
189
|
+
let formConfig = formJson.formConfig;
|
|
190
|
+
if (formConfig.formCode === vueInstance?.reportTemplate?.formCode) {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
let widgetArr = formJson.widgetList;
|
|
194
|
+
let itemFieldMap = {
|
|
195
|
+
grid: "cols",
|
|
196
|
+
table: "rows",
|
|
197
|
+
"table-cell": "widgetList",
|
|
198
|
+
"h5-table": "rows",
|
|
199
|
+
"h5-table-cell": "widgetList",
|
|
200
|
+
tab: "tabs",
|
|
201
|
+
"tab-pane": "widgetList",
|
|
202
|
+
"grid-col": "widgetList",
|
|
203
|
+
"vf-box": "widgetList",
|
|
204
|
+
card: "widgetList",
|
|
205
|
+
detail: "panes",
|
|
206
|
+
"detail-pane": "widgetList",
|
|
207
|
+
"detail-h5": "panes",
|
|
208
|
+
"h5-card": "panes",
|
|
209
|
+
"h5-card-pane": "widgetList",
|
|
210
|
+
};
|
|
211
|
+
let loopDo = (widgetList) => {
|
|
212
|
+
if (!widgetList) return;
|
|
213
|
+
widgetList.forEach((widget) => {
|
|
214
|
+
if (widget.type === "data-table" || widget.type === "list-h5") {
|
|
215
|
+
let vailColumns = widget.options.tableColumns.filter(
|
|
216
|
+
(item) => item.prop && item.label
|
|
217
|
+
);
|
|
218
|
+
vailColumns.forEach((item) => {
|
|
219
|
+
if (item.formatS === "editAttachment") {
|
|
220
|
+
let prop = item.prop;
|
|
221
|
+
let columnOption = item.columnOption;
|
|
222
|
+
let editColumnOption = item.editColumnOption;
|
|
223
|
+
|
|
224
|
+
let suffix = this.createAttachmentSuffix();
|
|
225
|
+
let keyName = this.createAttachmentKeyName(suffix);
|
|
226
|
+
if (columnOption) {
|
|
227
|
+
columnOption.keyName = keyName;
|
|
228
|
+
columnOption.keyNameSuffix = suffix;
|
|
229
|
+
}
|
|
230
|
+
if (editColumnOption) {
|
|
231
|
+
editColumnOption.keyName = keyName;
|
|
232
|
+
editColumnOption.keyNameSuffix = suffix;
|
|
233
|
+
}
|
|
234
|
+
item.prop = keyName;
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
} else if (
|
|
238
|
+
widget.type === "vabUpload" ||
|
|
239
|
+
widget.type === "baseAttachment"
|
|
240
|
+
) {
|
|
241
|
+
let suffix = this.createAttachmentSuffix();
|
|
242
|
+
let keyName = this.createAttachmentKeyName(suffix);
|
|
243
|
+
widget.options.keyName = keyName;
|
|
244
|
+
widget.options.keyNameSuffix = suffix;
|
|
245
|
+
} else {
|
|
246
|
+
if (widget.category === "container") {
|
|
247
|
+
let itemField = itemFieldMap[widget.type];
|
|
248
|
+
if (itemField) {
|
|
249
|
+
if ("table" === widget.type) {
|
|
250
|
+
widget[itemField].forEach((item) => {
|
|
251
|
+
loopDo(item.cols);
|
|
252
|
+
});
|
|
253
|
+
} else if ("h5-table" === widget.type) {
|
|
254
|
+
widget[itemField].forEach((item) => {
|
|
255
|
+
loopDo(item.cols);
|
|
256
|
+
});
|
|
257
|
+
} else {
|
|
258
|
+
loopDo(widget[itemField]);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
};
|
|
265
|
+
loopDo(widgetArr);
|
|
266
|
+
},
|
|
267
|
+
loadFormJson(formJson) {
|
|
268
|
+
let modifiedFlag = false;
|
|
269
|
+
|
|
270
|
+
if (!!formJson && !!formJson.widgetList) {
|
|
271
|
+
this.widgetList = formJson.widgetList;
|
|
272
|
+
modifiedFlag = true;
|
|
273
|
+
}
|
|
274
|
+
if (!!formJson && !!formJson.formConfig) {
|
|
275
|
+
//this.formConfig = importObj.formConfig
|
|
276
|
+
baseRefUtil.overwriteObj(
|
|
277
|
+
this.formConfig,
|
|
278
|
+
formJson.formConfig
|
|
279
|
+
); /* 用=赋值,会导致inject依赖注入的formConfig属性变成非响应式 */
|
|
280
|
+
modifiedFlag = true;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
if (modifiedFlag) {
|
|
284
|
+
this.emitEvent("form-json-imported", []); // 通知其他组件
|
|
285
|
+
}
|
|
286
|
+
this.setSelected();
|
|
287
|
+
return modifiedFlag;
|
|
288
|
+
},
|
|
289
|
+
handleSelectedWidget(selected) {
|
|
290
|
+
//处理历史未定义的属性
|
|
291
|
+
if (selected.formItemFlag || selected.type === "data-table") {
|
|
292
|
+
if (selected.options.submitFlag === void 0) {
|
|
293
|
+
// selected.options.submitFlag = true;
|
|
294
|
+
this.vueInstance.$set(selected.options, "submitFlag", true);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
this.handleKeyNameSuffix(selected);
|
|
298
|
+
},
|
|
299
|
+
handleKeyNameSuffix(selected) {
|
|
300
|
+
if (!selected) return;
|
|
301
|
+
let optionModel = selected.options;
|
|
302
|
+
let prefix = this.getKeyNamePrefix(selected.type);
|
|
303
|
+
if (
|
|
304
|
+
optionModel.keyNameEnabled &&
|
|
305
|
+
!!prefix &&
|
|
306
|
+
!optionModel.keyNameSuffix
|
|
307
|
+
) {
|
|
308
|
+
let keyName = optionModel.keyName;
|
|
309
|
+
if (keyName.startsWith(prefix)) {
|
|
310
|
+
this.vueInstance.$set(
|
|
311
|
+
optionModel,
|
|
312
|
+
"keyNameSuffix",
|
|
313
|
+
keyName.substring(prefix.length)
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
},
|
|
318
|
+
setSelected(selected) {
|
|
319
|
+
if (!selected) {
|
|
320
|
+
this.clearSelected();
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
//处理历史未定义的属性
|
|
325
|
+
this.handleSelectedWidget(selected);
|
|
326
|
+
|
|
327
|
+
this.selectedWidget = selected;
|
|
328
|
+
if (!!selected.id) {
|
|
329
|
+
this.selectedId = selected.id;
|
|
330
|
+
this.selectedWidgetName = selected.options.name;
|
|
331
|
+
if (!selected.category) {
|
|
332
|
+
this.emitEvent("canvas-select-field", selected.options.name);
|
|
333
|
+
} else {
|
|
334
|
+
this.emitEvent("canvas-select-container", selected.options.name);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
},
|
|
338
|
+
|
|
339
|
+
updateSelectedWidgetNameAndLabel(selectedWidget, newName, newLabel) {
|
|
340
|
+
this.selectedWidgetName = newName;
|
|
341
|
+
//selectedWidget.options.name = newName //此行多余
|
|
342
|
+
if (
|
|
343
|
+
!!newLabel &&
|
|
344
|
+
Object.keys(selectedWidget.options).indexOf("label") > -1
|
|
345
|
+
) {
|
|
346
|
+
selectedWidget.options.label = newLabel;
|
|
347
|
+
}
|
|
348
|
+
},
|
|
349
|
+
|
|
350
|
+
clearSelected() {
|
|
351
|
+
this.selectedId = null;
|
|
352
|
+
this.selectedWidgetName = null;
|
|
353
|
+
this.selectedWidget = {}; //this.selectedWidget = null
|
|
354
|
+
},
|
|
355
|
+
|
|
356
|
+
checkWidgetMove(evt) {
|
|
357
|
+
/* Only field widget can be dragged into sub-form */
|
|
358
|
+
if (!!evt.draggedContext && !!evt.draggedContext.element) {
|
|
359
|
+
let wgCategory = evt.draggedContext.element.category;
|
|
360
|
+
let wgType = evt.draggedContext.element.type;
|
|
361
|
+
if (!!evt.to) {
|
|
362
|
+
if (
|
|
363
|
+
evt.to.className === "sub-form-table" &&
|
|
364
|
+
wgCategory === "container"
|
|
365
|
+
) {
|
|
366
|
+
//this.$message.info(this.vueInstance.i18nt('designer.hint.onlyFieldWidgetAcceptable'))
|
|
367
|
+
return false;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
return true;
|
|
373
|
+
},
|
|
374
|
+
|
|
375
|
+
checkFieldMove(evt) {
|
|
376
|
+
if (!!evt.draggedContext && !!evt.draggedContext.element) {
|
|
377
|
+
let wgCategory = evt.draggedContext.element.category;
|
|
378
|
+
let wgType = evt.draggedContext.element.type + "";
|
|
379
|
+
//console.log('wgType======', wgType)
|
|
380
|
+
if (!!evt.to) {
|
|
381
|
+
if (evt.to.className === "sub-form-table" && wgType === "slot") {
|
|
382
|
+
//this.$message.info(this.vueInstance.i18nt('designer.hint.onlyFieldWidgetAcceptable'))
|
|
383
|
+
return false;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
return true;
|
|
389
|
+
},
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* 追加表格新行
|
|
393
|
+
* @param widget
|
|
394
|
+
*/
|
|
395
|
+
appendTableRow(widget) {
|
|
396
|
+
let rowIdx = widget.rows.length; //确定插入行位置
|
|
397
|
+
let newRow = baseRefUtil.deepClone(widget.rows[widget.rows.length - 1]);
|
|
398
|
+
newRow.id = "table-row-" + baseRefUtil.generateId();
|
|
399
|
+
newRow.merged = false;
|
|
400
|
+
newRow.cols.forEach((col) => {
|
|
401
|
+
col.id = "table-cell-" + baseRefUtil.generateId();
|
|
402
|
+
col.options.name = col.id;
|
|
403
|
+
col.merged = false;
|
|
404
|
+
col.options.colspan = 1;
|
|
405
|
+
col.options.rowspan = 1;
|
|
406
|
+
col.widgetList.length = 0;
|
|
407
|
+
});
|
|
408
|
+
widget.rows.splice(rowIdx, 0, newRow);
|
|
409
|
+
|
|
410
|
+
this.emitHistoryChange();
|
|
411
|
+
},
|
|
412
|
+
|
|
413
|
+
/**
|
|
414
|
+
* 追加表格新列
|
|
415
|
+
* @param widget
|
|
416
|
+
*/
|
|
417
|
+
appendTableCol(widget) {
|
|
418
|
+
let colIdx = widget.rows[0].cols.length; //确定插入列位置
|
|
419
|
+
widget.rows.forEach((row) => {
|
|
420
|
+
let newCol = baseRefUtil.deepClone(
|
|
421
|
+
this.getContainerByType("table-cell")
|
|
422
|
+
);
|
|
423
|
+
newCol.id = "table-cell-" + baseRefUtil.generateId();
|
|
424
|
+
newCol.options.name = newCol.id;
|
|
425
|
+
newCol.merged = false;
|
|
426
|
+
newCol.options.colspan = 1;
|
|
427
|
+
newCol.options.rowspan = 1;
|
|
428
|
+
newCol.widgetList.length = 0;
|
|
429
|
+
row.cols.splice(colIdx, 0, newCol);
|
|
430
|
+
});
|
|
431
|
+
|
|
432
|
+
this.emitHistoryChange();
|
|
433
|
+
},
|
|
434
|
+
|
|
435
|
+
insertTableRow(widget, insertPos, cloneRowIdx, curCol, aboveFlag) {
|
|
436
|
+
let newRowIdx = !!aboveFlag ? insertPos : insertPos + 1; //初步确定插入行位置
|
|
437
|
+
if (!aboveFlag) {
|
|
438
|
+
//继续向下寻找同列第一个未被合并的单元格
|
|
439
|
+
let tmpRowIdx = newRowIdx;
|
|
440
|
+
let rowFoundFlag = false;
|
|
441
|
+
while (tmpRowIdx < widget.rows.length) {
|
|
442
|
+
if (!widget.rows[tmpRowIdx].cols[curCol].merged) {
|
|
443
|
+
newRowIdx = tmpRowIdx;
|
|
444
|
+
rowFoundFlag = true;
|
|
445
|
+
break;
|
|
446
|
+
} else {
|
|
447
|
+
tmpRowIdx++;
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
if (!rowFoundFlag) {
|
|
452
|
+
newRowIdx = widget.rows.length;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
let newRow = baseRefUtil.deepClone(widget.rows[cloneRowIdx]);
|
|
457
|
+
newRow.id = "table-row-" + baseRefUtil.generateId();
|
|
458
|
+
newRow.merged = false;
|
|
459
|
+
newRow.cols.forEach((col) => {
|
|
460
|
+
col.id = "table-cell-" + baseRefUtil.generateId();
|
|
461
|
+
col.options.name = col.id;
|
|
462
|
+
col.merged = false;
|
|
463
|
+
col.options.colspan = 1;
|
|
464
|
+
col.options.rowspan = 1;
|
|
465
|
+
col.widgetList.length = 0;
|
|
466
|
+
});
|
|
467
|
+
widget.rows.splice(newRowIdx, 0, newRow);
|
|
468
|
+
|
|
469
|
+
let colNo = 0;
|
|
470
|
+
while (
|
|
471
|
+
newRowIdx < widget.rows.length - 1 &&
|
|
472
|
+
colNo < widget.rows[0].cols.length
|
|
473
|
+
) {
|
|
474
|
+
//越界判断
|
|
475
|
+
const cellOfNextRow = widget.rows[newRowIdx + 1].cols[colNo];
|
|
476
|
+
const rowMerged = cellOfNextRow.merged; //确定插入位置下一行的单元格是否为合并单元格
|
|
477
|
+
if (!!rowMerged) {
|
|
478
|
+
let rowArray = widget.rows;
|
|
479
|
+
let unMergedCell = {};
|
|
480
|
+
let startRowIndex = null;
|
|
481
|
+
for (let i = newRowIdx; i >= 0; i--) {
|
|
482
|
+
//查找该行已合并的主单元格
|
|
483
|
+
if (
|
|
484
|
+
!rowArray[i].cols[colNo].merged &&
|
|
485
|
+
rowArray[i].cols[colNo].options.rowspan > 1
|
|
486
|
+
) {
|
|
487
|
+
startRowIndex = i;
|
|
488
|
+
unMergedCell = rowArray[i].cols[colNo];
|
|
489
|
+
break;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
if (!!unMergedCell.options) {
|
|
494
|
+
//如果有符合条件的unMergedCell
|
|
495
|
+
let newRowspan = unMergedCell.options.rowspan + 1;
|
|
496
|
+
this.setPropsOfMergedRows(
|
|
497
|
+
widget.rows,
|
|
498
|
+
startRowIndex,
|
|
499
|
+
colNo,
|
|
500
|
+
unMergedCell.options.colspan,
|
|
501
|
+
newRowspan
|
|
502
|
+
);
|
|
503
|
+
colNo += unMergedCell.options.colspan;
|
|
504
|
+
} else {
|
|
505
|
+
colNo += 1;
|
|
506
|
+
}
|
|
507
|
+
} else {
|
|
508
|
+
//colNo += 1
|
|
509
|
+
colNo += cellOfNextRow.options.colspan || 1;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
this.emitHistoryChange();
|
|
514
|
+
},
|
|
515
|
+
|
|
516
|
+
insertTableCol(widget, insertPos, curRow, leftFlag) {
|
|
517
|
+
let newColIdx = !!leftFlag ? insertPos : insertPos + 1; //初步确定插入列位置
|
|
518
|
+
if (!leftFlag) {
|
|
519
|
+
//继续向右寻找同行第一个未被合并的单元格
|
|
520
|
+
let tmpColIdx = newColIdx;
|
|
521
|
+
let colFoundFlag = false;
|
|
522
|
+
while (tmpColIdx < widget.rows[curRow].cols.length) {
|
|
523
|
+
if (!widget.rows[curRow].cols[tmpColIdx].merged) {
|
|
524
|
+
newColIdx = tmpColIdx;
|
|
525
|
+
colFoundFlag = true;
|
|
526
|
+
break;
|
|
527
|
+
} else {
|
|
528
|
+
tmpColIdx++;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
if (!colFoundFlag) {
|
|
532
|
+
newColIdx = widget.rows[curRow].cols.length;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
widget.rows.forEach((row) => {
|
|
538
|
+
let newCol = baseRefUtil.deepClone(
|
|
539
|
+
this.getContainerByType("table-cell")
|
|
540
|
+
);
|
|
541
|
+
newCol.id = "table-cell-" + baseRefUtil.generateId();
|
|
542
|
+
newCol.options.name = newCol.id;
|
|
543
|
+
newCol.merged = false;
|
|
544
|
+
newCol.options.colspan = 1;
|
|
545
|
+
newCol.options.rowspan = 1;
|
|
546
|
+
newCol.widgetList.length = 0;
|
|
547
|
+
row.cols.splice(newColIdx, 0, newCol);
|
|
548
|
+
});
|
|
549
|
+
|
|
550
|
+
let rowNo = 0;
|
|
551
|
+
while (
|
|
552
|
+
newColIdx < widget.rows[0].cols.length - 1 &&
|
|
553
|
+
rowNo < widget.rows.length
|
|
554
|
+
) {
|
|
555
|
+
//越界判断
|
|
556
|
+
const cellOfNextCol = widget.rows[rowNo].cols[newColIdx + 1];
|
|
557
|
+
const colMerged = cellOfNextCol.merged; //确定插入位置右侧列的单元格是否为合并单元格
|
|
558
|
+
if (!!colMerged) {
|
|
559
|
+
let colArray = widget.rows[rowNo].cols;
|
|
560
|
+
let unMergedCell = {};
|
|
561
|
+
let startColIndex = null;
|
|
562
|
+
for (let i = newColIdx; i >= 0; i--) {
|
|
563
|
+
//查找该行已合并的主单元格
|
|
564
|
+
if (!colArray[i].merged && colArray[i].options.colspan > 1) {
|
|
565
|
+
startColIndex = i;
|
|
566
|
+
unMergedCell = colArray[i];
|
|
567
|
+
break;
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
if (!!unMergedCell.options) {
|
|
572
|
+
//如果有符合条件的unMergedCell
|
|
573
|
+
let newColspan = unMergedCell.options.colspan + 1;
|
|
574
|
+
this.setPropsOfMergedCols(
|
|
575
|
+
widget.rows,
|
|
576
|
+
rowNo,
|
|
577
|
+
startColIndex,
|
|
578
|
+
newColspan,
|
|
579
|
+
unMergedCell.options.rowspan
|
|
580
|
+
);
|
|
581
|
+
rowNo += unMergedCell.options.rowspan;
|
|
582
|
+
} else {
|
|
583
|
+
rowNo += 1;
|
|
584
|
+
}
|
|
585
|
+
} else {
|
|
586
|
+
//rowNo += 1
|
|
587
|
+
rowNo += cellOfNextCol.options.rowspan || 1;
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
this.emitHistoryChange();
|
|
592
|
+
},
|
|
593
|
+
insertH5TableCol(widget, insertPos, curRow, leftFlag) {
|
|
594
|
+
let newColIdx = !!leftFlag ? insertPos : insertPos + 1; //初步确定插入列位置
|
|
595
|
+
if (!leftFlag) {
|
|
596
|
+
//继续向右寻找同行第一个未被合并的单元格
|
|
597
|
+
let tmpColIdx = newColIdx;
|
|
598
|
+
let colFoundFlag = false;
|
|
599
|
+
while (tmpColIdx < widget.rows[curRow].cols.length) {
|
|
600
|
+
if (!widget.rows[curRow].cols[tmpColIdx].merged) {
|
|
601
|
+
newColIdx = tmpColIdx;
|
|
602
|
+
colFoundFlag = true;
|
|
603
|
+
break;
|
|
604
|
+
} else {
|
|
605
|
+
tmpColIdx++;
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
if (!colFoundFlag) {
|
|
609
|
+
newColIdx = widget.rows[curRow].cols.length;
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
widget.rows.forEach((row) => {
|
|
615
|
+
let newCol = baseRefUtil.deepClone(
|
|
616
|
+
this.getContainerByType("h5-table-cell")
|
|
617
|
+
);
|
|
618
|
+
newCol.id = "table-cell-" + baseRefUtil.generateId();
|
|
619
|
+
newCol.options.name = newCol.id;
|
|
620
|
+
newCol.merged = false;
|
|
621
|
+
newCol.options.colspan = 1;
|
|
622
|
+
newCol.options.rowspan = 1;
|
|
623
|
+
newCol.widgetList.length = 0;
|
|
624
|
+
row.cols.splice(newColIdx, 0, newCol);
|
|
625
|
+
});
|
|
626
|
+
|
|
627
|
+
let rowNo = 0;
|
|
628
|
+
while (
|
|
629
|
+
newColIdx < widget.rows[0].cols.length - 1 &&
|
|
630
|
+
rowNo < widget.rows.length
|
|
631
|
+
) {
|
|
632
|
+
//越界判断
|
|
633
|
+
const cellOfNextCol = widget.rows[rowNo].cols[newColIdx + 1];
|
|
634
|
+
const colMerged = cellOfNextCol.merged; //确定插入位置右侧列的单元格是否为合并单元格
|
|
635
|
+
if (!!colMerged) {
|
|
636
|
+
let colArray = widget.rows[rowNo].cols;
|
|
637
|
+
let unMergedCell = {};
|
|
638
|
+
let startColIndex = null;
|
|
639
|
+
for (let i = newColIdx; i >= 0; i--) {
|
|
640
|
+
//查找该行已合并的主单元格
|
|
641
|
+
if (!colArray[i].merged && colArray[i].options.colspan > 1) {
|
|
642
|
+
startColIndex = i;
|
|
643
|
+
unMergedCell = colArray[i];
|
|
644
|
+
break;
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
if (!!unMergedCell.options) {
|
|
649
|
+
//如果有符合条件的unMergedCell
|
|
650
|
+
let newColspan = unMergedCell.options.colspan + 1;
|
|
651
|
+
this.setPropsOfMergedCols(
|
|
652
|
+
widget.rows,
|
|
653
|
+
rowNo,
|
|
654
|
+
startColIndex,
|
|
655
|
+
newColspan,
|
|
656
|
+
unMergedCell.options.rowspan
|
|
657
|
+
);
|
|
658
|
+
rowNo += unMergedCell.options.rowspan;
|
|
659
|
+
} else {
|
|
660
|
+
rowNo += 1;
|
|
661
|
+
}
|
|
662
|
+
} else {
|
|
663
|
+
//rowNo += 1
|
|
664
|
+
rowNo += cellOfNextCol.options.rowspan || 1;
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
this.emitHistoryChange();
|
|
669
|
+
},
|
|
670
|
+
setPropsOfMergedCols(
|
|
671
|
+
rowArray,
|
|
672
|
+
startRowIndex,
|
|
673
|
+
startColIndex,
|
|
674
|
+
newColspan,
|
|
675
|
+
rowspan
|
|
676
|
+
) {
|
|
677
|
+
for (let i = startRowIndex; i < startRowIndex + rowspan; i++) {
|
|
678
|
+
for (let j = startColIndex; j < startColIndex + newColspan; j++) {
|
|
679
|
+
if (i === startRowIndex && j === startColIndex) {
|
|
680
|
+
rowArray[i].cols[j].options.colspan = newColspan; //合并后的主单元格
|
|
681
|
+
continue;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
rowArray[i].cols[j].merged = true;
|
|
685
|
+
rowArray[i].cols[j].options.colspan = newColspan;
|
|
686
|
+
rowArray[i].cols[j].widgetList = [];
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
},
|
|
690
|
+
|
|
691
|
+
setPropsOfMergedRows(
|
|
692
|
+
rowArray,
|
|
693
|
+
startRowIndex,
|
|
694
|
+
startColIndex,
|
|
695
|
+
colspan,
|
|
696
|
+
newRowspan
|
|
697
|
+
) {
|
|
698
|
+
for (let i = startRowIndex; i < startRowIndex + newRowspan; i++) {
|
|
699
|
+
for (let j = startColIndex; j < startColIndex + colspan; j++) {
|
|
700
|
+
if (i === startRowIndex && j === startColIndex) {
|
|
701
|
+
rowArray[i].cols[j].options.rowspan = newRowspan;
|
|
702
|
+
continue;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
rowArray[i].cols[j].merged = true;
|
|
706
|
+
rowArray[i].cols[j].options.rowspan = newRowspan;
|
|
707
|
+
rowArray[i].cols[j].widgetList = [];
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
},
|
|
711
|
+
|
|
712
|
+
setPropsOfSplitCol(
|
|
713
|
+
rowArray,
|
|
714
|
+
startRowIndex,
|
|
715
|
+
startColIndex,
|
|
716
|
+
colspan,
|
|
717
|
+
rowspan
|
|
718
|
+
) {
|
|
719
|
+
for (let i = startRowIndex; i < startRowIndex + rowspan; i++) {
|
|
720
|
+
for (let j = startColIndex; j < startColIndex + colspan; j++) {
|
|
721
|
+
rowArray[i].cols[j].merged = false;
|
|
722
|
+
rowArray[i].cols[j].options.rowspan = 1;
|
|
723
|
+
rowArray[i].cols[j].options.colspan = 1;
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
},
|
|
727
|
+
|
|
728
|
+
setPropsOfSplitRow(
|
|
729
|
+
rowArray,
|
|
730
|
+
startRowIndex,
|
|
731
|
+
startColIndex,
|
|
732
|
+
colspan,
|
|
733
|
+
rowspan
|
|
734
|
+
) {
|
|
735
|
+
for (let i = startRowIndex; i < startRowIndex + rowspan; i++) {
|
|
736
|
+
for (let j = startColIndex; j < startColIndex + colspan; j++) {
|
|
737
|
+
rowArray[i].cols[j].merged = false;
|
|
738
|
+
rowArray[i].cols[j].options.rowspan = 1;
|
|
739
|
+
rowArray[i].cols[j].options.colspan = 1;
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
},
|
|
743
|
+
|
|
744
|
+
mergeTableCol(rowArray, colArray, curRow, curCol, leftFlag, cellWidget) {
|
|
745
|
+
let mergedColIdx = !!leftFlag
|
|
746
|
+
? curCol
|
|
747
|
+
: curCol + colArray[curCol].options.colspan;
|
|
748
|
+
|
|
749
|
+
// let remainedColIdx = !!leftFlag ? curCol - colArray[curCol - 1].options.colspan : curCol
|
|
750
|
+
let remainedColIdx = !!leftFlag ? curCol - 1 : curCol;
|
|
751
|
+
if (!!leftFlag) {
|
|
752
|
+
//继续向左寻找同行未被合并的第一个单元格
|
|
753
|
+
let tmpColIdx = remainedColIdx;
|
|
754
|
+
while (tmpColIdx >= 0) {
|
|
755
|
+
if (!rowArray[curRow].cols[tmpColIdx].merged) {
|
|
756
|
+
remainedColIdx = tmpColIdx;
|
|
757
|
+
break;
|
|
758
|
+
} else {
|
|
759
|
+
tmpColIdx--;
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
if (
|
|
765
|
+
!!colArray[mergedColIdx].widgetList &&
|
|
766
|
+
colArray[mergedColIdx].widgetList.length > 0
|
|
767
|
+
) {
|
|
768
|
+
//保留widgetList
|
|
769
|
+
if (
|
|
770
|
+
!colArray[remainedColIdx].widgetList ||
|
|
771
|
+
colArray[remainedColIdx].widgetList.length === 0
|
|
772
|
+
) {
|
|
773
|
+
colArray[remainedColIdx].widgetList = baseRefUtil.deepClone(
|
|
774
|
+
colArray[mergedColIdx].widgetList
|
|
775
|
+
);
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
let newColspan =
|
|
780
|
+
colArray[mergedColIdx].options.colspan * 1 +
|
|
781
|
+
colArray[remainedColIdx].options.colspan * 1;
|
|
782
|
+
this.setPropsOfMergedCols(
|
|
783
|
+
rowArray,
|
|
784
|
+
curRow,
|
|
785
|
+
remainedColIdx,
|
|
786
|
+
newColspan,
|
|
787
|
+
cellWidget.options.rowspan
|
|
788
|
+
);
|
|
789
|
+
|
|
790
|
+
this.emitHistoryChange();
|
|
791
|
+
},
|
|
792
|
+
|
|
793
|
+
mergeTableWholeRow(rowArray, colArray, rowIndex, colIndex) {
|
|
794
|
+
//需要考虑操作的行存在已合并的单元格!!
|
|
795
|
+
//整行所有单元格行高不一致不可合并!!
|
|
796
|
+
let startRowspan = rowArray[rowIndex].cols[0].options.rowspan;
|
|
797
|
+
let unmatchedFlag = false;
|
|
798
|
+
for (let i = 1; i < rowArray[rowIndex].cols.length; i++) {
|
|
799
|
+
if (rowArray[rowIndex].cols[i].options.rowspan !== startRowspan) {
|
|
800
|
+
unmatchedFlag = true;
|
|
801
|
+
break;
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
if (unmatchedFlag) {
|
|
805
|
+
this.vueInstance.$message.info(
|
|
806
|
+
this.vueInstance.i18nt(
|
|
807
|
+
"designer.hint.rowspanNotConsistentForMergeEntireRow"
|
|
808
|
+
)
|
|
809
|
+
);
|
|
810
|
+
return;
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
let widgetListCols = colArray.filter((colItem) => {
|
|
814
|
+
return (
|
|
815
|
+
!colItem.merged &&
|
|
816
|
+
!!colItem.widgetList &&
|
|
817
|
+
colItem.widgetList.length > 0
|
|
818
|
+
);
|
|
819
|
+
});
|
|
820
|
+
if (!!widgetListCols && widgetListCols.length > 0) {
|
|
821
|
+
//保留widgetList
|
|
822
|
+
if (
|
|
823
|
+
widgetListCols[0].id !== colArray[0].id &&
|
|
824
|
+
(!colArray[0].widgetList || colArray[0].widgetList.length <= 0)
|
|
825
|
+
) {
|
|
826
|
+
colArray[0].widgetList = baseRefUtil.deepClone(
|
|
827
|
+
widgetListCols[0].widgetList
|
|
828
|
+
);
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
this.setPropsOfMergedCols(
|
|
833
|
+
rowArray,
|
|
834
|
+
rowIndex,
|
|
835
|
+
0,
|
|
836
|
+
colArray.length,
|
|
837
|
+
colArray[colIndex].options.rowspan
|
|
838
|
+
);
|
|
839
|
+
|
|
840
|
+
this.emitHistoryChange();
|
|
841
|
+
},
|
|
842
|
+
|
|
843
|
+
mergeTableRow(rowArray, curRow, curCol, aboveFlag, cellWidget) {
|
|
844
|
+
let mergedRowIdx = !!aboveFlag
|
|
845
|
+
? curRow
|
|
846
|
+
: curRow + cellWidget.options.rowspan;
|
|
847
|
+
|
|
848
|
+
//let remainedRowIdx = !!aboveFlag ? curRow - cellWidget.options.rowspan : curRow
|
|
849
|
+
let remainedRowIdx = !!aboveFlag ? curRow - 1 : curRow;
|
|
850
|
+
if (!!aboveFlag) {
|
|
851
|
+
//继续向上寻找同列未被合并的第一个单元格
|
|
852
|
+
let tmpRowIdx = remainedRowIdx;
|
|
853
|
+
while (tmpRowIdx >= 0) {
|
|
854
|
+
if (!rowArray[tmpRowIdx].cols[curCol].merged) {
|
|
855
|
+
remainedRowIdx = tmpRowIdx;
|
|
856
|
+
break;
|
|
857
|
+
} else {
|
|
858
|
+
tmpRowIdx--;
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
if (
|
|
864
|
+
!!rowArray[mergedRowIdx].cols[curCol].widgetList &&
|
|
865
|
+
rowArray[mergedRowIdx].cols[curCol].widgetList.length > 0
|
|
866
|
+
) {
|
|
867
|
+
//保留widgetList
|
|
868
|
+
if (
|
|
869
|
+
!rowArray[remainedRowIdx].cols[curCol].widgetList ||
|
|
870
|
+
rowArray[remainedRowIdx].cols[curCol].widgetList.length === 0
|
|
871
|
+
) {
|
|
872
|
+
rowArray[remainedRowIdx].cols[curCol].widgetList =
|
|
873
|
+
baseRefUtil.deepClone(
|
|
874
|
+
rowArray[mergedRowIdx].cols[curCol].widgetList
|
|
875
|
+
);
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
let newRowspan =
|
|
880
|
+
rowArray[mergedRowIdx].cols[curCol].options.rowspan * 1 +
|
|
881
|
+
rowArray[remainedRowIdx].cols[curCol].options.rowspan * 1;
|
|
882
|
+
this.setPropsOfMergedRows(
|
|
883
|
+
rowArray,
|
|
884
|
+
remainedRowIdx,
|
|
885
|
+
curCol,
|
|
886
|
+
cellWidget.options.colspan,
|
|
887
|
+
newRowspan
|
|
888
|
+
);
|
|
889
|
+
|
|
890
|
+
this.emitHistoryChange();
|
|
891
|
+
},
|
|
892
|
+
|
|
893
|
+
mergeTableWholeCol(rowArray, colArray, rowIndex, colIndex) {
|
|
894
|
+
//需要考虑操作的列存在已合并的单元格!!
|
|
895
|
+
//整列所有单元格列宽不一致不可合并!!
|
|
896
|
+
let startColspan = rowArray[0].cols[colIndex].options.colspan;
|
|
897
|
+
let unmatchedFlag = false;
|
|
898
|
+
for (let i = 1; i < rowArray.length; i++) {
|
|
899
|
+
if (rowArray[i].cols[colIndex].options.colspan !== startColspan) {
|
|
900
|
+
unmatchedFlag = true;
|
|
901
|
+
break;
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
if (unmatchedFlag) {
|
|
905
|
+
this.vueInstance.$message.info(
|
|
906
|
+
this.vueInstance.i18nt(
|
|
907
|
+
"designer.hint.colspanNotConsistentForMergeEntireColumn"
|
|
908
|
+
)
|
|
909
|
+
);
|
|
910
|
+
return;
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
let widgetListCols = [];
|
|
914
|
+
rowArray.forEach((rowItem) => {
|
|
915
|
+
let tempCell = rowItem.cols[colIndex];
|
|
916
|
+
if (
|
|
917
|
+
!tempCell.merged &&
|
|
918
|
+
!!tempCell.widgetList &&
|
|
919
|
+
tempCell.widgetList.length > 0
|
|
920
|
+
) {
|
|
921
|
+
widgetListCols.push(tempCell);
|
|
922
|
+
}
|
|
923
|
+
});
|
|
924
|
+
|
|
925
|
+
let firstCellOfCol = rowArray[0].cols[colIndex];
|
|
926
|
+
if (!!widgetListCols && widgetListCols.length > 0) {
|
|
927
|
+
//保留widgetList
|
|
928
|
+
if (
|
|
929
|
+
widgetListCols[0].id !== firstCellOfCol.id &&
|
|
930
|
+
(!firstCellOfCol.widgetList ||
|
|
931
|
+
firstCellOfCol.widgetList.length <= 0)
|
|
932
|
+
) {
|
|
933
|
+
firstCellOfCol.widgetList = baseRefUtil.deepClone(
|
|
934
|
+
widgetListCols[0].widgetList
|
|
935
|
+
);
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
this.setPropsOfMergedRows(
|
|
940
|
+
rowArray,
|
|
941
|
+
0,
|
|
942
|
+
colIndex,
|
|
943
|
+
firstCellOfCol.options.colspan,
|
|
944
|
+
rowArray.length
|
|
945
|
+
);
|
|
946
|
+
|
|
947
|
+
this.emitHistoryChange();
|
|
948
|
+
},
|
|
949
|
+
|
|
950
|
+
undoMergeTableCol(rowArray, rowIndex, colIndex, colspan, rowspan) {
|
|
951
|
+
this.setPropsOfSplitCol(rowArray, rowIndex, colIndex, colspan, rowspan);
|
|
952
|
+
|
|
953
|
+
this.emitHistoryChange();
|
|
954
|
+
},
|
|
955
|
+
|
|
956
|
+
undoMergeTableRow(rowArray, rowIndex, colIndex, colspan, rowspan) {
|
|
957
|
+
this.setPropsOfSplitRow(rowArray, rowIndex, colIndex, colspan, rowspan);
|
|
958
|
+
|
|
959
|
+
this.emitHistoryChange();
|
|
960
|
+
},
|
|
961
|
+
|
|
962
|
+
deleteTableWholeCol(rowArray, colIndex) {
|
|
963
|
+
//需考虑删除的是合并列!!
|
|
964
|
+
let onlyOneColFlag = true;
|
|
965
|
+
rowArray.forEach((ri) => {
|
|
966
|
+
if (ri.cols[0].options.colspan !== rowArray[0].cols.length) {
|
|
967
|
+
onlyOneColFlag = false;
|
|
968
|
+
}
|
|
969
|
+
});
|
|
970
|
+
//仅剩一列则不可删除!!
|
|
971
|
+
if (onlyOneColFlag) {
|
|
972
|
+
this.vueInstance.$message.info(
|
|
973
|
+
this.vueInstance.i18nt("designer.hint.lastColCannotBeDeleted")
|
|
974
|
+
);
|
|
975
|
+
return;
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
//整列所有单元格列宽不一致不可删除!!
|
|
979
|
+
let startColspan = rowArray[0].cols[colIndex].options.colspan;
|
|
980
|
+
let unmatchedFlag = false;
|
|
981
|
+
for (let i = 1; i < rowArray.length; i++) {
|
|
982
|
+
if (rowArray[i].cols[colIndex].options.colspan !== startColspan) {
|
|
983
|
+
unmatchedFlag = true;
|
|
984
|
+
break;
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
if (unmatchedFlag) {
|
|
988
|
+
this.vueInstance.$message.info(
|
|
989
|
+
this.vueInstance.i18nt(
|
|
990
|
+
"designer.hint.colspanNotConsistentForDeleteEntireColumn"
|
|
991
|
+
)
|
|
992
|
+
);
|
|
993
|
+
return;
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
rowArray.forEach((rItem) => {
|
|
997
|
+
rItem.cols.splice(colIndex, startColspan);
|
|
998
|
+
});
|
|
999
|
+
|
|
1000
|
+
this.emitHistoryChange();
|
|
1001
|
+
},
|
|
1002
|
+
|
|
1003
|
+
deleteTableWholeRow(rowArray, rowIndex) {
|
|
1004
|
+
//需考虑删除的是合并行!!
|
|
1005
|
+
let onlyOneRowFlag = true;
|
|
1006
|
+
rowArray[0].cols.forEach((ci) => {
|
|
1007
|
+
if (ci.options.rowspan !== rowArray.length) {
|
|
1008
|
+
onlyOneRowFlag = false;
|
|
1009
|
+
}
|
|
1010
|
+
});
|
|
1011
|
+
//仅剩一行则不可删除!!
|
|
1012
|
+
if (onlyOneRowFlag) {
|
|
1013
|
+
this.vueInstance.$message.info(
|
|
1014
|
+
this.vueInstance.i18nt("designer.hint.lastRowCannotBeDeleted")
|
|
1015
|
+
);
|
|
1016
|
+
return;
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
//整行所有单元格行高不一致不可删除!!
|
|
1020
|
+
let startRowspan = rowArray[rowIndex].cols[0].options.rowspan;
|
|
1021
|
+
let unmatchedFlag = false;
|
|
1022
|
+
for (let i = 1; i < rowArray[rowIndex].cols.length; i++) {
|
|
1023
|
+
if (rowArray[rowIndex].cols[i].options.rowspan !== startRowspan) {
|
|
1024
|
+
unmatchedFlag = true;
|
|
1025
|
+
break;
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
if (unmatchedFlag) {
|
|
1029
|
+
this.vueInstance.$message.info(
|
|
1030
|
+
this.vueInstance.i18nt(
|
|
1031
|
+
"designer.hint.rowspanNotConsistentForDeleteEntireRow"
|
|
1032
|
+
)
|
|
1033
|
+
);
|
|
1034
|
+
return;
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
rowArray.splice(rowIndex, startRowspan);
|
|
1038
|
+
|
|
1039
|
+
this.emitHistoryChange();
|
|
1040
|
+
},
|
|
1041
|
+
|
|
1042
|
+
getContainerByType(typeName) {
|
|
1043
|
+
let allWidgets = [
|
|
1044
|
+
...baseRefUtil.containers,
|
|
1045
|
+
...baseRefUtil.basicFields,
|
|
1046
|
+
...baseRefUtil.advancedFields,
|
|
1047
|
+
...baseRefUtil.customFields,
|
|
1048
|
+
...businessFields,
|
|
1049
|
+
];
|
|
1050
|
+
let foundCon = null;
|
|
1051
|
+
allWidgets.forEach((con) => {
|
|
1052
|
+
if (!!con.category && !!con.type && con.type === typeName) {
|
|
1053
|
+
foundCon = con;
|
|
1054
|
+
}
|
|
1055
|
+
});
|
|
1056
|
+
|
|
1057
|
+
return foundCon;
|
|
1058
|
+
},
|
|
1059
|
+
|
|
1060
|
+
getFieldWidgetByType(typeName) {
|
|
1061
|
+
let allWidgets = [
|
|
1062
|
+
...baseRefUtil.containers,
|
|
1063
|
+
...baseRefUtil.basicFields,
|
|
1064
|
+
...baseRefUtil.advancedFields,
|
|
1065
|
+
...baseRefUtil.customFields,
|
|
1066
|
+
...chartContainers,
|
|
1067
|
+
...chartWidgets,
|
|
1068
|
+
...businessFields,
|
|
1069
|
+
];
|
|
1070
|
+
let foundWidget = null;
|
|
1071
|
+
allWidgets.forEach((widget) => {
|
|
1072
|
+
if (!!!widget.category && !!widget.type && widget.type === typeName) {
|
|
1073
|
+
foundWidget = widget;
|
|
1074
|
+
}
|
|
1075
|
+
});
|
|
1076
|
+
|
|
1077
|
+
return foundWidget;
|
|
1078
|
+
},
|
|
1079
|
+
|
|
1080
|
+
hasConfig(widget, configName) {
|
|
1081
|
+
let originalWidget = null;
|
|
1082
|
+
if (!!widget.category) {
|
|
1083
|
+
originalWidget = this.getContainerByType(widget.type);
|
|
1084
|
+
} else {
|
|
1085
|
+
originalWidget = this.getFieldWidgetByType(widget.type);
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
if (!originalWidget || !originalWidget.options) {
|
|
1089
|
+
return false;
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
return Object.keys(originalWidget.options).indexOf(configName) > -1;
|
|
1093
|
+
},
|
|
1094
|
+
/*upgradeWidgetConfig(oldWidget) {
|
|
1095
|
+
let newWidget = null;
|
|
1096
|
+
if (!!oldWidget.category) {
|
|
1097
|
+
newWidget = this.getContainerByType(oldWidget.type);
|
|
1098
|
+
} else {
|
|
1099
|
+
newWidget = this.getFieldWidgetByType(oldWidget.type);
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
if (!newWidget || !newWidget.options) {
|
|
1103
|
+
return;
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
Object.keys(newWidget.options).forEach(ck => {
|
|
1107
|
+
if (!oldWidget.options.hasOwnProperty(ck)) {
|
|
1108
|
+
oldWidget.options[ck] = baseRefUtil.deepClone(newWidget.options[ck]);
|
|
1109
|
+
}
|
|
1110
|
+
});
|
|
1111
|
+
},*/
|
|
1112
|
+
upgradeWidgetConfig(oldWidget) {
|
|
1113
|
+
let newWidget = null;
|
|
1114
|
+
if (!!oldWidget.category) {
|
|
1115
|
+
newWidget = this.getContainerByType(oldWidget.type);
|
|
1116
|
+
} else {
|
|
1117
|
+
newWidget = this.getFieldWidgetByType(oldWidget.type);
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
if (!newWidget || !newWidget.options) {
|
|
1121
|
+
return;
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
Object.keys(newWidget.options).forEach((ck) => {
|
|
1125
|
+
if (!oldWidget.options.hasOwnProperty(ck)) {
|
|
1126
|
+
let value = newWidget.options[ck];
|
|
1127
|
+
let nullValue = Array.isArray(value) ? [] : null;
|
|
1128
|
+
oldWidget.options[ck] = nullValue;
|
|
1129
|
+
}
|
|
1130
|
+
});
|
|
1131
|
+
},
|
|
1132
|
+
|
|
1133
|
+
upgradeFormConfig(oldFormConfig) {
|
|
1134
|
+
Object.keys(this.formConfig).forEach((fc) => {
|
|
1135
|
+
if (!oldFormConfig.hasOwnProperty(fc)) {
|
|
1136
|
+
let value = this.formConfig[fc];
|
|
1137
|
+
let nullValue = Array.isArray(value) ? [] : null;
|
|
1138
|
+
oldFormConfig[fc] = baseRefUtil.deepClone(nullValue);
|
|
1139
|
+
}
|
|
1140
|
+
});
|
|
1141
|
+
},
|
|
1142
|
+
|
|
1143
|
+
cloneGridCol(widget, parentWidget) {
|
|
1144
|
+
let newGridCol = baseRefUtil.deepClone(
|
|
1145
|
+
this.getContainerByType("grid-col")
|
|
1146
|
+
);
|
|
1147
|
+
newGridCol.options.span = widget.options.span;
|
|
1148
|
+
let tmpId = baseRefUtil.generateId();
|
|
1149
|
+
newGridCol.id = "grid-col-" + tmpId;
|
|
1150
|
+
newGridCol.options.name = "gridCol" + tmpId;
|
|
1151
|
+
|
|
1152
|
+
parentWidget.cols.push(newGridCol);
|
|
1153
|
+
},
|
|
1154
|
+
|
|
1155
|
+
cloneContainer(containWidget) {
|
|
1156
|
+
if (containWidget.type === "grid") {
|
|
1157
|
+
let newGrid = baseRefUtil.deepClone(this.getContainerByType("grid"));
|
|
1158
|
+
newGrid.id = newGrid.type + baseRefUtil.generateId();
|
|
1159
|
+
newGrid.options.name = newGrid.id;
|
|
1160
|
+
containWidget.cols.forEach((gridCol) => {
|
|
1161
|
+
let newGridCol = baseRefUtil.deepClone(
|
|
1162
|
+
this.getContainerByType("grid-col")
|
|
1163
|
+
);
|
|
1164
|
+
let tmpId = baseRefUtil.generateId();
|
|
1165
|
+
newGridCol.id = "grid-col-" + tmpId;
|
|
1166
|
+
newGridCol.options.name = "gridCol" + tmpId;
|
|
1167
|
+
newGridCol.options.span = gridCol.options.span;
|
|
1168
|
+
newGrid.cols.push(newGridCol);
|
|
1169
|
+
});
|
|
1170
|
+
|
|
1171
|
+
return newGrid;
|
|
1172
|
+
} else if (containWidget.type === "table") {
|
|
1173
|
+
let newTable = baseRefUtil.deepClone(
|
|
1174
|
+
this.getContainerByType("table")
|
|
1175
|
+
);
|
|
1176
|
+
newTable.id = newTable.type + baseRefUtil.generateId();
|
|
1177
|
+
newTable.options.name = newTable.id;
|
|
1178
|
+
containWidget.rows.forEach((tRow) => {
|
|
1179
|
+
let newRow = baseRefUtil.deepClone(tRow);
|
|
1180
|
+
newRow.id = "table-row-" + baseRefUtil.generateId();
|
|
1181
|
+
newRow.cols.forEach((col) => {
|
|
1182
|
+
col.id = "table-cell-" + baseRefUtil.generateId();
|
|
1183
|
+
col.options.name = col.id;
|
|
1184
|
+
col.widgetList = []; //清空组件列表
|
|
1185
|
+
});
|
|
1186
|
+
newTable.rows.push(newRow);
|
|
1187
|
+
});
|
|
1188
|
+
|
|
1189
|
+
return newTable;
|
|
1190
|
+
} else if (containWidget.type === "h5-table") {
|
|
1191
|
+
let newTable = baseRefUtil.deepClone(
|
|
1192
|
+
this.getContainerByType("h5-table")
|
|
1193
|
+
);
|
|
1194
|
+
newTable.id = newTable.type + baseRefUtil.generateId();
|
|
1195
|
+
newTable.options.name = newTable.id;
|
|
1196
|
+
containWidget.rows.forEach((tRow) => {
|
|
1197
|
+
let newRow = baseRefUtil.deepClone(tRow);
|
|
1198
|
+
newRow.id = "table-row-" + baseRefUtil.generateId();
|
|
1199
|
+
newRow.cols.forEach((col) => {
|
|
1200
|
+
col.id = "table-cell-" + baseRefUtil.generateId();
|
|
1201
|
+
col.options.name = col.id;
|
|
1202
|
+
col.widgetList = []; //清空组件列表
|
|
1203
|
+
});
|
|
1204
|
+
newTable.rows.push(newRow);
|
|
1205
|
+
});
|
|
1206
|
+
|
|
1207
|
+
return newTable;
|
|
1208
|
+
} else {
|
|
1209
|
+
//其他容器组件不支持clone操作
|
|
1210
|
+
return null;
|
|
1211
|
+
}
|
|
1212
|
+
},
|
|
1213
|
+
|
|
1214
|
+
moveUpWidget(parentList, indexOfParentList) {
|
|
1215
|
+
if (!!parentList) {
|
|
1216
|
+
if (indexOfParentList === 0) {
|
|
1217
|
+
this.vueInstance.$message(
|
|
1218
|
+
this.vueInstance.i18nt("designer.hint.moveUpFirstChildHint")
|
|
1219
|
+
);
|
|
1220
|
+
return;
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
let tempWidget = parentList[indexOfParentList];
|
|
1224
|
+
parentList.splice(indexOfParentList, 1);
|
|
1225
|
+
parentList.splice(indexOfParentList - 1, 0, tempWidget);
|
|
1226
|
+
}
|
|
1227
|
+
},
|
|
1228
|
+
|
|
1229
|
+
moveDownWidget(parentList, indexOfParentList) {
|
|
1230
|
+
if (!!parentList) {
|
|
1231
|
+
if (indexOfParentList === parentList.length - 1) {
|
|
1232
|
+
this.vueInstance.$message(
|
|
1233
|
+
this.vueInstance.i18nt("designer.hint.moveDownLastChildHint")
|
|
1234
|
+
);
|
|
1235
|
+
return;
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
let tempWidget = parentList[indexOfParentList];
|
|
1239
|
+
parentList.splice(indexOfParentList, 1);
|
|
1240
|
+
parentList.splice(indexOfParentList + 1, 0, tempWidget);
|
|
1241
|
+
}
|
|
1242
|
+
},
|
|
1243
|
+
copyNewFieldWidget(origin) {
|
|
1244
|
+
let newWidget = baseRefUtil.deepClone(origin);
|
|
1245
|
+
let sourceType = newWidget.type;
|
|
1246
|
+
newWidget.type = newWidget.targetType || newWidget.type;
|
|
1247
|
+
newWidget.sourceType = sourceType;
|
|
1248
|
+
let tempId = baseRefUtil.generateId();
|
|
1249
|
+
newWidget.id = newWidget.type.replace(/-/g, "") + tempId;
|
|
1250
|
+
if (newWidget.hasOwnProperty("tableField")) {
|
|
1251
|
+
newWidget.tableField = newWidget.id; //表字段
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1254
|
+
// newWidget.options.name = newWidget.id;
|
|
1255
|
+
// newWidget.options.label = newWidget.options.label || newWidget.type.toLowerCase();
|
|
1256
|
+
|
|
1257
|
+
newWidget.nameReadonly
|
|
1258
|
+
? newWidget.options.label &&
|
|
1259
|
+
newWidget.options.label.indexOf(".") > -1 &&
|
|
1260
|
+
(newWidget.options.label = newWidget.options.label.substring(
|
|
1261
|
+
newWidget.options.label.indexOf(".") + 1
|
|
1262
|
+
))
|
|
1263
|
+
: ((newWidget.options.name = newWidget.id),
|
|
1264
|
+
(newWidget.options.label =
|
|
1265
|
+
newWidget.options.label || newWidget.type.toLowerCase()));
|
|
1266
|
+
delete newWidget.displayName;
|
|
1267
|
+
if (!newWidget.nameReadonly) {
|
|
1268
|
+
newWidget.options.keyNameEnabled = true;
|
|
1269
|
+
if (!newWidget.options.keyName)
|
|
1270
|
+
newWidget.options.keyName = newWidget.id;
|
|
1271
|
+
if (
|
|
1272
|
+
newWidget.type === "vabUpload" ||
|
|
1273
|
+
newWidget.type === "baseAttachment"
|
|
1274
|
+
) {
|
|
1275
|
+
let keyNameSuffix = this.createKeyNameSuffix(newWidget.type);
|
|
1276
|
+
// this.createKeyNameSuffix()
|
|
1277
|
+
newWidget.options.keyName = this.createKeyName(
|
|
1278
|
+
newWidget.type,
|
|
1279
|
+
keyNameSuffix
|
|
1280
|
+
);
|
|
1281
|
+
newWidget.options.keyNameSuffix = keyNameSuffix;
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
if (newWidget.type === "dropdown") {
|
|
1285
|
+
let dropdownItem1 = this.copyNewFieldWidget(
|
|
1286
|
+
this.getFieldWidgetByType("dropdown-item")
|
|
1287
|
+
);
|
|
1288
|
+
dropdownItem1.options.label = "下拉按钮1";
|
|
1289
|
+
let dropdownItem2 = this.copyNewFieldWidget(
|
|
1290
|
+
this.getFieldWidgetByType("dropdown-item")
|
|
1291
|
+
);
|
|
1292
|
+
dropdownItem2.options.label = "下拉按钮2";
|
|
1293
|
+
newWidget.widgetList.push(dropdownItem1);
|
|
1294
|
+
newWidget.widgetList.push(dropdownItem2);
|
|
1295
|
+
}
|
|
1296
|
+
this.emitEvent("canvas-add-field", newWidget.options.name);
|
|
1297
|
+
return newWidget;
|
|
1298
|
+
},
|
|
1299
|
+
createKeyName(type, suffix) {
|
|
1300
|
+
let keyNameSuffix = suffix ? suffix : this.createKeyNameSuffix(type);
|
|
1301
|
+
let keyNamePrefix = this.getKeyNamePrefix(type);
|
|
1302
|
+
let keyName = null;
|
|
1303
|
+
if (keyNamePrefix) {
|
|
1304
|
+
keyName = keyNamePrefix + keyNameSuffix;
|
|
1305
|
+
} else {
|
|
1306
|
+
keyName = keyNameSuffix;
|
|
1307
|
+
}
|
|
1308
|
+
return keyName;
|
|
1309
|
+
},
|
|
1310
|
+
createKeyNameSuffix(type) {
|
|
1311
|
+
let suffix = createUUID();
|
|
1312
|
+
/*if (type === "vabUpload" || type === "baseAttachment") {
|
|
1313
|
+
let formCode = vueInstance.reportTemplate.formCode;
|
|
1314
|
+
suffix = formCode + "_" + suffix;
|
|
1315
|
+
}*/
|
|
1316
|
+
return suffix;
|
|
1317
|
+
},
|
|
1318
|
+
getKeyNamePrefix(type) {
|
|
1319
|
+
return keyNamePrefixMap[type] ?? null;
|
|
1320
|
+
},
|
|
1321
|
+
getFormCodePrefix(type) {
|
|
1322
|
+
let prefix = this.getKeyNamePrefix(type) || "";
|
|
1323
|
+
let attachmentPrefix =
|
|
1324
|
+
prefix + vueInstance.reportTemplate.formCode + "_";
|
|
1325
|
+
return attachmentPrefix;
|
|
1326
|
+
},
|
|
1327
|
+
createAttachmentSuffix() {
|
|
1328
|
+
let type = "vabUpload";
|
|
1329
|
+
return this.createKeyNameSuffix(type);
|
|
1330
|
+
},
|
|
1331
|
+
getAttachmentPrefix() {
|
|
1332
|
+
let type = "vabUpload";
|
|
1333
|
+
return this.getKeyNamePrefix(type);
|
|
1334
|
+
},
|
|
1335
|
+
getAttachmentFormCodePrefix() {
|
|
1336
|
+
let type = "vabUpload";
|
|
1337
|
+
let attachmentPrefix = this.getFormCodePrefix(type);
|
|
1338
|
+
return attachmentPrefix;
|
|
1339
|
+
},
|
|
1340
|
+
createAttachmentKeyName(suffix) {
|
|
1341
|
+
let type = "vabUpload";
|
|
1342
|
+
let keyName = this.createKeyName(type, suffix);
|
|
1343
|
+
return keyName;
|
|
1344
|
+
},
|
|
1345
|
+
copyNewContainerWidget(origin) {
|
|
1346
|
+
let newCon = baseRefUtil.deepClone(origin);
|
|
1347
|
+
let sourceType = newCon.type;
|
|
1348
|
+
newCon.type = newCon.targetType || newCon.type;
|
|
1349
|
+
newCon.sourceType = sourceType;
|
|
1350
|
+
newCon.id = newCon.type.replace(/-/g, "") + baseRefUtil.generateId();
|
|
1351
|
+
newCon.options.name = newCon.id;
|
|
1352
|
+
if ((newCon.options.keyNameEnabled = true)) {
|
|
1353
|
+
newCon.options.keyName = newCon.id;
|
|
1354
|
+
}
|
|
1355
|
+
if (newCon.hasOwnProperty("tableField")) {
|
|
1356
|
+
newCon.tableField = newCon.id; //表字段
|
|
1357
|
+
}
|
|
1358
|
+
if (newCon.type === "grid") {
|
|
1359
|
+
let newCol = baseRefUtil.deepClone(
|
|
1360
|
+
this.getContainerByType("grid-col")
|
|
1361
|
+
);
|
|
1362
|
+
let tmpId = baseRefUtil.generateId();
|
|
1363
|
+
newCol.id = "grid-col-" + tmpId;
|
|
1364
|
+
newCol.options.name = "gridCol" + tmpId;
|
|
1365
|
+
newCon.cols.push(newCol);
|
|
1366
|
+
//
|
|
1367
|
+
newCol = baseRefUtil.deepClone(newCol);
|
|
1368
|
+
tmpId = baseRefUtil.generateId();
|
|
1369
|
+
newCol.id = "grid-col-" + tmpId;
|
|
1370
|
+
newCol.options.name = "gridCol" + tmpId;
|
|
1371
|
+
newCon.cols.push(newCol);
|
|
1372
|
+
} else if (newCon.type === "table") {
|
|
1373
|
+
let newRow = {
|
|
1374
|
+
cols: [],
|
|
1375
|
+
};
|
|
1376
|
+
newRow.id = "table-row-" + baseRefUtil.generateId();
|
|
1377
|
+
newRow.merged = false;
|
|
1378
|
+
for (let i = 0; i < 4; i++) {
|
|
1379
|
+
let newCell = baseRefUtil.deepClone(
|
|
1380
|
+
this.getContainerByType("table-cell")
|
|
1381
|
+
);
|
|
1382
|
+
newCell.id = "table-cell-" + baseRefUtil.generateId();
|
|
1383
|
+
newCell.options.name = newCell.id;
|
|
1384
|
+
newCell.merged = false;
|
|
1385
|
+
newCell.options.colspan = 1;
|
|
1386
|
+
newCell.options.rowspan = 1;
|
|
1387
|
+
newRow.cols.push(newCell);
|
|
1388
|
+
}
|
|
1389
|
+
newCon.rows.push(newRow);
|
|
1390
|
+
} else if (newCon.type === "tab") {
|
|
1391
|
+
let newTabPane = baseRefUtil.deepClone(
|
|
1392
|
+
this.getContainerByType("tab-pane")
|
|
1393
|
+
);
|
|
1394
|
+
newTabPane.id = "tab-pane-" + baseRefUtil.generateId();
|
|
1395
|
+
newTabPane.options.name = "tab1";
|
|
1396
|
+
newTabPane.options.label = "tab 1";
|
|
1397
|
+
newCon.tabs.push(newTabPane);
|
|
1398
|
+
} else if (newCon.type === "data-table") {
|
|
1399
|
+
let add_button = this.copyNewFieldWidget(
|
|
1400
|
+
this.getFieldWidgetByType("add_button")
|
|
1401
|
+
);
|
|
1402
|
+
add_button.options.onClick =
|
|
1403
|
+
"this.getWidgetRef('" +
|
|
1404
|
+
newCon.options.name +
|
|
1405
|
+
"').openEditDialog();";
|
|
1406
|
+
newCon.buttons.push(add_button);
|
|
1407
|
+
} else if (newCon.type === "detail") {
|
|
1408
|
+
let buttonCon1 = this.copyNewFieldWidget(
|
|
1409
|
+
this.getFieldWidgetByType("reset_button")
|
|
1410
|
+
);
|
|
1411
|
+
// buttonCon1.options.label = "重置";
|
|
1412
|
+
|
|
1413
|
+
let buttonCon2 = this.copyNewFieldWidget(
|
|
1414
|
+
this.getFieldWidgetByType("save_button")
|
|
1415
|
+
);
|
|
1416
|
+
buttonCon2.options.label = "保存";
|
|
1417
|
+
|
|
1418
|
+
newCon.widgetList.push(buttonCon1);
|
|
1419
|
+
newCon.widgetList.push(buttonCon2);
|
|
1420
|
+
|
|
1421
|
+
let newCol = baseRefUtil.deepClone(
|
|
1422
|
+
this.getContainerByType("detail-pane")
|
|
1423
|
+
);
|
|
1424
|
+
let tmpId = baseRefUtil.generateId();
|
|
1425
|
+
newCol.id = "detail-pane-" + tmpId;
|
|
1426
|
+
newCol.options.name = "detailPane" + tmpId;
|
|
1427
|
+
newCol.options.label = "隐藏信息";
|
|
1428
|
+
newCol.options.hidden = true;
|
|
1429
|
+
|
|
1430
|
+
let tableCon = this.copyNewContainerWidget(
|
|
1431
|
+
this.getContainerByType("table")
|
|
1432
|
+
);
|
|
1433
|
+
newCol.widgetList.push(tableCon);
|
|
1434
|
+
newCon.panes.push(newCol);
|
|
1435
|
+
|
|
1436
|
+
newCol = baseRefUtil.deepClone(
|
|
1437
|
+
this.getContainerByType("detail-pane")
|
|
1438
|
+
);
|
|
1439
|
+
tmpId = baseRefUtil.generateId();
|
|
1440
|
+
newCol.id = "detail-pane-" + tmpId;
|
|
1441
|
+
newCol.options.name = "detailPane" + tmpId;
|
|
1442
|
+
newCol.options.label = "基础信息";
|
|
1443
|
+
|
|
1444
|
+
tableCon = this.copyNewContainerWidget(
|
|
1445
|
+
this.getContainerByType("table")
|
|
1446
|
+
);
|
|
1447
|
+
newCol.widgetList.push(tableCon);
|
|
1448
|
+
newCon.panes.push(newCol);
|
|
1449
|
+
//
|
|
1450
|
+
newCol = baseRefUtil.deepClone(
|
|
1451
|
+
this.getContainerByType("detail-pane")
|
|
1452
|
+
);
|
|
1453
|
+
tmpId = baseRefUtil.generateId();
|
|
1454
|
+
newCol.id = "detail-pane-" + tmpId;
|
|
1455
|
+
newCol.options.name = "detailPane" + tmpId;
|
|
1456
|
+
newCol.options.label = "明细信息";
|
|
1457
|
+
newCol.options.tableRef = tableCon.id;
|
|
1458
|
+
let dataTableCon = this.copyNewContainerWidget(
|
|
1459
|
+
this.getContainerByType("data-table")
|
|
1460
|
+
);
|
|
1461
|
+
newCol.widgetList.push(dataTableCon);
|
|
1462
|
+
newCol.options.tableRef = dataTableCon.id;
|
|
1463
|
+
|
|
1464
|
+
let buttonCon3 = this.copyNewFieldWidget(
|
|
1465
|
+
this.getFieldWidgetByType("button")
|
|
1466
|
+
);
|
|
1467
|
+
buttonCon3.options.label = "新增";
|
|
1468
|
+
buttonCon3.options.icon = "el-icon-search";
|
|
1469
|
+
// buttonCon3.options.onClick = "this.getWidgetRef('" + dataTableCon.options.name + "').addTableData();"
|
|
1470
|
+
buttonCon3.options.clickBindEvent = "2";
|
|
1471
|
+
Object.assign(buttonCon3.options.addTableDataConfig, {
|
|
1472
|
+
tableRef: dataTableCon.options.name,
|
|
1473
|
+
});
|
|
1474
|
+
|
|
1475
|
+
newCol.buttonWidgetList.push(buttonCon3);
|
|
1476
|
+
newCon.panes.push(newCol);
|
|
1477
|
+
|
|
1478
|
+
newCol = baseRefUtil.deepClone(
|
|
1479
|
+
this.getContainerByType("detail-pane")
|
|
1480
|
+
);
|
|
1481
|
+
tmpId = baseRefUtil.generateId();
|
|
1482
|
+
newCol.id = "detail-pane-" + tmpId;
|
|
1483
|
+
newCol.options.name = "detailPane" + tmpId;
|
|
1484
|
+
newCol.options.label = "附件信息";
|
|
1485
|
+
let vabUploadCon = this.copyNewFieldWidget(
|
|
1486
|
+
this.getFieldWidgetByType("vabUpload")
|
|
1487
|
+
); //vabUpload
|
|
1488
|
+
newCol.widgetList.push(vabUploadCon);
|
|
1489
|
+
newCon.panes.push(newCol);
|
|
1490
|
+
} else if (newCon.type === "table-column") {
|
|
1491
|
+
newCon.options.label = "tableColumn";
|
|
1492
|
+
} else if (newCon.type === "h5-card") {
|
|
1493
|
+
let newCol = baseRefUtil.deepClone(
|
|
1494
|
+
this.getContainerByType("h5-card-pane")
|
|
1495
|
+
);
|
|
1496
|
+
let tmpId = baseRefUtil.generateId();
|
|
1497
|
+
newCol.id = "h5-card-pane-" + tmpId;
|
|
1498
|
+
newCol.options.name = "h5CardPane" + tmpId;
|
|
1499
|
+
newCol.options.label = "基本信息";
|
|
1500
|
+
newCon.panes.push(newCol);
|
|
1501
|
+
} else if (newCon.type === "detail-h5") {
|
|
1502
|
+
/*let newTab = this.copyNewContainerWidget(this.getContainerByType('tab'));
|
|
1503
|
+
newCon.panes.push(newTab)
|
|
1504
|
+
|
|
1505
|
+
newTab.options.tabClass = "tab-box";
|
|
1506
|
+
let newTabPane = newTab.tabs[0];
|
|
1507
|
+
newTabPane.options.label = '基本信息';*/
|
|
1508
|
+
|
|
1509
|
+
//基本信息
|
|
1510
|
+
let newCard = this.copyNewContainerWidget(
|
|
1511
|
+
this.getContainerByType("h5-card")
|
|
1512
|
+
);
|
|
1513
|
+
// newTabPane.widgetList.push(newCard);
|
|
1514
|
+
newCon.panes.push(newCard);
|
|
1515
|
+
|
|
1516
|
+
//明细信息
|
|
1517
|
+
let newCardPane = this.copyNewContainerWidget(
|
|
1518
|
+
this.getContainerByType("h5-card-pane")
|
|
1519
|
+
);
|
|
1520
|
+
newCardPane.options.label = "明细信息";
|
|
1521
|
+
newCard.panes.push(newCardPane);
|
|
1522
|
+
|
|
1523
|
+
//列表
|
|
1524
|
+
let listH5 = this.copyNewContainerWidget(
|
|
1525
|
+
this.getContainerByType("list-h5")
|
|
1526
|
+
); //vabUpload
|
|
1527
|
+
newCardPane.widgetList.push(listH5);
|
|
1528
|
+
|
|
1529
|
+
//列表新增按钮
|
|
1530
|
+
let buttonCon = this.copyNewFieldWidget(
|
|
1531
|
+
this.getFieldWidgetByType("button")
|
|
1532
|
+
);
|
|
1533
|
+
buttonCon.options.label = "新增";
|
|
1534
|
+
buttonCon.options.icon = "el-icon-search";
|
|
1535
|
+
buttonCon.options.onClick =
|
|
1536
|
+
"this.getWidgetRef('" + listH5.options.name + "').addTableData();";
|
|
1537
|
+
newCardPane.buttonWidgetList.push(buttonCon);
|
|
1538
|
+
|
|
1539
|
+
//列表行查看按钮
|
|
1540
|
+
buttonCon = this.copyNewFieldWidget(
|
|
1541
|
+
this.getFieldWidgetByType("button")
|
|
1542
|
+
);
|
|
1543
|
+
buttonCon.options.rowFlag = true;
|
|
1544
|
+
buttonCon.options.label = "查看";
|
|
1545
|
+
buttonCon.options.icon = "el-icon-edit";
|
|
1546
|
+
buttonCon.options.onClick =
|
|
1547
|
+
"this.getWidgetRef('" +
|
|
1548
|
+
listH5.options.name +
|
|
1549
|
+
"').openRowDetailDialog(row);";
|
|
1550
|
+
listH5.lineButtons.push(buttonCon);
|
|
1551
|
+
|
|
1552
|
+
//附件信息
|
|
1553
|
+
newCardPane = this.copyNewContainerWidget(
|
|
1554
|
+
this.getContainerByType("h5-card-pane")
|
|
1555
|
+
);
|
|
1556
|
+
newCardPane.options.label = "附件信息";
|
|
1557
|
+
newCard.panes.push(newCardPane);
|
|
1558
|
+
|
|
1559
|
+
let vabUploadCon = this.copyNewFieldWidget(
|
|
1560
|
+
this.getFieldWidgetByType("vabUpload")
|
|
1561
|
+
); //vabUpload
|
|
1562
|
+
newCardPane.widgetList.push(vabUploadCon);
|
|
1563
|
+
} else if (newCon.type === "h5-table") {
|
|
1564
|
+
for (let i = 0; i < 4; i++) {
|
|
1565
|
+
let newRow = {
|
|
1566
|
+
cols: [],
|
|
1567
|
+
};
|
|
1568
|
+
newRow.id = "table-row-" + baseRefUtil.generateId();
|
|
1569
|
+
newRow.merged = false;
|
|
1570
|
+
|
|
1571
|
+
let newCell = baseRefUtil.deepClone(
|
|
1572
|
+
this.getContainerByType("h5-table-cell")
|
|
1573
|
+
);
|
|
1574
|
+
newCell.id = "table-cell-" + baseRefUtil.generateId();
|
|
1575
|
+
newCell.options.name = newCell.id;
|
|
1576
|
+
newCell.merged = false;
|
|
1577
|
+
newCell.options.colspan = 1;
|
|
1578
|
+
newCell.options.rowspan = 1;
|
|
1579
|
+
newRow.cols.push(newCell);
|
|
1580
|
+
|
|
1581
|
+
let newInput = this.copyNewFieldWidget(
|
|
1582
|
+
this.getFieldWidgetByType("input")
|
|
1583
|
+
);
|
|
1584
|
+
newCell.widgetList.push(newInput);
|
|
1585
|
+
|
|
1586
|
+
newCon.rows.push(newRow);
|
|
1587
|
+
}
|
|
1588
|
+
} else if (newCon.type === "tree-pane") {
|
|
1589
|
+
//初始化列表
|
|
1590
|
+
let dataTableCon = this.copyNewContainerWidget(
|
|
1591
|
+
this.getContainerByType("data-table")
|
|
1592
|
+
);
|
|
1593
|
+
dataTableCon.options.showPagination = true;
|
|
1594
|
+
dataTableCon.options.showSearchArea = true;
|
|
1595
|
+
dataTableCon.options.isQueryTable = true;
|
|
1596
|
+
dataTableCon.options.tableHeight = "auto";
|
|
1597
|
+
dataTableCon.options.accessReturnType = "2";
|
|
1598
|
+
|
|
1599
|
+
newCon.widgetList.push(dataTableCon);
|
|
1600
|
+
|
|
1601
|
+
let addButton = this.copyNewFieldWidget(
|
|
1602
|
+
this.getFieldWidgetByType("add_button")
|
|
1603
|
+
);
|
|
1604
|
+
addButton.options.onClick =
|
|
1605
|
+
"this.getWidgetRef('" +
|
|
1606
|
+
dataTableCon.options.name +
|
|
1607
|
+
"').openEditDialog();";
|
|
1608
|
+
dataTableCon.buttons.push(addButton);
|
|
1609
|
+
|
|
1610
|
+
let tableExportButton = this.copyNewFieldWidget(
|
|
1611
|
+
this.getFieldWidgetByType("table-export-button")
|
|
1612
|
+
);
|
|
1613
|
+
tableExportButton.options.tableExportParam =
|
|
1614
|
+
"return { title: '导出', targetRef: '" +
|
|
1615
|
+
dataTableCon.options.name +
|
|
1616
|
+
"'}";
|
|
1617
|
+
dataTableCon.buttons.push(tableExportButton);
|
|
1618
|
+
|
|
1619
|
+
let searchInput = this.copyNewFieldWidget(
|
|
1620
|
+
this.getFieldWidgetByType("input")
|
|
1621
|
+
);
|
|
1622
|
+
searchInput.options.disabled = true;
|
|
1623
|
+
searchInput.options.label = newCon.options.treeLabel;
|
|
1624
|
+
dataTableCon.widgetList.push(searchInput);
|
|
1625
|
+
|
|
1626
|
+
let searchIdInput = this.copyNewFieldWidget(
|
|
1627
|
+
this.getFieldWidgetByType("input")
|
|
1628
|
+
);
|
|
1629
|
+
searchIdInput.options.disabled = true;
|
|
1630
|
+
searchIdInput.options.hidden = true;
|
|
1631
|
+
searchIdInput.options.label = `隐藏${newCon.options.treeLabel}ID`;
|
|
1632
|
+
dataTableCon.widgetList.push(searchIdInput);
|
|
1633
|
+
|
|
1634
|
+
//列表重置的时候,忽略该字段
|
|
1635
|
+
dataTableCon.options.onResetTable = `this.resetEvent({\n ignoreFields:['${searchInput.options.name}', '${searchIdInput.options.name}']\n});`;
|
|
1636
|
+
|
|
1637
|
+
//初始化树
|
|
1638
|
+
let treeCon = this.copyNewContainerWidget(
|
|
1639
|
+
this.getContainerByType("tree")
|
|
1640
|
+
);
|
|
1641
|
+
treeCon.options.onNodeClick = `this.getWidgetRef('${searchInput.options.name}').setValue(data.label);\nthis.getWidgetRef('${searchIdInput.options.name}').setValue(data.id);\nthis.getWidgetRef('${dataTableCon.options.name}').searchEvent();`;
|
|
1642
|
+
|
|
1643
|
+
newCon.options.onTreeLabelClick = `this.getWidgetRef('${treeCon.options.name}').setCurrentKey();\nthis.getWidgetRef('${searchInput.options.name}').setValue(null);\nthis.getWidgetRef('${searchIdInput.options.name}').setValue(null);\nthis.getWidgetRef('${dataTableCon.options.name}').searchEvent();`;
|
|
1644
|
+
newCon.leftWidgetList.push(treeCon);
|
|
1645
|
+
}
|
|
1646
|
+
//newCon.options.customClass = []
|
|
1647
|
+
|
|
1648
|
+
delete newCon.displayName;
|
|
1649
|
+
return newCon;
|
|
1650
|
+
},
|
|
1651
|
+
|
|
1652
|
+
addContainerByDbClick(container) {
|
|
1653
|
+
let newCon = this.copyNewContainerWidget(container);
|
|
1654
|
+
this.widgetList.push(newCon);
|
|
1655
|
+
this.setSelected(newCon);
|
|
1656
|
+
},
|
|
1657
|
+
|
|
1658
|
+
addFieldByDbClick(widget) {
|
|
1659
|
+
let newWidget = this.copyNewFieldWidget(widget);
|
|
1660
|
+
if (!!this.selectedWidget && this.selectedWidget.type === "tab") {
|
|
1661
|
+
//获取当前激活的tabPane
|
|
1662
|
+
let activeTab = this.selectedWidget.tabs[0];
|
|
1663
|
+
this.selectedWidget.tabs.forEach((tabPane) => {
|
|
1664
|
+
if (!!tabPane.options.active) {
|
|
1665
|
+
activeTab = tabPane;
|
|
1666
|
+
}
|
|
1667
|
+
});
|
|
1668
|
+
|
|
1669
|
+
!!activeTab && activeTab.widgetList.push(newWidget);
|
|
1670
|
+
} else if (!!this.selectedWidget && !!this.selectedWidget.widgetList) {
|
|
1671
|
+
this.selectedWidget.widgetList.push(newWidget);
|
|
1672
|
+
} else {
|
|
1673
|
+
this.widgetList.push(newWidget);
|
|
1674
|
+
}
|
|
1675
|
+
|
|
1676
|
+
this.setSelected(newWidget);
|
|
1677
|
+
this.emitEvent("canvas-add-field", newWidget.options.name),
|
|
1678
|
+
this.emitHistoryChange();
|
|
1679
|
+
},
|
|
1680
|
+
deletePaneOfDetail(gridWidget, colIdx) {
|
|
1681
|
+
if (!!gridWidget && !!gridWidget.panes) {
|
|
1682
|
+
gridWidget.panes.splice(colIdx, 1);
|
|
1683
|
+
}
|
|
1684
|
+
},
|
|
1685
|
+
cloneDetailPane(widget, parentWidget) {
|
|
1686
|
+
let newGridCol = baseRefUtil.deepClone(
|
|
1687
|
+
this.getContainerByType("detail-pane")
|
|
1688
|
+
);
|
|
1689
|
+
let tmpId = baseRefUtil.generateId();
|
|
1690
|
+
newGridCol.id = "detail-pane-" + tmpId;
|
|
1691
|
+
newGridCol.options.name = "detailPane" + tmpId;
|
|
1692
|
+
newGridCol.options.label = widget.options.label;
|
|
1693
|
+
parentWidget.panes.push(newGridCol);
|
|
1694
|
+
},
|
|
1695
|
+
cloneH5CardPanePane(widget, parentWidget) {
|
|
1696
|
+
let newGridCol = baseRefUtil.deepClone(
|
|
1697
|
+
this.getContainerByType("h5-card-pane")
|
|
1698
|
+
);
|
|
1699
|
+
let tmpId = baseRefUtil.generateId();
|
|
1700
|
+
newGridCol.id = "h5-card-pane-" + tmpId;
|
|
1701
|
+
newGridCol.options.name = "h5CardPane" + tmpId;
|
|
1702
|
+
newGridCol.options.label = widget.options.label;
|
|
1703
|
+
parentWidget.panes.push(newGridCol);
|
|
1704
|
+
},
|
|
1705
|
+
|
|
1706
|
+
addNewPaneOfDetail(gridWidget) {
|
|
1707
|
+
const cols = gridWidget.panes;
|
|
1708
|
+
let newGridCol = baseRefUtil.deepClone(
|
|
1709
|
+
this.getContainerByType("detail-pane")
|
|
1710
|
+
);
|
|
1711
|
+
let tmpId = baseRefUtil.generateId();
|
|
1712
|
+
newGridCol.id = "detail-pane-" + tmpId;
|
|
1713
|
+
newGridCol.options.name = "detailPane" + tmpId;
|
|
1714
|
+
newGridCol.options.label = "detailPane" + tmpId;
|
|
1715
|
+
gridWidget.panes.push(newGridCol);
|
|
1716
|
+
},
|
|
1717
|
+
|
|
1718
|
+
deleteColOfGrid(gridWidget, colIdx) {
|
|
1719
|
+
if (!!gridWidget && !!gridWidget.cols) {
|
|
1720
|
+
gridWidget.cols.splice(colIdx, 1);
|
|
1721
|
+
}
|
|
1722
|
+
},
|
|
1723
|
+
|
|
1724
|
+
addNewColOfGrid(gridWidget) {
|
|
1725
|
+
const cols = gridWidget.cols;
|
|
1726
|
+
let newGridCol = baseRefUtil.deepClone(
|
|
1727
|
+
this.getContainerByType("grid-col")
|
|
1728
|
+
);
|
|
1729
|
+
let tmpId = baseRefUtil.generateId();
|
|
1730
|
+
newGridCol.id = "grid-col-" + tmpId;
|
|
1731
|
+
newGridCol.options.name = "gridCol" + tmpId;
|
|
1732
|
+
if (!!cols && cols.length > 0) {
|
|
1733
|
+
let spanSum = 0;
|
|
1734
|
+
cols.forEach((col) => {
|
|
1735
|
+
spanSum += col.options.span;
|
|
1736
|
+
});
|
|
1737
|
+
|
|
1738
|
+
if (spanSum >= 24) {
|
|
1739
|
+
//this.$message.info('列栅格之和超出24')
|
|
1740
|
+
console.log("列栅格之和超出24");
|
|
1741
|
+
gridWidget.cols.push(newGridCol);
|
|
1742
|
+
} else {
|
|
1743
|
+
newGridCol.options.span = 24 - spanSum > 12 ? 12 : 24 - spanSum;
|
|
1744
|
+
gridWidget.cols.push(newGridCol);
|
|
1745
|
+
}
|
|
1746
|
+
} else {
|
|
1747
|
+
gridWidget.cols = [newGridCol];
|
|
1748
|
+
}
|
|
1749
|
+
},
|
|
1750
|
+
|
|
1751
|
+
addTabPaneOfTabs(tabsWidget) {
|
|
1752
|
+
const tabPanes = tabsWidget.tabs;
|
|
1753
|
+
let newTabPane = baseRefUtil.deepClone(
|
|
1754
|
+
this.getContainerByType("tab-pane")
|
|
1755
|
+
);
|
|
1756
|
+
newTabPane.id = "tab-pane-" + baseRefUtil.generateId();
|
|
1757
|
+
newTabPane.options.name = newTabPane.id;
|
|
1758
|
+
newTabPane.options.label = "tab " + (tabPanes.length + 1);
|
|
1759
|
+
tabPanes.push(newTabPane);
|
|
1760
|
+
},
|
|
1761
|
+
|
|
1762
|
+
deleteTabPaneOfTabs(tabsWidget, tpIdx) {
|
|
1763
|
+
tabsWidget.tabs.splice(tpIdx, 1);
|
|
1764
|
+
},
|
|
1765
|
+
|
|
1766
|
+
addDropdownItem(tabsWidget) {
|
|
1767
|
+
const tabPanes = tabsWidget.widgetList;
|
|
1768
|
+
let newTabPane = baseRefUtil.deepClone(
|
|
1769
|
+
this.getFieldWidgetByType("dropdown-item")
|
|
1770
|
+
);
|
|
1771
|
+
newTabPane.id = "dropdown-item-" + baseRefUtil.generateId();
|
|
1772
|
+
newTabPane.options.name = newTabPane.id;
|
|
1773
|
+
newTabPane.options.label = "dropdown-item " + (tabPanes.length + 1);
|
|
1774
|
+
tabPanes.push(newTabPane);
|
|
1775
|
+
},
|
|
1776
|
+
|
|
1777
|
+
deleteDropdownItem(tabsWidget, tpIdx) {
|
|
1778
|
+
tabsWidget.widgetList.splice(tpIdx, 1);
|
|
1779
|
+
},
|
|
1780
|
+
|
|
1781
|
+
emitEvent(evtName, evtData) {
|
|
1782
|
+
//用于兄弟组件发射事件
|
|
1783
|
+
this.vueInstance.$emit(evtName, evtData);
|
|
1784
|
+
},
|
|
1785
|
+
|
|
1786
|
+
handleEvent(evtName, callback) {
|
|
1787
|
+
//用于兄弟组件接收事件
|
|
1788
|
+
this.vueInstance.$on(evtName, (data) => callback(data));
|
|
1789
|
+
},
|
|
1790
|
+
|
|
1791
|
+
setCssClassList(cssClassList) {
|
|
1792
|
+
this.cssClassList = cssClassList;
|
|
1793
|
+
},
|
|
1794
|
+
|
|
1795
|
+
getCssClassList() {
|
|
1796
|
+
return this.cssClassList;
|
|
1797
|
+
},
|
|
1798
|
+
|
|
1799
|
+
registerFormWidget(formWidget) {
|
|
1800
|
+
this.formWidget = formWidget;
|
|
1801
|
+
},
|
|
1802
|
+
|
|
1803
|
+
initHistoryData() {
|
|
1804
|
+
this.loadFormContentFromStorage();
|
|
1805
|
+
this.historyData.index++;
|
|
1806
|
+
this.historyData.steps[this.historyData.index] = {
|
|
1807
|
+
widgetList: baseRefUtil.deepClone(this.widgetList),
|
|
1808
|
+
formConfig: baseRefUtil.deepClone(this.formConfig),
|
|
1809
|
+
};
|
|
1810
|
+
},
|
|
1811
|
+
|
|
1812
|
+
emitHistoryChange() {
|
|
1813
|
+
//console.log('------------', 'Form history changed!')
|
|
1814
|
+
|
|
1815
|
+
if (this.historyData.index === this.historyData.maxStep - 1) {
|
|
1816
|
+
this.historyData.steps.shift();
|
|
1817
|
+
} else {
|
|
1818
|
+
this.historyData.index++;
|
|
1819
|
+
}
|
|
1820
|
+
|
|
1821
|
+
this.historyData.steps[this.historyData.index] = {
|
|
1822
|
+
widgetList: baseRefUtil.deepClone(this.widgetList),
|
|
1823
|
+
formConfig: baseRefUtil.deepClone(this.formConfig),
|
|
1824
|
+
};
|
|
1825
|
+
|
|
1826
|
+
this.saveFormContentToStorage();
|
|
1827
|
+
|
|
1828
|
+
if (this.historyData.index < this.historyData.steps.length - 1) {
|
|
1829
|
+
this.historyData.steps = this.historyData.steps.slice(
|
|
1830
|
+
0,
|
|
1831
|
+
this.historyData.index + 1
|
|
1832
|
+
);
|
|
1833
|
+
}
|
|
1834
|
+
|
|
1835
|
+
//console.log('history', this.historyData.index)
|
|
1836
|
+
},
|
|
1837
|
+
|
|
1838
|
+
saveCurrentHistoryStep() {
|
|
1839
|
+
this.historyData.steps[this.historyData.index] = baseRefUtil.deepClone({
|
|
1840
|
+
widgetList: this.widgetList,
|
|
1841
|
+
formConfig: this.formConfig,
|
|
1842
|
+
});
|
|
1843
|
+
|
|
1844
|
+
this.saveFormContentToStorage();
|
|
1845
|
+
},
|
|
1846
|
+
|
|
1847
|
+
undoHistoryStep() {
|
|
1848
|
+
if (this.historyData.index !== 0) {
|
|
1849
|
+
this.historyData.index--;
|
|
1850
|
+
}
|
|
1851
|
+
//console.log('undo', this.historyData.index)
|
|
1852
|
+
|
|
1853
|
+
this.widgetList = baseRefUtil.deepClone(
|
|
1854
|
+
this.historyData.steps[this.historyData.index].widgetList
|
|
1855
|
+
);
|
|
1856
|
+
this.formConfig = baseRefUtil.deepClone(
|
|
1857
|
+
this.historyData.steps[this.historyData.index].formConfig
|
|
1858
|
+
);
|
|
1859
|
+
},
|
|
1860
|
+
|
|
1861
|
+
redoHistoryStep() {
|
|
1862
|
+
if (this.historyData.index !== this.historyData.steps.length - 1) {
|
|
1863
|
+
this.historyData.index++;
|
|
1864
|
+
}
|
|
1865
|
+
//console.log('redo', this.historyData.index)
|
|
1866
|
+
|
|
1867
|
+
this.widgetList = baseRefUtil.deepClone(
|
|
1868
|
+
this.historyData.steps[this.historyData.index].widgetList
|
|
1869
|
+
);
|
|
1870
|
+
this.formConfig = baseRefUtil.deepClone(
|
|
1871
|
+
this.historyData.steps[this.historyData.index].formConfig
|
|
1872
|
+
);
|
|
1873
|
+
},
|
|
1874
|
+
|
|
1875
|
+
undoEnabled() {
|
|
1876
|
+
return this.historyData.index > 0 && this.historyData.steps.length > 0;
|
|
1877
|
+
},
|
|
1878
|
+
|
|
1879
|
+
redoEnabled() {
|
|
1880
|
+
return this.historyData.index < this.historyData.steps.length - 1;
|
|
1881
|
+
},
|
|
1882
|
+
|
|
1883
|
+
saveFormContentToStorage() {
|
|
1884
|
+
window.localStorage.setItem(
|
|
1885
|
+
"widget__list__backup",
|
|
1886
|
+
JSON.stringify(this.widgetList)
|
|
1887
|
+
);
|
|
1888
|
+
window.localStorage.setItem(
|
|
1889
|
+
"form__config__backup",
|
|
1890
|
+
JSON.stringify(this.formConfig)
|
|
1891
|
+
);
|
|
1892
|
+
},
|
|
1893
|
+
|
|
1894
|
+
loadFormContentFromStorage() {
|
|
1895
|
+
let widgetListBackup = window.localStorage.getItem(
|
|
1896
|
+
"widget__list__backup"
|
|
1897
|
+
);
|
|
1898
|
+
if (!!widgetListBackup) {
|
|
1899
|
+
this.widgetList = JSON.parse(widgetListBackup);
|
|
1900
|
+
}
|
|
1901
|
+
|
|
1902
|
+
let formConfigBackup = window.localStorage.getItem(
|
|
1903
|
+
"form__config__backup"
|
|
1904
|
+
);
|
|
1905
|
+
if (!!formConfigBackup) {
|
|
1906
|
+
//this.formConfig = JSON.parse(formConfigBackup)
|
|
1907
|
+
baseRefUtil.overwriteObj(
|
|
1908
|
+
this.formConfig,
|
|
1909
|
+
JSON.parse(formConfigBackup)
|
|
1910
|
+
); /* 用=赋值,会导致inject依赖注入的formConfig属性变成非响应式 */
|
|
1911
|
+
}
|
|
1912
|
+
},
|
|
1913
|
+
getColumnWidget(row, isEdit) {
|
|
1914
|
+
//获取
|
|
1915
|
+
let formatS = isEdit ? row.editFormatS : row.formatS;
|
|
1916
|
+
let type = columnFormatMap[formatS];
|
|
1917
|
+
if (!type) return null;
|
|
1918
|
+
if (isEdit) {
|
|
1919
|
+
if (row.editWidget) {
|
|
1920
|
+
return row.editWidget;
|
|
1921
|
+
}
|
|
1922
|
+
if (row.editColumnOption) {
|
|
1923
|
+
let fieldWidget = this.copyNewFieldWidget(
|
|
1924
|
+
this.getFieldWidgetByType(type)
|
|
1925
|
+
);
|
|
1926
|
+
fieldWidget.options = row.editColumnOption;
|
|
1927
|
+
return fieldWidget;
|
|
1928
|
+
}
|
|
1929
|
+
} else {
|
|
1930
|
+
if (row.widget) {
|
|
1931
|
+
return row.widget;
|
|
1932
|
+
}
|
|
1933
|
+
if (row.columnOption) {
|
|
1934
|
+
let fieldWidget = this.copyNewFieldWidget(
|
|
1935
|
+
this.getFieldWidgetByType(type)
|
|
1936
|
+
);
|
|
1937
|
+
fieldWidget.options = row.columnOption;
|
|
1938
|
+
return fieldWidget;
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1941
|
+
return this.createColumnWidget(row, isEdit);
|
|
1942
|
+
},
|
|
1943
|
+
getIsFileWidget(type) {
|
|
1944
|
+
return type === "vabUpload" || type === "baseAttachment";
|
|
1945
|
+
},
|
|
1946
|
+
createColumnWidget(row, isEdit) {
|
|
1947
|
+
let formatS = isEdit ? row.editFormatS : row.formatS;
|
|
1948
|
+
let type = columnFormatMap[formatS];
|
|
1949
|
+
if (!type) return null;
|
|
1950
|
+
|
|
1951
|
+
let columnSelectedWidget = null;
|
|
1952
|
+
if (type) {
|
|
1953
|
+
columnSelectedWidget = this.copyNewFieldWidget(
|
|
1954
|
+
this.getFieldWidgetByType(type)
|
|
1955
|
+
);
|
|
1956
|
+
|
|
1957
|
+
if (columnSelectedWidget.options.hasOwnProperty("required")) {
|
|
1958
|
+
columnSelectedWidget.options.required = row.required || false;
|
|
1959
|
+
}
|
|
1960
|
+
|
|
1961
|
+
if ("editDelete" === formatS) {
|
|
1962
|
+
columnSelectedWidget.options.prefixIcon = "el-icon-delete";
|
|
1963
|
+
columnSelectedWidget.options.label = "删除";
|
|
1964
|
+
columnSelectedWidget.options.labelHidden = true;
|
|
1965
|
+
columnSelectedWidget.options.hiddenByWf = true;
|
|
1966
|
+
columnSelectedWidget.options.onClick =
|
|
1967
|
+
"let tableParam = this.tableParam;\nlet tableRef = this.getWidgetRef(this.parentWidget.options.name);\ntableRef.deleteRow(tableParam.row,tableParam.rowIndex);";
|
|
1968
|
+
} else if ("editButton" === formatS) {
|
|
1969
|
+
columnSelectedWidget.options.prefixIcon = "el-icon-edit";
|
|
1970
|
+
columnSelectedWidget.options.label = "查看";
|
|
1971
|
+
columnSelectedWidget.options.labelHidden = true;
|
|
1972
|
+
columnSelectedWidget.options.onClick =
|
|
1973
|
+
"let tableParam = this.tableParam;\nlet tableRef = this.getWidgetRef(this.parentWidget.options.name);\ntableRef.openEditDialog(tableParam.row)";
|
|
1974
|
+
} else if ("addSiblingEditRow" === formatS) {
|
|
1975
|
+
columnSelectedWidget.options.prefixIcon = "el-icon-plus";
|
|
1976
|
+
columnSelectedWidget.options.label = "新增兄弟节点";
|
|
1977
|
+
columnSelectedWidget.options.labelHidden = false;
|
|
1978
|
+
columnSelectedWidget.options.onClick =
|
|
1979
|
+
"let tableParam = this.tableParam;\nthis.getParentTarget().addSiblingTreeRow(null,tableParam);";
|
|
1980
|
+
} else if ("addChildTreeRow" === formatS) {
|
|
1981
|
+
columnSelectedWidget.options.prefixIcon = "el-icon-plus";
|
|
1982
|
+
columnSelectedWidget.options.label = "新增子节点";
|
|
1983
|
+
columnSelectedWidget.options.labelHidden = false;
|
|
1984
|
+
columnSelectedWidget.options.onClick =
|
|
1985
|
+
"let tableParam = this.tableParam;\nthis.getParentTarget().addChildTreeRow(null,tableParam);";
|
|
1986
|
+
} else if ("moveUpRow" === formatS) {
|
|
1987
|
+
columnSelectedWidget.options.label = "↑上移";
|
|
1988
|
+
columnSelectedWidget.options.labelHidden = false;
|
|
1989
|
+
columnSelectedWidget.options.onClick =
|
|
1990
|
+
"let tableParam = this.tableParam;\nthis.getParentTarget().moveUpRow(tableParam);";
|
|
1991
|
+
} else if ("moveDownRow" === formatS) {
|
|
1992
|
+
columnSelectedWidget.options.label = "↓下移";
|
|
1993
|
+
columnSelectedWidget.options.labelHidden = false;
|
|
1994
|
+
columnSelectedWidget.options.onClick =
|
|
1995
|
+
"let tableParam = this.tableParam;\nthis.getParentTarget().moveDownRow(tableParam);";
|
|
1996
|
+
} else if ("removeTreeRow" === formatS) {
|
|
1997
|
+
columnSelectedWidget.options.prefixIcon = "el-icon-delete";
|
|
1998
|
+
columnSelectedWidget.options.label = "删除";
|
|
1999
|
+
columnSelectedWidget.options.labelHidden = true;
|
|
2000
|
+
columnSelectedWidget.options.onClick =
|
|
2001
|
+
"let tableParam = this.tableParam;\nthis.getParentTarget().removeTreeRow(tableParam);";
|
|
2002
|
+
}
|
|
2003
|
+
|
|
2004
|
+
if (columnSelectedWidget.options.hasOwnProperty("keyName")) {
|
|
2005
|
+
if (!this.getIsFileWidget(type)) {
|
|
2006
|
+
columnSelectedWidget.options.keyName = row.prop;
|
|
2007
|
+
}
|
|
2008
|
+
|
|
2009
|
+
columnSelectedWidget.options.keyNameEnabled = true;
|
|
2010
|
+
} else {
|
|
2011
|
+
columnSelectedWidget.options.name = row.prop;
|
|
2012
|
+
}
|
|
2013
|
+
|
|
2014
|
+
if (type === "dropdown") {
|
|
2015
|
+
columnSelectedWidget.options.dropdownType = "link";
|
|
2016
|
+
} else if (type !== "button" && type !== "a-link") {
|
|
2017
|
+
columnSelectedWidget.options.label = row.label;
|
|
2018
|
+
columnSelectedWidget.options.labelHidden = true;
|
|
2019
|
+
}
|
|
2020
|
+
}
|
|
2021
|
+
return columnSelectedWidget;
|
|
2022
|
+
},
|
|
2023
|
+
};
|
|
2024
|
+
};
|
|
2025
|
+
})();
|
|
2026
|
+
|
|
2027
|
+
export const createDesigner = createDesigner0;
|