cloud-web-corejs 1.1.0-dev.19 → 1.1.0-dev.20

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