fix: 上游跟进,(fix: sort params missing when switch page numbers #3906)
This commit is contained in:
		
							parent
							
								
									57e14cdb77
								
							
						
					
					
						commit
						c9bbe51500
					
				@ -1,6 +1,6 @@
 | 
				
			|||||||
import { ArrayField } from '@nocobase/schema';
 | 
					import { ArrayField } from '@nocobase/schema';
 | 
				
			||||||
import { useField, useFieldSchema } from '@nocobase/schema';
 | 
					import { useField, useFieldSchema } from '@nocobase/schema';
 | 
				
			||||||
import { useEffect } from 'react';
 | 
					import { useCallback, useEffect, useMemo } from 'react';
 | 
				
			||||||
import { useFilterBlock } from '../../../../../filter-provider/FilterProvider';
 | 
					import { useFilterBlock } from '../../../../../filter-provider/FilterProvider';
 | 
				
			||||||
import { mergeFilter } from '../../../../../filter-provider/utils';
 | 
					import { mergeFilter } from '../../../../../filter-provider/utils';
 | 
				
			||||||
import { removeNullCondition } from '../../../../../schema-component';
 | 
					import { removeNullCondition } from '../../../../../schema-component';
 | 
				
			||||||
@ -13,6 +13,7 @@ export const useTableBlockProps = () => {
 | 
				
			|||||||
  const ctx = useTableBlockContext();
 | 
					  const ctx = useTableBlockContext();
 | 
				
			||||||
  const globalSort = fieldSchema.parent?.['x-decorator-props']?.['params']?.['sort'];
 | 
					  const globalSort = fieldSchema.parent?.['x-decorator-props']?.['params']?.['sort'];
 | 
				
			||||||
  const { getDataBlocks } = useFilterBlock();
 | 
					  const { getDataBlocks } = useFilterBlock();
 | 
				
			||||||
 | 
					  const params = ctx?.service?.params;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  useEffect(() => {
 | 
					  useEffect(() => {
 | 
				
			||||||
    if (!ctx?.service?.loading) {
 | 
					    if (!ctx?.service?.loading) {
 | 
				
			||||||
@ -53,10 +54,20 @@ export const useTableBlockProps = () => {
 | 
				
			|||||||
      });
 | 
					      });
 | 
				
			||||||
      ctx.service.refresh();
 | 
					      ctx.service.refresh();
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    onChange({ current, pageSize }, filters, sorter) {
 | 
					    onChange: useCallback(
 | 
				
			||||||
      const sort = sorter.order ? (sorter.order === `ascend` ? [sorter.field] : [`-${sorter.field}`]) : globalSort;
 | 
					      ({ current, pageSize }, filters, sorter) => {
 | 
				
			||||||
      ctx.service.run({ ...ctx.service.params?.[0], page: current, pageSize, sort });
 | 
					        const sort = !ctx.dragSort
 | 
				
			||||||
 | 
					          ? sorter.order
 | 
				
			||||||
 | 
					            ? sorter.order === `ascend`
 | 
				
			||||||
 | 
					              ? [sorter.field]
 | 
				
			||||||
 | 
					              : [`-${sorter.field}`]
 | 
				
			||||||
 | 
					            : globalSort || ctx.dragSortBy
 | 
				
			||||||
 | 
					          : ctx.dragSortBy;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        ctx.service.run({ ...params?.[0], page: current, pageSize, sort });
 | 
				
			||||||
      },
 | 
					      },
 | 
				
			||||||
 | 
					      [globalSort, params],
 | 
				
			||||||
 | 
					    ),
 | 
				
			||||||
    onClickRow(record, setSelectedRow, selectedRow) {
 | 
					    onClickRow(record, setSelectedRow, selectedRow) {
 | 
				
			||||||
      const { targets, uid } = findFilterTargets(fieldSchema);
 | 
					      const { targets, uid } = findFilterTargets(fieldSchema);
 | 
				
			||||||
      const dataBlocks = getDataBlocks();
 | 
					      const dataBlocks = getDataBlocks();
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user