added export res chess table
This commit is contained in:
parent
512cbf6cea
commit
473492f6f0
@ -21,3 +21,7 @@ export const exportChessTableManual = (versionId: string, data: ChessManualReque
|
||||
|
||||
export const fetchChessConsolidationsResult = (id: string) =>
|
||||
api.get<IntercompanyMatrixResultResponse>(`/consolidations/versions/${id}/intercompany-matrix/result-table`);
|
||||
export const exportChessConsolidationsResult = (versionId: string) =>
|
||||
apiFetchBlob(`/consolidations/versions/${versionId}/intercompany-matrix/result-table/export`, {
|
||||
method: 'GET',
|
||||
});
|
||||
|
||||
@ -4,6 +4,7 @@ import { useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { ApiError } from '../../api/client';
|
||||
import {
|
||||
exportChessConsolidationsResult,
|
||||
exportChessTableAll,
|
||||
exportChessTableManual,
|
||||
fetchChessConsolidations,
|
||||
@ -25,7 +26,7 @@ export const ChessContent = ({ card }: { card: VersionCard | null }) => {
|
||||
|
||||
const [data, setData] = useState<IntercompanyMatrixResponse | null>(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [expoerLoading, setExportLoading] = useState(false);
|
||||
const [exportLoading, setExportLoading] = useState(false);
|
||||
const [companies, setCompanies] = useState<string[]>([]);
|
||||
const [decimals, setDecimals] = useState(2);
|
||||
const [units, setUnits] = useState('thousand');
|
||||
@ -131,6 +132,22 @@ export const ChessContent = ({ card }: { card: VersionCard | null }) => {
|
||||
setExportLoading(false);
|
||||
}
|
||||
};
|
||||
const downloadResTable = async () => {
|
||||
if (!version_id) {
|
||||
return;
|
||||
}
|
||||
setExportLoading(true);
|
||||
try {
|
||||
const { blob, filename } = await exportChessConsolidationsResult(version_id);
|
||||
saveBlob(blob, filename ?? exportFilename(card?.company_group.name ?? 'ГК', card?.year ?? 0, card?.quarter ?? ''));
|
||||
} catch (e) {
|
||||
if (e instanceof ApiError) {
|
||||
notification.error({ description: e.message });
|
||||
}
|
||||
} finally {
|
||||
setExportLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const filteredData = useMemo(() => {
|
||||
if (!data) return null;
|
||||
@ -223,7 +240,7 @@ export const ChessContent = ({ card }: { card: VersionCard | null }) => {
|
||||
/>
|
||||
</div>
|
||||
<div style={{ display: 'flex', gap: 8, marginTop: 8 }}>
|
||||
<Button loading={expoerLoading} onClick={() => download()} icon={<DownloadOutlined />}>
|
||||
<Button loading={exportLoading} onClick={() => download()} icon={<DownloadOutlined />}>
|
||||
Экспорт
|
||||
</Button>
|
||||
<Button
|
||||
@ -272,6 +289,9 @@ export const ChessContent = ({ card }: { card: VersionCard | null }) => {
|
||||
/>
|
||||
</div>
|
||||
<div style={{ display: 'flex', gap: 8, marginTop: 8 }}>
|
||||
<Button loading={exportLoading} onClick={() => downloadResTable()} icon={<DownloadOutlined />}>
|
||||
Экспорт
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => toggleFullscreen(resTableRef, setIsResFullscreen)}
|
||||
icon={isResFullscreen ? <FullscreenExitOutlined /> : <FullscreenOutlined />}>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user