pcpuma_unam_operador/components/selects/SelectCarrera.vue

89 lines
2.2 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
icon="store"
:loading="isLoadingSelect"
2022-07-26 13:35:38 +00:00
v-model="institucionCarrera"
2022-07-26 04:30:07 +00:00
expanded
rounded
>
<option :disabled="deshabilitarOptVacia" :value="objVacio">
Selecciona una opción
</option>
2022-07-26 13:35:38 +00:00
<option
v-for="(ic, index) in institucionCarreras"
:key="index"
:value="ic"
>
{{ 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-07-26 13:35:38 +00:00
institucionCarreraPadre: {
type: Object,
required: true,
default: () => ({}),
},
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-07-26 13:35:38 +00:00
institucionCarrera: {},
2022-07-26 04:30:07 +00:00
objVacio: {},
}
},
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: {
idInstitucion(nuevoIdInstitucion) {
2022-07-26 13:35:38 +00:00
if (nuevoIdInstitucion) this.obtenerInstitucionCarreras()
2022-07-26 04:30:07 +00:00
},
2022-07-26 13:35:38 +00:00
institucionCarrera(institucionCarreraSeleccionada) {
this.$emit(
'institucion-carrera-seleccionada',
institucionCarreraSeleccionada
)
2022-07-26 04:30:07 +00:00
},
2022-07-26 13:35:38 +00:00
institucionCarreraPadre(nuevaInstitucionCarrera) {
2022-07-26 21:06:12 +00:00
if (this.$funcionesGlobales.objIsEmpty(nuevaInstitucionCarrera))
2022-07-26 13:35:38 +00:00
this.institucionCarrera = this.objVacio
2022-07-26 04:30:07 +00:00
},
},
created() {
2022-07-26 13:35:38 +00:00
this.institucionCarrera = this.objVacio
2022-07-26 21:06:12 +00:00
this.obtenerInstitucionCarreras()
2022-07-26 04:30:07 +00:00
},
}
</script>
<style scoped></style>