提交 044e2e4e 作者: 无木

fix(table): `rowClassName` not worked with `striped`

修复rowClassName属性无法和striped同时生效的问题

fixed: #1167
上级 59a90877
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
- **BasicTable** - **BasicTable**
- 单元格编辑新增提交回调,将根据回调函数返回的结果来决定是否将数据提交到表格 - 单元格编辑新增提交回调,将根据回调函数返回的结果来决定是否将数据提交到表格
- 行编辑添加校验方法,允许只校验而不提交值,以便异步保存数据成功后才提交倒表格 - 行编辑添加校验方法,允许只校验而不提交值,以便异步保存数据成功后才提交倒表格
- 修复`rowClassName`属性无法和`striped`同时使用的问题
### 🐛 Bug Fixes ### 🐛 Bug Fixes
......
...@@ -6,11 +6,14 @@ import { isFunction } from '/@/utils/is'; ...@@ -6,11 +6,14 @@ import { isFunction } from '/@/utils/is';
export function useTableStyle(propsRef: ComputedRef<BasicTableProps>, prefixCls: string) { export function useTableStyle(propsRef: ComputedRef<BasicTableProps>, prefixCls: string) {
function getRowClassName(record: TableCustomRecord, index: number) { function getRowClassName(record: TableCustomRecord, index: number) {
const { striped, rowClassName } = unref(propsRef); const { striped, rowClassName } = unref(propsRef);
if (!striped) return; const classNames: string[] = [];
if (striped) {
classNames.push((index || 0) % 2 === 1 ? `${prefixCls}-row__striped` : '');
}
if (rowClassName && isFunction(rowClassName)) { if (rowClassName && isFunction(rowClassName)) {
return rowClassName(record); classNames.push(rowClassName(record, index));
} }
return (index || 0) % 2 === 1 ? `${prefixCls}-row__striped` : ''; return classNames.filter((cls) => !!cls).join(' ');
} }
return { getRowClassName }; return { getRowClassName };
......
...@@ -25,7 +25,7 @@ export interface TableRowSelection<T = any> extends ITableRowSelection { ...@@ -25,7 +25,7 @@ export interface TableRowSelection<T = any> extends ITableRowSelection {
/** /**
* Callback executed when select/deselect one row * Callback executed when select/deselect one row
* @type FunctionT * @type Function
*/ */
onSelect?: (record: T, selected: boolean, selectedRows: Object[], nativeEvent: Event) => any; onSelect?: (record: T, selected: boolean, selectedRows: Object[], nativeEvent: Event) => any;
...@@ -291,7 +291,7 @@ export interface BasicTableProps<T = any> { ...@@ -291,7 +291,7 @@ export interface BasicTableProps<T = any> {
* Row's className * Row's className
* @type Function * @type Function
*/ */
rowClassName?: (record: TableCustomRecord<T>) => string; rowClassName?: (record: TableCustomRecord<T>, index: number) => string;
/** /**
* Row selection config * Row selection config
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论