122 lines
3.5 KiB
Vue
122 lines
3.5 KiB
Vue
<template>
|
|
<div class="column">
|
|
<b-field label="Número de Inventario">
|
|
<b-input
|
|
type="text"
|
|
v-model="numeroInventario"
|
|
@keyup.enter.native="prestamoNumeroInventario()"
|
|
disabled
|
|
/>
|
|
</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 '@/components/operador/ModalMultaNumeroInventario'
|
|
|
|
export default {
|
|
props: {
|
|
operador: { type: Object, required: true, default: () => ({}) },
|
|
updateIsLoading: { type: Function, required: true, default: () => {} },
|
|
},
|
|
data() {
|
|
return {
|
|
numeroInventario: '',
|
|
}
|
|
},
|
|
methods: {
|
|
revisionMultaNumeroInventario() {
|
|
const modalProps = {
|
|
operador: this.operador,
|
|
regresarNumeroInventario: this.regresarNumeroInventario,
|
|
}
|
|
|
|
this.$buefy.modal.open({
|
|
props: modalProps,
|
|
parent: this,
|
|
component: ModalMultaNumeroInventario,
|
|
hasModalCard: true,
|
|
customClass: 'custom-class custom-class-2',
|
|
trapFocus: true,
|
|
})
|
|
},
|
|
regresarNumeroInventario(descripcion, id_institucion_infraccion) {
|
|
const data = {
|
|
id_operador: this.operador.id_operador,
|
|
numero_inventario: this.numeroInventario,
|
|
}
|
|
|
|
this.updateIsLoading(true)
|
|
if (descripcion) data.descripcion = descripcion
|
|
if (id_institucion_infraccion)
|
|
data.id_institucion_infraccion = id_institucion_infraccion
|
|
return axios
|
|
.put(
|
|
`${process.env.api}/prestamo/regresar-numero-inventario`,
|
|
data,
|
|
this.$getToken.token()
|
|
)
|
|
.then((res) => {
|
|
this.numeroInventario = ''
|
|
this.$alertsGenericos.imprimirMensaje(this.$buefy, res.data.message)
|
|
this.updateIsLoading(false)
|
|
})
|
|
.catch((err) => {
|
|
this.updateIsLoading(false)
|
|
this.$alertsGenericos.imprimirError(
|
|
this.$buefy,
|
|
this.$router,
|
|
err.response.data
|
|
)
|
|
})
|
|
},
|
|
prestamoNumeroInventario() {
|
|
if (this.numeroInventario) {
|
|
this.updateIsLoading(true)
|
|
return axios
|
|
.get(
|
|
`${process.env.api}/prestamo/prestamo-numero-inventario?numero_inventario=${this.numeroInventario}&id_institucion=${this.operador.institucion.id_institucion}`,
|
|
this.$getToken.token()
|
|
)
|
|
.then((res) => {
|
|
let data = res.data
|
|
|
|
this.updateIsLoading(false)
|
|
if (data.Equipo.Status.idStatus === 2)
|
|
this.$alertsGenericos.imprimirError(this.$buefy, this.$router, {
|
|
message: 'Aún no se entrega el equipo de cómputo al usuario.',
|
|
})
|
|
else if (data.Equipo.Status.idStatus === 3)
|
|
this.$alertsGenericos.imprimirWarning(
|
|
this.$buefy,
|
|
'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
|
|
)
|
|
})
|
|
.catch((err) => {
|
|
this.updateIsLoading(false)
|
|
this.$alertsGenericos.imprimirError(
|
|
this.$buefy,
|
|
this.$router,
|
|
err.response.data
|
|
)
|
|
})
|
|
}
|
|
},
|
|
},
|
|
}
|
|
</script>
|
|
|
|
<style></style>
|