139 lines
3.3 KiB
Vue
139 lines
3.3 KiB
Vue
<template>
|
|
<div class="px-2">
|
|
<p class="subtitle is-4">
|
|
<b
|
|
>Captura la siguiente información tal cual se muestra en tu ticket de
|
|
CEDETEC que se te entrego en cajas.</b
|
|
>
|
|
</p>
|
|
|
|
<div class="columns">
|
|
<b-image
|
|
class="column mx-2"
|
|
:src="require('@/assets/ticket.jpeg')"
|
|
alt="Ticket Acatlán"
|
|
ratio="16by10"
|
|
></b-image>
|
|
|
|
<div class="column pr-5">
|
|
<b-field label="Monto">
|
|
<b-input v-model="monto" type="number"></b-input>
|
|
</b-field>
|
|
|
|
<b-field label="Fecha">
|
|
<b-datepicker
|
|
v-model="fechaTicket"
|
|
placeholder="Selecciona la fecha"
|
|
icon="calendar-today"
|
|
:min-date="minDate"
|
|
:max-date="maxDate"
|
|
>
|
|
</b-datepicker>
|
|
</b-field>
|
|
|
|
<b-field label="Ticket">
|
|
<b-input maxlength="6" v-model="folio"></b-input>
|
|
</b-field>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="has-text-centered pb-2 pt-3">
|
|
<p>Tu crédito es de: ${{ creditoDisponible }} pesos</p>
|
|
</div>
|
|
|
|
<div class="has-text-centered pb-5 pt-3">
|
|
<b-button
|
|
:disabled="!(folio && monto && fechaTicket)"
|
|
@click="
|
|
imprimirWarning(
|
|
'¿Los datos para el servicio de impresiones son correctos?',
|
|
cargarCredito
|
|
)
|
|
"
|
|
type="is-success"
|
|
>Cargar crédito</b-button
|
|
>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import axios from 'axios'
|
|
|
|
export default {
|
|
props: {
|
|
imprimirMensaje: { type: Function, required: true },
|
|
imprimirWarning: { type: Function, required: true },
|
|
imprimirError: { type: Function, required: true },
|
|
updateIsLoading: { type: Function, required: true },
|
|
idUsuario: { type: Number, required: true },
|
|
},
|
|
data() {
|
|
const today = new Date()
|
|
return {
|
|
folio: '',
|
|
monto: '',
|
|
fechaTicket: null,
|
|
|
|
creditoDisponible: 0,
|
|
|
|
minDate: this.diaMin(today),
|
|
maxDate: new Date(),
|
|
|
|
data: {},
|
|
}
|
|
},
|
|
methods: {
|
|
traerCredito() {
|
|
this.updateIsLoading(true)
|
|
axios
|
|
.get(
|
|
`${process.env.api}/usuario/credito?numeroCuenta=${this.numeroCuenta}`,
|
|
this.token
|
|
)
|
|
.then((res) => {
|
|
this.updateIsLoading(false)
|
|
this.creditoDisponible = res.data.credito
|
|
})
|
|
.catch((err) => {
|
|
this.updateIsLoading(false)
|
|
this.imprimirError(err.response.data)
|
|
})
|
|
},
|
|
diaMin(today) {
|
|
return new Date(
|
|
today.getFullYear(),
|
|
today.getMonth(),
|
|
today.getDate() - today.getDate() + 1
|
|
)
|
|
},
|
|
clear() {
|
|
this.folio = ''
|
|
this.monto = ''((this.fechaTicket = null))
|
|
},
|
|
async cargarCredito() {
|
|
this.data.idUsuario = this.idUsuario
|
|
this.data.folio = this.folio
|
|
this.data.monto = this.monto
|
|
this.data.fechaTicket = this.fechaTicket
|
|
|
|
this.updateIsLoading(true)
|
|
await axios
|
|
.post(`${process.env.api}/Usuario/agregar_credito`, this.data)
|
|
.then((res) => {
|
|
this.updateIsLoading(false)
|
|
this.imprimirMensaje(res.data.message)
|
|
this.clear()
|
|
})
|
|
.catch((err) => {
|
|
this.updateIsLoading(false)
|
|
this.imprimirError(err.response.data)
|
|
})
|
|
},
|
|
},
|
|
created() {
|
|
this.traerCredito()
|
|
},
|
|
}
|
|
</script>
|