fix: ajuste no carregamento do componente analitico de /dre-filial
This commit is contained in:
parent
c413015542
commit
977918957b
|
|
@ -89,12 +89,15 @@ interface AnaliticoProps {
|
|||
filtros: {
|
||||
dataInicio: string;
|
||||
dataFim: string;
|
||||
centroCusto?: string;
|
||||
codigoGrupo?: string;
|
||||
codigoSubgrupo?: string;
|
||||
codigoConta?: string;
|
||||
linhaSelecionada?: string;
|
||||
excluirCentroCusto?: string;
|
||||
excluirCodigoConta?: string;
|
||||
codigosCentrosCustoSelecionados?: string;
|
||||
codigosContasSelecionadas?: string;
|
||||
filial?: string;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -382,18 +385,27 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) {
|
|||
if (filtrosExternos.dataFim) {
|
||||
params.append('dataFim', filtrosExternos.dataFim);
|
||||
}
|
||||
if (filtrosExternos.centroCusto) {
|
||||
params.append('centroCusto', filtrosExternos.centroCusto);
|
||||
}
|
||||
if (filtrosExternos.codigoGrupo) {
|
||||
params.append('codigoGrupo', filtrosExternos.codigoGrupo);
|
||||
}
|
||||
if (filtrosExternos.codigoSubgrupo) {
|
||||
params.append('codigoSubgrupo', filtrosExternos.codigoSubgrupo);
|
||||
}
|
||||
if (filtrosExternos.codigoConta) {
|
||||
params.append('codigoConta', filtrosExternos.codigoConta);
|
||||
}
|
||||
if (filtrosExternos.filial) {
|
||||
params.append('filial', filtrosExternos.filial);
|
||||
if (filtrosExternos.excluirCentroCusto) {
|
||||
params.append('excluirCentroCusto', filtrosExternos.excluirCentroCusto);
|
||||
}
|
||||
if (filtrosExternos.excluirCodigoConta) {
|
||||
params.append('excluirCodigoConta', filtrosExternos.excluirCodigoConta);
|
||||
}
|
||||
if (filtrosExternos.codigosCentrosCustoSelecionados) {
|
||||
params.append('codigosCentrosCustoSelecionados', filtrosExternos.codigosCentrosCustoSelecionados);
|
||||
}
|
||||
if (filtrosExternos.codigosContasSelecionadas) {
|
||||
params.append('codigosContasSelecionadas', filtrosExternos.codigosContasSelecionadas);
|
||||
}
|
||||
|
|
@ -403,9 +415,13 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) {
|
|||
console.log('📋 Parâmetros enviados:', {
|
||||
dataInicio: filtrosExternos.dataInicio,
|
||||
dataFim: filtrosExternos.dataFim,
|
||||
centroCusto: filtrosExternos.centroCusto,
|
||||
codigoGrupo: filtrosExternos.codigoGrupo,
|
||||
codigoSubgrupo: filtrosExternos.codigoSubgrupo,
|
||||
codigoConta: filtrosExternos.codigoConta,
|
||||
filial: filtrosExternos.filial,
|
||||
excluirCentroCusto: filtrosExternos.excluirCentroCusto,
|
||||
excluirCodigoConta: filtrosExternos.excluirCodigoConta,
|
||||
codigosCentrosCustoSelecionados: filtrosExternos.codigosCentrosCustoSelecionados,
|
||||
codigosContasSelecionadas: filtrosExternos.codigosContasSelecionadas
|
||||
});
|
||||
|
||||
|
|
@ -497,6 +513,54 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) {
|
|||
};
|
||||
|
||||
const baseColumns = [
|
||||
{
|
||||
field: "numero_lancamento",
|
||||
headerName: "ID",
|
||||
width: 100,
|
||||
sortable: true,
|
||||
resizable: true,
|
||||
renderCell: (params: any) => params.value || "-",
|
||||
},
|
||||
{
|
||||
field: "data_lancamento",
|
||||
headerName: "Dt Lanc",
|
||||
width: 95,
|
||||
sortable: true,
|
||||
resizable: true,
|
||||
renderCell: dateCellRenderer,
|
||||
},
|
||||
{
|
||||
field: "data_compensacao",
|
||||
headerName: "Dt Comp",
|
||||
width: 95,
|
||||
sortable: true,
|
||||
resizable: true,
|
||||
renderCell: dateCellRenderer,
|
||||
},
|
||||
{
|
||||
field: "data_vencimento",
|
||||
headerName: "Dt Venc",
|
||||
width: 95,
|
||||
sortable: true,
|
||||
resizable: true,
|
||||
renderCell: dateCellRenderer,
|
||||
},
|
||||
{
|
||||
field: "data_caixa",
|
||||
headerName: "Dt Caixa",
|
||||
width: 95,
|
||||
sortable: true,
|
||||
resizable: true,
|
||||
renderCell: dateCellRenderer,
|
||||
},
|
||||
{
|
||||
field: "data_pagto",
|
||||
headerName: "Dt Pagto",
|
||||
width: 95,
|
||||
sortable: true,
|
||||
resizable: true,
|
||||
renderCell: dateCellRenderer,
|
||||
},
|
||||
{
|
||||
field: "ano_mes_comp",
|
||||
headerName: "Ano/Mês Comp",
|
||||
|
|
@ -506,27 +570,42 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) {
|
|||
renderCell: (params: any) => params.value || "-",
|
||||
},
|
||||
{
|
||||
field: "filial",
|
||||
headerName: "Filial",
|
||||
field: "entidade",
|
||||
headerName: "Entidade",
|
||||
width: 90,
|
||||
sortable: true,
|
||||
resizable: true,
|
||||
renderCell: (params: any) => params.value || "-",
|
||||
},
|
||||
{
|
||||
field: "codigo_grupo",
|
||||
headerName: "Cod.Grupo",
|
||||
field: "codigo_fornecedor",
|
||||
headerName: "Cod. Fornec",
|
||||
width: 100,
|
||||
sortable: true,
|
||||
resizable: true,
|
||||
},
|
||||
{
|
||||
field: "grupo",
|
||||
headerName: "Grupo",
|
||||
field: "nome_fornecedor",
|
||||
headerName: "Fornecedor",
|
||||
width: 200,
|
||||
sortable: true,
|
||||
resizable: true,
|
||||
},
|
||||
{
|
||||
field: "codigo_centrocusto",
|
||||
headerName: "Cod.CC",
|
||||
width: 90,
|
||||
sortable: true,
|
||||
resizable: true,
|
||||
},
|
||||
{
|
||||
field: "centro_custo",
|
||||
headerName: "Centro Custo",
|
||||
width: 180,
|
||||
sortable: true,
|
||||
resizable: true,
|
||||
renderCell: (params: any) => params.value || "-",
|
||||
},
|
||||
{
|
||||
field: "codigo_conta",
|
||||
headerName: "Cod.Conta",
|
||||
|
|
@ -551,13 +630,54 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) {
|
|||
renderCell: (params: any) => currencyCellRenderer(params, true),
|
||||
},
|
||||
{
|
||||
field: "tipo",
|
||||
headerName: "Tipo",
|
||||
field: "valor_previsto",
|
||||
headerName: "VI.Pr",
|
||||
type: "number" as const,
|
||||
width: 85,
|
||||
sortable: true,
|
||||
resizable: true,
|
||||
renderCell: (params: any) => currencyCellRenderer(params, false),
|
||||
},
|
||||
{
|
||||
field: "valor_confirmado",
|
||||
headerName: "VI.Confirmado",
|
||||
type: "number" as const,
|
||||
width: 125,
|
||||
sortable: true,
|
||||
resizable: true,
|
||||
renderCell: (params: any) => currencyCellRenderer(params, false),
|
||||
},
|
||||
{
|
||||
field: "historico",
|
||||
headerName: "Histórico",
|
||||
width: 250,
|
||||
sortable: true,
|
||||
resizable: true,
|
||||
},
|
||||
{
|
||||
field: "tipo_parceiro",
|
||||
headerName: "Tipo Parc",
|
||||
width: 95,
|
||||
sortable: true,
|
||||
resizable: true,
|
||||
renderCell: (params: any) => params.value || "-",
|
||||
},
|
||||
{
|
||||
field: "valor_pago",
|
||||
headerName: "VI.Pago",
|
||||
type: "number" as const,
|
||||
width: 100,
|
||||
sortable: true,
|
||||
resizable: true,
|
||||
renderCell: (params: any) => currencyCellRenderer(params, false),
|
||||
},
|
||||
{
|
||||
field: "historico2",
|
||||
headerName: "Histórico 2",
|
||||
width: 250,
|
||||
sortable: true,
|
||||
resizable: true,
|
||||
},
|
||||
];
|
||||
|
||||
// Adicionar renderHeader com filtro Excel para todas as colunas
|
||||
|
|
@ -637,6 +757,15 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) {
|
|||
if (sortedAndFilteredData.length === 0) return;
|
||||
|
||||
// Funções auxiliares para formatar valores exatamente como na grid
|
||||
const formatDateValue = (value: any): string => {
|
||||
if (!value) return "-";
|
||||
try {
|
||||
return new Date(value).toLocaleDateString("pt-BR");
|
||||
} catch (error) {
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
const formatCurrencyValue = (value: any, showZero: boolean = false): string | number => {
|
||||
if (value === null || value === undefined || value === "") return "-";
|
||||
const numValue = typeof value === "string" ? parseFloat(value) : Number(value);
|
||||
|
|
@ -654,18 +783,32 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) {
|
|||
|
||||
// Se a coluna tem renderCell, aplicar a mesma lógica
|
||||
if (column.renderCell) {
|
||||
// Para datas
|
||||
if (column.field.includes("data_")) {
|
||||
return formatDateValue(value);
|
||||
}
|
||||
|
||||
// Para valores monetários
|
||||
if (column.field === "valor") {
|
||||
return formatCurrencyValue(value, true);
|
||||
}
|
||||
if (column.field === "valor_previsto" || column.field === "valor_confirmado" || column.field === "valor_pago") {
|
||||
return formatCurrencyValue(value, false);
|
||||
}
|
||||
|
||||
// Para campos que retornam "-" se vazios
|
||||
if (column.field === "filial" || column.field === "ano_mes_comp" ||
|
||||
column.field === "tipo") {
|
||||
if (column.field === "centro_custo" || column.field === "numero_lancamento" ||
|
||||
column.field === "entidade" || column.field === "tipo_parceiro" ||
|
||||
column.field === "ano_mes_comp") {
|
||||
return value || "-";
|
||||
}
|
||||
}
|
||||
|
||||
// Para datas sem renderCell explícito (mas que são datas)
|
||||
if (column.field.includes("data_")) {
|
||||
return formatDateValue(value);
|
||||
}
|
||||
|
||||
// Valor padrão
|
||||
return value ?? "";
|
||||
};
|
||||
|
|
@ -719,7 +862,7 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) {
|
|||
return (
|
||||
<>
|
||||
{/* Filtros Externos Ativos - Apenas quando maximizado */}
|
||||
{isMaximized && (filtrosExternos.dataInicio || filtrosExternos.codigoGrupo || filtrosExternos.codigoConta) && (
|
||||
{isMaximized && (filtrosExternos.dataInicio || filtrosExternos.codigoGrupo || filtrosExternos.codigoSubgrupo || filtrosExternos.codigoConta || filtrosExternos.centroCusto) && (
|
||||
<div className="flex items-center gap-2 mb-4">
|
||||
<div className="w-2 h-2 bg-blue-500 rounded-full"></div>
|
||||
<span className="text-sm font-medium text-blue-900">Filtros aplicados pela tabela DRE Filial:</span>
|
||||
|
|
@ -734,11 +877,21 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) {
|
|||
Grupo: {filtrosExternos.codigoGrupo}
|
||||
</span>
|
||||
)}
|
||||
{filtrosExternos.codigoSubgrupo && (
|
||||
<span className="px-2 py-1 bg-blue-100 rounded">
|
||||
Subgrupo: {filtrosExternos.codigoSubgrupo}
|
||||
</span>
|
||||
)}
|
||||
{filtrosExternos.codigoConta && (
|
||||
<span className="px-2 py-1 bg-blue-100 rounded">
|
||||
Conta: {filtrosExternos.codigoConta}
|
||||
</span>
|
||||
)}
|
||||
{filtrosExternos.centroCusto && (
|
||||
<span className="px-2 py-1 bg-blue-100 rounded">
|
||||
Centro Custo: {filtrosExternos.centroCusto}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
|
@ -891,7 +1044,7 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) {
|
|||
</div>
|
||||
|
||||
{/* Filtros Externos Ativos - Centralizado */}
|
||||
{(filtrosExternos.dataInicio || filtrosExternos.codigoGrupo || filtrosExternos.codigoConta) && (
|
||||
{(filtrosExternos.dataInicio || filtrosExternos.codigoGrupo || filtrosExternos.codigoSubgrupo || filtrosExternos.codigoConta || filtrosExternos.centroCusto) && (
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="w-2 h-2 bg-blue-500 rounded-full"></div>
|
||||
<span className="text-sm font-medium text-blue-900">Filtros aplicados pela tabela DRE Filial:</span>
|
||||
|
|
@ -906,11 +1059,21 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) {
|
|||
Grupo: {filtrosExternos.codigoGrupo}
|
||||
</span>
|
||||
)}
|
||||
{filtrosExternos.codigoSubgrupo && (
|
||||
<span className="px-2 py-1 bg-blue-100 rounded">
|
||||
Subgrupo: {filtrosExternos.codigoSubgrupo}
|
||||
</span>
|
||||
)}
|
||||
{filtrosExternos.codigoConta && (
|
||||
<span className="px-2 py-1 bg-blue-100 rounded">
|
||||
Conta: {filtrosExternos.codigoConta}
|
||||
</span>
|
||||
)}
|
||||
{filtrosExternos.centroCusto && (
|
||||
<span className="px-2 py-1 bg-blue-100 rounded">
|
||||
Centro Custo: {filtrosExternos.centroCusto}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
|
|
|||
Loading…
Reference in New Issue