Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions packages/components/table/PrimaryTable.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
import React, { useRef, forwardRef, useImperativeHandle, ReactNode, RefAttributes } from 'react';
import { get } from 'lodash-es';
import React, { forwardRef, ReactNode, RefAttributes, useImperativeHandle, useRef } from 'react';
import classNames from 'classnames';
import { get } from 'lodash-es';

import useDefaultProps from '../hooks/useDefaultProps';
import BaseTable from './BaseTable';
import { primaryTableDefaultProps } from './defaultProps';
import EditableCell, { type EditableCellProps } from './EditableCell';
import useAsyncLoading from './hooks/useAsyncLoading';
import useClassName from './hooks/useClassName';
import useColumnController from './hooks/useColumnController';
import useDragSort from './hooks/useDragSort';
import { useEditableRow } from './hooks/useEditableRow';
import useFilter from './hooks/useFilter';
import useRowExpand from './hooks/useRowExpand';
import useTableHeader, { renderTitle } from './hooks/useTableHeader';
import useRowSelect from './hooks/useRowSelect';
import { TdPrimaryTableProps, PrimaryTableCol, TableRowData, PrimaryTableCellParams } from './type';
import useSorter from './hooks/useSorter';
import useFilter from './hooks/useFilter';
import useDragSort from './hooks/useDragSort';
import useAsyncLoading from './hooks/useAsyncLoading';
import { PageInfo, PaginationProps } from '../pagination';
import useClassName from './hooks/useClassName';
import useStyle from './hooks/useStyle';
import { BaseTableProps, PrimaryTableProps, PrimaryTableRef } from './interface';
import EditableCell, { EditableCellProps } from './EditableCell';
import { StyledProps } from '../common';
import { useEditableRow } from './hooks/useEditableRow';
import { primaryTableDefaultProps } from './defaultProps';
import { CheckboxGroupValue } from '../checkbox';
import useDefaultProps from '../hooks/useDefaultProps';
import useTableHeader, { renderTitle } from './hooks/useTableHeader';

import type { CheckboxGroupValue } from '../checkbox';
import type { StyledProps } from '../common';
import type { PageInfo, PaginationProps } from '../pagination';
import type { BaseTableProps, PrimaryTableProps, PrimaryTableRef } from './interface';
import type { PrimaryTableCellParams, PrimaryTableCol, TableRowData, TdPrimaryTableProps } from './type';

export { BASE_TABLE_ALL_EVENTS } from './BaseTable';

Expand Down Expand Up @@ -188,7 +190,7 @@ const PrimaryTable = forwardRef<PrimaryTableRef, TPrimaryTableProps>((originalPr
})();

const onInnerPageChange = (pageInfo: PageInfo, newData: Array<TableRowData>) => {
innerPagination.current = { ...innerPagination, ...pageInfo };
innerPagination.current = { ...innerPagination.current, ...pageInfo };
setCurrentPaginateData(newData);
props.onPageChange?.(pageInfo, newData);
const changeParams: Parameters<TdPrimaryTableProps['onChange']> = [
Expand Down
5 changes: 3 additions & 2 deletions packages/components/table/hooks/useDragSort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ export default function useDragSort(

// 本地分页的表格,index 不同,需加上分页计数
function getDataPageIndex(index: number, pagination: PaginationProps) {
const current = pagination.current ?? pagination.defaultCurrent;
const pageSize = pagination.pageSize ?? pagination.defaultPageSize;
if (!pagination) return index;
const current = pagination.current ?? pagination.defaultCurrent ?? 1;
const pageSize = pagination.pageSize ?? pagination.defaultPageSize ?? 10;
// 开启本地分页的场景
if (!props.disableDataPage && pagination && data.length > pageSize) {
return pageSize * (current - 1) + index;
Expand Down
Loading