pcpuma_unam_operador/components/operador/TodosEquipos.vue

160 lines
3.6 KiB
Vue
Raw Normal View History

2022-07-06 02:16:03 +00:00
<template>
<div>
2022-07-07 04:17:11 +00:00
<div class="columns is-align-items-flex-end pl-0 pb-4">
<b-field class="column mb-0 pb-0" field="carrito" label="Carrito">
<b-input
placeholder="Carrito"
v-model="carrito"
rounded
@keyup.enter.native="obtenerEquipos"
/>
</b-field>
<b-field class="column mb-0 pb-0" field="equipo" label="Equipo">
<b-input
placeholder="Equipo"
v-model="equipo"
rounded
@keyup.enter.native="obtenerEquipos"
/>
</b-field>
<b-button
class="column mb-0"
type="is-info"
@click="obtenerEquipos"
2022-07-07 21:05:32 +00:00
expanded
2022-07-07 04:17:11 +00:00
rounded
>Buscar</b-button
>
</div>
2022-07-06 02:16:03 +00:00
<b-table
:data="data"
:total="total"
:loading="isLoadingTable"
@page-change="onPageChange"
2022-07-06 02:19:44 +00:00
:selected.sync="selectedEquipo"
2022-07-08 08:19:56 +00:00
:row-class="(row, index) => 'pointer'"
2022-07-06 02:16:03 +00:00
backend-pagination
hoverable
striped
paginated
>
2022-07-07 04:17:11 +00:00
<b-table-column field="equipo" label="Equipo" centered v-slot="props">
2022-07-06 02:16:03 +00:00
{{ props.row.equipo }}
</b-table-column>
<b-table-column
field="numeroInventario"
label="Número de Inventario"
2022-07-07 04:17:11 +00:00
centered
2022-07-06 02:16:03 +00:00
v-slot="props"
>
{{ props.row.numero_inventario }}
</b-table-column>
2022-07-07 04:17:11 +00:00
<b-table-column field="carrito" label="Carrito" centered v-slot="props">
2022-07-06 02:16:03 +00:00
{{ props.row.carrito.carrito }}
</b-table-column>
2022-07-07 04:17:11 +00:00
<b-table-column field="modulo" label="Módulo" centered v-slot="props">
2022-07-06 02:16:03 +00:00
{{ props.row.carrito.modulo.modulo }}
</b-table-column>
2022-07-07 04:17:11 +00:00
<b-table-column
field="tipoCarrito"
label="Tipo Carrito"
centered
v-slot="props"
>
2022-07-06 02:16:03 +00:00
{{ props.row.carrito.tipoCarrito.tipo_carrito }}
</b-table-column>
2022-07-07 04:17:11 +00:00
<b-table-column field="status" label="Status" centered v-slot="props">
2022-07-06 02:19:44 +00:00
<span
class="is-size-6 tag"
:class="choooseTag(props.row.status.id_status)"
>
{{ props.row.status.status }}
</span>
2022-07-06 02:16:03 +00:00
</b-table-column>
</b-table>
</div>
</template>
<script>
import axios from 'axios'
export default {
2022-07-07 21:05:32 +00:00
props: {
operador: { type: Object, require: true },
},
2022-07-06 02:16:03 +00:00
data() {
return {
data: [],
total: 0,
2022-07-06 02:19:44 +00:00
selectedEquipo: {},
2022-07-06 02:16:03 +00:00
isLoadingTable: false,
page: 1,
2022-07-07 04:17:11 +00:00
carrito: '',
equipo: '',
2022-07-06 02:16:03 +00:00
}
},
methods: {
onPageChange(page) {
this.page = page
this.obtenerEquipos()
},
2022-07-06 02:19:44 +00:00
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]
},
2022-07-06 02:16:03 +00:00
obtenerEquipos() {
2022-07-07 04:17:11 +00:00
let carrito = ''
let equipo = ''
if (this.carrito != '') carrito = '&carrito=' + this.carrito
if (this.equipo != '') equipo = '&equipo=' + this.equipo
2022-07-06 02:16:03 +00:00
axios
2022-07-07 04:17:11 +00:00
.get(
`${process.env.api}/equipo/equipos?pagina=${this.page}${carrito}${equipo}`
)
2022-07-06 02:16:03 +00:00
.then((res) => {
this.data = res.data[0]
this.total = res.data[1]
this.isLoadingTable = false
})
.catch((err) => {
this.isLoadingTable = false
2022-07-11 14:15:10 +00:00
this.$alertsGenericos.imprimirError(this.$buefy, err.response.data)
2022-07-06 02:16:03 +00:00
})
},
},
2022-07-06 02:19:44 +00:00
watch: {
2022-07-07 23:20:54 +00:00
selectedEquipo() {
2022-07-07 21:05:32 +00:00
this.$router.push({
path:
'../equipos/buscar_equipo/' + this.selectedEquipo.numero_inventario,
})
2022-07-06 02:19:44 +00:00
},
},
2022-07-06 02:16:03 +00:00
created() {
this.obtenerEquipos()
},
}
</script>
2022-07-08 08:19:56 +00:00
<style>
.pointer {
cursor: pointer;
}
</style>