162 lines
4.1 KiB
Vue
162 lines
4.1 KiB
Vue
<template>
|
|
<b-table
|
|
class="pb-6"
|
|
:data="dias"
|
|
:loading="isLoadingTable"
|
|
:opened-detailed="open"
|
|
detail-key="id_institucion_dia"
|
|
detailed
|
|
hoverable
|
|
:show-detail-icon="!mostrar"
|
|
striped
|
|
>
|
|
<b-table-column
|
|
field="props.row.dia.dia"
|
|
label="Día"
|
|
v-slot="props"
|
|
centered
|
|
>
|
|
<p>{{ props.row.dia.dia }}</p>
|
|
</b-table-column>
|
|
|
|
<b-table-column
|
|
field="hora_inicio"
|
|
label="Hora inicio del servicio"
|
|
v-slot="props"
|
|
centered
|
|
>
|
|
<p>{{ props.row.hora_inicio }}</p>
|
|
</b-table-column>
|
|
|
|
<b-table-column
|
|
field="hora_fin"
|
|
label="Hora fin del servicio"
|
|
v-slot="props"
|
|
centered
|
|
>
|
|
<p>{{ props.row.hora_fin }}</p>
|
|
</b-table-column>
|
|
|
|
<b-table-column
|
|
field="hora_extra"
|
|
label="Hora extra del servicio"
|
|
v-slot="props"
|
|
centered
|
|
>
|
|
<p>{{ props.row.hora_extra }}</p>
|
|
</b-table-column>
|
|
|
|
<b-table-column
|
|
field="hora_tope"
|
|
label="Hora tope del servicio"
|
|
v-slot="props"
|
|
centered
|
|
>
|
|
<p>{{ props.row.hora_tope }}</p>
|
|
</b-table-column>
|
|
|
|
<b-table-column field="editar" label="Editar horas" v-slot="props" centered>
|
|
<BotonEditar :editar="editar" :row="props.row" />
|
|
</b-table-column>
|
|
|
|
<b-table-column field="activo" label="Status" v-slot="props" centered>
|
|
<BotonDesactivar
|
|
:activarDesactivar="activarDesactivar"
|
|
:row="props.row"
|
|
:msjWarning="`¿Estás segur@ de querer ${
|
|
props.row.activo || props.row.mostrar ? 'desactivar' : 'activar'
|
|
} este día?`"
|
|
/>
|
|
</b-table-column>
|
|
|
|
<template #detail="props">
|
|
<HorasExcepcionDia
|
|
:horasExcepcion="props.row.horasExcepcion"
|
|
:editar="editar"
|
|
:updateIsLoading="updateIsLoading"
|
|
:institucionDia="props.row"
|
|
v-if="!mostrar"
|
|
/>
|
|
|
|
<RelojesInstitucionDia
|
|
:editar="editar"
|
|
:obtenerDias="obtenerDias"
|
|
:institucionDia="props.row"
|
|
:updateIsLoading="updateIsLoading"
|
|
v-if="mostrar"
|
|
/>
|
|
</template>
|
|
</b-table>
|
|
</template>
|
|
|
|
<script>
|
|
import axios from 'axios'
|
|
import BotonDesactivar from '@/components/botones/BotonDesactivar'
|
|
import BotonEditar from '@/components/botones/BotonEditar'
|
|
import HorasExcepcionDia from '@/components/tablas/HorasExcepcionDia'
|
|
import RelojesInstitucionDia from '@/components/admin/RelojesInstitucionDia'
|
|
|
|
export default {
|
|
components: {
|
|
BotonEditar,
|
|
BotonDesactivar,
|
|
HorasExcepcionDia,
|
|
RelojesInstitucionDia,
|
|
},
|
|
props: {
|
|
dias: { type: Array, required: true, default: () => [] },
|
|
isLoadingTable: { type: Boolean, required: true, default: false },
|
|
obtenerDias: { type: Function, required: true },
|
|
updateIsLoading: { type: Function, required: true },
|
|
},
|
|
data() {
|
|
return { mostrar: false, open: [], openAux: [] }
|
|
},
|
|
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,
|
|
this.$router,
|
|
err.response.data
|
|
)
|
|
})
|
|
},
|
|
editar(institucionDia) {
|
|
const index = this.open.findIndex(
|
|
(element) => element === institucionDia.id_institucion_dia
|
|
)
|
|
|
|
if (index < 0) {
|
|
this.open.push(institucionDia.id_institucion_dia)
|
|
this.openAux.push(institucionDia.id_institucion_dia)
|
|
} else {
|
|
this.open.splice(index, 1)
|
|
this.openAux.splice(index, 1)
|
|
}
|
|
if (this.open.length > this.openAux.length) this.open = [...this.openAux]
|
|
if (this.openAux.length > 0) this.mostrar = true
|
|
else this.mostrar = false
|
|
},
|
|
},
|
|
}
|
|
</script>
|