|
1 | 1 | // 表格 行拖拽 + 列拖拽功能 |
2 | 2 | import { MutableRefObject, useEffect, useMemo, useRef, useState } from 'react'; |
3 | | -import Sortable, { SortableEvent, SortableOptions, MoveEvent } from 'sortablejs'; |
4 | 3 | import { get } from 'lodash-es'; |
| 4 | +import Sortable, { MoveEvent, SortableEvent, SortableOptions } from 'sortablejs'; |
| 5 | + |
| 6 | + |
5 | 7 | import log from '@tdesign/common-js/log/index'; |
6 | | -import swapDragArrayElement from '@tdesign/common-js/utils/swapDragArrayElement'; |
7 | 8 | import { getColumnDataByKey, getColumnIndexByKey } from '@tdesign/common-js/table/utils'; |
8 | | -import { PaginationProps } from '../../pagination'; |
9 | | -import { TableRowData, TdPrimaryTableProps, DragSortContext } from '../type'; |
10 | | -import useClassName from './useClassName'; |
| 9 | +import swapDragArrayElement from '@tdesign/common-js/utils/swapDragArrayElement'; |
11 | 10 | import { hasClass } from '../../_util/style'; |
12 | 11 | import useLatest from '../../hooks/useLatest'; |
13 | | -import { BaseTableColumns } from '../interface'; |
| 12 | +import useClassName from './useClassName'; |
| 13 | +import { DEFAULT_CURRENT, DEFAULT_PAGE_SIZE } from './usePagination'; |
| 14 | + |
| 15 | +import type { PaginationProps } from '../../pagination'; |
| 16 | +import type { BaseTableColumns } from '../interface'; |
| 17 | +import type { DragSortContext, TableRowData, TdPrimaryTableProps } from '../type'; |
14 | 18 |
|
15 | 19 | export default function useDragSort( |
16 | 20 | props: TdPrimaryTableProps, |
@@ -68,8 +72,8 @@ export default function useDragSort( |
68 | 72 |
|
69 | 73 | // 本地分页的表格,index 不同,需加上分页计数 |
70 | 74 | function getDataPageIndex(index: number, pagination: PaginationProps) { |
71 | | - const current = pagination.current ?? pagination.defaultCurrent; |
72 | | - const pageSize = pagination.pageSize ?? pagination.defaultPageSize; |
| 75 | + const current = pagination.current || pagination.defaultCurrent || DEFAULT_CURRENT; |
| 76 | + const pageSize = pagination.pageSize || pagination.defaultPageSize || DEFAULT_PAGE_SIZE; |
73 | 77 | // 开启本地分页的场景 |
74 | 78 | if (!props.disableDataPage && pagination && data.length > pageSize) { |
75 | 79 | return pageSize * (current - 1) + index; |
|
0 commit comments