-
Editar información del alumno
-
-
-
+
@@ -77,13 +78,16 @@
Actualizar Datos
-
-
@@ -107,6 +111,7 @@ export default {
imprimirMensaje: { type: Function, required: true },
imprimirWarning: { type: Function, required: true },
imprimirError: { type: Function, required: true },
+ updateIsLoading: { type: Function, required: true },
},
methods: {
fecha(date) {
@@ -141,21 +146,10 @@ export default {
}
return false
},
- actualizarDialog() {
- this.$buefy.dialog.confirm({
- title: 'Actualizar datos',
- message: '¿Seguro(a) que quiere actualizar estos datos?',
- confirmText: 'Confirmar',
- cancelText: 'Cancelar',
- type: 'is-success',
- hasIcon: true,
- onConfirm: () => this.actualizar(),
- })
- },
actualizar() {
const data = { idCasoEspecial: this.idCasoEspecial }
- this.isLoading = true
+ this.updateIsLoading(true)
if (this.nuevo.direccion) data.direccion = this.nuevo.direccion
if (this.nuevo.correo) data.correo = this.nuevo.correo
if (this.nuevo.telefono) data.telefono = this.nuevo.telefono
@@ -167,33 +161,32 @@ export default {
if (this.nuevo.fechaFin) data.fechaFin = moment(this.nuevo.fechaFin)
if (this.nuevo.fechaNacimiento)
data.fechaNacimiento = moment(this.nuevo.fechaNacimiento)
-
axios
.put(`${process.env.api}/caso_especial/update`, data, this.admin.token)
.then((res) => {
- this.isLoading = false
- this.$buefy.dialog.alert('Los datos han sido actualizados')
+ this.updateIsLoading(false)
+ this.imprimirMensaje(res.data.message)
this.$router.push('/admin/casos_especiales/caso_especial')
})
.catch((err) => {
- this.isLoading = false
- this.error(err.response.data.message)
+ this.updateIsLoading(false)
+ this.imprimirError(err.response.data)
})
},
obtenerCasoEspecial() {
- this.isLoading = true
- return axios
+ this.updateIsLoading(true)
+ axios
.get(
`${process.env.api}/caso_especial/?idCasoEspecial=${this.idCasoEspecial}`,
this.admin.token
)
.then((res) => {
this.viejo = res.data
- this.isLoading = false
+ this.updateIsLoading(false)
})
.catch((err) => {
- this.isLoading = false
- this.error(err.response.data.message)
+ this.updateIsLoading(false)
+ this.imprimirError(err.response.data)
})
},
},
@@ -205,7 +198,8 @@ export default {
},
created() {
this.idCasoEspecial = localStorage.getItem('idCasoEspecial')
- if (this.admin.idTipoUsuario === 1) this.obtenerCasoEspecial()
+ if (this.admin.idTipoUsuario === 1 && this.idCasoEspecial)
+ this.obtenerCasoEspecial()
},
}
diff --git a/pages/admin/casos_especiales/caso_especial/editar/index.vue b/pages/admin/casos_especiales/caso_especial/editar/index.vue
index fcc8b0f..382f933 100644
--- a/pages/admin/casos_especiales/caso_especial/editar/index.vue
+++ b/pages/admin/casos_especiales/caso_especial/editar/index.vue
@@ -2,12 +2,17 @@