This commit is contained in:
2021-03-25 20:42:34 -06:00
parent 5caf028cbd
commit 2b1b0cb70d
+70 -1
View File
@@ -47,6 +47,51 @@
disabled
>Descargar archivo</b-button
>
<p class="is-size-2 mb-5">Descargar reportes</p>
<p class="is-size-3">Seleccione una fecha de inicio:</p>
<b-datepicker
v-model="selectedInicio"
class="my-5"
placeholder="Seleccione una fecha de inicio"
:min-date="minDate"
icon="calendar-today"
trap-focus
>
</b-datepicker>
<p class="is-size-3">Seleccione una fecha de fin:</p>
<b-datepicker
class="my-5"
v-model="selectedFin"
:max-date="maxDate"
placeholder="Seleccione una fecha de fin"
icon="calendar-today"
trap-focus
>
</b-datepicker>
<b-button
class="is-info mb-5"
v-if="selectedInicio && selectedFin"
@click="crearReporte()"
>Crear reporte</b-button
>
<b-button class="is-info mb-5" v-else disabled>Crear reporte</b-button>
<a :href="link2" target="_blank">
<b-button
class="is-info mb-5"
v-if="selectedInicio && selectedFin && reporteListo"
>Descargar reporte</b-button
>
</a>
<b-button
class="is-info"
v-if="!(selectedInicio && selectedFin && reporteListo)"
disabled
>Descargar reporte</b-button
>
<b-loading
:is-full-page="true"
v-model="isLoading"
@@ -67,8 +112,14 @@ export default {
years: [],
selectedYear: null,
selectedCuestionario: null,
selectedInicio: null,
selectedFin: null,
botonDos: false,
reporteListo: false,
minDate: new Date("January 1, 2020"),
maxDate: new Date(),
link: "",
link2: "",
isLoading: false,
token: {
headers: {
@@ -101,6 +152,24 @@ export default {
this.isLoading = false;
});
},
crearReporte() {
this.isLoading = true;
axios
.get(
`${process.env.api}/servicio/reporte?inicio=${this.selectedInicio}&fin=${this.selectedFin}`,
this.token
)
.then((res) => {
this.link2 = `${process.env.api}/reporte.csv`;
this.reporteListo = true;
})
.catch((err) => {
this.error(err.response.data.message);
})
.finally(() => {
this.isLoading = false;
});
},
error(msj) {
let salir = false;
switch (msj) {
@@ -154,7 +223,7 @@ export default {
<style scoped>
.container {
margin-bottom: 4%;
margin-bottom: 10%;
margin-top: 2%;
}
</style>