diff --git a/packages/components/table/src/table-body/render-helper.ts b/packages/components/table/src/table-body/render-helper.ts index 9ecbc03a7c..9531a7c774 100644 --- a/packages/components/table/src/table-body/render-helper.ts +++ b/packages/components/table/src/table-body/render-helper.ts @@ -116,7 +116,7 @@ function useRender(props: Partial>) { 'td', { style: getCellStyle($index, cellIndex, row, column), - class: getCellClass($index, cellIndex, row, column), + class: getCellClass($index, cellIndex, row, column, colspan - 1), key: `${patchKey}${baseKey}`, rowspan, colspan, diff --git a/packages/components/table/src/table-body/styles-helper.ts b/packages/components/table/src/table-body/styles-helper.ts index 00ea147486..2b52210001 100644 --- a/packages/components/table/src/table-body/styles-helper.ts +++ b/packages/components/table/src/table-body/styles-helper.ts @@ -79,11 +79,19 @@ function useStyles(props: Partial>) { rowIndex: number, columnIndex: number, row: T, - column: TableColumnCtx + column: TableColumnCtx, + offset: number ) => { const fixedClasses = column.isSubColumn ? [] - : getFixedColumnsClass(ns.b(), columnIndex, props?.fixed, props.store) + : getFixedColumnsClass( + ns.b(), + columnIndex, + props?.fixed, + props.store, + undefined, + offset + ) const classes = [column.id, column.align, column.className, ...fixedClasses] const cellClassName = parent?.props.cellClassName if (typeof cellClassName === 'string') { diff --git a/packages/components/table/src/util.ts b/packages/components/table/src/util.ts index 2ebcdb43db..a0b3be1f2d 100644 --- a/packages/components/table/src/util.ts +++ b/packages/components/table/src/util.ts @@ -440,18 +440,22 @@ export const getFixedColumnsClass = ( index: number, fixed: string | boolean, store: any, - realColumns?: TableColumnCtx[] + realColumns?: TableColumnCtx[], + offset = 0 ) => { const classes: string[] = [] const { direction, start } = isFixedColumn(index, fixed, store, realColumns) if (direction) { const isLeft = direction === 'left' classes.push(`${namespace}-fixed-column--${direction}`) - if (isLeft && start === store.states.fixedLeafColumnsLength.value - 1) { + if ( + isLeft && + start + offset === store.states.fixedLeafColumnsLength.value - 1 + ) { classes.push('is-last-column') } else if ( !isLeft && - start === + start - offset === store.states.columns.value.length - store.states.rightFixedLeafColumnsLength.value ) {