From 60ff2b0788a98413b2af162fd776a36b847ace5a Mon Sep 17 00:00:00 2001 From: "bai.zixv" Date: Mon, 22 Jul 2024 15:09:50 +0800 Subject: [PATCH] fix: table,sort (#1361) Reviewed-on: https://git.daoyoucloud.com/daoyoucloud/tachybase/pulls/1361 Reviewed-by: sealday Co-authored-by: bai.zixv Co-committed-by: bai.zixv --- .../data-blocks/table/hooks/useTableBlockProps.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/core/client/src/modules/blocks/data-blocks/table/hooks/useTableBlockProps.tsx b/packages/core/client/src/modules/blocks/data-blocks/table/hooks/useTableBlockProps.tsx index 647f04725..98d69c837 100644 --- a/packages/core/client/src/modules/blocks/data-blocks/table/hooks/useTableBlockProps.tsx +++ b/packages/core/client/src/modules/blocks/data-blocks/table/hooks/useTableBlockProps.tsx @@ -64,17 +64,19 @@ export const useTableBlockProps = () => { }, onChange({ current, pageSize }, filters, sorter) { const parentSort = fieldSchema.parent?.['x-decorator-props']?.['params']?.sort; + const sortParams = ctx.params.sort || []; + // NOTE: 这里将原本就有的排序参数保留 + const parentSortReal = [...new Set([...sortParams, ...(parentSort || [])])]; + const sort = globalSort ? globalSort : sorter.order ? sorter.order === `ascend` ? [sorter.field] : [`-${sorter.field}`] - : parentSort; - // NOTE: 这里将原本就有的排序参数保留 - const sortParams = ctx.params.sort || []; - const sortFinal = [...new Set([...sortParams, ...(sort || [])])]; - ctx.service.run({ ...ctx.service.params?.[0], page: current, pageSize, sort: sortFinal }); + : parentSortReal; + + ctx.service.run({ ...ctx.service.params?.[0], page: current, pageSize, sort }); }, onClickRow(record, setSelectedRow, selectedRow) { const { targets, uid } = findFilterTargets(fieldSchema);