99 lines
2.5 KiB
Vue
99 lines
2.5 KiB
Vue
<template>
|
|
<div class="columns margin">
|
|
<div class="column ml-2 mr-5">
|
|
<b-field label="Número de cuenta">
|
|
<b-input v-model="numeroCuenta" expanded></b-input>
|
|
<p class="control">
|
|
<b-button @click="traerDatos" type="is-link">Buscar</b-button>
|
|
</p>
|
|
</b-field>
|
|
|
|
<b-field label="Restar crédito">
|
|
<b-input type="number" v-model="credito" expanded></b-input>
|
|
<p class="control">
|
|
<b-button @click="restarCredito" type="is-link">Restar</b-button>
|
|
</p>
|
|
</b-field>
|
|
</div>
|
|
|
|
<div class="column mr-2 box ml-5">
|
|
<p class="subtitle is-3">Cuenta: {{ this.numeroCuenta }}</p>
|
|
<p class="subtitle is-3">Nombre: {{ datos.nombre }}</p>
|
|
<p class="subtitle is-3">Credito: {{ datos.credito }}</p>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import axios from 'axios'
|
|
export default {
|
|
props: {
|
|
updateIsLoading: { type: Function, require: true },
|
|
imprimirError: { type: Function, require: true },
|
|
imprimirMensaje: { type: Function, require: true },
|
|
imprimirWarning: { type: Function, require: true },
|
|
},
|
|
data() {
|
|
return {
|
|
token: '',
|
|
|
|
numeroCuenta: '',
|
|
credito: '',
|
|
datos: {},
|
|
}
|
|
},
|
|
methods: {
|
|
traerDatos() {
|
|
this.updateIsLoading(true)
|
|
axios
|
|
.get(
|
|
`${process.env.api}/admin/credito?numeroCuenta=${this.numeroCuenta}`,
|
|
this.token
|
|
)
|
|
.then((res) => {
|
|
this.updateIsLoading(false)
|
|
console.log(res)
|
|
// this.datos.nombre = res.nombre
|
|
// this.datos.credito = res.credito
|
|
})
|
|
.catch((err) => {
|
|
this.updateIsLoading(false)
|
|
this.imprimirError(err.response.data)
|
|
})
|
|
},
|
|
restarCredito() {
|
|
const data = {
|
|
numeroCuenta: this.numeroCuenta,
|
|
creditoUsado: this.credito,
|
|
}
|
|
this.updateIsLoading(true)
|
|
axios
|
|
.get(`${process.env.api}/usuario/restar_credito`, data, this.token)
|
|
.then((res) => {
|
|
this.updateIsLoading(false)
|
|
;(this.datos.nombre = res.data.nombre),
|
|
(this.datos.credito = res.data.credito)
|
|
this.imprimirMensaje(res.data.message)
|
|
this.traerDatos()
|
|
})
|
|
.catch((err) => {
|
|
this.updateIsLoading(false)
|
|
this.imprimirError(err.response.data)
|
|
})
|
|
},
|
|
},
|
|
created() {
|
|
this.token = {
|
|
headers: { token: localStorage.getItem('token') },
|
|
}
|
|
},
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
.margin {
|
|
margin-top: 70px;
|
|
padding-bottom: 10%;
|
|
}
|
|
</style>
|