【issues/7200】basicTable选中后没有选中样式 ---

pull/7333/head
JEECG 2 months ago
parent c868d90c2f
commit a3997dfd16

@ -2,8 +2,40 @@ import type { ComputedRef } from 'vue';
import type { BasicTableProps, TableCustomRecord } from '../types/table';
import { unref } from 'vue';
import { isFunction } from '/@/utils/is';
import { ROW_KEY } from '/@/components/Table/src/const';
export function useTableStyle(propsRef: ComputedRef<BasicTableProps>, prefixCls: string) {
/**
* 2024-09-19
* liaozhiyang
* issues/7200basicTable选中后没有选中样式
* */
const isChecked = (propsRef, record) => {
const getAutoCreateKey = () => {
return unref(propsRef).autoCreateKey && !unref(propsRef).rowKey;
};
const getRowKey = () => {
const { rowKey } = unref(propsRef);
return getAutoCreateKey() ? ROW_KEY : rowKey;
};
// key
const getRecordKey = (record) => {
const key = getRowKey();
if (!key) {
return record[ROW_KEY];
} else if (isFunction(key)) {
return key(record);
} else {
return record[key];
}
};
const { rowSelection } = unref(propsRef);
if (rowSelection?.selectedRowKeys?.length) {
return rowSelection.selectedRowKeys.includes(getRecordKey(record));
}
return false;
};
function getRowClassName(record: TableCustomRecord, index: number) {
const { striped, rowClassName } = unref(propsRef);
const classNames: string[] = [];
@ -13,6 +45,11 @@ export function useTableStyle(propsRef: ComputedRef<BasicTableProps>, prefixCls:
if (rowClassName && isFunction(rowClassName)) {
classNames.push(rowClassName(record, index));
}
// update-begin--author:liaozhiyang---date:20240919---forissues/7200basicTable
if (isChecked(propsRef, record)) {
classNames.push('ant-table-row-selected');
}
// update-end--author:liaozhiyang---date:20240919---forissues/7200basicTable
return classNames.filter((cls) => !!cls).join(' ');
}

Loading…
Cancel
Save