Files
servicio_social_front/components/admin/servicio/programa/tablaResponsables.vue
T

165 lines
4.1 KiB
Vue
Raw Normal View History

2020-11-19 16:12:38 -06:00
<template>
2020-12-09 14:24:05 -06:00
<div class="container mt-5">
<div class="columns">
<div class="column is-3 mb-4 pb-4">
<b-field>
<b-input
type="name"
placeholder="Nombre"
icon="account"
rounded
v-model="nombre"
></b-input>
</b-field>
</div>
<div class="column is-3 mb-0">
2020-12-09 15:32:07 -06:00
<b-field>
2020-11-19 16:12:38 -06:00
<b-input
2020-12-09 14:24:05 -06:00
placeholder="Correo electrónico"
icon="school"
rounded
v-model="correo"
maxlength="9"
2020-11-19 16:12:38 -06:00
>
2020-12-09 14:24:05 -06:00
</b-input>
</b-field>
</div>
<div class="buttons section pt-3 pl-5">
2020-12-09 15:32:07 -06:00
<b-button type="is-info" @click="obtenerDatos(idStatus)">
Buscar
</b-button>
</div>
2020-12-09 14:24:05 -06:00
</div>
<div class="columns mb-5">
<section class="column is-12">
<b-table
2020-12-09 15:32:07 -06:00
:data="data"
:loading="loading"
hoverable
striped
paginated
backend-pagination
:total="total"
:per-page="perPage"
@page-change="onPageChange"
2020-12-09 14:24:05 -06:00
>
<b-table-column field="nombre" label="Nombre" v-slot="props" centered>
2020-12-09 16:13:26 -06:00
<span @click="verRegistro(props.row)">{{
2020-12-09 15:32:07 -06:00
props.row.nombre
}}</span>
2020-12-09 14:24:05 -06:00
</b-table-column>
2020-12-09 15:32:07 -06:00
<b-table-column
field="correo"
label="Correo electrónico"
v-slot="props"
centered
2020-12-08 21:50:16 -06:00
>
2020-12-09 16:13:26 -06:00
<span @click="verRegistro(props.row)">{{
2020-12-09 15:32:07 -06:00
props.row.usuario
2020-12-08 21:50:16 -06:00
}}</span>
2020-12-09 14:24:05 -06:00
</b-table-column>
</b-table>
</section>
</div>
</div>
2020-11-19 16:12:38 -06:00
</template>
<script>
2020-12-09 15:32:07 -06:00
import axios from "axios";
2020-11-19 16:12:38 -06:00
export default {
2020-12-08 21:50:16 -06:00
data() {
2020-11-19 16:12:38 -06:00
return {
2020-12-09 15:32:07 -06:00
idUsuario: "",
2020-12-09 14:24:05 -06:00
data: [],
2020-12-09 15:32:07 -06:00
total: "",
2020-12-09 14:24:05 -06:00
loading: false,
2020-11-19 16:12:38 -06:00
page: 1,
2020-12-09 14:24:05 -06:00
perPage: 25,
2020-12-09 15:32:07 -06:00
correo: "",
nombre: "",
idStatus: 1,
2020-12-08 21:50:16 -06:00
};
2020-11-19 16:12:38 -06:00
},
methods: {
2020-12-08 21:50:16 -06:00
onPageChange(page) {
this.page = page;
2020-12-09 15:32:07 -06:00
this.obtenerDatos();
console.log(this.page);
2020-12-09 14:24:05 -06:00
},
2020-12-09 15:32:07 -06:00
obtenerDatos(idStatus) {
this.loading = true;
this.data = [];
axios
.get(
2020-12-09 16:13:26 -06:00
`${process.env.api}/usuario/responsable?pagina=${this.page}&nombre=${this.nombre}&correo=${this.correo}`
2020-12-09 15:32:07 -06:00
)
.then((res) => {
const servicios = res.data.servicios;
2020-12-09 14:24:05 -06:00
if (servicios.length !== 0) {
for (let i = 0; i < servicios.length; i++) {
this.data.push({
nombre: servicios[i].nombre,
usuario: servicios[i].usuario,
2020-12-09 15:32:07 -06:00
idUsuario: servicios[i].idUsuario,
});
2020-12-09 14:24:05 -06:00
}
}
2020-12-09 15:32:07 -06:00
let currentTotal = servicios.length;
let contador;
for (let i = 0; i < res.data.registros / this.perPage + 1; i++) {
contador = i;
2020-12-09 14:24:05 -06:00
}
2020-12-09 15:32:07 -06:00
currentTotal = this.perPage * contador;
this.total = currentTotal;
this.loading = false;
2020-12-09 14:24:05 -06:00
})
.catch((err) => {
2020-12-09 15:32:07 -06:00
console.log(err.response.data.message);
this.loading = false;
});
2020-12-09 14:24:05 -06:00
},
2020-12-09 15:32:07 -06:00
insertIdLocal() {
this.idUsuario = localStorage.getItem("idUsuario");
},
2020-12-09 16:13:26 -06:00
verRegistro(responsable) {
localStorage.setItem("correo", responsable.usuario);
localStorage.setItem("idResponsable", responsable.idUsuario);
localStorage.setItem("nombre", responsable.nombre);
2020-12-09 15:32:07 -06:00
this.$router.push("./infoResponsable");
2020-12-09 14:24:05 -06:00
},
2020-11-19 16:12:38 -06:00
},
computed: {
2020-12-08 21:50:16 -06:00
busquedaNombreResponsable() {
return this.responsables.filter((responsables) =>
2020-11-19 16:12:38 -06:00
responsables.nombreResp.includes(this.buscarNombreResponsable)
2020-12-08 21:50:16 -06:00
);
},
2020-11-19 16:12:38 -06:00
},
2020-12-09 15:32:07 -06:00
async created() {
await this.obtenerDatos();
this.insertIdLocal();
},
2020-12-08 21:50:16 -06:00
};
2020-11-19 16:12:38 -06:00
</script>
<style scoped>
2020-12-09 15:32:07 -06:00
.b-table {
2020-12-09 14:24:05 -06:00
cursor: pointer;
}
2020-12-09 15:32:07 -06:00
.input:focus {
border: #1b3d70;
2020-12-09 14:24:05 -06:00
box-shadow: 0 0 8px 0 #1b3d70;
}
2020-12-09 15:32:07 -06:00
.select select:focus {
2020-12-09 14:24:05 -06:00
border-color: #1b3d70;
box-shadow: 0 0 8px 0 #1b3d70;
}
2020-12-09 15:32:07 -06:00
.select:not(.is-multiple):not(.is-loading)::after {
2020-12-09 14:24:05 -06:00
border-color: #1b3d70;
}
.pagination-link.is-current {
background-color: #1b3d70;
border-color: #1b3d70;
}
2020-11-19 16:12:38 -06:00
</style>