fix: table sorter

This commit is contained in:
jialin
2025-12-11 13:33:41 +08:00
parent 3328828da6
commit b38bc8a207
15 changed files with 106 additions and 23 deletions
+10 -4
View File
@@ -1,6 +1,5 @@
import useSetChunkRequest from '@/hooks/use-chunk-request';
import useTableRowSelection from '@/hooks/use-table-row-selection';
import useTableSort from '@/hooks/use-table-sort';
import useUpdateChunkedList from '@/hooks/use-update-chunk-list';
import { handleBatchRequest } from '@/utils';
import _ from 'lodash';
@@ -52,8 +51,12 @@ export default function useTableFetch<T>(
const chunkRequedtRef = useRef<any>(null);
const modalRef = useRef<any>(null);
const rowSelection = useTableRowSelection();
const { sortOrder, setSortOrder } = useTableSort({
defaultSortOrder: 'descend'
const [sortOrder, setSortOrder] = useState<{
order?: 'ascend' | 'descend' | null;
columnKey?: string;
}>({
order: null,
columnKey: undefined
});
// for skeleton loading
@@ -235,7 +238,10 @@ export default function useTableFetch<T>(
};
const handleTableChange = (pagination: any, filters: any, sorter: any) => {
setSortOrder(sorter.order);
setSortOrder({
order: sorter.order,
columnKey: sorter.columnKey || sorter.field
});
};
const handleSearch = () => {