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 formBlockCtx = useFormBlockContext();
const formFieldCtx = useFormFieldContext(); 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)) { if (!formBlockCtx?.updateAssociationValues?.includes(fullFieldName)) {
formBlockCtx?.updateAssociationValues?.push(fullFieldName); formBlockCtx?.updateAssociationValues?.push(fullFieldName);
} }

View File

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

View File

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

View File

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