20260723225430

This commit is contained in:
oneao committed 2026-07-23 22:54:30 +08:00
1 parent 4d118a0037
commit 4f40ad9f11
2 files changed
+24 -9

No files matched your search

@@ -22,7 +22,7 @@ const props = defineProps({
activeRowKey: { type: [String, Number], default: null },
});
const emit = defineEmits(["update:columns"]);
const emit = defineEmits(["update:columns", "row-click"]);
function getRowKey(row) {
return typeof props.rowKey === "function" ? props.rowKey(row) : row?.[props.rowKey];
@@ -30,9 +30,19 @@ function getRowKey(row) {
const selectedRowKeySet = computed(() => new Set(props.rowSelection?.selectedRowKeys || []));
// 追踪用户点击的单元格列,用于编辑态自动聚焦到对应列
const activeColKey = ref(null);
function onStkRowClick(ev, row, data) {
const td = ev.target.closest?.("td");
activeColKey.value = td?.dataset?.colKey || null;
emit("row-click", ev, row, data);
}
const EditableCell = createEditableCellRenderer({
getRowKey,
getActiveRowKey: () => props.activeRowKey,
getActiveColKey: () => activeColKey.value,
});
const { SelectionCell, SelectionHeaderCell } = createSelectionCellRenderers({
@@ -154,6 +164,7 @@ defineExpose({ scrollToRow });
:row-key="rowKey"
:bordered="bordered"
:no-data-full="noDataFull"
@row-click="onStkRowClick"
>
<template v-for="(slot, name) in forwardSlots" :key="name" #[name]="slotProps">
<slot :name="name" v-bind="slotProps || {}" />