diff --git a/src/Components/Clientes/Traficos/RptClientesTraficos.tsx b/src/Components/Clientes/Traficos/RptClientesTraficos.tsx index 4bd1703..5b7aeb8 100644 --- a/src/Components/Clientes/Traficos/RptClientesTraficos.tsx +++ b/src/Components/Clientes/Traficos/RptClientesTraficos.tsx @@ -292,56 +292,33 @@ export default function RptClientesTraficos(props: IProps) { } function exportExcel(jsonData: any[], fileName: string): void { - let Heading = [ - [ - { - title: 'Aduana Seccion Despacho', - style: { font: { sz: '18', bold: true } }, - }, - 'Patente', - 'Referencia', - 'Pedimento', - 'Fecha Pago', - 'Fecha Entrada Presentacion', - 'Clave Docto', - 'Es rectificacion', - 'Tipo Cambio', - 'Valor Dls', - 'Valor Aduana', - 'Numero Factura', - 'Fecha Factura', - 'Proveedor Factura', - 'Incrementables Fact', - 'Fraccion', - 'Subdiv NICO', - 'Descripcion', - 'Pais Origen', - 'Pais Vendedor', - 'Tasa DTA', - 'Tasa IGI', - 'Numero Parte', - 'Cantidad Comercial', - 'TL Pais', - 'Tipo Tasa', - 'Unidad Comercial', - 'Valor Factura Item', - 'Valor Comercial Ped', - 'Valor Factura Item MN', - ], - ] - const wb = XLSX.utils.book_new() - const ws: XLSX.WorkSheet = XLSX.utils.json_to_sheet([]) - XLSX.utils.sheet_add_aoa(ws, Heading) - XLSX.utils.sheet_add_json(ws, jsonData, { origin: 'A2', skipHeader: true }) - XLSX.utils.book_append_sheet(wb, ws, 'Sheet1') - - XLSX.writeFile(wb, fileName + '.xlsx') - var range = XLSX.utils.decode_range(ws['!ref?']) - for (var C = range.s.c; C <= range.e.c; ++C) { - var address = XLSX.utils.encode_col(C) + '1' // <-- first row, column number C - if (!ws[address]) continue - ws[address].v = ws[address].v.toUpperCase() + const data: DTOFiltrosTraficosClientes = { + Inicio: moment(Inicio).format('YYYY-MM-DD'), + Fin: moment(Fin).format('YYYY-MM-DD'), + TipoOperacion: TipoOperacion, + NoCliente: Cliente, + IdCorresponsal: Corresponsal, + Pedimento: Pedimento, + Aduana: Aduana, + Patente: Patente, + Referencia: Referencia, + IdUsuario: UserId, + Estado: Estado } + ClientesServices.GetExcel(data) + .then(resp => { + const url = window.URL.createObjectURL(new Blob([resp.data])); + const link = document.createElement('a'); + link.href = url; + link.setAttribute('download', `Reporte_Operaciones.xlsx`); + document.body.appendChild(link); + link.click(); + }).catch(e => { + setHeader('Error') + setMsg('Ocurrio un error al generar el reporte. Por favor, intentelo de nuevo.') + setShowMsg(true) + return + }) } return ( @@ -512,7 +489,6 @@ export default function RptClientesTraficos(props: IProps) {   Buscar - {(Depto === 'Corresponsalias' || Depto === 'Sistemas') ? ( - ) : ( - '' - )} diff --git a/src/Services/Catalogos/Clientes.Services.ts b/src/Services/Catalogos/Clientes.Services.ts index 808a092..4b41769 100644 --- a/src/Services/Catalogos/Clientes.Services.ts +++ b/src/Services/Catalogos/Clientes.Services.ts @@ -37,5 +37,9 @@ class ClientesDataService { GetTraficos(data: DTOFiltrosTraficosClientes){ return http.get(`/Clientes/Traficos?Inicio=${data.Inicio}&Fin=${data.Fin}&TipoOperacion=${data.TipoOperacion}&NoCliente=${data.NoCliente}&IdCorresponsal=${data.IdCorresponsal}&Pedimento=${data.Pedimento}&Aduana=${data.Aduana}&Patente=${data.Patente}&Referencia=${data.Referencia}&IdUsuario=${data.IdUsuario}&Estado=${data.Estado}`) } + + GetExcel(data: DTOFiltrosTraficosClientes){ + return http.get(`/Clientes/Excel?Inicio=${data.Inicio}&Fin=${data.Fin}&TipoOperacion=${data.TipoOperacion}&NoCliente=${data.NoCliente}&IdCorresponsal=${data.IdCorresponsal}&Pedimento=${data.Pedimento}&Aduana=${data.Aduana}&Patente=${data.Patente}&Referencia=${data.Referencia}&IdUsuario=${data.IdUsuario}&Estado=${data.Estado}`,{responseType: 'blob'}) + } } export default new ClientesDataService(); \ No newline at end of file