FranchisePerformanceCard.vue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <template>
  2. <q-card class="franchise-performance-card">
  3. <div class="row justify-between items-center no-wrap">
  4. <span class="text-subtitle1 text-dark">Desempenho por Franquia</span>
  5. <q-btn color="primary" label="Exportar Relatório" icon="mdi-download" unelevated no-caps />
  6. </div>
  7. <q-table
  8. flat
  9. dense
  10. :rows="rows"
  11. :columns="columns"
  12. :loading="loading"
  13. row-key="id"
  14. :pagination="{ rowsPerPage: 0 }"
  15. hide-pagination
  16. virtual-scroll
  17. class="q-mt-md"
  18. style="max-height: 280px"
  19. >
  20. <template #body-cell-revenue="{ row }">
  21. <q-td align="left">{{ formatCurrency(row.revenue) }}</q-td>
  22. </template>
  23. <template #body-cell-expense="{ row }">
  24. <q-td align="left">{{ formatCurrency(row.expense) }}</q-td>
  25. </template>
  26. <template #body-cell-performance="{ row }">
  27. <q-td align="left">
  28. <span :class="row.performance >= 0 ? 'text-positive' : 'text-negative'">
  29. {{ row.performance }}%
  30. </span>
  31. </q-td>
  32. </template>
  33. <template #no-data>
  34. <div class="full-width text-center text-caption text-foreground q-py-md">
  35. Nenhum dado encontrado
  36. </div>
  37. </template>
  38. </q-table>
  39. </q-card>
  40. </template>
  41. <script setup>
  42. defineProps({
  43. rows: { type: Array, default: () => [] },
  44. loading: { type: Boolean, default: false },
  45. });
  46. const formatCurrency = (value) =>
  47. new Intl.NumberFormat("pt-BR", { style: "currency", currency: "BRL" }).format(value ?? 0);
  48. const columns = [
  49. { name: "franchise", label: "Franquia", field: "franchise", align: "left" },
  50. { name: "revenue", label: "Faturamento", field: "revenue", align: "left" },
  51. { name: "expense", label: "Despesa", field: "expense", align: "left" },
  52. { name: "performance", label: "Desempenho", field: "performance", align: "left" },
  53. ];
  54. </script>
  55. <style scoped lang="scss">
  56. .franchise-performance-card {
  57. flex: 1 1 0;
  58. min-width: 220px;
  59. height: 380px;
  60. border-radius: 12px;
  61. box-shadow: 0 0 0 1px #c0c0c0c0 !important;
  62. padding: 16px 20px;
  63. overflow: hidden;
  64. }
  65. </style>