This commit is contained in:
@@ -70,6 +70,34 @@ const app = createApp({
|
|||||||
alert(`Error: ${error}`);
|
alert(`Error: ${error}`);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
async descargar() {
|
||||||
|
store.current.modal_state = 'Generando reporte en Excel...';
|
||||||
|
$('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() {
|
async mounted() {
|
||||||
this.puestos = await fetch('action/puesto.php').then(res => res.json());
|
this.puestos = await fetch('action/puesto.php').then(res => res.json());
|
||||||
this.carreras = await fetch('action/action_carreras.php').then(res => res.json());
|
this.carreras = await fetch('action/action_carreras.php').then(res => res.json());
|
||||||
|
|||||||
@@ -47,6 +47,10 @@
|
|||||||
<span class="ing-mas"></span>
|
<span class="ing-mas"></span>
|
||||||
Agregar puesto
|
Agregar puesto
|
||||||
</button>
|
</button>
|
||||||
|
<button type="button" class="btn btn-success mx-2" @click="descargar()">
|
||||||
|
<span class="ing-descarga"></span>
|
||||||
|
Agregar Excel
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?
|
<?
|
||||||
|
|||||||
Reference in New Issue
Block a user