feat: Support table row selection (#10072)

This commit is contained in:
2025-08-20 16:39:17 +08:00 committed by GitHub
parent 536a5fc1a0
commit d6f16cf700
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -14,6 +14,7 @@
@selection-change="handleSelectionChange"
:max-height="tableHeight"
@row-contextmenu="handleRightClick"
@row-click="handleRowClick"
>
<slot></slot>
<template #empty>
@ -190,6 +191,23 @@ watch(
{ immediate: true },
);
function handleRowClick(row: any, column: any, event: MouseEvent) {
if (!tableRef.value) return;
const target = event.target as HTMLElement;
if (target.closest('.el-checkbox')) return;
if (
target.closest('button') ||
target.closest('a') ||
target.closest('.el-switch') ||
target.closest('.table-link') ||
target.closest('.cursor-pointer')
) {
return;
}
tableRef.value.refElTable.toggleRowSelection(row);
}
defineExpose({
clearSelects,
sort,