pcpuma_unam_operador/components/admin/HorasExcepcion.vue

115 lines
3.0 KiB
Vue
Raw Normal View History

2022-07-06 06:57:55 +00:00
<template>
<div>
<div class="has-text-centered">
<p class="subtitle is-3">Hora Excepción</p>
2022-07-06 19:52:10 +00:00
<b-button type="is-primary" @click="mostrar = true" v-if="!mostrar"
>Agregar</b-button
>
2022-07-06 06:57:55 +00:00
</div>
2022-07-22 03:54:26 +00:00
<Reloj
2022-07-06 06:57:55 +00:00
:diaSeleccion="horasExcepcion"
2022-07-06 19:52:10 +00:00
:crearHoraExcepcion="crearHoraExcepcion"
2022-07-06 06:57:55 +00:00
tipo="crearHoraExcepcion"
v-if="mostrar"
/>
<b-table :data="horasExcepcion.horasExcepcion">
<b-table-column
field="horaInicio"
label="Hora Inicio"
centered
v-slot="props"
>
{{ props.row.hora_inicio }}
</b-table-column>
<b-table-column field="horaFin" label="Hora Fin" centered v-slot="props">
{{ props.row.hora_fin }}
</b-table-column>
2022-07-12 21:03:05 +00:00
<b-table-column field="eliminar" label="Eliminar" centered v-slot="props">
<b-button
type="is-danger"
@click="
;(id_hora_excepcion = props.row.id_hora_excepcion),
$alertsGenericos.imprimirWarning(
$buefy,
'¿Esta segur@ de querer eliminar esta hora excepció?',
eliminarHoraExcepcion
)
"
>
Eliminar
</b-button>
</b-table-column>
2022-07-06 06:57:55 +00:00
</b-table>
</div>
</template>
<script>
import axios from 'axios'
2022-07-22 03:54:26 +00:00
import Reloj from '@/components/admin/Reloj'
2022-07-06 06:57:55 +00:00
export default {
2022-07-22 03:54:26 +00:00
components: { Reloj },
2022-07-06 06:57:55 +00:00
props: {
horasExcepcion: { type: Object, require: true },
2022-07-06 19:52:10 +00:00
updateIsLoading: { type: Function, required: true },
actualizarTabla: { type: Boolean, required: true },
updateActualizarTabla: { type: Function, required: true },
2022-07-06 06:57:55 +00:00
},
data() {
return {
hora_inicio: new Date(),
hora_fin: new Date(),
mostrar: false,
2022-07-12 21:03:05 +00:00
id_hora_excepcion: 0,
2022-07-06 06:57:55 +00:00
}
},
methods: {
crearHoraExcepcion(id_institucion_dia, hora_inicio, hora_fin) {
const data = {
id_institucion_dia,
hora_inicio,
hora_fin,
}
2022-07-06 19:52:10 +00:00
// this.updateIsLoading(true)
2022-07-06 06:57:55 +00:00
axios
2022-07-19 16:41:33 +00:00
.post(`${process.env.api}/hora-excepcion`, data, this.$getToken.token())
2022-07-06 06:57:55 +00:00
.then((res) => {
2022-07-11 14:15:10 +00:00
this.$alertsGenericos.imprimirMensaje(this.$buefy, res.data.message)
2022-07-06 06:57:55 +00:00
this.updateActualizarTabla(true)
})
.catch((err) => {
this.error = 'is-danger'
2022-07-11 14:15:10 +00:00
this.$alertsGenericos.imprimirError(this.$buefy, err.response.data)
2022-07-06 06:57:55 +00:00
})
},
2022-07-12 21:03:05 +00:00
eliminarHoraExcepcion() {
const data = {
id_hora_excepcion: this.id_hora_excepcion,
}
2022-07-13 20:40:58 +00:00
2022-07-12 21:03:05 +00:00
axios
2022-07-19 16:41:33 +00:00
.delete(
`${process.env.api}/hora-excepcion`,
2022-07-22 03:17:53 +00:00
this.$getToken.tokenDelete(data)
2022-07-19 16:41:33 +00:00
)
2022-07-12 21:03:05 +00:00
.then((res) => {
this.$alertsGenericos.imprimirMensaje(
this.$buefy,
'Se ah eliminado correctamente la hora excepción'
)
this.updateActualizarTabla(true)
})
.catch((err) => {
this.error = 'is-danger'
this.$alertsGenericos.imprimirError(this.$buefy, err.response.data)
})
},
2022-07-06 06:57:55 +00:00
},
}
</script>