@vxe-ui/plugin-menu 3.3.0 → 3.3.1

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/es/index.js ADDED
@@ -0,0 +1,1462 @@
1
+ import XEUtils from 'xe-utils';
2
+ let VxeUI;
3
+ let handleCopy;
4
+ const columnIndexOf = (cols, column) => {
5
+ return XEUtils.findIndexOf(cols, item => item.id === column.id);
6
+ };
7
+ const rowIndexOf = ($table, rows, row) => {
8
+ return $table.findRowIndexOf(rows, row);
9
+ };
10
+ function handleFixedColumn(fixed) {
11
+ return {
12
+ tableMenuMethod(params) {
13
+ const { $table, column } = params;
14
+ XEUtils.eachTree([column], (column) => {
15
+ column.fixed = fixed;
16
+ });
17
+ $table.refreshColumn();
18
+ }
19
+ };
20
+ }
21
+ function getClipboardObj() {
22
+ const globalStore = VxeUI.globalStore;
23
+ if (globalStore) {
24
+ return globalStore.clipboard || '';
25
+ }
26
+ // 兼容老版本
27
+ const globalConfig = VxeUI.config;
28
+ if (globalConfig && globalConfig.clipboard) {
29
+ return globalConfig.clipboard;
30
+ }
31
+ return null;
32
+ }
33
+ function setClipboardConfig(clipObj) {
34
+ const globalStore = VxeUI.globalStore;
35
+ if (globalStore) {
36
+ globalStore.clipboard = clipObj;
37
+ }
38
+ else if (VxeUI.config) {
39
+ // 兼容老版本
40
+ VxeUI.config.clipboard = clipObj;
41
+ }
42
+ }
43
+ let copyElem;
44
+ function handleText(content) {
45
+ if (!copyElem) {
46
+ copyElem = document.createElement('textarea');
47
+ copyElem.id = '$XECopy';
48
+ const styles = copyElem.style;
49
+ styles.width = '48px';
50
+ styles.height = '24px';
51
+ styles.position = 'fixed';
52
+ styles.zIndex = '0';
53
+ styles.left = '-500px';
54
+ styles.top = '-500px';
55
+ document.body.appendChild(copyElem);
56
+ }
57
+ copyElem.value = content === null || content === undefined ? '' : ('' + content);
58
+ }
59
+ function copyText(content) {
60
+ let result = false;
61
+ try {
62
+ handleText(content);
63
+ copyElem.select();
64
+ copyElem.setSelectionRange(0, copyElem.value.length);
65
+ result = document.execCommand('copy');
66
+ copyElem.blur();
67
+ }
68
+ catch (e) { }
69
+ return result;
70
+ }
71
+ function handleCopyOrCut(params, isCut) {
72
+ const { $event, $table, row, column } = params;
73
+ if (row && column) {
74
+ const props = $table;
75
+ const { mouseConfig } = props;
76
+ const mouseOpts = $table.computeMouseOpts;
77
+ let text = '';
78
+ if (mouseConfig && mouseOpts.area) {
79
+ if (isCut) {
80
+ $table.triggerCutCellAreaEvent($event);
81
+ }
82
+ else {
83
+ $table.triggerCopyCellAreaEvent($event);
84
+ }
85
+ const clipboard = getClipboardObj();
86
+ text = clipboard ? clipboard.text : '';
87
+ }
88
+ else {
89
+ // 操作内置剪贴板
90
+ text = XEUtils.toValueString(XEUtils.get(row, column.field));
91
+ setClipboardConfig({ text, html: '' });
92
+ }
93
+ // 开始复制操作
94
+ if (XEUtils.isFunction(handleCopy)) {
95
+ handleCopy(text);
96
+ }
97
+ else {
98
+ copyText(text);
99
+ }
100
+ }
101
+ }
102
+ function createCommitHandle(code) {
103
+ return function (params) {
104
+ const { $grid } = params;
105
+ if ($grid) {
106
+ $grid.commitProxy(code);
107
+ }
108
+ };
109
+ }
110
+ function checkCellOverlay(params, cellAreas) {
111
+ const { $table } = params;
112
+ const { visibleData } = $table.getTableData();
113
+ const { visibleColumn } = $table.getTableColumn();
114
+ const indexMaps = {};
115
+ for (let aIndex = 0, areaSize = cellAreas.length; aIndex < areaSize; aIndex++) {
116
+ const areaItem = cellAreas[aIndex];
117
+ const { rows, cols } = areaItem;
118
+ for (let rIndex = 0, rowSize = rows.length; rIndex < rowSize; rIndex++) {
119
+ const offsetRow = rows[rIndex];
120
+ const orIndex = rowIndexOf($table, visibleData, offsetRow);
121
+ for (let cIndex = 0, colSize = cols.length; cIndex < colSize; cIndex++) {
122
+ const offsetColumn = cols[cIndex];
123
+ const ocIndex = columnIndexOf(visibleColumn, offsetColumn);
124
+ const key = orIndex + ':' + ocIndex;
125
+ if (indexMaps[key]) {
126
+ return false;
127
+ }
128
+ indexMaps[key] = true;
129
+ }
130
+ }
131
+ }
132
+ return true;
133
+ }
134
+ function getBeenMerges(params) {
135
+ const { $table } = params;
136
+ const tableProps = $table;
137
+ const { mouseConfig } = tableProps;
138
+ const mouseOpts = $table.computeMouseOpts;
139
+ const { visibleData } = $table.getTableData();
140
+ const { visibleColumn } = $table.getTableColumn();
141
+ const cellAreas = mouseConfig && mouseOpts.area ? $table.getCellAreas() : [];
142
+ const mergeList = $table.getMergeCells();
143
+ return mergeList.filter(({ row: mergeRowIndex, col: mergeColIndex, rowspan: mergeRowspan, colspan: mergeColspan }) => {
144
+ return cellAreas.some(areaItem => {
145
+ const { rows, cols } = areaItem;
146
+ const startRowIndex = rowIndexOf($table, visibleData, rows[0]);
147
+ const endRowIndex = rowIndexOf($table, visibleData, rows[rows.length - 1]);
148
+ const startColIndex = columnIndexOf(visibleColumn, cols[0]);
149
+ const endColIndex = columnIndexOf(visibleColumn, cols[cols.length - 1]);
150
+ return mergeRowIndex >= startRowIndex && mergeRowIndex + mergeRowspan - 1 <= endRowIndex && mergeColIndex >= startColIndex && mergeColIndex + mergeColspan - 1 <= endColIndex;
151
+ });
152
+ });
153
+ }
154
+ function handleClearMergeCells(params) {
155
+ const { $table } = params;
156
+ const beenMerges = getBeenMerges(params);
157
+ if (beenMerges.length) {
158
+ $table.removeMergeCells(beenMerges);
159
+ }
160
+ return beenMerges;
161
+ }
162
+ function checkPrivilege(item, params) {
163
+ const { code } = item;
164
+ const { $table, $grid, row, column, type } = params;
165
+ const tableProps = $table;
166
+ const { editConfig, mouseConfig } = tableProps;
167
+ switch (code) {
168
+ case 'CLEAR_ALL_SORT': {
169
+ const sortList = $table.getSortColumns();
170
+ item.disabled = !sortList.length;
171
+ break;
172
+ }
173
+ case 'CLEAR_ALL_FILTER': {
174
+ const filterList = $table.getCheckedFilters();
175
+ item.disabled = !filterList.length;
176
+ break;
177
+ }
178
+ case 'CLEAR_ALL_MERGE': {
179
+ const mergeCells = $table.getMergeCells();
180
+ const mergeFooterItems = $table.getMergeFooterItems();
181
+ item.disabled = !mergeCells.length && !mergeFooterItems.length;
182
+ break;
183
+ }
184
+ case 'CLEAR_MERGE_CELL': {
185
+ const beenMerges = getBeenMerges(params);
186
+ item.disabled = !beenMerges.length;
187
+ break;
188
+ }
189
+ case 'COPY_TITLE': {
190
+ item.disabled = !column || type !== 'header';
191
+ break;
192
+ }
193
+ case 'SELECT_ALL_AREA': {
194
+ const { visibleData } = $table.getTableData();
195
+ const { visibleColumn } = $table.getTableColumn();
196
+ item.disabled = !visibleData.length || !visibleColumn.length;
197
+ break;
198
+ }
199
+ case 'SELECT_AREA_TO_LEFT':
200
+ case 'SELECT_AREA_TO_RIGHT':
201
+ case 'SELECT_AREA_TO_TOP':
202
+ case 'SELECT_AREA_TO_BOTTON': {
203
+ item.disabled = !column || !row;
204
+ break;
205
+ }
206
+ case 'DELETE_CHECKBOX_ROW': {
207
+ const selectRecords = $table.getCheckboxRecords();
208
+ item.disabled = !selectRecords.length;
209
+ break;
210
+ }
211
+ case 'EDIT_CELL':
212
+ case 'CLEAR_CELL':
213
+ case 'CLEAR_ROW':
214
+ case 'COPY_CELL':
215
+ case 'CUT_CELL':
216
+ case 'PASTE_CELL':
217
+ case 'MERGE_OR_CLEAR':
218
+ case 'MERGE_CELL':
219
+ case 'REVERT_CELL':
220
+ case 'REVERT_ROW':
221
+ case 'DELETE_ROW':
222
+ case 'DELETE_AREA_ROW':
223
+ case 'CLEAR_SORT':
224
+ case 'SORT_ASC':
225
+ case 'SORT_DESC':
226
+ case 'CLEAR_FILTER':
227
+ case 'FILTER_CELL':
228
+ case 'EXPORT_ROW':
229
+ case 'OPEN_FIND':
230
+ case 'OPEN_REPLACE':
231
+ case 'HIDDEN_COLUMN':
232
+ case 'FIXED_LEFT_COLUMN':
233
+ case 'FIXED_RIGHT_COLUMN':
234
+ case 'CLEAR_FIXED_COLUMN': {
235
+ item.disabled = !column;
236
+ if (column) {
237
+ const mouseOpts = $table.computeMouseOpts;
238
+ const isChildCol = !!column.parentId;
239
+ switch (code) {
240
+ case 'CLEAR_SORT': {
241
+ item.disabled = !column.sortable || !column.order;
242
+ break;
243
+ }
244
+ case 'SORT_ASC':
245
+ case 'SORT_DESC':
246
+ item.disabled = !column.sortable;
247
+ break;
248
+ case 'FILTER_CELL':
249
+ case 'CLEAR_FILTER':
250
+ item.disabled = !column.filters || !column.filters.length;
251
+ if (!item.disabled) {
252
+ switch (code) {
253
+ case 'CLEAR_FILTER':
254
+ item.disabled = !column.filters.some((option) => option.checked);
255
+ break;
256
+ }
257
+ }
258
+ break;
259
+ case 'REVERT_CELL': {
260
+ item.disabled = !row || !column.field || !$table.isUpdateByRow(row, column.field);
261
+ break;
262
+ }
263
+ case 'REVERT_ROW': {
264
+ item.disabled = !row || !column.field || !$table.isUpdateByRow(row);
265
+ break;
266
+ }
267
+ case 'OPEN_FIND':
268
+ case 'OPEN_REPLACE': {
269
+ item.disabled = !(mouseConfig && mouseOpts.area);
270
+ break;
271
+ }
272
+ case 'EDIT_CELL': {
273
+ item.disabled = !editConfig || !column.editRender;
274
+ break;
275
+ }
276
+ case 'COPY_CELL':
277
+ case 'CUT_CELL':
278
+ case 'PASTE_CELL': {
279
+ const cellAreas = mouseConfig && mouseOpts.area ? $table.getCellAreas() : [];
280
+ item.disabled = cellAreas.length > 1;
281
+ if (!item.disabled) {
282
+ switch (code) {
283
+ case 'PASTE_CELL': {
284
+ const clipboard = getClipboardObj();
285
+ item.disabled = !clipboard || !clipboard.text;
286
+ break;
287
+ }
288
+ }
289
+ }
290
+ break;
291
+ }
292
+ case 'MERGE_OR_CLEAR':
293
+ case 'MERGE_CELL': {
294
+ const cellAreas = mouseConfig && mouseOpts.area ? $table.getCellAreas() : [];
295
+ item.disabled = !cellAreas.length || (cellAreas.length === 1 && cellAreas[0].rows.length === 1 && cellAreas[0].cols.length === 1) || !checkCellOverlay(params, cellAreas);
296
+ break;
297
+ }
298
+ case 'FIXED_LEFT_COLUMN':
299
+ item.disabled = isChildCol || column.fixed === 'left';
300
+ break;
301
+ case 'FIXED_RIGHT_COLUMN':
302
+ item.disabled = isChildCol || column.fixed === 'right';
303
+ break;
304
+ case 'CLEAR_FIXED_COLUMN':
305
+ item.disabled = isChildCol || !column.fixed;
306
+ break;
307
+ }
308
+ }
309
+ break;
310
+ }
311
+ case 'COMMIT_PROXY_INITIAL':
312
+ case 'COMMIT_PROXY_QUERY':
313
+ case 'COMMIT_PROXY_RELOAD':
314
+ case 'COMMIT_PROXY_DELETE':
315
+ case 'COMMIT_PROXY_SAVE': {
316
+ item.disabled = !$grid;
317
+ break;
318
+ }
319
+ }
320
+ }
321
+ function handlePrivilegeEvent(params) {
322
+ params.options.forEach((list) => {
323
+ list.forEach((item) => {
324
+ checkPrivilege(item, params);
325
+ if (item.children) {
326
+ item.children.forEach((child) => {
327
+ checkPrivilege(child, params);
328
+ });
329
+ }
330
+ });
331
+ });
332
+ return true;
333
+ }
334
+ function selectMultipleRows() {
335
+ return new Promise(resolve => {
336
+ if (VxeUI.modal) {
337
+ const VxeUINumberInputComponent = VxeUI.getComponent('VxeNumberInput');
338
+ if (VxeUINumberInputComponent) {
339
+ let rowSize = 1;
340
+ VxeUI.modal.alert({
341
+ title: '请输入行数',
342
+ width: 220,
343
+ maskClosable: false,
344
+ slots: {
345
+ default(params, h) {
346
+ return h(VxeUINumberInputComponent, {
347
+ props: {
348
+ value: rowSize,
349
+ min: 1,
350
+ max: 100,
351
+ type: 'integer',
352
+ align: 'center',
353
+ controlConfig: {
354
+ layout: 'default'
355
+ }
356
+ },
357
+ style: {
358
+ width: '100%'
359
+ },
360
+ on: {
361
+ modelValue(value) {
362
+ rowSize = value;
363
+ }
364
+ }
365
+ });
366
+ }
367
+ }
368
+ }).then((type) => {
369
+ if (type === 'confirm') {
370
+ resolve({
371
+ size: rowSize || 1
372
+ });
373
+ }
374
+ else {
375
+ resolve({
376
+ size: 0
377
+ });
378
+ }
379
+ });
380
+ }
381
+ else {
382
+ console.error(VxeUI.getI18n('vxe.error.reqComp', ['vxe-number-input']));
383
+ resolve({
384
+ size: 0
385
+ });
386
+ }
387
+ }
388
+ else {
389
+ resolve({
390
+ size: 0
391
+ });
392
+ }
393
+ });
394
+ }
395
+ /**
396
+ * 浏览器-刷新页面(对应按键F5)
397
+ */
398
+ function systemPageRefresh() {
399
+ location.reload();
400
+ }
401
+ /**
402
+ * 浏览器-前进
403
+ */
404
+ function systemPageforward() {
405
+ history.forward();
406
+ }
407
+ /**
408
+ * 浏览器-后退
409
+ */
410
+ function systemPageBack() {
411
+ history.back();
412
+ }
413
+ function pluginConfig(options) {
414
+ if (options && options.copy) {
415
+ handleCopy = options.copy;
416
+ }
417
+ }
418
+ export const VxeUIPluginMenu = {
419
+ setConfig: pluginConfig,
420
+ install(core, options) {
421
+ VxeUI = core;
422
+ // 检查版本
423
+ if (VxeUI.checkVersion) {
424
+ const pVersion = 3;
425
+ const sVersion = 13;
426
+ if (!VxeUI.checkVersion(VxeUI.tableVersion, pVersion, sVersion)) {
427
+ console.error(`[@vxe-ui/plugin-menu 3.3.1] ${VxeUI.getI18n('vxe.error.errorVersion', [`vxe-table@${VxeUI.tableVersion || '?'}`, `vxe-table v${pVersion}.${sVersion}+`])}`);
428
+ }
429
+ }
430
+ else {
431
+ if (!/^(3)\./.test(VxeUI.uiVersion || VxeUI.tableVersion)) {
432
+ console.error('[@vxe-ui/plugin-menu 3.3.1] Requires vxe-table 3.9.0+ version. https://vxeui.com/other3/#/plugin-menu/install');
433
+ }
434
+ }
435
+ pluginConfig(options);
436
+ VxeUI.menus.mixin({
437
+ /**
438
+ * 浏览器-刷新页面(对应按键F5)
439
+ */
440
+ SYSTEM_PAGE_REFRESH: {
441
+ tableMenuMethod: systemPageRefresh,
442
+ treeMenuMethod: systemPageRefresh,
443
+ calendarMenuMethod: systemPageRefresh,
444
+ menuMenuMethod: systemPageRefresh,
445
+ formDesignMenuMethod: systemPageRefresh
446
+ },
447
+ /**
448
+ * 浏览器-前进
449
+ */
450
+ SYSTEM_PAGE_FORWARD: {
451
+ tableMenuMethod: systemPageforward,
452
+ treeMenuMethod: systemPageforward,
453
+ calendarMenuMethod: systemPageforward,
454
+ menuMenuMethod: systemPageforward,
455
+ formDesignMenuMethod: systemPageforward
456
+ },
457
+ /**
458
+ * 浏览器-后退
459
+ */
460
+ SYSTEM_PAGE_BACK: {
461
+ tableMenuMethod: systemPageBack,
462
+ treeMenuMethod: systemPageBack,
463
+ calendarMenuMethod: systemPageBack,
464
+ menuMenuMethod: systemPageBack,
465
+ formDesignMenuMethod: systemPageBack
466
+ },
467
+ /**
468
+ * 清除单元格数据的值;如果启用 mouse-config.area 功能,则清除区域范围内的单元格数据
469
+ */
470
+ CLEAR_CELL: {
471
+ tableMenuMethod(params) {
472
+ const { $table, row, column } = params;
473
+ if (row && column) {
474
+ const tableProps = $table;
475
+ const { mouseConfig } = tableProps;
476
+ const mouseOpts = $table.computeMouseOpts;
477
+ if (mouseConfig && mouseOpts.area) {
478
+ const cellAreas = $table.getCellAreas();
479
+ if (cellAreas && cellAreas.length) {
480
+ cellAreas.forEach(areaItem => {
481
+ const { rows, cols } = areaItem;
482
+ cols.forEach(column => {
483
+ rows.forEach(row => {
484
+ $table.clearData(row, column.field);
485
+ });
486
+ });
487
+ });
488
+ }
489
+ }
490
+ else {
491
+ $table.clearData(row, column.field);
492
+ }
493
+ }
494
+ }
495
+ },
496
+ /**
497
+ * 清除行数据的值
498
+ */
499
+ CLEAR_ROW: {
500
+ tableMenuMethod(params) {
501
+ const { $table, row } = params;
502
+ if (row) {
503
+ $table.clearData(row);
504
+ }
505
+ }
506
+ },
507
+ /**
508
+ * 清除复选框选中行数据的值
509
+ */
510
+ CLEAR_CHECKBOX_ROW: {
511
+ tableMenuMethod(params) {
512
+ const { $table } = params;
513
+ $table.clearData($table.getCheckboxRecords());
514
+ }
515
+ },
516
+ /**
517
+ * 清除区域选择范围内数据的值
518
+ */
519
+ CLEAR_AREA_ROW: {
520
+ tableMenuMethod(params) {
521
+ const { $table, row, column } = params;
522
+ const tableProps = $table;
523
+ const { mouseConfig } = tableProps;
524
+ const mouseOpts = $table.computeMouseOpts;
525
+ if (mouseConfig && mouseOpts.area) {
526
+ const cellAreas = mouseConfig && mouseOpts.area ? $table.getCellAreas() : [];
527
+ cellAreas.forEach(areaItem => {
528
+ const { rows, cols } = areaItem;
529
+ rows.forEach(row => {
530
+ cols.forEach(column => {
531
+ $table.clearData(row);
532
+ });
533
+ });
534
+ });
535
+ }
536
+ else {
537
+ if (row && column) {
538
+ $table.clearData(row);
539
+ }
540
+ }
541
+ }
542
+ },
543
+ /**
544
+ * 清除所有数据的值
545
+ */
546
+ CLEAR_ALL: {
547
+ tableMenuMethod(params) {
548
+ const { $table } = params;
549
+ $table.clearData();
550
+ }
551
+ },
552
+ /**
553
+ * 选取所有区域
554
+ */
555
+ SELECT_ALL_AREA: {
556
+ tableMenuMethod(params) {
557
+ const { $table } = params;
558
+ const tableProps = $table;
559
+ const { mouseConfig } = tableProps;
560
+ const mouseOpts = $table.computeMouseOpts;
561
+ if (mouseConfig && mouseOpts.area) {
562
+ const { visibleData } = $table.getTableData();
563
+ const { visibleColumn } = $table.getTableColumn();
564
+ $table.setCellAreas([{
565
+ startRow: XEUtils.first(visibleData),
566
+ endRow: XEUtils.last(visibleData),
567
+ startColumn: XEUtils.first(visibleColumn),
568
+ endColumn: XEUtils.last(visibleColumn)
569
+ }]);
570
+ }
571
+ }
572
+ },
573
+ /**
574
+ * 以当前单元格为起点,范围选取到左侧单元格
575
+ */
576
+ SELECT_AREA_TO_LEFT: {
577
+ tableMenuMethod(params) {
578
+ const { $table, row, column } = params;
579
+ const tableProps = $table;
580
+ const { mouseConfig } = tableProps;
581
+ const mouseOpts = $table.computeMouseOpts;
582
+ if (mouseConfig && mouseOpts.area) {
583
+ const { visibleColumn } = $table.getTableColumn();
584
+ const cellAreas = $table.getCellAreas();
585
+ if (cellAreas.length === 1) {
586
+ const fitstArea = cellAreas[0];
587
+ $table.setCellAreas([{
588
+ startRow: XEUtils.first(fitstArea.rows),
589
+ endRow: XEUtils.last(fitstArea.rows),
590
+ startColumn: XEUtils.first(visibleColumn),
591
+ endColumn: XEUtils.last(fitstArea.cols)
592
+ }], { column, row });
593
+ }
594
+ else {
595
+ $table.setCellAreas([{
596
+ startRow: row,
597
+ endRow: row,
598
+ startColumn: XEUtils.first(visibleColumn),
599
+ endColumn: column
600
+ }], { column, row });
601
+ }
602
+ }
603
+ }
604
+ },
605
+ /**
606
+ * 以当前单元格为起点,范围选取到右侧单元格
607
+ */
608
+ SELECT_AREA_TO_RIGHT: {
609
+ tableMenuMethod(params) {
610
+ const { $table, row, column } = params;
611
+ const tableProps = $table;
612
+ const { mouseConfig } = tableProps;
613
+ const mouseOpts = $table.computeMouseOpts;
614
+ if (mouseConfig && mouseOpts.area) {
615
+ const { visibleColumn } = $table.getTableColumn();
616
+ const cellAreas = $table.getCellAreas();
617
+ if (cellAreas.length === 1) {
618
+ const fitstArea = cellAreas[0];
619
+ $table.setCellAreas([{
620
+ startRow: XEUtils.first(fitstArea.rows),
621
+ endRow: XEUtils.last(fitstArea.rows),
622
+ startColumn: XEUtils.first(fitstArea.cols),
623
+ endColumn: XEUtils.last(visibleColumn)
624
+ }], { column, row });
625
+ }
626
+ else {
627
+ $table.setCellAreas([{
628
+ startRow: row,
629
+ endRow: row,
630
+ startColumn: column,
631
+ endColumn: XEUtils.last(visibleColumn)
632
+ }], { column, row });
633
+ }
634
+ }
635
+ }
636
+ },
637
+ /**
638
+ * 以当前单元格为起点,范围选取到顶部单元格
639
+ */
640
+ SELECT_AREA_TO_TOP: {
641
+ tableMenuMethod(params) {
642
+ const { $table, row, column } = params;
643
+ const tableProps = $table;
644
+ const { mouseConfig } = tableProps;
645
+ const mouseOpts = $table.computeMouseOpts;
646
+ if (mouseConfig && mouseOpts.area) {
647
+ const { visibleData } = $table.getTableData();
648
+ const cellAreas = $table.getCellAreas();
649
+ if (cellAreas.length === 1) {
650
+ const fitstArea = cellAreas[0];
651
+ $table.setCellAreas([{
652
+ startRow: XEUtils.first(visibleData),
653
+ endRow: XEUtils.last(fitstArea.rows),
654
+ startColumn: XEUtils.first(fitstArea.cols),
655
+ endColumn: XEUtils.last(fitstArea.cols)
656
+ }], { column, row });
657
+ }
658
+ else {
659
+ $table.setCellAreas([{
660
+ startRow: XEUtils.first(visibleData),
661
+ endRow: row,
662
+ startColumn: column,
663
+ endColumn: column
664
+ }], { column, row });
665
+ }
666
+ }
667
+ }
668
+ },
669
+ /**
670
+ * 以当前单元格为起点,范围选取到底部单元格
671
+ */
672
+ SELECT_AREA_TO_BOTTON: {
673
+ tableMenuMethod(params) {
674
+ const { $table, row, column } = params;
675
+ const tableProps = $table;
676
+ const { mouseConfig } = tableProps;
677
+ const mouseOpts = $table.computeMouseOpts;
678
+ if (mouseConfig && mouseOpts.area) {
679
+ const { visibleData } = $table.getTableData();
680
+ const cellAreas = $table.getCellAreas();
681
+ if (cellAreas.length === 1) {
682
+ const fitstArea = cellAreas[0];
683
+ $table.setCellAreas([{
684
+ startRow: XEUtils.first(fitstArea.rows),
685
+ endRow: XEUtils.last(visibleData),
686
+ startColumn: XEUtils.first(fitstArea.cols),
687
+ endColumn: XEUtils.last(fitstArea.cols)
688
+ }], { column, row });
689
+ }
690
+ else {
691
+ $table.setCellAreas([{
692
+ startRow: row,
693
+ endRow: XEUtils.last(visibleData),
694
+ startColumn: column,
695
+ endColumn: column
696
+ }], { column, row });
697
+ }
698
+ }
699
+ }
700
+ },
701
+ /**
702
+ * 还原单元格数据的值;如果启用 mouse-config.area 功能,则还原区域范围内的单元格数据
703
+ */
704
+ REVERT_CELL: {
705
+ tableMenuMethod(params) {
706
+ const { $table, row, column } = params;
707
+ if (row && column) {
708
+ const tableProps = $table;
709
+ const { mouseConfig } = tableProps;
710
+ const mouseOpts = $table.computeMouseOpts;
711
+ if (mouseConfig && mouseOpts.area) {
712
+ const cellAreas = $table.getCellAreas();
713
+ if (cellAreas && cellAreas.length) {
714
+ cellAreas.forEach(areaItem => {
715
+ const { rows, cols } = areaItem;
716
+ cols.forEach(column => {
717
+ rows.forEach(row => {
718
+ $table.revertData(row, column.field);
719
+ });
720
+ });
721
+ });
722
+ }
723
+ }
724
+ else {
725
+ $table.revertData(row, column.field);
726
+ }
727
+ }
728
+ }
729
+ },
730
+ /**
731
+ * 还原行数据的值
732
+ */
733
+ REVERT_ROW: {
734
+ tableMenuMethod(params) {
735
+ const { $table, row } = params;
736
+ if (row) {
737
+ $table.revertData(row);
738
+ }
739
+ }
740
+ },
741
+ /**
742
+ * 还原复选框选中行数据的值
743
+ */
744
+ REVERT_CHECKBOX_ROW: {
745
+ tableMenuMethod(params) {
746
+ const { $table } = params;
747
+ $table.revertData($table.getCheckboxRecords());
748
+ }
749
+ },
750
+ /**
751
+ * 还原所有数据的值
752
+ */
753
+ REVERT_ALL: {
754
+ tableMenuMethod(params) {
755
+ const { $table } = params;
756
+ $table.revertData();
757
+ }
758
+ },
759
+ /**
760
+ * 复制列头标题
761
+ */
762
+ COPY_TITLE: {
763
+ tableMenuMethod(params) {
764
+ const { column } = params;
765
+ const text = column.getTitle();
766
+ if (text) {
767
+ // 开始复制操作
768
+ if (XEUtils.isFunction(handleCopy)) {
769
+ handleCopy(text);
770
+ }
771
+ else {
772
+ copyText(text);
773
+ }
774
+ }
775
+ }
776
+ },
777
+ /**
778
+ * 复制单元格数据的值;如果启用 mouse-config.area 功能,则复制区域范围内的单元格数据,支持 Excel 和 WPS
779
+ */
780
+ COPY_CELL: {
781
+ tableMenuMethod(params) {
782
+ handleCopyOrCut(params);
783
+ }
784
+ },
785
+ /**
786
+ * 剪贴单元格数据的值;如果启用 mouse-config.area 功能,则剪贴区域范围内的单元格数据,支持 Excel 和 WPS
787
+ */
788
+ CUT_CELL: {
789
+ tableMenuMethod(params) {
790
+ handleCopyOrCut(params, true);
791
+ }
792
+ },
793
+ /**
794
+ * 粘贴从表格中被复制的数据;如果启用 mouse-config.area 功能,则粘贴区域范围内的单元格数据,不支持读取剪贴板
795
+ */
796
+ PASTE_CELL: {
797
+ tableMenuMethod(params) {
798
+ const { $event, $table, row, column } = params;
799
+ const tableProps = $table;
800
+ const { mouseConfig } = tableProps;
801
+ const mouseOpts = $table.computeMouseOpts;
802
+ if (mouseConfig && mouseOpts.area) {
803
+ $table.triggerPasteCellAreaEvent($event);
804
+ }
805
+ else {
806
+ const clipboard = getClipboardObj();
807
+ // 读取内置剪贴板
808
+ if (clipboard && clipboard.text) {
809
+ XEUtils.set(row, column.field, clipboard.text);
810
+ }
811
+ }
812
+ }
813
+ },
814
+ /**
815
+ * 如果启用 mouse-config.area 功能,如果所选区域内已存在合并单元格,则取消临时合并,否则临时合并
816
+ */
817
+ MERGE_OR_CLEAR: {
818
+ tableMenuMethod(params) {
819
+ const { $event, $table } = params;
820
+ const cellAreas = $table.getCellAreas();
821
+ const beenMerges = getBeenMerges(params);
822
+ let status = false;
823
+ if (beenMerges.length) {
824
+ $table.removeMergeCells(beenMerges);
825
+ }
826
+ else {
827
+ status = true;
828
+ $table.setMergeCells(cellAreas.map(({ rows, cols }) => {
829
+ return {
830
+ row: rows[0],
831
+ col: cols[0],
832
+ rowspan: rows.length,
833
+ colspan: cols.length
834
+ };
835
+ }));
836
+ }
837
+ const targetAreas = cellAreas.map(({ rows, cols }) => ({ rows, cols }));
838
+ $table.dispatchEvent('cell-area-merge', { status, targetAreas }, $event);
839
+ }
840
+ },
841
+ /**
842
+ * 如果启用 mouse-config.area 功能,临时合并区域范围内的单元格,不管是否存在已合并
843
+ */
844
+ MERGE_CELL: {
845
+ tableMenuMethod(params) {
846
+ const { $event, $table } = params;
847
+ const { visibleData } = $table.getTableData();
848
+ const { visibleColumn } = $table.getTableColumn();
849
+ const cellAreas = $table.getCellAreas();
850
+ handleClearMergeCells(params);
851
+ if (cellAreas.some(({ rows, cols }) => rows.length === visibleData.length || cols.length === visibleColumn.length)) {
852
+ if (VxeUI.modal) {
853
+ VxeUI.modal.message({ content: VxeUI.getI18n('vxe.pro.area.mergeErr'), status: 'error', id: 'operErr' });
854
+ }
855
+ return;
856
+ }
857
+ $table.setMergeCells(cellAreas.map(({ rows, cols }) => {
858
+ return {
859
+ row: rows[0],
860
+ col: cols[0],
861
+ rowspan: rows.length,
862
+ colspan: cols.length
863
+ };
864
+ }));
865
+ const targetAreas = cellAreas.map(({ rows, cols }) => ({ rows, cols }));
866
+ $table.dispatchEvent('cell-area-merge', { status: true, targetAreas }, $event);
867
+ }
868
+ },
869
+ /**
870
+ * 如果启用 mouse-config.area 功能,清除区域范围内单元格的临时合并状态
871
+ */
872
+ CLEAR_MERGE_CELL: {
873
+ tableMenuMethod(params) {
874
+ const { $event, $table } = params;
875
+ const beenMerges = handleClearMergeCells(params);
876
+ if (beenMerges.length) {
877
+ $table.dispatchEvent('clear-cell-area-merge', { mergeCells: beenMerges }, $event);
878
+ }
879
+ }
880
+ },
881
+ /**
882
+ * 清除所有单元格及表尾的临时合并状态
883
+ */
884
+ CLEAR_ALL_MERGE: {
885
+ tableMenuMethod(params) {
886
+ const { $event, $table } = params;
887
+ const mergeCells = $table.getMergeCells();
888
+ const mergeFooterItems = $table.getMergeFooterItems();
889
+ $table.clearMergeCells();
890
+ $table.clearMergeFooterItems();
891
+ $table.dispatchEvent('clear-merge', { mergeCells, mergeFooterItems }, $event);
892
+ }
893
+ },
894
+ /**
895
+ * 编辑单元格
896
+ */
897
+ EDIT_CELL: {
898
+ tableMenuMethod(params) {
899
+ const { $table, row, column } = params;
900
+ if ($table.setEditCell) {
901
+ $table.setEditCell(row, column);
902
+ }
903
+ else {
904
+ // 兼容老版本
905
+ $table.setActiveCell(row, column.field);
906
+ }
907
+ }
908
+ },
909
+ /**
910
+ * 编辑行
911
+ */
912
+ EDIT_ROW: {
913
+ tableMenuMethod(params) {
914
+ const { $table, row } = params;
915
+ if ($table.setEditRow) {
916
+ $table.setEditRow(row);
917
+ }
918
+ else {
919
+ // 兼容老版本
920
+ $table.setActiveRow(row);
921
+ }
922
+ }
923
+ },
924
+ /**
925
+ * 插入数据
926
+ */
927
+ INSERT_ROW: {
928
+ tableMenuMethod(params) {
929
+ const { $table, menu, column } = params;
930
+ const tableProps = $table;
931
+ const { mouseConfig } = tableProps;
932
+ const mouseOpts = $table.computeMouseOpts;
933
+ $table.insert(menu.params || {}).then(({ rows }) => {
934
+ if (column && mouseConfig && mouseOpts.area) {
935
+ $table.setCellAreas([
936
+ { startRow: XEUtils.first(rows), endRow: XEUtils.last(rows), startColumn: column, endColumn: column }
937
+ ]);
938
+ }
939
+ });
940
+ }
941
+ },
942
+ /**
943
+ * 插入数据到指定位置
944
+ */
945
+ INSERT_AT_ROW: {
946
+ tableMenuMethod(params) {
947
+ const { $table, menu, row, column } = params;
948
+ const tableProps = $table;
949
+ const { mouseConfig } = tableProps;
950
+ const mouseOpts = $table.computeMouseOpts;
951
+ (row ? $table.insertAt(menu.params || {}, row) : $table.insert(menu.params || {})).then(({ rows }) => {
952
+ if (column && mouseConfig && mouseOpts.area) {
953
+ $table.setCellAreas([
954
+ { startRow: XEUtils.first(rows), endRow: XEUtils.last(rows), startColumn: column, endColumn: column }
955
+ ]);
956
+ }
957
+ });
958
+ }
959
+ },
960
+ /**
961
+ * 插入多行数据
962
+ */
963
+ BATCH_INSERT_AT_ROW: {
964
+ tableMenuMethod(params) {
965
+ const { $table, menu, row, column } = params;
966
+ const tableProps = $table;
967
+ const { mouseConfig } = tableProps;
968
+ const mouseOpts = $table.computeMouseOpts;
969
+ selectMultipleRows().then(({ size }) => {
970
+ if (size) {
971
+ const records = XEUtils.range(0, size).map(() => Object.assign({}, menu.params));
972
+ (row ? $table.insertAt(records, row) : $table.insert(records)).then(({ rows }) => {
973
+ if (column && mouseConfig && mouseOpts.area) {
974
+ $table.setCellAreas([
975
+ { startRow: XEUtils.first(rows), endRow: XEUtils.last(rows), startColumn: column, endColumn: column }
976
+ ]);
977
+ }
978
+ });
979
+ }
980
+ });
981
+ }
982
+ },
983
+ /**
984
+ * 插入数据到指定位置
985
+ */
986
+ INSERT_NEXT_AT_ROW: {
987
+ tableMenuMethod(params) {
988
+ const { $table, menu, row, column } = params;
989
+ const tableProps = $table;
990
+ const { mouseConfig } = tableProps;
991
+ const mouseOpts = $table.computeMouseOpts;
992
+ (row ? $table.insertNextAt(menu.params || {}, row) : $table.insert(menu.params || {})).then(({ rows }) => {
993
+ if (column && mouseConfig && mouseOpts.area) {
994
+ $table.setCellAreas([
995
+ { startRow: XEUtils.first(rows), endRow: XEUtils.last(rows), startColumn: column, endColumn: column }
996
+ ]);
997
+ }
998
+ });
999
+ }
1000
+ },
1001
+ /**
1002
+ * 插入数据到指定位置
1003
+ */
1004
+ BATCH_INSERT_NEXT_AT_ROW: {
1005
+ tableMenuMethod(params) {
1006
+ const { $table, menu, row, column } = params;
1007
+ const tableProps = $table;
1008
+ const { mouseConfig } = tableProps;
1009
+ const mouseOpts = $table.computeMouseOpts;
1010
+ selectMultipleRows().then(({ size }) => {
1011
+ if (size) {
1012
+ const records = XEUtils.range(0, size).map(() => Object.assign({}, menu.params));
1013
+ (row ? $table.insertNextAt(records, row) : $table.insert(records)).then(({ rows }) => {
1014
+ if (column && mouseConfig && mouseOpts.area) {
1015
+ $table.setCellAreas([
1016
+ { startRow: XEUtils.first(rows), endRow: XEUtils.last(rows), startColumn: column, endColumn: column }
1017
+ ]);
1018
+ }
1019
+ });
1020
+ }
1021
+ });
1022
+ }
1023
+ },
1024
+ /**
1025
+ * 插入数据并激活编辑状态
1026
+ * @deprecated
1027
+ */
1028
+ INSERT_ACTIVED_ROW: {
1029
+ tableMenuMethod(params) {
1030
+ const { $table, menu, column } = params;
1031
+ const args = menu.params || []; // [{}, 'field']
1032
+ const record = Object.assign({}, args[0] || {});
1033
+ $table.insert(record).then(({ row }) => {
1034
+ if ($table.setEditCell) {
1035
+ $table.setEditCell(row, args[1] || column);
1036
+ }
1037
+ else {
1038
+ // 兼容老版本
1039
+ $table.setActiveCell(row, args[1] || column.field);
1040
+ }
1041
+ });
1042
+ }
1043
+ },
1044
+ /**
1045
+ * 插入数据并激活编辑状态
1046
+ * @deprecated
1047
+ */
1048
+ INSERT_EDIT_ROW: {
1049
+ tableMenuMethod(params) {
1050
+ const { $table, menu, column } = params;
1051
+ const args = menu.params || []; // [{}, 'field']
1052
+ const record = Object.assign({}, args[0] || {});
1053
+ $table.insert(record).then(({ row }) => {
1054
+ if ($table.setEditCell) {
1055
+ $table.setEditCell(row, args[1] || column);
1056
+ }
1057
+ else {
1058
+ // 兼容老版本
1059
+ $table.setActiveCell(row, args[1] || column.field);
1060
+ }
1061
+ });
1062
+ }
1063
+ },
1064
+ /**
1065
+ * 插入数据到指定位置并激活编辑状态
1066
+ */
1067
+ INSERT_AT_ACTIVED_ROW: {
1068
+ tableMenuMethod(params) {
1069
+ const { $table, menu, row, column } = params;
1070
+ const args = menu.params || []; // [{}, 'field']
1071
+ const record = Object.assign({}, args[0] || {});
1072
+ (row ? $table.insertAt(record, row) : $table.insert(record)).then(({ row }) => {
1073
+ if ($table.setEditCell) {
1074
+ $table.setEditCell(row, args[1] || column);
1075
+ }
1076
+ else {
1077
+ // 兼容老版本
1078
+ $table.setActiveCell(row, args[1] || column.field);
1079
+ }
1080
+ });
1081
+ }
1082
+ },
1083
+ /**
1084
+ * 插入数据到指定位置并激活编辑状态
1085
+ */
1086
+ INSERT_AT_EDIT_ROW: {
1087
+ tableMenuMethod(params) {
1088
+ const { $table, menu, row, column } = params;
1089
+ const args = menu.params || []; // [{}, 'field']
1090
+ const record = Object.assign({}, args[0] || {});
1091
+ (row ? $table.insertAt(record, row) : $table.insert(record)).then(({ row }) => {
1092
+ if ($table.setEditCell) {
1093
+ $table.setEditCell(row, args[1] || column);
1094
+ }
1095
+ else {
1096
+ // 兼容老版本
1097
+ $table.setActiveCell(row, args[1] || column.field);
1098
+ }
1099
+ });
1100
+ }
1101
+ },
1102
+ /**
1103
+ * 批量插入数据到指定位置并激活编辑状态
1104
+ */
1105
+ BATCH_INSERT_AT_EDIT_ROW: {
1106
+ tableMenuMethod(params) {
1107
+ const { $table, menu, row, column } = params;
1108
+ const args = menu.params || []; // [{}, 'field']
1109
+ selectMultipleRows().then(({ size }) => {
1110
+ if (size) {
1111
+ const records = XEUtils.range(0, size).map(() => Object.assign({}, args[0]));
1112
+ (row ? $table.insertAt(records, row) : $table.insert(records)).then(({ row }) => {
1113
+ if ($table.setEditCell) {
1114
+ $table.setEditCell(row, args[1] || column);
1115
+ }
1116
+ else {
1117
+ // 兼容老版本
1118
+ $table.setActiveCell(row, args[1] || column.field);
1119
+ }
1120
+ });
1121
+ }
1122
+ });
1123
+ }
1124
+ },
1125
+ /**
1126
+ * 插入数据到指定位置并激活编辑状态
1127
+ */
1128
+ INSERT_NEXT_AT_EDIT_ROW: {
1129
+ tableMenuMethod(params) {
1130
+ const { $table, menu, row, column } = params;
1131
+ const args = menu.params || []; // [{}, 'field']
1132
+ const record = Object.assign({}, args[0] || {});
1133
+ (row ? $table.insertNextAt(record, row) : $table.insert(record)).then(({ row }) => {
1134
+ if ($table.setEditCell) {
1135
+ $table.setEditCell(row, args[1] || column);
1136
+ }
1137
+ else {
1138
+ // 兼容老版本
1139
+ $table.setActiveCell(row, args[1] || column.field);
1140
+ }
1141
+ });
1142
+ }
1143
+ },
1144
+ /**
1145
+ * 批量插入数据到指定位置并激活编辑状态
1146
+ */
1147
+ BATCH_INSERT_NEXT_AT_EDIT_ROW: {
1148
+ tableMenuMethod(params) {
1149
+ const { $table, menu, row, column } = params;
1150
+ const args = menu.params || []; // [{}, 'field']
1151
+ selectMultipleRows().then(({ size }) => {
1152
+ if (size) {
1153
+ const records = XEUtils.range(0, size).map(() => Object.assign({}, args[0]));
1154
+ (row ? $table.insertNextAt(records, row) : $table.insert(records)).then(({ row }) => {
1155
+ if ($table.setEditCell) {
1156
+ $table.setEditCell(row, args[1] || column);
1157
+ }
1158
+ else {
1159
+ // 兼容老版本
1160
+ $table.setActiveCell(row, args[1] || column.field);
1161
+ }
1162
+ });
1163
+ }
1164
+ });
1165
+ }
1166
+ },
1167
+ /**
1168
+ * 移除行数据
1169
+ */
1170
+ DELETE_ROW: {
1171
+ tableMenuMethod(params) {
1172
+ const { $table, row } = params;
1173
+ if (row) {
1174
+ $table.remove(row);
1175
+ }
1176
+ }
1177
+ },
1178
+ /**
1179
+ * 如果启用 mouse-config.area 功能,移除所选区域行数据
1180
+ */
1181
+ DELETE_AREA_ROW: {
1182
+ tableMenuMethod(params) {
1183
+ const { $table, row } = params;
1184
+ const tableProps = $table;
1185
+ const { mouseConfig } = tableProps;
1186
+ const mouseOpts = $table.computeMouseOpts;
1187
+ if (mouseConfig && mouseOpts.area) {
1188
+ const cellAreas = mouseConfig && mouseOpts.area ? $table.getCellAreas() : [];
1189
+ cellAreas.forEach(areaItem => {
1190
+ const { rows } = areaItem;
1191
+ $table.remove(rows);
1192
+ });
1193
+ }
1194
+ else {
1195
+ if (row) {
1196
+ $table.remove(row);
1197
+ }
1198
+ }
1199
+ }
1200
+ },
1201
+ /**
1202
+ * 移除复选框选中行数据
1203
+ */
1204
+ DELETE_CHECKBOX_ROW: {
1205
+ tableMenuMethod(params) {
1206
+ const { $table } = params;
1207
+ $table.removeCheckboxRow();
1208
+ }
1209
+ },
1210
+ /**
1211
+ * 移除所有行数据
1212
+ */
1213
+ DELETE_ALL: {
1214
+ tableMenuMethod(params) {
1215
+ const { $table } = params;
1216
+ $table.remove();
1217
+ }
1218
+ },
1219
+ /**
1220
+ * 清除所选列排序条件
1221
+ */
1222
+ CLEAR_SORT: {
1223
+ tableMenuMethod(params) {
1224
+ const { $event, $table, column } = params;
1225
+ if (column) {
1226
+ $table.triggerSortEvent($event, column, null);
1227
+ }
1228
+ }
1229
+ },
1230
+ /**
1231
+ * 清除所有排序条件
1232
+ */
1233
+ CLEAR_ALL_SORT: {
1234
+ tableMenuMethod(params) {
1235
+ const { $event, $table } = params;
1236
+ const sortList = $table.getSortColumns();
1237
+ if (sortList.length) {
1238
+ $table.clearSort();
1239
+ $table.dispatchEvent('clear-sort', { sortList }, $event);
1240
+ }
1241
+ }
1242
+ },
1243
+ /**
1244
+ * 按所选列的值升序
1245
+ */
1246
+ SORT_ASC: {
1247
+ tableMenuMethod(params) {
1248
+ const { $event, $table, column } = params;
1249
+ if (column) {
1250
+ $table.triggerSortEvent($event, column, 'asc');
1251
+ }
1252
+ }
1253
+ },
1254
+ /**
1255
+ * 按所选列的值倒序
1256
+ */
1257
+ SORT_DESC: {
1258
+ tableMenuMethod(params) {
1259
+ const { $event, $table, column } = params;
1260
+ if (column) {
1261
+ $table.triggerSortEvent($event, column, 'desc');
1262
+ }
1263
+ }
1264
+ },
1265
+ /**
1266
+ * 清除复选框选中列的筛选条件
1267
+ */
1268
+ CLEAR_FILTER: {
1269
+ tableMenuMethod(params) {
1270
+ const { $event, $table, column } = params;
1271
+ if (column) {
1272
+ $table.handleClearFilter(column);
1273
+ $table.confirmFilterEvent($event);
1274
+ }
1275
+ }
1276
+ },
1277
+ /**
1278
+ * 清除所有列筛选条件
1279
+ */
1280
+ CLEAR_ALL_FILTER: {
1281
+ tableMenuMethod(params) {
1282
+ const { $event, $table } = params;
1283
+ const filterList = $table.getCheckedFilters();
1284
+ if (filterList.length) {
1285
+ $table.clearFilter();
1286
+ $table.dispatchEvent('clear-filter', { filterList }, $event);
1287
+ }
1288
+ }
1289
+ },
1290
+ /**
1291
+ * 根据单元格值筛选
1292
+ */
1293
+ FILTER_CELL: {
1294
+ tableMenuMethod(params) {
1295
+ const { $table, row, column } = params;
1296
+ if (row && column) {
1297
+ const { field, filters } = column;
1298
+ if (filters.length) {
1299
+ const option = filters[0];
1300
+ option.data = XEUtils.get(row, field);
1301
+ option.checked = true;
1302
+ $table.updateData();
1303
+ }
1304
+ }
1305
+ }
1306
+ },
1307
+ /**
1308
+ * 导出行数据
1309
+ */
1310
+ EXPORT_ROW: {
1311
+ tableMenuMethod(params) {
1312
+ const { $table, menu, row } = params;
1313
+ if (row) {
1314
+ const opts = { data: [row] };
1315
+ $table.exportData(XEUtils.assign({}, menu.params ? menu.params[0] : {}, opts));
1316
+ }
1317
+ }
1318
+ },
1319
+ /**
1320
+ * 导出复选框选中行数据
1321
+ */
1322
+ EXPORT_CHECKBOX_ROW: {
1323
+ tableMenuMethod(params) {
1324
+ const { $table, menu } = params;
1325
+ const opts = { data: $table.getCheckboxRecords() };
1326
+ $table.exportData(XEUtils.assign({}, menu.params ? menu.params[0] : {}, opts));
1327
+ }
1328
+ },
1329
+ /**
1330
+ * 导出所有行数据
1331
+ */
1332
+ EXPORT_ALL: {
1333
+ tableMenuMethod(params) {
1334
+ const { $table, menu } = params;
1335
+ $table.exportData(menu.params);
1336
+ }
1337
+ },
1338
+ /**
1339
+ * 打印所有行数据
1340
+ */
1341
+ PRINT_ALL: {
1342
+ tableMenuMethod(params) {
1343
+ const { $table, menu } = params;
1344
+ $table.print(menu.params);
1345
+ }
1346
+ },
1347
+ /**
1348
+ * 打印复选框选中行
1349
+ */
1350
+ PRINT_CHECKBOX_ROW: {
1351
+ tableMenuMethod(params) {
1352
+ const { $table, menu } = params;
1353
+ const opts = { data: $table.getCheckboxRecords() };
1354
+ $table.print(XEUtils.assign(opts, menu.params));
1355
+ }
1356
+ },
1357
+ /**
1358
+ * 打开查找功能
1359
+ */
1360
+ OPEN_FIND: {
1361
+ tableMenuMethod(params) {
1362
+ const { $event, $table } = params;
1363
+ $table.triggerFNROpenEvent($event, 'find');
1364
+ }
1365
+ },
1366
+ /**
1367
+ * 打开替换功能
1368
+ */
1369
+ OPEN_REPLACE: {
1370
+ tableMenuMethod(params) {
1371
+ const { $event, $table } = params;
1372
+ $table.triggerFNROpenEvent($event, 'replace');
1373
+ }
1374
+ },
1375
+ /**
1376
+ * 隐藏当前列
1377
+ */
1378
+ HIDDEN_COLUMN: {
1379
+ tableMenuMethod(params) {
1380
+ const { $table, column } = params;
1381
+ if (column) {
1382
+ $table.hideColumn(column);
1383
+ }
1384
+ }
1385
+ },
1386
+ /**
1387
+ * 将列固定到左侧
1388
+ */
1389
+ FIXED_LEFT_COLUMN: handleFixedColumn('left'),
1390
+ /**
1391
+ * 将列固定到右侧
1392
+ */
1393
+ FIXED_RIGHT_COLUMN: handleFixedColumn('right'),
1394
+ /**
1395
+ * 清除固定列
1396
+ */
1397
+ CLEAR_FIXED_COLUMN: handleFixedColumn(null),
1398
+ /**
1399
+ * 重置列的可视状态
1400
+ */
1401
+ RESET_COLUMN: {
1402
+ tableMenuMethod(params) {
1403
+ const { $table } = params;
1404
+ $table.resetColumn({ visible: true, resizable: false });
1405
+ }
1406
+ },
1407
+ /**
1408
+ * 重置列宽状态
1409
+ */
1410
+ RESET_RESIZABLE: {
1411
+ tableMenuMethod(params) {
1412
+ const { $table } = params;
1413
+ $table.resetColumn({ visible: false, resizable: true });
1414
+ }
1415
+ },
1416
+ /**
1417
+ * 重置列的所有状态
1418
+ */
1419
+ RESET_ALL: {
1420
+ tableMenuMethod(params) {
1421
+ const { $table } = params;
1422
+ $table.resetColumn(true);
1423
+ }
1424
+ },
1425
+ /**
1426
+ * 用于 proxy-config,重新初始化,恢复到初始状态,触发对应的 ajax.query
1427
+ */
1428
+ COMMIT_PROXY_INITIAL: {
1429
+ tableMenuMethod: createCommitHandle('initial')
1430
+ },
1431
+ /**
1432
+ * 用于 proxy-config,重新加载,如果有分页,返回第一页,触发对应的 ajax.query
1433
+ */
1434
+ COMMIT_PROXY_QUERY: {
1435
+ tableMenuMethod: createCommitHandle('query')
1436
+ },
1437
+ /**
1438
+ * 用于 proxy-config,刷新当前页,触发对应的 ajax.quer
1439
+ */
1440
+ COMMIT_PROXY_RELOAD: {
1441
+ tableMenuMethod: createCommitHandle('reload')
1442
+ },
1443
+ /**
1444
+ * 用于 proxy-config,直接删除,触发对应的 ajax.delete
1445
+ */
1446
+ COMMIT_PROXY_DELETE: {
1447
+ tableMenuMethod: createCommitHandle('delete')
1448
+ },
1449
+ /**
1450
+ * 用于 proxy-config,保存数据,触发对应的 ajax.save
1451
+ */
1452
+ COMMIT_PROXY_SAVE: {
1453
+ tableMenuMethod: createCommitHandle('save')
1454
+ }
1455
+ });
1456
+ VxeUI.interceptor.add('event.showMenu', handlePrivilegeEvent);
1457
+ }
1458
+ };
1459
+ if (typeof window !== 'undefined' && window.VxeUI && window.VxeUI.use) {
1460
+ window.VxeUI.use(VxeUIPluginMenu);
1461
+ }
1462
+ export default VxeUIPluginMenu;