From 4849b1d7e5b2b2ba7eaec130505119e9259bb8cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alessandro=20Gon=C3=A7aalves?= Date: Mon, 10 Nov 2025 12:57:28 -0300 Subject: [PATCH] =?UTF-8?q?fix:=20fixar=20coluna=20descri=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/DRE/teste.tsx | 220 +++++++++++++++++++++++++++++++++--------- 1 file changed, 175 insertions(+), 45 deletions(-) diff --git a/src/app/DRE/teste.tsx b/src/app/DRE/teste.tsx index 9685173..0c7ef9b 100644 --- a/src/app/DRE/teste.tsx +++ b/src/app/DRE/teste.tsx @@ -251,6 +251,19 @@ export default function Teste() { }); const [linhaSelecionada, setLinhaSelecionada] = useState(null); const [isAllExpanded, setIsAllExpanded] = useState(false); + + // Refs para sincronizar scroll vertical entre coluna fixa e valores + const descricaoScrollRef = React.useRef(null); + const valoresScrollRef = React.useRef(null); + + // Função para sincronizar scroll vertical + const syncScroll = (source: 'descricao' | 'valores') => { + if (source === 'descricao' && descricaoScrollRef.current && valoresScrollRef.current) { + valoresScrollRef.current.scrollTop = descricaoScrollRef.current.scrollTop; + } else if (source === 'valores' && descricaoScrollRef.current && valoresScrollRef.current) { + descricaoScrollRef.current.scrollTop = valoresScrollRef.current.scrollTop; + } + }; useEffect(() => { // Carregar períodos disponíveis da API @@ -2789,55 +2802,172 @@ export default function Teste() { {/* Table Container */} {filtrosAplicados && !loading && !error && (
- {/* Scroll Container - Apenas um container com scroll */} -
- {/* Table */} - - {/* Table Header */} - - - - {mesesDisponiveis.map((mes) => ( - - + + + {/* Table Body */} + + {hierarchicalData.map((row, index) => ( + + {/* Colunas de valores por mês */} + {mesesDisponiveis.map((mes) => ( + + + + + ))} + + {/* Coluna Total */} + + + {/* Coluna Percentual Total */} + + + ))} + +
- Descrição - - {mes} + {/* Container com coluna fixa e scroll horizontal */} +
+ {/* Coluna fixa - Descrição */} +
+ {/* Header fixo da descrição */} +
+
+ Descrição +
+
+ {/* Corpo da descrição com scroll vertical */} +
syncScroll('descricao')} + > + {hierarchicalData.map((row, index) => ( +
+
+
+ {renderCellContent(row)} +
+
+
+ ))} +
+
+ + {/* Parte com scroll - Valores */} +
+
syncScroll('valores')} + > + + {/* Table Header */} + + + {mesesDisponiveis.map((mes) => ( + + + + + ))} + - - ))} - - - - - - {/* Table Body */} - - {hierarchicalData.map((row, index) => ( - - ))} - -
+ {mes} + + % + + Total % - Total - - % -
+
handleRowClick(row, mes)} + title={ + row.valoresPorMes && row.valoresPorMes[mes] + ? formatCurrency(row.valoresPorMes[mes]) + : "-" + } + > + {row.valoresPorMes && row.valoresPorMes[mes] + ? (() => { + const { formatted, isNegative } = + formatCurrencyWithColor(row.valoresPorMes[mes]); + return ( + + {formatted} + + ); + })() + : "-"} + handleRowClick(row, mes)} + title={ + row.percentuaisPorMes && + row.percentuaisPorMes[mes] !== undefined + ? `${row.percentuaisPorMes[mes].toFixed(1)}%` + : "-" + } + > + {row.percentuaisPorMes && + row.percentuaisPorMes[mes] !== undefined + ? `${row.percentuaisPorMes[mes].toFixed(1)}%` + : "-"} + handleRowClick(row)} + title={row.total ? formatCurrency(row.total) : "-"} + > + {(() => { + const { formatted, isNegative } = formatCurrencyWithColor( + row.total! + ); + return ( + + {formatted} + + ); + })()} + handleRowClick(row)} + title={ + row.percentualTotal !== undefined + ? `${row.percentualTotal.toFixed(1)}%` + : "-" + } + > + {row.percentualTotal !== undefined + ? `${row.percentualTotal.toFixed(1)}%` + : "-"} +
+
+
)}