152 lines
4.3 KiB
Vue
152 lines
4.3 KiB
Vue
<template>
|
|
<div>
|
|
<div class="columns is-multiline mb-5 is-align-items-flex-end">
|
|
<SelectInstitucion
|
|
columnSize="is-3"
|
|
:deshabilitarOptVacia="false"
|
|
:idInstitucionPadre="idInstitucion"
|
|
@institucion-seleccionada="
|
|
(nuevaInstitucion) => (idInstitucion = nuevaInstitucion)
|
|
"
|
|
v-if="admin.tipoUsuario.id_tipo_usuario === 2"
|
|
/>
|
|
|
|
<InputFecha
|
|
columnSize="is-3"
|
|
label="Fecha inicio"
|
|
:fechaPadre="fechaInicio"
|
|
:fechaMaxima="fechaMax"
|
|
:fechaMinima="fechaMinInicio"
|
|
@fecha="(fechaNueva) => (fechaInicio = fechaNueva)"
|
|
/>
|
|
|
|
<InputFecha
|
|
columnSize="is-3"
|
|
label="Fecha fin"
|
|
:fechaPadre="fechaFin"
|
|
:fechaMaxima="fechaMax"
|
|
:fechaMinima="fechaMinFin"
|
|
@fecha="(fechaNueva) => (fechaFin = fechaNueva)"
|
|
/>
|
|
|
|
<BotonBuscar
|
|
columnSize="is-3"
|
|
:buscar="obtenerMotivos"
|
|
:disabled="false"
|
|
/>
|
|
</div>
|
|
|
|
<BarraModulos :data="data" :labels="instituciones" />
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import axios from 'axios'
|
|
import moment from 'moment'
|
|
import BarraModulos from '@/components/admin/graficas/BarraModulos'
|
|
import BotonBuscar from '@/components/botones/BotonBuscar'
|
|
import SelectCarrera from '@/components/selects/SelectCarrera'
|
|
import SelectInstitucion from '@/components/selects/SelectInstitucion'
|
|
import SelectModulo from '@/components/selects/SelectModulo'
|
|
import SelectTipoCarrito from '@/components/selects/SelectTipoCarrito'
|
|
import SelectTipoUsuario from '@/components/selects/SelectTipoUsuario'
|
|
import InputFecha from '@/components/inputs/InputFecha'
|
|
|
|
export default {
|
|
components: {
|
|
BarraModulos,
|
|
BotonBuscar,
|
|
InputFecha,
|
|
SelectCarrera,
|
|
SelectInstitucion,
|
|
SelectModulo,
|
|
SelectTipoCarrito,
|
|
SelectTipoUsuario,
|
|
},
|
|
props: {
|
|
updateIsLoading: { type: Function, required: false, default: () => {} },
|
|
admin: { type: Object, required: true, default: () => ({}) },
|
|
},
|
|
data() {
|
|
return {
|
|
data: [],
|
|
instituciones: [],
|
|
idInstitucion: 0,
|
|
fechaFin: moment().toDate(),
|
|
fechaInicio: null,
|
|
hoy: moment(),
|
|
}
|
|
},
|
|
methods: {
|
|
obtenerMotivos() {
|
|
let query = '?'
|
|
|
|
this.updateIsLoading(true)
|
|
this.data = []
|
|
this.instituciones = []
|
|
if (this.admin.institucion)
|
|
query += `&id_institucion=${this.admin.institucion.id_institucion}`
|
|
else if (this.idInstitucion)
|
|
query += `&id_institucion=${this.idInstitucion}`
|
|
if (this.fechaInicio)
|
|
query += `&fechaInicio=${moment(this.fechaInicio).format('YYYY-MM-DD')}`
|
|
if (this.fechaFin)
|
|
query += `&fechaFin=${moment(this.fechaFin).format('YYYY-MM-DD')}`
|
|
return axios
|
|
.get(
|
|
`${process.env.api}/modulo-motivo/reporte-actividad-especial${query}`,
|
|
this.$getToken.token()
|
|
)
|
|
.then((res) => {
|
|
const motivos = []
|
|
const ins = res.data.map((value) => {
|
|
return value.modulo.institucion.institucion
|
|
})
|
|
|
|
this.instituciones = ins.filter((value, index, self) => {
|
|
if (self.indexOf(value) === index) {
|
|
motivos.push([res.data[index]])
|
|
return true
|
|
}
|
|
motivos[motivos.length - 1].push(res.data[index])
|
|
return false
|
|
})
|
|
for (let i = 0; i < this.instituciones.length; i++)
|
|
this.data.push({
|
|
motivos: motivos[i],
|
|
institucion: this.instituciones[i],
|
|
})
|
|
this.updateIsLoading(false)
|
|
})
|
|
.catch((err) => {
|
|
this.updateIsLoading(false)
|
|
this.$alertsGenericos.imprimirError(
|
|
this.$buefy,
|
|
this.$router,
|
|
err.response.data
|
|
)
|
|
})
|
|
},
|
|
},
|
|
computed: {
|
|
fechaMax() {
|
|
return moment().toDate()
|
|
},
|
|
fechaMinInicio() {
|
|
return moment('2022-08-15').toDate()
|
|
},
|
|
fechaMinFin() {
|
|
let fechaMinFin = moment(this.fechaInicio)
|
|
|
|
return fechaMinFin.isValid() ? fechaMinFin.toDate() : moment().toDate()
|
|
},
|
|
},
|
|
created() {
|
|
if (this.hoy < moment(`${this.hoy.year()}-07-01`))
|
|
this.fechaInicio = moment(`${this.hoy.year()}-01-01`).toDate()
|
|
else this.fechaInicio = moment(`${this.hoy.year()}-07-01`).toDate()
|
|
this.obtenerMotivos()
|
|
},
|
|
}
|
|
</script>
|