fix: export of relation blocks (#546)
This commit is contained in:
parent
fdb7b4c664
commit
839d588892
@ -40,6 +40,10 @@ export abstract class RelationRepository {
|
||||
this.targetCollection = this.sourceCollection.context.database.modelCollection.get(this.targetModel);
|
||||
}
|
||||
|
||||
get collection() {
|
||||
return this.db.getCollection(this.targetModel.name);
|
||||
}
|
||||
|
||||
targetKey() {
|
||||
return this.associationField.targetKey;
|
||||
}
|
||||
|
@ -226,7 +226,7 @@ export class APIClient {
|
||||
} else {
|
||||
config['method'] = 'post';
|
||||
}
|
||||
return async (params?: ActionParams) => {
|
||||
return async (params?: ActionParams, opts?: any) => {
|
||||
const { values, filter, ...others } = params || {};
|
||||
config['params'] = others;
|
||||
if (filter) {
|
||||
@ -239,7 +239,10 @@ export class APIClient {
|
||||
if (config.method !== 'get') {
|
||||
config['data'] = values || {};
|
||||
}
|
||||
return await this.request(config);
|
||||
return await this.request({
|
||||
...config,
|
||||
...opts,
|
||||
});
|
||||
};
|
||||
},
|
||||
};
|
||||
|
@ -4,12 +4,12 @@ import {
|
||||
useBlockRequestContext,
|
||||
useCollection,
|
||||
useCollectionManager,
|
||||
useCompile,
|
||||
useCompile
|
||||
} from '@nocobase/client';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
export const useExportAction = () => {
|
||||
const { service } = useBlockRequestContext();
|
||||
const { service, resource } = useBlockRequestContext();
|
||||
const apiClient = useAPIClient();
|
||||
const actionSchema = useFieldSchema();
|
||||
const compile = useCompile();
|
||||
@ -30,18 +30,18 @@ export const useExportAction = () => {
|
||||
}
|
||||
es.defaultTitle = uiSchema?.title;
|
||||
});
|
||||
const { data } = await apiClient.request({
|
||||
url: `/${name}:exportXlsx`,
|
||||
method: 'get',
|
||||
responseType: 'blob',
|
||||
params: {
|
||||
const { data } = await resource.exportXlsx(
|
||||
{
|
||||
title: compile(title),
|
||||
columns: JSON.stringify(compile(exportSettings)),
|
||||
appends: service.params[0]?.appends?.join(),
|
||||
filter: JSON.stringify(service.params[0]?.filter),
|
||||
},
|
||||
});
|
||||
|
||||
{
|
||||
method: 'get',
|
||||
responseType: 'blob',
|
||||
},
|
||||
);
|
||||
let blob = new Blob([data], { type: 'application/x-xls' });
|
||||
const a = document.createElement('a');
|
||||
const blobUrl = window.URL.createObjectURL(blob);
|
||||
|
Loading…
Reference in New Issue
Block a user