@vxe-ui/plugin-menu 4.3.2 → 4.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 +134 -52
- package/dist/index.umd.min.js +1 -1
- package/es/index.esm.js +101 -26
- package/es/index.js +101 -26
- package/lib/index.common.js +134 -52
- package/lib/index.js +134 -52
- package/lib/index.umd.js +134 -52
- package/lib/index.umd.min.js +1 -1
- package/package.json +17 -18
- package/src/index.ts +100 -24
package/es/index.esm.js
CHANGED
|
@@ -2,6 +2,15 @@ import XEUtils from 'xe-utils';
|
|
|
2
2
|
import { ref, h } from 'vue';
|
|
3
3
|
let VxeUI;
|
|
4
4
|
let handleCopy;
|
|
5
|
+
/**
|
|
6
|
+
* 用于开关类型的配置项
|
|
7
|
+
* 局部启用规则:conf={}
|
|
8
|
+
* 局部禁用规则:conf={enabled:false}
|
|
9
|
+
* 全局默认启用规则:conf.enabled=true
|
|
10
|
+
*/
|
|
11
|
+
export function hasEnableConf(conf, opts) {
|
|
12
|
+
return opts && (conf ? opts.enabled !== false : opts.enabled);
|
|
13
|
+
}
|
|
5
14
|
const columnIndexOf = (cols, column) => {
|
|
6
15
|
return XEUtils.findIndexOf(cols, item => item.id === column.id);
|
|
7
16
|
};
|
|
@@ -76,8 +85,8 @@ function handleCopyOrCut(params, isCut) {
|
|
|
76
85
|
const { mouseConfig } = tableProps;
|
|
77
86
|
const { computeMouseOpts } = $table.getComputeMaps();
|
|
78
87
|
const mouseOpts = computeMouseOpts.value;
|
|
79
|
-
let text
|
|
80
|
-
if (mouseConfig && mouseOpts.area) {
|
|
88
|
+
let text;
|
|
89
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
81
90
|
if (isCut) {
|
|
82
91
|
$table.triggerCutCellAreaEvent($event);
|
|
83
92
|
}
|
|
@@ -141,7 +150,7 @@ function getBeenMerges(params) {
|
|
|
141
150
|
const mouseOpts = computeMouseOpts.value;
|
|
142
151
|
const { visibleData } = $table.getTableData();
|
|
143
152
|
const { visibleColumn } = $table.getTableColumn();
|
|
144
|
-
const cellAreas = mouseConfig && mouseOpts.area ? $table.getCellAreas() : [];
|
|
153
|
+
const cellAreas = hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area ? $table.getCellAreas() : [];
|
|
145
154
|
const mergeList = $table.getMergeCells();
|
|
146
155
|
return mergeList.filter(({ row: mergeRowIndex, col: mergeColIndex, rowspan: mergeRowspan, colspan: mergeColspan }) => {
|
|
147
156
|
return cellAreas.some(areaItem => {
|
|
@@ -213,10 +222,14 @@ function checkPrivilege(item, params) {
|
|
|
213
222
|
}
|
|
214
223
|
case 'EDIT_CELL':
|
|
215
224
|
case 'CLEAR_CELL':
|
|
225
|
+
case 'CLEAR_AREA_CELL':
|
|
216
226
|
case 'CLEAR_ROW':
|
|
217
227
|
case 'COPY_CELL':
|
|
228
|
+
case 'COPY_AREA_CELL':
|
|
218
229
|
case 'CUT_CELL':
|
|
230
|
+
case 'CUT_AREA_CELL':
|
|
219
231
|
case 'PASTE_CELL':
|
|
232
|
+
case 'PASTE_AREA_CELL':
|
|
220
233
|
case 'MERGE_OR_CLEAR':
|
|
221
234
|
case 'MERGE_CELL':
|
|
222
235
|
case 'REVERT_CELL':
|
|
@@ -270,7 +283,7 @@ function checkPrivilege(item, params) {
|
|
|
270
283
|
}
|
|
271
284
|
case 'OPEN_FIND':
|
|
272
285
|
case 'OPEN_REPLACE': {
|
|
273
|
-
item.disabled = !(mouseConfig && mouseOpts.area);
|
|
286
|
+
item.disabled = !(hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area);
|
|
274
287
|
break;
|
|
275
288
|
}
|
|
276
289
|
case 'EDIT_CELL': {
|
|
@@ -278,13 +291,17 @@ function checkPrivilege(item, params) {
|
|
|
278
291
|
break;
|
|
279
292
|
}
|
|
280
293
|
case 'COPY_CELL':
|
|
294
|
+
case 'COPY_AREA_CELL':
|
|
281
295
|
case 'CUT_CELL':
|
|
282
|
-
case '
|
|
283
|
-
|
|
296
|
+
case 'CUT_AREA_CELL':
|
|
297
|
+
case 'PASTE_CELL':
|
|
298
|
+
case 'PASTE_AREA_CELL': {
|
|
299
|
+
const cellAreas = hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area ? $table.getCellAreas() : [];
|
|
284
300
|
item.disabled = cellAreas.length > 1;
|
|
285
301
|
if (!item.disabled) {
|
|
286
302
|
switch (code) {
|
|
287
|
-
case 'PASTE_CELL':
|
|
303
|
+
case 'PASTE_CELL':
|
|
304
|
+
case 'PASTE_AREA_CELL': {
|
|
288
305
|
const clipboard = getClipboardObj();
|
|
289
306
|
item.disabled = !clipboard || !clipboard.text;
|
|
290
307
|
break;
|
|
@@ -295,7 +312,7 @@ function checkPrivilege(item, params) {
|
|
|
295
312
|
}
|
|
296
313
|
case 'MERGE_OR_CLEAR':
|
|
297
314
|
case 'MERGE_CELL': {
|
|
298
|
-
const cellAreas = mouseConfig && mouseOpts.area ? $table.getCellAreas() : [];
|
|
315
|
+
const cellAreas = hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area ? $table.getCellAreas() : [];
|
|
299
316
|
item.disabled = !cellAreas.length || (cellAreas.length === 1 && cellAreas[0].rows.length === 1 && cellAreas[0].cols.length === 1) || !checkCellOverlay(params, cellAreas);
|
|
300
317
|
break;
|
|
301
318
|
}
|
|
@@ -427,12 +444,12 @@ export const VxeUIPluginMenu = {
|
|
|
427
444
|
const pVersion = 4;
|
|
428
445
|
const sVersion = 11;
|
|
429
446
|
if (!VxeUI.checkVersion(VxeUI.tableVersion, pVersion, sVersion)) {
|
|
430
|
-
console.error(`[@vxe-ui/plugin-menu 4.
|
|
447
|
+
console.error(`[@vxe-ui/plugin-menu 4.4.0] ${VxeUI.getI18n('vxe.error.errorVersion', [`vxe-table@${VxeUI.tableVersion || '?'}`, `vxe-table v${pVersion}.${sVersion}+`])} https://vxeui.com/other4/#/plugin-menu/install`);
|
|
431
448
|
}
|
|
432
449
|
}
|
|
433
450
|
else {
|
|
434
451
|
if (!/^(4)\./.test(VxeUI.uiVersion || VxeUI.tableVersion)) {
|
|
435
|
-
console.error('[@vxe-ui/plugin-menu 4.
|
|
452
|
+
console.error('[@vxe-ui/plugin-menu 4.4.0] Requires vxe-table 4.7.0+ version. https://vxeui.com/other4/#/plugin-menu/install');
|
|
436
453
|
}
|
|
437
454
|
}
|
|
438
455
|
pluginSetup(options);
|
|
@@ -478,7 +495,7 @@ export const VxeUIPluginMenu = {
|
|
|
478
495
|
const { mouseConfig } = tableProps;
|
|
479
496
|
const { computeMouseOpts } = $table.getComputeMaps();
|
|
480
497
|
const mouseOpts = computeMouseOpts.value;
|
|
481
|
-
if (mouseConfig && mouseOpts.area) {
|
|
498
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
482
499
|
const cellAreas = $table.getCellAreas();
|
|
483
500
|
if (cellAreas && cellAreas.length) {
|
|
484
501
|
cellAreas.forEach(areaItem => {
|
|
@@ -497,6 +514,33 @@ export const VxeUIPluginMenu = {
|
|
|
497
514
|
}
|
|
498
515
|
}
|
|
499
516
|
},
|
|
517
|
+
/**
|
|
518
|
+
* 用于 mouse-config.area 功能,清除区域范围内的单元格数据
|
|
519
|
+
*/
|
|
520
|
+
CLEAR_AREA_CELL: {
|
|
521
|
+
tableMenuMethod(params) {
|
|
522
|
+
const { $table, row, column } = params;
|
|
523
|
+
if (row && column) {
|
|
524
|
+
const tableProps = $table.props;
|
|
525
|
+
const { mouseConfig } = tableProps;
|
|
526
|
+
const { computeMouseOpts } = $table.getComputeMaps();
|
|
527
|
+
const mouseOpts = computeMouseOpts.value;
|
|
528
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
529
|
+
const cellAreas = $table.getCellAreas();
|
|
530
|
+
if (cellAreas && cellAreas.length) {
|
|
531
|
+
cellAreas.forEach(areaItem => {
|
|
532
|
+
const { rows, cols } = areaItem;
|
|
533
|
+
cols.forEach(column => {
|
|
534
|
+
rows.forEach(row => {
|
|
535
|
+
$table.clearData(row, column.field);
|
|
536
|
+
});
|
|
537
|
+
});
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
},
|
|
500
544
|
/**
|
|
501
545
|
* 清除行数据的值
|
|
502
546
|
*/
|
|
@@ -527,8 +571,8 @@ export const VxeUIPluginMenu = {
|
|
|
527
571
|
const { mouseConfig } = tableProps;
|
|
528
572
|
const { computeMouseOpts } = $table.getComputeMaps();
|
|
529
573
|
const mouseOpts = computeMouseOpts.value;
|
|
530
|
-
if (mouseConfig && mouseOpts.area) {
|
|
531
|
-
const cellAreas =
|
|
574
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
575
|
+
const cellAreas = mouseOpts.area ? $table.getCellAreas() : [];
|
|
532
576
|
cellAreas.forEach(areaItem => {
|
|
533
577
|
const { rows } = areaItem;
|
|
534
578
|
$table.clearData(rows);
|
|
@@ -560,7 +604,7 @@ export const VxeUIPluginMenu = {
|
|
|
560
604
|
const { mouseConfig } = tableProps;
|
|
561
605
|
const { computeMouseOpts } = $table.getComputeMaps();
|
|
562
606
|
const mouseOpts = computeMouseOpts.value;
|
|
563
|
-
if (mouseConfig && mouseOpts.area) {
|
|
607
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
564
608
|
const { visibleData } = $table.getTableData();
|
|
565
609
|
const { visibleColumn } = $table.getTableColumn();
|
|
566
610
|
$table.setCellAreas([{
|
|
@@ -582,7 +626,7 @@ export const VxeUIPluginMenu = {
|
|
|
582
626
|
const { mouseConfig } = tableProps;
|
|
583
627
|
const { computeMouseOpts } = $table.getComputeMaps();
|
|
584
628
|
const mouseOpts = computeMouseOpts.value;
|
|
585
|
-
if (row && column && mouseConfig && mouseOpts.area) {
|
|
629
|
+
if (row && column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
586
630
|
const { visibleColumn } = $table.getTableColumn();
|
|
587
631
|
const cellAreas = $table.getCellAreas();
|
|
588
632
|
if (cellAreas.length === 1) {
|
|
@@ -615,7 +659,7 @@ export const VxeUIPluginMenu = {
|
|
|
615
659
|
const { mouseConfig } = tableProps;
|
|
616
660
|
const { computeMouseOpts } = $table.getComputeMaps();
|
|
617
661
|
const mouseOpts = computeMouseOpts.value;
|
|
618
|
-
if (row && column && mouseConfig && mouseOpts.area) {
|
|
662
|
+
if (row && column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
619
663
|
const { visibleColumn } = $table.getTableColumn();
|
|
620
664
|
const cellAreas = $table.getCellAreas();
|
|
621
665
|
if (cellAreas.length === 1) {
|
|
@@ -648,7 +692,7 @@ export const VxeUIPluginMenu = {
|
|
|
648
692
|
const { mouseConfig } = tableProps;
|
|
649
693
|
const { computeMouseOpts } = $table.getComputeMaps();
|
|
650
694
|
const mouseOpts = computeMouseOpts.value;
|
|
651
|
-
if (row && column && mouseConfig && mouseOpts.area) {
|
|
695
|
+
if (row && column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
652
696
|
const { visibleData } = $table.getTableData();
|
|
653
697
|
const cellAreas = $table.getCellAreas();
|
|
654
698
|
if (cellAreas.length === 1) {
|
|
@@ -681,7 +725,7 @@ export const VxeUIPluginMenu = {
|
|
|
681
725
|
const { mouseConfig } = tableProps;
|
|
682
726
|
const { computeMouseOpts } = $table.getComputeMaps();
|
|
683
727
|
const mouseOpts = computeMouseOpts.value;
|
|
684
|
-
if (row && column && mouseConfig && mouseOpts.area) {
|
|
728
|
+
if (row && column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
685
729
|
const { visibleData } = $table.getTableData();
|
|
686
730
|
const cellAreas = $table.getCellAreas();
|
|
687
731
|
if (cellAreas.length === 1) {
|
|
@@ -715,7 +759,7 @@ export const VxeUIPluginMenu = {
|
|
|
715
759
|
const { mouseConfig } = tableProps;
|
|
716
760
|
const { computeMouseOpts } = $table.getComputeMaps();
|
|
717
761
|
const mouseOpts = computeMouseOpts.value;
|
|
718
|
-
if (mouseConfig && mouseOpts.area) {
|
|
762
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
719
763
|
const cellAreas = $table.getCellAreas();
|
|
720
764
|
if (cellAreas && cellAreas.length) {
|
|
721
765
|
cellAreas.forEach(areaItem => {
|
|
@@ -789,6 +833,14 @@ export const VxeUIPluginMenu = {
|
|
|
789
833
|
handleCopyOrCut(params);
|
|
790
834
|
}
|
|
791
835
|
},
|
|
836
|
+
/**
|
|
837
|
+
* 复制单元格数据的值;用于 mouse-config.area 功能,复制区域范围内的单元格数据,支持 Excel 和 WPS
|
|
838
|
+
*/
|
|
839
|
+
COPY_AREA_CELL: {
|
|
840
|
+
tableMenuMethod(params) {
|
|
841
|
+
handleCopyOrCut(params);
|
|
842
|
+
}
|
|
843
|
+
},
|
|
792
844
|
/**
|
|
793
845
|
* 剪贴单元格数据的值;如果启用 mouse-config.area 功能,则剪贴区域范围内的单元格数据,支持 Excel 和 WPS
|
|
794
846
|
*/
|
|
@@ -797,6 +849,14 @@ export const VxeUIPluginMenu = {
|
|
|
797
849
|
handleCopyOrCut(params, true);
|
|
798
850
|
}
|
|
799
851
|
},
|
|
852
|
+
/**
|
|
853
|
+
* 剪贴单元格数据的值;用于 mouse-config.area 功能,剪贴区域范围内的单元格数据,支持 Excel 和 WPS
|
|
854
|
+
*/
|
|
855
|
+
CUT_AREA_CELL: {
|
|
856
|
+
tableMenuMethod(params) {
|
|
857
|
+
handleCopyOrCut(params, true);
|
|
858
|
+
}
|
|
859
|
+
},
|
|
800
860
|
/**
|
|
801
861
|
* 粘贴从表格中被复制的数据;如果启用 mouse-config.area 功能,则粘贴区域范围内的单元格数据,不支持读取剪贴板
|
|
802
862
|
*/
|
|
@@ -807,7 +867,7 @@ export const VxeUIPluginMenu = {
|
|
|
807
867
|
const { mouseConfig } = tableProps;
|
|
808
868
|
const { computeMouseOpts } = $table.getComputeMaps();
|
|
809
869
|
const mouseOpts = computeMouseOpts.value;
|
|
810
|
-
if (mouseConfig && mouseOpts.area) {
|
|
870
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
811
871
|
$table.triggerPasteCellAreaEvent($event);
|
|
812
872
|
}
|
|
813
873
|
else {
|
|
@@ -819,6 +879,21 @@ export const VxeUIPluginMenu = {
|
|
|
819
879
|
}
|
|
820
880
|
}
|
|
821
881
|
},
|
|
882
|
+
/**
|
|
883
|
+
* 粘贴从表格中被复制的数据;用于 mouse-config.area 功能,粘贴区域范围内的单元格数据,不支持读取剪贴板
|
|
884
|
+
*/
|
|
885
|
+
PASTE_AREA_CELL: {
|
|
886
|
+
tableMenuMethod(params) {
|
|
887
|
+
const { $event, $table } = params;
|
|
888
|
+
const tableProps = $table.props;
|
|
889
|
+
const { mouseConfig } = tableProps;
|
|
890
|
+
const { computeMouseOpts } = $table.getComputeMaps();
|
|
891
|
+
const mouseOpts = computeMouseOpts.value;
|
|
892
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
893
|
+
$table.triggerPasteCellAreaEvent($event);
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
},
|
|
822
897
|
/**
|
|
823
898
|
* 如果启用 mouse-config.area 功能,如果所选区域内已存在合并单元格,则取消临时合并,否则临时合并
|
|
824
899
|
*/
|
|
@@ -940,7 +1015,7 @@ export const VxeUIPluginMenu = {
|
|
|
940
1015
|
const { computeMouseOpts } = $table.getComputeMaps();
|
|
941
1016
|
const mouseOpts = computeMouseOpts.value;
|
|
942
1017
|
$table.insert(menu.params || {}).then(({ rows }) => {
|
|
943
|
-
if (column && mouseConfig && mouseOpts.area) {
|
|
1018
|
+
if (column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
944
1019
|
$table.setCellAreas([
|
|
945
1020
|
{ startRow: XEUtils.first(rows), endRow: XEUtils.last(rows), startColumn: column, endColumn: column }
|
|
946
1021
|
]);
|
|
@@ -959,7 +1034,7 @@ export const VxeUIPluginMenu = {
|
|
|
959
1034
|
const { computeMouseOpts } = $table.getComputeMaps();
|
|
960
1035
|
const mouseOpts = computeMouseOpts.value;
|
|
961
1036
|
(row ? $table.insertAt(menu.params || {}, row) : $table.insert(menu.params || {})).then(({ rows }) => {
|
|
962
|
-
if (column && mouseConfig && mouseOpts.area) {
|
|
1037
|
+
if (column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
963
1038
|
$table.setCellAreas([
|
|
964
1039
|
{ startRow: XEUtils.first(rows), endRow: XEUtils.last(rows), startColumn: column, endColumn: column }
|
|
965
1040
|
]);
|
|
@@ -981,7 +1056,7 @@ export const VxeUIPluginMenu = {
|
|
|
981
1056
|
if (size) {
|
|
982
1057
|
const records = XEUtils.range(0, size).map(() => Object.assign({}, menu.params));
|
|
983
1058
|
(row ? $table.insertAt(records, row) : $table.insert(records)).then(({ rows }) => {
|
|
984
|
-
if (column && mouseConfig && mouseOpts.area) {
|
|
1059
|
+
if (column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
985
1060
|
$table.setCellAreas([
|
|
986
1061
|
{ startRow: XEUtils.first(rows), endRow: XEUtils.last(rows), startColumn: column, endColumn: column }
|
|
987
1062
|
]);
|
|
@@ -1002,7 +1077,7 @@ export const VxeUIPluginMenu = {
|
|
|
1002
1077
|
const { computeMouseOpts } = $table.getComputeMaps();
|
|
1003
1078
|
const mouseOpts = computeMouseOpts.value;
|
|
1004
1079
|
(row ? $table.insertNextAt(menu.params || {}, row) : $table.insert(menu.params || {})).then(({ rows }) => {
|
|
1005
|
-
if (column && mouseConfig && mouseOpts.area) {
|
|
1080
|
+
if (column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
1006
1081
|
$table.setCellAreas([
|
|
1007
1082
|
{ startRow: XEUtils.first(rows), endRow: XEUtils.last(rows), startColumn: column, endColumn: column }
|
|
1008
1083
|
]);
|
|
@@ -1024,7 +1099,7 @@ export const VxeUIPluginMenu = {
|
|
|
1024
1099
|
if (size) {
|
|
1025
1100
|
const records = XEUtils.range(0, size).map(() => Object.assign({}, menu.params));
|
|
1026
1101
|
(row ? $table.insertNextAt(records, row) : $table.insert(records)).then(({ rows }) => {
|
|
1027
|
-
if (column && mouseConfig && mouseOpts.area) {
|
|
1102
|
+
if (column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
1028
1103
|
$table.setCellAreas([
|
|
1029
1104
|
{ startRow: XEUtils.first(rows), endRow: XEUtils.last(rows), startColumn: column, endColumn: column }
|
|
1030
1105
|
]);
|
|
@@ -1198,7 +1273,7 @@ export const VxeUIPluginMenu = {
|
|
|
1198
1273
|
const { mouseConfig } = tableProps;
|
|
1199
1274
|
const { computeMouseOpts } = $table.getComputeMaps();
|
|
1200
1275
|
const mouseOpts = computeMouseOpts.value;
|
|
1201
|
-
if (mouseConfig && mouseOpts.area) {
|
|
1276
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
1202
1277
|
const cellAreas = $table.getCellAreas();
|
|
1203
1278
|
cellAreas.forEach(areaItem => {
|
|
1204
1279
|
const { rows } = areaItem;
|
package/es/index.js
CHANGED
|
@@ -2,6 +2,15 @@ import XEUtils from 'xe-utils';
|
|
|
2
2
|
import { ref, h } from 'vue';
|
|
3
3
|
let VxeUI;
|
|
4
4
|
let handleCopy;
|
|
5
|
+
/**
|
|
6
|
+
* 用于开关类型的配置项
|
|
7
|
+
* 局部启用规则:conf={}
|
|
8
|
+
* 局部禁用规则:conf={enabled:false}
|
|
9
|
+
* 全局默认启用规则:conf.enabled=true
|
|
10
|
+
*/
|
|
11
|
+
export function hasEnableConf(conf, opts) {
|
|
12
|
+
return opts && (conf ? opts.enabled !== false : opts.enabled);
|
|
13
|
+
}
|
|
5
14
|
const columnIndexOf = (cols, column) => {
|
|
6
15
|
return XEUtils.findIndexOf(cols, item => item.id === column.id);
|
|
7
16
|
};
|
|
@@ -76,8 +85,8 @@ function handleCopyOrCut(params, isCut) {
|
|
|
76
85
|
const { mouseConfig } = tableProps;
|
|
77
86
|
const { computeMouseOpts } = $table.getComputeMaps();
|
|
78
87
|
const mouseOpts = computeMouseOpts.value;
|
|
79
|
-
let text
|
|
80
|
-
if (mouseConfig && mouseOpts.area) {
|
|
88
|
+
let text;
|
|
89
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
81
90
|
if (isCut) {
|
|
82
91
|
$table.triggerCutCellAreaEvent($event);
|
|
83
92
|
}
|
|
@@ -141,7 +150,7 @@ function getBeenMerges(params) {
|
|
|
141
150
|
const mouseOpts = computeMouseOpts.value;
|
|
142
151
|
const { visibleData } = $table.getTableData();
|
|
143
152
|
const { visibleColumn } = $table.getTableColumn();
|
|
144
|
-
const cellAreas = mouseConfig && mouseOpts.area ? $table.getCellAreas() : [];
|
|
153
|
+
const cellAreas = hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area ? $table.getCellAreas() : [];
|
|
145
154
|
const mergeList = $table.getMergeCells();
|
|
146
155
|
return mergeList.filter(({ row: mergeRowIndex, col: mergeColIndex, rowspan: mergeRowspan, colspan: mergeColspan }) => {
|
|
147
156
|
return cellAreas.some(areaItem => {
|
|
@@ -213,10 +222,14 @@ function checkPrivilege(item, params) {
|
|
|
213
222
|
}
|
|
214
223
|
case 'EDIT_CELL':
|
|
215
224
|
case 'CLEAR_CELL':
|
|
225
|
+
case 'CLEAR_AREA_CELL':
|
|
216
226
|
case 'CLEAR_ROW':
|
|
217
227
|
case 'COPY_CELL':
|
|
228
|
+
case 'COPY_AREA_CELL':
|
|
218
229
|
case 'CUT_CELL':
|
|
230
|
+
case 'CUT_AREA_CELL':
|
|
219
231
|
case 'PASTE_CELL':
|
|
232
|
+
case 'PASTE_AREA_CELL':
|
|
220
233
|
case 'MERGE_OR_CLEAR':
|
|
221
234
|
case 'MERGE_CELL':
|
|
222
235
|
case 'REVERT_CELL':
|
|
@@ -270,7 +283,7 @@ function checkPrivilege(item, params) {
|
|
|
270
283
|
}
|
|
271
284
|
case 'OPEN_FIND':
|
|
272
285
|
case 'OPEN_REPLACE': {
|
|
273
|
-
item.disabled = !(mouseConfig && mouseOpts.area);
|
|
286
|
+
item.disabled = !(hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area);
|
|
274
287
|
break;
|
|
275
288
|
}
|
|
276
289
|
case 'EDIT_CELL': {
|
|
@@ -278,13 +291,17 @@ function checkPrivilege(item, params) {
|
|
|
278
291
|
break;
|
|
279
292
|
}
|
|
280
293
|
case 'COPY_CELL':
|
|
294
|
+
case 'COPY_AREA_CELL':
|
|
281
295
|
case 'CUT_CELL':
|
|
282
|
-
case '
|
|
283
|
-
|
|
296
|
+
case 'CUT_AREA_CELL':
|
|
297
|
+
case 'PASTE_CELL':
|
|
298
|
+
case 'PASTE_AREA_CELL': {
|
|
299
|
+
const cellAreas = hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area ? $table.getCellAreas() : [];
|
|
284
300
|
item.disabled = cellAreas.length > 1;
|
|
285
301
|
if (!item.disabled) {
|
|
286
302
|
switch (code) {
|
|
287
|
-
case 'PASTE_CELL':
|
|
303
|
+
case 'PASTE_CELL':
|
|
304
|
+
case 'PASTE_AREA_CELL': {
|
|
288
305
|
const clipboard = getClipboardObj();
|
|
289
306
|
item.disabled = !clipboard || !clipboard.text;
|
|
290
307
|
break;
|
|
@@ -295,7 +312,7 @@ function checkPrivilege(item, params) {
|
|
|
295
312
|
}
|
|
296
313
|
case 'MERGE_OR_CLEAR':
|
|
297
314
|
case 'MERGE_CELL': {
|
|
298
|
-
const cellAreas = mouseConfig && mouseOpts.area ? $table.getCellAreas() : [];
|
|
315
|
+
const cellAreas = hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area ? $table.getCellAreas() : [];
|
|
299
316
|
item.disabled = !cellAreas.length || (cellAreas.length === 1 && cellAreas[0].rows.length === 1 && cellAreas[0].cols.length === 1) || !checkCellOverlay(params, cellAreas);
|
|
300
317
|
break;
|
|
301
318
|
}
|
|
@@ -427,12 +444,12 @@ export const VxeUIPluginMenu = {
|
|
|
427
444
|
const pVersion = 4;
|
|
428
445
|
const sVersion = 11;
|
|
429
446
|
if (!VxeUI.checkVersion(VxeUI.tableVersion, pVersion, sVersion)) {
|
|
430
|
-
console.error(`[@vxe-ui/plugin-menu 4.
|
|
447
|
+
console.error(`[@vxe-ui/plugin-menu 4.4.0] ${VxeUI.getI18n('vxe.error.errorVersion', [`vxe-table@${VxeUI.tableVersion || '?'}`, `vxe-table v${pVersion}.${sVersion}+`])} https://vxeui.com/other4/#/plugin-menu/install`);
|
|
431
448
|
}
|
|
432
449
|
}
|
|
433
450
|
else {
|
|
434
451
|
if (!/^(4)\./.test(VxeUI.uiVersion || VxeUI.tableVersion)) {
|
|
435
|
-
console.error('[@vxe-ui/plugin-menu 4.
|
|
452
|
+
console.error('[@vxe-ui/plugin-menu 4.4.0] Requires vxe-table 4.7.0+ version. https://vxeui.com/other4/#/plugin-menu/install');
|
|
436
453
|
}
|
|
437
454
|
}
|
|
438
455
|
pluginSetup(options);
|
|
@@ -478,7 +495,7 @@ export const VxeUIPluginMenu = {
|
|
|
478
495
|
const { mouseConfig } = tableProps;
|
|
479
496
|
const { computeMouseOpts } = $table.getComputeMaps();
|
|
480
497
|
const mouseOpts = computeMouseOpts.value;
|
|
481
|
-
if (mouseConfig && mouseOpts.area) {
|
|
498
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
482
499
|
const cellAreas = $table.getCellAreas();
|
|
483
500
|
if (cellAreas && cellAreas.length) {
|
|
484
501
|
cellAreas.forEach(areaItem => {
|
|
@@ -497,6 +514,33 @@ export const VxeUIPluginMenu = {
|
|
|
497
514
|
}
|
|
498
515
|
}
|
|
499
516
|
},
|
|
517
|
+
/**
|
|
518
|
+
* 用于 mouse-config.area 功能,清除区域范围内的单元格数据
|
|
519
|
+
*/
|
|
520
|
+
CLEAR_AREA_CELL: {
|
|
521
|
+
tableMenuMethod(params) {
|
|
522
|
+
const { $table, row, column } = params;
|
|
523
|
+
if (row && column) {
|
|
524
|
+
const tableProps = $table.props;
|
|
525
|
+
const { mouseConfig } = tableProps;
|
|
526
|
+
const { computeMouseOpts } = $table.getComputeMaps();
|
|
527
|
+
const mouseOpts = computeMouseOpts.value;
|
|
528
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
529
|
+
const cellAreas = $table.getCellAreas();
|
|
530
|
+
if (cellAreas && cellAreas.length) {
|
|
531
|
+
cellAreas.forEach(areaItem => {
|
|
532
|
+
const { rows, cols } = areaItem;
|
|
533
|
+
cols.forEach(column => {
|
|
534
|
+
rows.forEach(row => {
|
|
535
|
+
$table.clearData(row, column.field);
|
|
536
|
+
});
|
|
537
|
+
});
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
},
|
|
500
544
|
/**
|
|
501
545
|
* 清除行数据的值
|
|
502
546
|
*/
|
|
@@ -527,8 +571,8 @@ export const VxeUIPluginMenu = {
|
|
|
527
571
|
const { mouseConfig } = tableProps;
|
|
528
572
|
const { computeMouseOpts } = $table.getComputeMaps();
|
|
529
573
|
const mouseOpts = computeMouseOpts.value;
|
|
530
|
-
if (mouseConfig && mouseOpts.area) {
|
|
531
|
-
const cellAreas =
|
|
574
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
575
|
+
const cellAreas = mouseOpts.area ? $table.getCellAreas() : [];
|
|
532
576
|
cellAreas.forEach(areaItem => {
|
|
533
577
|
const { rows } = areaItem;
|
|
534
578
|
$table.clearData(rows);
|
|
@@ -560,7 +604,7 @@ export const VxeUIPluginMenu = {
|
|
|
560
604
|
const { mouseConfig } = tableProps;
|
|
561
605
|
const { computeMouseOpts } = $table.getComputeMaps();
|
|
562
606
|
const mouseOpts = computeMouseOpts.value;
|
|
563
|
-
if (mouseConfig && mouseOpts.area) {
|
|
607
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
564
608
|
const { visibleData } = $table.getTableData();
|
|
565
609
|
const { visibleColumn } = $table.getTableColumn();
|
|
566
610
|
$table.setCellAreas([{
|
|
@@ -582,7 +626,7 @@ export const VxeUIPluginMenu = {
|
|
|
582
626
|
const { mouseConfig } = tableProps;
|
|
583
627
|
const { computeMouseOpts } = $table.getComputeMaps();
|
|
584
628
|
const mouseOpts = computeMouseOpts.value;
|
|
585
|
-
if (row && column && mouseConfig && mouseOpts.area) {
|
|
629
|
+
if (row && column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
586
630
|
const { visibleColumn } = $table.getTableColumn();
|
|
587
631
|
const cellAreas = $table.getCellAreas();
|
|
588
632
|
if (cellAreas.length === 1) {
|
|
@@ -615,7 +659,7 @@ export const VxeUIPluginMenu = {
|
|
|
615
659
|
const { mouseConfig } = tableProps;
|
|
616
660
|
const { computeMouseOpts } = $table.getComputeMaps();
|
|
617
661
|
const mouseOpts = computeMouseOpts.value;
|
|
618
|
-
if (row && column && mouseConfig && mouseOpts.area) {
|
|
662
|
+
if (row && column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
619
663
|
const { visibleColumn } = $table.getTableColumn();
|
|
620
664
|
const cellAreas = $table.getCellAreas();
|
|
621
665
|
if (cellAreas.length === 1) {
|
|
@@ -648,7 +692,7 @@ export const VxeUIPluginMenu = {
|
|
|
648
692
|
const { mouseConfig } = tableProps;
|
|
649
693
|
const { computeMouseOpts } = $table.getComputeMaps();
|
|
650
694
|
const mouseOpts = computeMouseOpts.value;
|
|
651
|
-
if (row && column && mouseConfig && mouseOpts.area) {
|
|
695
|
+
if (row && column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
652
696
|
const { visibleData } = $table.getTableData();
|
|
653
697
|
const cellAreas = $table.getCellAreas();
|
|
654
698
|
if (cellAreas.length === 1) {
|
|
@@ -681,7 +725,7 @@ export const VxeUIPluginMenu = {
|
|
|
681
725
|
const { mouseConfig } = tableProps;
|
|
682
726
|
const { computeMouseOpts } = $table.getComputeMaps();
|
|
683
727
|
const mouseOpts = computeMouseOpts.value;
|
|
684
|
-
if (row && column && mouseConfig && mouseOpts.area) {
|
|
728
|
+
if (row && column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
685
729
|
const { visibleData } = $table.getTableData();
|
|
686
730
|
const cellAreas = $table.getCellAreas();
|
|
687
731
|
if (cellAreas.length === 1) {
|
|
@@ -715,7 +759,7 @@ export const VxeUIPluginMenu = {
|
|
|
715
759
|
const { mouseConfig } = tableProps;
|
|
716
760
|
const { computeMouseOpts } = $table.getComputeMaps();
|
|
717
761
|
const mouseOpts = computeMouseOpts.value;
|
|
718
|
-
if (mouseConfig && mouseOpts.area) {
|
|
762
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
719
763
|
const cellAreas = $table.getCellAreas();
|
|
720
764
|
if (cellAreas && cellAreas.length) {
|
|
721
765
|
cellAreas.forEach(areaItem => {
|
|
@@ -789,6 +833,14 @@ export const VxeUIPluginMenu = {
|
|
|
789
833
|
handleCopyOrCut(params);
|
|
790
834
|
}
|
|
791
835
|
},
|
|
836
|
+
/**
|
|
837
|
+
* 复制单元格数据的值;用于 mouse-config.area 功能,复制区域范围内的单元格数据,支持 Excel 和 WPS
|
|
838
|
+
*/
|
|
839
|
+
COPY_AREA_CELL: {
|
|
840
|
+
tableMenuMethod(params) {
|
|
841
|
+
handleCopyOrCut(params);
|
|
842
|
+
}
|
|
843
|
+
},
|
|
792
844
|
/**
|
|
793
845
|
* 剪贴单元格数据的值;如果启用 mouse-config.area 功能,则剪贴区域范围内的单元格数据,支持 Excel 和 WPS
|
|
794
846
|
*/
|
|
@@ -797,6 +849,14 @@ export const VxeUIPluginMenu = {
|
|
|
797
849
|
handleCopyOrCut(params, true);
|
|
798
850
|
}
|
|
799
851
|
},
|
|
852
|
+
/**
|
|
853
|
+
* 剪贴单元格数据的值;用于 mouse-config.area 功能,剪贴区域范围内的单元格数据,支持 Excel 和 WPS
|
|
854
|
+
*/
|
|
855
|
+
CUT_AREA_CELL: {
|
|
856
|
+
tableMenuMethod(params) {
|
|
857
|
+
handleCopyOrCut(params, true);
|
|
858
|
+
}
|
|
859
|
+
},
|
|
800
860
|
/**
|
|
801
861
|
* 粘贴从表格中被复制的数据;如果启用 mouse-config.area 功能,则粘贴区域范围内的单元格数据,不支持读取剪贴板
|
|
802
862
|
*/
|
|
@@ -807,7 +867,7 @@ export const VxeUIPluginMenu = {
|
|
|
807
867
|
const { mouseConfig } = tableProps;
|
|
808
868
|
const { computeMouseOpts } = $table.getComputeMaps();
|
|
809
869
|
const mouseOpts = computeMouseOpts.value;
|
|
810
|
-
if (mouseConfig && mouseOpts.area) {
|
|
870
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
811
871
|
$table.triggerPasteCellAreaEvent($event);
|
|
812
872
|
}
|
|
813
873
|
else {
|
|
@@ -819,6 +879,21 @@ export const VxeUIPluginMenu = {
|
|
|
819
879
|
}
|
|
820
880
|
}
|
|
821
881
|
},
|
|
882
|
+
/**
|
|
883
|
+
* 粘贴从表格中被复制的数据;用于 mouse-config.area 功能,粘贴区域范围内的单元格数据,不支持读取剪贴板
|
|
884
|
+
*/
|
|
885
|
+
PASTE_AREA_CELL: {
|
|
886
|
+
tableMenuMethod(params) {
|
|
887
|
+
const { $event, $table } = params;
|
|
888
|
+
const tableProps = $table.props;
|
|
889
|
+
const { mouseConfig } = tableProps;
|
|
890
|
+
const { computeMouseOpts } = $table.getComputeMaps();
|
|
891
|
+
const mouseOpts = computeMouseOpts.value;
|
|
892
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
893
|
+
$table.triggerPasteCellAreaEvent($event);
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
},
|
|
822
897
|
/**
|
|
823
898
|
* 如果启用 mouse-config.area 功能,如果所选区域内已存在合并单元格,则取消临时合并,否则临时合并
|
|
824
899
|
*/
|
|
@@ -940,7 +1015,7 @@ export const VxeUIPluginMenu = {
|
|
|
940
1015
|
const { computeMouseOpts } = $table.getComputeMaps();
|
|
941
1016
|
const mouseOpts = computeMouseOpts.value;
|
|
942
1017
|
$table.insert(menu.params || {}).then(({ rows }) => {
|
|
943
|
-
if (column && mouseConfig && mouseOpts.area) {
|
|
1018
|
+
if (column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
944
1019
|
$table.setCellAreas([
|
|
945
1020
|
{ startRow: XEUtils.first(rows), endRow: XEUtils.last(rows), startColumn: column, endColumn: column }
|
|
946
1021
|
]);
|
|
@@ -959,7 +1034,7 @@ export const VxeUIPluginMenu = {
|
|
|
959
1034
|
const { computeMouseOpts } = $table.getComputeMaps();
|
|
960
1035
|
const mouseOpts = computeMouseOpts.value;
|
|
961
1036
|
(row ? $table.insertAt(menu.params || {}, row) : $table.insert(menu.params || {})).then(({ rows }) => {
|
|
962
|
-
if (column && mouseConfig && mouseOpts.area) {
|
|
1037
|
+
if (column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
963
1038
|
$table.setCellAreas([
|
|
964
1039
|
{ startRow: XEUtils.first(rows), endRow: XEUtils.last(rows), startColumn: column, endColumn: column }
|
|
965
1040
|
]);
|
|
@@ -981,7 +1056,7 @@ export const VxeUIPluginMenu = {
|
|
|
981
1056
|
if (size) {
|
|
982
1057
|
const records = XEUtils.range(0, size).map(() => Object.assign({}, menu.params));
|
|
983
1058
|
(row ? $table.insertAt(records, row) : $table.insert(records)).then(({ rows }) => {
|
|
984
|
-
if (column && mouseConfig && mouseOpts.area) {
|
|
1059
|
+
if (column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
985
1060
|
$table.setCellAreas([
|
|
986
1061
|
{ startRow: XEUtils.first(rows), endRow: XEUtils.last(rows), startColumn: column, endColumn: column }
|
|
987
1062
|
]);
|
|
@@ -1002,7 +1077,7 @@ export const VxeUIPluginMenu = {
|
|
|
1002
1077
|
const { computeMouseOpts } = $table.getComputeMaps();
|
|
1003
1078
|
const mouseOpts = computeMouseOpts.value;
|
|
1004
1079
|
(row ? $table.insertNextAt(menu.params || {}, row) : $table.insert(menu.params || {})).then(({ rows }) => {
|
|
1005
|
-
if (column && mouseConfig && mouseOpts.area) {
|
|
1080
|
+
if (column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
1006
1081
|
$table.setCellAreas([
|
|
1007
1082
|
{ startRow: XEUtils.first(rows), endRow: XEUtils.last(rows), startColumn: column, endColumn: column }
|
|
1008
1083
|
]);
|
|
@@ -1024,7 +1099,7 @@ export const VxeUIPluginMenu = {
|
|
|
1024
1099
|
if (size) {
|
|
1025
1100
|
const records = XEUtils.range(0, size).map(() => Object.assign({}, menu.params));
|
|
1026
1101
|
(row ? $table.insertNextAt(records, row) : $table.insert(records)).then(({ rows }) => {
|
|
1027
|
-
if (column && mouseConfig && mouseOpts.area) {
|
|
1102
|
+
if (column && hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
1028
1103
|
$table.setCellAreas([
|
|
1029
1104
|
{ startRow: XEUtils.first(rows), endRow: XEUtils.last(rows), startColumn: column, endColumn: column }
|
|
1030
1105
|
]);
|
|
@@ -1198,7 +1273,7 @@ export const VxeUIPluginMenu = {
|
|
|
1198
1273
|
const { mouseConfig } = tableProps;
|
|
1199
1274
|
const { computeMouseOpts } = $table.getComputeMaps();
|
|
1200
1275
|
const mouseOpts = computeMouseOpts.value;
|
|
1201
|
-
if (mouseConfig && mouseOpts.area) {
|
|
1276
|
+
if (hasEnableConf(mouseConfig, mouseOpts) && mouseOpts.area) {
|
|
1202
1277
|
const cellAreas = $table.getCellAreas();
|
|
1203
1278
|
cellAreas.forEach(areaItem => {
|
|
1204
1279
|
const { rows } = areaItem;
|