LastTransactionsCard.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <template>
  2. <q-card class="last-transactions-card">
  3. <div class="row justify-between items-center no-wrap">
  4. <span class="text-subtitle1 text-dark">Últimas Movimentações</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="transactions-table q-mt-md"
  18. style="max-height: 280px"
  19. >
  20. <template #body-cell-value="{ row }">
  21. <q-td align="left">{{ formatCurrency(row.value) }}</q-td>
  22. </template>
  23. <template #body-cell-status="{ row }">
  24. <q-td align="left">
  25. <q-badge
  26. :color="statusColor(row.status)"
  27. :label="row.status"
  28. style="padding: 4px 8px"
  29. />
  30. </q-td>
  31. </template>
  32. <template #no-data>
  33. <div class="full-width text-center text-caption text-foreground q-py-md">
  34. Nenhuma movimentação encontrada
  35. </div>
  36. </template>
  37. </q-table>
  38. </q-card>
  39. </template>
  40. <script setup>
  41. defineProps({
  42. rows: { type: Array, default: () => [] },
  43. loading: { type: Boolean, default: false },
  44. });
  45. const formatCurrency = (value) =>
  46. new Intl.NumberFormat("pt-BR", { style: "currency", currency: "BRL" }).format(value ?? 0);
  47. const columns = [
  48. {
  49. name: "description",
  50. label: "Descrição",
  51. field: "description",
  52. align: "left",
  53. },
  54. {
  55. name: "value",
  56. label: "Valor",
  57. field: "value",
  58. align: "left",
  59. },
  60. {
  61. name: "status",
  62. label: "Status",
  63. field: "status",
  64. align: "left",
  65. },
  66. ];
  67. const statusColor = (status) => {
  68. const map = {
  69. Pago: "positive",
  70. Pendente: "warning",
  71. Cancelado: "negative",
  72. };
  73. return map[status] ?? "grey";
  74. };
  75. </script>
  76. <style scoped lang="scss">
  77. .last-transactions-card {
  78. flex: 1 1 0;
  79. min-width: 220px;
  80. height: 380px;
  81. border-radius: 12px;
  82. box-shadow: 0 0 0 1px #c0c0c0c0 !important;
  83. padding: 16px 20px;
  84. overflow: hidden;
  85. }
  86. .transactions-table {
  87. border-radius: 8px;
  88. }
  89. </style>