179 lines
4.1 KiB
Vue
179 lines
4.1 KiB
Vue
<template>
|
|
<div>
|
|
<h3 class="title">Tabla de responsables</h3>
|
|
|
|
<div class="columns">
|
|
<b-field class="column" label="Correo Electrónico">
|
|
<b-input
|
|
type="text"
|
|
placeholder="Correo"
|
|
icon="mail"
|
|
v-model="busqueda.correo"
|
|
@keyup.enter.native="obtenerResponsables()"
|
|
rounded
|
|
/>
|
|
</b-field>
|
|
|
|
<b-field class="column" label="Nombre">
|
|
<b-input
|
|
type="name"
|
|
placeholder="Nombre"
|
|
icon="account"
|
|
v-model="busqueda.nombre"
|
|
@keyup.enter.native="obtenerResponsables()"
|
|
rounded
|
|
/>
|
|
</b-field>
|
|
|
|
<div class="column is-align-self-center">
|
|
<b-button
|
|
type="is-info"
|
|
@click="obtenerResponsables()"
|
|
expanded
|
|
rounded
|
|
>
|
|
Buscar
|
|
</b-button>
|
|
</div>
|
|
</div>
|
|
|
|
<b-table
|
|
:data="data"
|
|
:total="total"
|
|
:current-page="page"
|
|
:per-page="perPage"
|
|
:selected.sync="responsableSeleccionado"
|
|
:loading="isLoading"
|
|
:row-class="(row, index) => 'pointer'"
|
|
@page-change="onPageChange"
|
|
hoverable
|
|
striped
|
|
paginated
|
|
backend-pagination
|
|
>
|
|
<b-table-column
|
|
field="correo"
|
|
label="Correo Electrónico"
|
|
v-slot="props"
|
|
centered
|
|
>
|
|
<span>{{ props.row.usuario }}</span>
|
|
</b-table-column>
|
|
|
|
<b-table-column field="nombre" label="Nombre" v-slot="props" centered>
|
|
<span>{{ props.row.nombre }} </span>
|
|
</b-table-column>
|
|
|
|
<b-table-column field="estado" label="Estado" v-slot="props" centered>
|
|
<span :class="style(props.row.activo)">
|
|
{{ props.row.activo ? 'Activo' : 'Desactivado' }}
|
|
</span>
|
|
</b-table-column>
|
|
</b-table>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import axios from 'axios'
|
|
|
|
export default {
|
|
data() {
|
|
return {
|
|
data: [],
|
|
page: 1,
|
|
perPage: 25,
|
|
total: 0,
|
|
isLoading: false,
|
|
busqueda: {},
|
|
busquedaAnterior: {},
|
|
responsableSeleccionado: {},
|
|
}
|
|
},
|
|
props: {
|
|
admin: { type: Object, required: true },
|
|
imprimirMensaje: { type: Function, required: true },
|
|
imprimirWarning: { type: Function, required: true },
|
|
imprimirError: { type: Function, required: true },
|
|
},
|
|
methods: {
|
|
style(activo) {
|
|
let style = 'tag'
|
|
|
|
if (activo) style += ' is-success'
|
|
else style += ' is-danger'
|
|
return style
|
|
},
|
|
onPageChange(page) {
|
|
this.page = page
|
|
this.obtenerResponsables()
|
|
},
|
|
obtenerResponsables() {
|
|
let data = ''
|
|
|
|
this.isLoading = true
|
|
if (
|
|
this.busqueda.correo != this.busquedaAnterior.correo ||
|
|
this.busqueda.nombre != this.busquedaAnterior.nombre
|
|
) {
|
|
this.page = 1
|
|
this.busquedaAnterior.correo = this.busqueda.correo
|
|
this.busquedaAnterior.nombre = this.busqueda.nombre
|
|
}
|
|
if (this.busqueda.nombre) data += `&nombre=${this.busqueda.nombre}`
|
|
if (this.busqueda.correo) data = `&correo=${this.busqueda.correo}`
|
|
axios
|
|
.get(
|
|
`${process.env.api}/usuario/responsables?&pagina=${this.page}${data}`,
|
|
this.admin.token
|
|
)
|
|
.then((res) => {
|
|
this.data = res.data.responsables
|
|
this.total = res.data.count
|
|
this.isLoading = false
|
|
})
|
|
.catch((err) => {
|
|
this.isLoading = false
|
|
this.imprimirError(err.response.data)
|
|
})
|
|
},
|
|
},
|
|
watch: {
|
|
responsableSeleccionado() {
|
|
localStorage.setItem(
|
|
'idResponsable',
|
|
this.responsableSeleccionado.idUsuario
|
|
)
|
|
this.$router.push(`/admin/responsables/infoResponsable`)
|
|
},
|
|
},
|
|
created() {
|
|
if (this.admin.idTipoUsuario === 1) this.obtenerResponsables()
|
|
},
|
|
}
|
|
</script>
|
|
|
|
<style>
|
|
.input:focus {
|
|
border: #1b3d70;
|
|
box-shadow: 0 0 8px 0 #1b3d70;
|
|
}
|
|
|
|
.select select:focus {
|
|
border-color: #1b3d70;
|
|
box-shadow: 0 0 8px 0 #1b3d70;
|
|
}
|
|
|
|
.select:not(.is-multiple):not(.is-loading)::after {
|
|
border-color: #1b3d70;
|
|
}
|
|
|
|
.pagination-link.is-current {
|
|
background-color: #1b3d70;
|
|
border-color: #1b3d70;
|
|
}
|
|
|
|
.pointer {
|
|
cursor: pointer;
|
|
}
|
|
</style>
|