fix: sync table sort to export (#723)

This commit is contained in:
SemmyWong 2022-08-11 22:22:24 +08:00 committed by GitHub
parent f11c0025c0
commit 538a28d0bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 11 deletions

View File

@ -17,8 +17,8 @@ const InternalTableFieldProvider = (props) => {
const formBlockCtx = useFormBlockContext();
const formFieldCtx = useFormFieldContext();
const fullFieldName = formFieldCtx && formFieldCtx.fieldName ? `${formFieldCtx.fieldName}.${fieldName}` : fieldName;
const fullFieldName = formFieldCtx && formFieldCtx.fieldName ? `${formFieldCtx.fieldName}.${fieldName}` : fieldName;
if (!formBlockCtx?.updateAssociationValues?.includes(fullFieldName)) {
formBlockCtx?.updateAssociationValues?.push(fullFieldName);
}

View File

@ -35,10 +35,7 @@ const CollectionResourceActionProvider = (props) => {
params: {
...others,
...request?.params,
appends: [
...collection?.fields?.filter?.((field) => field.target).map((field) => field.name),
...appends,
],
appends: [...collection?.fields?.filter?.((field) => field.target).map((field) => field.name), ...appends],
sort: dragSort ? [collection.sortable === true ? 'sort' : collection.sortable] : request?.params?.sort,
},
},
@ -66,10 +63,7 @@ const AssociationResourceActionProvider = (props) => {
...request,
params: {
...request?.params,
appends: [
...collection?.fields?.filter?.((field) => field.target).map((field) => field.name),
...appends,
],
appends: [...collection?.fields?.filter?.((field) => field.target).map((field) => field.name), ...appends],
},
},
{ uid },

View File

@ -41,6 +41,7 @@ export const useExportAction = () => {
columns: JSON.stringify(compile(exportSettings)),
appends: service.params[0]?.appends?.join(),
filter: JSON.stringify(service.params[0]?.filter),
sort: service.params[0]?.sort,
},
{
method: 'get',

View File

@ -5,7 +5,7 @@ import render from '../renders';
import { columns2Appends } from '../utils';
export async function exportXlsx(ctx: Context, next: Next) {
let { title, columns, filter, fields, except } = ctx.action.params;
let { title, columns, filter, sort, fields, except } = ctx.action.params;
const { resourceName, resourceOf } = ctx.action;
if (typeof columns === 'string') {
columns = JSON.parse(columns);
@ -19,6 +19,7 @@ export async function exportXlsx(ctx: Context, next: Next) {
fields,
appends,
except,
sort,
context: ctx,
});
const collectionFields = columns.map((col) => collection.fields.get(col.dataIndex[0]));