@vxe-ui/plugin-menu 3.3.2 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.umd.js +104 -24
- package/dist/index.umd.min.js +1 -1
- package/es/index.esm.js +102 -26
- package/es/index.js +102 -26
- package/lib/index.common.js +104 -24
- package/lib/index.js +104 -24
- package/lib/index.umd.js +104 -24
- package/lib/index.umd.min.js +1 -1
- package/package.json +6 -7
- package/src/index.ts +100 -24
package/es/index.esm.js
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import XEUtils from 'xe-utils';
|
|
2
2
|
let VxeUI;
|
|
3
3
|
let handleCopy;
|
|
4
|
+
/**
|
|
5
|
+
* 用于开关类型的配置项
|
|
6
|
+
* 局部启用规则:conf={}
|
|
7
|
+
* 局部禁用规则:conf={enabled:false}
|
|
8
|
+
* 全局默认启用规则:conf.enabled=true
|
|
9
|
+
*/
|
|
10
|
+
export function hasEnableConf(conf, opts) {
|
|
11
|
+
return opts && (conf ? opts.enabled !== false : opts.enabled);
|
|
12
|
+
}
|
|
4
13
|
const columnIndexOf = (cols, column) => {
|
|
5
14
|
return XEUtils.findIndexOf(cols, item => item.id === column.id);
|
|
6
15
|
};
|
|
@@ -75,7 +84,7 @@ function handleCopyOrCut(params, isCut) {
|
|
|
75
84
|
const { mouseConfig } = props;
|
|
76
85
|
const mouseOpts = $table.computeMouseOpts;
|
|
77
86
|
let text = '';
|
|
78
|
-
if (mouseConfig && mouseOpts.area) {
|
|
87
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
79
88
|
if (isCut) {
|
|
80
89
|
$table.triggerCutCellAreaEvent($event);
|
|
81
90
|
}
|
|
@@ -138,7 +147,7 @@ function getBeenMerges(params) {
|
|
|
138
147
|
const mouseOpts = $table.computeMouseOpts;
|
|
139
148
|
const { visibleData } = $table.getTableData();
|
|
140
149
|
const { visibleColumn } = $table.getTableColumn();
|
|
141
|
-
const cellAreas = mouseConfig && mouseOpts.area ? $table.getCellAreas() : [];
|
|
150
|
+
const cellAreas = hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area ? $table.getCellAreas() : [];
|
|
142
151
|
const mergeList = $table.getMergeCells();
|
|
143
152
|
return mergeList.filter(({ row: mergeRowIndex, col: mergeColIndex, rowspan: mergeRowspan, colspan: mergeColspan }) => {
|
|
144
153
|
return cellAreas.some(areaItem => {
|
|
@@ -210,10 +219,14 @@ function checkPrivilege(item, params) {
|
|
|
210
219
|
}
|
|
211
220
|
case 'EDIT_CELL':
|
|
212
221
|
case 'CLEAR_CELL':
|
|
222
|
+
case 'CLEAR_AREA_CELL':
|
|
213
223
|
case 'CLEAR_ROW':
|
|
214
224
|
case 'COPY_CELL':
|
|
225
|
+
case 'COPY_AREA_CELL':
|
|
215
226
|
case 'CUT_CELL':
|
|
227
|
+
case 'CUT_AREA_CELL':
|
|
216
228
|
case 'PASTE_CELL':
|
|
229
|
+
case 'PASTE_AREA_CELL':
|
|
217
230
|
case 'MERGE_OR_CLEAR':
|
|
218
231
|
case 'MERGE_CELL':
|
|
219
232
|
case 'REVERT_CELL':
|
|
@@ -266,7 +279,7 @@ function checkPrivilege(item, params) {
|
|
|
266
279
|
}
|
|
267
280
|
case 'OPEN_FIND':
|
|
268
281
|
case 'OPEN_REPLACE': {
|
|
269
|
-
item.disabled = !(mouseConfig && mouseOpts.area);
|
|
282
|
+
item.disabled = !(hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area);
|
|
270
283
|
break;
|
|
271
284
|
}
|
|
272
285
|
case 'EDIT_CELL': {
|
|
@@ -274,13 +287,17 @@ function checkPrivilege(item, params) {
|
|
|
274
287
|
break;
|
|
275
288
|
}
|
|
276
289
|
case 'COPY_CELL':
|
|
290
|
+
case 'COPY_AREA_CELL':
|
|
277
291
|
case 'CUT_CELL':
|
|
278
|
-
case '
|
|
279
|
-
|
|
292
|
+
case 'CUT_AREA_CELL':
|
|
293
|
+
case 'PASTE_CELL':
|
|
294
|
+
case 'PASTE_AREA_CELL': {
|
|
295
|
+
const cellAreas = hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area ? $table.getCellAreas() : [];
|
|
280
296
|
item.disabled = cellAreas.length > 1;
|
|
281
297
|
if (!item.disabled) {
|
|
282
298
|
switch (code) {
|
|
283
|
-
case 'PASTE_CELL':
|
|
299
|
+
case 'PASTE_CELL':
|
|
300
|
+
case 'PASTE_AREA_CELL': {
|
|
284
301
|
const clipboard = getClipboardObj();
|
|
285
302
|
item.disabled = !clipboard || !clipboard.text;
|
|
286
303
|
break;
|
|
@@ -291,7 +308,7 @@ function checkPrivilege(item, params) {
|
|
|
291
308
|
}
|
|
292
309
|
case 'MERGE_OR_CLEAR':
|
|
293
310
|
case 'MERGE_CELL': {
|
|
294
|
-
const cellAreas = mouseConfig && mouseOpts.area ? $table.getCellAreas() : [];
|
|
311
|
+
const cellAreas = hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area ? $table.getCellAreas() : [];
|
|
295
312
|
item.disabled = !cellAreas.length || (cellAreas.length === 1 && cellAreas[0].rows.length === 1 && cellAreas[0].cols.length === 1) || !checkCellOverlay(params, cellAreas);
|
|
296
313
|
break;
|
|
297
314
|
}
|
|
@@ -424,12 +441,12 @@ export const VxeUIPluginMenu = {
|
|
|
424
441
|
const pVersion = 3;
|
|
425
442
|
const sVersion = 13;
|
|
426
443
|
if (!VxeUI.checkVersion(VxeUI.tableVersion, pVersion, sVersion)) {
|
|
427
|
-
console.error(`[@vxe-ui/plugin-menu 3.
|
|
444
|
+
console.error(`[@vxe-ui/plugin-menu 3.4.0] ${VxeUI.getI18n('vxe.error.errorVersion', [`vxe-table@${VxeUI.tableVersion || '?'}`, `vxe-table v${pVersion}.${sVersion}+`])}`);
|
|
428
445
|
}
|
|
429
446
|
}
|
|
430
447
|
else {
|
|
431
448
|
if (!/^(3)\./.test(VxeUI.uiVersion || VxeUI.tableVersion)) {
|
|
432
|
-
console.error('[@vxe-ui/plugin-menu 3.
|
|
449
|
+
console.error('[@vxe-ui/plugin-menu 3.4.0] Requires vxe-table 3.9.0+ version. https://vxeui.com/other3/#/plugin-menu/install');
|
|
433
450
|
}
|
|
434
451
|
}
|
|
435
452
|
pluginConfig(options);
|
|
@@ -474,7 +491,36 @@ export const VxeUIPluginMenu = {
|
|
|
474
491
|
const tableProps = $table;
|
|
475
492
|
const { mouseConfig } = tableProps;
|
|
476
493
|
const mouseOpts = $table.computeMouseOpts;
|
|
477
|
-
if (mouseConfig && mouseOpts.area) {
|
|
494
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
495
|
+
const cellAreas = $table.getCellAreas();
|
|
496
|
+
if (cellAreas && cellAreas.length) {
|
|
497
|
+
cellAreas.forEach(areaItem => {
|
|
498
|
+
const { rows, cols } = areaItem;
|
|
499
|
+
cols.forEach(column => {
|
|
500
|
+
rows.forEach(row => {
|
|
501
|
+
$table.clearData(row, column.field);
|
|
502
|
+
});
|
|
503
|
+
});
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
else {
|
|
508
|
+
$table.clearData(row, column.field);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
},
|
|
513
|
+
/**
|
|
514
|
+
* 清除单元格数据的值;如果启用 mouse-config.area 功能,则清除区域范围内的单元格数据
|
|
515
|
+
*/
|
|
516
|
+
CLEAR_AREA_CELL: {
|
|
517
|
+
tableMenuMethod(params) {
|
|
518
|
+
const { $table, row, column } = params;
|
|
519
|
+
if (row && column) {
|
|
520
|
+
const tableProps = $table;
|
|
521
|
+
const { mouseConfig } = tableProps;
|
|
522
|
+
const mouseOpts = $table.computeMouseOpts;
|
|
523
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
478
524
|
const cellAreas = $table.getCellAreas();
|
|
479
525
|
if (cellAreas && cellAreas.length) {
|
|
480
526
|
cellAreas.forEach(areaItem => {
|
|
@@ -522,8 +568,8 @@ export const VxeUIPluginMenu = {
|
|
|
522
568
|
const tableProps = $table;
|
|
523
569
|
const { mouseConfig } = tableProps;
|
|
524
570
|
const mouseOpts = $table.computeMouseOpts;
|
|
525
|
-
if (mouseConfig && mouseOpts.area) {
|
|
526
|
-
const cellAreas =
|
|
571
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
572
|
+
const cellAreas = mouseOpts.area ? $table.getCellAreas() : [];
|
|
527
573
|
cellAreas.forEach(areaItem => {
|
|
528
574
|
const { rows, cols } = areaItem;
|
|
529
575
|
rows.forEach(row => {
|
|
@@ -558,7 +604,7 @@ export const VxeUIPluginMenu = {
|
|
|
558
604
|
const tableProps = $table;
|
|
559
605
|
const { mouseConfig } = tableProps;
|
|
560
606
|
const mouseOpts = $table.computeMouseOpts;
|
|
561
|
-
if (mouseConfig && mouseOpts.area) {
|
|
607
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
562
608
|
const { visibleData } = $table.getTableData();
|
|
563
609
|
const { visibleColumn } = $table.getTableColumn();
|
|
564
610
|
$table.setCellAreas([{
|
|
@@ -579,7 +625,7 @@ export const VxeUIPluginMenu = {
|
|
|
579
625
|
const tableProps = $table;
|
|
580
626
|
const { mouseConfig } = tableProps;
|
|
581
627
|
const mouseOpts = $table.computeMouseOpts;
|
|
582
|
-
if (mouseConfig && mouseOpts.area) {
|
|
628
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
583
629
|
const { visibleColumn } = $table.getTableColumn();
|
|
584
630
|
const cellAreas = $table.getCellAreas();
|
|
585
631
|
if (cellAreas.length === 1) {
|
|
@@ -611,7 +657,7 @@ export const VxeUIPluginMenu = {
|
|
|
611
657
|
const tableProps = $table;
|
|
612
658
|
const { mouseConfig } = tableProps;
|
|
613
659
|
const mouseOpts = $table.computeMouseOpts;
|
|
614
|
-
if (mouseConfig && mouseOpts.area) {
|
|
660
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
615
661
|
const { visibleColumn } = $table.getTableColumn();
|
|
616
662
|
const cellAreas = $table.getCellAreas();
|
|
617
663
|
if (cellAreas.length === 1) {
|
|
@@ -643,7 +689,7 @@ export const VxeUIPluginMenu = {
|
|
|
643
689
|
const tableProps = $table;
|
|
644
690
|
const { mouseConfig } = tableProps;
|
|
645
691
|
const mouseOpts = $table.computeMouseOpts;
|
|
646
|
-
if (mouseConfig && mouseOpts.area) {
|
|
692
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
647
693
|
const { visibleData } = $table.getTableData();
|
|
648
694
|
const cellAreas = $table.getCellAreas();
|
|
649
695
|
if (cellAreas.length === 1) {
|
|
@@ -675,7 +721,7 @@ export const VxeUIPluginMenu = {
|
|
|
675
721
|
const tableProps = $table;
|
|
676
722
|
const { mouseConfig } = tableProps;
|
|
677
723
|
const mouseOpts = $table.computeMouseOpts;
|
|
678
|
-
if (mouseConfig && mouseOpts.area) {
|
|
724
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
679
725
|
const { visibleData } = $table.getTableData();
|
|
680
726
|
const cellAreas = $table.getCellAreas();
|
|
681
727
|
if (cellAreas.length === 1) {
|
|
@@ -708,7 +754,7 @@ export const VxeUIPluginMenu = {
|
|
|
708
754
|
const tableProps = $table;
|
|
709
755
|
const { mouseConfig } = tableProps;
|
|
710
756
|
const mouseOpts = $table.computeMouseOpts;
|
|
711
|
-
if (mouseConfig && mouseOpts.area) {
|
|
757
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
712
758
|
const cellAreas = $table.getCellAreas();
|
|
713
759
|
if (cellAreas && cellAreas.length) {
|
|
714
760
|
cellAreas.forEach(areaItem => {
|
|
@@ -782,6 +828,14 @@ export const VxeUIPluginMenu = {
|
|
|
782
828
|
handleCopyOrCut(params);
|
|
783
829
|
}
|
|
784
830
|
},
|
|
831
|
+
/**
|
|
832
|
+
* 复制单元格数据的值;用于 mouse-config.area 功能,复制区域范围内的单元格数据,支持 Excel 和 WPS
|
|
833
|
+
*/
|
|
834
|
+
COPY_AREA_CELL: {
|
|
835
|
+
tableMenuMethod(params) {
|
|
836
|
+
handleCopyOrCut(params);
|
|
837
|
+
}
|
|
838
|
+
},
|
|
785
839
|
/**
|
|
786
840
|
* 剪贴单元格数据的值;如果启用 mouse-config.area 功能,则剪贴区域范围内的单元格数据,支持 Excel 和 WPS
|
|
787
841
|
*/
|
|
@@ -790,6 +844,14 @@ export const VxeUIPluginMenu = {
|
|
|
790
844
|
handleCopyOrCut(params, true);
|
|
791
845
|
}
|
|
792
846
|
},
|
|
847
|
+
/**
|
|
848
|
+
* 剪贴单元格数据的值;用于 mouse-config.area 功能,剪贴区域范围内的单元格数据,支持 Excel 和 WPS
|
|
849
|
+
*/
|
|
850
|
+
CUT_AREA_CELL: {
|
|
851
|
+
tableMenuMethod(params) {
|
|
852
|
+
handleCopyOrCut(params, true);
|
|
853
|
+
}
|
|
854
|
+
},
|
|
793
855
|
/**
|
|
794
856
|
* 粘贴从表格中被复制的数据;如果启用 mouse-config.area 功能,则粘贴区域范围内的单元格数据,不支持读取剪贴板
|
|
795
857
|
*/
|
|
@@ -799,7 +861,7 @@ export const VxeUIPluginMenu = {
|
|
|
799
861
|
const tableProps = $table;
|
|
800
862
|
const { mouseConfig } = tableProps;
|
|
801
863
|
const mouseOpts = $table.computeMouseOpts;
|
|
802
|
-
if (mouseConfig && mouseOpts.area) {
|
|
864
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
803
865
|
$table.triggerPasteCellAreaEvent($event);
|
|
804
866
|
}
|
|
805
867
|
else {
|
|
@@ -811,6 +873,20 @@ export const VxeUIPluginMenu = {
|
|
|
811
873
|
}
|
|
812
874
|
}
|
|
813
875
|
},
|
|
876
|
+
/**
|
|
877
|
+
* 粘贴从表格中被复制的数据;用于 mouse-config.area 功能,粘贴区域范围内的单元格数据,不支持读取剪贴板
|
|
878
|
+
*/
|
|
879
|
+
PASTE_AREA_CELL: {
|
|
880
|
+
tableMenuMethod(params) {
|
|
881
|
+
const { $event, $table } = params;
|
|
882
|
+
const tableProps = $table;
|
|
883
|
+
const { mouseConfig } = tableProps;
|
|
884
|
+
const mouseOpts = $table.computeMouseOpts;
|
|
885
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
886
|
+
$table.triggerPasteCellAreaEvent($event);
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
},
|
|
814
890
|
/**
|
|
815
891
|
* 如果启用 mouse-config.area 功能,如果所选区域内已存在合并单元格,则取消临时合并,否则临时合并
|
|
816
892
|
*/
|
|
@@ -931,7 +1007,7 @@ export const VxeUIPluginMenu = {
|
|
|
931
1007
|
const { mouseConfig } = tableProps;
|
|
932
1008
|
const mouseOpts = $table.computeMouseOpts;
|
|
933
1009
|
$table.insert(menu.params || {}).then(({ rows }) => {
|
|
934
|
-
if (column && mouseConfig && mouseOpts.area) {
|
|
1010
|
+
if (column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
935
1011
|
$table.setCellAreas([
|
|
936
1012
|
{ startRow: XEUtils.first(rows), endRow: XEUtils.last(rows), startColumn: column, endColumn: column }
|
|
937
1013
|
]);
|
|
@@ -949,7 +1025,7 @@ export const VxeUIPluginMenu = {
|
|
|
949
1025
|
const { mouseConfig } = tableProps;
|
|
950
1026
|
const mouseOpts = $table.computeMouseOpts;
|
|
951
1027
|
(row ? $table.insertAt(menu.params || {}, row) : $table.insert(menu.params || {})).then(({ rows }) => {
|
|
952
|
-
if (column && mouseConfig && mouseOpts.area) {
|
|
1028
|
+
if (column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
953
1029
|
$table.setCellAreas([
|
|
954
1030
|
{ startRow: XEUtils.first(rows), endRow: XEUtils.last(rows), startColumn: column, endColumn: column }
|
|
955
1031
|
]);
|
|
@@ -970,7 +1046,7 @@ export const VxeUIPluginMenu = {
|
|
|
970
1046
|
if (size) {
|
|
971
1047
|
const records = XEUtils.range(0, size).map(() => Object.assign({}, menu.params));
|
|
972
1048
|
(row ? $table.insertAt(records, row) : $table.insert(records)).then(({ rows }) => {
|
|
973
|
-
if (column && mouseConfig && mouseOpts.area) {
|
|
1049
|
+
if (column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
974
1050
|
$table.setCellAreas([
|
|
975
1051
|
{ startRow: XEUtils.first(rows), endRow: XEUtils.last(rows), startColumn: column, endColumn: column }
|
|
976
1052
|
]);
|
|
@@ -990,7 +1066,7 @@ export const VxeUIPluginMenu = {
|
|
|
990
1066
|
const { mouseConfig } = tableProps;
|
|
991
1067
|
const mouseOpts = $table.computeMouseOpts;
|
|
992
1068
|
(row ? $table.insertNextAt(menu.params || {}, row) : $table.insert(menu.params || {})).then(({ rows }) => {
|
|
993
|
-
if (column && mouseConfig && mouseOpts.area) {
|
|
1069
|
+
if (column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
994
1070
|
$table.setCellAreas([
|
|
995
1071
|
{ startRow: XEUtils.first(rows), endRow: XEUtils.last(rows), startColumn: column, endColumn: column }
|
|
996
1072
|
]);
|
|
@@ -1011,7 +1087,7 @@ export const VxeUIPluginMenu = {
|
|
|
1011
1087
|
if (size) {
|
|
1012
1088
|
const records = XEUtils.range(0, size).map(() => Object.assign({}, menu.params));
|
|
1013
1089
|
(row ? $table.insertNextAt(records, row) : $table.insert(records)).then(({ rows }) => {
|
|
1014
|
-
if (column && mouseConfig && mouseOpts.area) {
|
|
1090
|
+
if (column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
1015
1091
|
$table.setCellAreas([
|
|
1016
1092
|
{ startRow: XEUtils.first(rows), endRow: XEUtils.last(rows), startColumn: column, endColumn: column }
|
|
1017
1093
|
]);
|
|
@@ -1184,8 +1260,8 @@ export const VxeUIPluginMenu = {
|
|
|
1184
1260
|
const tableProps = $table;
|
|
1185
1261
|
const { mouseConfig } = tableProps;
|
|
1186
1262
|
const mouseOpts = $table.computeMouseOpts;
|
|
1187
|
-
if (mouseConfig && mouseOpts.area) {
|
|
1188
|
-
const cellAreas =
|
|
1263
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
1264
|
+
const cellAreas = $table.getCellAreas();
|
|
1189
1265
|
cellAreas.forEach(areaItem => {
|
|
1190
1266
|
const { rows } = areaItem;
|
|
1191
1267
|
$table.remove(rows);
|
package/es/index.js
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import XEUtils from 'xe-utils';
|
|
2
2
|
let VxeUI;
|
|
3
3
|
let handleCopy;
|
|
4
|
+
/**
|
|
5
|
+
* 用于开关类型的配置项
|
|
6
|
+
* 局部启用规则:conf={}
|
|
7
|
+
* 局部禁用规则:conf={enabled:false}
|
|
8
|
+
* 全局默认启用规则:conf.enabled=true
|
|
9
|
+
*/
|
|
10
|
+
export function hasEnableConf(conf, opts) {
|
|
11
|
+
return opts && (conf ? opts.enabled !== false : opts.enabled);
|
|
12
|
+
}
|
|
4
13
|
const columnIndexOf = (cols, column) => {
|
|
5
14
|
return XEUtils.findIndexOf(cols, item => item.id === column.id);
|
|
6
15
|
};
|
|
@@ -75,7 +84,7 @@ function handleCopyOrCut(params, isCut) {
|
|
|
75
84
|
const { mouseConfig } = props;
|
|
76
85
|
const mouseOpts = $table.computeMouseOpts;
|
|
77
86
|
let text = '';
|
|
78
|
-
if (mouseConfig && mouseOpts.area) {
|
|
87
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
79
88
|
if (isCut) {
|
|
80
89
|
$table.triggerCutCellAreaEvent($event);
|
|
81
90
|
}
|
|
@@ -138,7 +147,7 @@ function getBeenMerges(params) {
|
|
|
138
147
|
const mouseOpts = $table.computeMouseOpts;
|
|
139
148
|
const { visibleData } = $table.getTableData();
|
|
140
149
|
const { visibleColumn } = $table.getTableColumn();
|
|
141
|
-
const cellAreas = mouseConfig && mouseOpts.area ? $table.getCellAreas() : [];
|
|
150
|
+
const cellAreas = hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area ? $table.getCellAreas() : [];
|
|
142
151
|
const mergeList = $table.getMergeCells();
|
|
143
152
|
return mergeList.filter(({ row: mergeRowIndex, col: mergeColIndex, rowspan: mergeRowspan, colspan: mergeColspan }) => {
|
|
144
153
|
return cellAreas.some(areaItem => {
|
|
@@ -210,10 +219,14 @@ function checkPrivilege(item, params) {
|
|
|
210
219
|
}
|
|
211
220
|
case 'EDIT_CELL':
|
|
212
221
|
case 'CLEAR_CELL':
|
|
222
|
+
case 'CLEAR_AREA_CELL':
|
|
213
223
|
case 'CLEAR_ROW':
|
|
214
224
|
case 'COPY_CELL':
|
|
225
|
+
case 'COPY_AREA_CELL':
|
|
215
226
|
case 'CUT_CELL':
|
|
227
|
+
case 'CUT_AREA_CELL':
|
|
216
228
|
case 'PASTE_CELL':
|
|
229
|
+
case 'PASTE_AREA_CELL':
|
|
217
230
|
case 'MERGE_OR_CLEAR':
|
|
218
231
|
case 'MERGE_CELL':
|
|
219
232
|
case 'REVERT_CELL':
|
|
@@ -266,7 +279,7 @@ function checkPrivilege(item, params) {
|
|
|
266
279
|
}
|
|
267
280
|
case 'OPEN_FIND':
|
|
268
281
|
case 'OPEN_REPLACE': {
|
|
269
|
-
item.disabled = !(mouseConfig && mouseOpts.area);
|
|
282
|
+
item.disabled = !(hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area);
|
|
270
283
|
break;
|
|
271
284
|
}
|
|
272
285
|
case 'EDIT_CELL': {
|
|
@@ -274,13 +287,17 @@ function checkPrivilege(item, params) {
|
|
|
274
287
|
break;
|
|
275
288
|
}
|
|
276
289
|
case 'COPY_CELL':
|
|
290
|
+
case 'COPY_AREA_CELL':
|
|
277
291
|
case 'CUT_CELL':
|
|
278
|
-
case '
|
|
279
|
-
|
|
292
|
+
case 'CUT_AREA_CELL':
|
|
293
|
+
case 'PASTE_CELL':
|
|
294
|
+
case 'PASTE_AREA_CELL': {
|
|
295
|
+
const cellAreas = hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area ? $table.getCellAreas() : [];
|
|
280
296
|
item.disabled = cellAreas.length > 1;
|
|
281
297
|
if (!item.disabled) {
|
|
282
298
|
switch (code) {
|
|
283
|
-
case 'PASTE_CELL':
|
|
299
|
+
case 'PASTE_CELL':
|
|
300
|
+
case 'PASTE_AREA_CELL': {
|
|
284
301
|
const clipboard = getClipboardObj();
|
|
285
302
|
item.disabled = !clipboard || !clipboard.text;
|
|
286
303
|
break;
|
|
@@ -291,7 +308,7 @@ function checkPrivilege(item, params) {
|
|
|
291
308
|
}
|
|
292
309
|
case 'MERGE_OR_CLEAR':
|
|
293
310
|
case 'MERGE_CELL': {
|
|
294
|
-
const cellAreas = mouseConfig && mouseOpts.area ? $table.getCellAreas() : [];
|
|
311
|
+
const cellAreas = hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area ? $table.getCellAreas() : [];
|
|
295
312
|
item.disabled = !cellAreas.length || (cellAreas.length === 1 && cellAreas[0].rows.length === 1 && cellAreas[0].cols.length === 1) || !checkCellOverlay(params, cellAreas);
|
|
296
313
|
break;
|
|
297
314
|
}
|
|
@@ -424,12 +441,12 @@ export const VxeUIPluginMenu = {
|
|
|
424
441
|
const pVersion = 3;
|
|
425
442
|
const sVersion = 13;
|
|
426
443
|
if (!VxeUI.checkVersion(VxeUI.tableVersion, pVersion, sVersion)) {
|
|
427
|
-
console.error(`[@vxe-ui/plugin-menu 3.
|
|
444
|
+
console.error(`[@vxe-ui/plugin-menu 3.4.0] ${VxeUI.getI18n('vxe.error.errorVersion', [`vxe-table@${VxeUI.tableVersion || '?'}`, `vxe-table v${pVersion}.${sVersion}+`])}`);
|
|
428
445
|
}
|
|
429
446
|
}
|
|
430
447
|
else {
|
|
431
448
|
if (!/^(3)\./.test(VxeUI.uiVersion || VxeUI.tableVersion)) {
|
|
432
|
-
console.error('[@vxe-ui/plugin-menu 3.
|
|
449
|
+
console.error('[@vxe-ui/plugin-menu 3.4.0] Requires vxe-table 3.9.0+ version. https://vxeui.com/other3/#/plugin-menu/install');
|
|
433
450
|
}
|
|
434
451
|
}
|
|
435
452
|
pluginConfig(options);
|
|
@@ -474,7 +491,36 @@ export const VxeUIPluginMenu = {
|
|
|
474
491
|
const tableProps = $table;
|
|
475
492
|
const { mouseConfig } = tableProps;
|
|
476
493
|
const mouseOpts = $table.computeMouseOpts;
|
|
477
|
-
if (mouseConfig && mouseOpts.area) {
|
|
494
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
495
|
+
const cellAreas = $table.getCellAreas();
|
|
496
|
+
if (cellAreas && cellAreas.length) {
|
|
497
|
+
cellAreas.forEach(areaItem => {
|
|
498
|
+
const { rows, cols } = areaItem;
|
|
499
|
+
cols.forEach(column => {
|
|
500
|
+
rows.forEach(row => {
|
|
501
|
+
$table.clearData(row, column.field);
|
|
502
|
+
});
|
|
503
|
+
});
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
else {
|
|
508
|
+
$table.clearData(row, column.field);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
},
|
|
513
|
+
/**
|
|
514
|
+
* 清除单元格数据的值;如果启用 mouse-config.area 功能,则清除区域范围内的单元格数据
|
|
515
|
+
*/
|
|
516
|
+
CLEAR_AREA_CELL: {
|
|
517
|
+
tableMenuMethod(params) {
|
|
518
|
+
const { $table, row, column } = params;
|
|
519
|
+
if (row && column) {
|
|
520
|
+
const tableProps = $table;
|
|
521
|
+
const { mouseConfig } = tableProps;
|
|
522
|
+
const mouseOpts = $table.computeMouseOpts;
|
|
523
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
478
524
|
const cellAreas = $table.getCellAreas();
|
|
479
525
|
if (cellAreas && cellAreas.length) {
|
|
480
526
|
cellAreas.forEach(areaItem => {
|
|
@@ -522,8 +568,8 @@ export const VxeUIPluginMenu = {
|
|
|
522
568
|
const tableProps = $table;
|
|
523
569
|
const { mouseConfig } = tableProps;
|
|
524
570
|
const mouseOpts = $table.computeMouseOpts;
|
|
525
|
-
if (mouseConfig && mouseOpts.area) {
|
|
526
|
-
const cellAreas =
|
|
571
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
572
|
+
const cellAreas = mouseOpts.area ? $table.getCellAreas() : [];
|
|
527
573
|
cellAreas.forEach(areaItem => {
|
|
528
574
|
const { rows, cols } = areaItem;
|
|
529
575
|
rows.forEach(row => {
|
|
@@ -558,7 +604,7 @@ export const VxeUIPluginMenu = {
|
|
|
558
604
|
const tableProps = $table;
|
|
559
605
|
const { mouseConfig } = tableProps;
|
|
560
606
|
const mouseOpts = $table.computeMouseOpts;
|
|
561
|
-
if (mouseConfig && mouseOpts.area) {
|
|
607
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
562
608
|
const { visibleData } = $table.getTableData();
|
|
563
609
|
const { visibleColumn } = $table.getTableColumn();
|
|
564
610
|
$table.setCellAreas([{
|
|
@@ -579,7 +625,7 @@ export const VxeUIPluginMenu = {
|
|
|
579
625
|
const tableProps = $table;
|
|
580
626
|
const { mouseConfig } = tableProps;
|
|
581
627
|
const mouseOpts = $table.computeMouseOpts;
|
|
582
|
-
if (mouseConfig && mouseOpts.area) {
|
|
628
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
583
629
|
const { visibleColumn } = $table.getTableColumn();
|
|
584
630
|
const cellAreas = $table.getCellAreas();
|
|
585
631
|
if (cellAreas.length === 1) {
|
|
@@ -611,7 +657,7 @@ export const VxeUIPluginMenu = {
|
|
|
611
657
|
const tableProps = $table;
|
|
612
658
|
const { mouseConfig } = tableProps;
|
|
613
659
|
const mouseOpts = $table.computeMouseOpts;
|
|
614
|
-
if (mouseConfig && mouseOpts.area) {
|
|
660
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
615
661
|
const { visibleColumn } = $table.getTableColumn();
|
|
616
662
|
const cellAreas = $table.getCellAreas();
|
|
617
663
|
if (cellAreas.length === 1) {
|
|
@@ -643,7 +689,7 @@ export const VxeUIPluginMenu = {
|
|
|
643
689
|
const tableProps = $table;
|
|
644
690
|
const { mouseConfig } = tableProps;
|
|
645
691
|
const mouseOpts = $table.computeMouseOpts;
|
|
646
|
-
if (mouseConfig && mouseOpts.area) {
|
|
692
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
647
693
|
const { visibleData } = $table.getTableData();
|
|
648
694
|
const cellAreas = $table.getCellAreas();
|
|
649
695
|
if (cellAreas.length === 1) {
|
|
@@ -675,7 +721,7 @@ export const VxeUIPluginMenu = {
|
|
|
675
721
|
const tableProps = $table;
|
|
676
722
|
const { mouseConfig } = tableProps;
|
|
677
723
|
const mouseOpts = $table.computeMouseOpts;
|
|
678
|
-
if (mouseConfig && mouseOpts.area) {
|
|
724
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
679
725
|
const { visibleData } = $table.getTableData();
|
|
680
726
|
const cellAreas = $table.getCellAreas();
|
|
681
727
|
if (cellAreas.length === 1) {
|
|
@@ -708,7 +754,7 @@ export const VxeUIPluginMenu = {
|
|
|
708
754
|
const tableProps = $table;
|
|
709
755
|
const { mouseConfig } = tableProps;
|
|
710
756
|
const mouseOpts = $table.computeMouseOpts;
|
|
711
|
-
if (mouseConfig && mouseOpts.area) {
|
|
757
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
712
758
|
const cellAreas = $table.getCellAreas();
|
|
713
759
|
if (cellAreas && cellAreas.length) {
|
|
714
760
|
cellAreas.forEach(areaItem => {
|
|
@@ -782,6 +828,14 @@ export const VxeUIPluginMenu = {
|
|
|
782
828
|
handleCopyOrCut(params);
|
|
783
829
|
}
|
|
784
830
|
},
|
|
831
|
+
/**
|
|
832
|
+
* 复制单元格数据的值;用于 mouse-config.area 功能,复制区域范围内的单元格数据,支持 Excel 和 WPS
|
|
833
|
+
*/
|
|
834
|
+
COPY_AREA_CELL: {
|
|
835
|
+
tableMenuMethod(params) {
|
|
836
|
+
handleCopyOrCut(params);
|
|
837
|
+
}
|
|
838
|
+
},
|
|
785
839
|
/**
|
|
786
840
|
* 剪贴单元格数据的值;如果启用 mouse-config.area 功能,则剪贴区域范围内的单元格数据,支持 Excel 和 WPS
|
|
787
841
|
*/
|
|
@@ -790,6 +844,14 @@ export const VxeUIPluginMenu = {
|
|
|
790
844
|
handleCopyOrCut(params, true);
|
|
791
845
|
}
|
|
792
846
|
},
|
|
847
|
+
/**
|
|
848
|
+
* 剪贴单元格数据的值;用于 mouse-config.area 功能,剪贴区域范围内的单元格数据,支持 Excel 和 WPS
|
|
849
|
+
*/
|
|
850
|
+
CUT_AREA_CELL: {
|
|
851
|
+
tableMenuMethod(params) {
|
|
852
|
+
handleCopyOrCut(params, true);
|
|
853
|
+
}
|
|
854
|
+
},
|
|
793
855
|
/**
|
|
794
856
|
* 粘贴从表格中被复制的数据;如果启用 mouse-config.area 功能,则粘贴区域范围内的单元格数据,不支持读取剪贴板
|
|
795
857
|
*/
|
|
@@ -799,7 +861,7 @@ export const VxeUIPluginMenu = {
|
|
|
799
861
|
const tableProps = $table;
|
|
800
862
|
const { mouseConfig } = tableProps;
|
|
801
863
|
const mouseOpts = $table.computeMouseOpts;
|
|
802
|
-
if (mouseConfig && mouseOpts.area) {
|
|
864
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
803
865
|
$table.triggerPasteCellAreaEvent($event);
|
|
804
866
|
}
|
|
805
867
|
else {
|
|
@@ -811,6 +873,20 @@ export const VxeUIPluginMenu = {
|
|
|
811
873
|
}
|
|
812
874
|
}
|
|
813
875
|
},
|
|
876
|
+
/**
|
|
877
|
+
* 粘贴从表格中被复制的数据;用于 mouse-config.area 功能,粘贴区域范围内的单元格数据,不支持读取剪贴板
|
|
878
|
+
*/
|
|
879
|
+
PASTE_AREA_CELL: {
|
|
880
|
+
tableMenuMethod(params) {
|
|
881
|
+
const { $event, $table } = params;
|
|
882
|
+
const tableProps = $table;
|
|
883
|
+
const { mouseConfig } = tableProps;
|
|
884
|
+
const mouseOpts = $table.computeMouseOpts;
|
|
885
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
886
|
+
$table.triggerPasteCellAreaEvent($event);
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
},
|
|
814
890
|
/**
|
|
815
891
|
* 如果启用 mouse-config.area 功能,如果所选区域内已存在合并单元格,则取消临时合并,否则临时合并
|
|
816
892
|
*/
|
|
@@ -931,7 +1007,7 @@ export const VxeUIPluginMenu = {
|
|
|
931
1007
|
const { mouseConfig } = tableProps;
|
|
932
1008
|
const mouseOpts = $table.computeMouseOpts;
|
|
933
1009
|
$table.insert(menu.params || {}).then(({ rows }) => {
|
|
934
|
-
if (column && mouseConfig && mouseOpts.area) {
|
|
1010
|
+
if (column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
935
1011
|
$table.setCellAreas([
|
|
936
1012
|
{ startRow: XEUtils.first(rows), endRow: XEUtils.last(rows), startColumn: column, endColumn: column }
|
|
937
1013
|
]);
|
|
@@ -949,7 +1025,7 @@ export const VxeUIPluginMenu = {
|
|
|
949
1025
|
const { mouseConfig } = tableProps;
|
|
950
1026
|
const mouseOpts = $table.computeMouseOpts;
|
|
951
1027
|
(row ? $table.insertAt(menu.params || {}, row) : $table.insert(menu.params || {})).then(({ rows }) => {
|
|
952
|
-
if (column && mouseConfig && mouseOpts.area) {
|
|
1028
|
+
if (column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
953
1029
|
$table.setCellAreas([
|
|
954
1030
|
{ startRow: XEUtils.first(rows), endRow: XEUtils.last(rows), startColumn: column, endColumn: column }
|
|
955
1031
|
]);
|
|
@@ -970,7 +1046,7 @@ export const VxeUIPluginMenu = {
|
|
|
970
1046
|
if (size) {
|
|
971
1047
|
const records = XEUtils.range(0, size).map(() => Object.assign({}, menu.params));
|
|
972
1048
|
(row ? $table.insertAt(records, row) : $table.insert(records)).then(({ rows }) => {
|
|
973
|
-
if (column && mouseConfig && mouseOpts.area) {
|
|
1049
|
+
if (column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
974
1050
|
$table.setCellAreas([
|
|
975
1051
|
{ startRow: XEUtils.first(rows), endRow: XEUtils.last(rows), startColumn: column, endColumn: column }
|
|
976
1052
|
]);
|
|
@@ -990,7 +1066,7 @@ export const VxeUIPluginMenu = {
|
|
|
990
1066
|
const { mouseConfig } = tableProps;
|
|
991
1067
|
const mouseOpts = $table.computeMouseOpts;
|
|
992
1068
|
(row ? $table.insertNextAt(menu.params || {}, row) : $table.insert(menu.params || {})).then(({ rows }) => {
|
|
993
|
-
if (column && mouseConfig && mouseOpts.area) {
|
|
1069
|
+
if (column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
994
1070
|
$table.setCellAreas([
|
|
995
1071
|
{ startRow: XEUtils.first(rows), endRow: XEUtils.last(rows), startColumn: column, endColumn: column }
|
|
996
1072
|
]);
|
|
@@ -1011,7 +1087,7 @@ export const VxeUIPluginMenu = {
|
|
|
1011
1087
|
if (size) {
|
|
1012
1088
|
const records = XEUtils.range(0, size).map(() => Object.assign({}, menu.params));
|
|
1013
1089
|
(row ? $table.insertNextAt(records, row) : $table.insert(records)).then(({ rows }) => {
|
|
1014
|
-
if (column && mouseConfig && mouseOpts.area) {
|
|
1090
|
+
if (column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
1015
1091
|
$table.setCellAreas([
|
|
1016
1092
|
{ startRow: XEUtils.first(rows), endRow: XEUtils.last(rows), startColumn: column, endColumn: column }
|
|
1017
1093
|
]);
|
|
@@ -1184,8 +1260,8 @@ export const VxeUIPluginMenu = {
|
|
|
1184
1260
|
const tableProps = $table;
|
|
1185
1261
|
const { mouseConfig } = tableProps;
|
|
1186
1262
|
const mouseOpts = $table.computeMouseOpts;
|
|
1187
|
-
if (mouseConfig && mouseOpts.area) {
|
|
1188
|
-
const cellAreas =
|
|
1263
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
1264
|
+
const cellAreas = $table.getCellAreas();
|
|
1189
1265
|
cellAreas.forEach(areaItem => {
|
|
1190
1266
|
const { rows } = areaItem;
|
|
1191
1267
|
$table.remove(rows);
|