pcpuma_unam_operador/components/admin/InstitucionSelect.vue

68 lines
1.6 KiB
Vue
Raw Normal View History

2022-07-08 18:23:45 +00:00
<template>
<b-field class="column mb-0 pb-0" :class="columnSize" label="Institución">
2022-07-11 08:23:33 +00:00
<b-select
icon="school-outline"
:loading="isLoading"
v-model="institucion"
expanded
rounded
>
<option :disabled="disableDefOption" :value="null">
2022-07-08 18:23:45 +00:00
Selecciona una opción
</option>
2022-07-09 20:46:52 +00:00
<option v-for="(i, index) in instituciones" :key="index" :value="i">
2022-07-08 18:23:45 +00:00
{{ i.institucion }}
</option>
</b-select>
</b-field>
</template>
<script>
import axios from 'axios'
export default {
props: {
2022-07-09 20:46:52 +00:00
disableDefOption: { typeof: Boolean, required: false, default: true },
2022-07-08 18:23:45 +00:00
updateIdInstitucion: { type: Function, required: true },
2022-07-09 20:46:52 +00:00
idInstitucion: { type: Number, required: true },
2022-07-08 18:23:45 +00:00
// token: { typeof: Object, required: true },
columnSize: { typeof: String, required: false, default: '' },
},
data() {
return {
instituciones: [],
isLoading: false,
2022-07-11 08:23:33 +00:00
institucion: null,
2022-07-09 20:46:52 +00:00
objVacio: {},
2022-07-08 18:23:45 +00:00
}
},
methods: {
obtenerCatalogoInstitucion() {
this.isLoading = true
axios
.get(`${process.env.api}/institucion` /*, this.token*/)
.then((res) => {
this.instituciones = res.data
this.isLoading = false
})
.catch((err) => {
this.isLoading = false
2022-07-11 14:15:10 +00:00
this.$alertsGenericos.imprimirError(this.$buefy, err.response.data)
2022-07-08 18:23:45 +00:00
})
},
},
watch: {
idInstitucion() {
2022-07-09 20:46:52 +00:00
if (!this.idInstitucion) this.institucion = this.objVacio
2022-07-08 18:23:45 +00:00
},
institucion() {
this.updateIdInstitucion(this.institucion.id_institucion)
},
},
created() {
this.obtenerCatalogoInstitucion()
},
}
</script>