2022-07-01 05:01:54 +00:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<b-table :data="data">
|
|
|
|
<b-table-column
|
|
|
|
field="infraccion"
|
|
|
|
label="Infracción"
|
|
|
|
v-slot="props"
|
|
|
|
centered
|
|
|
|
>
|
|
|
|
{{ props.row.infraccion.infraccion }}
|
|
|
|
</b-table-column>
|
|
|
|
|
|
|
|
<b-table-column
|
|
|
|
field="diasMulta"
|
|
|
|
label="Días de multa"
|
2022-07-01 05:06:24 +00:00
|
|
|
width="300"
|
2022-07-01 05:01:54 +00:00
|
|
|
v-slot="props"
|
|
|
|
centered
|
|
|
|
>
|
|
|
|
<p>
|
|
|
|
<b-input
|
|
|
|
type="number"
|
|
|
|
v-model="props.row.dias_multa"
|
|
|
|
:disabled="
|
|
|
|
idInstitucionInfraccion != props.row.id_institucion_infraccion
|
|
|
|
"
|
|
|
|
/>
|
|
|
|
</p>
|
|
|
|
</b-table-column>
|
|
|
|
|
|
|
|
<b-table-column field="editar" label="Editar" v-slot="props" centered
|
|
|
|
><b-button
|
|
|
|
type="is-primary"
|
|
|
|
@click="habilitarGuardado(props.row.id_institucion_infraccion)"
|
|
|
|
v-if="idInstitucionInfraccion != props.row.id_institucion_infraccion"
|
|
|
|
>
|
|
|
|
<b-icon icon="pencil" size="is-small" />
|
|
|
|
</b-button>
|
|
|
|
|
|
|
|
<b-button
|
|
|
|
type="is-success"
|
|
|
|
@click="
|
2022-07-11 14:15:10 +00:00
|
|
|
$alertsGenericos.imprimirWarning(
|
|
|
|
$buefy,
|
2022-07-01 05:01:54 +00:00
|
|
|
'¿Estás seguro de querer actualizar estos datos?',
|
|
|
|
editarDiasMulta
|
|
|
|
)
|
|
|
|
"
|
|
|
|
v-if="idInstitucionInfraccion === props.row.id_institucion_infraccion"
|
|
|
|
>
|
|
|
|
Guardar
|
|
|
|
</b-button>
|
|
|
|
</b-table-column>
|
|
|
|
</b-table>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import axios from 'axios'
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
admin: { type: Object, require: true },
|
|
|
|
updateIsLoading: { type: Function, required: true },
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
data: [],
|
|
|
|
idInstitucionInfraccion: 0,
|
|
|
|
diasMulta: 0,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
habilitarGuardado(id_institucion_infraccion) {
|
|
|
|
this.idInstitucionInfraccion = id_institucion_infraccion
|
|
|
|
},
|
|
|
|
editarDiasMulta() {
|
|
|
|
for (let i = 0; i < this.data.length; i++) {
|
|
|
|
if (
|
|
|
|
this.data[i].id_institucion_infraccion ===
|
|
|
|
this.idInstitucionInfraccion
|
|
|
|
)
|
|
|
|
this.diasMulta = this.data[i].dias_multa
|
|
|
|
}
|
|
|
|
|
|
|
|
const data = {
|
|
|
|
id_institucion_infraccion: this.idInstitucionInfraccion,
|
|
|
|
dias_multa: Number(this.diasMulta),
|
|
|
|
}
|
2022-07-11 14:15:10 +00:00
|
|
|
|
2022-07-01 05:01:54 +00:00
|
|
|
this.updateIsLoading(true)
|
|
|
|
axios
|
|
|
|
.put(`${process.env.api}/institucion-infraccion/`, data)
|
|
|
|
.then((res) => {
|
2022-07-11 14:15:10 +00:00
|
|
|
this.$alertsGenericos.imprimirMensaje(this.$buefy, res.data.message)
|
2022-07-01 05:01:54 +00:00
|
|
|
this.obtenerCatalogoInfracciones()
|
|
|
|
this.idInstitucionInfraccion = 0
|
|
|
|
this.updateIsLoading(false)
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
2022-07-11 14:15:10 +00:00
|
|
|
this.$alertsGenericos.imprimirError(this.$buefy, err.response.data)
|
2022-07-01 05:01:54 +00:00
|
|
|
this.updateIsLoading(false)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
obtenerCatalogoInfracciones() {
|
|
|
|
this.updateIsLoading(true)
|
|
|
|
axios
|
|
|
|
.get(
|
|
|
|
`${process.env.api}/institucion-infraccion/infracciones?id_institucion=${this.admin.institucion.id_institucion}`
|
|
|
|
)
|
|
|
|
.then((res) => {
|
|
|
|
this.data = res.data
|
|
|
|
this.updateIsLoading(false)
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
this.updateIsLoading(false)
|
2022-07-11 14:15:10 +00:00
|
|
|
this.$alertsGenericos.imprimirError(this.$buefy, err.response.data)
|
2022-07-01 05:01:54 +00:00
|
|
|
})
|
|
|
|
},
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.obtenerCatalogoInfracciones()
|
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|