menu.html 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <main class="container">
  2. <button type="button" class="secondary" v-for="item in menu" @click="item.click">
  3. <i :class="item.icon"></i>
  4. {{ item.name }}
  5. </button>
  6. </main>
  7. <script>
  8. PetiteVue.createApp({
  9. menu: [{
  10. name: 'Construcción de Calificación',
  11. icon: 'fas fa-plus',
  12. url: '/export/excel.php',
  13. filename: 'calificacion.csv',
  14. async click() {
  15. store.loading = true;
  16. const response = await fetch(this.url, { method: 'POST', body: JSON.stringify({ query: 'calificaciones' }) });
  17. const blob = await response.blob();
  18. const url = window.URL.createObjectURL(blob);
  19. const a = document.createElement('a');
  20. a.href = url;
  21. a.download = this.filename;
  22. a.charset = "windows-1252"; // Set the charset to ANSI
  23. a.click();
  24. a.remove();
  25. store.loading = false;
  26. }
  27. },
  28. {
  29. name: 'Usuarios registrados',
  30. icon: 'fas fa-plus',
  31. url: '/export/excel.php',
  32. filename: 'usuarios.csv',
  33. async click() {
  34. store.loading = true;
  35. const response = await fetch(this.url, { method: 'POST', body: JSON.stringify({ query: 'usuarios' }) });
  36. const blob = await response.blob();
  37. const url = window.URL.createObjectURL(blob);
  38. const a = document.createElement('a');
  39. a.href = url;
  40. a.download = this.filename;
  41. a.charset = "windows-1252"; // Set the charset to ANSI
  42. a.click();
  43. a.remove();
  44. store.loading = false;
  45. }
  46. }
  47. ],
  48. }).mount();
  49. </script>