pcpuma_unam_operador/components/crear/CrearCarreraPrograma.vue

95 lines
2.6 KiB
Vue
Raw Normal View History

2022-07-26 05:44:07 +00:00
<template>
2022-07-26 13:35:38 +00:00
<section class="mb-6">
2022-07-26 21:06:12 +00:00
<h3 class="is-size-4 mb-3">Asociar un software con una carrera</h3>
2022-07-26 05:44:07 +00:00
2022-07-26 13:35:38 +00:00
<div class="box">
<div class="columns is-align-items-flex-end pl-0 pb-4">
<SelectCarrera
:idInstitucion="idInstitucion"
:institucionCarreraPadre="institucionCarrera"
@institucion-carrera-seleccionada="
(nuevaInstitucionCarrera) =>
(institucionCarrera = nuevaInstitucionCarrera)
"
/>
2022-07-26 05:44:07 +00:00
2022-07-26 13:35:38 +00:00
<SelectPrograma
:programaPadre="programa"
@programa-seleccionado="(nuevoPrograma) => (programa = nuevoPrograma)"
/>
2022-07-26 05:44:07 +00:00
2022-07-26 13:35:38 +00:00
<BotonCrear
:disabled="
!institucionCarrera.id_institucion_carrera || !programa.id_programa
2022-07-26 05:44:07 +00:00
"
2022-07-26 13:35:38 +00:00
:crear="warning"
/>
</div>
</div>
</section>
2022-07-26 05:44:07 +00:00
</template>
<script>
import axios from 'axios'
2022-07-26 13:35:38 +00:00
import BotonCrear from '@/components/botones/BotonCrear'
import SelectCarrera from '@/components/selects/SelectCarrera'
import SelectPrograma from '@/components/selects/SelectPrograma'
2022-07-26 05:44:07 +00:00
export default {
2022-07-26 13:35:38 +00:00
components: { BotonCrear, SelectCarrera, SelectPrograma },
2022-07-26 05:44:07 +00:00
props: {
2022-07-26 21:06:12 +00:00
obtenerCarrerasProgramas: {
type: Function,
required: true,
default: () => {},
},
2022-07-26 13:35:38 +00:00
updateIsLoading: { type: Function, required: true },
idInstitucion: { type: Number, required: true, default: 0 },
2022-07-26 05:44:07 +00:00
},
data() {
return {
2022-07-26 13:35:38 +00:00
institucionCarrera: {},
programa: {},
2022-07-26 05:44:07 +00:00
}
},
methods: {
2022-07-26 13:35:38 +00:00
crearCarreraPrograma() {
2022-07-26 05:44:07 +00:00
const data = {
2022-07-26 13:35:38 +00:00
id_institucion_carrera: this.institucionCarrera.id_institucion_carrera,
id_programa: this.programa.id_programa,
2022-07-26 05:44:07 +00:00
}
this.updateIsLoading(true)
axios
.post(
`${process.env.api}/carrera-programa`,
data,
this.$getToken.token()
)
.then((res) => {
2022-07-26 13:35:38 +00:00
this.institucionCarrera = {}
this.programa = {}
2022-07-26 21:06:12 +00:00
this.obtenerCarrerasProgramas()
2022-07-26 05:44:07 +00:00
this.updateIsLoading(false)
this.$alertsGenericos.imprimirMensaje(this.$buefy, res.data.message)
})
.catch((err) => {
this.updateIsLoading(false)
this.$alertsGenericos.imprimirError(this.$buefy, err.response.data)
})
},
2022-07-26 13:35:38 +00:00
warning() {
if (
2022-07-26 21:06:12 +00:00
this.institucionCarrera.id_institucion_carrera &&
this.programa.id_programa
2022-07-26 13:35:38 +00:00
)
this.$alertsGenericos.imprimirWarning(
this.$buefy,
'¿Estas segur@ de querer asignar este software a esta carrera?',
this.crearCarreraPrograma
2022-07-26 05:44:07 +00:00
)
},
},
}
</script>