pcpuma_unam_operador/components/operador/Equipo.vue
2022-07-28 18:51:50 -05:00

133 lines
3.4 KiB
Vue

<template>
<section class="mb-5">
<BuscarEquipo
:operador="operador"
:equipo="equipo"
:updateIsLoading="updateIsLoading"
:obtenerMotivos="obtenerMotivos"
:updateEquipo="updateEquipo"
/>
<b-tabs>
<b-tab-item label="Historial">
<TablaPrestamo
:isLoadingTable="isLoadingTable"
:data="dataPrestamos"
:page="pagePrestamos"
:onPageChange="onPrestamosPageChange"
:total="totalPrestamos"
:columnaNumeroCuenta="true"
:columnaIdPrestamo="true"
:columnaHoraRegreso="true"
:columnaCanceladoOperador="true"
:columnaCanceladoUsuario="true"
:columnaOperadores="true"
:filaActivo="true"
/>
</b-tab-item>
<b-tab-item label="Motivos">
<TablaMotivos
:data="dataMotivos"
:page="pageMotivos"
:total="totalMotivos"
:isLoading="isLoadingTable"
:onPageChange="onMotivosPageChange"
/>
</b-tab-item>
</b-tabs>
</section>
</template>
<script>
import axios from 'axios'
import BuscarEquipo from '@/components/buscar/BuscarEquipo'
import TablaPrestamo from '@/components/tablas/TablaPrestamos'
import TablaMotivos from '@/components/operador/TablaMotivos'
export default {
components: { BuscarEquipo, TablaPrestamo, TablaMotivos },
props: {
operador: { type: Object, required: true },
updateIsLoading: { type: Function, required: true },
},
data() {
return {
equipo: {
carrito: { modulo: {}, tipoCarrito: {} },
programas: [],
status: {},
tiposEntradas: [],
},
dataPrestamos: [],
pagePrestamos: 1,
totalPrestamos: 0,
dataMotivos: [],
pageMotivos: 1,
totalMotivos: 0,
isLoadingTable: false,
}
},
methods: {
onPrestamosPageChange(page) {
this.pagePrestamos = page
this.obtenerPrestamos()
},
onReportesPageChange(page) {
this.pageReportes = page
this.obtenerReportes()
},
onMotivosPageChange(page) {
this.pageMotivos = page
this.obtenerMotivos()
},
updateEquipo(valorObject) {
this.equipo = valorObject
},
obtenerPrestamos() {
this.isLoadingTable = true
axios
.get(
`${process.env.api}/prestamo/historial-equipo?pagina=${this.pagePrestamos}&id_equipo=${this.equipo.id_equipo}`,
this.$getToken.token()
)
.then((res) => {
this.dataPrestamos = res.data[0]
this.totalPrestamos = res.data[1]
this.isLoadingTable = false
})
.catch((err) => {
this.isLoadingTable = false
this.$alertsGenericos.imprimirError(this.$buefy, err.response.data)
})
},
obtenerMotivos() {
this.isLoadingTable = true
axios
.get(
`${process.env.api}/motivo?pagina=${this.pageMotivos}&id_equipo=${this.equipo.id_equipo}`,
this.$getToken.token()
)
.then((res) => {
this.dataMotivos = res.data[0]
this.totalMotivos = res.data[1]
this.isLoadingTable = false
})
.catch((err) => {
this.isLoadingTable = false
this.$alertsGenericos.imprimirError(this.$buefy, err.response.data)
})
},
},
watch: {
equipo() {
this.obtenerPrestamos()
this.obtenerMotivos()
},
},
}
</script>
<style></style>