pcpuma_unam_operador/components/tablas/TablaHoraExcepcion.vue
2023-01-09 11:29:31 -06:00

77 lines
1.9 KiB
Vue

<template>
<b-table
class="pb-6"
:data="horasExcepcion"
:loading="isLoadingTable"
hoverable
striped
>
<b-table-column
field="horaInicio"
label="Hora inicio"
v-slot="props"
centered
>
<p>{{ props.row.hora_inicio }}</p>
</b-table-column>
<b-table-column field="horaFin" label="Hora fin" v-slot="props" centered>
<p>{{ props.row.hora_fin }}</p>
</b-table-column>
<b-table-column field="eliminar" label="Eliminar" v-slot="props" centered>
<BotonEliminar
:eliminar="eliminarHoraExcepcion"
:row="props.row"
:msjWarning="`¿Estás segur@ de querer eliminar esta hora excepción?`"
/>
</b-table-column>
</b-table>
</template>
<script>
import axios from 'axios'
import BotonEliminar from '@/components/botones/BotonEliminar'
export default {
components: { BotonEliminar },
props: {
horasExcepcion: { type: Array, required: true, default: () => [] },
isLoadingTable: { type: Boolean, required: true, default: false },
obtenerHorasExcepcion: {
type: Function,
required: true,
default: () => {},
},
updateIsLoading: { type: Function, required: true, default: () => {} },
},
methods: {
eliminarHoraExcepcion(horaExcepcion) {
const data = {
id_hora_excepcion: horaExcepcion.id_hora_excepcion,
}
this.updateIsLoading(true)
return axios
.delete(
`${process.env.api}/hora-excepcion`,
this.$getToken.tokenDelete(data)
)
.then((res) => {
this.obtenerHorasExcepcion()
this.updateIsLoading(false)
this.$alertsGenericos.imprimirMensaje(this.$buefy, res.data.message)
})
.catch((err) => {
this.updateIsLoading(false)
this.$alertsGenericos.imprimirError(
this.$buefy,
this.$router,
err.response.data
)
})
},
},
}
</script>