453 lines
15 KiB
Vue
453 lines
15 KiB
Vue
<template>
|
|
<div>
|
|
<h3 class="is-size-4 mb-3">
|
|
Préstamos{{ activos ? ' activos' : '' }}: {{ total }}
|
|
</h3>
|
|
|
|
<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="operador.tipoUsuario.id_tipo_usuario === 2"
|
|
/>
|
|
|
|
<SelectOperador
|
|
label="de entrega"
|
|
columnSize="is-3"
|
|
:deshabilitarOptVacia="false"
|
|
:idOperadorPadre="idOperadorEntrega"
|
|
@operador-seleccionado="
|
|
(nuevoOperador) => (idOperadorEntrega = nuevoOperador)
|
|
"
|
|
v-if="operador.tipoUsuario.id_tipo_usuario === 3"
|
|
/>
|
|
|
|
<SelectOperador
|
|
label="de regreso"
|
|
columnSize="is-3"
|
|
:deshabilitarOptVacia="false"
|
|
:idOperadorPadre="idOperadorRegreso"
|
|
@operador-seleccionado="
|
|
(nuevoOperador) => (idOperadorRegreso = nuevoOperador)
|
|
"
|
|
v-if="operador.tipoUsuario.id_tipo_usuario === 3"
|
|
/>
|
|
|
|
<SelectCarrera
|
|
:idInstitucion="
|
|
operador.institucion
|
|
? operador.institucion.id_institucion
|
|
: idInstitucion
|
|
"
|
|
:idInstitucionCarreraPadre="idInstitucionCarrera"
|
|
@institucion-carrera-seleccionada="
|
|
(nuevaInstitucionCarrera) =>
|
|
(idInstitucionCarrera = nuevaInstitucionCarrera)
|
|
"
|
|
:deshabilitarOptVacia="false"
|
|
/>
|
|
|
|
<SelectModulo
|
|
columnSize="is-3"
|
|
:deshabilitarOptVacia="false"
|
|
:idInstitucion="
|
|
operador.institucion
|
|
? operador.institucion.id_institucion
|
|
: idInstitucion
|
|
"
|
|
:idModuloPadre="idModulo"
|
|
:operador="operador"
|
|
@modulo-seleccionado="(nuevoModulo) => (idModulo = nuevoModulo)"
|
|
v-if="
|
|
mostrarSelectModulo ||
|
|
(mostrarSelectModuloA && operador.tipoUsuario.id_tipo_usuario < 4)
|
|
"
|
|
/>
|
|
|
|
<SelectTipoCarrito
|
|
columnSize="is-3"
|
|
:deshabilitarOptVacia="false"
|
|
:idTipoCarritoPadre="idTipoCarrito"
|
|
@tipo-carrito-seleccionado="
|
|
(nuevoTipoCarrito) => (idTipoCarrito = nuevoTipoCarrito)
|
|
"
|
|
/>
|
|
|
|
<InputCarrito
|
|
columnSize="is-3"
|
|
:carritoPadre="carrito"
|
|
:ejecutar="obtenerPrestamos"
|
|
@carrito="(carritoNuevo) => (carrito = carritoNuevo)"
|
|
/>
|
|
|
|
<InputEquipo
|
|
columnSize="is-3"
|
|
:equipoPadre="equipo"
|
|
:ejecutar="obtenerPrestamos"
|
|
@equipo="(equipoNuevo) => (equipo = equipoNuevo)"
|
|
/>
|
|
|
|
<InputIdPrestamo
|
|
columnSize="is-3"
|
|
:idPrestamoPadre="idPrestamo"
|
|
:ejecutar="obtenerPrestamos"
|
|
@id-prestamo="(idPrestamoNuevo) => (idPrestamo = idPrestamoNuevo)"
|
|
/>
|
|
|
|
<InputNumeroCuenta
|
|
columnSize="is-3"
|
|
:numeroCuentaPadre="numeroCuenta"
|
|
:ejecutar="obtenerPrestamos"
|
|
@numero-cuenta="
|
|
(numeroCuentaNuevo) => (numeroCuenta = numeroCuentaNuevo)
|
|
"
|
|
/>
|
|
|
|
<SelectTipoUsuario
|
|
columnSize="is-3"
|
|
:deshabilitarOptVacia="false"
|
|
:idTipoUsuarioPadre="idTipoUsuario"
|
|
@tipo-usuario-seleccionado="
|
|
(nuevoTipoUsuario) => (idTipoUsuario = nuevoTipoUsuario)
|
|
"
|
|
/>
|
|
|
|
<InputSwitch
|
|
columnSize="is-3"
|
|
label="Cancelado por usuario"
|
|
@opcion="(opcionNueva) => (canceladoUsuario = opcionNueva)"
|
|
v-if="mostrarInputSwitch"
|
|
/>
|
|
|
|
<InputSwitch
|
|
columnSize="is-3"
|
|
label="Cancelado por operador"
|
|
@opcion="(opcionNueva) => (canceladoOperador = opcionNueva)"
|
|
v-if="mostrarInputSwitch"
|
|
/>
|
|
|
|
<InputSwitch
|
|
columnSize="is-3"
|
|
label="Activos"
|
|
@opcion="(opcionNueva) => (activo = opcionNueva)"
|
|
v-if="mostrarInputSwitch"
|
|
/>
|
|
|
|
<InputFecha
|
|
columnSize="is-3"
|
|
label="Fecha inicio"
|
|
fechaPadre="fechaInicio"
|
|
:fechaMaxima="fechaMax"
|
|
:fechaMinima="fechaMinInicio"
|
|
@fecha="(fechaNueva) => (fechaInicio = fechaNueva)"
|
|
v-if="mostrarInputFecha"
|
|
/>
|
|
|
|
<InputFecha
|
|
columnSize="is-3"
|
|
label="Fecha fin"
|
|
fechaPadre="fechaFin"
|
|
:fechaMaxima="fechaMax"
|
|
:fechaMinima="fechaMinFin"
|
|
@fecha="(fechaNueva) => (fechaFin = fechaNueva)"
|
|
v-if="mostrarInputFecha && fechaInicio"
|
|
/>
|
|
|
|
<BotonBuscar
|
|
columnSize="is-3"
|
|
:buscar="obtenerPrestamos"
|
|
:disabled="false"
|
|
/>
|
|
|
|
<BotonDescargarCatalogo
|
|
campo="reporte"
|
|
nombreArchivo="reporte"
|
|
:obtener="obtenerReporte"
|
|
v-if="
|
|
(operador.tipoUsuario.id_tipo_usuario === 2 ||
|
|
operador.tipoUsuario.id_tipo_usuario === 3) &&
|
|
!activos
|
|
"
|
|
/>
|
|
</div>
|
|
|
|
<TablaPrestamos
|
|
:prestamos="prestamos"
|
|
:isLoadingTable="isLoadingTable"
|
|
:onPageChange="onPageChange"
|
|
:page="page"
|
|
:total="total"
|
|
:columnaBotonCancelar="columnaBotonCancelar"
|
|
:columnaHoraFin="columnaHoraFin"
|
|
:columnaHoraRegreso="columnaHoraRegreso"
|
|
:columnaModulo="
|
|
mostrarSelectModuloA ? (operador.id_modulo ? false : true) : true
|
|
"
|
|
:filaActivo="filaActivo"
|
|
:filaRetraso="filaRetraso"
|
|
:operador="operador"
|
|
columnaCarrito
|
|
columnaEquipo
|
|
columnaIdPrestamo
|
|
columnaNombre
|
|
columnaNumeroInventario
|
|
columnaTipo
|
|
columnaNumeroCuenta
|
|
/>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import axios from 'axios'
|
|
import moment from 'moment'
|
|
import BotonBuscar from '@/components/botones/BotonBuscar'
|
|
import BotonDescargarCatalogo from '@/components/botones/BotonDescargarCatalogo'
|
|
import InputCarrito from '@/components/inputs/InputCarrito'
|
|
import InputEquipo from '@/components/inputs/InputEquipo'
|
|
import InputIdPrestamo from '@/components/inputs/InputIdPrestamo'
|
|
import InputNumeroCuenta from '@/components/inputs/InputNumeroCuenta'
|
|
import SelectCarrera from '@/components/selects/SelectCarrera'
|
|
import SelectInstitucion from '@/components/selects/SelectInstitucion'
|
|
import SelectModulo from '@/components/selects/SelectModulo'
|
|
import SelectOperador from '@/components/selects/SelectOperador'
|
|
import SelectTipoCarrito from '@/components/selects/SelectTipoCarrito'
|
|
import SelectTipoUsuario from '@/components/selects/SelectTipoUsuario'
|
|
import InputSwitch from '@/components/inputs/InputSwitch'
|
|
import InputFecha from '@/components/inputs/InputFecha'
|
|
import TablaPrestamos from '@/components/tablas/TablaPrestamos'
|
|
|
|
export default {
|
|
components: {
|
|
BotonBuscar,
|
|
BotonDescargarCatalogo,
|
|
InputCarrito,
|
|
InputEquipo,
|
|
InputIdPrestamo,
|
|
InputNumeroCuenta,
|
|
SelectCarrera,
|
|
SelectInstitucion,
|
|
SelectModulo,
|
|
SelectOperador,
|
|
SelectTipoCarrito,
|
|
SelectTipoUsuario,
|
|
InputFecha,
|
|
InputSwitch,
|
|
TablaPrestamos,
|
|
},
|
|
props: {
|
|
activos: { type: Boolean, required: false, default: false },
|
|
actualizarTabla: { type: Boolean, required: false, default: false },
|
|
columnaBotonCancelar: { type: Boolean, required: false, default: false },
|
|
columnaHoraFin: { type: Boolean, required: false, default: false },
|
|
columnaHoraRegreso: { type: Boolean, required: false, default: false },
|
|
filaActivo: { type: Boolean, required: false, default: false },
|
|
filaRetraso: { type: Boolean, required: false, default: false },
|
|
mostrarSelectModulo: { type: Boolean, required: false, default: false },
|
|
mostrarSelectModuloA: { type: Boolean, required: false, default: false },
|
|
mostrarInputFecha: { type: Boolean, required: false, default: false },
|
|
mostrarInputSwitch: { type: Boolean, required: false, default: false },
|
|
operador: { type: Object, required: true, default: () => ({}) },
|
|
},
|
|
data() {
|
|
return {
|
|
prestamos: [],
|
|
isLoadingTable: false,
|
|
idInstitucion: 0,
|
|
idInstitucionCarrera: 0,
|
|
idModulo: 0,
|
|
idOperadorEntrega: 0,
|
|
idOperadorRegreso: 0,
|
|
idTipoCarrito: 0,
|
|
idTipoUsuario: 0,
|
|
page: 1,
|
|
total: 0,
|
|
canceladoUsuario: '',
|
|
canceladoOperador: '',
|
|
activo: '',
|
|
lastSearch: {},
|
|
fechaInicio: null,
|
|
fechaFin: null,
|
|
carrito: '',
|
|
equipo: '',
|
|
idPrestamo: '',
|
|
numeroCuenta: '',
|
|
}
|
|
},
|
|
methods: {
|
|
obtenerPrestamos() {
|
|
let data = ''
|
|
|
|
this.isLoadingTable = true
|
|
if (
|
|
this.canceladoOperador != this.lastSearch.canceladoOperador ||
|
|
this.canceladoUsuario != this.lastSearch.canceladoUsuario ||
|
|
this.carrito != this.lastSearch.carrito ||
|
|
this.equipo != this.lastSearch.equipo ||
|
|
this.fechaInicio != this.lastSearch.fechaInicio ||
|
|
this.fechaFin != this.lastSearch.fechaFin ||
|
|
this.idInstitucionCarrera != this.lastSearch.idInstitucionCarrera ||
|
|
this.idModulo != this.lastSearch.idModulo ||
|
|
this.idPrestamo != this.lastSearch.idPrestamo ||
|
|
this.idOperadorEntrega != this.lastSearch.idOperadorEntrega ||
|
|
this.idOperadorRegreso != this.lastSearch.idOperadorRegreso ||
|
|
this.idTipoCarrito != this.lastSearch.idTipoCarrito ||
|
|
this.idTipoUsuario != this.lastSearch.idTipoUsuario ||
|
|
this.numeroCuenta != this.lastSearch.numeroCuenta ||
|
|
(this.operador.institucion &&
|
|
this.operador.institucion.id_institucion !=
|
|
this.lastSearch.idInstitucion) ||
|
|
(this.operador.tipoUsuario.id_tipo_usuario === 2 &&
|
|
this.idInstitucion &&
|
|
this.idInstitucion != this.lastSearch.idInstitucion)
|
|
) {
|
|
this.page = 1
|
|
if (this.operador.institucion)
|
|
this.lastSearch.idInstitucion =
|
|
this.operador.institucion.id_institucion
|
|
else if (this.idInstitucion)
|
|
this.lastSearch.idInstitucion = this.idInstitucion
|
|
this.lastSearch.idInstitucionCarrera = this.idInstitucionCarrera
|
|
this.lastSearch.idModulo = this.idModulo
|
|
this.lastSearch.idTipoCarrito = this.idTipoCarrito
|
|
this.lastSearch.idTipoUsuario = this.idTipoUsuario
|
|
this.lastSearch.idOperadorEntrega = this.idOperadorEntrega
|
|
this.lastSearch.idOperadorRegreso = this.idOperadorRegreso
|
|
this.lastSearch.carrito = this.carrito
|
|
this.lastSearch.equipo = this.equipo
|
|
this.lastSearch.idPrestamo = this.idPrestamo
|
|
this.lastSearch.numeroCuenta = this.numeroCuenta
|
|
this.lastSearch.canceladoUsuario = this.canceladoUsuario
|
|
this.lastSearch.canceladoOperador = this.canceladoOperador
|
|
this.lastSearch.fechaInicio = this.fechaInicio
|
|
this.lastSearch.fechaFin = this.fechaFin
|
|
}
|
|
if (this.carrito) data += `&carrito=${this.carrito}`
|
|
if (this.equipo) data += `&equipo=${this.equipo}`
|
|
if (this.operador.institucion)
|
|
data += `&id_institucion=${this.operador.institucion.id_institucion}`
|
|
else if (this.idInstitucion)
|
|
data += `&id_institucion=${this.idInstitucion}`
|
|
if (this.idInstitucionCarrera)
|
|
data += `&id_institucion_carrera=${this.idInstitucionCarrera}`
|
|
if (this.idModulo) data += `&id_modulo=${this.idModulo}`
|
|
if (this.idTipoCarrito) data += `&id_tipo_carrito=${this.idTipoCarrito}`
|
|
if (this.idTipoUsuario) data += `&id_tipo_usuario=${this.idTipoUsuario}`
|
|
if (this.idOperadorEntrega)
|
|
data += `&id_operador_entrega=${this.idOperadorEntrega}`
|
|
if (this.idOperadorRegreso)
|
|
data += `&id_operador_regreso=${this.idOperadorRegreso}`
|
|
if (this.idPrestamo) data += `&id_prestamo=${this.idPrestamo}`
|
|
if (this.numeroCuenta) data += `&usuario=${this.numeroCuenta}`
|
|
if (this.fechaInicio)
|
|
data += `&fechaInicio=${moment(this.fechaInicio).format('YYYY-MM-DD')}`
|
|
if (this.fechaFin)
|
|
data += `&fechaFin=${moment(this.fechaFin).format('YYYY-MM-DD')}`
|
|
if (typeof this.canceladoUsuario === 'boolean')
|
|
data += `&cancelado_usuario=${this.canceladoUsuario}`
|
|
if (typeof this.canceladoOperador === 'boolean')
|
|
data += `&cancelado_operador=${this.canceladoOperador}`
|
|
if (typeof this.activo === 'boolean') data += `&activo=${this.activo}`
|
|
return axios
|
|
.get(
|
|
`${process.env.api}/prestamo/${
|
|
this.activos ? 'activos' : 'historial'
|
|
}?pagina=${this.page}${data}`,
|
|
this.$getToken.token()
|
|
)
|
|
.then((res) => {
|
|
this.prestamos = res.data[0]
|
|
this.total = res.data[1]
|
|
this.isLoadingTable = false
|
|
})
|
|
.catch((err) => {
|
|
this.isLoadingTable = false
|
|
this.$alertsGenericos.imprimirError(
|
|
this.$buefy,
|
|
this.$router,
|
|
err.response.data
|
|
)
|
|
})
|
|
},
|
|
obtenerReporte() {
|
|
let data = '?'
|
|
|
|
this.isLoadingTable = true
|
|
if (this.carrito) data += `&carrito=${this.carrito}`
|
|
if (this.equipo) data += `&equipo=${this.equipo}`
|
|
if (this.operador.institucion)
|
|
data += `&id_institucion=${this.operador.institucion.id_institucion}`
|
|
else if (this.idInstitucion)
|
|
data += `&id_institucion=${this.idInstitucion}`
|
|
if (this.idInstitucionCarrera)
|
|
data += `&id_institucion_carrera=${this.idInstitucionCarrera}`
|
|
if (this.idModulo) data += `&id_modulo=${this.idModulo}`
|
|
if (this.idTipoCarrito) data += `&id_tipo_carrito=${this.idTipoCarrito}`
|
|
if (this.idTipoUsuario) data += `&id_tipo_usuario=${this.idTipoUsuario}`
|
|
if (this.idOperadorEntrega)
|
|
data += `&id_operador_entrega=${this.idOperadorEntrega}`
|
|
if (this.idOperadorRegreso)
|
|
data += `&id_operador_regreso=${this.idOperadorRegreso}`
|
|
if (this.idPrestamo) data += `&id_prestamo=${this.idPrestamo}`
|
|
if (this.numeroCuenta) data += `&usuario=${this.numeroCuenta}`
|
|
if (this.fechaInicio)
|
|
data += `&fechaInicio=${moment(this.fechaInicio).format('YYYY-MM-DD')}`
|
|
if (this.fechaFin)
|
|
data += `&fechaFin=${moment(this.fechaFin).format('YYYY-MM-DD')}`
|
|
if (typeof this.canceladoUsuario === 'boolean')
|
|
data += `&cancelado_usuario=${this.canceladoUsuario}`
|
|
if (typeof this.canceladoOperador === 'boolean')
|
|
data += `&cancelado_operador=${this.canceladoOperador}`
|
|
if (typeof this.activo === 'boolean') data += `&activo=${this.activo}`
|
|
return axios
|
|
.get(
|
|
`${process.env.api}/prestamo/reporte${data}`,
|
|
this.$getToken.token()
|
|
)
|
|
.then((res) => {
|
|
this.isLoadingTable = false
|
|
return res.data
|
|
})
|
|
.catch((err) => {
|
|
this.isLoadingTable = false
|
|
this.$alertsGenericos.imprimirError(
|
|
this.$buefy,
|
|
this.$router,
|
|
err.response.data
|
|
)
|
|
})
|
|
},
|
|
onPageChange(page) {
|
|
this.page = page
|
|
this.obtenerPrestamos()
|
|
},
|
|
},
|
|
watch: {
|
|
actualizarTabla() {
|
|
this.obtenerPrestamos()
|
|
},
|
|
},
|
|
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.mostrarSelectModuloA && this.operador.id_modulo)
|
|
this.idModulo = this.operador.id_modulo
|
|
this.obtenerPrestamos()
|
|
},
|
|
}
|
|
</script>
|