fix: export action missing data scope filter (#4476)

This commit is contained in:
Katherine 2024-05-24 09:08:43 +08:00 committed by GitHub
parent bbbb409565
commit bdde49ee84
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -9,27 +9,27 @@
import { useFieldSchema } from '@formily/react'; import { useFieldSchema } from '@formily/react';
import { import {
useAPIClient,
useBlockRequestContext, useBlockRequestContext,
useCollection_deprecated, useCollection_deprecated,
useCollectionManager_deprecated, useCollectionManager_deprecated,
useCompile, useCompile,
mergeFilter,
} from '@nocobase/client'; } from '@nocobase/client';
import lodash from 'lodash'; import lodash from 'lodash';
import { saveAs } from 'file-saver'; import { saveAs } from 'file-saver';
import { App } from 'antd'; import { App } from 'antd';
import { useExportTranslation } from './locale'; import { useExportTranslation } from './locale';
import React from 'react';
export const useExportAction = () => { export const useExportAction = () => {
const { service, resource } = useBlockRequestContext(); const { service, resource, props } = useBlockRequestContext();
const apiClient = useAPIClient(); const defaultFilter = props?.params.filter;
const actionSchema = useFieldSchema(); const actionSchema = useFieldSchema();
const compile = useCompile(); const compile = useCompile();
const { getCollectionJoinField } = useCollectionManager_deprecated(); const { getCollectionJoinField } = useCollectionManager_deprecated();
const { name, title, getField } = useCollection_deprecated(); const { name, title } = useCollection_deprecated();
const { t } = useExportTranslation(); const { t } = useExportTranslation();
const { modal } = App.useApp(); const { modal } = App.useApp();
const filters = service.params?.[1]?.filters || {};
return { return {
async onClick() { async onClick() {
const confirmed = await modal.confirm({ const confirmed = await modal.confirm({
@ -61,7 +61,7 @@ export const useExportAction = () => {
{ {
title: compile(title), title: compile(title),
appends: service.params[0]?.appends?.join(), appends: service.params[0]?.appends?.join(),
filter: JSON.stringify(service.params[0]?.filter), filter: mergeFilter([...Object.values(filters), defaultFilter]),
sort: service.params[0]?.sort, sort: service.params[0]?.sort,
}, },
{ {