Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
xuliangzhan committed Sep 1, 2020
1 parent 2c62904 commit 51151ff
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ VXETable.use(VXETablePluginMenus, {
| REVERT_ROW | 还原行数据的值 ||
| REVERT_CHECKBOX_ROW | 还原复选框选中行数据的值 ||
| REVERT_ALL | 还原所有数据的值 ||
| MERGE_CELL | 如果启用 mouse-config.area 功能,临时合并区域范围内的单元格 ||
| MERGE_OR_CLEAR | 如果启用 mouse-config.area 功能,如果所选区域内已存在合并单元格,则取消临时合并,否则临时合并 ||
| MERGE_CELL | 如果启用 mouse-config.area 功能,临时合并区域范围内的单元格,不管是否存在已合并 ||
| CLEAR_MERGE_CELL | 如果启用 mouse-config.area 功能,清除区域范围内单元格的临时合并状态 ||
| CLEAR_ALL_MERGE | 清除所有单元格及表尾的临时合并状态 ||
| COPY_CELL | 复制单元格数据的值;如果启用 mouse-config.area 功能,则复制区域范围内的单元格数据,支持 Excel 和 WPS ||
Expand Down
26 changes: 25 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,29 @@ const menuMap = {
}
},
/**
* 如果启用 mouse-config.area 功能,临时合并区域范围内的单元格
* 如果启用 mouse-config.area 功能,如果所选区域内已存在合并单元格,则取消临时合并,否则临时合并
*/
MERGE_OR_CLEAR(params: MenuLinkParams) {
const { $table } = params
const cellAreas = $table.getCellAreas()
const beenMerges = getBeenMerges(params)
if (beenMerges.length) {
$table.removeMergeCells(beenMerges)
} else {
$table.setMergeCells(
cellAreas.map(({ rows, cols }) => {
return {
row: rows[0],
col: cols[0],
rowspan: rows.length,
colspan: cols.length
}
})
)
}
},
/**
* 如果启用 mouse-config.area 功能,临时合并区域范围内的单元格,不管是否存在已合并
*/
MERGE_CELL(params: MenuLinkParams) {
const { $table } = params
Expand Down Expand Up @@ -519,6 +541,7 @@ function checkPrivilege(item: MenuFirstOption | MenuChildOption, params: Interce
case 'COPY_CELL':
case 'CUT_CELL':
case 'PASTE_CELL':
case 'MERGE_OR_CLEAR':
case 'MERGE_CELL':
case 'REVERT_CELL':
case 'REVERT_ROW':
Expand Down Expand Up @@ -567,6 +590,7 @@ function checkPrivilege(item: MenuFirstOption | MenuChildOption, params: Interce
item.disabled = cellAreas.length > 1
break
}
case 'MERGE_OR_CLEAR':
case 'MERGE_CELL': {
const cellAreas = $table.mouseConfig && $table.mouseOpts.area ? $table.getCellAreas() : []
item.disabled = !cellAreas.length || (cellAreas.length === 1 && cellAreas[0].rows.length === 1 && cellAreas[0].cols.length === 1) || !checkCellOverlay(params, cellAreas)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vxe-table-plugin-menus",
"version": "1.4.7",
"version": "1.4.8",
"description": "基于 vxe-table 表格的增强插件,提供实用的快捷菜单集",
"scripts": {
"lib": "gulp build"
Expand Down

0 comments on commit 51151ff

Please sign in to comment.