#5 feat(CSV): export csv tryton.
This commit is contained in:
parent
db8ec154ae
commit
f8a52fc3ec
39
src/components/ExportPurchasesForTryton.vue
Normal file
39
src/components/ExportPurchasesForTryton.vue
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<v-btn @click="downloadCSV">Descargar CSV</v-btn>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
import { inject } from 'vue';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'ExportPurchasesForTryton',
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
api: inject('api'),
|
||||||
|
};
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
downloadCSV() {
|
||||||
|
this.api.getCSVForTryton()
|
||||||
|
.then(data => {
|
||||||
|
const blob = new Blob([data['csv']], {type: 'text/csv'});
|
||||||
|
const pattern = /[/: ]/g;
|
||||||
|
const datetime = new Date();
|
||||||
|
const date = datetime.toLocaleDateString().replace(pattern, '-');
|
||||||
|
const time = datetime.toLocaleTimeString().replace(pattern, '-');
|
||||||
|
const name = `VentasTryton_${date}_${time}.csv`;
|
||||||
|
const link = document.createElement('a');
|
||||||
|
|
||||||
|
link.href = URL.createObjectURL(blob);
|
||||||
|
link.download = name;
|
||||||
|
link.click();
|
||||||
|
URL.revokeObjectURL(link.href);
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error(error);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
@ -31,6 +31,7 @@
|
|||||||
{ title: 'Comprar', route:'/comprar'},
|
{ title: 'Comprar', route:'/comprar'},
|
||||||
{ title: 'Cuadrar tarro', route: '/cuadrar_tarro'},
|
{ title: 'Cuadrar tarro', route: '/cuadrar_tarro'},
|
||||||
{ title: 'Cuadres de tarro', route: '/cuadres_de_tarro'},
|
{ title: 'Cuadres de tarro', route: '/cuadres_de_tarro'},
|
||||||
|
{ title: 'CSV Tryton', route: '/ventas_para_tryton'},
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
watch: {
|
watch: {
|
||||||
|
3
src/pages/ventas_para_tryton.vue
Normal file
3
src/pages/ventas_para_tryton.vue
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<template>
|
||||||
|
<ExportPurchasesForTryton />
|
||||||
|
</template>
|
Loading…
Reference in New Issue
Block a user