FeriadosCard.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <q-card flat class="feriados-card card-ring">
  3. <div class="flex justify-between items-center no-wrap q-mb-sm">
  4. <div class="flex items-center q-gutter-x-sm">
  5. <q-icon name="mdi-calendar-star-outline" color="dark" size="sm" />
  6. <span class="text-subtitle1">Feriados do Mês</span>
  7. </div>
  8. <q-btn
  9. icon="mdi-plus"
  10. color="primary"
  11. style="width: 40px; height: 40px"
  12. @click="openDialog"
  13. />
  14. </div>
  15. <q-separator />
  16. <div
  17. v-if="currentMonthHolidays.length === 0"
  18. class="text-caption text-grey-5 text-center q-mt-md"
  19. >
  20. Sem feriados para este mês.
  21. </div>
  22. <q-list v-else dense>
  23. <template v-for="(holiday, index) in currentMonthHolidays" :key="holiday.id">
  24. <q-item class="q-px-none person-item">
  25. <q-item-section avatar style="min-width: 36px">
  26. <div class="day-badge">{{ holiday.day }}</div>
  27. </q-item-section>
  28. <q-item-section>
  29. <q-item-label class="text-body2">{{ holiday.description }}</q-item-label>
  30. <q-item-label caption>{{ typeLabel(holiday.type) }}</q-item-label>
  31. </q-item-section>
  32. </q-item>
  33. <q-separator v-if="index < currentMonthHolidays.length - 1" />
  34. </template>
  35. </q-list>
  36. </q-card>
  37. </template>
  38. <script setup>
  39. import { ref, computed } from "vue";
  40. import { useQuasar } from "quasar";
  41. import FeriadosDialog from "src/pages/dashboard/components/FeriadosDialog.vue";
  42. const $q = useQuasar();
  43. const now = new Date();
  44. const holidays = ref([]);
  45. const currentMonthHolidays = computed(() =>
  46. holidays.value
  47. .filter((h) => h.month === now.getMonth() + 1 && h.year === now.getFullYear())
  48. .sort((a, b) => a.day - b.day),
  49. );
  50. function typeLabel(type) {
  51. return type === "facultativo" ? "Ponto Facultativo" : "Feriado";
  52. }
  53. function openDialog() {
  54. $q.dialog({
  55. component: FeriadosDialog,
  56. componentProps: { initialHolidays: holidays.value },
  57. }).onOk((updated) => {
  58. holidays.value = updated;
  59. });
  60. }
  61. </script>
  62. <style scoped>
  63. .feriados-card {
  64. border-radius: 12px;
  65. padding: 20px 24px;
  66. display: flex;
  67. flex-direction: column;
  68. max-height: 370px;
  69. overflow: hidden;
  70. }
  71. .person-item {
  72. padding-top: 6px;
  73. padding-bottom: 6px;
  74. }
  75. .day-badge {
  76. width: 30px;
  77. height: 30px;
  78. border-radius: 50%;
  79. background-color: #e64a19;
  80. color: #fff;
  81. font-size: 12px;
  82. font-weight: 600;
  83. display: flex;
  84. align-items: center;
  85. justify-content: center;
  86. flex-shrink: 0;
  87. }
  88. </style>