correciones de marco

This commit is contained in:
Lemuel Marquez
2021-01-05 15:08:03 -06:00
13 changed files with 201 additions and 98 deletions
@@ -27,30 +27,72 @@
>Enviar archivo</b-button
>
<b-button v-else disabled class="is-info">Enviar archivo</b-button>
<b-loading
:is-full-page="true"
v-model="isLoading"
:can-cancel="false"
></b-loading>
</div>
</template>
<script>
export default {
data(){
return{
csv: {}
}
data() {
return {
csv: {},
isLoading: false,
toastType: null,
toastMessage: null,
};
},
methods: {
validarExt() {
const extPermitidas = /(.csv)$/i;
if (!extPermitidas.exec(this.csv.name)) {
this.dangerToast();
this.toastType = 'is-danger'
this.toastMessage = 'Asegurate de ingresar un archivo .CSV'
this.toast();
this.csv = {};
}
},
dangerToast() {
toast() {
this.$buefy.toast.open({
message: "Asegurate de ingresar un archivo .CSV",
type: "is-danger",
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",
hasIcon: true,
onConfirm: () => this.enviarCargaMasiva(),
});
},
enviarCargaMasiva () {
this.isLoading = true;
const formData = new FormData();
if (this.cartaAceptacion) {
formData.append("cartaAceptacion", this.cartaAceptacion);
}
axios
.put(`${process.env.api}/programa/carga_masiva`, formData)
.then((res) => {
this.isLoading = false;
this.toastType = 'is-success'
this.toastMessage = 'Se ha enviado la carga masiva con éxito'
this.toast();
})
.catch((err) => {
this.isLoading = false;
this.toastType = 'is-danger'
this.toastMessage = err.response.data.message
this.toast()
});
},
},
};
</script>