responsable info
This commit is contained in:
@@ -0,0 +1,109 @@
|
||||
<template>
|
||||
<div>
|
||||
<h3 class="title">Información del responsable</h3>
|
||||
|
||||
<b-field label="Nombre:">
|
||||
<p class="input">{{ responsable.nombre }}</p>
|
||||
</b-field>
|
||||
|
||||
<b-field label="Correo:">
|
||||
<p class="input">{{ responsable.usuario }}</p>
|
||||
</b-field>
|
||||
|
||||
<b-field label="Clave de programa:">
|
||||
<b-select v-model="programaSelected" expanded>
|
||||
<option value="" disabled>Elija una clave de programa:</option>
|
||||
|
||||
<option v-for="(p, i) in programas" :key="i" :value="i">
|
||||
{{ p.clavePrograma }}
|
||||
</option>
|
||||
</b-select>
|
||||
</b-field>
|
||||
|
||||
<b-field label="Institucion:">
|
||||
<p class="input">{{ programa.institucion }}</p>
|
||||
</b-field>
|
||||
|
||||
<b-field label="Dependencia:">
|
||||
<p class="input">{{ programa.dependencia }}</p>
|
||||
</b-field>
|
||||
|
||||
<b-field label="Programa:">
|
||||
<p class="input">{{ programa.programa }}</p>
|
||||
</b-field>
|
||||
|
||||
<b-button
|
||||
type="is-link"
|
||||
class="my-5"
|
||||
tag="router-link"
|
||||
to="/admin/responsables/responsable/modificar"
|
||||
>
|
||||
Editar información
|
||||
</b-button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import axios from 'axios'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
idResponsable: null,
|
||||
programaSelected: null,
|
||||
programas: [],
|
||||
programa: {},
|
||||
responsable: {},
|
||||
}
|
||||
},
|
||||
props: {
|
||||
admin: { type: Object, required: true },
|
||||
imprimirError: { type: Function, required: true },
|
||||
updateIsLoading: { type: Function, required: true },
|
||||
},
|
||||
methods: {
|
||||
obtenerResponsable() {
|
||||
this.updateIsLoading(true)
|
||||
axios
|
||||
.get(
|
||||
`${process.env.api}/usuario/responsable?idUsuario=${this.idResponsable}`,
|
||||
this.admin.token
|
||||
)
|
||||
.then((res) => {
|
||||
this.responsable = res.data
|
||||
this.obtenerProgramas()
|
||||
this.updateIsLoading(false)
|
||||
})
|
||||
.catch((err) => {
|
||||
this.updateIsLoading(false)
|
||||
this.imprimirError(err.response.data)
|
||||
})
|
||||
},
|
||||
obtenerProgramas() {
|
||||
axios
|
||||
.get(
|
||||
`${process.env.api}/programa/programas_admin?idUsuario=${this.idResponsable}`,
|
||||
this.admin.token
|
||||
)
|
||||
.then((res) => {
|
||||
this.programas = res.data
|
||||
})
|
||||
.catch((err) => {
|
||||
this.imprimirError(err.response.data)
|
||||
})
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
programaSelected() {
|
||||
this.programa = this.programas[this.programaSelected]
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.idResponsable = Number(localStorage.getItem('idResponsable'))
|
||||
if (this.admin.idTipoUsuario === 1 && this.idResponsable)
|
||||
this.obtenerResponsable()
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped></style>
|
||||
@@ -0,0 +1,154 @@
|
||||
<template>
|
||||
<div>
|
||||
<h3 class="title">Editar información del responsable</h3>
|
||||
|
||||
<b-field label="Nombre">
|
||||
<b-input
|
||||
type="text"
|
||||
:placeholder="responsable.nombre"
|
||||
v-model="nuevo.nombre"
|
||||
>
|
||||
</b-input>
|
||||
</b-field>
|
||||
|
||||
<b-field label="Correo eletrónico">
|
||||
<b-input
|
||||
type="email"
|
||||
:placeholder="responsable.usuario"
|
||||
v-model="nuevo.correo"
|
||||
>
|
||||
</b-input>
|
||||
</b-field>
|
||||
|
||||
<!-- <b-field label="Estado:">
|
||||
<b-select v-model="nuevo.activo" expanded>
|
||||
<option :value="true">Activado</option>
|
||||
<option :value="false">Desactivado</option>
|
||||
</b-select>
|
||||
</b-field> -->
|
||||
|
||||
<div class="pt-5">
|
||||
<b-button
|
||||
type="is-info"
|
||||
:disabled="mostrarBoton()"
|
||||
@click="
|
||||
imprimirWarning(
|
||||
'¿Seguro(a) que quiere actualizar la información de este usuario?',
|
||||
actualizar
|
||||
)
|
||||
"
|
||||
>
|
||||
Guardar Cambios
|
||||
</b-button>
|
||||
|
||||
<b-button
|
||||
type="is-info"
|
||||
@click="
|
||||
imprimirWarning(
|
||||
'¿Seguro(a) que quiere cambiar la contraseña para este usuario?',
|
||||
password
|
||||
)
|
||||
"
|
||||
>
|
||||
Cambiar contraseña
|
||||
</b-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import validator from 'validator'
|
||||
import axios from 'axios'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
responsable: {},
|
||||
idResponsable: null,
|
||||
nuevo: {},
|
||||
}
|
||||
},
|
||||
props: {
|
||||
admin: { type: Object, required: true },
|
||||
imprimirMensaje: { type: Function, required: true },
|
||||
imprimirWarning: { type: Function, required: true },
|
||||
imprimirError: { type: Function, required: true },
|
||||
updateIsLoading: { type: Function, required: true },
|
||||
},
|
||||
methods: {
|
||||
mostrarBoton() {
|
||||
if (this.nuevo.correo) {
|
||||
if (!validator.isEmail(this.nuevo.correo)) return true
|
||||
if (this.nuevo.correo != this.responsable.usuario) return false
|
||||
}
|
||||
if (this.nuevo.nombre && this.nuevo.nombre != this.responsable.nombre)
|
||||
return false
|
||||
return true
|
||||
},
|
||||
actualizar() {
|
||||
const data = { idUsuario: this.idResponsable }
|
||||
|
||||
this.updateIsLoading(true)
|
||||
if (this.nuevo.correo) data.correo = this.nuevo.correo
|
||||
if (this.nuevo.nombre) data.nombre = this.nuevo.nombre
|
||||
axios
|
||||
.put(
|
||||
`${process.env.api}/usuario/responsable/update`,
|
||||
data,
|
||||
this.admin.token
|
||||
)
|
||||
.then((res) => {
|
||||
this.updateIsLoading(false)
|
||||
this.imprimirMensaje(res.data.message)
|
||||
this.$router.push('/admin/responsables')
|
||||
})
|
||||
.catch((err) => {
|
||||
this.updateIsLoading(false)
|
||||
this.imprimirError(err.response.data)
|
||||
})
|
||||
},
|
||||
password() {
|
||||
const data = { idUsuario: this.idResponsable }
|
||||
|
||||
this.updateIsLoading(true)
|
||||
axios
|
||||
.put(
|
||||
`${process.env.api}/usuario/new_password_responsable`,
|
||||
data,
|
||||
this.admin.token
|
||||
)
|
||||
.then((res) => {
|
||||
this.updateIsLoading(false)
|
||||
this.imprimirMensaje(res.data.message)
|
||||
this.$router.push('/admin/responsables')
|
||||
})
|
||||
.catch((err) => {
|
||||
this.updateIsLoading(false)
|
||||
this.imprimirError(err.response.data)
|
||||
})
|
||||
},
|
||||
obtenerResponsable() {
|
||||
this.updateIsLoading(true)
|
||||
axios
|
||||
.get(
|
||||
`${process.env.api}/usuario/responsable?idUsuario=${this.idResponsable}`,
|
||||
this.admin.token
|
||||
)
|
||||
.then((res) => {
|
||||
this.responsable = res.data
|
||||
// this.nuevo.activo = this.responsable.activo
|
||||
this.updateIsLoading(false)
|
||||
})
|
||||
.catch((err) => {
|
||||
this.updateIsLoading(false)
|
||||
this.imprimirError(err.response.data)
|
||||
})
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.idResponsable = localStorage.getItem('idResponsable')
|
||||
if (this.admin.idTipoUsuario === 1 && this.idResponsable)
|
||||
this.obtenerResponsable()
|
||||
},
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user