mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 21:49:25 +08:00
fix(table): update row key generation to include index and improve tooltip import
This commit is contained in:
parent
823d67ac13
commit
9d0a989e46
@ -59,6 +59,7 @@ import {
|
|||||||
} from '../../../formily/NocoBaseRecursionField';
|
} from '../../../formily/NocoBaseRecursionField';
|
||||||
import { withDynamicSchemaProps } from '../../../hoc/withDynamicSchemaProps';
|
import { withDynamicSchemaProps } from '../../../hoc/withDynamicSchemaProps';
|
||||||
import { withSkeletonComponent } from '../../../hoc/withSkeletonComponent';
|
import { withSkeletonComponent } from '../../../hoc/withSkeletonComponent';
|
||||||
|
import { withTooltipComponent } from '../../../hoc/withTooltipComponent';
|
||||||
import { LinkageRuleDataKeyMap } from '../../../schema-settings/LinkageRules/type';
|
import { LinkageRuleDataKeyMap } from '../../../schema-settings/LinkageRules/type';
|
||||||
import { GetStyleRules } from '../../../schema-settings/LinkageRules/useActionValues';
|
import { GetStyleRules } from '../../../schema-settings/LinkageRules/useActionValues';
|
||||||
import { HighPerformanceSpin } from '../../common/high-performance-spin/HighPerformanceSpin';
|
import { HighPerformanceSpin } from '../../common/high-performance-spin/HighPerformanceSpin';
|
||||||
@ -66,7 +67,6 @@ import { useToken } from '../__builtins__';
|
|||||||
import { useAssociationFieldContext } from '../association-field/hooks';
|
import { useAssociationFieldContext } from '../association-field/hooks';
|
||||||
import { TableSkeleton } from './TableSkeleton';
|
import { TableSkeleton } from './TableSkeleton';
|
||||||
import { extractIndex, isCollectionFieldComponent, isColumnComponent } from './utils';
|
import { extractIndex, isCollectionFieldComponent, isColumnComponent } from './utils';
|
||||||
import { withTooltipComponent } from '../../../hoc/withTooltipComponent';
|
|
||||||
|
|
||||||
type BodyRowComponentProps = {
|
type BodyRowComponentProps = {
|
||||||
rowIndex?: number;
|
rowIndex?: number;
|
||||||
@ -929,9 +929,9 @@ export const Table: any = withDynamicSchemaProps(
|
|||||||
* @param record
|
* @param record
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
const defaultRowKey = useCallback((record: any) => {
|
const defaultRowKey = useCallback((record: any, index) => {
|
||||||
if (rowKey) {
|
if (rowKey) {
|
||||||
return getRowKey(record);
|
return getRowKey(record, index);
|
||||||
}
|
}
|
||||||
if (record.key) {
|
if (record.key) {
|
||||||
return record.key;
|
return record.key;
|
||||||
@ -947,14 +947,9 @@ export const Table: any = withDynamicSchemaProps(
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const getRowKey = useCallback(
|
const getRowKey = useCallback(
|
||||||
(record: any) => {
|
(record: any, index) => {
|
||||||
if (Array.isArray(rowKey)) {
|
if (Array.isArray(rowKey)) {
|
||||||
// 使用多个字段值组合生成唯一键
|
return index;
|
||||||
return rowKey
|
|
||||||
.map((keyField) => {
|
|
||||||
return record[keyField]?.toString() || '';
|
|
||||||
})
|
|
||||||
.join('-');
|
|
||||||
} else if (typeof rowKey === 'string') {
|
} else if (typeof rowKey === 'string') {
|
||||||
return record[rowKey];
|
return record[rowKey];
|
||||||
} else {
|
} else {
|
||||||
@ -1063,7 +1058,7 @@ export const Table: any = withDynamicSchemaProps(
|
|||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<div className={classNames(checked ? 'checked' : null, rowSelectCheckboxContentClass)}>
|
<div className={classNames(checked ? 'checked' : null, rowSelectCheckboxContentClass)}>
|
||||||
{dragSort && <SortHandle id={getRowKey(record)} />}
|
{dragSort && <SortHandle id={getRowKey(record, index)} />}
|
||||||
{showIndex && <TableIndex index={index} />}
|
{showIndex && <TableIndex index={index} />}
|
||||||
</div>
|
</div>
|
||||||
{isRowSelect && (
|
{isRowSelect && (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user