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:
parent
266c934ce6
commit
0bb71dea68
@ -12,11 +12,13 @@ import { removeNullCondition } from '../../../../../schema-component';
|
|||||||
export const useTableBlockProps = () => {
|
export const useTableBlockProps = () => {
|
||||||
const field = useField<ArrayField>();
|
const field = useField<ArrayField>();
|
||||||
const fieldSchema = useFieldSchema();
|
const fieldSchema = useFieldSchema();
|
||||||
|
|
||||||
const ctx = useTableBlockContext();
|
const ctx = useTableBlockContext();
|
||||||
const globalSort = fieldSchema.parent?.['x-decorator-props']?.['dragSortBy'];
|
const globalSort = fieldSchema.parent?.['x-decorator-props']?.['dragSortBy'];
|
||||||
const { getDataBlocks } = useFilterBlock();
|
const { getDataBlocks } = useFilterBlock();
|
||||||
const isLoading = ctx?.service?.loading;
|
const isLoading = ctx?.service?.loading;
|
||||||
const params = ctx?.service?.params;
|
const params = ctx?.service?.params;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isLoading) {
|
if (!isLoading) {
|
||||||
const serviceResponse = ctx?.service?.data;
|
const serviceResponse = ctx?.service?.data;
|
||||||
@ -61,7 +63,14 @@ export const useTableBlockProps = () => {
|
|||||||
ctx.service.refresh();
|
ctx.service.refresh();
|
||||||
},
|
},
|
||||||
onChange({ current, pageSize }, filters, sorter) {
|
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 });
|
ctx.service.run({ ...ctx.service.params?.[0], page: current, pageSize, sort });
|
||||||
},
|
},
|
||||||
onClickRow(record, setSelectedRow, selectedRow) {
|
onClickRow(record, setSelectedRow, selectedRow) {
|
||||||
|
Loading…
Reference in New Issue
Block a user