187 lines
4.7 KiB
Vue
187 lines
4.7 KiB
Vue
![]() |
<template>
|
||
|
<b-table
|
||
|
:data="data"
|
||
|
:loading="isLoadingTable"
|
||
|
class="mb-6"
|
||
|
show-detail-icon
|
||
|
paginated
|
||
|
detailed
|
||
|
>
|
||
|
<b-table-column field="carrito" label="Carrito" v-slot="props" centered>
|
||
|
<span>{{ props.row.carrito }}</span>
|
||
|
</b-table-column>
|
||
|
|
||
|
<b-table-column field="modulo" label="Módulo" v-slot="props" centered>
|
||
|
<span>{{ props.row.modulo.modulo }}</span>
|
||
|
</b-table-column>
|
||
|
|
||
|
<b-table-column field="tipo" label="Tipo" v-slot="props" centered>
|
||
|
<span>{{ props.row.tipoCarrito.tipo_carrito }}</span>
|
||
|
</b-table-column>
|
||
|
|
||
|
<b-table-column field="activo" label="Activo" v-slot="props" centered>
|
||
|
<BotonDesactivar
|
||
|
:admin="operador"
|
||
|
:data="props.row"
|
||
|
tipo="carrito"
|
||
|
:cambiarStatus="cambiarStatus"
|
||
|
:imprimirWarning="imprimirWarning"
|
||
|
/>
|
||
|
</b-table-column>
|
||
|
|
||
|
<template #detail="equipos">
|
||
|
<b-table
|
||
|
:data="equipos.row.Equipos"
|
||
|
:per-page="15"
|
||
|
:selected.sync="selectedEquipo"
|
||
|
:row-class="(row, index) => 'pointer'"
|
||
|
class="mb-6"
|
||
|
hoverable
|
||
|
striped
|
||
|
paginated
|
||
|
>
|
||
|
<b-table-column field="equipo" label="Equipo" v-slot="props" centered>
|
||
|
<span>
|
||
|
{{ props.row.equipo }}
|
||
|
</span>
|
||
|
</b-table-column>
|
||
|
|
||
|
<b-table-column
|
||
|
field="numeroInventario"
|
||
|
label="Número de inventario"
|
||
|
v-slot="props"
|
||
|
centered
|
||
|
>
|
||
|
<span>
|
||
|
{{ props.row.numero_inventario }}
|
||
|
</span>
|
||
|
</b-table-column>
|
||
|
|
||
|
<!-- <b-table-column
|
||
|
field="numeroSerie"
|
||
|
label="Número de serie"
|
||
|
v-slot="props"
|
||
|
centered
|
||
|
>
|
||
|
<span>
|
||
|
{{ props.row.numero_serie }}
|
||
|
</span>
|
||
|
</b-table-column> -->
|
||
|
|
||
|
<b-table-column field="status" label="Status" v-slot="props" centered>
|
||
|
<span
|
||
|
class="is-size-6 tag"
|
||
|
:class="choooseTag(props.row.status.id_status)"
|
||
|
>
|
||
|
{{ props.row.status.status }}
|
||
|
</span>
|
||
|
</b-table-column>
|
||
|
</b-table>
|
||
|
</template>
|
||
|
</b-table>
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
|
import axios from 'axios'
|
||
|
import BotonDesactivar from '@/components/operador/BotonDesactivar'
|
||
|
|
||
|
export default {
|
||
|
components: { BotonDesactivar },
|
||
|
props: {
|
||
|
operador: { type: Object, required: true },
|
||
|
imprimirError: { type: Function, required: true },
|
||
|
imprimirMensaje: { type: Function, required: true },
|
||
|
imprimirWarning: { type: Function, required: true },
|
||
|
},
|
||
|
data() {
|
||
|
return {
|
||
|
isLoadingTable: false,
|
||
|
data: [],
|
||
|
equipos: [],
|
||
|
selectedEquipo: {},
|
||
|
}
|
||
|
},
|
||
|
methods: {
|
||
|
choooseTag(idStatus) {
|
||
|
const style = {
|
||
|
1: 'is-info',
|
||
|
2: 'is-link',
|
||
|
3: 'is-primary',
|
||
|
4: 'is-success',
|
||
|
5: 'is-warning',
|
||
|
6: 'is-danger',
|
||
|
7: 'is-black',
|
||
|
}
|
||
|
return style[idStatus]
|
||
|
},
|
||
|
cambiarStatus(dataSelect, status) {
|
||
|
const data = { id_modulo: dataSelect.id_modulo, activo: status }
|
||
|
this.updateIsLoading(true)
|
||
|
|
||
|
axios
|
||
|
.put(`${process.env.api}/modulo`, data)
|
||
|
.then((res) => {
|
||
|
this.obtenerCatalogoModulo(this.data[0].institucion.id_institucion)
|
||
|
this.updateIsLoading(false)
|
||
|
this.imprimirMensaje(res.data.message)
|
||
|
})
|
||
|
.catch((err) => {
|
||
|
this.updateIsLoading(false)
|
||
|
this.imprimirError(err.response.data)
|
||
|
})
|
||
|
},
|
||
|
obtenerCarritos() {
|
||
|
this.isLoadingTable = true
|
||
|
axios
|
||
|
.get(`${process.env.api}/carrito/carritos?pagina=1&id_institucion=200`)
|
||
|
.then(async (res) => {
|
||
|
this.data = res.data[0]
|
||
|
for (let i = 0; i < this.data.length; i++) {
|
||
|
this.data[i].Equipos = []
|
||
|
this.data[i].Equipos = await this.obtenerEquipos(
|
||
|
this.data[i].id_carrito
|
||
|
)
|
||
|
}
|
||
|
console.log(this.data)
|
||
|
this.isLoadingTable = false
|
||
|
})
|
||
|
.catch((err) => {
|
||
|
this.isLoadingTable = false
|
||
|
this.imprimirError(err.response.data)
|
||
|
})
|
||
|
},
|
||
|
obtenerEquipos(idCarrito) {
|
||
|
return axios
|
||
|
.get(
|
||
|
`${process.env.api}/equipo/equipos?pagina=1&id_carrito=${idCarrito}`
|
||
|
)
|
||
|
.then((res) => {
|
||
|
return res.data[0]
|
||
|
})
|
||
|
.catch((err) => {
|
||
|
this.imprimirError(err.response.data)
|
||
|
})
|
||
|
},
|
||
|
},
|
||
|
watch: {
|
||
|
selectedEquipo(value) {
|
||
|
// localStorage.setItem(
|
||
|
// 'numeroInventario',
|
||
|
// this.selectedEquipo.numeroInventario
|
||
|
// )
|
||
|
// this.$router.push('buscar_equipo')
|
||
|
console.log(value)
|
||
|
},
|
||
|
},
|
||
|
created() {
|
||
|
this.obtenerCarritos()
|
||
|
},
|
||
|
}
|
||
|
</script>
|
||
|
|
||
|
<style>
|
||
|
.pointer {
|
||
|
cursor: pointer;
|
||
|
}
|
||
|
</style>
|