DashboardPage.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <div class="dashboard-page bg-page">
  3. <template v-if="loading">
  4. <div class="row items-center justify-center full-width bg-surface" style="height: 80vh">
  5. <q-spinner-dots color="primary" />
  6. </div>
  7. </template>
  8. <template v-else>
  9. <DashboardHeaderBar :data="headerBar" />
  10. <DashboardSummaryInfos :data="summaryInfos" />
  11. <DashboardPendingSchedules
  12. v-if="pendingSchedules.length > 0"
  13. :data="pendingSchedules"
  14. @view-details="openAcceptedDialog"
  15. />
  16. <DashboardScrollAreaSchedules />
  17. <DashboardClientProposals />
  18. <DashboardPendingCustomSchedules />
  19. <DashboardNextSchedules v-if="nextSchedules.length > 0" :data="nextSchedules" />
  20. <DashboardLastDoneSchedules v-if="lastDoneSchedules.length > 0" :data="lastDoneSchedules" />
  21. <DashboardFavoriteProviders v-if="favoriteProviders.length > 0" :data="favoriteProviders" />
  22. <DashboardProvidersClose v-if="providersClose.length > 0" :data="providersClose" />
  23. </template>
  24. </div>
  25. </template>
  26. <script setup>
  27. import DashboardHeaderBar from 'src/components/dashboard/DashboardHeaderBar.vue';
  28. import DashboardSummaryInfos from 'src/components/dashboard/DashboardSummaryInfos.vue';
  29. import DashboardPendingSchedules from 'src/components/dashboard/DashboardPendingSchedules.vue';
  30. import ScheduleAcceptedDialog from 'src/components/dashboard/ScheduleAcceptedDialog.vue';
  31. import DashboardScrollAreaSchedules from 'src/components/dashboard/DashboardScrollAreaSchedules.vue';
  32. import DashboardNextSchedules from 'src/components/dashboard/DashboardNextSchedules.vue';
  33. import DashboardLastDoneSchedules from 'src/components/dashboard/DashboardLastDoneSchedules.vue';
  34. import DashboardFavoriteProviders from 'src/components/dashboard/DashboardFavoriteProviders.vue';
  35. import DashboardProvidersClose from 'src/components/dashboard/DashboardProvidersClose.vue';
  36. import FinalSuccesModal from '../schedules/components/FinalSuccesModal.vue';
  37. import DashboardPendingCustomSchedules from 'src/pages/dashboard/components/DashboardPendingCustomSchedules.vue';
  38. import DashboardClientProposals from 'src/pages/dashboard/components/DashboardClientProposals.vue';
  39. import { useRouter } from 'vue-router'
  40. import { onMounted, ref } from 'vue';
  41. import { useQuasar } from 'quasar';
  42. import { dadosDashboard } from 'src/api/dashboard';
  43. const router = useRouter()
  44. const headerBar = ref({});
  45. const summaryInfos = ref({});
  46. const pendingSchedules = ref([]);
  47. const nextSchedules = ref([]);
  48. const lastDoneSchedules = ref([]);
  49. const favoriteProviders = ref([]);
  50. const providersClose = ref([]);
  51. const $q = useQuasar();
  52. const loading = ref(true);
  53. const showSuccessModal = ref(router.currentRoute.value.fullPath.includes('showSuccessModal') || false);
  54. const openAcceptedDialog = (schedule) => {
  55. $q.dialog({
  56. component: ScheduleAcceptedDialog,
  57. componentProps: { schedule }
  58. }).onOk(() => {
  59. reloadDashboard();
  60. });
  61. };
  62. const reloadDashboard = async () => {
  63. loading.value = true;
  64. const response = await dadosDashboard();
  65. if (response) {
  66. headerBar.value = response.headerBar;
  67. summaryInfos.value = response.summaryInfos;
  68. pendingSchedules.value = response.pendingSchedules ?? [];
  69. nextSchedules.value = response.nextSchedules ?? [];
  70. lastDoneSchedules.value = response.lastDoneSchedules ?? [];
  71. favoriteProviders.value = response.favoriteProviders ?? [];
  72. providersClose.value = response.providersClose ?? [];
  73. DashboardClientProposals.value = response.DashboardClientProposals ?? [];
  74. }
  75. if( showSuccessModal.value ) {
  76. $q.dialog({
  77. component: FinalSuccesModal
  78. })
  79. showSuccessModal.value = false;
  80. }
  81. loading.value = false;
  82. };
  83. onMounted(async () => {
  84. await reloadDashboard();
  85. });
  86. </script>
  87. <style scoped>
  88. .dashboard-page {
  89. width: 100%;
  90. min-height: 100%;
  91. box-sizing: border-box;
  92. }
  93. </style>