feature, exportar las facturas de un trafico a un archivo excel

feature/ConsolidarPedimentos_20231229
Felix Morales 10 months ago
parent d0247d1ea6
commit 3d96df5590
  1. 24
      src/Components/Corresponsales/TraficoCorresponsales.tsx
  2. 3
      src/Services/Corresponsalias/Corresponsales.Facturas.Services.ts

@ -119,6 +119,8 @@ import ClavesPedimentosService from '../../Services/Catalogos/ClavesPedimentos.S
import { ICatClavesPedimentos } from '../../Interfaces/Catalogos/ICatClavesPedimentos' import { ICatClavesPedimentos } from '../../Interfaces/Catalogos/ICatClavesPedimentos'
import FileManagerServices from '../../Services/Utils/FileManager.Services' import FileManagerServices from '../../Services/Utils/FileManager.Services'
import CorresponsalesAnticiposServices from '../../Services/Corresponsalias/Corresponsales.Anticipos.Services' import CorresponsalesAnticiposServices from '../../Services/Corresponsalias/Corresponsales.Anticipos.Services'
import { BiDownload } from 'react-icons/bi'
import CorresponsalesFacturasServices from '../../Services/Corresponsalias/Corresponsales.Facturas.Services'
interface IProps { interface IProps {
IDTrafico: number IDTrafico: number
@ -1359,7 +1361,7 @@ export default function TraficoCorresponsales (props:IProps) {
// //
fileData += `0|""|""|""|""|""|""|""|""|${ValorFacturasDls}|""|""|336|""|/ / : :|${moment().format("MM/DD/YYYY hh:mm:ss")}|${moment().format("MM/DD/YYYY hh:mm:ss")}|`; fileData += `0|""|""|""|""|""|""|""|""|${ValorFacturasDls}|""|""|336|""|/ / : :|${moment().format("MM/DD/YYYY hh:mm:ss")}|${moment().format("MM/DD/YYYY hh:mm:ss")}|`;
// //
fileData += `0|""|""|""|0|0|0|F|""|0|""|""|0|0|0|0|""|"${CentroCostos}"`; fileData += `0|""|""|""|0|0|0|F|""|0|""|""|0|0|0|0|""|"${CentroCostos.trim()}"`;
//const blob = new Blob([fileData], { type: "text/plain" }); //const blob = new Blob([fileData], { type: "text/plain" });
const file = new File([fileData], `${FolioTrafico}_${Date.now()}.txt`, {type: "text/plain"}); const file = new File([fileData], `${FolioTrafico}_${Date.now()}.txt`, {type: "text/plain"});
let formData = new FormData(); let formData = new FormData();
@ -1472,6 +1474,17 @@ export default function TraficoCorresponsales (props:IProps) {
link.click(); link.click();
} }
const GetFacturasExcel = () => {
CorresponsalesFacturasServices.GetExcel(IDTrafico)
.then(response => {
downloadFile(response.data, `Facturas_${FolioTrafico}.xlsx`);
}).catch(() => {
setHeader('Error')
setMsg('Ocurrió un error al generar el archivo. Por favor, intentelo de nuevo.')
setShowMsg(true)
return
})
}
return ( return (
<div style={{height:'100%', overflowY:'scroll'}}> <div style={{height:'100%', overflowY:'scroll'}}>
<Card className="labelSize13px" style={{borderStyle:'none', height:'100%'}}> <Card className="labelSize13px" style={{borderStyle:'none', height:'100%'}}>
@ -2416,17 +2429,14 @@ export default function TraficoCorresponsales (props:IProps) {
<Col sm={2}> <Col sm={2}>
<Form.Label <Form.Label
id="LinkFacturas123" id="LinkFacturas123"
onClick={() => {
showModalBox(2)
}}
style={{ cursor: 'pointer' }}
> >
<IconContext.Provider <IconContext.Provider
value={{ color: 'green', size: '15px' }} value={{ color: 'green', size: '15px' }}
> >
<HiCurrencyDollar /> <BiDownload onClick={() => {GetFacturasExcel()}} style={{ cursor: 'pointer' }}/>&nbsp;
<span onClick={() => {showModalBox(2)}} style={{ cursor: 'pointer' }}><HiCurrencyDollar />&nbsp;{LblFacturas}</span>
</IconContext.Provider> </IconContext.Provider>
&nbsp;{LblFacturas}
</Form.Label> </Form.Label>
</Col> </Col>
<Col xs={4}> <Col xs={4}>

@ -12,5 +12,8 @@ class Corresponsales_Facturas_DataService {
Delete(id: number) { Delete(id: number) {
return http.delete<IRespuesta>(`/Corresponsalias/Facturas/Delete/${id}`); return http.delete<IRespuesta>(`/Corresponsalias/Facturas/Delete/${id}`);
} }
GetExcel(idTrafico: number){
return http.get(`/Corresponsalias/Facturas/GetExcel?idTrafico=${idTrafico}`, {responseType:'blob'})
}
} }
export default new Corresponsales_Facturas_DataService(); export default new Corresponsales_Facturas_DataService();
Loading…
Cancel
Save