perf: refs #7134 currencies fetch

This commit is contained in:
Javier Segarra 2025-01-21 14:53:48 +01:00
parent b2b36289c7
commit ea9e099523
1 changed files with 17 additions and 7 deletions

View File

@ -12,6 +12,7 @@ import VnTable from 'src/components/VnTable/VnTable.vue';
import InvoiceInDescriptorProxy from 'src/pages/InvoiceIn/Card/InvoiceInDescriptorProxy.vue'; import InvoiceInDescriptorProxy from 'src/pages/InvoiceIn/Card/InvoiceInDescriptorProxy.vue';
import SupplierBalanceFilter from './SupplierBalanceFilter.vue'; import SupplierBalanceFilter from './SupplierBalanceFilter.vue';
import { onMounted } from 'vue'; import { onMounted } from 'vue';
import FetchData from 'src/components/FetchData.vue';
const { t } = useI18n(); const { t } = useI18n();
@ -24,13 +25,10 @@ const tableRef = ref();
const companyId = ref(); const companyId = ref();
const companyUser = ref(user.value.companyFk); const companyUser = ref(user.value.companyFk);
const balances = ref([]); const balances = ref([]);
const userParams = computed(() => { const userParams = ref({
return { supplierId: route.params.id,
supplierId: route.params.id, companyId: companyId.value ?? companyUser.value,
companyId: companyId.value ?? companyUser.value, isBooked: false,
isBooked: false,
currencyFk: 1, // EUR
};
}); });
const columns = computed(() => [ const columns = computed(() => [
@ -114,13 +112,25 @@ async function onFetch(data) {
function round(value) { function round(value) {
return Math.round(value * 100) / 100; return Math.round(value * 100) / 100;
} }
const onFetchCurrencies = (data) => {
const eur = data.find((currency) => currency.code === 'EUR');
userParams.value.currencyFk = eur?.id;
};
</script> </script>
<template> <template>
<QDrawer side="right" :width="265" v-model="stateStore.rightDrawer"> <QDrawer side="right" :width="265" v-model="stateStore.rightDrawer">
<SupplierBalanceFilter data-key="SupplierBalance" /> <SupplierBalanceFilter data-key="SupplierBalance" />
</QDrawer> </QDrawer>
<FetchData
url="Currencies"
:filter="{ fields: ['id', 'code'] }"
sort-by="code"
@on-fetch="onFetchCurrencies"
auto-load
/>
<VnTable <VnTable
v-if="userParams.currencyFk"
ref="tableRef" ref="tableRef"
data-key="SupplierBalance" data-key="SupplierBalance"
url="Suppliers/receipts" url="Suppliers/receipts"