diff --git a/packages/opendesign/src/table/OTable.vue b/packages/opendesign/src/table/OTable.vue index 217a2099198fa40d9802a4716a020690caf18c41..fed221a973978970ee2368b83a7fc84b28de8106 100644 --- a/packages/opendesign/src/table/OTable.vue +++ b/packages/opendesign/src/table/OTable.vue @@ -5,7 +5,7 @@ import { computed, ref } from 'vue'; import { IconLoading } from '../_utils/icons'; import { isHoverDevice, isString } from '../_utils/is'; import { useI18n } from '../locale'; -import { useTableMeta, DEFAULT_CELL_COL_MARKER, DEFAULT_ROW_MARKER } from './useTableMeta'; +import { useTableMeta, DEFAULT_CELL_LAST_COL_MARKER, DEFAULT_ROW_LAST_MARKER } from './useTableMeta'; const props = defineProps(tableProps); @@ -18,7 +18,7 @@ defineSlots<{ empty(): any; loading(): any; [k: `th_${string}`]: (props: { column: TableColumnT }) => any; - [k: `td_${string}`]: (props: { row: TableRowT }) => any; + [k: `td_${string}`]: (props: { row: TableRowT; rowIndex: number }) => any; }>(); const { t } = useI18n(); @@ -47,8 +47,7 @@ const highlightedDoms: Array = []; let highlightTrigger: HTMLTableCellElement | null = null; const clearHighlight = () => { highlightedDoms.forEach((cell) => { - cell.classList.remove('o-table-hover'); - cell.classList.remove('o-table-active'); + cell.classList.remove('o-table-highlight'); }); highlightedDoms.length = 0; highlightTrigger = null; @@ -57,7 +56,7 @@ const applyHighlight = (dom: HTMLTableRowElement | HTMLTableCellElement, classNa highlightedDoms.push(dom); dom.classList.add(className); }; -const highlightTable = (cell: HTMLTableCellElement, type: 'hover' | 'active') => { +const highlightTable = (cell: HTMLTableCellElement) => { if (highlightTrigger === cell) { // 避免重复添加高亮样式 return; @@ -71,7 +70,7 @@ const highlightTable = (cell: HTMLTableCellElement, type: 'hover' | 'active') => const section = cellMeta.section; const rowEl = section.rows[cellMeta.rowStart]; const rowSpan = cellMeta.el.rowSpan; - const className = `o-table-${type}`; + const className = 'o-table-highlight'; applyHighlight(rowEl, className); if (rowSpan === 1) { const rows = section.data[cellMeta.rowStart]; @@ -104,14 +103,14 @@ const handleMouseOver = (e: MouseEvent) => { if (!target || !isHoverDevice) { return; } - highlightTable(target, 'hover'); + highlightTable(target); }; const handleTouchStart = (e: TouchEvent) => { const target = getTdEl(e.target); if (!target) { return; } - highlightTable(target, 'active'); + highlightTable(target); };