2022-07-15 05:17:57 +00:00
|
|
|
<template>
|
|
|
|
<form class="modal-card">
|
|
|
|
<header class="modal-card-head">
|
|
|
|
<h5 class="modal-card-title">Multas</h5>
|
|
|
|
</header>
|
|
|
|
|
|
|
|
<section class="modal-card-body">
|
|
|
|
<b-field label="Número de Préstamo:">
|
|
|
|
<b-input type="input" v-model="idPrestamo" expanded />
|
|
|
|
</b-field>
|
|
|
|
|
|
|
|
<b-field label="Infracción cometida por el usuario:">
|
|
|
|
<b-select placeholder="Seleccionar" v-model="idInfraccion" expanded>
|
|
|
|
<option value="" disabled>Selecciona una opción</option>
|
|
|
|
<option
|
|
|
|
v-for="(i, index) in infracciones"
|
|
|
|
:key="index"
|
2022-07-15 21:12:49 +00:00
|
|
|
:value="i.id_institucion_infraccion"
|
2022-07-15 05:17:57 +00:00
|
|
|
>
|
2022-07-15 21:12:49 +00:00
|
|
|
{{ i.infraccion.infraccion }}
|
2022-07-15 05:17:57 +00:00
|
|
|
</option>
|
|
|
|
</b-select>
|
|
|
|
</b-field>
|
|
|
|
|
|
|
|
<b-field label="Motivos por los que desea multar al usuario:">
|
|
|
|
<b-input
|
|
|
|
type="textarea"
|
|
|
|
maxlength="500"
|
|
|
|
v-model="descripcion"
|
|
|
|
expanded
|
|
|
|
/>
|
|
|
|
</b-field>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
<footer
|
|
|
|
class="modal-card-foot"
|
|
|
|
style="display: flex; justify-content: space-between"
|
|
|
|
>
|
|
|
|
<b-button type="is-danger" @click="$emit('close')"> Cancelar </b-button>
|
|
|
|
|
|
|
|
<b-button
|
|
|
|
type="is-success"
|
|
|
|
@click="
|
|
|
|
multaPrestamo()
|
|
|
|
$emit('close')
|
|
|
|
"
|
2022-07-15 21:12:49 +00:00
|
|
|
:disabled="!idInfraccion || !descripcion || !idPrestamo"
|
2022-07-15 05:17:57 +00:00
|
|
|
>
|
|
|
|
Enviar
|
|
|
|
</b-button>
|
|
|
|
</footer>
|
|
|
|
</form>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import axios from 'axios'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
operador: { type: Object, required: true },
|
|
|
|
usuario: { type: Object, required: true },
|
2022-07-15 21:12:49 +00:00
|
|
|
updateIsLoading: { type: Function, required: true },
|
2022-07-15 05:17:57 +00:00
|
|
|
buscar: { type: Function, required: true },
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
idPrestamo: '',
|
|
|
|
idInfraccion: '',
|
|
|
|
descripcion: '',
|
|
|
|
infracciones: [],
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
multaPrestamo() {
|
|
|
|
const data = {
|
2022-07-15 21:12:49 +00:00
|
|
|
id_institucion_infraccion: this.idInfraccion,
|
2022-07-15 05:17:57 +00:00
|
|
|
id_operador: this.operador.id_operador,
|
2022-07-15 21:12:49 +00:00
|
|
|
id_prestamo: Number(this.idPrestamo),
|
2022-07-15 05:17:57 +00:00
|
|
|
descripcion: this.descripcion,
|
|
|
|
}
|
|
|
|
|
|
|
|
this.updateIsLoading(true)
|
|
|
|
return axios
|
2022-07-19 16:41:33 +00:00
|
|
|
.post(`${process.env.api}/multa`, data, this.$getToken.token())
|
2022-07-15 05:17:57 +00:00
|
|
|
.then((res) => {
|
|
|
|
this.buscar()
|
|
|
|
this.updateIsLoading(false)
|
|
|
|
this.imprimirMensaje(res.data.message)
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
this.updateIsLoading(false)
|
|
|
|
this.$alertsGenericos.imprimirError(this.$buefy, err.response.data)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
obtenerInfracciones() {
|
|
|
|
axios
|
|
|
|
.get(
|
2022-07-15 21:12:49 +00:00
|
|
|
`${process.env.api}/institucion-infraccion/infracciones?id_institucion=${this.operador.institucion.id_institucion}`,
|
2022-07-19 16:41:33 +00:00
|
|
|
this.$getToken.token()
|
2022-07-15 05:17:57 +00:00
|
|
|
)
|
|
|
|
.then((res) => {
|
|
|
|
this.infracciones = res.data
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
this.$alertsGenericos.imprimirError(this.$buefy, err.response.data)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.obtenerInfracciones()
|
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|