vxe-table-plugin-menus
Advanced tools
Comparing version 1.6.2 to 2.0.0
@@ -40,3 +40,4 @@ (function (global, factory) { | ||
function handleCopyOrCut(params, isCut) { | ||
var $table = params.$table, | ||
var $event = params.$event, | ||
$table = params.$table, | ||
row = params.row, | ||
@@ -46,9 +47,14 @@ column = params.column; | ||
if (row && column) { | ||
var $vxe = $table.$vxe; | ||
var text = ''; | ||
if ($table.mouseConfig && $table.mouseOpts.area) { | ||
var clipRest = isCut ? $table.cutCellArea() : $table.copyCellArea(); | ||
text = clipRest.text; | ||
if (isCut) { | ||
$table.triggerCutCellAreaEvent($event); | ||
} else { | ||
$table.triggerCopyCellAreaEvent($event); | ||
} | ||
text = $vxe.clipboard.text; | ||
} else { | ||
var $vxe = $table.$vxe; | ||
text = _xeUtils["default"].toValueString(_xeUtils["default"].get(row, column.property)); // 操作内置剪贴板 | ||
@@ -142,2 +148,4 @@ | ||
} | ||
return beenMerges; | ||
} | ||
@@ -292,3 +300,4 @@ | ||
PASTE_CELL: function PASTE_CELL(params) { | ||
var $table = params.$table, | ||
var $event = params.$event, | ||
$table = params.$table, | ||
row = params.row, | ||
@@ -298,3 +307,3 @@ column = params.column; | ||
if ($table.mouseConfig && $table.mouseOpts.area) { | ||
$table.pasteCellArea(); | ||
$table.triggerPasteCellAreaEvent($event); | ||
} else { | ||
@@ -314,5 +323,7 @@ var $vxe = $table.$vxe; | ||
MERGE_OR_CLEAR: function MERGE_OR_CLEAR(params) { | ||
var $table = params.$table; | ||
var $event = params.$event, | ||
$table = params.$table; | ||
var cellAreas = $table.getCellAreas(); | ||
var beenMerges = getBeenMerges(params); | ||
var status = false; | ||
@@ -322,2 +333,3 @@ if (beenMerges.length) { | ||
} else { | ||
status = true; | ||
$table.setMergeCells(cellAreas.map(function (_ref2) { | ||
@@ -334,2 +346,15 @@ var rows = _ref2.rows, | ||
} | ||
var targetAreas = cellAreas.map(function (_ref3) { | ||
var rows = _ref3.rows, | ||
cols = _ref3.cols; | ||
return { | ||
rows: rows, | ||
cols: cols | ||
}; | ||
}); | ||
$table.emitEvent('cell-area-merge', { | ||
status: status, | ||
targetAreas: targetAreas | ||
}, $event); | ||
}, | ||
@@ -341,3 +366,4 @@ | ||
MERGE_CELL: function MERGE_CELL(params) { | ||
var $table = params.$table; | ||
var $event = params.$event, | ||
$table = params.$table; | ||
var $vxe = $table.$vxe; | ||
@@ -355,5 +381,5 @@ var modal = $vxe.modal; | ||
if (cellAreas.some(function (_ref3) { | ||
var rows = _ref3.rows, | ||
cols = _ref3.cols; | ||
if (cellAreas.some(function (_ref4) { | ||
var rows = _ref4.rows, | ||
cols = _ref4.cols; | ||
return rows.length === visibleData.length || cols.length === visibleColumn.length; | ||
@@ -372,5 +398,5 @@ })) { | ||
$table.setMergeCells(cellAreas.map(function (_ref4) { | ||
var rows = _ref4.rows, | ||
cols = _ref4.cols; | ||
$table.setMergeCells(cellAreas.map(function (_ref5) { | ||
var rows = _ref5.rows, | ||
cols = _ref5.cols; | ||
return { | ||
@@ -383,2 +409,14 @@ row: rows[0], | ||
})); | ||
var targetAreas = cellAreas.map(function (_ref6) { | ||
var rows = _ref6.rows, | ||
cols = _ref6.cols; | ||
return { | ||
rows: rows, | ||
cols: cols | ||
}; | ||
}); | ||
$table.emitEvent('cell-area-merge', { | ||
status: true, | ||
targetAreas: targetAreas | ||
}, $event); | ||
}, | ||
@@ -390,3 +428,11 @@ | ||
CLEAR_MERGE_CELL: function CLEAR_MERGE_CELL(params) { | ||
handleClearMergeCells(params); | ||
var $event = params.$event, | ||
$table = params.$table; | ||
var beenMerges = handleClearMergeCells(params); | ||
if (beenMerges.length) { | ||
$table.emitEvent('clear-cell-area-merge', { | ||
mergeCells: beenMerges | ||
}, $event); | ||
} | ||
}, | ||
@@ -398,5 +444,12 @@ | ||
CLEAR_ALL_MERGE: function CLEAR_ALL_MERGE(params) { | ||
var $table = params.$table; | ||
var $event = params.$event, | ||
$table = params.$table; | ||
var mergeCells = $table.getMergeCells(); | ||
var mergeFooterItems = $table.getMergeFooterItems(); | ||
$table.clearMergeCells(); | ||
$table.clearMergeFooterItems(); | ||
$table.emitEvent('clear-merge', { | ||
mergeCells: mergeCells, | ||
mergeFooterItems: mergeFooterItems | ||
}, $event); | ||
}, | ||
@@ -440,4 +493,4 @@ | ||
var args = menu.params || []; | ||
$table.insert(args[0]).then(function (_ref5) { | ||
var row = _ref5.row; | ||
$table.insert(args[0]).then(function (_ref7) { | ||
var row = _ref7.row; | ||
return $table.setActiveCell(row, args[1] || column.property); | ||
@@ -471,4 +524,4 @@ }); | ||
var args = menu.params || []; | ||
$table.insertAt(args[0], row).then(function (_ref6) { | ||
var row = _ref6.row; | ||
$table.insertAt(args[0], row).then(function (_ref8) { | ||
var row = _ref8.row; | ||
return $table.setActiveCell(row, args[1] || column.property); | ||
@@ -513,18 +566,40 @@ }); | ||
/** | ||
* 清除排序条件 | ||
* 清除所选列排序条件 | ||
*/ | ||
CLEAR_SORT: function CLEAR_SORT(params) { | ||
var $table = params.$table; | ||
$table.clearSort(); | ||
var $event = params.$event, | ||
$table = params.$table, | ||
column = params.column; | ||
if (column) { | ||
$table.triggerSortEvent($event, column, null); | ||
} | ||
}, | ||
/** | ||
* 清除所有排序条件 | ||
*/ | ||
CLEAR_ALL_SORT: function CLEAR_ALL_SORT(params) { | ||
var $event = params.$event, | ||
$table = params.$table; | ||
var sortList = $table.getSortColumns(); | ||
if (sortList.length) { | ||
$table.clearSort(); | ||
$table.emitEvent('clear-sort', { | ||
sortList: sortList | ||
}, $event); | ||
} | ||
}, | ||
/** | ||
* 按所选列的值升序 | ||
*/ | ||
SORT_ASC: function SORT_ASC(params) { | ||
var $table = params.$table, | ||
var $event = params.$event, | ||
$table = params.$table, | ||
column = params.column; | ||
if (column) { | ||
$table.sort(column.property, 'asc'); | ||
$table.triggerSortEvent($event, column, 'asc'); | ||
} | ||
@@ -537,7 +612,8 @@ }, | ||
SORT_DESC: function SORT_DESC(params) { | ||
var $table = params.$table, | ||
var $event = params.$event, | ||
$table = params.$table, | ||
column = params.column; | ||
if (column) { | ||
$table.sort(column.property, 'desc'); | ||
$table.triggerSortEvent($event, column, 'desc'); | ||
} | ||
@@ -550,7 +626,9 @@ }, | ||
CLEAR_FILTER: function CLEAR_FILTER(params) { | ||
var $table = params.$table, | ||
var $event = params.$event, | ||
$table = params.$table, | ||
column = params.column; | ||
if (column) { | ||
$table.clearFilter(column); | ||
$table.handleClearFilter(column); | ||
$table.confirmFilterEvent($event); | ||
} | ||
@@ -563,4 +641,12 @@ }, | ||
CLEAR_ALL_FILTER: function CLEAR_ALL_FILTER(params) { | ||
var $table = params.$table; | ||
$table.clearFilter(); | ||
var $event = params.$event, | ||
$table = params.$table; | ||
var filterList = $table.getCheckedFilters(); | ||
if (filterList.length) { | ||
$table.clearFilter(); | ||
$table.dispatchEvent('clear-filter', { | ||
filterList: filterList | ||
}, $event); | ||
} | ||
}, | ||
@@ -661,4 +747,5 @@ | ||
OPEN_FIND: function OPEN_FIND(params) { | ||
var $table = params.$table; | ||
$table.openFind(); | ||
var $event = params.$event, | ||
$table = params.$table; | ||
$table.triggerFNROpenEvent($event, 'find'); | ||
}, | ||
@@ -670,4 +757,5 @@ | ||
OPEN_REPLACE: function OPEN_REPLACE(params) { | ||
var $table = params.$table; | ||
$table.openReplace(); | ||
var $event = params.$event, | ||
$table = params.$table; | ||
$table.triggerFNROpenEvent($event, 'replace'); | ||
}, | ||
@@ -744,7 +832,6 @@ | ||
switch (code) { | ||
case 'CLEAR_SORT': | ||
case 'CLEAR_ALL_SORT': | ||
{ | ||
item.disabled = !columns.some(function (column) { | ||
return column.sortable && column.order; | ||
}); | ||
var sortList = $table.getSortColumns(); | ||
item.disabled = !sortList.length; | ||
break; | ||
@@ -755,7 +842,4 @@ } | ||
{ | ||
item.disabled = !columns.some(function (column) { | ||
return column.filters && column.filters.some(function (option) { | ||
return option.checked; | ||
}); | ||
}); | ||
var filterList = $table.getCheckedFilters(); | ||
item.disabled = !filterList.length; | ||
break; | ||
@@ -800,2 +884,3 @@ } | ||
case 'DELETE_ROW': | ||
case 'CLEAR_SORT': | ||
case 'SORT_ASC': | ||
@@ -819,2 +904,8 @@ case 'SORT_DESC': | ||
switch (code) { | ||
case 'CLEAR_SORT': | ||
{ | ||
item.disabled = !column.sortable || !column.order; | ||
break; | ||
} | ||
case 'SORT_ASC': | ||
@@ -934,5 +1025,5 @@ case 'SORT_DESC': | ||
setup: setup, | ||
install: function install(_ref7, options) { | ||
var interceptor = _ref7.interceptor, | ||
menus = _ref7.menus; | ||
install: function install(_ref9, options) { | ||
var interceptor = _ref9.interceptor, | ||
menus = _ref9.menus; | ||
@@ -939,0 +1030,0 @@ if (window.XEClipboard) { |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"function"==typeof define&&define.amd?define("vxe-table-plugin-menus",["exports","xe-utils"],t):"undefined"!=typeof exports?t(exports,require("xe-utils")):(t((t={exports:{}}).exports,e.XEUtils),e.VXETablePluginMenus=t.exports.default)}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,function(e,o){"use strict";var t,l;function a(a){return function(e){var t=e.$table,e=e.column;o.default.eachTree([e],function(e){e.fixed=a}),t.refreshColumn()}}function n(e,t){var a=e.$table,n=e.row,r=e.column;n&&r&&(e="",a.mouseConfig&&a.mouseOpts.area?e=(t?a.cutCellArea():a.copyCellArea()).text:(a=a.$vxe,e=o.default.toValueString(o.default.get(n,r.property)),a.clipboard={text:e}),o.default.isFunction(l)?l(e):console.warn("Copy function does not exist, copy to clipboard failed."))}function f(e){var e=e.$table,s=e.getTableData().visibleData,c=e.getTableColumn().visibleColumn,t=e.mouseConfig&&e.mouseOpts.area?e.getCellAreas():[];return e.getMergeCells().filter(function(e){var r=e.row,o=e.col,l=e.rowspan,E=e.colspan;return t.some(function(e){var t=e.rows,a=e.cols,n=s.indexOf(t[0]),e=s.indexOf(t[t.length-1]),t=c.indexOf(a[0]),a=c.indexOf(a[a.length-1]);return n<=r&&r+l-1<=e&&t<=o&&o+E-1<=a})})}function E(e){var t=e.$table,e=f(e);e.length&&t.removeMergeCells(e)}function r(e,t){console.warn('The code "'.concat(e,'" has been scrapped, please use "').concat(t,'"'))}Object.defineProperty(e,"__esModule",{value:!0}),e.default=e.VXETablePluginMenus=void 0,o=(t=o)&&t.__esModule?t:{default:t};var s={CLEAR_CELL:function(e){var n=e.$table,t=e.row,a=e.column;t&&a&&(n.mouseConfig&&n.mouseOpts.area?(e=n.getCellAreas())&&e.length&&e.forEach(function(e){var a=e.rows;e.cols.forEach(function(t){a.forEach(function(e){n.clearData(e,t.property)})})}):n.clearData(t,a.property))},CLEAR_ROW:function(e){var t=e.$table,e=e.row;e&&t.clearData(e)},CLEAR_SELECTED_ROW:function(e){return r("CLEAR_SELECTED_ROW","CLEAR_CHECKBOX_ROW"),s.CLEAR_CHECKBOX_ROW(e)},CLEAR_CHECKBOX_ROW:function(e){e=e.$table;e.clearData(e.getCheckboxRecords())},CLEAR_ALL:function(e){e.$table.clearData()},REVERT_CELL:function(e){var n=e.$table,t=e.row,a=e.column;t&&a&&(n.mouseConfig&&n.mouseOpts.area?(e=n.getCellAreas())&&e.length&&e.forEach(function(e){var a=e.rows;e.cols.forEach(function(t){a.forEach(function(e){n.revertData(e,t.property)})})}):n.revertData(t,a.property))},REVERT_ROW:function(e){var t=e.$table,e=e.row;e&&t.revertData(e)},REVERT_SELECTED_ROW:function(e){return r("REVERT_SELECTED_ROW","REVERT_CHECKBOX_ROW"),s.REVERT_CHECKBOX_ROW(e)},REVERT_CHECKBOX_ROW:function(e){e=e.$table;e.revertData(e.getCheckboxRecords())},REVERT_ALL:function(e){e.$table.revertData()},COPY_CELL:function(e){n(e)},CUT_CELL:function(e){n(e,!0)},PASTE_CELL:function(e){var t=e.$table,a=e.row,e=e.column;t.mouseConfig&&t.mouseOpts.area?t.pasteCellArea():(t=t.$vxe.clipboard)&&t.text&&o.default.set(a,e.property,t.text)},MERGE_OR_CLEAR:function(e){var t=e.$table,a=t.getCellAreas(),e=f(e);e.length?t.removeMergeCells(e):t.setMergeCells(a.map(function(e){var t=e.rows,e=e.cols;return{row:t[0],col:e[0],rowspan:t.length,colspan:e.length}}))},MERGE_CELL:function(e){var t=e.$table,a=t.$vxe,n=a.modal,r=t.getTableData().visibleData,o=t.getTableColumn().visibleColumn,l=t.getCellAreas();E(e),l.some(function(e){var t=e.rows,e=e.cols;return t.length===r.length||e.length===o.length})?n&&n.message({content:a.t("vxe.pro.area.mergeErr"),status:"error",id:"operErr"}):t.setMergeCells(l.map(function(e){var t=e.rows,e=e.cols;return{row:t[0],col:e[0],rowspan:t.length,colspan:e.length}}))},CLEAR_MERGE_CELL:function(e){E(e)},CLEAR_ALL_MERGE:function(e){e=e.$table;e.clearMergeCells(),e.clearMergeFooterItems()},EDIT_CELL:function(e){var t=e.$table,a=e.row,e=e.column;t.setActiveCell(a,e.property)},EDIT_ROW:function(e){var t=e.$table,e=e.row;t.setActiveRow(e)},INSERT_ROW:function(e){var t=e.$table,e=e.menu;t.insert(e.params)},INSERT_ACTIVED_ROW:function(e){var t=e.$table,a=e.menu,n=e.column,r=a.params||[];t.insert(r[0]).then(function(e){e=e.row;return t.setActiveCell(e,r[1]||n.property)})},INSERT_AT_ROW:function(e){var t=e.$table,a=e.menu,e=e.row;e&&t.insertAt(a.params,e)},INSERT_AT_ACTIVED_ROW:function(e){var t,a=e.$table,n=e.menu,r=e.row,o=e.column;r&&(t=n.params||[],a.insertAt(t[0],r).then(function(e){e=e.row;return a.setActiveCell(e,t[1]||o.property)}))},DELETE_ROW:function(e){var t=e.$table,e=e.row;e&&t.remove(e)},DELETE_SELECTED_ROW:function(e){return r("DELETE_SELECTED_ROW","DELETE_CHECKBOX_ROW"),s.DELETE_CHECKBOX_ROW(e)},DELETE_CHECKBOX_ROW:function(e){e.$table.removeCheckboxRow()},DELETE_ALL:function(e){e.$table.remove()},CLEAR_SORT:function(e){e.$table.clearSort()},SORT_ASC:function(e){var t=e.$table,e=e.column;e&&t.sort(e.property,"asc")},SORT_DESC:function(e){var t=e.$table,e=e.column;e&&t.sort(e.property,"desc")},CLEAR_FILTER:function(e){var t=e.$table,e=e.column;e&&t.clearFilter(e)},CLEAR_ALL_FILTER:function(e){e.$table.clearFilter()},FILTER_CELL:function(e){var t=e.$table,a=e.row,n=e.column;a&&n&&(e=n.property,(n=n.filters).length&&((n=n[0]).data=o.default.get(a,e),n.checked=!0,t.updateData()))},EXPORT_ROW:function(e){var t=e.$table,a=e.menu,e=e.row;e&&(e={data:[e]},t.exportData(o.default.assign(e,a.params[0])))},EXPORT_SELECTED_ROW:function(e){return r("EXPORT_SELECTED_ROW","EXPORT_CHECKBOX_ROW"),s.EXPORT_CHECKBOX_ROW(e)},EXPORT_CHECKBOX_ROW:function(e){var t=e.$table,a=e.menu,e={data:t.getCheckboxRecords()};t.exportData(o.default.assign(e,a.params[0]))},EXPORT_ALL:function(e){var t=e.$table,e=e.menu;t.exportData(e.params)},PRINT_ALL:function(e){var t=e.$table,e=e.menu;t.print(e.params)},PRINT_SELECTED_ROW:function(e){return r("PRINT_SELECTED_ROW","PRINT_CHECKBOX_ROW"),s.PRINT_CHECKBOX_ROW(e)},PRINT_CHECKBOX_ROW:function(e){var t=e.$table,a=e.menu,e={data:t.getCheckboxRecords()};t.print(o.default.assign(e,a.params))},OPEN_FIND:function(e){e.$table.openFind()},OPEN_REPLACE:function(e){e.$table.openReplace()},HIDDEN_COLUMN:function(e){var t=e.$table,e=e.column;e&&t.hideColumn(e)},FIXED_LEFT_COLUMN:a("left"),FIXED_RIGHT_COLUMN:a("right"),CLEAR_FIXED_COLUMN:a(""),RESET_COLUMN:function(e){e.$table.resetColumn({visible:!0,resizable:!1})},RESET_RESIZABLE:function(e){e.$table.resetColumn({visible:!1,resizable:!0})},RESET_ALL:function(e){e.$table.resetColumn(!0)}};function c(e,t){var a=e.code,n=t.$table,r=t.columns,o=t.column,l=n.editConfig,E=n.mouseConfig,s=n.mouseOpts,c=n.fnrOpts;switch(a){case"CLEAR_SORT":e.disabled=!r.some(function(e){return e.sortable&&e.order});break;case"CLEAR_ALL_FILTER":e.disabled=!r.some(function(e){return e.filters&&e.filters.some(function(e){return e.checked})});break;case"CLEAR_ALL_MERGE":var i=n.getMergeCells(),u=n.getMergeFooterItems();e.disabled=!i.length&&!u.length;break;case"CLEAR_MERGE_CELL":u=f(t);e.disabled=!u.length;break;case"EDIT_ROW":e.disabled=!l||!r.some(function(e){return e.editRender});break;case"EDIT_CELL":case"CLEAR_CELL":case"CLEAR_ROW":case"COPY_CELL":case"CUT_CELL":case"PASTE_CELL":case"MERGE_OR_CLEAR":case"MERGE_CELL":case"REVERT_CELL":case"REVERT_ROW":case"INSERT_AT_ROW":case"INSERT_AT_ACTIVED_ROW":case"DELETE_ROW":case"SORT_ASC":case"SORT_DESC":case"CLEAR_FILTER":case"FILTER_CELL":case"EXPORT_ROW":case"OPEN_FIND":case"OPEN_REPLACE":case"HIDDEN_COLUMN":case"FIXED_LEFT_COLUMN":case"FIXED_RIGHT_COLUMN":case"CLEAR_FIXED_COLUMN":if(e.disabled=!o,o){var C=!!o.parentId;switch(a){case"SORT_ASC":case"SORT_DESC":e.disabled=!o.sortable;break;case"FILTER_CELL":case"CLEAR_FILTER":e.disabled=!o.filters||!o.filters.length,e.disabled||"CLEAR_FILTER"===a&&(e.disabled=!o.filters.some(function(e){return e.checked}));break;case"OPEN_FIND":e.disabled=!(c&&E&&s.area&&c.isFind);break;case"OPEN_REPLACE":e.disabled=!(c&&E&&s.area&&c.isReplace);break;case"EDIT_CELL":e.disabled=!l||!o.editRender;break;case"COPY_CELL":case"CUT_CELL":case"PASTE_CELL":var _=E&&s.area?n.getCellAreas():[];e.disabled=1<_.length,e.disabled||"PASTE_CELL"===a&&(R=n.$vxe.clipboard,e.disabled=!R||!R.text);break;case"MERGE_OR_CLEAR":case"MERGE_CELL":var R=E&&s.area?n.getCellAreas():[];e.disabled=!R.length||1===R.length&&1===R[0].rows.length&&1===R[0].cols.length||!function(e,t){for(var a=(e=e.$table).getTableData().visibleData,n=e.getTableColumn().visibleColumn,r={},o=0,l=t.length;o<l;o++)for(var E=t[o],s=E.rows,c=E.cols,i=0,u=s.length;i<u;i++)for(var C=s[i],_=a.indexOf(C),R=0,f=c.length;R<f;R++){var L=c[R],L=_+":"+n.indexOf(L);if(r[L])return;r[L]=!0}return 1}(t,R);break;case"FIXED_LEFT_COLUMN":e.disabled=C||"left"===o.fixed;break;case"FIXED_RIGHT_COLUMN":e.disabled=C||"right"===o.fixed;break;case"CLEAR_FIXED_COLUMN":e.disabled=C||!o.fixed}}}}function i(t){return t.options.forEach(function(e){e.forEach(function(e){c(e,t),e.children&&e.children.forEach(function(e){c(e,t)})})}),!0}function u(e){e&&e.copy&&(l=e.copy)}var C={setup:u,install:function(e,t){var a=e.interceptor,e=e.menus;window.XEClipboard&&(l=window.XEClipboard.copy),u(t),a.add("event.showMenu",i),e.mixin(s)}};e.VXETablePluginMenus=C,"undefined"!=typeof window&&window.VXETable&&window.VXETable.use&&window.VXETable.use(C),e.default=C}); | ||
!function(e,t){"function"==typeof define&&define.amd?define("vxe-table-plugin-menus",["exports","xe-utils"],t):"undefined"!=typeof exports?t(exports,require("xe-utils")):(t((t={exports:{}}).exports,e.XEUtils),e.VXETablePluginMenus=t.exports.default)}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,function(e,E){"use strict";var t,s;function a(a){return function(e){var t=e.$table,e=e.column;E.default.eachTree([e],function(e){e.fixed=a}),t.refreshColumn()}}function n(e,t){var a,n=e.$event,r=e.$table,o=e.row,l=e.column;o&&l&&(a=r.$vxe,e="",r.mouseConfig&&r.mouseOpts.area?(t?r.triggerCutCellAreaEvent(n):r.triggerCopyCellAreaEvent(n),e=a.clipboard.text):(e=E.default.toValueString(E.default.get(o,l.property)),a.clipboard={text:e}),E.default.isFunction(s)?s(e):console.warn("Copy function does not exist, copy to clipboard failed."))}function L(e){var e=e.$table,s=e.getTableData().visibleData,i=e.getTableColumn().visibleColumn,t=e.mouseConfig&&e.mouseOpts.area?e.getCellAreas():[];return e.getMergeCells().filter(function(e){var r=e.row,o=e.col,l=e.rowspan,E=e.colspan;return t.some(function(e){var t=e.rows,a=e.cols,n=s.indexOf(t[0]),e=s.indexOf(t[t.length-1]),t=i.indexOf(a[0]),a=i.indexOf(a[a.length-1]);return n<=r&&r+l-1<=e&&t<=o&&o+E-1<=a})})}function i(e){var t=e.$table,e=L(e);return e.length&&t.removeMergeCells(e),e}function r(e,t){console.warn('The code "'.concat(e,'" has been scrapped, please use "').concat(t,'"'))}Object.defineProperty(e,"__esModule",{value:!0}),e.default=e.VXETablePluginMenus=void 0,E=(t=E)&&t.__esModule?t:{default:t};var o={CLEAR_CELL:function(e){var n=e.$table,t=e.row,a=e.column;t&&a&&(n.mouseConfig&&n.mouseOpts.area?(e=n.getCellAreas())&&e.length&&e.forEach(function(e){var a=e.rows;e.cols.forEach(function(t){a.forEach(function(e){n.clearData(e,t.property)})})}):n.clearData(t,a.property))},CLEAR_ROW:function(e){var t=e.$table,e=e.row;e&&t.clearData(e)},CLEAR_SELECTED_ROW:function(e){return r("CLEAR_SELECTED_ROW","CLEAR_CHECKBOX_ROW"),o.CLEAR_CHECKBOX_ROW(e)},CLEAR_CHECKBOX_ROW:function(e){e=e.$table;e.clearData(e.getCheckboxRecords())},CLEAR_ALL:function(e){e.$table.clearData()},REVERT_CELL:function(e){var n=e.$table,t=e.row,a=e.column;t&&a&&(n.mouseConfig&&n.mouseOpts.area?(e=n.getCellAreas())&&e.length&&e.forEach(function(e){var a=e.rows;e.cols.forEach(function(t){a.forEach(function(e){n.revertData(e,t.property)})})}):n.revertData(t,a.property))},REVERT_ROW:function(e){var t=e.$table,e=e.row;e&&t.revertData(e)},REVERT_SELECTED_ROW:function(e){return r("REVERT_SELECTED_ROW","REVERT_CHECKBOX_ROW"),o.REVERT_CHECKBOX_ROW(e)},REVERT_CHECKBOX_ROW:function(e){e=e.$table;e.revertData(e.getCheckboxRecords())},REVERT_ALL:function(e){e.$table.revertData()},COPY_CELL:function(e){n(e)},CUT_CELL:function(e){n(e,!0)},PASTE_CELL:function(e){var t=e.$event,a=e.$table,n=e.row,e=e.column;a.mouseConfig&&a.mouseOpts.area?a.triggerPasteCellAreaEvent(t):(a=a.$vxe.clipboard)&&a.text&&E.default.set(n,e.property,a.text)},MERGE_OR_CLEAR:function(e){var t=e.$event,a=e.$table,n=a.getCellAreas(),r=L(e),e=!1;r.length?a.removeMergeCells(r):(e=!0,a.setMergeCells(n.map(function(e){var t=e.rows,e=e.cols;return{row:t[0],col:e[0],rowspan:t.length,colspan:e.length}})));n=n.map(function(e){return{rows:e.rows,cols:e.cols}});a.emitEvent("cell-area-merge",{status:e,targetAreas:n},t)},MERGE_CELL:function(e){var t=e.$event,a=e.$table,n=a.$vxe,r=n.modal,o=a.getTableData().visibleData,l=a.getTableColumn().visibleColumn,E=a.getCellAreas();i(e),E.some(function(e){var t=e.rows,e=e.cols;return t.length===o.length||e.length===l.length})?r&&r.message({content:n.t("vxe.pro.area.mergeErr"),status:"error",id:"operErr"}):(a.setMergeCells(E.map(function(e){var t=e.rows,e=e.cols;return{row:t[0],col:e[0],rowspan:t.length,colspan:e.length}})),E=E.map(function(e){return{rows:e.rows,cols:e.cols}}),a.emitEvent("cell-area-merge",{status:!0,targetAreas:E},t))},CLEAR_MERGE_CELL:function(e){var t=e.$event,a=e.$table,e=i(e);e.length&&a.emitEvent("clear-cell-area-merge",{mergeCells:e},t)},CLEAR_ALL_MERGE:function(e){var t=e.$event,a=e.$table,n=a.getMergeCells(),e=a.getMergeFooterItems();a.clearMergeCells(),a.clearMergeFooterItems(),a.emitEvent("clear-merge",{mergeCells:n,mergeFooterItems:e},t)},EDIT_CELL:function(e){var t=e.$table,a=e.row,e=e.column;t.setActiveCell(a,e.property)},EDIT_ROW:function(e){var t=e.$table,e=e.row;t.setActiveRow(e)},INSERT_ROW:function(e){var t=e.$table,e=e.menu;t.insert(e.params)},INSERT_ACTIVED_ROW:function(e){var t=e.$table,a=e.menu,n=e.column,r=a.params||[];t.insert(r[0]).then(function(e){e=e.row;return t.setActiveCell(e,r[1]||n.property)})},INSERT_AT_ROW:function(e){var t=e.$table,a=e.menu,e=e.row;e&&t.insertAt(a.params,e)},INSERT_AT_ACTIVED_ROW:function(e){var t,a=e.$table,n=e.menu,r=e.row,o=e.column;r&&(t=n.params||[],a.insertAt(t[0],r).then(function(e){e=e.row;return a.setActiveCell(e,t[1]||o.property)}))},DELETE_ROW:function(e){var t=e.$table,e=e.row;e&&t.remove(e)},DELETE_SELECTED_ROW:function(e){return r("DELETE_SELECTED_ROW","DELETE_CHECKBOX_ROW"),o.DELETE_CHECKBOX_ROW(e)},DELETE_CHECKBOX_ROW:function(e){e.$table.removeCheckboxRow()},DELETE_ALL:function(e){e.$table.remove()},CLEAR_SORT:function(e){var t=e.$event,a=e.$table,e=e.column;e&&a.triggerSortEvent(t,e,null)},CLEAR_ALL_SORT:function(e){var t=e.$event,a=e.$table,e=a.getSortColumns();e.length&&(a.clearSort(),a.emitEvent("clear-sort",{sortList:e},t))},SORT_ASC:function(e){var t=e.$event,a=e.$table,e=e.column;e&&a.triggerSortEvent(t,e,"asc")},SORT_DESC:function(e){var t=e.$event,a=e.$table,e=e.column;e&&a.triggerSortEvent(t,e,"desc")},CLEAR_FILTER:function(e){var t=e.$event,a=e.$table,e=e.column;e&&(a.handleClearFilter(e),a.confirmFilterEvent(t))},CLEAR_ALL_FILTER:function(e){var t=e.$event,a=e.$table,e=a.getCheckedFilters();e.length&&(a.clearFilter(),a.dispatchEvent("clear-filter",{filterList:e},t))},FILTER_CELL:function(e){var t=e.$table,a=e.row,n=e.column;a&&n&&(e=n.property,(n=n.filters).length&&((n=n[0]).data=E.default.get(a,e),n.checked=!0,t.updateData()))},EXPORT_ROW:function(e){var t=e.$table,a=e.menu,e=e.row;e&&(e={data:[e]},t.exportData(E.default.assign(e,a.params[0])))},EXPORT_SELECTED_ROW:function(e){return r("EXPORT_SELECTED_ROW","EXPORT_CHECKBOX_ROW"),o.EXPORT_CHECKBOX_ROW(e)},EXPORT_CHECKBOX_ROW:function(e){var t=e.$table,a=e.menu,e={data:t.getCheckboxRecords()};t.exportData(E.default.assign(e,a.params[0]))},EXPORT_ALL:function(e){var t=e.$table,e=e.menu;t.exportData(e.params)},PRINT_ALL:function(e){var t=e.$table,e=e.menu;t.print(e.params)},PRINT_SELECTED_ROW:function(e){return r("PRINT_SELECTED_ROW","PRINT_CHECKBOX_ROW"),o.PRINT_CHECKBOX_ROW(e)},PRINT_CHECKBOX_ROW:function(e){var t=e.$table,a=e.menu,e={data:t.getCheckboxRecords()};t.print(E.default.assign(e,a.params))},OPEN_FIND:function(e){var t=e.$event;e.$table.triggerFNROpenEvent(t,"find")},OPEN_REPLACE:function(e){var t=e.$event;e.$table.triggerFNROpenEvent(t,"replace")},HIDDEN_COLUMN:function(e){var t=e.$table,e=e.column;e&&t.hideColumn(e)},FIXED_LEFT_COLUMN:a("left"),FIXED_RIGHT_COLUMN:a("right"),CLEAR_FIXED_COLUMN:a(""),RESET_COLUMN:function(e){e.$table.resetColumn({visible:!0,resizable:!1})},RESET_RESIZABLE:function(e){e.$table.resetColumn({visible:!1,resizable:!0})},RESET_ALL:function(e){e.$table.resetColumn(!0)}};function l(e,t){var a=e.code,n=t.$table,r=t.columns,o=t.column,l=n.editConfig,E=n.mouseConfig,s=n.mouseOpts,i=n.fnrOpts;switch(a){case"CLEAR_ALL_SORT":var c=n.getSortColumns();e.disabled=!c.length;break;case"CLEAR_ALL_FILTER":var u=n.getCheckedFilters();e.disabled=!u.length;break;case"CLEAR_ALL_MERGE":var u=n.getMergeCells(),C=n.getMergeFooterItems();e.disabled=!u.length&&!C.length;break;case"CLEAR_MERGE_CELL":C=L(t);e.disabled=!C.length;break;case"EDIT_ROW":e.disabled=!l||!r.some(function(e){return e.editRender});break;case"EDIT_CELL":case"CLEAR_CELL":case"CLEAR_ROW":case"COPY_CELL":case"CUT_CELL":case"PASTE_CELL":case"MERGE_OR_CLEAR":case"MERGE_CELL":case"REVERT_CELL":case"REVERT_ROW":case"INSERT_AT_ROW":case"INSERT_AT_ACTIVED_ROW":case"DELETE_ROW":case"CLEAR_SORT":case"SORT_ASC":case"SORT_DESC":case"CLEAR_FILTER":case"FILTER_CELL":case"EXPORT_ROW":case"OPEN_FIND":case"OPEN_REPLACE":case"HIDDEN_COLUMN":case"FIXED_LEFT_COLUMN":case"FIXED_RIGHT_COLUMN":case"CLEAR_FIXED_COLUMN":if(e.disabled=!o,o){var _=!!o.parentId;switch(a){case"CLEAR_SORT":e.disabled=!o.sortable||!o.order;break;case"SORT_ASC":case"SORT_DESC":e.disabled=!o.sortable;break;case"FILTER_CELL":case"CLEAR_FILTER":e.disabled=!o.filters||!o.filters.length,e.disabled||"CLEAR_FILTER"===a&&(e.disabled=!o.filters.some(function(e){return e.checked}));break;case"OPEN_FIND":e.disabled=!(i&&E&&s.area&&i.isFind);break;case"OPEN_REPLACE":e.disabled=!(i&&E&&s.area&&i.isReplace);break;case"EDIT_CELL":e.disabled=!l||!o.editRender;break;case"COPY_CELL":case"CUT_CELL":case"PASTE_CELL":var R=E&&s.area?n.getCellAreas():[];e.disabled=1<R.length,e.disabled||"PASTE_CELL"===a&&(f=n.$vxe.clipboard,e.disabled=!f||!f.text);break;case"MERGE_OR_CLEAR":case"MERGE_CELL":var f=E&&s.area?n.getCellAreas():[];e.disabled=!f.length||1===f.length&&1===f[0].rows.length&&1===f[0].cols.length||!function(e,t){for(var a=(e=e.$table).getTableData().visibleData,n=e.getTableColumn().visibleColumn,r={},o=0,l=t.length;o<l;o++)for(var E=t[o],s=E.rows,i=E.cols,c=0,u=s.length;c<u;c++)for(var C=s[c],_=a.indexOf(C),R=0,f=i.length;R<f;R++){var L=i[R],L=_+":"+n.indexOf(L);if(r[L])return;r[L]=!0}return 1}(t,f);break;case"FIXED_LEFT_COLUMN":e.disabled=_||"left"===o.fixed;break;case"FIXED_RIGHT_COLUMN":e.disabled=_||"right"===o.fixed;break;case"CLEAR_FIXED_COLUMN":e.disabled=_||!o.fixed}}}}function c(t){return t.options.forEach(function(e){e.forEach(function(e){l(e,t),e.children&&e.children.forEach(function(e){l(e,t)})})}),!0}function u(e){e&&e.copy&&(s=e.copy)}var C={setup:u,install:function(e,t){var a=e.interceptor,e=e.menus;window.XEClipboard&&(s=window.XEClipboard.copy),u(t),a.add("event.showMenu",c),e.mixin(o)}};e.VXETablePluginMenus=C,"undefined"!=typeof window&&window.VXETable&&window.VXETable.use&&window.VXETable.use(C),e.default=C}); |
99
index.ts
@@ -25,10 +25,14 @@ import XEUtils from 'xe-utils' | ||
function handleCopyOrCut(params: MenuLinkParams, isCut?: boolean) { | ||
const { $table, row, column } = params | ||
const { $event, $table, row, column } = params | ||
if (row && column) { | ||
const { $vxe } = $table | ||
let text = '' | ||
if ($table.mouseConfig && $table.mouseOpts.area) { | ||
const clipRest = isCut ? $table.cutCellArea() : $table.copyCellArea() | ||
text = clipRest.text | ||
if (isCut) { | ||
$table.triggerCutCellAreaEvent($event) | ||
} else { | ||
$table.triggerCopyCellAreaEvent($event) | ||
} | ||
text = $vxe.clipboard.text | ||
} else { | ||
const { $vxe } = $table | ||
text = XEUtils.toValueString(XEUtils.get(row, column.property)) | ||
@@ -96,2 +100,3 @@ // 操作内置剪贴板 | ||
} | ||
return beenMerges | ||
} | ||
@@ -222,5 +227,5 @@ | ||
PASTE_CELL(params: MenuLinkParams) { | ||
const { $table, row, column } = params | ||
const { $event, $table, row, column } = params | ||
if ($table.mouseConfig && $table.mouseOpts.area) { | ||
$table.pasteCellArea() | ||
$table.triggerPasteCellAreaEvent($event) | ||
} else { | ||
@@ -239,8 +244,10 @@ const { $vxe } = $table | ||
MERGE_OR_CLEAR(params: MenuLinkParams) { | ||
const { $table } = params | ||
const { $event, $table } = params | ||
const cellAreas = $table.getCellAreas() | ||
const beenMerges = getBeenMerges(params) | ||
let status = false | ||
if (beenMerges.length) { | ||
$table.removeMergeCells(beenMerges) | ||
} else { | ||
status = true | ||
$table.setMergeCells( | ||
@@ -257,2 +264,4 @@ cellAreas.map(({ rows, cols }) => { | ||
} | ||
const targetAreas = cellAreas.map(({ rows, cols }) => ({ rows, cols })) | ||
$table.emitEvent('cell-area-merge', { status, targetAreas }, $event) | ||
}, | ||
@@ -263,3 +272,3 @@ /** | ||
MERGE_CELL(params: MenuLinkParams) { | ||
const { $table } = params | ||
const { $event, $table } = params | ||
const { $vxe } = $table | ||
@@ -287,2 +296,4 @@ const { modal } = $vxe | ||
) | ||
const targetAreas = cellAreas.map(({ rows, cols }) => ({ rows, cols })) | ||
$table.emitEvent('cell-area-merge', { status: true, targetAreas }, $event) | ||
}, | ||
@@ -293,3 +304,7 @@ /** | ||
CLEAR_MERGE_CELL(params: MenuLinkParams) { | ||
handleClearMergeCells(params) | ||
const { $event, $table } = params | ||
const beenMerges = handleClearMergeCells(params) | ||
if (beenMerges.length) { | ||
$table.emitEvent('clear-cell-area-merge', { mergeCells: beenMerges }, $event) | ||
} | ||
}, | ||
@@ -300,5 +315,8 @@ /** | ||
CLEAR_ALL_MERGE(params: MenuLinkParams) { | ||
const { $table } = params | ||
const { $event, $table } = params | ||
const mergeCells = $table.getMergeCells() | ||
const mergeFooterItems = $table.getMergeFooterItems() | ||
$table.clearMergeCells() | ||
$table.clearMergeFooterItems() | ||
$table.emitEvent('clear-merge', { mergeCells, mergeFooterItems }, $event) | ||
}, | ||
@@ -384,15 +402,28 @@ /** | ||
/** | ||
* 清除排序条件 | ||
* 清除所选列排序条件 | ||
*/ | ||
CLEAR_SORT(params: MenuLinkParams) { | ||
const { $table } = params | ||
$table.clearSort() | ||
const { $event, $table, column } = params | ||
if (column) { | ||
$table.triggerSortEvent($event, column, null) | ||
} | ||
}, | ||
/** | ||
* 清除所有排序条件 | ||
*/ | ||
CLEAR_ALL_SORT(params: MenuLinkParams) { | ||
const { $event, $table } = params | ||
const sortList = $table.getSortColumns() | ||
if (sortList.length) { | ||
$table.clearSort() | ||
$table.emitEvent('clear-sort', { sortList }, $event) | ||
} | ||
}, | ||
/** | ||
* 按所选列的值升序 | ||
*/ | ||
SORT_ASC(params: MenuLinkParams) { | ||
const { $table, column } = params | ||
const { $event, $table, column } = params | ||
if (column) { | ||
$table.sort(column.property, 'asc') | ||
$table.triggerSortEvent($event, column, 'asc') | ||
} | ||
@@ -404,5 +435,5 @@ }, | ||
SORT_DESC(params: MenuLinkParams) { | ||
const { $table, column } = params | ||
const { $event, $table, column } = params | ||
if (column) { | ||
$table.sort(column.property, 'desc') | ||
$table.triggerSortEvent($event, column, 'desc') | ||
} | ||
@@ -414,5 +445,6 @@ }, | ||
CLEAR_FILTER(params: MenuLinkParams) { | ||
const { $table, column } = params | ||
const { $event, $table, column } = params | ||
if (column) { | ||
$table.clearFilter(column) | ||
$table.handleClearFilter(column) | ||
$table.confirmFilterEvent($event) | ||
} | ||
@@ -424,4 +456,8 @@ }, | ||
CLEAR_ALL_FILTER(params: MenuLinkParams) { | ||
const { $table } = params | ||
$table.clearFilter() | ||
const { $event, $table } = params | ||
const filterList = $table.getCheckedFilters() | ||
if (filterList.length) { | ||
$table.clearFilter() | ||
$table.dispatchEvent('clear-filter', { filterList }, $event) | ||
} | ||
}, | ||
@@ -497,4 +533,4 @@ /** | ||
OPEN_FIND(params: MenuLinkParams) { | ||
const { $table } = params | ||
$table.openFind() | ||
const { $event, $table } = params | ||
$table.triggerFNROpenEvent($event, 'find') | ||
}, | ||
@@ -505,4 +541,4 @@ /** | ||
OPEN_REPLACE(params: MenuLinkParams) { | ||
const { $table } = params | ||
$table.openReplace() | ||
const { $event, $table } = params | ||
$table.triggerFNROpenEvent($event, 'replace') | ||
}, | ||
@@ -558,8 +594,10 @@ /** | ||
switch (code) { | ||
case 'CLEAR_SORT': { | ||
item.disabled = !columns.some((column) => column.sortable && column.order) | ||
case 'CLEAR_ALL_SORT': { | ||
const sortList = $table.getSortColumns() | ||
item.disabled = !sortList.length | ||
break | ||
} | ||
case 'CLEAR_ALL_FILTER': { | ||
item.disabled = !columns.some((column) => column.filters && column.filters.some((option) => option.checked)) | ||
const filterList = $table.getCheckedFilters() | ||
item.disabled = !filterList.length | ||
break | ||
@@ -595,2 +633,3 @@ } | ||
case 'DELETE_ROW': | ||
case 'CLEAR_SORT': | ||
case 'SORT_ASC': | ||
@@ -611,2 +650,6 @@ case 'SORT_DESC': | ||
switch (code) { | ||
case 'CLEAR_SORT': { | ||
item.disabled = !column.sortable || !column.order | ||
break | ||
} | ||
case 'SORT_ASC': | ||
@@ -613,0 +656,0 @@ case 'SORT_DESC': |
{ | ||
"name": "vxe-table-plugin-menus", | ||
"version": "1.6.2", | ||
"version": "2.0.0", | ||
"description": "基于 vxe-table 的表格插件,提供实用的快捷菜单集", | ||
@@ -51,7 +51,7 @@ "scripts": { | ||
"vue": "^2.6.12", | ||
"vxe-table": "^3.3.0", | ||
"vxe-table": "^3.3.5", | ||
"xe-utils": "^3.2.1" | ||
}, | ||
"peerDependencies": { | ||
"vxe-table": "^2.10.0 || ^3.2.0" | ||
"vxe-table": "^3.3.5" | ||
}, | ||
@@ -58,0 +58,0 @@ "repository": { |
@@ -68,3 +68,4 @@ # vxe-table-plugin-menus | ||
| DELETE_ALL | 移除所有行数据 | — | | ||
| CLEAR_SORT | 清除排序条件 | — | | ||
| CLEAR_SORT | 清除所选列排序条件 | — | | ||
| CLEAR_ALL_SORT | 清除所有排序条件 | — | | ||
| SORT_ASC | 按所选列的值升序 | — | | ||
@@ -71,0 +72,0 @@ | SORT_DESC | 按所选列的值倒序 | — | |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
196173
2879
127