Skip to content

Commit

Permalink
fix 修复按键isDel和isBack问题 #2526
Browse files Browse the repository at this point in the history
  • Loading branch information
xuliangzhan committed Aug 21, 2024
1 parent f060bc8 commit c679f98
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 26 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vxe-table",
"version": "4.7.66",
"version": "4.7.67",
"description": "一个基于 vue 的 PC 端表格组件,支持增删改查、虚拟树、列拖拽,懒加载、快捷菜单、数据校验、树形结构、打印、导入导出、自定义模板、渲染器、JSON 配置式...",
"scripts": {
"update": "npm install --legacy-peer-deps",
Expand Down Expand Up @@ -28,7 +28,7 @@
"style": "lib/style.css",
"typings": "types/index.d.ts",
"dependencies": {
"vxe-pc-ui": "^4.1.0"
"vxe-pc-ui": "^4.1.1"
},
"devDependencies": {
"@types/resize-observer-browser": "^0.1.11",
Expand Down
51 changes: 27 additions & 24 deletions packages/table/src/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4982,6 +4982,7 @@ export default defineComponent({
const operArrow = isLeftArrow || isUpArrow || isRightArrow || isDwArrow
const operCtxMenu = isMenu && ctxMenuStore.visible && (isEnter || isSpacebar || operArrow)
const isEditStatus = isEnableConf(editConfig) && actived.column && actived.row
const beforeEditMethod = editOpts.beforeEditMethod || editOpts.activeMethod
let params: any
if (operCtxMenu) {
// 如果配置了右键菜单; 支持方向键操作、回车
Expand Down Expand Up @@ -5108,18 +5109,21 @@ export default defineComponent({
columnIndex: tableMethods.getColumnIndex(selected.column),
$table: $xeTable
}
if (delMethod) {
delMethod(delPaqrams)
} else {
setCellValue(selected.row, selected.column, null)
// 是否被禁用
if (!beforeEditMethod || beforeEditMethod(params)) {
if (delMethod) {
delMethod(delPaqrams)
} else {
setCellValue(selected.row, selected.column, null)
}
// 如果按下 del 键,更新表尾数据
tableMethods.updateFooter()
$xeTable.dispatchEvent('cell-delete-value', delPaqrams, evnt)
}
// 如果按下 del 键,更新表尾数据
tableMethods.updateFooter()
$xeTable.dispatchEvent('cell-delete-value', delPaqrams, evnt)
}
} else if (hasBackspaceKey && keyboardConfig && keyboardOpts.isBack && isEnableConf(editConfig) && (selected.row || selected.column)) {
if (!isEditStatus) {
const { delMethod, backMethod } = keyboardOpts
const { backMethod } = keyboardOpts
// 如果是删除键
if (keyboardOpts.isDel && isEnableConf(editConfig) && (selected.row || selected.column)) {
const delPaqrams = {
Expand All @@ -5129,23 +5133,22 @@ export default defineComponent({
columnIndex: tableMethods.getColumnIndex(selected.column),
$table: $xeTable
}
if (delMethod) {
delMethod(delPaqrams)
} else {
setCellValue(selected.row, selected.column, null)
}
if (backMethod) {
backMethod({
row: selected.row,
rowIndex: tableMethods.getRowIndex(selected.row),
column: selected.column,
columnIndex: tableMethods.getColumnIndex(selected.column),
$table: $xeTable
})
} else {
$xeTable.handleActived(selected.args, evnt)
// 是否被禁用
if (!beforeEditMethod || beforeEditMethod(params)) {
if (backMethod) {
backMethod({
row: selected.row,
rowIndex: tableMethods.getRowIndex(selected.row),
column: selected.column,
columnIndex: tableMethods.getColumnIndex(selected.column),
$table: $xeTable
})
} else {
setCellValue(selected.row, selected.column, null)
$xeTable.handleActived(selected.args, evnt)
}
$xeTable.dispatchEvent('cell-backspace-value', delPaqrams, evnt)
}
$xeTable.dispatchEvent('cell-backspace-value', delPaqrams, evnt)
}
}
} else if (hasBackspaceKey && keyboardConfig && treeConfig && keyboardOpts.isBack && (rowOpts.isCurrent || highlightCurrentRow) && currentRow) {
Expand Down

0 comments on commit c679f98

Please sign in to comment.