Skip to content

Commit

Permalink
releases 3.11.18
Browse files Browse the repository at this point in the history
  • Loading branch information
xuliangzhan committed Dec 5, 2024
1 parent 0bb7759 commit 59c79dc
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 5 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": "3.11.17",
"version": "3.11.18",
"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": "^3.3.17"
"vxe-pc-ui": "^3.3.18"
},
"devDependencies": {
"@babel/plugin-transform-modules-commonjs": "^7.25.7",
Expand Down
42 changes: 39 additions & 3 deletions packages/table/src/methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3388,9 +3388,13 @@ const Methods = {
* 全局键盘事件
*/
handleGlobalKeydownEvent (evnt: any) {
const $xeTable = this
const internalData = $xeTable

// 该行为只对当前激活的表格有效
if (this.isActivated) {
this.preventEvent(evnt, 'event.keydown', null, () => {
const { afterFullData } = internalData
const { filterStore, isCtxMenu, ctxMenuStore, editStore, editOpts, editConfig, mouseConfig, mouseOpts, keyboardConfig, keyboardOpts, treeConfig, treeOpts, highlightCurrentRow, currentRow, bodyCtxMenu, rowOpts } = this
const { selected, actived } = editStore
const { keyCode } = evnt
Expand Down Expand Up @@ -3456,6 +3460,7 @@ const Methods = {
this._keyCtx = false
}, 1000)
} else if (isEnter && !hasAltKey && keyboardConfig && keyboardOpts.isEnter && (selected.row || actived.row || (treeConfig && (rowOpts.isCurrent || highlightCurrentRow) && currentRow))) {
const { isLastEnterAppendRow, beforeEnterMethod, enterMethod } = keyboardOpts
// 退出选中
if (hasCtrlKey) {
// 如果是激活编辑状态,则取消编辑
Expand All @@ -3481,7 +3486,35 @@ const Methods = {
if (keyboardOpts.enterToTab) {
this.moveTabSelected(targetArgs, hasShiftKey, evnt)
} else {
this.moveSelected(targetArgs, isLeftArrow, false, isRightArrow, true, evnt)
const _rowIndex = $xeTable.getVTRowIndex(selected.row)
const etrParams = {
row: selected.row,
rowIndex: $xeTable.getRowIndex(selected.row),
$rowIndex: $xeTable.getVMRowIndex(selected.row),
_rowIndex,
column: selected.column,
columnIndex: $xeTable.getColumnIndex(selected.column),
$columnIndex: $xeTable.getVMColumnIndex(selected.column),
_columnIndex: $xeTable.getVTColumnIndex(selected.column),
$table: $xeTable
}
if (!beforeEnterMethod || beforeEnterMethod(etrParams) !== false) {
// 最后一行按下回车键,自动追加一行
if (isLastEnterAppendRow) {
if (_rowIndex >= afterFullData.length - 1) {
$xeTable.insertAt({}, -1).then(({ row: newRow }: any) => {
$xeTable.scrollToRow(newRow, selected.column)
$xeTable.setSelectCell(newRow, selected.column)
})
$xeTable.dispatchEvent('enter-append-row', etrParams, evnt)
return
}
}
this.moveSelected(targetArgs, isLeftArrow, false, isRightArrow, true, evnt)
if (enterMethod) {
enterMethod(etrParams)
}
}
}
}
} else if (treeConfig && (rowOpts.isCurrent || highlightCurrentRow) && currentRow) {
Expand Down Expand Up @@ -3540,7 +3573,7 @@ const Methods = {
}
} else if (hasBackspaceKey && keyboardConfig && keyboardOpts.isBack && isEnableConf(editConfig) && (selected.row || selected.column)) {
if (!isEditStatus) {
const { backMethod } = keyboardOpts
const { editMode, backMethod } = keyboardOpts
// 如果是删除键
if (keyboardOpts.isDel && isEnableConf(editConfig) && (selected.row || selected.column)) {
const params = {
Expand All @@ -3556,7 +3589,10 @@ const Methods = {
if (backMethod) {
backMethod(params)
} else {
setCellValue(selected.row, selected.column, null)
// 追加方式与覆盖式
if (editMode !== 'insert') {
setCellValue(selected.row, selected.column, null)
}
this.handleEdit(selected.args, evnt)
}
this.emitEvent('cell-backspace-value', params, evnt)
Expand Down

0 comments on commit 59c79dc

Please sign in to comment.