fix: 修复表格在没有拖拽排序下点击分页没有排序字段 (#1202)

Reviewed-on: daoyoucloud/tachybase#1202
Co-authored-by: wjh <wwwjh0710@163.com>
Co-committed-by: wjh <wwwjh0710@163.com>
This commit is contained in:
wjh 2024-06-18 14:09:56 +08:00 committed by baizixv
parent 266c934ce6
commit 0bb71dea68

View File

@ -12,11 +12,13 @@ import { removeNullCondition } from '../../../../../schema-component';
export const useTableBlockProps = () => {
const field = useField<ArrayField>();
const fieldSchema = useFieldSchema();
const ctx = useTableBlockContext();
const globalSort = fieldSchema.parent?.['x-decorator-props']?.['dragSortBy'];
const { getDataBlocks } = useFilterBlock();
const isLoading = ctx?.service?.loading;
const params = ctx?.service?.params;
useEffect(() => {
if (!isLoading) {
const serviceResponse = ctx?.service?.data;
@ -61,7 +63,14 @@ export const useTableBlockProps = () => {
ctx.service.refresh();
},
onChange({ current, pageSize }, filters, sorter) {
const sort = sorter.order ? (sorter.order === `ascend` ? [sorter.field] : [`-${sorter.field}`]) : globalSort;
const parentSort = fieldSchema.parent?.['x-decorator-props']?.['params']?.sort;
const sort = globalSort
? globalSort
: sorter.order
? sorter.order === `ascend`
? [sorter.field]
: [`-${sorter.field}`]
: parentSort;
ctx.service.run({ ...ctx.service.params?.[0], page: current, pageSize, sort });
},
onClickRow(record, setSelectedRow, selectedRow) {