8 Commits
0.1 ... 0.1.3

7 changed files with 73 additions and 3 deletions

View 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>

View File

@@ -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: {

View File

@@ -14,7 +14,6 @@ import ApiImplementation from './services/api-implementation';
// Composables // Composables
import { createApp } from 'vue' import { createApp } from 'vue'
process.env.API_IMPLEMENTATION = 'django';
let apiImplementation = new ApiImplementation(); let apiImplementation = new ApiImplementation();
const api = apiImplementation.getApi(); const api = apiImplementation.getApi();

View File

@@ -0,0 +1,19 @@
<template>
<div>
<CodeDialog @code-verified="(verified) => showComponent = verified"/>
</div>
<ExportPurchasesForTryton v-if="showComponent" />
</template>
<script>
import CodeDialog from '../components/CodeDialog.vue'
export default {
data() {
return {
showComponent: false,
}
},
components: { CodeDialog },
methods: {},
}
</script>

View File

@@ -46,6 +46,10 @@ class Api {
createCustomer(customer) { createCustomer(customer) {
return this.apiImplementation.createCustomer(customer); return this.apiImplementation.createCustomer(customer);
} }
getCSVForTryton() {
return this.apiImplementation.getCSVForTryton();
}
} }
export default Api; export default Api;

View File

@@ -1,6 +1,6 @@
class DjangoApi { class DjangoApi {
constructor() { constructor() {
this.base = 'http://localhost:7000'; this.base = process.env.DJANGO_BASE_URL;
} }
getCustomers() { getCustomers() {
@@ -58,6 +58,11 @@ class DjangoApi {
return this.postRequest(url, customer); return this.postRequest(url, customer);
} }
getCSVForTryton() {
const url = this.base + '/don_confiao/api/sales/for_tryton';
return this.getRequest(url);
}
getRequest(url) { getRequest(url) {
return new Promise ((resolve, reject) => { return new Promise ((resolve, reject) => {
fetch(url) fetch(url)

View File

@@ -46,7 +46,10 @@ export default defineConfig({
vueTemplate: true, vueTemplate: true,
}), }),
], ],
define: { 'process.env': {} }, define: { 'process.env': {
API_IMPLEMENTATION: 'django',
DJANGO_BASE_URL: 'http://localhost:7000'
} },
resolve: { resolve: {
alias: { alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)) '@': fileURLToPath(new URL('./src', import.meta.url))