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