Merge remote-tracking branch 'origin/dev' into eithan

This commit is contained in:
eithan
2021-01-06 00:29:44 -06:00
7 changed files with 508 additions and 44 deletions
+313
View File
@@ -0,0 +1,313 @@
<template>
<div
v-if="this.idTipoUsuario == 1 && this.tipoUsuario == 'admin'"
class="container"
>
<div class="columns">
<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>
<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-4 pb-4 ">
<b-field>
<b-select
placeholder="Status"
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>
<option value="10">Cancelado</option>
</optgroup>
</b-select>
</b-field>
</div>
<div class="buttons section pt-3 pl-5">
<b-button type="is-info" @click="obtenerDatos(idStatus)">
Buscar
</b-button>
</div>
</div>
<div class="columns">
<section class="column is-12">
<b-table
:data="data"
:loading="isLoading"
paginated
backend-pagination
:total="total"
:per-page="perPage"
@page-change="onPageChange"
hoverable
striped
>
<b-table-column field="nombre" label="Nombre" v-slot="props" centered>
<span @click="servicios(props.row.idServicio)">{{
props.row.nombre
}}</span>
</b-table-column>
<b-table-column
field="numeroCuenta"
label="Número de Cuenta"
v-slot="props"
centered
width="100"
>
<span @click="servicios(props.row.idServicio)">{{
props.row.numeroCuenta
}}</span>
</b-table-column>
<b-table-column
field="carrera"
label="Carrera"
v-slot="props"
centered
>
<span @click="servicios(props.row.idServicio)">{{
props.row.carrera
}}</span>
</b-table-column>
<b-table-column
field="fechaInicio"
truncate="10"
label="Fecha Inicio"
v-slot="props"
centered
>
<span @click="servicios(props.row.idServicio)">{{
fecha(props.row.fechaInicio)
}}</span>
</b-table-column>
<b-table-column
field="fechaFin"
label="Fecha Fin"
v-slot="props"
centered
>
<span @click="servicios(props.row.idServicio)">{{
fecha(props.row.fechaFin)
}}</span>
</b-table-column>
<b-table-column field="status" label="Status" v-slot="props" centered>
<span
@click="servicios(props.row.idServicio)"
class="tag"
:class="types(props.row.idStatus)"
>{{ props.row.status }}</span
>
</b-table-column>
</b-table>
</section>
</div>
</div>
</template>
<script>
import axios from "axios";
import moment from "moment";
export default {
data() {
return {
idUsuario: "",
idTipoUsuario: "",
tipoUsuario: "",
data: [],
total: "",
isLoading: false,
page: 1,
perPage: 25,
numeroCuenta: "",
nombre: "",
idStatus: "",
token: {
headers: {
token: window.localStorage.getItem("token"),
},
},
};
},
methods: {
onPageChange(page) {
this.page = page;
this.obtenerDatos();
console.log(this.page);
},
types(idStatus) {
if (idStatus === 1) {
return "is-dark";
} else if (idStatus === 2) {
return "is-info";
} else if (idStatus === 3) {
return "is-link";
} else if (idStatus === 4) {
return "is-warning";
} else if (idStatus === 5) {
return "is-success";
} else if (idStatus === 6) {
return "is-link";
} else if (idStatus === 7) {
return "is-danger";
} else if (idStatus === 8) {
return "is-danger";
} else if (idStatus === 9) {
return "is-danger";
} else if (idStatus === 10) {
// admin
return "is-danger";
}
},
fecha(date) {
const fecha = moment(date.substr(0, 10));
return `${fecha.date()}/${fecha.month() + 1}/${fecha.year()}`;
},
obtenerDatos(idStatus) {
this.isLoading = true;
this.data = [];
axios
.get(
`${process.env.api}/servicio/servicios_admin?pagina=${this.page}&idStatus=${this.idStatus}&nombre=${this.nombre}&numeroCuenta=${this.numeroCuenta}`,
this.token
)
.then((res) => {
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,
idStatus: servicios[i].Status.idStatus,
idServicio: servicios[i].idServicio,
});
}
}
let currentTotal = servicios.length;
let contador;
for (let i = 0; i < res.data.registros / 25 + 1; i++) {
contador = i;
}
currentTotal = this.perPage * contador;
this.total = currentTotal;
})
.catch((error) => {
error(error.response.data.message);
})
.finally(() => {
this.isLoading = false;
});
},
servicios(idServicio) {
window.localStorage.setItem("idServicio", idServicio);
this.$router.push("/admin/servicio");
},
getIdLocal() {
this.idUsuario = localStorage.getItem("idUsuario");
this.idTipoUsuario = localStorage.getItem("idTipoUsuario");
this.tipoUsuario = localStorage.getItem("tipoUsuario");
if (this.idTipoUsuario != 1 && this.tipoUsuario != "admin") {
this.$router.push("/");
}
},
error(msj) {
let salir = false;
switch (msj) {
case "invalid signature":
msj = "tu token no es valido, inicia sesión de nuevo";
break;
case "jwt expired":
msj = "tu sesión ha expirado, inicia sesión de nuevo";
break;
case "no hay token":
msj = "no has enviado tu token, inicia sesión de nuevo";
break;
default:
salir = true;
}
this.$buefy.dialog.alert({
title: "Error",
message: msj,
type: "is-danger",
hasIcon: true,
icon: "alert-circle",
iconPack: "mdi",
ariaRole: "alertdialog",
ariaModal: true,
});
if (salir === true) {
localStorage.clear();
this.$router.push(`/`);
}
},
},
created() {
this.getIdLocal();
this.obtenerDatos(0);
},
};
</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;
}
.b-table {
cursor: pointer;
}
</style>
+38 -15
View File
@@ -49,6 +49,8 @@
>Enviar</b-button
>
</b-field>
<b-loading :is-full-page="true" v-model="isLoading" :can-cancel="true">
</b-loading>
</div>
</template>
@@ -62,6 +64,7 @@ export default {
file: [],
idServicio: "",
cartaAceptacion: "",
isLoading: false,
token: {
headers: {
token: window.localStorage.getItem("token"),
@@ -92,17 +95,15 @@ export default {
const formData = new FormData();
formData.append("data", JSON.stringify(data));
formData.append("cartaAceptacion", this.file);
console.log(formData);
this.isLoading = true;
axios
.put(`${process.env.api}/servicio/carta_aceptacion`, formData, {
headers: {
"Content-Type": "multipart/form-data",
token: this.token.headers.token,
},
})
.then((res) => {
console.log(res.data);
loadingComponent.close();
this.$buefy.dialog.alert({
title: "Success",
message: "Se enviaron los datos correctamente",
@@ -115,19 +116,10 @@ export default {
});
})
.catch((error) => {
loadingComponent.close();
this.$buefy.dialog.alert({
title: "Error",
message: error.response.data.message,
type: "is-danger",
hasIcon: true,
icon: "alert-circle",
iconPack: "mdi",
ariaRole: "alertdialog",
ariaModal: true,
});
error(error.response.data.message);
})
.finally(() => {
this.isLoading = false;
this.$router.push("/responsable");
localStorage.removeItem("idServicio");
localStorage.removeItem("cartaAceptacion");
@@ -141,6 +133,37 @@ export default {
this.$router.push("/responsable");
}
},
error(msj) {
let salir = false;
switch (msj) {
case "invalid signature":
msj = "tu token no es valido, inicia sesión de nuevo";
break;
case "jwt expired":
msj = "tu sesión ha expirado, inicia sesión de nuevo";
break;
case "no hay token":
msj = "no has enviado tu token, inicia sesión de nuevo";
break;
default:
salir = true;
}
this.$buefy.dialog.alert({
title: "Error",
message: msj,
type: "is-danger",
hasIcon: true,
icon: "alert-circle",
iconPack: "mdi",
ariaRole: "alertdialog",
ariaModal: true,
});
if (salir === true) {
localStorage.clear();
this.$router.push(`/`);
}
},
},
watch: {
file: function(newFile, oldFile) {
+38 -12
View File
@@ -49,6 +49,8 @@
Enviar
</b-button>
</b-field>
<b-loading :is-full-page="true" v-model="isLoading" :can-cancel="true">
</b-loading>
</div>
</template>
@@ -62,6 +64,7 @@ export default {
file: [],
idServicio: "",
cartaTermino: "",
isLoading: false,
token: {
headers: {
token: window.localStorage.getItem("token"),
@@ -93,11 +96,12 @@ export default {
const formData = new FormData();
formData.append("data", JSON.stringify(data));
formData.append("cartaTermino", this.file);
console.log(formData);
this.isLoading = true;
axios
.put(`${process.env.api}/servicio/carta_termino`, formData, {
headers: {
"Content-Type": "multipart/form-data",
token: this.token.headers.token,
},
})
.then((res) => {
@@ -116,19 +120,10 @@ export default {
});
})
.catch((error) => {
loadingComponent.close();
this.$buefy.dialog.alert({
title: "Error",
message: error.response.data.message,
type: "is-danger",
hasIcon: true,
icon: "alert-circle",
iconPack: "mdi",
ariaRole: "alertdialog",
ariaModal: true,
});
error(error.response.data.message);
})
.finally(() => {
this.isLoading = false;
this.$router.push("/responsable");
localStorage.removeItem("idServicio");
localStorage.removeItem("cartaTermino");
@@ -142,6 +137,37 @@ export default {
this.$router.push("/responsable");
}
},
error(msj) {
let salir = false;
switch (msj) {
case "invalid signature":
msj = "tu token no es valido, inicia sesión de nuevo";
break;
case "jwt expired":
msj = "tu sesión ha expirado, inicia sesión de nuevo";
break;
case "no hay token":
msj = "no has enviado tu token, inicia sesión de nuevo";
break;
default:
salir = true;
}
this.$buefy.dialog.alert({
title: "Error",
message: msj,
type: "is-danger",
hasIcon: true,
icon: "alert-circle",
iconPack: "mdi",
ariaRole: "alertdialog",
ariaModal: true,
});
if (salir === true) {
localStorage.clear();
this.$router.push(`/`);
}
},
},
watch: {
file: function(newFile, oldFile) {
+60 -5
View File
@@ -160,6 +160,9 @@
>
</b-field>
</section>
<b-loading :is-full-page="true" v-model="isLoading" :can-cancel="true">
</b-loading>
</div>
</template>
@@ -170,6 +173,7 @@ export default {
return {
idServicio: "",
cuestionario: "",
isLoading: false,
actividad1: "",
actividad2: "",
@@ -198,13 +202,33 @@ export default {
p6: this.p6,
p7: this.p7,
};
console.log(data);
/*
this.isLoading = true;
axios
.post(`${process.env.api}/cuestionario_programa`, data)
.then((res) => {});
*/
.post(`${process.env.api}/cuestionario_programa`, data, this.token)
.then((res) => {
this.$buefy.dialog.alert({
title: "Success",
message: "Se enviaron los datos correctamente",
type: "is-success",
hasIcon: true,
icon: "checkbox-marked-circle",
iconPack: "mdi",
ariaRole: "alertdialog",
ariaModal: true,
});
})
.catch((error) => {
error(error.response.data.message);
})
.finally(() => {
this.isLoading = false;
this.$router.push("/responsable");
localStorage.removeItem("idServicio");
localStorage.removeItem("cuestionario");
});
},
getIdLocal() {
this.idServicio = localStorage.getItem("idServicio");
@@ -214,6 +238,37 @@ export default {
this.$router.push("/responsable");
}
},
error(msj) {
let salir = false;
switch (msj) {
case "invalid signature":
msj = "tu token no es valido, inicia sesión de nuevo";
break;
case "jwt expired":
msj = "tu sesión ha expirado, inicia sesión de nuevo";
break;
case "no hay token":
msj = "no has enviado tu token, inicia sesión de nuevo";
break;
default:
salir = true;
}
this.$buefy.dialog.alert({
title: "Error",
message: msj,
type: "is-danger",
hasIcon: true,
icon: "alert-circle",
iconPack: "mdi",
ariaRole: "alertdialog",
ariaModal: true,
});
if (salir === true) {
localStorage.clear();
this.$router.push(`/`);
}
},
},
created() {
this.getIdLocal();
+58 -10
View File
@@ -1,5 +1,8 @@
<template>
<div class="container">
<div
v-if="this.idTipoUsuario == 2 && this.tipoUsuario == 'responsable'"
class="container"
>
<div class="columns">
<div class="column is-3 mb-0">
<b-field>
@@ -55,7 +58,7 @@
<section class="column is-12">
<b-table
:data="data"
:loading="loading"
:loading="isLoading"
hoverable
striped
paginated
@@ -232,15 +235,21 @@ export default {
return {
idTipoUsuario: "",
idUsuario: "",
tipoUsuario: "",
data: [],
total: "",
loading: true,
isLoading: false,
page: 1,
perPage: 25,
numeroCuenta: "",
nombre: "",
idStatus: "",
idServicio: "",
token: {
headers: {
token: window.localStorage.getItem("token"),
},
},
};
},
methods: {
@@ -304,11 +313,12 @@ export default {
return `${fecha.year()}/${fecha.month() + 1}/${fecha.date()}`;
},
obtenerDatos(idStatus) {
this.loading = true;
this.isLoading = true;
this.data = [];
axios
.get(
`${process.env.api}/servicio/servicios_responsable?idUsuario=${this.idUsuario}&pagina=${this.page}&idStatus=${this.idStatus}&nombre=${this.nombre}&numeroCuenta=${this.numeroCuenta}`
`${process.env.api}/servicio/servicios_responsable?idUsuario=${this.idUsuario}&pagina=${this.page}&idStatus=${this.idStatus}&nombre=${this.nombre}&numeroCuenta=${this.numeroCuenta}`,
this.token
)
.then((res) => {
const servicios = res.data.servicios;
@@ -337,11 +347,13 @@ export default {
}
currentTotal = this.perPage * contador;
this.total = currentTotal;
this.loading = false;
})
.catch((err) => {
console.log(err.response.data.message);
this.loading = false;
.catch((error) => {
error(error.response.data.message);
})
.finally(() => {
this.isLoading = false;
});
},
cartaAceptacion(idServicio, idStatus) {
@@ -350,8 +362,44 @@ export default {
this.$router.push("/responsable/carta_aceptacion");
},
getIdLocal() {
this.idTipoUsuario = localStorage.getItem("idTipoUsuario");
this.idUsuario = localStorage.getItem("idUsuario");
this.idTipoUsuario = localStorage.getItem("idTipoUsuario");
this.tipoUsuario = localStorage.getItem("tipoUsuario");
if (this.idTipoUsuario != 2 && this.tipoUsuario != "responsable") {
this.$router.push("/");
}
},
error(msj) {
let salir = false;
switch (msj) {
case "invalid signature":
msj = "tu token no es valido, inicia sesión de nuevo";
break;
case "jwt expired":
msj = "tu sesión ha expirado, inicia sesión de nuevo";
break;
case "no hay token":
msj = "no has enviado tu token, inicia sesión de nuevo";
break;
default:
salir = true;
}
this.$buefy.dialog.alert({
title: "Error",
message: msj,
type: "is-danger",
hasIcon: true,
icon: "alert-circle",
iconPack: "mdi",
ariaRole: "alertdialog",
ariaModal: true,
});
if (salir === true) {
localStorage.clear();
this.$router.push(`/`);
}
},
},
created() {
+1 -1
View File
@@ -19,7 +19,7 @@
</template>
<script>
import InputTableA from "../../components/admin//servicio/inputTableA";
import InputTableA from "../../components/admin/inputTableA";
export default {
components: {
-1
View File
@@ -430,7 +430,6 @@ export default {
ariaRole: "alertdialog",
ariaModal: true,
});
this.reset();
})
.catch((error) => {