Puestos UI

This commit is contained in:
Your Name
2024-09-06 12:42:03 -06:00
parent 811b7d7369
commit da22c0de55
2 changed files with 31 additions and 0 deletions

View File

@@ -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());

View File

@@ -47,6 +47,10 @@
<span class="ing-mas"></span>
Agregar puesto
</button>
<button type="button" class="btn btn-success mx-2" @click="descargar()">
<span class="ing-descarga"></span>
Agregar Excel
</button>
</div>
<?