pcpuma_unam_operador/components/selects/SelectCarrera.vue

79 lines
2.0 KiB
Vue
Raw Normal View History

2022-07-26 04:30:07 +00:00
<template>
<b-field class="column mb-0 pb-0" label="Carrera" :class="columnSize">
<b-select
2022-08-08 02:08:22 +00:00
icon="school-outline"
2022-07-26 04:30:07 +00:00
:loading="isLoadingSelect"
2022-08-03 20:34:17 +00:00
v-model="idInstitucionCarrera"
2022-07-26 04:30:07 +00:00
expanded
rounded
>
2022-08-03 20:34:17 +00:00
<option :disabled="deshabilitarOptVacia" :value="0">
2022-07-26 04:30:07 +00:00
Selecciona una opción
</option>
2022-07-26 13:35:38 +00:00
<option
v-for="(ic, index) in institucionCarreras"
:key="index"
2022-08-03 20:34:17 +00:00
:value="ic.id_institucion_carrera"
2022-07-26 13:35:38 +00:00
>
{{ ic.carrera.carrera }}
2022-07-26 04:30:07 +00:00
</option>
</b-select>
</b-field>
</template>
<script>
import axios from 'axios'
export default {
props: {
deshabilitarOptVacia: { typeof: Boolean, required: false, default: true },
idInstitucion: { type: Number, required: true, default: 0 },
2022-08-03 20:34:17 +00:00
idInstitucionCarreraPadre: { type: Number, required: true, default: 0 },
2022-07-26 04:30:07 +00:00
columnSize: { typeof: String, required: false, default: '' },
},
data: () => {
return {
2022-07-26 13:35:38 +00:00
institucionCarreras: [],
2022-07-26 04:30:07 +00:00
isLoadingSelect: false,
2022-08-03 20:34:17 +00:00
idInstitucionCarrera: 0,
2022-07-26 04:30:07 +00:00
}
},
methods: {
2022-07-26 13:35:38 +00:00
obtenerInstitucionCarreras() {
2022-07-26 04:30:07 +00:00
this.isLoadingSelect = true
2022-07-26 13:35:38 +00:00
this.institucionCarreras = []
2022-07-26 04:30:07 +00:00
axios
.get(
2022-07-29 14:16:12 +00:00
`${process.env.api}/institucion-carrera?id_institucion=${this.idInstitucion}`,
this.$getToken.token()
2022-07-26 04:30:07 +00:00
)
.then((res) => {
2022-07-26 13:35:38 +00:00
this.institucionCarreras = res.data
this.$emit('catalogo-institucion-carreras', this.institucionCarreras)
2022-07-26 04:30:07 +00:00
this.isLoadingSelect = false
})
.catch((err) => {
this.isLoadingSelect = false
})
},
},
watch: {
2022-08-03 20:34:17 +00:00
idInstitucionCarrera(institucionCarreraSeleccionada) {
2022-07-26 13:35:38 +00:00
this.$emit(
'institucion-carrera-seleccionada',
institucionCarreraSeleccionada
)
2022-07-26 04:30:07 +00:00
},
2022-08-03 20:34:17 +00:00
idInstitucionCarreraPadre(nuevaInstitucionCarrera) {
this.idInstitucionCarrera = nuevaInstitucionCarrera
2022-07-26 04:30:07 +00:00
},
},
created() {
2022-08-03 20:41:31 +00:00
if (this.idInstitucion) this.obtenerInstitucionCarreras()
2022-07-26 04:30:07 +00:00
},
}
</script>
<style scoped></style>