vxe-table-plugin-menus
Advanced tools
Comparing version 3.0.9 to 3.1.0
@@ -38,11 +38,13 @@ (function (global, factory) { | ||
function handleFixedColumn(fixed) { | ||
return function (params) { | ||
var $table = params.$table, | ||
column = params.column; | ||
return { | ||
menuMethod: function menuMethod(params) { | ||
var $table = params.$table, | ||
column = params.column; | ||
_xeUtils["default"].eachTree([column], function (column) { | ||
column.fixed = fixed; | ||
}); | ||
_xeUtils["default"].eachTree([column], function (column) { | ||
column.fixed = fixed; | ||
}); | ||
$table.refreshColumn(); | ||
$table.refreshColumn(); | ||
} | ||
}; | ||
@@ -421,32 +423,34 @@ } | ||
*/ | ||
CLEAR_CELL: function CLEAR_CELL(params) { | ||
var $table = params.$table, | ||
row = params.row, | ||
column = params.column; | ||
CLEAR_CELL: { | ||
menuMethod: function menuMethod(params) { | ||
var $table = params.$table, | ||
row = params.row, | ||
column = params.column; | ||
if (row && column) { | ||
var props = $table.props; | ||
var mouseConfig = props.mouseConfig; | ||
if (row && column) { | ||
var props = $table.props; | ||
var mouseConfig = props.mouseConfig; | ||
var _$table$getComputeMap4 = $table.getComputeMaps(), | ||
computeMouseOpts = _$table$getComputeMap4.computeMouseOpts; | ||
var _$table$getComputeMap4 = $table.getComputeMaps(), | ||
computeMouseOpts = _$table$getComputeMap4.computeMouseOpts; | ||
var mouseOpts = computeMouseOpts.value; | ||
var mouseOpts = computeMouseOpts.value; | ||
if (mouseConfig && mouseOpts.area) { | ||
var cellAreas = $table.getCellAreas(); | ||
if (mouseConfig && mouseOpts.area) { | ||
var cellAreas = $table.getCellAreas(); | ||
if (cellAreas && cellAreas.length) { | ||
cellAreas.forEach(function (areaItem) { | ||
var rows = areaItem.rows, | ||
cols = areaItem.cols; | ||
cols.forEach(function (column) { | ||
rows.forEach(function (row) { | ||
$table.clearData(row, column.field); | ||
if (cellAreas && cellAreas.length) { | ||
cellAreas.forEach(function (areaItem) { | ||
var rows = areaItem.rows, | ||
cols = areaItem.cols; | ||
cols.forEach(function (column) { | ||
rows.forEach(function (row) { | ||
$table.clearData(row, column.field); | ||
}); | ||
}); | ||
}); | ||
}); | ||
} | ||
} else { | ||
$table.clearData(row, column.field); | ||
} | ||
} else { | ||
$table.clearData(row, column.field); | ||
} | ||
@@ -459,8 +463,10 @@ } | ||
*/ | ||
CLEAR_ROW: function CLEAR_ROW(params) { | ||
var $table = params.$table, | ||
row = params.row; | ||
CLEAR_ROW: { | ||
menuMethod: function menuMethod(params) { | ||
var $table = params.$table, | ||
row = params.row; | ||
if (row) { | ||
$table.clearData(row); | ||
if (row) { | ||
$table.clearData(row); | ||
} | ||
} | ||
@@ -472,5 +478,7 @@ }, | ||
*/ | ||
CLEAR_CHECKBOX_ROW: function CLEAR_CHECKBOX_ROW(params) { | ||
var $table = params.$table; | ||
$table.clearData($table.getCheckboxRecords()); | ||
CLEAR_CHECKBOX_ROW: { | ||
menuMethod: function menuMethod(params) { | ||
var $table = params.$table; | ||
$table.clearData($table.getCheckboxRecords()); | ||
} | ||
}, | ||
@@ -481,5 +489,7 @@ | ||
*/ | ||
CLEAR_ALL: function CLEAR_ALL(params) { | ||
var $table = params.$table; | ||
$table.clearData(); | ||
CLEAR_ALL: { | ||
menuMethod: function menuMethod(params) { | ||
var $table = params.$table; | ||
$table.clearData(); | ||
} | ||
}, | ||
@@ -490,32 +500,34 @@ | ||
*/ | ||
REVERT_CELL: function REVERT_CELL(params) { | ||
var $table = params.$table, | ||
row = params.row, | ||
column = params.column; | ||
REVERT_CELL: { | ||
menuMethod: function menuMethod(params) { | ||
var $table = params.$table, | ||
row = params.row, | ||
column = params.column; | ||
if (row && column) { | ||
var props = $table.props; | ||
var mouseConfig = props.mouseConfig; | ||
if (row && column) { | ||
var props = $table.props; | ||
var mouseConfig = props.mouseConfig; | ||
var _$table$getComputeMap5 = $table.getComputeMaps(), | ||
computeMouseOpts = _$table$getComputeMap5.computeMouseOpts; | ||
var _$table$getComputeMap5 = $table.getComputeMaps(), | ||
computeMouseOpts = _$table$getComputeMap5.computeMouseOpts; | ||
var mouseOpts = computeMouseOpts.value; | ||
var mouseOpts = computeMouseOpts.value; | ||
if (mouseConfig && mouseOpts.area) { | ||
var cellAreas = $table.getCellAreas(); | ||
if (mouseConfig && mouseOpts.area) { | ||
var cellAreas = $table.getCellAreas(); | ||
if (cellAreas && cellAreas.length) { | ||
cellAreas.forEach(function (areaItem) { | ||
var rows = areaItem.rows, | ||
cols = areaItem.cols; | ||
cols.forEach(function (column) { | ||
rows.forEach(function (row) { | ||
$table.revertData(row, column.field); | ||
if (cellAreas && cellAreas.length) { | ||
cellAreas.forEach(function (areaItem) { | ||
var rows = areaItem.rows, | ||
cols = areaItem.cols; | ||
cols.forEach(function (column) { | ||
rows.forEach(function (row) { | ||
$table.revertData(row, column.field); | ||
}); | ||
}); | ||
}); | ||
}); | ||
} | ||
} else { | ||
$table.revertData(row, column.field); | ||
} | ||
} else { | ||
$table.revertData(row, column.field); | ||
} | ||
@@ -528,8 +540,10 @@ } | ||
*/ | ||
REVERT_ROW: function REVERT_ROW(params) { | ||
var $table = params.$table, | ||
row = params.row; | ||
REVERT_ROW: { | ||
menuMethod: function menuMethod(params) { | ||
var $table = params.$table, | ||
row = params.row; | ||
if (row) { | ||
$table.revertData(row); | ||
if (row) { | ||
$table.revertData(row); | ||
} | ||
} | ||
@@ -541,5 +555,7 @@ }, | ||
*/ | ||
REVERT_CHECKBOX_ROW: function REVERT_CHECKBOX_ROW(params) { | ||
var $table = params.$table; | ||
$table.revertData($table.getCheckboxRecords()); | ||
REVERT_CHECKBOX_ROW: { | ||
menuMethod: function menuMethod(params) { | ||
var $table = params.$table; | ||
$table.revertData($table.getCheckboxRecords()); | ||
} | ||
}, | ||
@@ -550,5 +566,7 @@ | ||
*/ | ||
REVERT_ALL: function REVERT_ALL(params) { | ||
var $table = params.$table; | ||
$table.revertData(); | ||
REVERT_ALL: { | ||
menuMethod: function menuMethod(params) { | ||
var $table = params.$table; | ||
$table.revertData(); | ||
} | ||
}, | ||
@@ -559,4 +577,6 @@ | ||
*/ | ||
COPY_CELL: function COPY_CELL(params) { | ||
handleCopyOrCut(params); | ||
COPY_CELL: { | ||
menuMethod: function menuMethod(params) { | ||
handleCopyOrCut(params); | ||
} | ||
}, | ||
@@ -567,4 +587,6 @@ | ||
*/ | ||
CUT_CELL: function CUT_CELL(params) { | ||
handleCopyOrCut(params, true); | ||
CUT_CELL: { | ||
menuMethod: function menuMethod(params) { | ||
handleCopyOrCut(params, true); | ||
} | ||
}, | ||
@@ -575,22 +597,24 @@ | ||
*/ | ||
PASTE_CELL: function PASTE_CELL(params) { | ||
var $event = params.$event, | ||
$table = params.$table, | ||
row = params.row, | ||
column = params.column; | ||
var props = $table.props; | ||
var mouseConfig = props.mouseConfig; | ||
PASTE_CELL: { | ||
menuMethod: function menuMethod(params) { | ||
var $event = params.$event, | ||
$table = params.$table, | ||
row = params.row, | ||
column = params.column; | ||
var props = $table.props; | ||
var mouseConfig = props.mouseConfig; | ||
var _$table$getComputeMap6 = $table.getComputeMaps(), | ||
computeMouseOpts = _$table$getComputeMap6.computeMouseOpts; | ||
var _$table$getComputeMap6 = $table.getComputeMaps(), | ||
computeMouseOpts = _$table$getComputeMap6.computeMouseOpts; | ||
var mouseOpts = computeMouseOpts.value; | ||
var mouseOpts = computeMouseOpts.value; | ||
if (mouseConfig && mouseOpts.area) { | ||
$table.triggerPasteCellAreaEvent($event); | ||
} else { | ||
var clipboard = vxetable.config.clipboard; // 读取内置剪贴板 | ||
if (mouseConfig && mouseOpts.area) { | ||
$table.triggerPasteCellAreaEvent($event); | ||
} else { | ||
var clipboard = vxetable.config.clipboard; // 读取内置剪贴板 | ||
if (clipboard && clipboard.text) { | ||
_xeUtils["default"].set(row, column.field, clipboard.text); | ||
if (clipboard && clipboard.text) { | ||
_xeUtils["default"].set(row, column.field, clipboard.text); | ||
} | ||
} | ||
@@ -603,37 +627,39 @@ } | ||
*/ | ||
MERGE_OR_CLEAR: function MERGE_OR_CLEAR(params) { | ||
var $event = params.$event, | ||
$table = params.$table; | ||
var cellAreas = $table.getCellAreas(); | ||
var beenMerges = getBeenMerges(params); | ||
var status = false; | ||
MERGE_OR_CLEAR: { | ||
menuMethod: function menuMethod(params) { | ||
var $event = params.$event, | ||
$table = params.$table; | ||
var cellAreas = $table.getCellAreas(); | ||
var beenMerges = getBeenMerges(params); | ||
var status = false; | ||
if (beenMerges.length) { | ||
$table.removeMergeCells(beenMerges); | ||
} else { | ||
status = true; | ||
$table.setMergeCells(cellAreas.map(function (_ref2) { | ||
var rows = _ref2.rows, | ||
cols = _ref2.cols; | ||
if (beenMerges.length) { | ||
$table.removeMergeCells(beenMerges); | ||
} else { | ||
status = true; | ||
$table.setMergeCells(cellAreas.map(function (_ref2) { | ||
var rows = _ref2.rows, | ||
cols = _ref2.cols; | ||
return { | ||
row: rows[0], | ||
col: cols[0], | ||
rowspan: rows.length, | ||
colspan: cols.length | ||
}; | ||
})); | ||
} | ||
var targetAreas = cellAreas.map(function (_ref3) { | ||
var rows = _ref3.rows, | ||
cols = _ref3.cols; | ||
return { | ||
row: rows[0], | ||
col: cols[0], | ||
rowspan: rows.length, | ||
colspan: cols.length | ||
rows: rows, | ||
cols: cols | ||
}; | ||
})); | ||
}); | ||
$table.dispatchEvent('cell-area-merge', { | ||
status: status, | ||
targetAreas: targetAreas | ||
}, $event); | ||
} | ||
var targetAreas = cellAreas.map(function (_ref3) { | ||
var rows = _ref3.rows, | ||
cols = _ref3.cols; | ||
return { | ||
rows: rows, | ||
cols: cols | ||
}; | ||
}); | ||
$table.dispatchEvent('cell-area-merge', { | ||
status: status, | ||
targetAreas: targetAreas | ||
}, $event); | ||
}, | ||
@@ -644,53 +670,55 @@ | ||
*/ | ||
MERGE_CELL: function MERGE_CELL(params) { | ||
var $event = params.$event, | ||
$table = params.$table; | ||
MERGE_CELL: { | ||
menuMethod: function menuMethod(params) { | ||
var $event = params.$event, | ||
$table = params.$table; | ||
var _$table$getTableData3 = $table.getTableData(), | ||
visibleData = _$table$getTableData3.visibleData; | ||
var _$table$getTableData3 = $table.getTableData(), | ||
visibleData = _$table$getTableData3.visibleData; | ||
var _$table$getTableColum3 = $table.getTableColumn(), | ||
visibleColumn = _$table$getTableColum3.visibleColumn; | ||
var _$table$getTableColum3 = $table.getTableColumn(), | ||
visibleColumn = _$table$getTableColum3.visibleColumn; | ||
var cellAreas = $table.getCellAreas(); | ||
handleClearMergeCells(params); | ||
var cellAreas = $table.getCellAreas(); | ||
handleClearMergeCells(params); | ||
if (cellAreas.some(function (_ref4) { | ||
var rows = _ref4.rows, | ||
cols = _ref4.cols; | ||
return rows.length === visibleData.length || cols.length === visibleColumn.length; | ||
})) { | ||
if (vxetable.modal) { | ||
vxetable.modal.message({ | ||
content: vxetable.t('vxe.pro.area.mergeErr'), | ||
status: 'error', | ||
id: 'operErr' | ||
}); | ||
if (cellAreas.some(function (_ref4) { | ||
var rows = _ref4.rows, | ||
cols = _ref4.cols; | ||
return rows.length === visibleData.length || cols.length === visibleColumn.length; | ||
})) { | ||
if (vxetable.modal) { | ||
vxetable.modal.message({ | ||
content: vxetable.t('vxe.pro.area.mergeErr'), | ||
status: 'error', | ||
id: 'operErr' | ||
}); | ||
} | ||
return; | ||
} | ||
return; | ||
$table.setMergeCells(cellAreas.map(function (_ref5) { | ||
var rows = _ref5.rows, | ||
cols = _ref5.cols; | ||
return { | ||
row: rows[0], | ||
col: cols[0], | ||
rowspan: rows.length, | ||
colspan: cols.length | ||
}; | ||
})); | ||
var targetAreas = cellAreas.map(function (_ref6) { | ||
var rows = _ref6.rows, | ||
cols = _ref6.cols; | ||
return { | ||
rows: rows, | ||
cols: cols | ||
}; | ||
}); | ||
$table.dispatchEvent('cell-area-merge', { | ||
status: true, | ||
targetAreas: targetAreas | ||
}, $event); | ||
} | ||
$table.setMergeCells(cellAreas.map(function (_ref5) { | ||
var rows = _ref5.rows, | ||
cols = _ref5.cols; | ||
return { | ||
row: rows[0], | ||
col: cols[0], | ||
rowspan: rows.length, | ||
colspan: cols.length | ||
}; | ||
})); | ||
var targetAreas = cellAreas.map(function (_ref6) { | ||
var rows = _ref6.rows, | ||
cols = _ref6.cols; | ||
return { | ||
rows: rows, | ||
cols: cols | ||
}; | ||
}); | ||
$table.dispatchEvent('cell-area-merge', { | ||
status: true, | ||
targetAreas: targetAreas | ||
}, $event); | ||
}, | ||
@@ -701,11 +729,13 @@ | ||
*/ | ||
CLEAR_MERGE_CELL: function CLEAR_MERGE_CELL(params) { | ||
var $event = params.$event, | ||
$table = params.$table; | ||
var beenMerges = handleClearMergeCells(params); | ||
CLEAR_MERGE_CELL: { | ||
menuMethod: function menuMethod(params) { | ||
var $event = params.$event, | ||
$table = params.$table; | ||
var beenMerges = handleClearMergeCells(params); | ||
if (beenMerges.length) { | ||
$table.dispatchEvent('clear-cell-area-merge', { | ||
mergeCells: beenMerges | ||
}, $event); | ||
if (beenMerges.length) { | ||
$table.dispatchEvent('clear-cell-area-merge', { | ||
mergeCells: beenMerges | ||
}, $event); | ||
} | ||
} | ||
@@ -717,13 +747,15 @@ }, | ||
*/ | ||
CLEAR_ALL_MERGE: function CLEAR_ALL_MERGE(params) { | ||
var $event = params.$event, | ||
$table = params.$table; | ||
var mergeCells = $table.getMergeCells(); | ||
var mergeFooterItems = $table.getMergeFooterItems(); | ||
$table.clearMergeCells(); | ||
$table.clearMergeFooterItems(); | ||
$table.dispatchEvent('clear-merge', { | ||
mergeCells: mergeCells, | ||
mergeFooterItems: mergeFooterItems | ||
}, $event); | ||
CLEAR_ALL_MERGE: { | ||
menuMethod: function menuMethod(params) { | ||
var $event = params.$event, | ||
$table = params.$table; | ||
var mergeCells = $table.getMergeCells(); | ||
var mergeFooterItems = $table.getMergeFooterItems(); | ||
$table.clearMergeCells(); | ||
$table.clearMergeFooterItems(); | ||
$table.dispatchEvent('clear-merge', { | ||
mergeCells: mergeCells, | ||
mergeFooterItems: mergeFooterItems | ||
}, $event); | ||
} | ||
}, | ||
@@ -734,12 +766,14 @@ | ||
*/ | ||
EDIT_CELL: function EDIT_CELL(params) { | ||
var $table = params.$table, | ||
row = params.row, | ||
column = params.column; | ||
EDIT_CELL: { | ||
menuMethod: function menuMethod(params) { | ||
var $table = params.$table, | ||
row = params.row, | ||
column = params.column; | ||
if ($table.setEditCell) { | ||
$table.setEditCell(row, column); | ||
} else { | ||
// 兼容老版本 | ||
$table.setActiveCell(row, column.field); | ||
if ($table.setEditCell) { | ||
$table.setEditCell(row, column); | ||
} else { | ||
// 兼容老版本 | ||
$table.setActiveCell(row, column.field); | ||
} | ||
} | ||
@@ -751,11 +785,13 @@ }, | ||
*/ | ||
EDIT_ROW: function EDIT_ROW(params) { | ||
var $table = params.$table, | ||
row = params.row; | ||
EDIT_ROW: { | ||
menuMethod: function menuMethod(params) { | ||
var $table = params.$table, | ||
row = params.row; | ||
if ($table.setEditRow) { | ||
$table.setEditRow(row); | ||
} else { | ||
// 兼容老版本 | ||
$table.setActiveRow(row); | ||
if ($table.setEditRow) { | ||
$table.setEditRow(row); | ||
} else { | ||
// 兼容老版本 | ||
$table.setActiveRow(row); | ||
} | ||
} | ||
@@ -767,6 +803,8 @@ }, | ||
*/ | ||
INSERT_ROW: function INSERT_ROW(params) { | ||
var $table = params.$table, | ||
menu = params.menu; | ||
$table.insert(menu.params); | ||
INSERT_ROW: { | ||
menuMethod: function menuMethod(params) { | ||
var $table = params.$table, | ||
menu = params.menu; | ||
$table.insert(menu.params); | ||
} | ||
}, | ||
@@ -777,18 +815,20 @@ | ||
*/ | ||
INSERT_ACTIVED_ROW: function INSERT_ACTIVED_ROW(params) { | ||
var $table = params.$table, | ||
menu = params.menu, | ||
column = params.column; | ||
var args = menu.params || []; // [{}, 'field'] | ||
INSERT_ACTIVED_ROW: { | ||
menuMethod: function menuMethod(params) { | ||
var $table = params.$table, | ||
menu = params.menu, | ||
column = params.column; | ||
var args = menu.params || []; // [{}, 'field'] | ||
$table.insert(args[0]).then(function (_ref7) { | ||
var row = _ref7.row; | ||
$table.insert(args[0]).then(function (_ref7) { | ||
var row = _ref7.row; | ||
if ($table.setEditCell) { | ||
$table.setEditCell(row, args[1] || column); | ||
} else { | ||
// 兼容老版本 | ||
$table.setActiveCell(row, args[1] || column.field); | ||
} | ||
}); | ||
if ($table.setEditCell) { | ||
$table.setEditCell(row, args[1] || column); | ||
} else { | ||
// 兼容老版本 | ||
$table.setActiveCell(row, args[1] || column.field); | ||
} | ||
}); | ||
} | ||
}, | ||
@@ -799,9 +839,11 @@ | ||
*/ | ||
INSERT_AT_ROW: function INSERT_AT_ROW(params) { | ||
var $table = params.$table, | ||
menu = params.menu, | ||
row = params.row; | ||
INSERT_AT_ROW: { | ||
menuMethod: function menuMethod(params) { | ||
var $table = params.$table, | ||
menu = params.menu, | ||
row = params.row; | ||
if (row) { | ||
$table.insertAt(menu.params, row); | ||
if (row) { | ||
$table.insertAt(menu.params, row); | ||
} | ||
} | ||
@@ -813,21 +855,23 @@ }, | ||
*/ | ||
INSERT_AT_ACTIVED_ROW: function INSERT_AT_ACTIVED_ROW(params) { | ||
var $table = params.$table, | ||
menu = params.menu, | ||
row = params.row, | ||
column = params.column; | ||
INSERT_AT_ACTIVED_ROW: { | ||
menuMethod: function menuMethod(params) { | ||
var $table = params.$table, | ||
menu = params.menu, | ||
row = params.row, | ||
column = params.column; | ||
if (row) { | ||
var args = menu.params || []; // [{}, 'field'] | ||
if (row) { | ||
var args = menu.params || []; // [{}, 'field'] | ||
$table.insertAt(args[0], row).then(function (_ref8) { | ||
var row = _ref8.row; | ||
$table.insertAt(args[0], row).then(function (_ref8) { | ||
var row = _ref8.row; | ||
if ($table.setEditCell) { | ||
$table.setEditCell(row, args[1] || column); | ||
} else { | ||
// 兼容老版本 | ||
$table.setActiveCell(row, args[1] || column.field); | ||
} | ||
}); | ||
if ($table.setEditCell) { | ||
$table.setEditCell(row, args[1] || column); | ||
} else { | ||
// 兼容老版本 | ||
$table.setActiveCell(row, args[1] || column.field); | ||
} | ||
}); | ||
} | ||
} | ||
@@ -839,8 +883,10 @@ }, | ||
*/ | ||
DELETE_ROW: function DELETE_ROW(params) { | ||
var $table = params.$table, | ||
row = params.row; | ||
DELETE_ROW: { | ||
menuMethod: function menuMethod(params) { | ||
var $table = params.$table, | ||
row = params.row; | ||
if (row) { | ||
$table.remove(row); | ||
if (row) { | ||
$table.remove(row); | ||
} | ||
} | ||
@@ -852,5 +898,7 @@ }, | ||
*/ | ||
DELETE_CHECKBOX_ROW: function DELETE_CHECKBOX_ROW(params) { | ||
var $table = params.$table; | ||
$table.removeCheckboxRow(); | ||
DELETE_CHECKBOX_ROW: { | ||
menuMethod: function menuMethod(params) { | ||
var $table = params.$table; | ||
$table.removeCheckboxRow(); | ||
} | ||
}, | ||
@@ -861,5 +909,7 @@ | ||
*/ | ||
DELETE_ALL: function DELETE_ALL(params) { | ||
var $table = params.$table; | ||
$table.remove(); | ||
DELETE_ALL: { | ||
menuMethod: function menuMethod(params) { | ||
var $table = params.$table; | ||
$table.remove(); | ||
} | ||
}, | ||
@@ -870,9 +920,11 @@ | ||
*/ | ||
CLEAR_SORT: function CLEAR_SORT(params) { | ||
var $event = params.$event, | ||
$table = params.$table, | ||
column = params.column; | ||
CLEAR_SORT: { | ||
menuMethod: function menuMethod(params) { | ||
var $event = params.$event, | ||
$table = params.$table, | ||
column = params.column; | ||
if (column) { | ||
$table.triggerSortEvent($event, column, null); | ||
if (column) { | ||
$table.triggerSortEvent($event, column, null); | ||
} | ||
} | ||
@@ -884,12 +936,14 @@ }, | ||
*/ | ||
CLEAR_ALL_SORT: function CLEAR_ALL_SORT(params) { | ||
var $event = params.$event, | ||
$table = params.$table; | ||
var sortList = $table.getSortColumns(); | ||
CLEAR_ALL_SORT: { | ||
menuMethod: function menuMethod(params) { | ||
var $event = params.$event, | ||
$table = params.$table; | ||
var sortList = $table.getSortColumns(); | ||
if (sortList.length) { | ||
$table.clearSort(); | ||
$table.dispatchEvent('clear-sort', { | ||
sortList: sortList | ||
}, $event); | ||
if (sortList.length) { | ||
$table.clearSort(); | ||
$table.dispatchEvent('clear-sort', { | ||
sortList: sortList | ||
}, $event); | ||
} | ||
} | ||
@@ -901,9 +955,11 @@ }, | ||
*/ | ||
SORT_ASC: function SORT_ASC(params) { | ||
var $event = params.$event, | ||
$table = params.$table, | ||
column = params.column; | ||
SORT_ASC: { | ||
menuMethod: function menuMethod(params) { | ||
var $event = params.$event, | ||
$table = params.$table, | ||
column = params.column; | ||
if (column) { | ||
$table.triggerSortEvent($event, column, 'asc'); | ||
if (column) { | ||
$table.triggerSortEvent($event, column, 'asc'); | ||
} | ||
} | ||
@@ -915,9 +971,11 @@ }, | ||
*/ | ||
SORT_DESC: function SORT_DESC(params) { | ||
var $event = params.$event, | ||
$table = params.$table, | ||
column = params.column; | ||
SORT_DESC: { | ||
menuMethod: function menuMethod(params) { | ||
var $event = params.$event, | ||
$table = params.$table, | ||
column = params.column; | ||
if (column) { | ||
$table.triggerSortEvent($event, column, 'desc'); | ||
if (column) { | ||
$table.triggerSortEvent($event, column, 'desc'); | ||
} | ||
} | ||
@@ -929,10 +987,12 @@ }, | ||
*/ | ||
CLEAR_FILTER: function CLEAR_FILTER(params) { | ||
var $event = params.$event, | ||
$table = params.$table, | ||
column = params.column; | ||
CLEAR_FILTER: { | ||
menuMethod: function menuMethod(params) { | ||
var $event = params.$event, | ||
$table = params.$table, | ||
column = params.column; | ||
if (column) { | ||
$table.handleClearFilter(column); | ||
$table.confirmFilterEvent($event); | ||
if (column) { | ||
$table.handleClearFilter(column); | ||
$table.confirmFilterEvent($event); | ||
} | ||
} | ||
@@ -944,12 +1004,14 @@ }, | ||
*/ | ||
CLEAR_ALL_FILTER: function CLEAR_ALL_FILTER(params) { | ||
var $event = params.$event, | ||
$table = params.$table; | ||
var filterList = $table.getCheckedFilters(); | ||
CLEAR_ALL_FILTER: { | ||
menuMethod: function menuMethod(params) { | ||
var $event = params.$event, | ||
$table = params.$table; | ||
var filterList = $table.getCheckedFilters(); | ||
if (filterList.length) { | ||
$table.clearFilter(); | ||
$table.dispatchEvent('clear-filter', { | ||
filterList: filterList | ||
}, $event); | ||
if (filterList.length) { | ||
$table.clearFilter(); | ||
$table.dispatchEvent('clear-filter', { | ||
filterList: filterList | ||
}, $event); | ||
} | ||
} | ||
@@ -961,16 +1023,18 @@ }, | ||
*/ | ||
FILTER_CELL: function FILTER_CELL(params) { | ||
var $table = params.$table, | ||
row = params.row, | ||
column = params.column; | ||
FILTER_CELL: { | ||
menuMethod: function menuMethod(params) { | ||
var $table = params.$table, | ||
row = params.row, | ||
column = params.column; | ||
if (row && column) { | ||
var field = column.field, | ||
filters = column.filters; | ||
if (row && column) { | ||
var field = column.field, | ||
filters = column.filters; | ||
if (filters.length) { | ||
var option = filters[0]; | ||
option.data = _xeUtils["default"].get(row, field); | ||
option.checked = true; | ||
$table.updateData(); | ||
if (filters.length) { | ||
var option = filters[0]; | ||
option.data = _xeUtils["default"].get(row, field); | ||
option.checked = true; | ||
$table.updateData(); | ||
} | ||
} | ||
@@ -983,12 +1047,14 @@ } | ||
*/ | ||
EXPORT_ROW: function EXPORT_ROW(params) { | ||
var $table = params.$table, | ||
menu = params.menu, | ||
row = params.row; | ||
EXPORT_ROW: { | ||
menuMethod: function menuMethod(params) { | ||
var $table = params.$table, | ||
menu = params.menu, | ||
row = params.row; | ||
if (row) { | ||
var opts = { | ||
data: [row] | ||
}; | ||
$table.exportData(_xeUtils["default"].assign(opts, menu.params[0])); | ||
if (row) { | ||
var opts = { | ||
data: [row] | ||
}; | ||
$table.exportData(_xeUtils["default"].assign(opts, menu.params[0])); | ||
} | ||
} | ||
@@ -1000,9 +1066,11 @@ }, | ||
*/ | ||
EXPORT_CHECKBOX_ROW: function EXPORT_CHECKBOX_ROW(params) { | ||
var $table = params.$table, | ||
menu = params.menu; | ||
var opts = { | ||
data: $table.getCheckboxRecords() | ||
}; | ||
$table.exportData(_xeUtils["default"].assign(opts, menu.params[0])); | ||
EXPORT_CHECKBOX_ROW: { | ||
menuMethod: function menuMethod(params) { | ||
var $table = params.$table, | ||
menu = params.menu; | ||
var opts = { | ||
data: $table.getCheckboxRecords() | ||
}; | ||
$table.exportData(_xeUtils["default"].assign(opts, menu.params[0])); | ||
} | ||
}, | ||
@@ -1013,6 +1081,8 @@ | ||
*/ | ||
EXPORT_ALL: function EXPORT_ALL(params) { | ||
var $table = params.$table, | ||
menu = params.menu; | ||
$table.exportData(menu.params); | ||
EXPORT_ALL: { | ||
menuMethod: function menuMethod(params) { | ||
var $table = params.$table, | ||
menu = params.menu; | ||
$table.exportData(menu.params); | ||
} | ||
}, | ||
@@ -1023,6 +1093,8 @@ | ||
*/ | ||
PRINT_ALL: function PRINT_ALL(params) { | ||
var $table = params.$table, | ||
menu = params.menu; | ||
$table.print(menu.params); | ||
PRINT_ALL: { | ||
menuMethod: function menuMethod(params) { | ||
var $table = params.$table, | ||
menu = params.menu; | ||
$table.print(menu.params); | ||
} | ||
}, | ||
@@ -1033,9 +1105,11 @@ | ||
*/ | ||
PRINT_CHECKBOX_ROW: function PRINT_CHECKBOX_ROW(params) { | ||
var $table = params.$table, | ||
menu = params.menu; | ||
var opts = { | ||
data: $table.getCheckboxRecords() | ||
}; | ||
$table.print(_xeUtils["default"].assign(opts, menu.params)); | ||
PRINT_CHECKBOX_ROW: { | ||
menuMethod: function menuMethod(params) { | ||
var $table = params.$table, | ||
menu = params.menu; | ||
var opts = { | ||
data: $table.getCheckboxRecords() | ||
}; | ||
$table.print(_xeUtils["default"].assign(opts, menu.params)); | ||
} | ||
}, | ||
@@ -1046,6 +1120,8 @@ | ||
*/ | ||
OPEN_FIND: function OPEN_FIND(params) { | ||
var $event = params.$event, | ||
$table = params.$table; | ||
$table.triggerFNROpenEvent($event, 'find'); | ||
OPEN_FIND: { | ||
menuMethod: function menuMethod(params) { | ||
var $event = params.$event, | ||
$table = params.$table; | ||
$table.triggerFNROpenEvent($event, 'find'); | ||
} | ||
}, | ||
@@ -1056,6 +1132,8 @@ | ||
*/ | ||
OPEN_REPLACE: function OPEN_REPLACE(params) { | ||
var $event = params.$event, | ||
$table = params.$table; | ||
$table.triggerFNROpenEvent($event, 'replace'); | ||
OPEN_REPLACE: { | ||
menuMethod: function menuMethod(params) { | ||
var $event = params.$event, | ||
$table = params.$table; | ||
$table.triggerFNROpenEvent($event, 'replace'); | ||
} | ||
}, | ||
@@ -1066,8 +1144,10 @@ | ||
*/ | ||
HIDDEN_COLUMN: function HIDDEN_COLUMN(params) { | ||
var $table = params.$table, | ||
column = params.column; | ||
HIDDEN_COLUMN: { | ||
menuMethod: function menuMethod(params) { | ||
var $table = params.$table, | ||
column = params.column; | ||
if (column) { | ||
$table.hideColumn(column); | ||
if (column) { | ||
$table.hideColumn(column); | ||
} | ||
} | ||
@@ -1094,8 +1174,10 @@ }, | ||
*/ | ||
RESET_COLUMN: function RESET_COLUMN(params) { | ||
var $table = params.$table; | ||
$table.resetColumn({ | ||
visible: true, | ||
resizable: false | ||
}); | ||
RESET_COLUMN: { | ||
menuMethod: function menuMethod(params) { | ||
var $table = params.$table; | ||
$table.resetColumn({ | ||
visible: true, | ||
resizable: false | ||
}); | ||
} | ||
}, | ||
@@ -1106,8 +1188,10 @@ | ||
*/ | ||
RESET_RESIZABLE: function RESET_RESIZABLE(params) { | ||
var $table = params.$table; | ||
$table.resetColumn({ | ||
visible: false, | ||
resizable: true | ||
}); | ||
RESET_RESIZABLE: { | ||
menuMethod: function menuMethod(params) { | ||
var $table = params.$table; | ||
$table.resetColumn({ | ||
visible: false, | ||
resizable: true | ||
}); | ||
} | ||
}, | ||
@@ -1118,5 +1202,7 @@ | ||
*/ | ||
RESET_ALL: function RESET_ALL(params) { | ||
var $table = params.$table; | ||
$table.resetColumn(true); | ||
RESET_ALL: { | ||
menuMethod: function menuMethod(params) { | ||
var $table = params.$table; | ||
$table.resetColumn(true); | ||
} | ||
} | ||
@@ -1123,0 +1209,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 d,c;Object.defineProperty(e,"__esModule",{value:!0}),e.default=e.VXETablePluginMenus=void 0,i=(t=i)&&t.__esModule?t:{default:t};function _(e,t){return i.default.findIndexOf(e,function(e){return e.id===t.id})}function b(e,t,a){return e.findRowIndexOf(t,a)}var n;function r(a){return function(e){var t=e.$table,e=e.column;i.default.eachTree([e],function(e){e.fixed=a}),t.refreshColumn()}}function u(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 l(e,t){var a,n,r,l=e.$event,o=e.$table,s=e.row,e=e.column;s&&e&&(a=o.props.mouseConfig,n=o.getComputeMaps().computeMouseOpts.value,r="",a&&n.area?(t?o.triggerCutCellAreaEvent(l):o.triggerCopyCellAreaEvent(l),r=d.config.clipboard.text):(r=i.default.toValueString(i.default.get(s,e.field)),d.config.clipboard={text:r,html:""}),(i.default.isFunction(c)?c:u)(r))}function L(e){var i=e.$table,e=i.props.mouseConfig,t=i.getComputeMaps().computeMouseOpts.value,c=i.getTableData().visibleData,u=i.getTableColumn().visibleColumn,a=e&&t.area?i.getCellAreas():[];return i.getMergeCells().filter(function(e){var r=e.row,l=e.col,o=e.rowspan,s=e.colspan;return a.some(function(e){var t=e.rows,e=e.cols,a=b(i,c,t[0]),t=b(i,c,t[t.length-1]),n=_(u,e[0]),e=_(u,e[e.length-1]);return a<=r&&r+o-1<=t&&n<=l&&l+s-1<=e})})}function o(e){var t=e.$table,e=L(e);return e.length&&t.removeMergeCells(e),e}function a(e,t){var a=e.code,n=t.$table,r=t.row,l=t.column,o=n.props,s=o.editConfig,i=o.mouseConfig;switch(a){case"CLEAR_ALL_SORT":var c=n.getSortColumns();e.disabled=!c.length;break;case"CLEAR_ALL_FILTER":c=n.getCheckedFilters();e.disabled=!c.length;break;case"CLEAR_ALL_MERGE":var c=n.getMergeCells(),u=n.getMergeFooterItems();e.disabled=!c.length&&!u.length;break;case"CLEAR_MERGE_CELL":c=L(t);e.disabled=!c.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,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":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 C=i&&E.area?n.getCellAreas():[];e.disabled=1<C.length,e.disabled||"PASTE_CELL"===a&&(C=d.config.clipboard,e.disabled=!C||!C.text);break;case"MERGE_OR_CLEAR":case"MERGE_CELL":C=i&&E.area?n.getCellAreas():[];e.disabled=!C.length||1===C.length&&1===C[0].rows.length&&1===C[0].cols.length||!function(e,t){for(var a=e.$table,n=a.getTableData().visibleData,r=a.getTableColumn().visibleColumn,l={},o=0,s=t.length;o<s;o++)for(var i=t[o],c=i.rows,u=i.cols,E=0,f=c.length;E<f;E++)for(var C=c[E],d=b(a,n,C),L=0,R=u.length;L<R;L++){var g=u[L],g=d+":"+_(r,g);if(l[g])return;l[g]=!0}return 1}(t,C);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 s(t){return t.options.forEach(function(e){e.forEach(function(e){a(e,t),e.children&&e.children.forEach(function(e){a(e,t)})})}),!0}function E(e){e&&e.copy&&(c=e.copy)}var t={setup:E,install:function(e,t){var a=e.interceptor,n=e.menus;d=e,E(t),n.mixin({CLEAR_CELL:function(e){var t,a,n=e.$table,r=e.row,e=e.column;r&&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(r,e.field))},CLEAR_ROW:function(e){var t=e.$table,e=e.row;e&&t.clearData(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 t,a,n=e.$table,r=e.row,e=e.column;r&&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(r,e.field))},REVERT_ROW:function(e){var t=e.$table,e=e.row;e&&t.revertData(e)},REVERT_CHECKBOX_ROW:function(e){e=e.$table;e.revertData(e.getCheckboxRecords())},REVERT_ALL:function(e){e.$table.revertData()},COPY_CELL:function(e){l(e)},CUT_CELL:function(e){l(e,!0)},PASTE_CELL:function(e){var t=e.$event,a=e.$table,n=e.row,e=e.column,r=a.props.mouseConfig,l=a.getComputeMaps().computeMouseOpts.value;r&&l.area?a.triggerPasteCellAreaEvent(t):(r=d.config.clipboard)&&r.text&&i.default.set(n,e.field,r.text)},MERGE_OR_CLEAR:function(e){var t=e.$event,a=e.$table,n=a.getCellAreas(),e=L(e),r=!1,e=(e.length?a.removeMergeCells(e):(r=!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:r,targetAreas:e},t)},MERGE_CELL:function(e){var t=e.$event,a=e.$table,n=a.getTableData().visibleData,r=a.getTableColumn().visibleColumn,l=a.getCellAreas();o(e),l.some(function(e){var t=e.rows,e=e.cols;return t.length===n.length||e.length===r.length})?d.modal&&d.modal.message({content:d.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:function(e){var t=e.$event,a=e.$table,e=o(e);e.length&&a.dispatchEvent("clear-cell-area-merge",{mergeCells:e},t)},CLEAR_ALL_MERGE: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: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:function(e){var t=e.$table,e=e.row;t.setEditRow?t.setEditRow(e):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;t.setEditCell?t.setEditCell(e,r[1]||n):t.setActiveCell(e,r[1]||n.field)})},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,l=e.column;r&&(t=n.params||[],a.insertAt(t[0],r).then(function(e){e=e.row;a.setEditCell?a.setEditCell(e,t[1]||l):a.setActiveCell(e,t[1]||l.field)}))},DELETE_ROW:function(e){var t=e.$table,e=e.row;e&&t.remove(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,e=e.$table,a=e.getSortColumns();a.length&&(e.clearSort(),e.dispatchEvent("clear-sort",{sortList:a},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,e=e.$table,a=e.getCheckedFilters();a.length&&(e.clearFilter(),e.dispatchEvent("clear-filter",{filterList:a},t))},FILTER_CELL: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: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:function(e){var t=e.$table,e=e.menu,a={data:t.getCheckboxRecords()};t.exportData(i.default.assign(a,e.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_CHECKBOX_ROW:function(e){var t=e.$table,e=e.menu,a={data:t.getCheckboxRecords()};t.print(i.default.assign(a,e.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:r("left"),FIXED_RIGHT_COLUMN:r("right"),CLEAR_FIXED_COLUMN:r(null),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)}}),a.add("event.showMenu",s)}};e.VXETablePluginMenus=t,"undefined"!=typeof window&&window.VXETable&&window.VXETable.use&&window.VXETable.use(t);e.default=t}); | ||
!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=(t=i)&&t.__esModule?t:{default:t};function g(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 o(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 r(e,t){var a,n,o,r=e.$event,l=e.$table,s=e.row,e=e.column;s&&e&&(a=l.props.mouseConfig,n=l.getComputeMaps().computeMouseOpts.value,o="",a&&n.area?(t?l.triggerCutCellAreaEvent(r):l.triggerCopyCellAreaEvent(r),o=C.config.clipboard.text):(o=i.default.toValueString(i.default.get(s,e.field)),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,r=e.col,l=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=g(c,e[0]),e=g(c,e[e.length-1]);return a<=o&&o+l-1<=t&&n<=r&&r+s-1<=e})})}function l(e){var t=e.$table,e=m(e);return e.length&&t.removeMergeCells(e),e}function a(e,t){var a=e.code,n=t.$table,o=t.row,r=t.column,l=n.props,s=l.editConfig,i=l.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=!r,r){var E=n.getComputeMaps().computeMouseOpts.value,d=!!r.parentId;switch(a){case"CLEAR_SORT":e.disabled=!r.sortable||!r.order;break;case"SORT_ASC":case"SORT_DESC":e.disabled=!r.sortable;break;case"FILTER_CELL":case"CLEAR_FILTER":e.disabled=!r.filters||!r.filters.length,e.disabled||"CLEAR_FILTER"===a&&(e.disabled=!r.filters.some(function(e){return e.checked}));break;case"REVERT_CELL":e.disabled=!o||!r.field||!n.isUpdateByRow(o,r.field);break;case"REVERT_ROW":e.disabled=!o||!r.field||!n.isUpdateByRow(o);break;case"OPEN_FIND":case"OPEN_REPLACE":e.disabled=!(i&&E.area);break;case"EDIT_CELL":e.disabled=!s||!r.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.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,r={},l=0,s=t.length;l<s;l++)for(var i=t[l],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,L=c.length;m<L;m++){var R=c[m],R=C+":"+g(o,R);if(r[R])return;r[R]=!0}return 1}(t,f);break;case"FIXED_LEFT_COLUMN":e.disabled=d||"left"===r.fixed;break;case"FIXED_RIGHT_COLUMN":e.disabled=d||"right"===r.fixed;break;case"CLEAR_FIXED_COLUMN":e.disabled=d||!r.fixed}}}}function s(t){return t.options.forEach(function(e){e.forEach(function(e){a(e,t),e.children&&e.children.forEach(function(e){a(e,t)})})}),!0}function E(e){e&&e.copy&&(u=e.copy)}var t={setup:E,install:function(e,t){var a=e.interceptor,n=e.menus;C=e,E(t),n.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){r(e)}},CUT_CELL:{menuMethod:function(e){r(e,!0)}},PASTE_CELL:{menuMethod:function(e){var t=e.$event,a=e.$table,n=e.row,e=e.column,o=a.props.mouseConfig,r=a.getComputeMaps().computeMouseOpts.value;o&&r.area?a.triggerPasteCellAreaEvent(t):(o=C.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,r=a.getCellAreas();l(e),r.some(function(e){var t=e.rows,e=e.cols;return t.length===n.length||e.length===o.length})?C.modal&&C.modal.message({content:C.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}})),e=r.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=l(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,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_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:o("left"),FIXED_RIGHT_COLUMN:o("right"),CLEAR_FIXED_COLUMN:o(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)}}}),a.add("event.showMenu",s)}};e.VXETablePluginMenus=t,"undefined"!=typeof window&&window.VXETable&&window.VXETable.use&&window.VXETable.use(t);e.default=t}); |
612
index.ts
@@ -17,8 +17,10 @@ import XEUtils from 'xe-utils' | ||
function handleFixedColumn (fixed: VxeColumnPropTypes.Fixed) { | ||
return function (params: VxeGlobalMenusHandles.MenusCallbackParams) { | ||
const { $table, column } = params | ||
XEUtils.eachTree([column], (column) => { | ||
column.fixed = fixed | ||
}) | ||
$table.refreshColumn() | ||
return { | ||
menuMethod (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
const { $table, column } = params | ||
XEUtils.eachTree([column], (column) => { | ||
column.fixed = fixed | ||
}) | ||
$table.refreshColumn() | ||
} | ||
} | ||
@@ -57,4 +59,4 @@ } | ||
function handleCopyOrCut (params: VxeGlobalMenusHandles.MenusCallbackParams, isCut?: boolean) { | ||
const { $event, $table, row, column } = params as VxeGlobalMenusHandles.MenusCallbackParams & { $table: VxeTableConstructor & VxeTablePrivateMethods } | ||
function handleCopyOrCut (params: VxeGlobalMenusHandles.MenuMethodParams, isCut?: boolean) { | ||
const { $event, $table, row, column } = params as VxeGlobalMenusHandles.MenuMethodParams & { $table: VxeTableConstructor & VxeTablePrivateMethods } | ||
if (row && column) { | ||
@@ -112,4 +114,4 @@ const { props } = $table | ||
function getBeenMerges (params: VxeGlobalMenusHandles.MenusCallbackParams | VxeGlobalInterceptorHandles.InterceptorShowMenuParams) { | ||
const { $table } = params as (VxeGlobalMenusHandles.MenusCallbackParams | VxeGlobalInterceptorHandles.InterceptorShowMenuParams) & { $table: VxeTableConstructor & VxeTablePrivateMethods } | ||
function getBeenMerges (params: VxeGlobalMenusHandles.MenuMethodParams | VxeGlobalInterceptorHandles.InterceptorShowMenuParams) { | ||
const { $table } = params as (VxeGlobalMenusHandles.MenuMethodParams | VxeGlobalInterceptorHandles.InterceptorShowMenuParams) & { $table: VxeTableConstructor & VxeTablePrivateMethods } | ||
const { props } = $table | ||
@@ -135,3 +137,3 @@ const { mouseConfig } = props | ||
function handleClearMergeCells (params: VxeGlobalMenusHandles.MenusCallbackParams) { | ||
function handleClearMergeCells (params: VxeGlobalMenusHandles.MenuMethodParams) { | ||
const { $table } = params | ||
@@ -317,23 +319,25 @@ const beenMerges = getBeenMerges(params) | ||
*/ | ||
CLEAR_CELL (params) { | ||
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) { | ||
const cellAreas = $table.getCellAreas() | ||
if (cellAreas && cellAreas.length) { | ||
cellAreas.forEach(areaItem => { | ||
const { rows, cols } = areaItem | ||
cols.forEach(column => { | ||
rows.forEach(row => { | ||
$table.clearData(row, column.field) | ||
CLEAR_CELL: { | ||
menuMethod (params) { | ||
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) { | ||
const cellAreas = $table.getCellAreas() | ||
if (cellAreas && cellAreas.length) { | ||
cellAreas.forEach(areaItem => { | ||
const { rows, cols } = areaItem | ||
cols.forEach(column => { | ||
rows.forEach(row => { | ||
$table.clearData(row, column.field) | ||
}) | ||
}) | ||
}) | ||
}) | ||
} | ||
} else { | ||
$table.clearData(row, column.field) | ||
} | ||
} else { | ||
$table.clearData(row, column.field) | ||
} | ||
@@ -345,6 +349,8 @@ } | ||
*/ | ||
CLEAR_ROW (params) { | ||
const { $table, row } = params | ||
if (row) { | ||
$table.clearData(row) | ||
CLEAR_ROW: { | ||
menuMethod (params) { | ||
const { $table, row } = params | ||
if (row) { | ||
$table.clearData(row) | ||
} | ||
} | ||
@@ -355,5 +361,7 @@ }, | ||
*/ | ||
CLEAR_CHECKBOX_ROW (params) { | ||
const { $table } = params | ||
$table.clearData($table.getCheckboxRecords()) | ||
CLEAR_CHECKBOX_ROW: { | ||
menuMethod (params) { | ||
const { $table } = params | ||
$table.clearData($table.getCheckboxRecords()) | ||
} | ||
}, | ||
@@ -363,5 +371,7 @@ /** | ||
*/ | ||
CLEAR_ALL (params) { | ||
const { $table } = params | ||
$table.clearData() | ||
CLEAR_ALL: { | ||
menuMethod (params) { | ||
const { $table } = params | ||
$table.clearData() | ||
} | ||
}, | ||
@@ -371,23 +381,25 @@ /** | ||
*/ | ||
REVERT_CELL (params) { | ||
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) { | ||
const cellAreas = $table.getCellAreas() | ||
if (cellAreas && cellAreas.length) { | ||
cellAreas.forEach(areaItem => { | ||
const { rows, cols } = areaItem | ||
cols.forEach(column => { | ||
rows.forEach(row => { | ||
$table.revertData(row, column.field) | ||
REVERT_CELL: { | ||
menuMethod (params) { | ||
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) { | ||
const cellAreas = $table.getCellAreas() | ||
if (cellAreas && cellAreas.length) { | ||
cellAreas.forEach(areaItem => { | ||
const { rows, cols } = areaItem | ||
cols.forEach(column => { | ||
rows.forEach(row => { | ||
$table.revertData(row, column.field) | ||
}) | ||
}) | ||
}) | ||
}) | ||
} | ||
} else { | ||
$table.revertData(row, column.field) | ||
} | ||
} else { | ||
$table.revertData(row, column.field) | ||
} | ||
@@ -399,6 +411,8 @@ } | ||
*/ | ||
REVERT_ROW (params) { | ||
const { $table, row } = params | ||
if (row) { | ||
$table.revertData(row) | ||
REVERT_ROW: { | ||
menuMethod (params) { | ||
const { $table, row } = params | ||
if (row) { | ||
$table.revertData(row) | ||
} | ||
} | ||
@@ -409,5 +423,7 @@ }, | ||
*/ | ||
REVERT_CHECKBOX_ROW (params) { | ||
const { $table } = params | ||
$table.revertData($table.getCheckboxRecords()) | ||
REVERT_CHECKBOX_ROW: { | ||
menuMethod (params) { | ||
const { $table } = params | ||
$table.revertData($table.getCheckboxRecords()) | ||
} | ||
}, | ||
@@ -417,5 +433,7 @@ /** | ||
*/ | ||
REVERT_ALL (params) { | ||
const { $table } = params | ||
$table.revertData() | ||
REVERT_ALL: { | ||
menuMethod (params) { | ||
const { $table } = params | ||
$table.revertData() | ||
} | ||
}, | ||
@@ -425,4 +443,6 @@ /** | ||
*/ | ||
COPY_CELL (params) { | ||
handleCopyOrCut(params) | ||
COPY_CELL: { | ||
menuMethod (params) { | ||
handleCopyOrCut(params) | ||
} | ||
}, | ||
@@ -432,4 +452,6 @@ /** | ||
*/ | ||
CUT_CELL (params) { | ||
handleCopyOrCut(params, true) | ||
CUT_CELL: { | ||
menuMethod (params) { | ||
handleCopyOrCut(params, true) | ||
} | ||
}, | ||
@@ -439,15 +461,17 @@ /** | ||
*/ | ||
PASTE_CELL (params) { | ||
const { $event, $table, row, column } = params as VxeGlobalMenusHandles.MenusCallbackParams & { $table: VxeTableConstructor & VxeTablePrivateMethods } | ||
const { props } = $table | ||
const { mouseConfig } = props | ||
const { computeMouseOpts } = $table.getComputeMaps() | ||
const mouseOpts = computeMouseOpts.value | ||
if (mouseConfig && mouseOpts.area) { | ||
$table.triggerPasteCellAreaEvent($event) | ||
} else { | ||
const { clipboard } = vxetable.config | ||
// 读取内置剪贴板 | ||
if (clipboard && clipboard.text) { | ||
XEUtils.set(row, column.field, clipboard.text) | ||
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) { | ||
$table.triggerPasteCellAreaEvent($event) | ||
} else { | ||
const { clipboard } = vxetable.config | ||
// 读取内置剪贴板 | ||
if (clipboard && clipboard.text) { | ||
XEUtils.set(row, column.field, clipboard.text) | ||
} | ||
} | ||
@@ -459,11 +483,43 @@ } | ||
*/ | ||
MERGE_OR_CLEAR (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 | ||
MERGE_OR_CLEAR: { | ||
menuMethod (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( | ||
cellAreas.map(({ rows, cols }) => { | ||
return { | ||
row: rows[0], | ||
col: cols[0], | ||
rowspan: rows.length, | ||
colspan: cols.length | ||
} | ||
}) | ||
) | ||
} | ||
const targetAreas = cellAreas.map(({ rows, cols }) => ({ rows, cols })) | ||
$table.dispatchEvent('cell-area-merge', { status, targetAreas }, $event) | ||
} | ||
}, | ||
/** | ||
* 如果启用 mouse-config.area 功能,临时合并区域范围内的单元格,不管是否存在已合并 | ||
*/ | ||
MERGE_CELL: { | ||
menuMethod (params) { | ||
const { $event, $table } = params | ||
const { visibleData } = $table.getTableData() | ||
const { visibleColumn } = $table.getTableColumn() | ||
const cellAreas = $table.getCellAreas() | ||
handleClearMergeCells(params) | ||
if (cellAreas.some(({ rows, cols }) => rows.length === visibleData.length || cols.length === visibleColumn.length)) { | ||
if (vxetable.modal) { | ||
vxetable.modal.message({ content: vxetable.t('vxe.pro.area.mergeErr'), status: 'error', id: 'operErr' }) | ||
} | ||
return | ||
} | ||
$table.setMergeCells( | ||
@@ -479,65 +535,43 @@ cellAreas.map(({ rows, cols }) => { | ||
) | ||
const targetAreas = cellAreas.map(({ rows, cols }) => ({ rows, cols })) | ||
$table.dispatchEvent('cell-area-merge', { status: true, targetAreas }, $event) | ||
} | ||
const targetAreas = cellAreas.map(({ rows, cols }) => ({ rows, cols })) | ||
$table.dispatchEvent('cell-area-merge', { status, targetAreas }, $event) | ||
}, | ||
/** | ||
* 如果启用 mouse-config.area 功能,临时合并区域范围内的单元格,不管是否存在已合并 | ||
* 如果启用 mouse-config.area 功能,清除区域范围内单元格的临时合并状态 | ||
*/ | ||
MERGE_CELL (params) { | ||
const { $event, $table } = params | ||
const { visibleData } = $table.getTableData() | ||
const { visibleColumn } = $table.getTableColumn() | ||
const cellAreas = $table.getCellAreas() | ||
handleClearMergeCells(params) | ||
if (cellAreas.some(({ rows, cols }) => rows.length === visibleData.length || cols.length === visibleColumn.length)) { | ||
if (vxetable.modal) { | ||
vxetable.modal.message({ content: vxetable.t('vxe.pro.area.mergeErr'), status: 'error', id: 'operErr' }) | ||
CLEAR_MERGE_CELL: { | ||
menuMethod (params) { | ||
const { $event, $table } = params | ||
const beenMerges = handleClearMergeCells(params) | ||
if (beenMerges.length) { | ||
$table.dispatchEvent('clear-cell-area-merge', { mergeCells: beenMerges }, $event) | ||
} | ||
return | ||
} | ||
$table.setMergeCells( | ||
cellAreas.map(({ rows, cols }) => { | ||
return { | ||
row: rows[0], | ||
col: cols[0], | ||
rowspan: rows.length, | ||
colspan: cols.length | ||
} | ||
}) | ||
) | ||
const targetAreas = cellAreas.map(({ rows, cols }) => ({ rows, cols })) | ||
$table.dispatchEvent('cell-area-merge', { status: true, targetAreas }, $event) | ||
}, | ||
/** | ||
* 如果启用 mouse-config.area 功能,清除区域范围内单元格的临时合并状态 | ||
* 清除所有单元格及表尾的临时合并状态 | ||
*/ | ||
CLEAR_MERGE_CELL (params) { | ||
const { $event, $table } = params | ||
const beenMerges = handleClearMergeCells(params) | ||
if (beenMerges.length) { | ||
$table.dispatchEvent('clear-cell-area-merge', { mergeCells: beenMerges }, $event) | ||
CLEAR_ALL_MERGE: { | ||
menuMethod (params) { | ||
const { $event, $table } = params | ||
const mergeCells = $table.getMergeCells() | ||
const mergeFooterItems = $table.getMergeFooterItems() | ||
$table.clearMergeCells() | ||
$table.clearMergeFooterItems() | ||
$table.dispatchEvent('clear-merge', { mergeCells, mergeFooterItems }, $event) | ||
} | ||
}, | ||
/** | ||
* 清除所有单元格及表尾的临时合并状态 | ||
*/ | ||
CLEAR_ALL_MERGE (params) { | ||
const { $event, $table } = params | ||
const mergeCells = $table.getMergeCells() | ||
const mergeFooterItems = $table.getMergeFooterItems() | ||
$table.clearMergeCells() | ||
$table.clearMergeFooterItems() | ||
$table.dispatchEvent('clear-merge', { mergeCells, mergeFooterItems }, $event) | ||
}, | ||
/** | ||
* 编辑单元格 | ||
*/ | ||
EDIT_CELL (params) { | ||
const { $table, row, column } = params | ||
if ($table.setEditCell) { | ||
$table.setEditCell(row, column) | ||
} else { | ||
EDIT_CELL: { | ||
menuMethod (params) { | ||
const { $table, row, column } = params | ||
if ($table.setEditCell) { | ||
$table.setEditCell(row, column) | ||
} else { | ||
// 兼容老版本 | ||
$table.setActiveCell(row, column.field) | ||
$table.setActiveCell(row, column.field) | ||
} | ||
} | ||
@@ -548,9 +582,11 @@ }, | ||
*/ | ||
EDIT_ROW (params) { | ||
const { $table, row } = params | ||
if ($table.setEditRow) { | ||
$table.setEditRow(row) | ||
} else { | ||
EDIT_ROW: { | ||
menuMethod (params) { | ||
const { $table, row } = params | ||
if ($table.setEditRow) { | ||
$table.setEditRow(row) | ||
} else { | ||
// 兼容老版本 | ||
$table.setActiveRow(row) | ||
$table.setActiveRow(row) | ||
} | ||
} | ||
@@ -561,5 +597,7 @@ }, | ||
*/ | ||
INSERT_ROW (params) { | ||
const { $table, menu } = params | ||
$table.insert(menu.params) | ||
INSERT_ROW: { | ||
menuMethod (params) { | ||
const { $table, menu } = params | ||
$table.insert(menu.params) | ||
} | ||
}, | ||
@@ -569,14 +607,16 @@ /** | ||
*/ | ||
INSERT_ACTIVED_ROW (params) { | ||
const { $table, menu, column } = params | ||
const args: any[] = menu.params || [] // [{}, 'field'] | ||
$table.insert(args[0]) | ||
.then(({ row }) => { | ||
if ($table.setEditCell) { | ||
$table.setEditCell(row, args[1] || column) | ||
} else { | ||
INSERT_ACTIVED_ROW: { | ||
menuMethod (params) { | ||
const { $table, menu, column } = params | ||
const args: any[] = menu.params || [] // [{}, 'field'] | ||
$table.insert(args[0]) | ||
.then(({ row }) => { | ||
if ($table.setEditCell) { | ||
$table.setEditCell(row, args[1] || column) | ||
} else { | ||
// 兼容老版本 | ||
$table.setActiveCell(row, args[1] || column.field) | ||
} | ||
}) | ||
$table.setActiveCell(row, args[1] || column.field) | ||
} | ||
}) | ||
} | ||
}, | ||
@@ -586,6 +626,8 @@ /** | ||
*/ | ||
INSERT_AT_ROW (params) { | ||
const { $table, menu, row } = params | ||
if (row) { | ||
$table.insertAt(menu.params, row) | ||
INSERT_AT_ROW: { | ||
menuMethod (params) { | ||
const { $table, menu, row } = params | ||
if (row) { | ||
$table.insertAt(menu.params, row) | ||
} | ||
} | ||
@@ -596,15 +638,17 @@ }, | ||
*/ | ||
INSERT_AT_ACTIVED_ROW (params) { | ||
const { $table, menu, row, column } = params | ||
if (row) { | ||
const args: any[] = menu.params || [] // [{}, 'field'] | ||
$table.insertAt(args[0], row) | ||
.then(({ row }) => { | ||
if ($table.setEditCell) { | ||
$table.setEditCell(row, args[1] || column) | ||
} else { | ||
INSERT_AT_ACTIVED_ROW: { | ||
menuMethod (params) { | ||
const { $table, menu, row, column } = params | ||
if (row) { | ||
const args: any[] = menu.params || [] // [{}, 'field'] | ||
$table.insertAt(args[0], row) | ||
.then(({ row }) => { | ||
if ($table.setEditCell) { | ||
$table.setEditCell(row, args[1] || column) | ||
} else { | ||
// 兼容老版本 | ||
$table.setActiveCell(row, args[1] || column.field) | ||
} | ||
}) | ||
$table.setActiveCell(row, args[1] || column.field) | ||
} | ||
}) | ||
} | ||
} | ||
@@ -615,6 +659,8 @@ }, | ||
*/ | ||
DELETE_ROW (params) { | ||
const { $table, row } = params | ||
if (row) { | ||
$table.remove(row) | ||
DELETE_ROW: { | ||
menuMethod (params) { | ||
const { $table, row } = params | ||
if (row) { | ||
$table.remove(row) | ||
} | ||
} | ||
@@ -625,5 +671,7 @@ }, | ||
*/ | ||
DELETE_CHECKBOX_ROW (params) { | ||
const { $table } = params | ||
$table.removeCheckboxRow() | ||
DELETE_CHECKBOX_ROW: { | ||
menuMethod (params) { | ||
const { $table } = params | ||
$table.removeCheckboxRow() | ||
} | ||
}, | ||
@@ -633,5 +681,7 @@ /** | ||
*/ | ||
DELETE_ALL (params) { | ||
const { $table } = params | ||
$table.remove() | ||
DELETE_ALL: { | ||
menuMethod (params) { | ||
const { $table } = params | ||
$table.remove() | ||
} | ||
}, | ||
@@ -641,6 +691,8 @@ /** | ||
*/ | ||
CLEAR_SORT (params) { | ||
const { $event, $table, column } = params as VxeGlobalMenusHandles.MenusCallbackParams & { $table: VxeTableConstructor & VxeTablePrivateMethods } | ||
if (column) { | ||
$table.triggerSortEvent($event, column, null) | ||
CLEAR_SORT: { | ||
menuMethod (params) { | ||
const { $event, $table, column } = params as VxeGlobalMenusHandles.MenuMethodParams & { $table: VxeTableConstructor & VxeTablePrivateMethods } | ||
if (column) { | ||
$table.triggerSortEvent($event, column, null) | ||
} | ||
} | ||
@@ -651,8 +703,10 @@ }, | ||
*/ | ||
CLEAR_ALL_SORT (params) { | ||
const { $event, $table } = params | ||
const sortList = $table.getSortColumns() | ||
if (sortList.length) { | ||
$table.clearSort() | ||
$table.dispatchEvent('clear-sort', { sortList }, $event) | ||
CLEAR_ALL_SORT: { | ||
menuMethod (params) { | ||
const { $event, $table } = params | ||
const sortList = $table.getSortColumns() | ||
if (sortList.length) { | ||
$table.clearSort() | ||
$table.dispatchEvent('clear-sort', { sortList }, $event) | ||
} | ||
} | ||
@@ -663,6 +717,8 @@ }, | ||
*/ | ||
SORT_ASC (params) { | ||
const { $event, $table, column } = params as VxeGlobalMenusHandles.MenusCallbackParams & { $table: VxeTableConstructor & VxeTablePrivateMethods } | ||
if (column) { | ||
$table.triggerSortEvent($event, column, 'asc') | ||
SORT_ASC: { | ||
menuMethod (params) { | ||
const { $event, $table, column } = params as VxeGlobalMenusHandles.MenuMethodParams & { $table: VxeTableConstructor & VxeTablePrivateMethods } | ||
if (column) { | ||
$table.triggerSortEvent($event, column, 'asc') | ||
} | ||
} | ||
@@ -673,6 +729,8 @@ }, | ||
*/ | ||
SORT_DESC (params) { | ||
const { $event, $table, column } = params as VxeGlobalMenusHandles.MenusCallbackParams & { $table: VxeTableConstructor & VxeTablePrivateMethods } | ||
if (column) { | ||
$table.triggerSortEvent($event, column, 'desc') | ||
SORT_DESC: { | ||
menuMethod (params) { | ||
const { $event, $table, column } = params as VxeGlobalMenusHandles.MenuMethodParams & { $table: VxeTableConstructor & VxeTablePrivateMethods } | ||
if (column) { | ||
$table.triggerSortEvent($event, column, 'desc') | ||
} | ||
} | ||
@@ -683,7 +741,9 @@ }, | ||
*/ | ||
CLEAR_FILTER (params) { | ||
const { $event, $table, column } = params as VxeGlobalMenusHandles.MenusCallbackParams & { $table: VxeTableConstructor & VxeTablePrivateMethods } | ||
if (column) { | ||
$table.handleClearFilter(column) | ||
$table.confirmFilterEvent($event) | ||
CLEAR_FILTER: { | ||
menuMethod (params) { | ||
const { $event, $table, column } = params as VxeGlobalMenusHandles.MenuMethodParams & { $table: VxeTableConstructor & VxeTablePrivateMethods } | ||
if (column) { | ||
$table.handleClearFilter(column) | ||
$table.confirmFilterEvent($event) | ||
} | ||
} | ||
@@ -694,8 +754,10 @@ }, | ||
*/ | ||
CLEAR_ALL_FILTER (params) { | ||
const { $event, $table } = params | ||
const filterList = $table.getCheckedFilters() | ||
if (filterList.length) { | ||
$table.clearFilter() | ||
$table.dispatchEvent('clear-filter', { filterList }, $event) | ||
CLEAR_ALL_FILTER: { | ||
menuMethod (params) { | ||
const { $event, $table } = params | ||
const filterList = $table.getCheckedFilters() | ||
if (filterList.length) { | ||
$table.clearFilter() | ||
$table.dispatchEvent('clear-filter', { filterList }, $event) | ||
} | ||
} | ||
@@ -706,11 +768,13 @@ }, | ||
*/ | ||
FILTER_CELL (params) { | ||
const { $table, row, column } = params | ||
if (row && column) { | ||
const { field, filters } = column | ||
if (filters.length) { | ||
const option = filters[0] | ||
option.data = XEUtils.get(row, field) | ||
option.checked = true | ||
$table.updateData() | ||
FILTER_CELL: { | ||
menuMethod (params) { | ||
const { $table, row, column } = params | ||
if (row && column) { | ||
const { field, filters } = column | ||
if (filters.length) { | ||
const option = filters[0] | ||
option.data = XEUtils.get(row, field) | ||
option.checked = true | ||
$table.updateData() | ||
} | ||
} | ||
@@ -722,7 +786,9 @@ } | ||
*/ | ||
EXPORT_ROW (params) { | ||
const { $table, menu, row } = params | ||
if (row) { | ||
const opts = { data: [row] } | ||
$table.exportData(XEUtils.assign(opts, menu.params[0])) | ||
EXPORT_ROW: { | ||
menuMethod (params) { | ||
const { $table, menu, row } = params | ||
if (row) { | ||
const opts = { data: [row] } | ||
$table.exportData(XEUtils.assign(opts, menu.params[0])) | ||
} | ||
} | ||
@@ -733,6 +799,8 @@ }, | ||
*/ | ||
EXPORT_CHECKBOX_ROW (params) { | ||
const { $table, menu } = params | ||
const opts = { data: $table.getCheckboxRecords() } | ||
$table.exportData(XEUtils.assign(opts, menu.params[0])) | ||
EXPORT_CHECKBOX_ROW: { | ||
menuMethod (params) { | ||
const { $table, menu } = params | ||
const opts = { data: $table.getCheckboxRecords() } | ||
$table.exportData(XEUtils.assign(opts, menu.params[0])) | ||
} | ||
}, | ||
@@ -742,5 +810,7 @@ /** | ||
*/ | ||
EXPORT_ALL (params) { | ||
const { $table, menu } = params | ||
$table.exportData(menu.params) | ||
EXPORT_ALL: { | ||
menuMethod (params) { | ||
const { $table, menu } = params | ||
$table.exportData(menu.params) | ||
} | ||
}, | ||
@@ -750,5 +820,7 @@ /** | ||
*/ | ||
PRINT_ALL (params) { | ||
const { $table, menu } = params | ||
$table.print(menu.params) | ||
PRINT_ALL: { | ||
menuMethod (params) { | ||
const { $table, menu } = params | ||
$table.print(menu.params) | ||
} | ||
}, | ||
@@ -758,6 +830,8 @@ /** | ||
*/ | ||
PRINT_CHECKBOX_ROW (params) { | ||
const { $table, menu } = params | ||
const opts = { data: $table.getCheckboxRecords() } | ||
$table.print(XEUtils.assign(opts, menu.params)) | ||
PRINT_CHECKBOX_ROW: { | ||
menuMethod (params) { | ||
const { $table, menu } = params | ||
const opts = { data: $table.getCheckboxRecords() } | ||
$table.print(XEUtils.assign(opts, menu.params)) | ||
} | ||
}, | ||
@@ -767,5 +841,7 @@ /** | ||
*/ | ||
OPEN_FIND (params) { | ||
const { $event, $table } = params as VxeGlobalMenusHandles.MenusCallbackParams & { $table: VxeTableConstructor & VxeTablePrivateMethods } | ||
$table.triggerFNROpenEvent($event, 'find') | ||
OPEN_FIND: { | ||
menuMethod (params) { | ||
const { $event, $table } = params as VxeGlobalMenusHandles.MenuMethodParams & { $table: VxeTableConstructor & VxeTablePrivateMethods } | ||
$table.triggerFNROpenEvent($event, 'find') | ||
} | ||
}, | ||
@@ -775,5 +851,7 @@ /** | ||
*/ | ||
OPEN_REPLACE (params) { | ||
const { $event, $table } = params as VxeGlobalMenusHandles.MenusCallbackParams & { $table: VxeTableConstructor & VxeTablePrivateMethods } | ||
$table.triggerFNROpenEvent($event, 'replace') | ||
OPEN_REPLACE: { | ||
menuMethod (params) { | ||
const { $event, $table } = params as VxeGlobalMenusHandles.MenuMethodParams & { $table: VxeTableConstructor & VxeTablePrivateMethods } | ||
$table.triggerFNROpenEvent($event, 'replace') | ||
} | ||
}, | ||
@@ -783,6 +861,8 @@ /** | ||
*/ | ||
HIDDEN_COLUMN (params) { | ||
const { $table, column } = params | ||
if (column) { | ||
$table.hideColumn(column) | ||
HIDDEN_COLUMN: { | ||
menuMethod (params) { | ||
const { $table, column } = params | ||
if (column) { | ||
$table.hideColumn(column) | ||
} | ||
} | ||
@@ -805,5 +885,7 @@ }, | ||
*/ | ||
RESET_COLUMN (params) { | ||
const { $table } = params | ||
$table.resetColumn({ visible: true, resizable: false }) | ||
RESET_COLUMN: { | ||
menuMethod (params) { | ||
const { $table } = params | ||
$table.resetColumn({ visible: true, resizable: false }) | ||
} | ||
}, | ||
@@ -813,5 +895,7 @@ /** | ||
*/ | ||
RESET_RESIZABLE (params) { | ||
const { $table } = params | ||
$table.resetColumn({ visible: false, resizable: true }) | ||
RESET_RESIZABLE: { | ||
menuMethod (params) { | ||
const { $table } = params | ||
$table.resetColumn({ visible: false, resizable: true }) | ||
} | ||
}, | ||
@@ -821,5 +905,7 @@ /** | ||
*/ | ||
RESET_ALL (params) { | ||
const { $table } = params | ||
$table.resetColumn(true) | ||
RESET_ALL: { | ||
menuMethod (params) { | ||
const { $table } = params | ||
$table.resetColumn(true) | ||
} | ||
} | ||
@@ -826,0 +912,0 @@ }) |
{ | ||
"name": "vxe-table-plugin-menus", | ||
"version": "3.0.9", | ||
"version": "3.1.0", | ||
"description": "基于 vxe-table 的表格插件,提供实用的快捷菜单集", | ||
@@ -52,7 +52,7 @@ "scripts": { | ||
"vue": "^3.3.4", | ||
"vxe-table": "^4.4.6", | ||
"vxe-table": "^4.5.1", | ||
"xe-utils": "^3.5.11" | ||
}, | ||
"peerDependencies": { | ||
"vxe-table": "^4.0.27" | ||
"vxe-table": "^4.5.0" | ||
}, | ||
@@ -59,0 +59,0 @@ "repository": { |
@@ -12,3 +12,3 @@ # vxe-table-plugin-menus | ||
对应 vxe-table v4 版本 | ||
依赖 vxe-table v4 版本 | ||
@@ -15,0 +15,0 @@ ## Installing |
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
237461
3356