75 lines
1.9 KiB
Vue
75 lines
1.9 KiB
Vue
<template>
|
|
<section class="mb-6">
|
|
<h3 class="is-size-4 mb-3">Crear módulo</h3>
|
|
|
|
<div class="box">
|
|
<div class="columns is-align-items-flex-end pl-0 pb-4">
|
|
<InputModulo
|
|
:moduloPadre="modulo"
|
|
:ejecutar="warning"
|
|
@modulo="(moduloNuevo) => (modulo = moduloNuevo)"
|
|
column
|
|
/>
|
|
|
|
<BotonCrear columnSize="is-3" :disabled="!modulo" :crear="warning" />
|
|
</div>
|
|
</div>
|
|
</section>
|
|
</template>
|
|
|
|
<script>
|
|
import axios from 'axios'
|
|
import InputModulo from '@/components/inputs/InputModulo'
|
|
import BotonCrear from '@/components/botones/BotonCrear'
|
|
|
|
export default {
|
|
components: { BotonCrear, InputModulo },
|
|
props: {
|
|
updateActualizarTabla: {
|
|
type: Function,
|
|
required: true,
|
|
default: () => {},
|
|
},
|
|
updateIsLoading: { type: Function, required: true, default: () => {} },
|
|
idInstitucion: { type: Number, required: true, default: 0 },
|
|
},
|
|
data() {
|
|
return { modulo: '' }
|
|
},
|
|
methods: {
|
|
crearModulo() {
|
|
const data = {
|
|
id_institucion: this.idInstitucion,
|
|
modulo: this.modulo,
|
|
}
|
|
|
|
this.updateIsLoading(true)
|
|
return axios
|
|
.post(`${process.env.api}/modulo`, data, this.$getToken.token())
|
|
.then((res) => {
|
|
this.modulo = ''
|
|
this.updateActualizarTabla(true)
|
|
this.updateIsLoading(false)
|
|
this.$alertsGenericos.imprimirMensaje(this.$buefy, res.data.message)
|
|
})
|
|
.catch((err) => {
|
|
this.updateIsLoading(false)
|
|
this.$alertsGenericos.imprimirError(
|
|
this.$buefy,
|
|
this.$router,
|
|
err.response.data
|
|
)
|
|
})
|
|
},
|
|
warning() {
|
|
if (this.modulo)
|
|
this.$alertsGenericos.imprimirWarning(
|
|
this.$buefy,
|
|
'¿Esta segur@ de querer crear este módulo?',
|
|
this.crearModulo
|
|
)
|
|
},
|
|
},
|
|
}
|
|
</script>
|