127 lines
3.8 KiB
Vue
127 lines
3.8 KiB
Vue
<template>
|
|
<div class="column">
|
|
<b-field label="Número de Inventario">
|
|
<b-input
|
|
type="text"
|
|
v-model="numeroInventario"
|
|
@keyup.enter.native="prestamoNumeroInventario()"
|
|
/>
|
|
</b-field>
|
|
|
|
<b-field class="has-text-centered">
|
|
<b-button
|
|
type="is-info"
|
|
@click="prestamoNumeroInventario()"
|
|
:disabled="!numeroInventario"
|
|
>
|
|
Enviar
|
|
</b-button>
|
|
</b-field>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import axios from 'axios'
|
|
import ModalMultaNumeroInventario from './ModalMultaNumeroInventario'
|
|
|
|
export default {
|
|
props: {
|
|
operador: { type: Object, required: true },
|
|
imprimirWarning: { type: Function, required: true },
|
|
imprimirError: { type: Function, required: true },
|
|
imprimirMensaje: { type: Function, required: true },
|
|
updateIsLoading: { type: Function, required: true },
|
|
},
|
|
data() {
|
|
return {
|
|
numeroInventario: '',
|
|
}
|
|
},
|
|
methods: {
|
|
revisionMultaNumeroInventario() {
|
|
const modalProps = {
|
|
operador: this.operador,
|
|
numeroInventario: this.numeroInventario,
|
|
regresarNumeroInventario: this.regresarNumeroInventario,
|
|
updateIsLoading: this.updateIsLoading,
|
|
imprimirError: this.imprimirError,
|
|
imprimirMensaje: this.imprimirMensaje,
|
|
}
|
|
|
|
this.$buefy.modal.open({
|
|
props: modalProps,
|
|
parent: this,
|
|
component: ModalMultaNumeroInventario,
|
|
hasModalCard: true,
|
|
customClass: 'custom-class custom-class-2',
|
|
trapFocus: true,
|
|
})
|
|
},
|
|
regresarNumeroInventario() {
|
|
const data = {
|
|
idOperadorRegreso: this.operador.idOperador,
|
|
numeroInventario: this.numeroInventario,
|
|
}
|
|
|
|
this.updateIsLoading(true)
|
|
axios
|
|
.put(
|
|
`${process.env.api}/prestamo/regresar_numero_inventario`,
|
|
data,
|
|
this.operador.token
|
|
)
|
|
.then((res) => {
|
|
this.numeroInventario = ''
|
|
this.imprimirMensaje(res.data.message)
|
|
this.updateIsLoading(false)
|
|
})
|
|
.catch((err) => {
|
|
this.updateIsLoading(false)
|
|
this.imprimirError(err.response.data)
|
|
})
|
|
},
|
|
prestamoNumeroInventario() {
|
|
if (this.numeroInventario) {
|
|
this.updateIsLoading(true)
|
|
axios
|
|
.get(
|
|
`${process.env.api}/prestamo/prestamo_numero_inventario?numeroInventario=${this.numeroInventario}`,
|
|
this.operador.token
|
|
)
|
|
.then((res) => {
|
|
let data = res.data
|
|
|
|
this.updateIsLoading(false)
|
|
if (data.activo) {
|
|
if (data.Equipo.Status.idStatus === 1)
|
|
this.imprimirError({
|
|
message: 'Aún no se entrega el equipo de cómputo al usuario.',
|
|
})
|
|
else if (data.Equipo.Status.idStatus === 2)
|
|
this.imprimirWarning(
|
|
'Esta a punto de recibir el equipo de cómputo y dar por terminado un préstamo. ¿Esta segur@ de querer realizar esta acción?',
|
|
this.revisionMultaNumeroInventario
|
|
)
|
|
}
|
|
// this.imprimirWarning(
|
|
// 'Esta a punto de confirmar el regreso de un equipo de cómputo. ¿Esta segur@ de querer realizar esta acción?',
|
|
// this.revisionMultaNumeroInventario
|
|
// )
|
|
else
|
|
this.imprimirError({
|
|
message:
|
|
'Por el momento la opción de confirmar el regreso de un equipo por número de inventario no se encuentra disponible. Favor de usar el número de préstamo.',
|
|
})
|
|
})
|
|
.catch((err) => {
|
|
this.updateIsLoading(false)
|
|
this.imprimirError(err.response.data)
|
|
})
|
|
}
|
|
},
|
|
},
|
|
}
|
|
</script>
|
|
|
|
<style></style>
|