106 lines
2.4 KiB
Vue
106 lines
2.4 KiB
Vue
<template>
|
|
<div>
|
|
<h4 class="is-size-4 mb-2">Descargar cuestionarios</h4>
|
|
|
|
<b-field label="Cuestionario:">
|
|
<b-select v-model="selectedCuestionario" expanded>
|
|
<option value="" disabled>Seleccione un cuestionario:</option>
|
|
|
|
<option value="cuestionario_alumno">Cuestionarios del Alumnos</option>
|
|
|
|
<option value="cuestionario_programa">
|
|
Cuestionarios del Programas
|
|
</option>
|
|
</b-select>
|
|
</b-field>
|
|
|
|
<b-field label="Version:">
|
|
<b-select v-model="version" expanded>
|
|
<option value="" disabled>Seleccione una version:</option>
|
|
|
|
<option value="v1">v1</option>
|
|
|
|
<option value="v2">
|
|
v2
|
|
</option>
|
|
</b-select>
|
|
</b-field>
|
|
|
|
|
|
|
|
<b-field label="Año:">
|
|
<b-select v-model="selectedYear" expanded>
|
|
<option value="" disabled>Seleccione un año:</option>
|
|
|
|
<option v-for="(y, i) in years" :key="i" :value="y">
|
|
{{ y }}
|
|
</option>
|
|
</b-select>
|
|
</b-field>
|
|
|
|
<b-field class="pb-5 pt-3">
|
|
<b-button
|
|
type="is-info"
|
|
@click="descargar()"
|
|
:disabled="!selectedYear || !selectedCuestionario"
|
|
>
|
|
Descargar Excel
|
|
</b-button>
|
|
</b-field>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import axios from 'axios'
|
|
import fileDownload from 'js-file-download'
|
|
|
|
export default {
|
|
props: {
|
|
years: { type: Array, required: true },
|
|
admin: { type: Object, required: true },
|
|
imprimirError: { type: Function, required: true },
|
|
updateIsLoading: { type: Function, required: true },
|
|
},
|
|
data() {
|
|
return {
|
|
selectedCuestionario: '',
|
|
selectedYear: '',
|
|
version:''
|
|
}
|
|
},
|
|
methods: {
|
|
descargar() {
|
|
this.updateIsLoading(true)
|
|
axios
|
|
.get(
|
|
`${process.env.api}/${this.selectedCuestionario}`, {
|
|
params: {
|
|
year: this.selectedYear,
|
|
version: this.version,
|
|
},
|
|
headers: {
|
|
Authorization: `Bearer ${this.admin.token}`,
|
|
},
|
|
}
|
|
)
|
|
.then((res) => {
|
|
fileDownload(
|
|
res.data,
|
|
`${this.selectedYear}_${this.selectedCuestionario}_${this.version}.csv`
|
|
)
|
|
this.selectedYear = ''
|
|
this.selectedCuestionario = ''
|
|
this.version = ''
|
|
this.updateIsLoading(false)
|
|
})
|
|
.catch((err) => {
|
|
this.updateIsLoading(false)
|
|
this.imprimirError(err.response.data)
|
|
})
|
|
},
|
|
},
|
|
}
|
|
</script>
|
|
|
|
<style scoped></style>
|