Files

79 lines
1.6 KiB
Vue
Raw Permalink Normal View History

2022-02-05 00:27:58 -06:00
<template>
<div>
<div class="columns">
<b-field class="column" label="Fecha inicio">
<b-datepicker
v-model="inicio"
2022-05-06 01:45:36 -05:00
:min-date="minDate"
2022-02-05 00:27:58 -06:00
:max-date="maxDate"
icon="calendar-today"
rounded
>
</b-datepicker>
</b-field>
<b-field class="column" label="Fecha fin">
<b-datepicker
v-model="fin"
2022-05-06 01:45:36 -05:00
:min-date="inicio"
2022-02-05 00:27:58 -06:00
:max-date="maxDate"
icon="calendar-today"
rounded
>
</b-datepicker>
</b-field>
</div>
<div class="has-text-centered">
<b-button type="is-link" @click="pedirReporte()">Descargar</b-button>
</div>
</div>
</template>
<script>
import axios from 'axios'
import fileDownload from 'js-file-download'
export default {
props: {
2022-07-28 13:23:21 -05:00
updateIsLoading: { type: Function, required: true },
2022-02-05 00:27:58 -06:00
},
data() {
return {
token: '',
2022-05-06 01:47:06 -05:00
minDate: new Date('2022-01-01'),
2022-02-05 00:27:58 -06:00
maxDate: new Date(),
inicio: new Date(),
fin: new Date(),
}
},
methods: {
pedirReporte() {
console.log(this.inicio)
this.updateIsLoading(true)
axios
.get(
2022-03-19 21:00:20 -06:00
`${process.env.api}/admin/reporte?inicio=${this.inicio}&fin=${this.fin}`,
this.token
2022-02-05 00:27:58 -06:00
)
.then((res) => {
2022-03-19 21:00:20 -06:00
fileDownload(res.data, `inscripcionesCEDETEC.csv`)
2022-02-05 00:27:58 -06:00
this.updateIsLoading(false)
})
.catch((err) => {
this.updateIsLoading(false)
})
},
},
created() {
this.token = {
headers: { token: localStorage.getItem('token') },
}
},
2022-02-05 00:27:58 -06:00
}
</script>
<style scoped></style>