pcpuma_unam_operador/components/tablas/TablaDias.vue

106 lines
2.8 KiB
Vue
Raw Normal View History

2022-07-25 12:49:16 +00:00
<template>
<b-table
class="mb-6"
2022-07-26 16:49:26 +00:00
:data="dias"
2022-07-25 12:49:16 +00:00
:loading="isLoadingTable"
2022-07-26 16:49:26 +00:00
detailed
2022-07-25 12:49:16 +00:00
hoverable
2022-07-26 16:49:26 +00:00
show-detail-icon
2022-07-25 12:49:16 +00:00
striped
>
2022-07-26 16:49:26 +00:00
<b-table-column field="dia" label="Día" v-slot="props" centered>
2022-07-25 22:59:36 +00:00
<p>{{ props.row.dia.dia }}</p>
</b-table-column>
<b-table-column
field="hora_inicio"
label="Hora inicio del servicio"
v-slot="props"
2022-07-26 16:49:26 +00:00
centered
2022-07-25 22:59:36 +00:00
>
<p>{{ props.row.hora_inicio }}</p>
</b-table-column>
<b-table-column
field="hora_fin"
label="Hora fin del servicio"
v-slot="props"
2022-07-26 16:49:26 +00:00
centered
2022-07-25 22:59:36 +00:00
>
<p>{{ props.row.hora_fin }}</p>
</b-table-column>
2022-07-26 16:49:26 +00:00
<b-table-column field="editar" label="Editar horas" v-slot="props" centered>
2022-07-25 22:59:36 +00:00
<b-button type="is-primary" @click="editarHora(props.row)">
<b-icon icon="pencil" size="is-small" />
</b-button>
</b-table-column>
<b-table-column field="activo" label="Status" v-slot="props" centered>
<BotonDesactivar
:activarDesactivar="activarDesactivar"
2022-07-26 16:49:26 +00:00
:row="props.row"
2022-07-25 22:59:36 +00:00
:msjWarning="`¿Estás segur@ de querer ${
2022-07-26 16:49:26 +00:00
props.row.activo || props.row.mostrar ? 'desactivar' : 'activar'
2022-07-25 22:59:36 +00:00
} este tipo de carrito?`"
/>
</b-table-column>
2022-07-26 16:49:26 +00:00
<template #detail="props">
<HorasExcepcionDia
:institucionDia="props.row"
:horasExcepcion="props.row.horasExcepcion"
:isLoadingTable="isLoadingTable"
:obtenerDias="obtenerDias"
:updateIsLoading="updateIsLoading"
/>
</template>
2022-07-25 12:49:16 +00:00
</b-table>
</template>
<script>
2022-07-26 16:49:26 +00:00
import axios from 'axios'
2022-07-25 22:59:36 +00:00
import BotonDesactivar from '@/components/botones/BotonDesactivar'
2022-07-26 16:49:26 +00:00
import HorasExcepcionDia from '@/components/tablas/HorasExcepcionDia'
2022-07-25 22:59:36 +00:00
2022-07-25 12:49:16 +00:00
export default {
2022-07-26 16:49:26 +00:00
components: { BotonDesactivar, HorasExcepcionDia },
2022-07-25 12:49:16 +00:00
props: {
2022-07-26 16:49:26 +00:00
dias: { type: Array, required: true, default: () => [] },
2022-07-25 12:49:16 +00:00
isLoadingTable: { type: Boolean, required: true, default: false },
2022-07-26 16:49:26 +00:00
obtenerDias: { type: Function, required: true },
updateIsLoading: { type: Function, required: true },
2022-07-25 12:49:16 +00:00
},
data() {
return {}
},
2022-07-26 16:49:26 +00:00
methods: {
activarDesactivar(institucionDia) {
const data = {
id_institucion_dia: institucionDia.id_institucion_dia,
activo: !institucionDia.activo,
}
this.updateIsLoading(true)
axios
.put(
`${process.env.api}/institucion-dia/`,
data,
this.$getToken.token()
)
.then((res) => {
this.obtenerDias()
this.updateIsLoading(false)
this.$alertsGenericos.imprimirMensaje(this.$buefy, res.data.message)
})
.catch((err) => {
this.updateIsLoading(false)
this.$alertsGenericos.imprimirError(this.$buefy, err.response.data)
})
},
},
2022-07-25 12:49:16 +00:00
watch: {},
created() {},
}
</script>