AverageAttendanceDialog.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <q-dialog ref="dialogRef" @hide="onDialogHide">
  3. <q-card style="width: 800px; max-width: 95vw; border-radius: 12px">
  4. <q-bar class="bg-transparent q-px-md" style="height: 55px">
  5. <span class="text-h6 text-dark" style="font-weight: 600"
  6. >Frequência Média</span
  7. >
  8. <q-space />
  9. <q-btn dense flat icon="mdi-close" @click="onDialogCancel" />
  10. </q-bar>
  11. <q-card-section class="q-pt-none q-pb-md q-px-md">
  12. <q-card flat bordered style="border-radius: 8px">
  13. <q-card-section class="q-pb-sm">
  14. <q-input
  15. v-model="search"
  16. dense
  17. borderless
  18. placeholder="Busque por unidade, status"
  19. >
  20. <template #prepend>
  21. <q-icon name="mdi-magnify" color="grey-6" />
  22. </template>
  23. </q-input>
  24. </q-card-section>
  25. <q-separator />
  26. <div class="list-header q-px-md q-py-xs">
  27. <span class="text-caption text-grey-7">Unidade</span>
  28. <span class="text-caption text-grey-7">Frequência média</span>
  29. <span class="text-caption text-grey-7">Status</span>
  30. </div>
  31. <q-separator />
  32. <div>
  33. <template
  34. v-for="(item, index) in filteredUnidades"
  35. :key="item.id"
  36. >
  37. <div
  38. class="list-row q-px-md q-py-sm"
  39. :class="{ 'row-selected': index === selectedIndex }"
  40. @click="selectedIndex = index"
  41. >
  42. <span class="text-body2 text-dark">{{ item.unidade }}</span>
  43. <span class="text-body2 text-dark">{{ item.frequencia }}</span>
  44. <q-badge
  45. :label="item.status"
  46. :color="item.status === 'Alto' ? 'secondary' : 'orange'"
  47. style="
  48. border-radius: 8px;
  49. font-size: 11px;
  50. padding: 4px 8px;
  51. width: max-content;
  52. "
  53. />
  54. </div>
  55. <q-separator v-if="index < filteredUnidades.length - 1" />
  56. </template>
  57. </div>
  58. </q-card>
  59. </q-card-section>
  60. </q-card>
  61. </q-dialog>
  62. </template>
  63. <script setup>
  64. import { ref, computed } from "vue";
  65. import { useDialogPluginComponent } from "quasar";
  66. defineEmits([...useDialogPluginComponent.emits]);
  67. const { dialogRef, onDialogHide, onDialogCancel } = useDialogPluginComponent();
  68. const search = ref("");
  69. const selectedIndex = ref(0);
  70. const unidades = [
  71. { id: 1, unidade: "São Paulo", frequencia: "47%", status: "Baixa" },
  72. { id: 2, unidade: "Maringá", frequencia: "20 %", status: "Baixa" },
  73. { id: 3, unidade: "Curitiba", frequencia: "79 %", status: "Alto" },
  74. { id: 4, unidade: "Foz Iguaçu", frequencia: "98%", status: "Alto" },
  75. ];
  76. const filteredUnidades = computed(() => {
  77. if (!search.value) return unidades;
  78. const q = search.value.toLowerCase();
  79. return unidades.filter(
  80. (u) =>
  81. u.unidade.toLowerCase().includes(q) ||
  82. u.status.toLowerCase().includes(q),
  83. );
  84. });
  85. </script>
  86. <style scoped>
  87. .list-header {
  88. display: grid;
  89. grid-template-columns: 1fr 1fr 80px;
  90. align-items: center;
  91. }
  92. .list-row {
  93. display: grid;
  94. grid-template-columns: 1fr 1fr 80px;
  95. align-items: center;
  96. cursor: pointer;
  97. transition: background-color 0.15s;
  98. }
  99. .list-row:hover {
  100. background-color: #f5f5f5;
  101. }
  102. .row-selected {
  103. background-color: #b2dfdb !important;
  104. }
  105. </style>