Skip to content

Commit

Permalink
releases 4.9.15
Browse files Browse the repository at this point in the history
  • Loading branch information
xuliangzhan committed Dec 5, 2024
1 parent 68ca1bc commit cc8dcee
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 6 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.9.14",
"version": "4.9.15",
"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.3.14"
"vxe-pc-ui": "^4.3.15"
},
"devDependencies": {
"@types/resize-observer-browser": "^0.1.11",
Expand Down
2 changes: 1 addition & 1 deletion packages/table/module/edit/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ hooks.add('tableEditModule', {
params.cell = cell
if (cell && isEnableConf(editConfig) && isEnableConf(editRender)) {
// 激活编辑
if (!$xeTable.hasPendingByRow(row)) {
if (!$xeTable.isPendingByRow(row)) {
if (actived.row !== row || (mode === 'cell' ? actived.column !== column : false)) {
// 判断是否禁用编辑
let type: 'edit-disabled' | 'edit-activated' = 'edit-disabled'
Expand Down
2 changes: 2 additions & 0 deletions packages/table/src/emits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ export default [
'column-dragover',
'column-dragend',

'enter-append-row',

'edit-actived', // 废弃

'edit-activated',
Expand Down
39 changes: 36 additions & 3 deletions packages/table/src/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5482,6 +5482,7 @@ export default defineComponent({
tablePrivateMethods.preventEvent(evnt, 'event.keydown', null, () => {
const { mouseConfig, keyboardConfig, treeConfig, editConfig, highlightCurrentRow } = props
const { ctxMenuStore, editStore, currentRow } = reactData
const { afterFullData } = internalData
const isMenu = computeIsMenu.value
const bodyMenu = computeBodyMenu.value
const keyboardOpts = computeKeyboardOpts.value
Expand Down Expand Up @@ -5564,6 +5565,7 @@ export default defineComponent({
internalData._keyCtx = false
}, 1000)
} else if (isEnter && !isAltKey && keyboardConfig && keyboardOpts.isEnter && (selected.row || actived.row || (treeConfig && (rowOpts.isCurrent || highlightCurrentRow) && currentRow))) {
const { isLastEnterAppendRow, beforeEnterMethod, enterMethod } = keyboardOpts
// 退出选中
if (hasCtrlKey) {
// 如果是激活编辑状态,则取消编辑
Expand All @@ -5589,7 +5591,35 @@ export default defineComponent({
if (keyboardOpts.enterToTab) {
$xeTable.moveTabSelected(targetArgs, hasShiftKey, evnt)
} else {
$xeTable.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 }) => {
$xeTable.scrollToRow(newRow, selected.column)
$xeTable.setSelectCell(newRow, selected.column)
})
$xeTable.dispatchEvent('enter-append-row', etrParams, evnt)
return
}
}
$xeTable.moveSelected(targetArgs, isLeftArrow, false, isRightArrow, true, evnt)
if (enterMethod) {
enterMethod(etrParams)
}
}
}
}
} else if (treeConfig && (rowOpts.isCurrent || highlightCurrentRow) && currentRow) {
Expand Down Expand Up @@ -5693,7 +5723,7 @@ export default defineComponent({
.then(() => tablePrivateMethods.triggerCurrentRowEvent(evnt, params))
}
} else if (keyboardConfig && isEnableConf(editConfig) && keyboardOpts.isEdit && !hasCtrlKey && !hasMetaKey && (isSpacebar || (keyCode >= 48 && keyCode <= 57) || (keyCode >= 65 && keyCode <= 90) || (keyCode >= 96 && keyCode <= 111) || (keyCode >= 186 && keyCode <= 192) || (keyCode >= 219 && keyCode <= 222))) {
const { editMethod } = keyboardOpts
const { editMode, editMethod } = keyboardOpts
// 启用编辑后,空格键功能将失效
// if (isSpacebar) {
// evnt.preventDefault()
Expand All @@ -5713,7 +5743,10 @@ export default defineComponent({
if (editMethod) {
editMethod(params)
} else {
setCellValue(selected.row, selected.column, null)
// 追加方式与覆盖式
if (editMode !== 'insert') {
setCellValue(selected.row, selected.column, null)
}
$xeTable.handleEdit(selected.args, evnt)
}
}
Expand Down

0 comments on commit cc8dcee

Please sign in to comment.