nuevo formateo
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
</p>
|
||||
<p>
|
||||
{{
|
||||
csv.name || "Arrastra aquí tu archivo o da click para buscar"
|
||||
csv.name || 'Arrastra aquí tu archivo o da click para buscar'
|
||||
}}
|
||||
</p>
|
||||
</div>
|
||||
@@ -36,108 +36,108 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import axios from "axios";
|
||||
import axios from 'axios'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
csv: {},
|
||||
token: {
|
||||
headers: {
|
||||
token: window.localStorage.getItem("token"),
|
||||
token: window.localStorage.getItem('token'),
|
||||
},
|
||||
},
|
||||
isLoading: false,
|
||||
toastType: null,
|
||||
toastMessage: null,
|
||||
};
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
validarExt() {
|
||||
const extPermitidas = /(.csv)$/i;
|
||||
const extPermitidas = /(.csv)$/i
|
||||
if (!extPermitidas.exec(this.csv.name)) {
|
||||
this.toastType = "is-danger";
|
||||
this.toastMessage = "Asegurate de ingresar un archivo .CSV";
|
||||
this.toast();
|
||||
this.csv = {};
|
||||
this.toastType = 'is-danger'
|
||||
this.toastMessage = 'Asegurate de ingresar un archivo .CSV'
|
||||
this.toast()
|
||||
this.csv = {}
|
||||
}
|
||||
},
|
||||
toast() {
|
||||
this.$buefy.toast.open({
|
||||
message: this.toastMessage,
|
||||
type: this.toastType,
|
||||
});
|
||||
})
|
||||
},
|
||||
dialog() {
|
||||
this.$buefy.dialog.confirm({
|
||||
title: "Carga masiva",
|
||||
message: "¿Seguro(a) que quiere enviar este archivo?",
|
||||
confirmText: "Confirmar",
|
||||
cancelText: "Cancelar",
|
||||
type: "is-success",
|
||||
title: 'Carga masiva',
|
||||
message: '¿Seguro(a) que quiere enviar este archivo?',
|
||||
confirmText: 'Confirmar',
|
||||
cancelText: 'Cancelar',
|
||||
type: 'is-success',
|
||||
hasIcon: true,
|
||||
onConfirm: () => this.enviarCargaMasiva(),
|
||||
});
|
||||
})
|
||||
},
|
||||
enviarCargaMasiva() {
|
||||
const formData = new FormData();
|
||||
const formData = new FormData()
|
||||
|
||||
this.isLoading = true;
|
||||
formData.append("csv", this.csv);
|
||||
this.isLoading = true
|
||||
formData.append('csv', this.csv)
|
||||
axios
|
||||
.post(`${process.env.api}/programa/carga_masiva`, formData, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data",
|
||||
'Content-Type': 'multipart/form-data',
|
||||
token: this.token.headers.token,
|
||||
},
|
||||
})
|
||||
.then((res) => {
|
||||
this.isLoading = false;
|
||||
this.toastType = "is-success";
|
||||
this.toastMessage = "Se ha enviado la carga masiva con éxito";
|
||||
this.toast();
|
||||
this.$router.push("/admin");
|
||||
this.isLoading = false
|
||||
this.toastType = 'is-success'
|
||||
this.toastMessage = 'Se ha enviado la carga masiva con éxito'
|
||||
this.toast()
|
||||
this.$router.push('/admin')
|
||||
})
|
||||
.catch((err) => {
|
||||
this.isLoading = false;
|
||||
this.error(err.response.data.message);
|
||||
});
|
||||
this.isLoading = false
|
||||
this.error(err.response.data.message)
|
||||
})
|
||||
},
|
||||
error(msj) {
|
||||
let salir = false;
|
||||
let salir = false
|
||||
switch (msj) {
|
||||
case "invalid signature":
|
||||
msj = "Tu token no es valido, inicia sesión de nuevo.";
|
||||
salir = true;
|
||||
break;
|
||||
case "jwt expired":
|
||||
msj = "Tu sesión ha expirado, inicia sesión de nuevo.";
|
||||
salir = true;
|
||||
break;
|
||||
case "jwt malformed":
|
||||
msj = "No se encontro tu token, inicia sesión de nuevo.";
|
||||
salir = true;
|
||||
break;
|
||||
case "No hay token":
|
||||
msj = "Ocurrio un error al enviar tu token, inicia sesión de nuevo.";
|
||||
salir = true;
|
||||
break;
|
||||
case 'invalid signature':
|
||||
msj = 'Tu token no es valido, inicia sesión de nuevo.'
|
||||
salir = true
|
||||
break
|
||||
case 'jwt expired':
|
||||
msj = 'Tu sesión ha expirado, inicia sesión de nuevo.'
|
||||
salir = true
|
||||
break
|
||||
case 'jwt malformed':
|
||||
msj = 'No se encontro tu token, inicia sesión de nuevo.'
|
||||
salir = true
|
||||
break
|
||||
case 'No hay token':
|
||||
msj = 'Ocurrio un error al enviar tu token, inicia sesión de nuevo.'
|
||||
salir = true
|
||||
break
|
||||
}
|
||||
|
||||
this.$buefy.dialog.alert({
|
||||
title: "Error",
|
||||
title: 'Error',
|
||||
message: msj,
|
||||
type: "is-danger",
|
||||
type: 'is-danger',
|
||||
hasIcon: true,
|
||||
icon: "alert-circle",
|
||||
iconPack: "mdi",
|
||||
ariaRole: "alertdialog",
|
||||
icon: 'alert-circle',
|
||||
iconPack: 'mdi',
|
||||
ariaRole: 'alertdialog',
|
||||
ariaModal: true,
|
||||
});
|
||||
})
|
||||
if (salir == true) {
|
||||
localStorage.clear();
|
||||
this.$router.push(`/`);
|
||||
localStorage.clear()
|
||||
this.$router.push(`/`)
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -61,122 +61,122 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import axios from "axios";
|
||||
import axios from 'axios'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
idUsuario: "",
|
||||
idUsuario: '',
|
||||
data: [],
|
||||
total: "",
|
||||
total: '',
|
||||
loading: false,
|
||||
page: 1,
|
||||
perPage: 25,
|
||||
correo: "",
|
||||
nombre: "",
|
||||
correo: '',
|
||||
nombre: '',
|
||||
idStatus: 1,
|
||||
token: {
|
||||
headers: {
|
||||
token: window.localStorage.getItem("token"),
|
||||
token: window.localStorage.getItem('token'),
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
onPageChange(page) {
|
||||
this.page = page;
|
||||
this.obtenerDatos();
|
||||
this.page = page
|
||||
this.obtenerDatos()
|
||||
},
|
||||
obtenerDatos(idStatus) {
|
||||
this.loading = true;
|
||||
this.data = [];
|
||||
this.loading = true
|
||||
this.data = []
|
||||
axios
|
||||
.get(
|
||||
`${process.env.api}/usuario/responsable?pagina=${this.page}&nombre=${this.nombre}&correo=${this.correo}`,
|
||||
this.token
|
||||
)
|
||||
.then((res) => {
|
||||
const servicios = res.data.servicios;
|
||||
const servicios = res.data.servicios
|
||||
if (servicios.length !== 0) {
|
||||
for (let i = 0; i < servicios.length; i++) {
|
||||
this.data.push({
|
||||
nombre: servicios[i].nombre,
|
||||
usuario: servicios[i].usuario,
|
||||
idUsuario: servicios[i].idUsuario,
|
||||
});
|
||||
})
|
||||
}
|
||||
}
|
||||
let currentTotal = servicios.length;
|
||||
let contador;
|
||||
let currentTotal = servicios.length
|
||||
let contador
|
||||
for (let i = 0; i < res.data.registros / this.perPage + 1; i++) {
|
||||
contador = i;
|
||||
contador = i
|
||||
}
|
||||
currentTotal = this.perPage * contador;
|
||||
this.total = currentTotal;
|
||||
this.loading = false;
|
||||
currentTotal = this.perPage * contador
|
||||
this.total = currentTotal
|
||||
this.loading = false
|
||||
})
|
||||
.catch((err) => {
|
||||
this.loading = false;
|
||||
this.error(err.response.data.message);
|
||||
});
|
||||
this.loading = false
|
||||
this.error(err.response.data.message)
|
||||
})
|
||||
},
|
||||
error(msj) {
|
||||
let salir = false;
|
||||
let salir = false
|
||||
switch (msj) {
|
||||
case "invalid signature":
|
||||
msj = "Tu token no es valido, inicia sesión de nuevo.";
|
||||
salir = true;
|
||||
break;
|
||||
case "jwt expired":
|
||||
msj = "Tu sesión ha expirado, inicia sesión de nuevo.";
|
||||
salir = true;
|
||||
break;
|
||||
case "jwt malformed":
|
||||
msj = "No se encontro tu token, inicia sesión de nuevo.";
|
||||
salir = true;
|
||||
break;
|
||||
case "No hay token":
|
||||
msj = "Ocurrio un error al enviar tu token, inicia sesión de nuevo.";
|
||||
salir = true;
|
||||
break;
|
||||
case 'invalid signature':
|
||||
msj = 'Tu token no es valido, inicia sesión de nuevo.'
|
||||
salir = true
|
||||
break
|
||||
case 'jwt expired':
|
||||
msj = 'Tu sesión ha expirado, inicia sesión de nuevo.'
|
||||
salir = true
|
||||
break
|
||||
case 'jwt malformed':
|
||||
msj = 'No se encontro tu token, inicia sesión de nuevo.'
|
||||
salir = true
|
||||
break
|
||||
case 'No hay token':
|
||||
msj = 'Ocurrio un error al enviar tu token, inicia sesión de nuevo.'
|
||||
salir = true
|
||||
break
|
||||
}
|
||||
|
||||
this.$buefy.dialog.alert({
|
||||
title: "Error",
|
||||
title: 'Error',
|
||||
message: msj,
|
||||
type: "is-danger",
|
||||
type: 'is-danger',
|
||||
hasIcon: true,
|
||||
icon: "alert-circle",
|
||||
iconPack: "mdi",
|
||||
ariaRole: "alertdialog",
|
||||
icon: 'alert-circle',
|
||||
iconPack: 'mdi',
|
||||
ariaRole: 'alertdialog',
|
||||
ariaModal: true,
|
||||
});
|
||||
})
|
||||
if (salir == true) {
|
||||
localStorage.clear();
|
||||
this.$router.push(`/`);
|
||||
localStorage.clear()
|
||||
this.$router.push(`/`)
|
||||
}
|
||||
},
|
||||
insertIdLocal() {
|
||||
this.idUsuario = localStorage.getItem("idUsuario");
|
||||
this.idUsuario = localStorage.getItem('idUsuario')
|
||||
},
|
||||
verRegistro(responsable) {
|
||||
localStorage.setItem("correo", responsable.usuario);
|
||||
localStorage.setItem("idResponsable", responsable.idUsuario);
|
||||
localStorage.setItem("nombre", responsable.nombre);
|
||||
this.$router.push("/admin/programa/infoResponsable");
|
||||
localStorage.setItem('correo', responsable.usuario)
|
||||
localStorage.setItem('idResponsable', responsable.idUsuario)
|
||||
localStorage.setItem('nombre', responsable.nombre)
|
||||
this.$router.push('/admin/programa/infoResponsable')
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
busquedaNombreResponsable() {
|
||||
return this.responsables.filter((responsables) =>
|
||||
responsables.nombreResp.includes(this.buscarNombreResponsable)
|
||||
);
|
||||
)
|
||||
},
|
||||
},
|
||||
async created() {
|
||||
await this.obtenerDatos();
|
||||
this.insertIdLocal();
|
||||
await this.obtenerDatos()
|
||||
this.insertIdLocal()
|
||||
},
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
Reference in New Issue
Block a user