Files
servicio_social_front/components/responsable/inputTable.vue
T

295 lines
9.9 KiB
Vue
Raw Normal View History

2020-11-10 22:38:34 -06:00
<template>
<div class="container">
<div class="columns">
2020-12-08 21:50:16 -06:00
<div class="column is-3 mb-0">
<b-field>
<b-input
placeholder="No.Cuenta"
icon="school"
rounded
v-model="numeroCuenta"
maxlength="9"
></b-input>
</b-field>
</div>
2020-11-16 13:48:12 -06:00
2020-12-08 21:50:16 -06:00
<div class="column is-3 mb-4 pb-4">
<b-field>
<b-input
2020-11-16 13:48:12 -06:00
type="name"
placeholder="Nombre"
icon="account"
rounded
v-model="nombre"
2020-12-08 21:50:16 -06:00
></b-input>
</b-field>
</div>
2020-11-16 13:48:12 -06:00
2020-12-08 21:50:16 -06:00
<div class="column is-3 mb-4 pb-4 ">
<b-field>
<b-select icon="information" expanded rounded v-model="idStatus">
<optgroup>
<option value="">Status</option>
<option value="1">Pre-registro</option>
<option value="2">Registro</option>
<option value="3">Registro Validado</option>
<option value="4">Pre-Término</option>
<option value="5">Término</option>
<option value="6">Liberación</option>
<option value="7">Carta Aceptacion Rechazada</option>
<option value="8">Carta Termino Rechazada</option>
<option value="9">Informe Global Rechazado</option>
</optgroup>
</b-select>
</b-field>
</div>
2020-11-16 13:48:12 -06:00
2020-12-08 21:50:16 -06:00
<div class="buttons section pt-3 pl-5">
2020-12-07 14:11:29 -06:00
<b-button type="is-info" @click="obtenerDatos(idStatus)">
2020-12-08 21:50:16 -06:00
Buscar
2020-11-25 15:16:10 -06:00
</b-button>
</div>
2020-11-18 19:02:13 -06:00
</div>
2020-11-16 13:48:12 -06:00
2020-11-10 22:38:34 -06:00
<div class="columns">
2020-11-12 22:40:56 -06:00
<section class="column is-12">
2020-12-08 21:50:16 -06:00
<b-table
2020-11-26 16:19:34 -06:00
:data="data"
2020-11-27 19:49:26 -06:00
:loading="loading"
2020-11-29 19:41:17 -06:00
hoverable
striped
2020-11-26 16:19:34 -06:00
paginated
backend-pagination
2020-11-27 19:49:26 -06:00
:total="total"
2020-11-26 16:19:34 -06:00
:per-page="perPage"
2020-11-27 19:49:26 -06:00
@page-change="onPageChange"
2020-12-08 21:50:16 -06:00
>
2020-11-26 16:19:34 -06:00
<b-table-column field="nombre" label="Nombre" v-slot="props" centered>
2020-12-07 16:13:14 -06:00
<span class="cursorR" v-if="props.row.idStatus == 7" @click="cartaAceptacion(props.row.idServicio)">{{ props.row.nombre}}</span>
2020-12-04 17:22:54 -06:00
<span v-else>{{ props.row.nombre}}</span>
2020-11-12 22:40:56 -06:00
</b-table-column>
2020-12-01 17:23:49 -06:00
<b-table-column field="numeroCuenta" label="Número de Cuenta" v-slot="props" centered width="100">
2020-12-07 16:13:14 -06:00
<span class="cursorR" v-if="props.row.idStatus == 7" @click="cartaAceptacion(props.row.idServicio)">{{ props.row.numeroCuenta}}</span>
2020-12-04 17:22:54 -06:00
<span v-else>{{ props.row.numeroCuenta}}</span>
2020-11-12 22:40:56 -06:00
</b-table-column>
2020-11-26 16:19:34 -06:00
<b-table-column field="carrera" label="Carrera" v-slot="props" centered>
2020-12-07 16:13:14 -06:00
<span class="cursorR" v-if="props.row.idStatus == 7" @click="cartaAceptacion(props.row.idServicio)">{{ props.row.carrera}}</span>
2020-12-04 17:22:54 -06:00
<span v-else>{{ props.row.carrera}}</span>
2020-11-12 22:40:56 -06:00
</b-table-column>
2020-11-29 19:41:17 -06:00
<b-table-column field="fechaInicio" truncate=10 label="Fecha Inicio" v-slot="props" centered>
2020-12-08 18:41:21 -06:00
<span class="cursorR" v-if="props.row.idStatus == 7" @click="cartaAceptacion(props.row.idServicio)">{{props.row.fechaInicio}}</span>
2020-12-04 17:22:54 -06:00
<span v-else>{{ fecha(props.row.fechaInicio) }}</span>
2020-11-12 22:40:56 -06:00
</b-table-column>
2020-11-29 19:41:17 -06:00
<b-table-column field="fechaFin" label="Fecha Fin" v-slot="props" centered>
2020-12-08 18:41:21 -06:00
<span class="cursorR" v-if="props.row.idStatus == 7" @click="cartaAceptacion(props.row.idServicio)">{{props.row.fechaFin}}</span>
2020-12-04 17:22:54 -06:00
<span v-else>{{ fecha(props.row.fechaFin) }}</span>
2020-11-26 16:19:34 -06:00
</b-table-column>
<b-table-column field="status" label="Status" v-slot="props" centered>
2020-12-08 18:41:21 -06:00
<span class="cursorR" v-if="props.row.idStatus == 7" @click="cartaAceptacion(props.row.idServicio)">{{ props.row.status }}</span>
<span v-else class="tag" :class="types(props.row.idStatus)">{{ props.row.status}}</span>
2020-11-18 19:02:13 -06:00
</b-table-column>
2020-11-29 19:41:17 -06:00
2020-12-09 14:54:36 -06:00
<b-table-column field="cartaTermino" label="Carta Término" v-slot="props" centered v-if="idTipoUsuario == 2">
2020-12-09 14:51:06 -06:00
<div v-if="props.row.idStatus >= 4 && props.row.idStatus <= 7 || props.row.idStatus == 9">
<span
v-if="props.row.cartaTermino === 1"
>
<b-icon :icon="iconoCarta(props.row.cartaTermino)"
class="tag is-success"></b-icon>
</span>
<b-button
v-if="props.row.cartaTermino === null"
size="is-small"
@click="botonCarta(props.row.cartaTermino)"
class="tag is-danger"
:icon="iconoCarta(props.row.cartaTermino)"
>
Carta ©rmino
</b-button>
</div>
</b-table-column>
2020-11-18 19:02:13 -06:00
2020-12-09 14:51:06 -06:00
<b-table-column field="cuestionario" label="Cuestionario" v-slot="props" centered v-if="idTipoUsuario == 2">
<div v-if="props.row.idStatus >= 4 && props.row.idStatus <= 7 || props.row.idStatus == 9">
<span
v-if="props.row.cuestionario === 1"
>
<b-icon :icon="iconoCuestionario(props.row.cuestionario)"
class="tag is-success"></b-icon>
</span>
<b-button
v-if="props.row.cuestionario === null"
size="is-small"
@click="botonCuestionario(props.row.cuestionario)"
class="tag is-danger"
:icon="iconoCuestionario(props.row.cuestionario)">
Cuestionario
</b-button>
</div>
</b-table-column>
2020-12-08 21:50:16 -06:00
</b-table>
2020-11-10 22:38:34 -06:00
</section>
</div>
</div>
</template>
<script>
2020-12-08 21:50:16 -06:00
import axios from "axios";
import moment from "moment";
2020-11-18 19:02:13 -06:00
2020-11-10 22:38:34 -06:00
export default {
2020-12-08 21:50:16 -06:00
data() {
2020-11-10 22:38:34 -06:00
return {
2020-12-09 11:46:22 -06:00
idTipoUsuario: '',
2020-11-27 19:49:26 -06:00
data: [],
2020-12-08 21:50:16 -06:00
total: "",
2020-11-27 19:49:26 -06:00
loading: true,
2020-11-23 18:48:37 -06:00
page: 1,
2020-11-27 19:49:26 -06:00
perPage: 25,
2020-12-08 21:50:16 -06:00
numeroCuenta: "",
nombre: "",
idStatus: "",
};
2020-11-12 22:40:56 -06:00
},
methods: {
2020-12-08 21:50:16 -06:00
onPageChange(page) {
this.page = page;
this.obtenerDatos();
console.log(this.page);
2020-11-27 19:49:26 -06:00
},
2020-12-08 21:50:16 -06:00
types(idStatus) {
2020-12-01 17:23:49 -06:00
if (idStatus === 1) {
2020-12-08 21:50:16 -06:00
return "is-dark";
2020-12-01 17:23:49 -06:00
} else if (idStatus === 2) {
2020-12-08 21:50:16 -06:00
return "is-info";
2020-12-01 17:23:49 -06:00
} else if (idStatus === 3) {
2020-12-08 21:50:16 -06:00
return "is-link";
2020-12-01 17:23:49 -06:00
} else if (idStatus === 4) {
2020-12-08 21:50:16 -06:00
return "is-warning";
2020-12-01 17:23:49 -06:00
} else if (idStatus === 5) {
2020-12-08 21:50:16 -06:00
return "is-success";
2020-12-01 17:23:49 -06:00
} else if (idStatus === 6) {
2020-12-08 21:50:16 -06:00
return "is-link";
2020-12-01 17:23:49 -06:00
} else if (idStatus === 7) {
2020-12-08 21:50:16 -06:00
return "is-danger";
2020-12-01 17:23:49 -06:00
} else if (idStatus === 8) {
2020-12-08 21:50:16 -06:00
return "is-danger";
2020-12-01 17:23:49 -06:00
} else if (idStatus === 9) {
2020-12-08 21:50:16 -06:00
return "is-danger";
} else if (idStatus === 10) {
// admin
return "is-danger";
2020-11-12 22:40:56 -06:00
}
},
2020-12-08 21:50:16 -06:00
botonCarta(cartaTermino) {
this.$router.push("/responsable/carta_termino");
2020-11-29 19:41:17 -06:00
if (cartaTermino === 1) {
2020-12-08 21:50:16 -06:00
return "is-success";
2020-11-16 13:48:12 -06:00
} else {
2020-12-08 21:50:16 -06:00
return "is-danger";
2020-11-16 13:48:12 -06:00
}
},
2020-12-08 21:50:16 -06:00
botonCuestionario(cuestionario) {
this.$router.push("/responsable/cuestionario");
2020-11-29 19:41:17 -06:00
if (cuestionario === 1) {
2020-12-08 21:50:16 -06:00
return "is-success";
2020-11-16 13:48:12 -06:00
} else {
2020-12-08 21:50:16 -06:00
return "is-danger";
2020-11-16 13:48:12 -06:00
}
},
2020-12-08 21:50:16 -06:00
iconoCarta(cartaTermino) {
2020-11-29 19:41:17 -06:00
if (cartaTermino === 1) {
2020-12-08 21:50:16 -06:00
return "check";
2020-11-16 13:48:12 -06:00
} else {
2020-12-08 21:50:16 -06:00
return "close";
2020-11-16 13:48:12 -06:00
}
},
2020-12-08 21:50:16 -06:00
iconoCuestionario(cuestionario) {
2020-11-26 16:19:34 -06:00
if (cuestionario === 1) {
2020-12-08 21:50:16 -06:00
return "check";
2020-11-16 13:48:12 -06:00
} else {
2020-12-08 21:50:16 -06:00
return "close";
2020-11-16 13:48:12 -06:00
}
},
2020-12-08 21:50:16 -06:00
fecha(date) {
const fecha = moment(date.substr(0, 10));
return `${fecha.date()}/${fecha.month() + 1}/${fecha.year()}`;
2020-12-01 17:23:49 -06:00
},
2020-12-07 14:11:29 -06:00
obtenerDatos (idStatus) {
2020-11-29 19:41:17 -06:00
this.loading = true
2020-11-27 19:49:26 -06:00
this.data = []
2020-12-09 11:46:22 -06:00
axios.get(`${process.env.api}/servicio/servicios_responsable?idUsuario=${this.idTipoUsuario}&pagina=${this.page}&idStatus=${idStatus}&nombre=${this.nombre}&numeroCuenta=${this.numeroCuenta}`)
2020-11-23 15:35:03 -06:00
.then(res => {
2020-11-26 16:19:34 -06:00
const servicios = res.data.servicios
if (servicios.length !== 0) {
for (let i = 0; i < servicios.length; i++) {
this.data.push({
nombre: servicios[i].Usuario.nombre,
numeroCuenta: servicios[i].Usuario.usuario,
carrera: servicios[i].Carrera.carrera,
fechaInicio: servicios[i].fechaInicio,
fechaFin: servicios[i].fechaFin,
status: servicios[i].Status.status,
2020-12-01 12:24:37 -06:00
idStatus: servicios[i].Status.idStatus,
2020-11-29 19:41:17 -06:00
cuestionario: servicios[i].idCuestionarioPrograma,
2020-12-08 21:50:16 -06:00
cartaTermino: servicios[i].cartaTermino,
});
2020-11-26 16:19:34 -06:00
}
}
2020-12-08 21:50:16 -06:00
let currentTotal = servicios.length;
let contador;
2020-11-26 16:19:34 -06:00
2020-12-08 21:50:16 -06:00
for (let i = 0; i < res.data.registros / 25 + 1; i++) {
contador = i;
2020-11-26 16:19:34 -06:00
}
2020-12-08 21:50:16 -06:00
currentTotal = this.perPage * contador;
this.total = currentTotal;
this.loading = false;
2020-11-23 15:35:03 -06:00
})
2020-11-30 19:57:08 -06:00
.catch((err) => {
2020-12-08 21:50:16 -06:00
console.log(err.response.data.message);
this.loading = false;
});
},
cartaAceptacion(idServicio) {
window.localStorage.setItem("idServicio", idServicio);
this.$router.push("/responsable/carta_aceptacion");
2020-12-01 12:24:37 -06:00
},
2020-12-08 21:50:16 -06:00
insertIdLocal() {
this.idUsuario = localStorage.getItem("idUsuario");
2020-12-04 17:22:54 -06:00
},
2020-12-09 11:46:22 -06:00
getIdLocal () {
this.idTipoUsuario = localStorage.getItem('idTipoUsuario')
2020-11-23 15:35:03 -06:00
}
2020-11-25 15:16:10 -06:00
},
created () {
2020-12-09 11:46:22 -06:00
this.getIdLocal()
2020-12-07 14:11:29 -06:00
this.obtenerDatos(0)
2020-11-10 22:38:34 -06:00
}
}
</script>
2020-11-16 13:48:12 -06:00
<style>
2020-12-08 21:50:16 -06:00
.input:focus {
border: #1b3d70;
2020-11-29 19:41:17 -06:00
box-shadow: 0 0 8px 0 #1b3d70;
}
2020-12-08 21:50:16 -06:00
.select select:focus {
2020-11-29 19:41:17 -06:00
border-color: #1b3d70;
box-shadow: 0 0 8px 0 #1b3d70;
}
2020-12-08 21:50:16 -06:00
.select:not(.is-multiple):not(.is-loading)::after {
2020-11-29 19:41:17 -06:00
border-color: #1b3d70;
}
.pagination-link.is-current {
background-color: #1b3d70;
border-color: #1b3d70;
}
2020-12-08 21:50:16 -06:00
.cursorR {
2020-12-04 17:22:54 -06:00
cursor: pointer;
}
2020-11-16 13:48:12 -06:00
</style>