vxe-table-plugin-menus
Advanced tools
Comparing version 3.2.2 to 3.3.0
@@ -11,3 +11,3 @@ (function (global, factory) { | ||
factory(mod.exports, global.XEUtils); | ||
global.VXETablePluginMenus = mod.exports; | ||
global.VXETablePluginMenus = mod.exports.default; | ||
} | ||
@@ -28,12 +28,2 @@ })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _xeUtils) { | ||
var columnIndexOf = function columnIndexOf(cols, column) { | ||
return _xeUtils["default"].findIndexOf(cols, function (item) { | ||
return item.id === column.id; | ||
}); | ||
}; | ||
var rowIndexOf = function rowIndexOf($table, rows, row) { | ||
return $table.findRowIndexOf(rows, row); | ||
}; | ||
function handleFixedColumn(fixed) { | ||
@@ -94,12 +84,5 @@ return { | ||
if (row && column) { | ||
var props = $table.props; | ||
var mouseConfig = props.mouseConfig; | ||
var _$table$getComputeMap = $table.getComputeMaps(), | ||
computeMouseOpts = _$table$getComputeMap.computeMouseOpts; | ||
var mouseOpts = computeMouseOpts.value; | ||
var text = ''; | ||
if (mouseConfig && mouseOpts.area) { | ||
if ($table.mouseConfig && $table.mouseOpts.area) { | ||
if (isCut) { | ||
@@ -112,3 +95,3 @@ $table.triggerCutCellAreaEvent($event); | ||
var _ref = VXETableInstance.globalStore || VXETableInstance.config, | ||
var _ref = VXETableInstance.globalStore ? VXETableInstance.globalStore : $table.$vxe, | ||
clipboard = _ref.clipboard; | ||
@@ -126,4 +109,4 @@ | ||
}; | ||
} else if (VXETableInstance.config) { | ||
VXETableInstance.config.clipboard = { | ||
} else if ($table.$vxe) { | ||
$table.$vxe.clipboard = { | ||
text: text, | ||
@@ -162,7 +145,7 @@ html: '' | ||
var offsetRow = rows[rIndex]; | ||
var orIndex = rowIndexOf($table, visibleData, offsetRow); | ||
var orIndex = visibleData.indexOf(offsetRow); | ||
for (var cIndex = 0, colSize = cols.length; cIndex < colSize; cIndex++) { | ||
var offsetColumn = cols[cIndex]; | ||
var ocIndex = columnIndexOf(visibleColumn, offsetColumn); | ||
var ocIndex = visibleColumn.indexOf(offsetColumn); | ||
var key = orIndex + ':' + ocIndex; | ||
@@ -184,10 +167,3 @@ | ||
var $table = params.$table; | ||
var props = $table.props; | ||
var mouseConfig = props.mouseConfig; | ||
var _$table$getComputeMap2 = $table.getComputeMaps(), | ||
computeMouseOpts = _$table$getComputeMap2.computeMouseOpts; | ||
var mouseOpts = computeMouseOpts.value; | ||
var _$table$getTableData2 = $table.getTableData(), | ||
@@ -199,3 +175,3 @@ visibleData = _$table$getTableData2.visibleData; | ||
var cellAreas = mouseConfig && mouseOpts.area ? $table.getCellAreas() : []; | ||
var cellAreas = $table.mouseConfig && $table.mouseOpts.area ? $table.getCellAreas() : []; | ||
var mergeList = $table.getMergeCells(); | ||
@@ -210,6 +186,6 @@ return mergeList.filter(function (_ref2) { | ||
cols = areaItem.cols; | ||
var startRowIndex = rowIndexOf($table, visibleData, rows[0]); | ||
var endRowIndex = rowIndexOf($table, visibleData, rows[rows.length - 1]); | ||
var startColIndex = columnIndexOf(visibleColumn, cols[0]); | ||
var endColIndex = columnIndexOf(visibleColumn, cols[cols.length - 1]); | ||
var startRowIndex = visibleData.indexOf(rows[0]); | ||
var endRowIndex = visibleData.indexOf(rows[rows.length - 1]); | ||
var startColIndex = visibleColumn.indexOf(cols[0]); | ||
var endColIndex = visibleColumn.indexOf(cols[cols.length - 1]); | ||
return mergeRowIndex >= startRowIndex && mergeRowIndex + mergeRowspan - 1 <= endRowIndex && mergeColIndex >= startColIndex && mergeColIndex + mergeColspan - 1 <= endColIndex; | ||
@@ -231,10 +207,16 @@ }); | ||
function abandoned(code, newCode) { | ||
console.warn("The code \"".concat(code, "\" has been scrapped, please use \"").concat(newCode, "\"")); | ||
} | ||
function checkPrivilege(item, params) { | ||
var code = item.code; | ||
var $table = params.$table, | ||
columns = params.columns, | ||
row = params.row, | ||
column = params.column; | ||
var props = $table.props; | ||
var editConfig = props.editConfig, | ||
mouseConfig = props.mouseConfig; | ||
var editConfig = $table.editConfig, | ||
mouseConfig = $table.mouseConfig, | ||
mouseOpts = $table.mouseOpts, | ||
fnrOpts = $table.fnrOpts; | ||
@@ -271,2 +253,10 @@ switch (code) { | ||
case 'EDIT_ROW': | ||
{ | ||
item.disabled = !editConfig || !columns.some(function (column) { | ||
return column.editRender; | ||
}); | ||
break; | ||
} | ||
case 'EDIT_CELL': | ||
@@ -301,6 +291,2 @@ case 'CLEAR_CELL': | ||
if (column) { | ||
var _$table$getComputeMap3 = $table.getComputeMaps(), | ||
computeMouseOpts = _$table$getComputeMap3.computeMouseOpts; | ||
var mouseOpts = computeMouseOpts.value; | ||
var isChildCol = !!column.parentId; | ||
@@ -317,21 +303,25 @@ | ||
case 'SORT_DESC': | ||
item.disabled = !column.sortable; | ||
break; | ||
{ | ||
item.disabled = !column.sortable; | ||
break; | ||
} | ||
case 'FILTER_CELL': | ||
case 'CLEAR_FILTER': | ||
item.disabled = !column.filters || !column.filters.length; | ||
{ | ||
item.disabled = !column.filters || !column.filters.length; | ||
if (!item.disabled) { | ||
switch (code) { | ||
case 'CLEAR_FILTER': | ||
item.disabled = !column.filters.some(function (option) { | ||
return option.checked; | ||
}); | ||
break; | ||
if (!item.disabled) { | ||
switch (code) { | ||
case 'CLEAR_FILTER': | ||
item.disabled = !column.filters.some(function (option) { | ||
return option.checked; | ||
}); | ||
break; | ||
} | ||
} | ||
break; | ||
} | ||
break; | ||
case 'REVERT_CELL': | ||
@@ -350,5 +340,10 @@ { | ||
case 'OPEN_FIND': | ||
{ | ||
item.disabled = !(fnrOpts && mouseConfig && mouseOpts.area && fnrOpts.isFind); | ||
break; | ||
} | ||
case 'OPEN_REPLACE': | ||
{ | ||
item.disabled = !(mouseConfig && mouseOpts.area); | ||
item.disabled = !(fnrOpts && mouseConfig && mouseOpts.area && fnrOpts.isReplace); | ||
break; | ||
@@ -375,3 +370,3 @@ } | ||
// 兼容老版本 | ||
var _ref3 = VXETableInstance.globalStore || VXETableInstance.config, | ||
var _ref3 = VXETableInstance.globalStore ? VXETableInstance.globalStore : $table.$vxe, | ||
clipboard = _ref3.clipboard; | ||
@@ -431,3 +426,3 @@ | ||
function pluginSetup(options) { | ||
function setup(options) { | ||
if (options && options.copy) { | ||
@@ -438,3 +433,3 @@ handleCopy = options.copy; | ||
/** | ||
* 基于 vxe-table 表格的扩展插件,提供实用的快捷菜单配置 | ||
* 基于 vxe-table 表格的增强插件,提供实用的快捷菜单集 | ||
*/ | ||
@@ -444,11 +439,12 @@ | ||
var VXETablePluginMenus = { | ||
setup: pluginSetup, | ||
setup: setup, | ||
install: function install(vxetable, options) { | ||
VXETableInstance = vxetable; // 检查版本 | ||
if (!/^(4)\./.test(vxetable.version)) { | ||
console.error('[vxe-table-plugin-menus] Version vxe-table 4.x is required'); | ||
if (!/^(2|3)\./.test(vxetable.version)) { | ||
console.error('[vxe-table-plugin-menus] Version vxe-table 3.x is required'); | ||
} | ||
pluginSetup(options); | ||
setup(options); | ||
vxetable.interceptor.add('event.showMenu', handlePrivilegeEvent); | ||
vxetable.menus.mixin({ | ||
@@ -465,11 +461,3 @@ /** | ||
if (row && column) { | ||
var props = $table.props; | ||
var mouseConfig = props.mouseConfig; | ||
var _$table$getComputeMap4 = $table.getComputeMaps(), | ||
computeMouseOpts = _$table$getComputeMap4.computeMouseOpts; | ||
var mouseOpts = computeMouseOpts.value; | ||
if (mouseConfig && mouseOpts.area) { | ||
if ($table.mouseConfig && $table.mouseOpts.area) { | ||
var cellAreas = $table.getCellAreas(); | ||
@@ -508,2 +496,10 @@ | ||
}, | ||
// 已废弃 | ||
CLEAR_SELECTED_ROW: { | ||
menuMethod: function menuMethod(params) { | ||
abandoned('CLEAR_SELECTED_ROW', 'CLEAR_CHECKBOX_ROW'); | ||
var $table = params.$table; | ||
$table.clearData($table.getCheckboxRecords()); | ||
} | ||
}, | ||
@@ -540,11 +536,3 @@ /** | ||
if (row && column) { | ||
var props = $table.props; | ||
var mouseConfig = props.mouseConfig; | ||
var _$table$getComputeMap5 = $table.getComputeMaps(), | ||
computeMouseOpts = _$table$getComputeMap5.computeMouseOpts; | ||
var mouseOpts = computeMouseOpts.value; | ||
if (mouseConfig && mouseOpts.area) { | ||
if ($table.mouseConfig && $table.mouseOpts.area) { | ||
var cellAreas = $table.getCellAreas(); | ||
@@ -583,2 +571,10 @@ | ||
}, | ||
// 已废弃 | ||
REVERT_SELECTED_ROW: { | ||
menuMethod: function menuMethod(params) { | ||
abandoned('REVERT_SELECTED_ROW', 'REVERT_CHECKBOX_ROW'); | ||
var $table = params.$table; | ||
$table.revertData($table.getCheckboxRecords()); | ||
} | ||
}, | ||
@@ -632,15 +628,8 @@ /** | ||
column = params.column; | ||
var props = $table.props; | ||
var mouseConfig = props.mouseConfig; | ||
var _$table$getComputeMap6 = $table.getComputeMaps(), | ||
computeMouseOpts = _$table$getComputeMap6.computeMouseOpts; | ||
var mouseOpts = computeMouseOpts.value; | ||
if (mouseConfig && mouseOpts.area) { | ||
if ($table.mouseConfig && $table.mouseOpts.area) { | ||
$table.triggerPasteCellAreaEvent($event); | ||
} else { | ||
// 兼容老版本 | ||
var _ref4 = vxetable.globalStore || vxetable.config, | ||
var _ref4 = vxetable.globalStore ? vxetable.globalStore : $table.$vxe, | ||
clipboard = _ref4.clipboard; // 读取内置剪贴板 | ||
@@ -691,3 +680,3 @@ | ||
}); | ||
$table.dispatchEvent('cell-area-merge', { | ||
$table.emitEvent('cell-area-merge', { | ||
status: status, | ||
@@ -750,3 +739,3 @@ targetAreas: targetAreas | ||
}); | ||
$table.dispatchEvent('cell-area-merge', { | ||
$table.emitEvent('cell-area-merge', { | ||
status: true, | ||
@@ -768,3 +757,3 @@ targetAreas: targetAreas | ||
if (beenMerges.length) { | ||
$table.dispatchEvent('clear-cell-area-merge', { | ||
$table.emitEvent('clear-cell-area-merge', { | ||
mergeCells: beenMerges | ||
@@ -787,3 +776,3 @@ }, $event); | ||
$table.clearMergeFooterItems(); | ||
$table.dispatchEvent('clear-merge', { | ||
$table.emitEvent('clear-merge', { | ||
mergeCells: mergeCells, | ||
@@ -849,4 +838,3 @@ mergeFooterItems: mergeFooterItems | ||
column = params.column; | ||
var args = menu.params || []; // [{}, 'field'] | ||
var args = menu.params || []; | ||
$table.insert(args[0]).then(function (_ref10) { | ||
@@ -891,4 +879,3 @@ var row = _ref10.row; | ||
if (row) { | ||
var args = menu.params || []; // [{}, 'field'] | ||
var args = menu.params || []; | ||
$table.insertAt(args[0], row).then(function (_ref11) { | ||
@@ -921,2 +908,10 @@ var row = _ref11.row; | ||
}, | ||
// 已废弃 | ||
DELETE_SELECTED_ROW: { | ||
menuMethod: function menuMethod(params) { | ||
abandoned('DELETE_SELECTED_ROW', 'DELETE_CHECKBOX_ROW'); | ||
var $table = params.$table; | ||
$table.removeCheckboxRow(); | ||
} | ||
}, | ||
@@ -969,3 +964,3 @@ /** | ||
$table.clearSort(); | ||
$table.dispatchEvent('clear-sort', { | ||
$table.emitEvent('clear-sort', { | ||
sortList: sortList | ||
@@ -1051,3 +1046,3 @@ }, $event); | ||
if (row && column) { | ||
var field = column.field, | ||
var property = column.property, | ||
filters = column.filters; | ||
@@ -1057,3 +1052,3 @@ | ||
var option = filters[0]; | ||
option.data = _xeUtils["default"].get(row, field); | ||
option.data = _xeUtils["default"].get(row, property); | ||
option.checked = true; | ||
@@ -1083,2 +1078,14 @@ $table.updateData(); | ||
}, | ||
// 已废弃 | ||
EXPORT_SELECTED_ROW: { | ||
menuMethod: function menuMethod(params) { | ||
abandoned('EXPORT_SELECTED_ROW', 'EXPORT_CHECKBOX_ROW'); | ||
var $table = params.$table, | ||
menu = params.menu; | ||
var opts = { | ||
data: $table.getCheckboxRecords() | ||
}; | ||
$table.exportData(_xeUtils["default"].assign(opts, menu.params[0])); | ||
} | ||
}, | ||
@@ -1120,2 +1127,14 @@ /** | ||
}, | ||
// 已废弃 | ||
PRINT_SELECTED_ROW: { | ||
menuMethod: function menuMethod(params) { | ||
abandoned('PRINT_SELECTED_ROW', 'PRINT_CHECKBOX_ROW'); | ||
var $table = params.$table, | ||
menu = params.menu; | ||
var opts = { | ||
data: $table.getCheckboxRecords() | ||
}; | ||
$table.print(_xeUtils["default"].assign(opts, menu.params)); | ||
} | ||
}, | ||
@@ -1185,3 +1204,3 @@ /** | ||
*/ | ||
CLEAR_FIXED_COLUMN: handleFixedColumn(null), | ||
CLEAR_FIXED_COLUMN: handleFixedColumn(''), | ||
@@ -1224,3 +1243,2 @@ /** | ||
}); | ||
vxetable.interceptor.add('event.showMenu', handlePrivilegeEvent); | ||
} | ||
@@ -1227,0 +1245,0 @@ }; |
@@ -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={},e.XEUtils),e.VXETablePluginMenus=t)}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,function(e,i){"use strict";var C,u;Object.defineProperty(e,"__esModule",{value:!0}),e.default=e.VXETablePluginMenus=void 0,i=(r=i)&&r.__esModule?r:{default:r};function R(e,t){return i.default.findIndexOf(e,function(e){return e.id===t.id})}function _(e,t,a){return e.findRowIndexOf(t,a)}var n;function t(a){return{menuMethod:function(e){var t=e.$table,e=e.column;i.default.eachTree([e],function(e){e.fixed=a}),t.refreshColumn()}}}function c(e){var t,a;try{t=e,n||((n=document.createElement("textarea")).id="$XECopy",(a=n.style).width="48px",a.height="24px",a.position="fixed",a.zIndex="0",a.left="-500px",a.top="-500px",document.body.appendChild(n)),n.value=null==t?"":""+t,n.select(),n.setSelectionRange(0,n.value.length),document.execCommand("copy"),n.blur()}catch(e){}}function a(e,t){var a,n,o,l=e.$event,r=e.$table,s=e.row,e=e.column;s&&e&&(a=r.props.mouseConfig,n=r.getComputeMaps().computeMouseOpts.value,o="",a&&n.area?(t?r.triggerCutCellAreaEvent(l):r.triggerCopyCellAreaEvent(l),o=(C.globalStore||C.config).clipboard.text):(o=i.default.toValueString(i.default.get(s,e.field)),C.globalStore?C.globalStore.clipboard={text:o,html:""}:C.config&&(C.config.clipboard={text:o,html:""})),(i.default.isFunction(u)?u:c)(o))}function m(e){var i=e.$table,e=i.props.mouseConfig,t=i.getComputeMaps().computeMouseOpts.value,u=i.getTableData().visibleData,c=i.getTableColumn().visibleColumn,a=e&&t.area?i.getCellAreas():[];return i.getMergeCells().filter(function(e){var o=e.row,l=e.col,r=e.rowspan,s=e.colspan;return a.some(function(e){var t=e.rows,e=e.cols,a=_(i,u,t[0]),t=_(i,u,t[t.length-1]),n=R(c,e[0]),e=R(c,e[e.length-1]);return a<=o&&o+r-1<=t&&n<=l&&l+s-1<=e})})}function s(e){var t=e.$table,e=m(e);return e.length&&t.removeMergeCells(e),e}function o(e,t){var a=e.code,n=t.$table,o=t.row,l=t.column,r=n.props,s=r.editConfig,i=r.mouseConfig;switch(a){case"CLEAR_ALL_SORT":var u=n.getSortColumns();e.disabled=!u.length;break;case"CLEAR_ALL_FILTER":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":u=m(t);e.disabled=!u.length;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=!l,l){var E=n.getComputeMaps().computeMouseOpts.value,d=!!l.parentId;switch(a){case"CLEAR_SORT":e.disabled=!l.sortable||!l.order;break;case"SORT_ASC":case"SORT_DESC":e.disabled=!l.sortable;break;case"FILTER_CELL":case"CLEAR_FILTER":e.disabled=!l.filters||!l.filters.length,e.disabled||"CLEAR_FILTER"===a&&(e.disabled=!l.filters.some(function(e){return e.checked}));break;case"REVERT_CELL":e.disabled=!o||!l.field||!n.isUpdateByRow(o,l.field);break;case"REVERT_ROW":e.disabled=!o||!l.field||!n.isUpdateByRow(o);break;case"OPEN_FIND":case"OPEN_REPLACE":e.disabled=!(i&&E.area);break;case"EDIT_CELL":e.disabled=!s||!l.editRender;break;case"COPY_CELL":case"CUT_CELL":case"PASTE_CELL":var f=i&&E.area?n.getCellAreas():[];e.disabled=1<f.length,e.disabled||"PASTE_CELL"===a&&(f=(C.globalStore||C.config).clipboard,e.disabled=!f||!f.text);break;case"MERGE_OR_CLEAR":case"MERGE_CELL":f=i&&E.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.$table,n=a.getTableData().visibleData,o=a.getTableColumn().visibleColumn,l={},r=0,s=t.length;r<s;r++)for(var i=t[r],u=i.rows,c=i.cols,E=0,d=u.length;E<d;E++)for(var f=u[E],C=_(a,n,f),m=0,g=c.length;m<g;m++){var L=c[m],L=C+":"+R(o,L);if(l[L])return;l[L]=!0}return 1}(t,f);break;case"FIXED_LEFT_COLUMN":e.disabled=d||"left"===l.fixed;break;case"FIXED_RIGHT_COLUMN":e.disabled=d||"right"===l.fixed;break;case"CLEAR_FIXED_COLUMN":e.disabled=d||!l.fixed}}}}function l(t){return t.options.forEach(function(e){e.forEach(function(e){o(e,t),e.children&&e.children.forEach(function(e){o(e,t)})})}),!0}function E(e){e&&e.copy&&(u=e.copy)}var r={setup:E,install:function(r,e){C=r,/^(4)\./.test(r.version)||console.error("[vxe-table-plugin-menus] Version vxe-table 4.x is required"),E(e),r.menus.mixin({CLEAR_CELL:{menuMethod:function(e){var t,a,n=e.$table,o=e.row,e=e.column;o&&e&&(a=n.props.mouseConfig,t=n.getComputeMaps().computeMouseOpts.value,a&&t.area?(a=n.getCellAreas())&&a.length&&a.forEach(function(e){var a=e.rows;e.cols.forEach(function(t){a.forEach(function(e){n.clearData(e,t.field)})})}):n.clearData(o,e.field))}},CLEAR_ROW:{menuMethod:function(e){var t=e.$table,e=e.row;e&&t.clearData(e)}},CLEAR_CHECKBOX_ROW:{menuMethod:function(e){e=e.$table;e.clearData(e.getCheckboxRecords())}},CLEAR_ALL:{menuMethod:function(e){e.$table.clearData()}},REVERT_CELL:{menuMethod:function(e){var t,a,n=e.$table,o=e.row,e=e.column;o&&e&&(a=n.props.mouseConfig,t=n.getComputeMaps().computeMouseOpts.value,a&&t.area?(a=n.getCellAreas())&&a.length&&a.forEach(function(e){var a=e.rows;e.cols.forEach(function(t){a.forEach(function(e){n.revertData(e,t.field)})})}):n.revertData(o,e.field))}},REVERT_ROW:{menuMethod:function(e){var t=e.$table,e=e.row;e&&t.revertData(e)}},REVERT_CHECKBOX_ROW:{menuMethod:function(e){e=e.$table;e.revertData(e.getCheckboxRecords())}},REVERT_ALL:{menuMethod:function(e){e.$table.revertData()}},COPY_CELL:{menuMethod:function(e){a(e)}},CUT_CELL:{menuMethod:function(e){a(e,!0)}},PASTE_CELL:{menuMethod:function(e){var t=e.$event,a=e.$table,n=e.row,e=e.column,o=a.props.mouseConfig,l=a.getComputeMaps().computeMouseOpts.value;o&&l.area?a.triggerPasteCellAreaEvent(t):(o=(r.globalStore||r.config).clipboard)&&o.text&&i.default.set(n,e.field,o.text)}},MERGE_OR_CLEAR:{menuMethod:function(e){var t=e.$event,a=e.$table,n=a.getCellAreas(),e=m(e),o=!1,e=(e.length?a.removeMergeCells(e):(o=!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.map(function(e){return{rows:e.rows,cols:e.cols}}));a.dispatchEvent("cell-area-merge",{status:o,targetAreas:e},t)}},MERGE_CELL:{menuMethod:function(e){var t=e.$event,a=e.$table,n=a.getTableData().visibleData,o=a.getTableColumn().visibleColumn,l=a.getCellAreas();s(e),l.some(function(e){var t=e.rows,e=e.cols;return t.length===n.length||e.length===o.length})?r.modal&&r.modal.message({content:r.t("vxe.pro.area.mergeErr"),status:"error",id:"operErr"}):(a.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}})),e=l.map(function(e){return{rows:e.rows,cols:e.cols}}),a.dispatchEvent("cell-area-merge",{status:!0,targetAreas:e},t))}},CLEAR_MERGE_CELL:{menuMethod:function(e){var t=e.$event,a=e.$table,e=s(e);e.length&&a.dispatchEvent("clear-cell-area-merge",{mergeCells:e},t)}},CLEAR_ALL_MERGE:{menuMethod:function(e){var t=e.$event,e=e.$table,a=e.getMergeCells(),n=e.getMergeFooterItems();e.clearMergeCells(),e.clearMergeFooterItems(),e.dispatchEvent("clear-merge",{mergeCells:a,mergeFooterItems:n},t)}},EDIT_CELL:{menuMethod:function(e){var t=e.$table,a=e.row,e=e.column;t.setEditCell?t.setEditCell(a,e):t.setActiveCell(a,e.field)}},EDIT_ROW:{menuMethod:function(e){var t=e.$table,e=e.row;t.setEditRow?t.setEditRow(e):t.setActiveRow(e)}},INSERT_ROW:{menuMethod:function(e){var t=e.$table,e=e.menu;t.insert(e.params)}},INSERT_ACTIVED_ROW:{menuMethod:function(e){var t=e.$table,a=e.menu,n=e.column,o=a.params||[];t.insert(o[0]).then(function(e){e=e.row;t.setEditCell?t.setEditCell(e,o[1]||n):t.setActiveCell(e,o[1]||n.field)})}},INSERT_AT_ROW:{menuMethod:function(e){var t=e.$table,a=e.menu,e=e.row;e&&t.insertAt(a.params,e)}},INSERT_AT_ACTIVED_ROW:{menuMethod:function(e){var t,a=e.$table,n=e.menu,o=e.row,l=e.column;o&&(t=n.params||[],a.insertAt(t[0],o).then(function(e){e=e.row;a.setEditCell?a.setEditCell(e,t[1]||l):a.setActiveCell(e,t[1]||l.field)}))}},DELETE_ROW:{menuMethod:function(e){var t=e.$table,e=e.row;e&&t.remove(e)}},DELETE_CHECKBOX_ROW:{menuMethod:function(e){e.$table.removeCheckboxRow()}},DELETE_ALL:{menuMethod:function(e){e.$table.remove()}},CLEAR_SORT:{menuMethod:function(e){var t=e.$event,a=e.$table,e=e.column;e&&a.triggerSortEvent(t,e,null)}},CLEAR_ALL_SORT:{menuMethod:function(e){var t=e.$event,e=e.$table,a=e.getSortColumns();a.length&&(e.clearSort(),e.dispatchEvent("clear-sort",{sortList:a},t))}},SORT_ASC:{menuMethod:function(e){var t=e.$event,a=e.$table,e=e.column;e&&a.triggerSortEvent(t,e,"asc")}},SORT_DESC:{menuMethod:function(e){var t=e.$event,a=e.$table,e=e.column;e&&a.triggerSortEvent(t,e,"desc")}},CLEAR_FILTER:{menuMethod:function(e){var t=e.$event,a=e.$table,e=e.column;e&&(a.handleClearFilter(e),a.confirmFilterEvent(t))}},CLEAR_ALL_FILTER:{menuMethod:function(e){var t=e.$event,e=e.$table,a=e.getCheckedFilters();a.length&&(e.clearFilter(),e.dispatchEvent("clear-filter",{filterList:a},t))}},FILTER_CELL:{menuMethod:function(e){var t,a=e.$table,n=e.row,e=e.column;n&&e&&(t=e.field,(e=e.filters).length&&((e=e[0]).data=i.default.get(n,t),e.checked=!0,a.updateData()))}},EXPORT_ROW:{menuMethod:function(e){var t=e.$table,a=e.menu,e=e.row;e&&t.exportData(i.default.assign({data:[e]},a.params[0]))}},EXPORT_CHECKBOX_ROW:{menuMethod:function(e){var t=e.$table,e=e.menu,a={data:t.getCheckboxRecords()};t.exportData(i.default.assign(a,e.params[0]))}},EXPORT_ALL:{menuMethod:function(e){var t=e.$table,e=e.menu;t.exportData(e.params)}},PRINT_ALL:{menuMethod:function(e){var t=e.$table,e=e.menu;t.print(e.params)}},PRINT_CHECKBOX_ROW:{menuMethod:function(e){var t=e.$table,e=e.menu,a={data:t.getCheckboxRecords()};t.print(i.default.assign(a,e.params))}},OPEN_FIND:{menuMethod:function(e){var t=e.$event;e.$table.triggerFNROpenEvent(t,"find")}},OPEN_REPLACE:{menuMethod:function(e){var t=e.$event;e.$table.triggerFNROpenEvent(t,"replace")}},HIDDEN_COLUMN:{menuMethod:function(e){var t=e.$table,e=e.column;e&&t.hideColumn(e)}},FIXED_LEFT_COLUMN:t("left"),FIXED_RIGHT_COLUMN:t("right"),CLEAR_FIXED_COLUMN:t(null),RESET_COLUMN:{menuMethod:function(e){e.$table.resetColumn({visible:!0,resizable:!1})}},RESET_RESIZABLE:{menuMethod:function(e){e.$table.resetColumn({visible:!1,resizable:!0})}},RESET_ALL:{menuMethod:function(e){e.$table.resetColumn(!0)}}}),r.interceptor.add("event.showMenu",l)}};e.VXETablePluginMenus=r,"undefined"!=typeof window&&window.VXETable&&window.VXETable.use&&window.VXETable.use(r);e.default=r}); | ||
!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,s){"use strict";var t,m,l,o;function a(a){return{menuMethod:function(e){var t=e.$table,e=e.column;s.default.eachTree([e],function(e){e.fixed=a}),t.refreshColumn()}}}function i(e){var t,a,n=!1;try{t=e,o||((o=document.createElement("textarea")).id="$XECopy",(a=o.style).width="48px",a.height="24px",a.position="fixed",a.zIndex="0",a.left="-500px",a.top="-500px",document.body.appendChild(o)),o.value=null==t?"":""+t,o.select(),o.setSelectionRange(0,o.value.length),n=document.execCommand("copy"),o.blur()}catch(e){}return n}function n(e,t){var a=e.$event,n=e.$table,o=e.row,r=e.column;o&&r&&(e="",n.mouseConfig&&n.mouseOpts.area?(t?n.triggerCutCellAreaEvent(a):n.triggerCopyCellAreaEvent(a),e=(m.globalStore||n.$vxe).clipboard.text):(e=s.default.toValueString(s.default.get(o,r.field)),m.globalStore?m.globalStore.clipboard={text:e,html:""}:n.$vxe&&(n.$vxe.clipboard={text:e,html:""})),(s.default.isFunction(l)?l:i)(e))}function L(e){var e=e.$table,i=e.getTableData().visibleData,E=e.getTableColumn().visibleColumn,t=e.mouseConfig&&e.mouseOpts.area?e.getCellAreas():[];return e.getMergeCells().filter(function(e){var o=e.row,r=e.col,l=e.rowspan,s=e.colspan;return t.some(function(e){var t=e.rows,a=e.cols,n=i.indexOf(t[0]),e=i.indexOf(t[t.length-1]),t=E.indexOf(a[0]),a=E.indexOf(a[a.length-1]);return n<=o&&o+l-1<=e&&t<=r&&r+s-1<=a})})}function E(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,'"'))}function c(e,t){var a=e.code,n=t.$table,o=t.columns,r=t.row,l=t.column,s=n.editConfig,i=n.mouseConfig,E=n.mouseOpts,c=n.fnrOpts;switch(a){case"CLEAR_ALL_SORT":var u=n.getSortColumns();e.disabled=!u.length;break;case"CLEAR_ALL_FILTER":var d=n.getCheckedFilters();e.disabled=!d.length;break;case"CLEAR_ALL_MERGE":var d=n.getMergeCells(),C=n.getMergeFooterItems();e.disabled=!d.length&&!C.length;break;case"CLEAR_MERGE_CELL":C=L(t);e.disabled=!C.length;break;case"EDIT_ROW":e.disabled=!s||!o.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=!l,l){var f=!!l.parentId;switch(a){case"CLEAR_SORT":e.disabled=!l.sortable||!l.order;break;case"SORT_ASC":case"SORT_DESC":e.disabled=!l.sortable;break;case"FILTER_CELL":case"CLEAR_FILTER":e.disabled=!l.filters||!l.filters.length,e.disabled||"CLEAR_FILTER"===a&&(e.disabled=!l.filters.some(function(e){return e.checked}));break;case"REVERT_CELL":e.disabled=!r||!l.field||!n.isUpdateByRow(r,l.field);break;case"REVERT_ROW":e.disabled=!r||!l.field||!n.isUpdateByRow(r);break;case"OPEN_FIND":e.disabled=!(c&&i&&E.area&&c.isFind);break;case"OPEN_REPLACE":e.disabled=!(c&&i&&E.area&&c.isReplace);break;case"EDIT_CELL":e.disabled=!s||!l.editRender;break;case"COPY_CELL":case"CUT_CELL":case"PASTE_CELL":var R=i&&E.area?n.getCellAreas():[];e.disabled=1<R.length,e.disabled||"PASTE_CELL"===a&&(_=(m.globalStore||n.$vxe).clipboard,e.disabled=!_||!_.text);break;case"MERGE_OR_CLEAR":case"MERGE_CELL":var _=i&&E.area?n.getCellAreas():[];e.disabled=!_.length||1===_.length&&1===_[0].rows.length&&1===_[0].cols.length||!function(e,t){for(var a=(e=e.$table).getTableData().visibleData,n=e.getTableColumn().visibleColumn,o={},r=0,l=t.length;r<l;r++)for(var s=t[r],i=s.rows,E=s.cols,c=0,u=i.length;c<u;c++)for(var d=i[c],C=a.indexOf(d),f=0,R=E.length;f<R;f++){var _=E[f],_=C+":"+n.indexOf(_);if(o[_])return;o[_]=!0}return 1}(t,_);break;case"FIXED_LEFT_COLUMN":e.disabled=f||"left"===l.fixed;break;case"FIXED_RIGHT_COLUMN":e.disabled=f||"right"===l.fixed;break;case"CLEAR_FIXED_COLUMN":e.disabled=f||!l.fixed}}}}function u(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 d(e){e&&e.copy&&(l=e.copy)}Object.defineProperty(e,"__esModule",{value:!0}),e.default=e.VXETablePluginMenus=void 0,s=(t=s)&&t.__esModule?t:{default:t};var C={setup:d,install:function(l,e){/^(2|3)\./.test((m=l).version)||console.error("[vxe-table-plugin-menus] Version vxe-table 3.x is required"),d(e),l.interceptor.add("event.showMenu",u),l.menus.mixin({CLEAR_CELL:{menuMethod: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.field)})})}):n.clearData(t,a.field))}},CLEAR_ROW:{menuMethod:function(e){var t=e.$table,e=e.row;e&&t.clearData(e)}},CLEAR_SELECTED_ROW:{menuMethod:function(e){r("CLEAR_SELECTED_ROW","CLEAR_CHECKBOX_ROW");e=e.$table;e.clearData(e.getCheckboxRecords())}},CLEAR_CHECKBOX_ROW:{menuMethod:function(e){e=e.$table;e.clearData(e.getCheckboxRecords())}},CLEAR_ALL:{menuMethod:function(e){e.$table.clearData()}},REVERT_CELL:{menuMethod: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.field)})})}):n.revertData(t,a.field))}},REVERT_ROW:{menuMethod:function(e){var t=e.$table,e=e.row;e&&t.revertData(e)}},REVERT_SELECTED_ROW:{menuMethod:function(e){r("REVERT_SELECTED_ROW","REVERT_CHECKBOX_ROW");e=e.$table;e.revertData(e.getCheckboxRecords())}},REVERT_CHECKBOX_ROW:{menuMethod:function(e){e=e.$table;e.revertData(e.getCheckboxRecords())}},REVERT_ALL:{menuMethod:function(e){e.$table.revertData()}},COPY_CELL:{menuMethod:function(e){n(e)}},CUT_CELL:{menuMethod:function(e){n(e,!0)}},PASTE_CELL:{menuMethod:function(e){var t=e.$event,a=e.$table,n=e.row,e=e.column;a.mouseConfig&&a.mouseOpts.area?a.triggerPasteCellAreaEvent(t):(a=(l.globalStore||a.$vxe).clipboard)&&a.text&&s.default.set(n,e.field,a.text)}},MERGE_OR_CLEAR:{menuMethod:function(e){var t=e.$event,a=e.$table,n=a.getCellAreas(),o=L(e),e=!1;o.length?a.removeMergeCells(o):(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:{menuMethod:function(e){var t=e.$event,a=e.$table,n=a.getTableData().visibleData,o=a.getTableColumn().visibleColumn,r=a.getCellAreas();E(e),r.some(function(e){var t=e.rows,e=e.cols;return t.length===n.length||e.length===o.length})?l.modal&&l.modal.message({content:l.t("vxe.pro.area.mergeErr"),status:"error",id:"operErr"}):(a.setMergeCells(r.map(function(e){var t=e.rows,e=e.cols;return{row:t[0],col:e[0],rowspan:t.length,colspan:e.length}})),r=r.map(function(e){return{rows:e.rows,cols:e.cols}}),a.emitEvent("cell-area-merge",{status:!0,targetAreas:r},t))}},CLEAR_MERGE_CELL:{menuMethod:function(e){var t=e.$event,a=e.$table,e=E(e);e.length&&a.emitEvent("clear-cell-area-merge",{mergeCells:e},t)}},CLEAR_ALL_MERGE:{menuMethod: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:{menuMethod:function(e){var t=e.$table,a=e.row,e=e.column;t.setEditCell?t.setEditCell(a,e):t.setActiveCell(a,e.field)}},EDIT_ROW:{menuMethod:function(e){var t=e.$table,e=e.row;t.setEditRow?t.setEditRow(e):t.setActiveRow(e)}},INSERT_ROW:{menuMethod:function(e){var t=e.$table,e=e.menu;t.insert(e.params)}},INSERT_ACTIVED_ROW:{menuMethod:function(e){var t=e.$table,a=e.menu,n=e.column,o=a.params||[];t.insert(o[0]).then(function(e){e=e.row;t.setEditCell?t.setEditCell(e,o[1]||n):t.setActiveCell(e,o[1]||n.field)})}},INSERT_AT_ROW:{menuMethod:function(e){var t=e.$table,a=e.menu,e=e.row;e&&t.insertAt(a.params,e)}},INSERT_AT_ACTIVED_ROW:{menuMethod:function(e){var t,a=e.$table,n=e.menu,o=e.row,r=e.column;o&&(t=n.params||[],a.insertAt(t[0],o).then(function(e){e=e.row;a.setEditCell?a.setEditCell(e,t[1]||r):a.setActiveCell(e,t[1]||r.field)}))}},DELETE_ROW:{menuMethod:function(e){var t=e.$table,e=e.row;e&&t.remove(e)}},DELETE_SELECTED_ROW:{menuMethod:function(e){r("DELETE_SELECTED_ROW","DELETE_CHECKBOX_ROW"),e.$table.removeCheckboxRow()}},DELETE_CHECKBOX_ROW:{menuMethod:function(e){e.$table.removeCheckboxRow()}},DELETE_ALL:{menuMethod:function(e){e.$table.remove()}},CLEAR_SORT:{menuMethod:function(e){var t=e.$event,a=e.$table,e=e.column;e&&a.triggerSortEvent(t,e,null)}},CLEAR_ALL_SORT:{menuMethod: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:{menuMethod:function(e){var t=e.$event,a=e.$table,e=e.column;e&&a.triggerSortEvent(t,e,"asc")}},SORT_DESC:{menuMethod:function(e){var t=e.$event,a=e.$table,e=e.column;e&&a.triggerSortEvent(t,e,"desc")}},CLEAR_FILTER:{menuMethod:function(e){var t=e.$event,a=e.$table,e=e.column;e&&(a.handleClearFilter(e),a.confirmFilterEvent(t))}},CLEAR_ALL_FILTER:{menuMethod: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:{menuMethod: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=s.default.get(a,e),n.checked=!0,t.updateData()))}},EXPORT_ROW:{menuMethod:function(e){var t=e.$table,a=e.menu,e=e.row;e&&(e={data:[e]},t.exportData(s.default.assign(e,a.params[0])))}},EXPORT_SELECTED_ROW:{menuMethod:function(e){r("EXPORT_SELECTED_ROW","EXPORT_CHECKBOX_ROW");var t=e.$table,a=e.menu,e={data:t.getCheckboxRecords()};t.exportData(s.default.assign(e,a.params[0]))}},EXPORT_CHECKBOX_ROW:{menuMethod:function(e){var t=e.$table,a=e.menu,e={data:t.getCheckboxRecords()};t.exportData(s.default.assign(e,a.params[0]))}},EXPORT_ALL:{menuMethod:function(e){var t=e.$table,e=e.menu;t.exportData(e.params)}},PRINT_ALL:{menuMethod:function(e){var t=e.$table,e=e.menu;t.print(e.params)}},PRINT_SELECTED_ROW:{menuMethod:function(e){r("PRINT_SELECTED_ROW","PRINT_CHECKBOX_ROW");var t=e.$table,a=e.menu,e={data:t.getCheckboxRecords()};t.print(s.default.assign(e,a.params))}},PRINT_CHECKBOX_ROW:{menuMethod:function(e){var t=e.$table,a=e.menu,e={data:t.getCheckboxRecords()};t.print(s.default.assign(e,a.params))}},OPEN_FIND:{menuMethod:function(e){var t=e.$event;e.$table.triggerFNROpenEvent(t,"find")}},OPEN_REPLACE:{menuMethod:function(e){var t=e.$event;e.$table.triggerFNROpenEvent(t,"replace")}},HIDDEN_COLUMN:{menuMethod: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:{menuMethod:function(e){e.$table.resetColumn({visible:!0,resizable:!1})}},RESET_RESIZABLE:{menuMethod:function(e){e.$table.resetColumn({visible:!1,resizable:!0})}},RESET_ALL:{menuMethod:function(e){e.$table.resetColumn(!0)}}})}};e.VXETablePluginMenus=C,"undefined"!=typeof window&&window.VXETable&&window.VXETable.use&&window.VXETable.use(C),e.default=C}); |
294
index.ts
import XEUtils from 'xe-utils' | ||
import { VXETableCore, VxeTableConstructor, VxeTablePrivateMethods, VxeColumnPropTypes, VxeTableDefines, VxeTableProDefines, VxeGlobalInterceptorHandles, VxeGlobalMenusHandles } from 'vxe-table' | ||
import { | ||
VXETableCore, | ||
InterceptorMenuParams, | ||
MenuFirstOption, | ||
MenuChildOption, | ||
MouseCellArea, | ||
VxeGlobalMenusHandles, | ||
Table | ||
} from 'vxe-table' | ||
@@ -8,15 +16,7 @@ let VXETableInstance: VXETableCore | ||
const columnIndexOf = (cols: VxeTableDefines.ColumnInfo[], column: VxeTableDefines.ColumnInfo) => { | ||
return XEUtils.findIndexOf(cols, item => item.id === column.id) | ||
} | ||
const rowIndexOf = ($table: VxeTableConstructor & VxeTablePrivateMethods, rows: any[], row: any) => { | ||
return $table.findRowIndexOf(rows, row) | ||
} | ||
function handleFixedColumn (fixed: VxeColumnPropTypes.Fixed) { | ||
function handleFixedColumn (fixed: string) { | ||
return { | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
const { $table, column } = params | ||
XEUtils.eachTree([column], (column) => { | ||
XEUtils.eachTree([column], column => { | ||
column.fixed = fixed | ||
@@ -60,10 +60,6 @@ }) | ||
function handleCopyOrCut (params: VxeGlobalMenusHandles.MenuMethodParams, isCut?: boolean) { | ||
const { $event, $table, row, column } = params as VxeGlobalMenusHandles.MenuMethodParams & { $table: VxeTableConstructor & VxeTablePrivateMethods } | ||
const { $event, $table, row, column } = params | ||
if (row && column) { | ||
const { props } = $table | ||
const { mouseConfig } = props | ||
const { computeMouseOpts } = $table.getComputeMaps() | ||
const mouseOpts = computeMouseOpts.value | ||
let text = '' | ||
if (mouseConfig && mouseOpts.area) { | ||
if ($table.mouseConfig && $table.mouseOpts.area) { | ||
if (isCut) { | ||
@@ -75,4 +71,4 @@ $table.triggerCutCellAreaEvent($event) | ||
// 兼容老版本 | ||
const { clipboard } = (VXETableInstance as any).globalStore || (VXETableInstance as any).config | ||
text = clipboard ? clipboard.text : '' | ||
const { clipboard } = (VXETableInstance as any).globalStore ? (VXETableInstance as any).globalStore : $table.$vxe | ||
text = clipboard.text | ||
} else { | ||
@@ -84,4 +80,4 @@ // 操作内置剪贴板 | ||
(VXETableInstance as any).globalStore.clipboard = { text, html: '' } | ||
} else if ((VXETableInstance as any).config) { | ||
(VXETableInstance as any).config.clipboard = { text, html: '' } | ||
} else if ($table.$vxe) { | ||
$table.$vxe.clipboard = { text, html: '' } | ||
} | ||
@@ -98,3 +94,3 @@ } | ||
function checkCellOverlay (params: VxeGlobalInterceptorHandles.InterceptorShowMenuParams, cellAreas: VxeTableProDefines.MouseCellArea[]) { | ||
function checkCellOverlay (params: { $table: Table, [key: string]: any }, cellAreas: MouseCellArea[]) { | ||
const { $table } = params | ||
@@ -109,6 +105,6 @@ const { visibleData } = $table.getTableData() | ||
const offsetRow = rows[rIndex] | ||
const orIndex = rowIndexOf($table, visibleData, offsetRow) | ||
const orIndex = visibleData.indexOf(offsetRow) | ||
for (let cIndex = 0, colSize = cols.length; cIndex < colSize; cIndex++) { | ||
const offsetColumn = cols[cIndex] | ||
const ocIndex = columnIndexOf(visibleColumn, offsetColumn) | ||
const ocIndex = visibleColumn.indexOf(offsetColumn) | ||
const key = orIndex + ':' + ocIndex | ||
@@ -125,11 +121,7 @@ if (indexMaps[key]) { | ||
function getBeenMerges (params: VxeGlobalMenusHandles.MenuMethodParams | VxeGlobalInterceptorHandles.InterceptorShowMenuParams) { | ||
const { $table } = params as (VxeGlobalMenusHandles.MenuMethodParams | VxeGlobalInterceptorHandles.InterceptorShowMenuParams) & { $table: VxeTableConstructor & VxeTablePrivateMethods } | ||
const { props } = $table | ||
const { mouseConfig } = props | ||
const { computeMouseOpts } = $table.getComputeMaps() | ||
const mouseOpts = computeMouseOpts.value | ||
function getBeenMerges (params: { $table: Table, [key: string]: any }) { | ||
const { $table } = params | ||
const { visibleData } = $table.getTableData() | ||
const { visibleColumn } = $table.getTableColumn() | ||
const cellAreas = mouseConfig && mouseOpts.area ? $table.getCellAreas() : [] | ||
const cellAreas = $table.mouseConfig && $table.mouseOpts.area ? $table.getCellAreas() : [] | ||
const mergeList = $table.getMergeCells() | ||
@@ -139,6 +131,6 @@ return mergeList.filter(({ row: mergeRowIndex, col: mergeColIndex, rowspan: mergeRowspan, colspan: mergeColspan }) => { | ||
const { rows, cols } = areaItem | ||
const startRowIndex = rowIndexOf($table, visibleData, rows[0]) | ||
const endRowIndex = rowIndexOf($table, visibleData, rows[rows.length - 1]) | ||
const startColIndex = columnIndexOf(visibleColumn, cols[0]) | ||
const endColIndex = columnIndexOf(visibleColumn, cols[cols.length - 1]) | ||
const startRowIndex = visibleData.indexOf(rows[0]) | ||
const endRowIndex = visibleData.indexOf(rows[rows.length - 1]) | ||
const startColIndex = visibleColumn.indexOf(cols[0]) | ||
const endColIndex = visibleColumn.indexOf(cols[cols.length - 1]) | ||
return mergeRowIndex >= startRowIndex && mergeRowIndex + mergeRowspan - 1 <= endRowIndex && mergeColIndex >= startColIndex && mergeColIndex + mergeColspan - 1 <= endColIndex | ||
@@ -149,3 +141,3 @@ }) | ||
function handleClearMergeCells (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
function handleClearMergeCells (params: { $table: Table, [key: string]: any }) { | ||
const { $table } = params | ||
@@ -159,7 +151,10 @@ const beenMerges = getBeenMerges(params) | ||
function checkPrivilege (item: VxeTableDefines.MenuFirstOption | VxeTableDefines.MenuChildOption, params: VxeGlobalInterceptorHandles.InterceptorShowMenuParams) { | ||
function abandoned (code: string, newCode: string) { | ||
console.warn(`The code "${code}" has been scrapped, please use "${newCode}"`) | ||
} | ||
function checkPrivilege (item: MenuFirstOption | MenuChildOption, params: InterceptorMenuParams) { | ||
const { code } = item | ||
const { $table, row, column } = params | ||
const { props } = $table | ||
const { editConfig, mouseConfig } = props | ||
const { $table, columns, row, column } = params | ||
const { editConfig, mouseConfig, mouseOpts, fnrOpts } = $table | ||
switch (code) { | ||
@@ -187,2 +182,6 @@ case 'CLEAR_ALL_SORT': { | ||
} | ||
case 'EDIT_ROW': { | ||
item.disabled = !editConfig || !columns.some((column) => column.editRender) | ||
break | ||
} | ||
case 'EDIT_CELL': | ||
@@ -215,4 +214,2 @@ case 'CLEAR_CELL': | ||
if (column) { | ||
const { computeMouseOpts } = $table.getComputeMaps() | ||
const mouseOpts = computeMouseOpts.value | ||
const isChildCol = !!column.parentId | ||
@@ -225,7 +222,8 @@ switch (code) { | ||
case 'SORT_ASC': | ||
case 'SORT_DESC': | ||
case 'SORT_DESC': { | ||
item.disabled = !column.sortable | ||
break | ||
} | ||
case 'FILTER_CELL': | ||
case 'CLEAR_FILTER': | ||
case 'CLEAR_FILTER': { | ||
item.disabled = !column.filters || !column.filters.length | ||
@@ -240,2 +238,3 @@ if (!item.disabled) { | ||
break | ||
} | ||
case 'REVERT_CELL': { | ||
@@ -249,5 +248,8 @@ item.disabled = !row || !column.field || !$table.isUpdateByRow(row, column.field) | ||
} | ||
case 'OPEN_FIND': | ||
case 'OPEN_FIND': { | ||
item.disabled = !(fnrOpts && mouseConfig && mouseOpts.area && fnrOpts.isFind) | ||
break | ||
} | ||
case 'OPEN_REPLACE': { | ||
item.disabled = !(mouseConfig && mouseOpts.area) | ||
item.disabled = !(fnrOpts && mouseConfig && mouseOpts.area && fnrOpts.isReplace) | ||
break | ||
@@ -268,3 +270,3 @@ } | ||
// 兼容老版本 | ||
const { clipboard } = (VXETableInstance as any).globalStore || (VXETableInstance as any).config | ||
const { clipboard } = (VXETableInstance as any).globalStore ? (VXETableInstance as any).globalStore : $table.$vxe | ||
item.disabled = !clipboard || !clipboard.text | ||
@@ -299,3 +301,3 @@ break | ||
function handlePrivilegeEvent (params: VxeGlobalInterceptorHandles.InterceptorShowMenuParams) { | ||
function handlePrivilegeEvent (params: InterceptorMenuParams) { | ||
params.options.forEach((list) => { | ||
@@ -318,3 +320,3 @@ list.forEach((item) => { | ||
function pluginSetup (options?: VXETablePluginMenusOptions) { | ||
function setup (options?: VXETablePluginMenusOptions) { | ||
if (options && options.copy) { | ||
@@ -329,12 +331,12 @@ handleCopy = options.copy | ||
export const VXETablePluginMenus = { | ||
setup: pluginSetup, | ||
setup, | ||
install (vxetable: VXETableCore, options?: VXETablePluginMenusOptions) { | ||
VXETableInstance = vxetable | ||
// 检查版本 | ||
if (!/^(4)\./.test(vxetable.version)) { | ||
console.error('[vxe-table-plugin-menus] Version vxe-table 4.x is required') | ||
if (!/^(2|3)\./.test(vxetable.version)) { | ||
console.error('[vxe-table-plugin-menus 3.x] Version vxe-table 3.x is required') | ||
} | ||
pluginSetup(options) | ||
setup(options) | ||
vxetable.interceptor.add('event.showMenu', handlePrivilegeEvent) | ||
vxetable.menus.mixin({ | ||
@@ -345,10 +347,6 @@ /** | ||
CLEAR_CELL: { | ||
menuMethod (params) { | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
const { $table, row, column } = params | ||
if (row && column) { | ||
const { props } = $table | ||
const { mouseConfig } = props | ||
const { computeMouseOpts } = $table.getComputeMaps() | ||
const mouseOpts = computeMouseOpts.value | ||
if (mouseConfig && mouseOpts.area) { | ||
if ($table.mouseConfig && $table.mouseOpts.area) { | ||
const cellAreas = $table.getCellAreas() | ||
@@ -375,3 +373,3 @@ if (cellAreas && cellAreas.length) { | ||
CLEAR_ROW: { | ||
menuMethod (params) { | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
const { $table, row } = params | ||
@@ -383,2 +381,10 @@ if (row) { | ||
}, | ||
// 已废弃 | ||
CLEAR_SELECTED_ROW: { | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
abandoned('CLEAR_SELECTED_ROW', 'CLEAR_CHECKBOX_ROW') | ||
const { $table } = params | ||
$table.clearData($table.getCheckboxRecords()) | ||
} | ||
}, | ||
/** | ||
@@ -388,3 +394,3 @@ * 清除复选框选中行数据的值 | ||
CLEAR_CHECKBOX_ROW: { | ||
menuMethod (params) { | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
const { $table } = params | ||
@@ -398,3 +404,3 @@ $table.clearData($table.getCheckboxRecords()) | ||
CLEAR_ALL: { | ||
menuMethod (params) { | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
const { $table } = params | ||
@@ -408,10 +414,6 @@ $table.clearData() | ||
REVERT_CELL: { | ||
menuMethod (params) { | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
const { $table, row, column } = params | ||
if (row && column) { | ||
const { props } = $table | ||
const { mouseConfig } = props | ||
const { computeMouseOpts } = $table.getComputeMaps() | ||
const mouseOpts = computeMouseOpts.value | ||
if (mouseConfig && mouseOpts.area) { | ||
if ($table.mouseConfig && $table.mouseOpts.area) { | ||
const cellAreas = $table.getCellAreas() | ||
@@ -438,3 +440,3 @@ if (cellAreas && cellAreas.length) { | ||
REVERT_ROW: { | ||
menuMethod (params) { | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
const { $table, row } = params | ||
@@ -446,2 +448,10 @@ if (row) { | ||
}, | ||
// 已废弃 | ||
REVERT_SELECTED_ROW: { | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
abandoned('REVERT_SELECTED_ROW', 'REVERT_CHECKBOX_ROW') | ||
const { $table } = params | ||
$table.revertData($table.getCheckboxRecords()) | ||
} | ||
}, | ||
/** | ||
@@ -451,3 +461,3 @@ * 还原复选框选中行数据的值 | ||
REVERT_CHECKBOX_ROW: { | ||
menuMethod (params) { | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
const { $table } = params | ||
@@ -461,3 +471,3 @@ $table.revertData($table.getCheckboxRecords()) | ||
REVERT_ALL: { | ||
menuMethod (params) { | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
const { $table } = params | ||
@@ -471,3 +481,3 @@ $table.revertData() | ||
COPY_CELL: { | ||
menuMethod (params) { | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
handleCopyOrCut(params) | ||
@@ -480,3 +490,3 @@ } | ||
CUT_CELL: { | ||
menuMethod (params) { | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
handleCopyOrCut(params, true) | ||
@@ -489,13 +499,9 @@ } | ||
PASTE_CELL: { | ||
menuMethod (params) { | ||
const { $event, $table, row, column } = params as VxeGlobalMenusHandles.MenuMethodParams & { $table: VxeTableConstructor & VxeTablePrivateMethods } | ||
const { props } = $table | ||
const { mouseConfig } = props | ||
const { computeMouseOpts } = $table.getComputeMaps() | ||
const mouseOpts = computeMouseOpts.value | ||
if (mouseConfig && mouseOpts.area) { | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
const { $event, $table, row, column } = params | ||
if ($table.mouseConfig && $table.mouseOpts.area) { | ||
$table.triggerPasteCellAreaEvent($event) | ||
} else { | ||
// 兼容老版本 | ||
const { clipboard } = (vxetable as any).globalStore || (vxetable as any).config | ||
const { clipboard } = (vxetable as any).globalStore ? (vxetable as any).globalStore : $table.$vxe | ||
// 读取内置剪贴板 | ||
@@ -512,3 +518,3 @@ if (clipboard && clipboard.text) { | ||
MERGE_OR_CLEAR: { | ||
menuMethod (params) { | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
const { $event, $table } = params | ||
@@ -534,3 +540,3 @@ const cellAreas = $table.getCellAreas() | ||
const targetAreas = cellAreas.map(({ rows, cols }) => ({ rows, cols })) | ||
$table.dispatchEvent('cell-area-merge', { status, targetAreas }, $event) | ||
$table.emitEvent('cell-area-merge', { status, targetAreas }, $event) | ||
} | ||
@@ -542,3 +548,3 @@ }, | ||
MERGE_CELL: { | ||
menuMethod (params) { | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
const { $event, $table } = params | ||
@@ -551,3 +557,3 @@ const { visibleData } = $table.getTableData() | ||
if (vxetable.modal) { | ||
vxetable.modal.message({ content: vxetable.t('vxe.pro.area.mergeErr'), status: 'error', id: 'operErr' }) | ||
vxetable.modal.message({ content: vxetable.t('vxe.pro.area.mergeErr') as string, status: 'error', id: 'operErr' }) | ||
} | ||
@@ -567,3 +573,3 @@ return | ||
const targetAreas = cellAreas.map(({ rows, cols }) => ({ rows, cols })) | ||
$table.dispatchEvent('cell-area-merge', { status: true, targetAreas }, $event) | ||
$table.emitEvent('cell-area-merge', { status: true, targetAreas }, $event) | ||
} | ||
@@ -575,7 +581,7 @@ }, | ||
CLEAR_MERGE_CELL: { | ||
menuMethod (params) { | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
const { $event, $table } = params | ||
const beenMerges = handleClearMergeCells(params) | ||
if (beenMerges.length) { | ||
$table.dispatchEvent('clear-cell-area-merge', { mergeCells: beenMerges }, $event) | ||
$table.emitEvent('clear-cell-area-merge', { mergeCells: beenMerges }, $event) | ||
} | ||
@@ -588,3 +594,3 @@ } | ||
CLEAR_ALL_MERGE: { | ||
menuMethod (params) { | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
const { $event, $table } = params | ||
@@ -595,3 +601,3 @@ const mergeCells = $table.getMergeCells() | ||
$table.clearMergeFooterItems() | ||
$table.dispatchEvent('clear-merge', { mergeCells, mergeFooterItems }, $event) | ||
$table.emitEvent('clear-merge', { mergeCells, mergeFooterItems }, $event) | ||
} | ||
@@ -603,3 +609,3 @@ }, | ||
EDIT_CELL: { | ||
menuMethod (params) { | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
const { $table, row, column } = params | ||
@@ -618,3 +624,3 @@ if ($table.setEditCell) { | ||
EDIT_ROW: { | ||
menuMethod (params) { | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
const { $table, row } = params | ||
@@ -633,3 +639,3 @@ if ($table.setEditRow) { | ||
INSERT_ROW: { | ||
menuMethod (params) { | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
const { $table, menu } = params | ||
@@ -643,5 +649,5 @@ $table.insert(menu.params) | ||
INSERT_ACTIVED_ROW: { | ||
menuMethod (params) { | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
const { $table, menu, column } = params | ||
const args: any[] = menu.params || [] // [{}, 'field'] | ||
const args: any[] = menu.params || [] | ||
$table.insert(args[0]) | ||
@@ -662,3 +668,3 @@ .then(({ row }) => { | ||
INSERT_AT_ROW: { | ||
menuMethod (params) { | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
const { $table, menu, row } = params | ||
@@ -674,6 +680,6 @@ if (row) { | ||
INSERT_AT_ACTIVED_ROW: { | ||
menuMethod (params) { | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
const { $table, menu, row, column } = params | ||
if (row) { | ||
const args: any[] = menu.params || [] // [{}, 'field'] | ||
const args: any[] = menu.params || [] | ||
$table.insertAt(args[0], row) | ||
@@ -695,3 +701,3 @@ .then(({ row }) => { | ||
DELETE_ROW: { | ||
menuMethod (params) { | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
const { $table, row } = params | ||
@@ -703,2 +709,10 @@ if (row) { | ||
}, | ||
// 已废弃 | ||
DELETE_SELECTED_ROW: { | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
abandoned('DELETE_SELECTED_ROW', 'DELETE_CHECKBOX_ROW') | ||
const { $table } = params | ||
$table.removeCheckboxRow() | ||
} | ||
}, | ||
/** | ||
@@ -708,3 +722,3 @@ * 移除复选框选中行数据 | ||
DELETE_CHECKBOX_ROW: { | ||
menuMethod (params) { | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
const { $table } = params | ||
@@ -718,3 +732,3 @@ $table.removeCheckboxRow() | ||
DELETE_ALL: { | ||
menuMethod (params) { | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
const { $table } = params | ||
@@ -728,4 +742,4 @@ $table.remove() | ||
CLEAR_SORT: { | ||
menuMethod (params) { | ||
const { $event, $table, column } = params as VxeGlobalMenusHandles.MenuMethodParams & { $table: VxeTableConstructor & VxeTablePrivateMethods } | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
const { $event, $table, column } = params | ||
if (column) { | ||
@@ -740,3 +754,3 @@ $table.triggerSortEvent($event, column, null) | ||
CLEAR_ALL_SORT: { | ||
menuMethod (params) { | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
const { $event, $table } = params | ||
@@ -746,3 +760,3 @@ const sortList = $table.getSortColumns() | ||
$table.clearSort() | ||
$table.dispatchEvent('clear-sort', { sortList }, $event) | ||
$table.emitEvent('clear-sort', { sortList }, $event) | ||
} | ||
@@ -755,4 +769,4 @@ } | ||
SORT_ASC: { | ||
menuMethod (params) { | ||
const { $event, $table, column } = params as VxeGlobalMenusHandles.MenuMethodParams & { $table: VxeTableConstructor & VxeTablePrivateMethods } | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
const { $event, $table, column } = params | ||
if (column) { | ||
@@ -767,4 +781,4 @@ $table.triggerSortEvent($event, column, 'asc') | ||
SORT_DESC: { | ||
menuMethod (params) { | ||
const { $event, $table, column } = params as VxeGlobalMenusHandles.MenuMethodParams & { $table: VxeTableConstructor & VxeTablePrivateMethods } | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
const { $event, $table, column } = params | ||
if (column) { | ||
@@ -779,4 +793,4 @@ $table.triggerSortEvent($event, column, 'desc') | ||
CLEAR_FILTER: { | ||
menuMethod (params) { | ||
const { $event, $table, column } = params as VxeGlobalMenusHandles.MenuMethodParams & { $table: VxeTableConstructor & VxeTablePrivateMethods } | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
const { $event, $table, column } = params | ||
if (column) { | ||
@@ -792,3 +806,3 @@ $table.handleClearFilter(column) | ||
CLEAR_ALL_FILTER: { | ||
menuMethod (params) { | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
const { $event, $table } = params | ||
@@ -806,9 +820,9 @@ const filterList = $table.getCheckedFilters() | ||
FILTER_CELL: { | ||
menuMethod (params) { | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
const { $table, row, column } = params | ||
if (row && column) { | ||
const { field, filters } = column | ||
const { property, filters } = column | ||
if (filters.length) { | ||
const option = filters[0] | ||
option.data = XEUtils.get(row, field) | ||
option.data = XEUtils.get(row, property) | ||
option.checked = true | ||
@@ -824,3 +838,3 @@ $table.updateData() | ||
EXPORT_ROW: { | ||
menuMethod (params) { | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
const { $table, menu, row } = params | ||
@@ -833,2 +847,11 @@ if (row) { | ||
}, | ||
// 已废弃 | ||
EXPORT_SELECTED_ROW: { | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
abandoned('EXPORT_SELECTED_ROW', 'EXPORT_CHECKBOX_ROW') | ||
const { $table, menu } = params | ||
const opts = { data: $table.getCheckboxRecords() } | ||
$table.exportData(XEUtils.assign(opts, menu.params[0])) | ||
} | ||
}, | ||
/** | ||
@@ -838,3 +861,3 @@ * 导出复选框选中行数据 | ||
EXPORT_CHECKBOX_ROW: { | ||
menuMethod (params) { | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
const { $table, menu } = params | ||
@@ -849,3 +872,3 @@ const opts = { data: $table.getCheckboxRecords() } | ||
EXPORT_ALL: { | ||
menuMethod (params) { | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
const { $table, menu } = params | ||
@@ -859,3 +882,3 @@ $table.exportData(menu.params) | ||
PRINT_ALL: { | ||
menuMethod (params) { | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
const { $table, menu } = params | ||
@@ -865,2 +888,11 @@ $table.print(menu.params) | ||
}, | ||
// 已废弃 | ||
PRINT_SELECTED_ROW: { | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
abandoned('PRINT_SELECTED_ROW', 'PRINT_CHECKBOX_ROW') | ||
const { $table, menu } = params | ||
const opts = { data: $table.getCheckboxRecords() } | ||
$table.print(XEUtils.assign(opts, menu.params)) | ||
} | ||
}, | ||
/** | ||
@@ -870,3 +902,3 @@ * 打印复选框选中行 | ||
PRINT_CHECKBOX_ROW: { | ||
menuMethod (params) { | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
const { $table, menu } = params | ||
@@ -881,4 +913,4 @@ const opts = { data: $table.getCheckboxRecords() } | ||
OPEN_FIND: { | ||
menuMethod (params) { | ||
const { $event, $table } = params as VxeGlobalMenusHandles.MenuMethodParams & { $table: VxeTableConstructor & VxeTablePrivateMethods } | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
const { $event, $table } = params | ||
$table.triggerFNROpenEvent($event, 'find') | ||
@@ -891,4 +923,4 @@ } | ||
OPEN_REPLACE: { | ||
menuMethod (params) { | ||
const { $event, $table } = params as VxeGlobalMenusHandles.MenuMethodParams & { $table: VxeTableConstructor & VxeTablePrivateMethods } | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
const { $event, $table } = params | ||
$table.triggerFNROpenEvent($event, 'replace') | ||
@@ -901,3 +933,3 @@ } | ||
HIDDEN_COLUMN: { | ||
menuMethod (params) { | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
const { $table, column } = params | ||
@@ -920,3 +952,3 @@ if (column) { | ||
*/ | ||
CLEAR_FIXED_COLUMN: handleFixedColumn(null), | ||
CLEAR_FIXED_COLUMN: handleFixedColumn(''), | ||
/** | ||
@@ -926,3 +958,3 @@ * 重置列的可视状态 | ||
RESET_COLUMN: { | ||
menuMethod (params) { | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
const { $table } = params | ||
@@ -936,3 +968,3 @@ $table.resetColumn({ visible: true, resizable: false }) | ||
RESET_RESIZABLE: { | ||
menuMethod (params) { | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
const { $table } = params | ||
@@ -946,3 +978,3 @@ $table.resetColumn({ visible: false, resizable: true }) | ||
RESET_ALL: { | ||
menuMethod (params) { | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
const { $table } = params | ||
@@ -953,4 +985,2 @@ $table.resetColumn(true) | ||
}) | ||
vxetable.interceptor.add('event.showMenu', handlePrivilegeEvent) | ||
} | ||
@@ -957,0 +987,0 @@ } |
{ | ||
"name": "vxe-table-plugin-menus", | ||
"version": "3.2.2", | ||
"version": "3.3.0", | ||
"description": "基于 vxe-table 表格的扩展插件,提供实用的快捷菜单配置", | ||
@@ -38,3 +38,3 @@ "scripts": { | ||
"gulp": "^4.0.2", | ||
"gulp-autoprefixer": "^8.0.0", | ||
"gulp-autoprefixer": "^7.0.1", | ||
"gulp-babel": "^8.0.0", | ||
@@ -44,5 +44,5 @@ "gulp-clean-css": "^4.3.0", | ||
"gulp-rename": "^2.0.0", | ||
"gulp-replace": "^1.1.3", | ||
"gulp-replace": "^1.0.0", | ||
"gulp-sass": "^5.1.0", | ||
"gulp-sourcemaps": "^3.0.0", | ||
"gulp-sourcemaps": "^2.6.5", | ||
"gulp-typescript": "^5.0.1", | ||
@@ -54,8 +54,8 @@ "gulp-uglify": "^3.0.2", | ||
"typescript": "^4.6.4", | ||
"vue": "^3.3.4", | ||
"vxe-table": "^4.5.17", | ||
"xe-utils": "^3.5.13" | ||
"vue": "^2.6.14", | ||
"vxe-table": "^3.7.2", | ||
"xe-utils": "^3.5.19" | ||
}, | ||
"peerDependencies": { | ||
"vxe-table": "^4.5.0" | ||
"vxe-table": "^3.7.0" | ||
}, | ||
@@ -62,0 +62,0 @@ "repository": { |
@@ -12,3 +12,3 @@ # vxe-table-plugin-menus | ||
依赖 vxe-table v4 版本 | ||
对应 vxe-table v3 版本 | ||
@@ -18,3 +18,3 @@ ## Installing | ||
```shell | ||
npm install xe-utils vxe-table@next vxe-table-plugin-menus@next | ||
npm install xe-utils vxe-table@3 vxe-table-plugin-menus@2 | ||
``` | ||
@@ -62,3 +62,3 @@ | ||
| EDIT_CELL | 编辑选中单元格 | — | | ||
| EDIT_ROW | 编辑选中行并激活选中单元格 | — | | ||
| EDIT_ROW | 编辑选中行并默认激活第一个编辑的单元格 | — | | ||
| INSERT_ROW | 插入数据 | records | | ||
@@ -93,3 +93,3 @@ | INSERT_ACTIVED_ROW | 插入数据并激活编辑状态 | Array\<records, field\> | | ||
## demo | ||
## Demo | ||
@@ -96,0 +96,0 @@ ```html |
Sorry, the diff of this file is too big to display
251929
3540