DashboardPage.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. @cancel="cancelSchedule"
  16. />
  17. <DashboardTodaySchedules v-if="todaySchedules.length > 0" :data="todaySchedules" @rate="openRatingDialog" />
  18. <DashboardScrollAreaSchedules />
  19. <DashboardClientProposals :data="clientProposals" @refresh-data="reloadDashboard" />
  20. <DashboardPendingCustomSchedules v-if="clientProposals.length === 0" />
  21. <DashboardNextSchedules v-if="nextSchedules.length > 0" :data="nextSchedules" @view-details="openNextScheduleDialog" />
  22. <DashboardLastDoneSchedules v-if="lastDoneSchedules.length > 0" :data="lastDoneSchedules" />
  23. <DashboardFavoriteProviders v-if="favoriteProviders.length > 0" :data="favoriteProviders" />
  24. <DashboardProvidersClose v-if="providersClose.length > 0" :data="providersClose" />
  25. </template>
  26. </div>
  27. </template>
  28. <script setup>
  29. import DashboardHeaderBar from 'src/components/dashboard/DashboardHeaderBar.vue';
  30. import DashboardSummaryInfos from 'src/components/dashboard/DashboardSummaryInfos.vue';
  31. import DashboardPendingSchedules from 'src/components/dashboard/DashboardPendingSchedules.vue';
  32. import ScheduleAcceptedDialog from 'src/components/dashboard/ScheduleAcceptedDialog.vue';
  33. import DashboardScrollAreaSchedules from 'src/components/dashboard/DashboardScrollAreaSchedules.vue';
  34. import DashboardNextSchedules from 'src/components/dashboard/DashboardNextSchedules.vue';
  35. import DashboardLastDoneSchedules from 'src/components/dashboard/DashboardLastDoneSchedules.vue';
  36. import DashboardFavoriteProviders from 'src/components/dashboard/DashboardFavoriteProviders.vue';
  37. import DashboardProvidersClose from 'src/components/dashboard/DashboardProvidersClose.vue';
  38. import DashboardTodaySchedules from 'src/components/dashboard/DashboardTodaySchedules.vue';
  39. import FinalSuccesModal from '../schedules/components/FinalSuccesModal.vue';
  40. import DashboardPendingCustomSchedules from 'src/pages/dashboard/components/DashboardPendingCustomSchedules.vue';
  41. import DashboardClientProposals from 'src/pages/dashboard/components/DashboardClientProposals.vue';
  42. import { useRouter } from 'vue-router'
  43. import { onMounted, ref } from 'vue';
  44. import { useDialogPluginComponent, useQuasar } from 'quasar';
  45. import { dadosDashboard } from 'src/api/dashboard';
  46. import ScheduleCancelDialog from 'src/components/dashboard/ScheduleCancelDialog.vue';
  47. import NextSchedulesDetailsDialog from 'src/components/dashboard/NextSchedulesDetailsDialog.vue';
  48. import ScheduleRatingDialog from 'src/components/dashboard/ScheduleRatingDialog.vue';
  49. const router = useRouter()
  50. const headerBar = ref({});
  51. const summaryInfos = ref({});
  52. const pendingSchedules = ref([]);
  53. const nextSchedules = ref([]);
  54. const clientProposals = ref([]);
  55. const lastDoneSchedules = ref([]);
  56. const favoriteProviders = ref([]);
  57. const providersClose = ref([]);
  58. const todaySchedules = ref([]);
  59. const $q = useQuasar();
  60. const loading = ref(true);
  61. const showSuccessModal = ref(router.currentRoute.value.fullPath.includes('showSuccessModal') || false);
  62. const { onDialogOK } = useDialogPluginComponent();
  63. const openAcceptedDialog = (schedule) => {
  64. $q.dialog({
  65. component: ScheduleAcceptedDialog,
  66. componentProps: { schedule }
  67. }).onOk(() => {
  68. reloadDashboard();
  69. });
  70. };
  71. const reloadDashboard = async () => {
  72. loading.value = true;
  73. const response = await dadosDashboard();
  74. if (response) {
  75. headerBar.value = response.headerBar;
  76. summaryInfos.value = response.summaryInfos;
  77. pendingSchedules.value = response.pendingSchedules ?? [];
  78. nextSchedules.value = response.nextSchedules ?? [];
  79. lastDoneSchedules.value = response.lastDoneSchedules ?? [];
  80. favoriteProviders.value = response.favoriteProviders ?? [];
  81. providersClose.value = response.providersClose ?? [];
  82. clientProposals.value = response.schedulesProposals ?? [];
  83. todaySchedules.value = response.todaySchedules ?? [];
  84. }
  85. if( showSuccessModal.value == true) {
  86. $q.dialog({
  87. component: FinalSuccesModal
  88. })
  89. showSuccessModal.value = false;
  90. router.replace({ path: router.currentRoute.value.path, query: {} });
  91. }
  92. loading.value = false;
  93. };
  94. const openNextScheduleDialog = (schedule) => {
  95. $q.dialog({
  96. component: NextSchedulesDetailsDialog,
  97. componentProps: { schedule }
  98. }).onOk(() => {
  99. reloadDashboard();
  100. });
  101. };
  102. const cancelSchedule = (schedule) => {
  103. console.log(schedule)
  104. $q.dialog({
  105. component: ScheduleCancelDialog,
  106. componentProps: { schedule: schedule }
  107. }).onDismiss(() => {
  108. onDialogOK(reloadDashboard());
  109. })
  110. }
  111. const openRatingDialog = (schedule) => {
  112. $q.dialog({
  113. component: ScheduleRatingDialog,
  114. componentProps: { schedule }
  115. }).onOk(() => {
  116. reloadDashboard()
  117. })
  118. }
  119. onMounted(async () => {
  120. await reloadDashboard();
  121. });
  122. </script>
  123. <style scoped>
  124. .dashboard-page {
  125. width: 100%;
  126. min-height: 100%;
  127. box-sizing: border-box;
  128. }
  129. </style>