From 17acb2a36f00b07d63a48d18251e845b2c38d382 Mon Sep 17 00:00:00 2001
From: H171 <1091088708@qq.com>
Date: Wed, 3 May 2023 14:37:48 +0800
Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=A0=91=E5=BD=A2?=
=?UTF-8?q?=E8=A1=A8=E6=A0=BC=E9=94=AE=E7=9B=98=E5=AF=BC=E8=88=AA=E9=94=99?=
=?UTF-8?q?=E4=BD=8D=E7=9A=84=E9=97=AE=E9=A2=98=20#1991?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
examples/views/table/scroll/Tree.vue | 4 ++++
packages/keyboard/src/hook.ts | 17 +++++++++--------
2 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/examples/views/table/scroll/Tree.vue b/examples/views/table/scroll/Tree.vue
index 27b0d64dc9..0a9f385a23 100644
--- a/examples/views/table/scroll/Tree.vue
+++ b/examples/views/table/scroll/Tree.vue
@@ -15,6 +15,10 @@
ref="xTable"
:tree-config="{transform: true, rowField: 'id', parentField: 'parentId'}"
:scroll-y="{gt: 0}"
+ :mouse-config="{selected: true}"
+ :checkbox-config="{checkField: 'checked'}"
+ :edit-config="{trigger: 'dblclick', mode: 'cell', showStatus: true}"
+ :keyboard-config="{isArrow: true, isDel: true, isEnter: true, isTab: true, isEdit: true}"
:data="demo1.tableData">
diff --git a/packages/keyboard/src/hook.ts b/packages/keyboard/src/hook.ts
index b9c6cd96e9..19cbb881c8 100644
--- a/packages/keyboard/src/hook.ts
+++ b/packages/keyboard/src/hook.ts
@@ -230,14 +230,14 @@ const tableKeyboardHook: VxeGlobalHooksHandles.HookOptions = {
// 处理 Tab 键移动
moveTabSelected (args, isLeft, evnt) {
const { editConfig } = props
- const { afterFullData, visibleColumn } = internalData
+ const { afterFullData, visibleColumn, scrollYStore } = internalData
const editOpts = computeEditOpts.value
- let targetRow
- let targetRowIndex: any
- let targetColumnIndex: any
const params = Object.assign({}, args)
- const _rowIndex = $xetable.getVTRowIndex(params.row)
+ const _rowIndex = $xetable.getVMRowIndex(params.row) + scrollYStore.startIndex
const _columnIndex = $xetable.getVTColumnIndex(params.column)
+ let targetRowIndex = _rowIndex
+ let targetRow = afterFullData[targetRowIndex]
+ let targetColumnIndex = params.columnIndex
evnt.preventDefault()
if (isLeft) {
// 向左
@@ -251,9 +251,10 @@ const tableKeyboardHook: VxeGlobalHooksHandles.HookOptions = {
} else {
targetColumnIndex = _columnIndex - 1
}
+ // 向右
} else {
if (_columnIndex >= visibleColumn.length - 1) {
- // 如果已经是第一列,则移动到上一行
+ // 如果已经是第最后一列,则移动到下一行
if (_rowIndex < afterFullData.length - 1) {
targetRowIndex = _rowIndex + 1
targetRow = afterFullData[targetRowIndex]
@@ -329,9 +330,9 @@ const tableKeyboardHook: VxeGlobalHooksHandles.HookOptions = {
},
// 处理可编辑方向键移动
moveSelected (args, isLeftArrow, isUpArrow, isRightArrow, isDwArrow, evnt) {
- const { afterFullData, visibleColumn } = internalData
+ const { afterFullData, visibleColumn, scrollYStore } = internalData
const params = Object.assign({}, args)
- const _rowIndex = $xetable.getVTRowIndex(params.row)
+ const _rowIndex = $xetable.getVMRowIndex(params.row) + scrollYStore.startIndex
const _columnIndex = $xetable.getVTColumnIndex(params.column)
evnt.preventDefault()
if (isUpArrow && _rowIndex > 0) {