2022-06-27 21:59:35 +00:00
|
|
|
<template>
|
|
|
|
<div
|
|
|
|
class="full-h is-flex is-justify-content-center is-align-items-center my-5"
|
|
|
|
>
|
|
|
|
<form class="box">
|
|
|
|
<div class="has-text-centered">
|
|
|
|
<h2 class="is-size-1">PC Puma</h2>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<b-field label="Usuario" :type="error">
|
|
|
|
<b-input v-model="usuario" @keyup.enter.native="login()" />
|
|
|
|
</b-field>
|
|
|
|
|
|
|
|
<b-field label="Contraseña" :type="error">
|
|
|
|
<b-input
|
|
|
|
type="password"
|
|
|
|
password-reveal
|
|
|
|
v-model="password"
|
|
|
|
@keyup.enter.native="login()"
|
|
|
|
/>
|
|
|
|
</b-field>
|
|
|
|
|
|
|
|
<div class="has-text-centered">
|
|
|
|
<b-button
|
|
|
|
@click="login()"
|
|
|
|
type="is-success"
|
|
|
|
:disabled="error || !usuario || !password"
|
|
|
|
>
|
|
|
|
Iniciar Sesión
|
|
|
|
</b-button>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import axios from 'axios'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
updateIsLoading: { type: Function, required: true },
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
error: '',
|
|
|
|
usuario: '',
|
|
|
|
password: '',
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
login() {
|
|
|
|
if (this.usuario && this.password && !this.error) {
|
|
|
|
const data = {
|
|
|
|
operador: this.usuario,
|
|
|
|
password: this.password,
|
|
|
|
}
|
|
|
|
this.updateIsLoading(true)
|
|
|
|
axios
|
2022-07-19 16:41:33 +00:00
|
|
|
.post(
|
|
|
|
`${process.env.api}/auth/login-admin`,
|
|
|
|
data,
|
|
|
|
this.$getToken.token()
|
|
|
|
)
|
2022-06-27 21:59:35 +00:00
|
|
|
.then((res) => {
|
|
|
|
const info = JSON.stringify(res.data)
|
|
|
|
localStorage.setItem('usuario', info)
|
2022-07-19 19:45:18 +00:00
|
|
|
localStorage.setItem('token', res.data.token)
|
2022-06-27 21:59:35 +00:00
|
|
|
this.updateIsLoading(false)
|
2022-07-13 04:34:18 +00:00
|
|
|
if (res.data.operador.tipoUsuario.id_tipo_usuario === 3)
|
2022-07-29 14:16:12 +00:00
|
|
|
this.$router.push('/prestamo_devolucion')
|
|
|
|
else
|
|
|
|
this.$router.push(
|
|
|
|
'/admin/configuracion/instituciones/buscar_institucion'
|
|
|
|
)
|
2022-06-27 21:59:35 +00:00
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
this.error = 'is-danger'
|
|
|
|
this.updateIsLoading(false)
|
2022-07-11 14:15:10 +00:00
|
|
|
this.$alertsGenericos.imprimirError(this.$buefy, err.response.data)
|
2022-06-27 21:59:35 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
obtenerCatalogoInstitucion() {
|
|
|
|
axios
|
2022-07-19 16:41:33 +00:00
|
|
|
.get(`${process.env.api}/institucion`, this.$getToken.token())
|
2022-06-27 21:59:35 +00:00
|
|
|
.then((res) => {
|
|
|
|
this.instituciones = res.data
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
2022-07-11 14:15:10 +00:00
|
|
|
this.$alertsGenericos.imprimirError(this.$buefy, err.response.data)
|
2022-06-27 21:59:35 +00:00
|
|
|
})
|
|
|
|
},
|
|
|
|
obtenerCatalogoModulo() {
|
|
|
|
axios
|
|
|
|
.get(
|
2022-07-19 16:41:33 +00:00
|
|
|
`${process.env.api}/modulo/modulos?id_institucion=${this.idInstitucion}`,
|
|
|
|
this.$getToken.token()
|
2022-06-27 21:59:35 +00:00
|
|
|
)
|
|
|
|
.then((res) => {
|
|
|
|
this.modulos = res.data
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
2022-07-11 14:15:10 +00:00
|
|
|
this.$alertsGenericos.imprimirError(this.$buefy, err.response.data)
|
2022-06-27 21:59:35 +00:00
|
|
|
})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
password() {
|
|
|
|
if (this.error) this.error = ''
|
|
|
|
},
|
|
|
|
usuario() {
|
|
|
|
if (this.error) this.error = ''
|
|
|
|
},
|
|
|
|
idInstitucion() {
|
|
|
|
this.obtenerCatalogoModulo()
|
|
|
|
},
|
|
|
|
},
|
2022-07-19 16:41:33 +00:00
|
|
|
created() {},
|
2022-06-27 21:59:35 +00:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
.full-h {
|
|
|
|
height: 75vh;
|
|
|
|
}
|
|
|
|
|
|
|
|
form {
|
|
|
|
width: 30rem;
|
|
|
|
}
|
|
|
|
</style>
|