75 lines
1.8 KiB
Vue
75 lines
1.8 KiB
Vue
<template>
|
|
<b-field class="column mb-0 pb-0" label="Carrera" :class="columnSize">
|
|
<b-select
|
|
icon="store"
|
|
:loading="isLoadingSelect"
|
|
v-model="carrera"
|
|
expanded
|
|
rounded
|
|
>
|
|
<option :disabled="deshabilitarOptVacia" :value="objVacio">
|
|
Selecciona una opción
|
|
</option>
|
|
|
|
<option v-for="(c, index) in carreras" :key="index" :value="c">
|
|
{{ c.carrera.carrera }}
|
|
</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 },
|
|
carreraPadre: { type: Object, required: true, default: () => ({}) },
|
|
columnSize: { typeof: String, required: false, default: '' },
|
|
},
|
|
data: () => {
|
|
return {
|
|
carreras: [],
|
|
isLoadingSelect: false,
|
|
carrera: {},
|
|
objVacio: {},
|
|
}
|
|
},
|
|
methods: {
|
|
obtenerCarreras() {
|
|
this.isLoadingSelect = true
|
|
this.carreras = []
|
|
axios
|
|
.get(
|
|
`${process.env.api}/institucion-carrera?id_institucion=${this.idInstitucion}`
|
|
)
|
|
.then((res) => {
|
|
this.carreras = res.data
|
|
this.$emit('catalogo-carreras', this.carreras)
|
|
this.isLoadingSelect = false
|
|
})
|
|
.catch((err) => {
|
|
this.isLoadingSelect = false
|
|
})
|
|
},
|
|
},
|
|
watch: {
|
|
idInstitucion(nuevoIdInstitucion) {
|
|
if (nuevoIdInstitucion) this.obtenerCarreras()
|
|
},
|
|
carrera(carreraSeleccionada) {
|
|
this.$emit('carrera-seleccionada', carreraSeleccionada)
|
|
},
|
|
carreraPadre(nuevaCarrera) {
|
|
if (this.$objIsEmpty(nuevaCarrera)) this.carrera = this.objVacio
|
|
},
|
|
},
|
|
created() {
|
|
this.carrera = this.objVacio
|
|
},
|
|
}
|
|
</script>
|
|
|
|
<style scoped></style>
|