футер таблицы гудвила вынесен в отдельный компонент
This commit is contained in:
parent
67899fc963
commit
1ee71355da
@ -0,0 +1,108 @@
|
||||
import { Table, Typography } from 'antd';
|
||||
import type { GoodwillTableResponse, GoodwillTreeRow } from '../../../types/goodwill/goodwill';
|
||||
import { chessTableCellFormatValue } from '../../../utils/chessTableCellFormatValue';
|
||||
import { sumAmounts } from '../../../utils/money';
|
||||
import { ColumnGroupType } from 'antd/es/table';
|
||||
import { ColumnType } from 'antd/lib/table';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
interface ConsolidationGoodwillSummaryI {
|
||||
data: GoodwillTableResponse | null;
|
||||
visibleColumns: (ColumnGroupType<GoodwillTreeRow> | ColumnType<GoodwillTreeRow>)[];
|
||||
units: string;
|
||||
decimals: number;
|
||||
}
|
||||
|
||||
export const ConsolidationGoodwillSummary: React.FC<ConsolidationGoodwillSummaryI> = ({ data, visibleColumns, units, decimals }) => {
|
||||
if (!data?.rows) return null;
|
||||
|
||||
const totalFinInv = sumAmounts(data.rows.map((c) => c.financial_investment_amount)) ?? '0.00';
|
||||
const totalParticipation = sumAmounts(data.rows.map((c) => c.participation_amount)) ?? '0.00';
|
||||
const totalCharter = sumAmounts(data.rows.map((c) => c.charter_capital_amount)) ?? '0.00';
|
||||
const totalGoodwill = sumAmounts(data.rows.map((c) => c.goodwill_amount)) ?? '0.00';
|
||||
|
||||
return (
|
||||
<Table.Summary fixed>
|
||||
<Table.Summary.Row className='resRow'>
|
||||
{visibleColumns.map((col, index) => {
|
||||
if (col.key === 'include_in_kfo') {
|
||||
return (
|
||||
<Table.Summary.Cell key={col.key} index={index} align='center'>
|
||||
<Text strong>—</Text>
|
||||
</Table.Summary.Cell>
|
||||
);
|
||||
}
|
||||
|
||||
if (col.key === 'name') {
|
||||
return (
|
||||
<Table.Summary.Cell key={col.key} index={index} align='left'>
|
||||
<div style={{ backgroundColor: '#e6f4ea', width: '100%', height: '100%' }}>
|
||||
<Text strong>Итого по листу</Text>
|
||||
</div>
|
||||
</Table.Summary.Cell>
|
||||
);
|
||||
}
|
||||
|
||||
if (col.key === 'ownership_share') {
|
||||
return (
|
||||
<Table.Summary.Cell key={col.key} index={index} align='right'>
|
||||
<Text strong>—</Text>
|
||||
</Table.Summary.Cell>
|
||||
);
|
||||
}
|
||||
|
||||
if (col.key === 'financial_investment_amount') {
|
||||
return (
|
||||
<Table.Summary.Cell key={col.key} index={index} align='right'>
|
||||
<div style={{ backgroundColor: '#e6f4ea' }}>
|
||||
<Text strong>{chessTableCellFormatValue(totalFinInv, units, decimals)}</Text>
|
||||
</div>
|
||||
</Table.Summary.Cell>
|
||||
);
|
||||
}
|
||||
|
||||
if (col.key === 'participation_amount') {
|
||||
return (
|
||||
<Table.Summary.Cell key={col.key} index={index} align='right'>
|
||||
<div style={{ backgroundColor: '#e6f4ea' }}>
|
||||
<Text strong>{chessTableCellFormatValue(totalParticipation, units, decimals)}</Text>
|
||||
</div>
|
||||
</Table.Summary.Cell>
|
||||
);
|
||||
}
|
||||
|
||||
if (col.key === 'charter_capital_amount') {
|
||||
return (
|
||||
<Table.Summary.Cell key={col.key} index={index} align='right'>
|
||||
<div style={{ backgroundColor: '#e6f4ea' }}>
|
||||
<Text strong>{chessTableCellFormatValue(totalCharter, units, decimals)}</Text>
|
||||
</div>
|
||||
</Table.Summary.Cell>
|
||||
);
|
||||
}
|
||||
|
||||
if (col.key === 'goodwill_amount') {
|
||||
return (
|
||||
<Table.Summary.Cell key={col.key} index={index} align='right'>
|
||||
<div style={{ backgroundColor: '#e6f4ea' }}>
|
||||
<Text strong>{chessTableCellFormatValue(totalGoodwill, units, decimals)}</Text>
|
||||
</div>
|
||||
</Table.Summary.Cell>
|
||||
);
|
||||
}
|
||||
|
||||
if (col.key === 'comment') {
|
||||
return (
|
||||
<Table.Summary.Cell key={col.key} index={index} align='right'>
|
||||
<Text strong>—</Text>
|
||||
</Table.Summary.Cell>
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
})}
|
||||
</Table.Summary.Row>
|
||||
</Table.Summary>
|
||||
);
|
||||
};
|
||||
@ -1,14 +1,12 @@
|
||||
import { Table, Typography } from 'antd';
|
||||
import { Table } from 'antd';
|
||||
import type { ColumnsType } from 'antd/es/table';
|
||||
import type React from 'react';
|
||||
import { useMemo } from 'react';
|
||||
import type { GoodwillRow, GoodwillTableResponse, GoodwillTreeRow } from '../../../types/goodwill/goodwill';
|
||||
import './ConsolidationGoodwillTable.css';
|
||||
import { chessTableCellFormatValue } from '../../../utils/chessTableCellFormatValue';
|
||||
import { sumAmounts } from '../../../utils/money';
|
||||
import { getGoodwillColumns } from './config';
|
||||
|
||||
const { Text } = Typography;
|
||||
import { getGoodwillColumns } from './config';
|
||||
import { ConsolidationGoodwillSummary } from '../ConsolidationGoodwillSummary/ConsolidationGoodwillSummary';
|
||||
|
||||
interface ConsolidationGoodwillTableI {
|
||||
data: GoodwillTableResponse | null;
|
||||
@ -128,99 +126,6 @@ export const ConsolidationGoodwillTable: React.FC<ConsolidationGoodwillTableI> =
|
||||
|
||||
const scrollY = isFullscreen ? 'calc(100vh - 200px)' : 'auto';
|
||||
|
||||
const renderSummary = () => {
|
||||
if (!data?.rows) return null;
|
||||
|
||||
const totalFinInv = sumAmounts(data.rows.map((c) => c.financial_investment_amount)) ?? '0.00';
|
||||
const totalParticipation = sumAmounts(data.rows.map((c) => c.participation_amount)) ?? '0.00';
|
||||
const totalCharter = sumAmounts(data.rows.map((c) => c.charter_capital_amount)) ?? '0.00';
|
||||
const totalGoodwill = sumAmounts(data.rows.map((c) => c.goodwill_amount)) ?? '0.00';
|
||||
|
||||
return (
|
||||
<Table.Summary fixed>
|
||||
<Table.Summary.Row className='resRow'>
|
||||
{visibleColumns.map((col, index) => {
|
||||
if (col.key === 'include_in_kfo') {
|
||||
return (
|
||||
<Table.Summary.Cell key={col.key} index={index} align='center'>
|
||||
<Text strong>—</Text>
|
||||
</Table.Summary.Cell>
|
||||
);
|
||||
}
|
||||
|
||||
if (col.key === 'name') {
|
||||
return (
|
||||
<Table.Summary.Cell key={col.key} index={index} align='left'>
|
||||
<div style={{ backgroundColor: '#e6f4ea', width: '100%', height: '100%' }}>
|
||||
<Text strong>Итого по листу</Text>
|
||||
</div>
|
||||
</Table.Summary.Cell>
|
||||
);
|
||||
}
|
||||
|
||||
if (col.key === 'ownership_share') {
|
||||
return (
|
||||
<Table.Summary.Cell key={col.key} index={index} align='right'>
|
||||
<Text strong>—</Text>
|
||||
</Table.Summary.Cell>
|
||||
);
|
||||
}
|
||||
|
||||
if (col.key === 'financial_investment_amount') {
|
||||
return (
|
||||
<Table.Summary.Cell key={col.key} index={index} align='right'>
|
||||
<div style={{ backgroundColor: '#e6f4ea' }}>
|
||||
<Text strong>{chessTableCellFormatValue(String(totalFinInv), units, decimals)}</Text>
|
||||
</div>
|
||||
</Table.Summary.Cell>
|
||||
);
|
||||
}
|
||||
|
||||
if (col.key === 'participation_amount') {
|
||||
return (
|
||||
<Table.Summary.Cell key={col.key} index={index} align='right'>
|
||||
<div style={{ backgroundColor: '#e6f4ea' }}>
|
||||
<Text strong>{chessTableCellFormatValue(String(totalParticipation), units, decimals)}</Text>
|
||||
</div>
|
||||
</Table.Summary.Cell>
|
||||
);
|
||||
}
|
||||
|
||||
if (col.key === 'charter_capital_amount') {
|
||||
return (
|
||||
<Table.Summary.Cell key={col.key} index={index} align='right'>
|
||||
<div style={{ backgroundColor: '#e6f4ea' }}>
|
||||
<Text strong>{chessTableCellFormatValue(String(totalCharter), units, decimals)}</Text>
|
||||
</div>
|
||||
</Table.Summary.Cell>
|
||||
);
|
||||
}
|
||||
|
||||
if (col.key === 'goodwill_amount') {
|
||||
return (
|
||||
<Table.Summary.Cell key={col.key} index={index} align='right'>
|
||||
<div style={{ backgroundColor: '#e6f4ea' }}>
|
||||
<Text strong>{chessTableCellFormatValue(String(totalGoodwill), units, decimals)}</Text>
|
||||
</div>
|
||||
</Table.Summary.Cell>
|
||||
);
|
||||
}
|
||||
|
||||
if (col.key === 'comment') {
|
||||
return (
|
||||
<Table.Summary.Cell key={col.key} index={index} align='right'>
|
||||
<Text strong>—</Text>
|
||||
</Table.Summary.Cell>
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
})}
|
||||
</Table.Summary.Row>
|
||||
</Table.Summary>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<Table<GoodwillTreeRow>
|
||||
className='goodwillTable'
|
||||
@ -235,7 +140,7 @@ export const ConsolidationGoodwillTable: React.FC<ConsolidationGoodwillTableI> =
|
||||
title={() => toolbar}
|
||||
key={data?.rows?.length}
|
||||
expandable={{ defaultExpandAllRows: true }}
|
||||
summary={renderSummary}
|
||||
summary={() => <ConsolidationGoodwillSummary data={data} visibleColumns={visibleColumns} units={units} decimals={decimals} />}
|
||||
rowClassName={(record) => (record.isGroupTotal ? 'group-total-row' : '')}
|
||||
/>
|
||||
);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user