From 0bb71dea68dbfd2368e55c853733c7ec913634b8 Mon Sep 17 00:00:00 2001 From: wjh Date: Tue, 18 Jun 2024 14:09:56 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=A1=A8=E6=A0=BC?= =?UTF-8?q?=E5=9C=A8=E6=B2=A1=E6=9C=89=E6=8B=96=E6=8B=BD=E6=8E=92=E5=BA=8F?= =?UTF-8?q?=E4=B8=8B=E7=82=B9=E5=87=BB=E5=88=86=E9=A1=B5=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E6=8E=92=E5=BA=8F=E5=AD=97=E6=AE=B5=20(#1202)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-on: https://git.daoyoucloud.com/daoyoucloud/tachybase/pulls/1202 Co-authored-by: wjh Co-committed-by: wjh --- .../data-blocks/table/hooks/useTableBlockProps.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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 381a0c579..36095b87c 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 @@ -12,11 +12,13 @@ import { removeNullCondition } from '../../../../../schema-component'; export const useTableBlockProps = () => { const field = useField(); 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) {