diff --git a/js/puestos.js b/js/puestos.js
index acc9a9f..2f3891d 100644
--- a/js/puestos.js
+++ b/js/puestos.js
@@ -70,6 +70,33 @@ const app = createApp({
alert(`Error: ${error}`);
}
},
+ async descargar() {
+ $('div.modal#cargando').modal('show');
+ this.loading = true;
+ try {
+ const res = await fetch('action/action_puestos_excel.php', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json'
+ },
+ });
+ const blob = await res.blob();
+ window.saveAs(blob, `puestos_${new Date().toISOString().slice(0, 10)}.xlsx`);
+ }
+ catch (error) {
+ if (error.response && error.response.status === 413) {
+ alert('Your request is too large! Please reduce the data size and try again.');
+ }
+ else {
+ alert('An error occurred: ' + error.message);
+ }
+ }
+ finally {
+ $('#cargando').modal('hide');
+ this.loading = false;
+ }
+ },
+
async mounted() {
this.puestos = await fetch('action/puesto.php').then(res => res.json());
this.carreras = await fetch('action/action_carreras.php').then(res => res.json());
diff --git a/puestos.php b/puestos.php
index 18ab0e9..9f67166 100644
--- a/puestos.php
+++ b/puestos.php
@@ -47,6 +47,10 @@
Agregar puesto
+