|
|
@@ -3,19 +3,15 @@
|
|
|
v-model:rows="rows"
|
|
|
:columns="columns"
|
|
|
title="Configurações TBR"
|
|
|
- description="faixas"
|
|
|
+ description="configurações"
|
|
|
:female="false"
|
|
|
:no-api-call="true"
|
|
|
:show-search-field="true"
|
|
|
:add-item="true"
|
|
|
@on-add-item="onAdd"
|
|
|
>
|
|
|
- <template #body-cell-year="{ row }">
|
|
|
- <q-td>{{ formatMonthRange(row.start_month, row.end_month) }}</q-td>
|
|
|
- </template>
|
|
|
-
|
|
|
- <template #body-cell-tbr="{ row }">
|
|
|
- <q-td>{{ formatPercentage(row.royalties_percentage) }}</q-td>
|
|
|
+ <template #body-cell-tbr_value="{ row }">
|
|
|
+ <q-td>{{ formatCurrency(row.tbr_value) }}</q-td>
|
|
|
</template>
|
|
|
|
|
|
<template #body-cell-royalties="{ row }">
|
|
|
@@ -27,9 +23,7 @@
|
|
|
</template>
|
|
|
|
|
|
<template #body-cell-maintenance="{ row }">
|
|
|
- <q-td align="center">{{
|
|
|
- formatPercentage(row.maintenance_percentage)
|
|
|
- }}</q-td>
|
|
|
+ <q-td>{{ formatPercentage(row.maintenance_percentage) }}</q-td>
|
|
|
</template>
|
|
|
|
|
|
<template #body-cell-actions>
|
|
|
@@ -45,62 +39,44 @@
|
|
|
|
|
|
<script setup>
|
|
|
import { ref, onMounted } from "vue";
|
|
|
+import { useQuasar } from "quasar";
|
|
|
import DefaultTable from "src/components/defaults/DefaultTable.vue";
|
|
|
-import {
|
|
|
- getRoyaltiesBaseBrackets,
|
|
|
- getFnmBaseBrackets,
|
|
|
- getMaintenanceBaseBrackets,
|
|
|
-} from "src/api/tbr";
|
|
|
+import CreateTbrDialog from "src/pages/tbr/components/CreateTbrDialog.vue";
|
|
|
+import { getTbrs } from "src/api/tbr";
|
|
|
|
|
|
+const $q = useQuasar();
|
|
|
const rows = ref([]);
|
|
|
|
|
|
const columns = [
|
|
|
- { name: "id", label: "ID", field: "id", align: "center" },
|
|
|
- { name: "year", label: "Ano", field: "start_month", align: "left" },
|
|
|
- { name: "tbr", label: "TBR", field: "royalties_percentage", align: "left" },
|
|
|
- {
|
|
|
- name: "royalties",
|
|
|
- label: "Royalties",
|
|
|
- field: "royalties_percentage",
|
|
|
- align: "left",
|
|
|
- },
|
|
|
+ { 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: "fnm", label: "FNM", field: "fnm_percentage", align: "left" },
|
|
|
- {
|
|
|
- name: "maintenance",
|
|
|
- label: "Manutenção",
|
|
|
- field: "maintenance_percentage",
|
|
|
- align: "center",
|
|
|
- },
|
|
|
+ { 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)}%`;
|
|
|
}
|
|
|
|
|
|
-function formatMonthRange(start, end) {
|
|
|
- return end ? `Mês ${start} - ${end}` : `Mês ${start}+`;
|
|
|
+async function loadData() {
|
|
|
+ rows.value = await getTbrs();
|
|
|
}
|
|
|
|
|
|
-onMounted(async () => {
|
|
|
- const [royalties, fnm, maintenance] = await Promise.all([
|
|
|
- getRoyaltiesBaseBrackets(),
|
|
|
- getFnmBaseBrackets(),
|
|
|
- getMaintenanceBaseBrackets(),
|
|
|
- ]);
|
|
|
-
|
|
|
- rows.value = royalties.map((r, i) => ({
|
|
|
- id: r.id,
|
|
|
- start_month: r.start_month,
|
|
|
- end_month: r.end_month,
|
|
|
- royalties_percentage: r.percentage,
|
|
|
- fnm_percentage: fnm[i]?.percentage ?? null,
|
|
|
- maintenance_percentage: maintenance[i]?.percentage ?? null,
|
|
|
- }));
|
|
|
-});
|
|
|
-
|
|
|
function onAdd() {
|
|
|
- // TODO
|
|
|
+ $q.dialog({ component: CreateTbrDialog }).onOk(() => loadData());
|
|
|
}
|
|
|
+
|
|
|
+onMounted(loadData);
|
|
|
</script>
|