fix: export using post request

This commit is contained in:
chenos 2023-01-01 15:07:50 +08:00
parent 1b0946bb8a
commit ff10e588bb
2 changed files with 7 additions and 4 deletions

View File

@ -4,7 +4,7 @@ import {
useBlockRequestContext,
useCollection,
useCollectionManager,
useCompile,
useCompile
} from '@nocobase/client';
import { saveAs } from 'file-saver';
import { cloneDeep } from 'lodash';
@ -39,13 +39,15 @@ export const useExportAction = () => {
const { data } = await resource.export(
{
title: compile(title),
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',
method: 'post',
data: {
columns: compile(exportSettings),
},
responseType: 'blob',
},
);

View File

@ -5,8 +5,9 @@ import render from '../renders';
import { columns2Appends } from '../utils';
export async function exportXlsx(ctx: Context, next: Next) {
let { title, columns, filter, sort, fields, except } = ctx.action.params;
let { title, filter, sort, fields, except } = ctx.action.params;
const { resourceName, resourceOf } = ctx.action;
let columns = ctx.action.params.values?.columns || ctx.action.params?.columns;
if (typeof columns === 'string') {
columns = JSON.parse(columns);
}