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: {
|
filtros: {
|
||||||
dataInicio: string;
|
dataInicio: string;
|
||||||
dataFim: string;
|
dataFim: string;
|
||||||
|
centroCusto?: string;
|
||||||
codigoGrupo?: string;
|
codigoGrupo?: string;
|
||||||
|
codigoSubgrupo?: string;
|
||||||
codigoConta?: string;
|
codigoConta?: string;
|
||||||
linhaSelecionada?: string;
|
linhaSelecionada?: string;
|
||||||
|
excluirCentroCusto?: string;
|
||||||
excluirCodigoConta?: string;
|
excluirCodigoConta?: string;
|
||||||
|
codigosCentrosCustoSelecionados?: string;
|
||||||
codigosContasSelecionadas?: string;
|
codigosContasSelecionadas?: string;
|
||||||
filial?: string;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -382,18 +385,27 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) {
|
||||||
if (filtrosExternos.dataFim) {
|
if (filtrosExternos.dataFim) {
|
||||||
params.append('dataFim', filtrosExternos.dataFim);
|
params.append('dataFim', filtrosExternos.dataFim);
|
||||||
}
|
}
|
||||||
|
if (filtrosExternos.centroCusto) {
|
||||||
|
params.append('centroCusto', filtrosExternos.centroCusto);
|
||||||
|
}
|
||||||
if (filtrosExternos.codigoGrupo) {
|
if (filtrosExternos.codigoGrupo) {
|
||||||
params.append('codigoGrupo', filtrosExternos.codigoGrupo);
|
params.append('codigoGrupo', filtrosExternos.codigoGrupo);
|
||||||
}
|
}
|
||||||
|
if (filtrosExternos.codigoSubgrupo) {
|
||||||
|
params.append('codigoSubgrupo', filtrosExternos.codigoSubgrupo);
|
||||||
|
}
|
||||||
if (filtrosExternos.codigoConta) {
|
if (filtrosExternos.codigoConta) {
|
||||||
params.append('codigoConta', filtrosExternos.codigoConta);
|
params.append('codigoConta', filtrosExternos.codigoConta);
|
||||||
}
|
}
|
||||||
if (filtrosExternos.filial) {
|
if (filtrosExternos.excluirCentroCusto) {
|
||||||
params.append('filial', filtrosExternos.filial);
|
params.append('excluirCentroCusto', filtrosExternos.excluirCentroCusto);
|
||||||
}
|
}
|
||||||
if (filtrosExternos.excluirCodigoConta) {
|
if (filtrosExternos.excluirCodigoConta) {
|
||||||
params.append('excluirCodigoConta', filtrosExternos.excluirCodigoConta);
|
params.append('excluirCodigoConta', filtrosExternos.excluirCodigoConta);
|
||||||
}
|
}
|
||||||
|
if (filtrosExternos.codigosCentrosCustoSelecionados) {
|
||||||
|
params.append('codigosCentrosCustoSelecionados', filtrosExternos.codigosCentrosCustoSelecionados);
|
||||||
|
}
|
||||||
if (filtrosExternos.codigosContasSelecionadas) {
|
if (filtrosExternos.codigosContasSelecionadas) {
|
||||||
params.append('codigosContasSelecionadas', filtrosExternos.codigosContasSelecionadas);
|
params.append('codigosContasSelecionadas', filtrosExternos.codigosContasSelecionadas);
|
||||||
}
|
}
|
||||||
|
|
@ -403,9 +415,13 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) {
|
||||||
console.log('📋 Parâmetros enviados:', {
|
console.log('📋 Parâmetros enviados:', {
|
||||||
dataInicio: filtrosExternos.dataInicio,
|
dataInicio: filtrosExternos.dataInicio,
|
||||||
dataFim: filtrosExternos.dataFim,
|
dataFim: filtrosExternos.dataFim,
|
||||||
|
centroCusto: filtrosExternos.centroCusto,
|
||||||
codigoGrupo: filtrosExternos.codigoGrupo,
|
codigoGrupo: filtrosExternos.codigoGrupo,
|
||||||
|
codigoSubgrupo: filtrosExternos.codigoSubgrupo,
|
||||||
codigoConta: filtrosExternos.codigoConta,
|
codigoConta: filtrosExternos.codigoConta,
|
||||||
filial: filtrosExternos.filial,
|
excluirCentroCusto: filtrosExternos.excluirCentroCusto,
|
||||||
|
excluirCodigoConta: filtrosExternos.excluirCodigoConta,
|
||||||
|
codigosCentrosCustoSelecionados: filtrosExternos.codigosCentrosCustoSelecionados,
|
||||||
codigosContasSelecionadas: filtrosExternos.codigosContasSelecionadas
|
codigosContasSelecionadas: filtrosExternos.codigosContasSelecionadas
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -497,6 +513,54 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) {
|
||||||
};
|
};
|
||||||
|
|
||||||
const baseColumns = [
|
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",
|
field: "ano_mes_comp",
|
||||||
headerName: "Ano/Mês Comp",
|
headerName: "Ano/Mês Comp",
|
||||||
|
|
@ -506,27 +570,42 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) {
|
||||||
renderCell: (params: any) => params.value || "-",
|
renderCell: (params: any) => params.value || "-",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: "filial",
|
field: "entidade",
|
||||||
headerName: "Filial",
|
headerName: "Entidade",
|
||||||
width: 90,
|
width: 90,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
resizable: true,
|
resizable: true,
|
||||||
renderCell: (params: any) => params.value || "-",
|
renderCell: (params: any) => params.value || "-",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: "codigo_grupo",
|
field: "codigo_fornecedor",
|
||||||
headerName: "Cod.Grupo",
|
headerName: "Cod. Fornec",
|
||||||
width: 100,
|
width: 100,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
resizable: true,
|
resizable: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: "grupo",
|
field: "nome_fornecedor",
|
||||||
headerName: "Grupo",
|
headerName: "Fornecedor",
|
||||||
width: 200,
|
width: 200,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
resizable: 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",
|
field: "codigo_conta",
|
||||||
headerName: "Cod.Conta",
|
headerName: "Cod.Conta",
|
||||||
|
|
@ -551,13 +630,54 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) {
|
||||||
renderCell: (params: any) => currencyCellRenderer(params, true),
|
renderCell: (params: any) => currencyCellRenderer(params, true),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
field: "tipo",
|
field: "valor_previsto",
|
||||||
headerName: "Tipo",
|
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,
|
width: 95,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
resizable: true,
|
resizable: true,
|
||||||
renderCell: (params: any) => params.value || "-",
|
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
|
// Adicionar renderHeader com filtro Excel para todas as colunas
|
||||||
|
|
@ -637,6 +757,15 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) {
|
||||||
if (sortedAndFilteredData.length === 0) return;
|
if (sortedAndFilteredData.length === 0) return;
|
||||||
|
|
||||||
// Funções auxiliares para formatar valores exatamente como na grid
|
// 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 => {
|
const formatCurrencyValue = (value: any, showZero: boolean = false): string | number => {
|
||||||
if (value === null || value === undefined || value === "") return "-";
|
if (value === null || value === undefined || value === "") return "-";
|
||||||
const numValue = typeof value === "string" ? parseFloat(value) : Number(value);
|
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
|
// Se a coluna tem renderCell, aplicar a mesma lógica
|
||||||
if (column.renderCell) {
|
if (column.renderCell) {
|
||||||
|
// Para datas
|
||||||
|
if (column.field.includes("data_")) {
|
||||||
|
return formatDateValue(value);
|
||||||
|
}
|
||||||
|
|
||||||
// Para valores monetários
|
// Para valores monetários
|
||||||
if (column.field === "valor") {
|
if (column.field === "valor") {
|
||||||
return formatCurrencyValue(value, true);
|
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
|
// Para campos que retornam "-" se vazios
|
||||||
if (column.field === "filial" || column.field === "ano_mes_comp" ||
|
if (column.field === "centro_custo" || column.field === "numero_lancamento" ||
|
||||||
column.field === "tipo") {
|
column.field === "entidade" || column.field === "tipo_parceiro" ||
|
||||||
|
column.field === "ano_mes_comp") {
|
||||||
return value || "-";
|
return value || "-";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Para datas sem renderCell explícito (mas que são datas)
|
||||||
|
if (column.field.includes("data_")) {
|
||||||
|
return formatDateValue(value);
|
||||||
|
}
|
||||||
|
|
||||||
// Valor padrão
|
// Valor padrão
|
||||||
return value ?? "";
|
return value ?? "";
|
||||||
};
|
};
|
||||||
|
|
@ -719,7 +862,7 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{/* Filtros Externos Ativos - Apenas quando maximizado */}
|
{/* 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="flex items-center gap-2 mb-4">
|
||||||
<div className="w-2 h-2 bg-blue-500 rounded-full"></div>
|
<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>
|
<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}
|
Grupo: {filtrosExternos.codigoGrupo}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
|
{filtrosExternos.codigoSubgrupo && (
|
||||||
|
<span className="px-2 py-1 bg-blue-100 rounded">
|
||||||
|
Subgrupo: {filtrosExternos.codigoSubgrupo}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
{filtrosExternos.codigoConta && (
|
{filtrosExternos.codigoConta && (
|
||||||
<span className="px-2 py-1 bg-blue-100 rounded">
|
<span className="px-2 py-1 bg-blue-100 rounded">
|
||||||
Conta: {filtrosExternos.codigoConta}
|
Conta: {filtrosExternos.codigoConta}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
|
{filtrosExternos.centroCusto && (
|
||||||
|
<span className="px-2 py-1 bg-blue-100 rounded">
|
||||||
|
Centro Custo: {filtrosExternos.centroCusto}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
@ -891,7 +1044,7 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Filtros Externos Ativos - Centralizado */}
|
{/* 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="flex items-center gap-2">
|
||||||
<div className="w-2 h-2 bg-blue-500 rounded-full"></div>
|
<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>
|
<span className="text-sm font-medium text-blue-900">Filtros aplicados pela tabela DRE Filial:</span>
|
||||||
|
|
@ -899,20 +1052,30 @@ export default function AnaliticoComponent({ filtros }: AnaliticoProps) {
|
||||||
{filtrosExternos.dataInicio && filtrosExternos.dataFim && (
|
{filtrosExternos.dataInicio && filtrosExternos.dataFim && (
|
||||||
<span className="px-2 py-1 bg-blue-100 rounded">
|
<span className="px-2 py-1 bg-blue-100 rounded">
|
||||||
Período: {filtrosExternos.dataInicio} a {filtrosExternos.dataFim}
|
Período: {filtrosExternos.dataInicio} a {filtrosExternos.dataFim}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
{filtrosExternos.codigoGrupo && (
|
{filtrosExternos.codigoGrupo && (
|
||||||
<span className="px-2 py-1 bg-blue-100 rounded">
|
<span className="px-2 py-1 bg-blue-100 rounded">
|
||||||
Grupo: {filtrosExternos.codigoGrupo}
|
Grupo: {filtrosExternos.codigoGrupo}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
|
{filtrosExternos.codigoSubgrupo && (
|
||||||
|
<span className="px-2 py-1 bg-blue-100 rounded">
|
||||||
|
Subgrupo: {filtrosExternos.codigoSubgrupo}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
{filtrosExternos.codigoConta && (
|
{filtrosExternos.codigoConta && (
|
||||||
<span className="px-2 py-1 bg-blue-100 rounded">
|
<span className="px-2 py-1 bg-blue-100 rounded">
|
||||||
Conta: {filtrosExternos.codigoConta}
|
Conta: {filtrosExternos.codigoConta}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</div>
|
{filtrosExternos.centroCusto && (
|
||||||
</div>
|
<span className="px-2 py-1 bg-blue-100 rounded">
|
||||||
|
Centro Custo: {filtrosExternos.centroCusto}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Controls */}
|
{/* Controls */}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue