tabs equipo

This commit is contained in:
xXpuma99Xx 2022-08-04 18:11:48 -05:00
parent 53e1d30094
commit 3b169744bf
5 changed files with 139 additions and 102 deletions

View File

@ -57,7 +57,6 @@ export default {
operador: { type: Object, required: true },
equipo: { type: Object, required: true },
updateIsLoading: { type: Function, required: true },
obtenerMotivos: { type: Function, required: true },
updateEquipo: { type: Function, required: true },
},
methods: {
@ -76,9 +75,6 @@ export default {
.then((res) => {
this.updateEquipo(res.data)
this.updateIsLoading(false)
// this.obtenerPrestamos()
// this.obtenerReportes()
this.obtenerMotivos()
this.$router.push(`/equipos/buscar_equipo/${this.numeroInventario}`)
})
.catch((err) => {

View File

@ -4,37 +4,13 @@
: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>
<TabPrestamo :equipo="equipo" />
<b-tab-item label="Motivos">
<TablaMotivos
:data="dataMotivos"
:page="pageMotivos"
:total="totalMotivos"
:isLoading="isLoadingTable"
:onPageChange="onMotivosPageChange"
/>
</b-tab-item>
<TabMotivos :equipo="equipo" />
</b-tabs>
</section>
</template>
@ -42,11 +18,15 @@
<script>
import axios from 'axios'
import BuscarEquipo from '@/components/buscar/BuscarEquipo'
import TablaPrestamo from '@/components/tablas/TablaPrestamos'
import TablaMotivos from '@/components/operador/TablaMotivos'
import TabMotivos from '@/components/operador/TabMotivos'
import TabPrestamo from '@/components/operador/TabPrestamo'
export default {
components: { BuscarEquipo, TablaPrestamo, TablaMotivos },
components: {
BuscarEquipo,
TabMotivos,
TabPrestamo,
},
props: {
operador: { type: Object, required: true },
updateIsLoading: { type: Function, required: true },
@ -59,72 +39,12 @@ export default {
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>

View File

@ -0,0 +1,60 @@
<template>
<b-tab-item label="Motivos">
<TablaMotivos
:data="data"
:page="page"
:total="total"
:isLoading="isLoadingTable"
:onPageChange="onPageChange"
/>
</b-tab-item>
</template>
<script>
import axios from 'axios'
import TablaMotivos from '@/components/operador/TablaMotivos'
export default {
components: { TablaMotivos },
props: {
equipo: { type: Object, required: true, default: () => ({}) },
},
data() {
return {
data: [],
page: 1,
total: 0,
isLoadingTable: false,
}
},
methods: {
onPageChange(page) {
this.page = page
this.obtenerMotivos()
},
obtenerMotivos() {
this.isLoadingTable = true
axios
.get(
`${process.env.api}/motivo?pagina=${this.page}&id_equipo=${this.equipo.id_equipo}`,
this.$getToken.token()
)
.then((res) => {
this.data = res.data[0]
this.total = res.data[1]
this.isLoadingTable = false
})
.catch((err) => {
this.isLoadingTable = false
})
},
},
watch: {
equipo() {
this.obtenerMotivos()
},
},
}
</script>
<style></style>

View File

@ -0,0 +1,67 @@
<template>
<b-tab-item label="Historial">
<TablaPrestamo
:isLoadingTable="isLoadingTable"
:data="dataPrestamos"
:page="page"
:onPageChange="onPageChange"
:total="total"
:columnaNumeroCuenta="true"
:columnaIdPrestamo="true"
:columnaHoraRegreso="true"
:columnaCanceladoOperador="true"
:columnaCanceladoUsuario="true"
:columnaOperadores="true"
:filaActivo="true"
/>
</b-tab-item>
</template>
<script>
import axios from 'axios'
import TablaPrestamo from '@/components/tablas/TablaPrestamos'
export default {
components: { TablaPrestamo },
props: {
equipo: { type: Object, required: true, default: () => ({}) },
},
data() {
return {
dataPrestamos: [],
page: 1,
total: 0,
isLoadingTable: false,
}
},
methods: {
onPageChange(page) {
this.page = page
this.obtenerPrestamos()
},
obtenerPrestamos() {
this.isLoadingTable = true
axios
.get(
`${process.env.api}/prestamo/historial-equipo?pagina=${this.page}&id_equipo=${this.equipo.id_equipo}`,
this.$getToken.token()
)
.then((res) => {
this.dataPrestamos = res.data[0]
this.total = res.data[1]
this.isLoadingTable = false
})
.catch((err) => {
this.isLoadingTable = false
})
},
},
watch: {
equipo() {
this.obtenerPrestamos()
},
},
}
</script>
<style></style>

View File

@ -35,14 +35,14 @@
<SelectMarca
columnSize="is-3"
tipo="c"
tipo="e"
:idMarcaPadre="idMarca"
@marca-seleccionada="(nuevaMarca) => (idMarca = nuevaMarca)"
/>
<SelectModelo
columnSize="is-3"
tipo="c"
tipo="e"
:idModeloPadre="idModelo"
@modelo-seleccionado="(nuevoModelo) => (idModelo = nuevoModelo)"
/>
@ -72,13 +72,7 @@
<BotonBuscar
columnSize="is-3"
:buscar="obtenerEquipos"
:disabled="
institucion.id_institucion ||
operador.institucion.id_institucion ||
operador
? false
: true
"
:disabled="false"
/>
</div>