|
|
@@ -11,7 +11,7 @@
|
|
|
@on-add-item="onAdd"
|
|
|
>
|
|
|
<template #body-cell-tbr_value="{ row }">
|
|
|
- <q-td>{{ formatCurrency(row.tbr_value) }}</q-td>
|
|
|
+ <q-td>{{ formatToBRLCurrency(row.tbr_value) }}</q-td>
|
|
|
</template>
|
|
|
|
|
|
<template #body-cell-royalties="{ row }">
|
|
|
@@ -26,11 +26,18 @@
|
|
|
<q-td>{{ formatPercentage(row.maintenance_percentage) }}</q-td>
|
|
|
</template>
|
|
|
|
|
|
- <template #body-cell-actions>
|
|
|
+ <template #body-cell-actions="{ row }">
|
|
|
<q-td align="center">
|
|
|
<div class="row no-wrap" style="gap: 4px">
|
|
|
<q-btn flat round dense icon="mdi-eye-outline" size="sm" />
|
|
|
- <q-btn flat round dense icon="mdi-file-edit-outline" size="sm" />
|
|
|
+ <q-btn
|
|
|
+ flat
|
|
|
+ round
|
|
|
+ dense
|
|
|
+ icon="mdi-file-edit-outline"
|
|
|
+ size="sm"
|
|
|
+ @click="onEdit(row)"
|
|
|
+ />
|
|
|
</div>
|
|
|
</q-td>
|
|
|
</template>
|
|
|
@@ -41,8 +48,9 @@
|
|
|
import { ref, onMounted } from "vue";
|
|
|
import { useQuasar } from "quasar";
|
|
|
import DefaultTable from "src/components/defaults/DefaultTable.vue";
|
|
|
-import CreateTbrDialog from "src/pages/tbr/components/CreateTbrDialog.vue";
|
|
|
+import AddEditTbrDialog from "src/pages/tbr/components/AddEditTbrDialog.vue";
|
|
|
import { getTbrs } from "src/api/tbr";
|
|
|
+import { formatToBRLCurrency, formatPercentage } from "src/helpers/utils";
|
|
|
|
|
|
const $q = useQuasar();
|
|
|
const rows = ref([]);
|
|
|
@@ -51,31 +59,34 @@ const columns = [
|
|
|
{ name: "id", label: "ID", field: "id", align: "left" },
|
|
|
{ name: "year", label: "Ano", field: "year", align: "left" },
|
|
|
{ name: "tbr_value", label: "TBR", field: "tbr_value", align: "left" },
|
|
|
- { name: "royalties", label: "Royalties", field: "royalties_percentage", align: "left" },
|
|
|
+ {
|
|
|
+ name: "royalties",
|
|
|
+ label: "Royalties",
|
|
|
+ field: "royalties_percentage",
|
|
|
+ align: "left",
|
|
|
+ },
|
|
|
{ name: "fnm", label: "FNM", field: "fnm_percentage", align: "left" },
|
|
|
- { name: "maintenance", label: "Manutenção", field: "maintenance_percentage", align: "left" },
|
|
|
+ {
|
|
|
+ name: "maintenance",
|
|
|
+ label: "Manutenção",
|
|
|
+ field: "maintenance_percentage",
|
|
|
+ align: "left",
|
|
|
+ },
|
|
|
{ name: "actions", label: "Ações", field: "actions", align: "center" },
|
|
|
];
|
|
|
|
|
|
-function formatCurrency(value) {
|
|
|
- if (value == null) return "—";
|
|
|
- return new Intl.NumberFormat("pt-BR", {
|
|
|
- minimumFractionDigits: 2,
|
|
|
- maximumFractionDigits: 2,
|
|
|
- }).format(value) + " $";
|
|
|
-}
|
|
|
-
|
|
|
-function formatPercentage(value) {
|
|
|
- if (value == null) return "—";
|
|
|
- return `${(value * 100).toFixed(0)}%`;
|
|
|
-}
|
|
|
-
|
|
|
async function loadData() {
|
|
|
rows.value = await getTbrs();
|
|
|
}
|
|
|
|
|
|
function onAdd() {
|
|
|
- $q.dialog({ component: CreateTbrDialog }).onOk(() => loadData());
|
|
|
+ $q.dialog({ component: AddEditTbrDialog }).onOk(() => loadData());
|
|
|
+}
|
|
|
+
|
|
|
+function onEdit(row) {
|
|
|
+ $q.dialog({ component: AddEditTbrDialog, componentProps: { tbr: row } }).onOk(
|
|
|
+ () => loadData(),
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
onMounted(loadData);
|