0
0
Fork 0

Se asigno directamente la data fetcheada desde los componentes FetchData y se borró las funciones que se usaban para esto

This commit is contained in:
William Buezas 2023-12-15 16:52:46 -03:00
parent c4af2e3cf7
commit 5a1d4e90c9
3 changed files with 32 additions and 46 deletions

View File

@ -57,18 +57,6 @@ const getStatus = computed({
}, },
}); });
const onFetchCompanies = (companies) => {
companiesOptions.value = [...companies];
};
const onFetchPrinters = (printers) => {
printersOptions.value = [...printers];
};
const onFetchClients = (clients) => {
clientsOptions.value = [...clients];
};
onMounted(async () => { onMounted(async () => {
await invoiceOutGlobalStore.init(); await invoiceOutGlobalStore.init();
formData.value = { ...formInitialData.value }; formData.value = { ...formInitialData.value };
@ -76,9 +64,13 @@ onMounted(async () => {
</script> </script>
<template> <template>
<FetchData url="Companies" @on-fetch="(data) => onFetchCompanies(data)" auto-load /> <FetchData
<FetchData url="Printers" @on-fetch="(data) => onFetchPrinters(data)" auto-load /> url="Companies"
<FetchData url="Clients" @on-fetch="(data) => onFetchClients(data)" auto-load /> @on-fetch="(data) => (companiesOptions = data)"
auto-load
/>
<FetchData url="Printers" @on-fetch="(data) => (printersOptions = data)" auto-load />
<FetchData url="Clients" @on-fetch="(data) => (clientsOptions = data)" auto-load />
<QForm <QForm
v-if="!initialDataLoading && optionsInitialData" v-if="!initialDataLoading && optionsInitialData"

View File

@ -1,5 +1,5 @@
<script setup> <script setup>
import { reactive } from 'vue'; import { reactive, ref } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import FetchData from 'components/FetchData.vue'; import FetchData from 'components/FetchData.vue';
@ -16,16 +16,10 @@ const props = defineProps({
}, },
}); });
const filtersOptions = reactive({ const warehousesOptions = ref([]);
warehouses: [], const continentsOptions = ref([]);
continents: [], const agenciesOptions = ref([]);
agencies: [], const suppliersOptions = ref([]);
suppliers: [],
});
const updateFilterOptions = (data, optionKey) => {
filtersOptions[optionKey] = [...data];
};
const add = (paramsObj, key) => { const add = (paramsObj, key) => {
if (paramsObj[key] === undefined) { if (paramsObj[key] === undefined) {
@ -45,22 +39,22 @@ const decrement = (paramsObj, key) => {
<template> <template>
<FetchData <FetchData
url="Warehouses" url="Warehouses"
@on-fetch="(data) => updateFilterOptions(data, 'warehouses')" @on-fetch="(data) => (warehousesOptions = data)"
auto-load auto-load
/> />
<FetchData <FetchData
url="Continents" url="Continents"
@on-fetch="(data) => updateFilterOptions(data, 'continents')" @on-fetch="(data) => (continentsOptions = data)"
auto-load auto-load
/> />
<FetchData <FetchData
url="AgencyModes" url="AgencyModes"
@on-fetch="(data) => updateFilterOptions(data, 'agencies')" @on-fetch="(data) => (agenciesOptions = data)"
auto-load auto-load
/> />
<FetchData <FetchData
url="Suppliers" url="Suppliers"
@on-fetch="(data) => updateFilterOptions(data, 'suppliers')" @on-fetch="(data) => (suppliersOptions = data)"
auto-load auto-load
/> />
@ -123,7 +117,7 @@ const decrement = (paramsObj, key) => {
<VnSelectFilter <VnSelectFilter
:label="t('params.agencyModeFk')" :label="t('params.agencyModeFk')"
v-model="params.agencyModeFk" v-model="params.agencyModeFk"
:options="filtersOptions.agencies" :options="agenciesOptions"
option-value="agencyFk" option-value="agencyFk"
option-label="name" option-label="name"
hide-selected hide-selected
@ -156,7 +150,7 @@ const decrement = (paramsObj, key) => {
<VnSelectFilter <VnSelectFilter
:label="t('params.warehouseOutFk')" :label="t('params.warehouseOutFk')"
v-model="params.warehouseOutFk" v-model="params.warehouseOutFk"
:options="filtersOptions.warehouses" :options="warehousesOptions"
option-value="id" option-value="id"
option-label="name" option-label="name"
hide-selected hide-selected
@ -171,7 +165,7 @@ const decrement = (paramsObj, key) => {
<VnSelectFilter <VnSelectFilter
:label="t('params.warehouseInFk')" :label="t('params.warehouseInFk')"
v-model="params.warehouseInFk" v-model="params.warehouseInFk"
:options="filtersOptions.warehouses" :options="warehousesOptions"
option-value="id" option-value="id"
option-label="name" option-label="name"
hide-selected hide-selected
@ -186,7 +180,7 @@ const decrement = (paramsObj, key) => {
<VnSelectFilter <VnSelectFilter
:label="t('supplier.pageTitles.supplier')" :label="t('supplier.pageTitles.supplier')"
v-model="params.cargoSupplierFk" v-model="params.cargoSupplierFk"
:options="filtersOptions.suppliers" :options="suppliersOptions"
option-value="id" option-value="id"
option-label="name" option-label="name"
hide-selected hide-selected
@ -201,7 +195,7 @@ const decrement = (paramsObj, key) => {
<VnSelectFilter <VnSelectFilter
:label="t('params.continent')" :label="t('params.continent')"
v-model="params.continent" v-model="params.continent"
:options="filtersOptions.continents" :options="continentsOptions"
option-value="code" option-value="code"
option-label="name" option-label="name"
hide-selected hide-selected

View File

@ -24,8 +24,8 @@ const newTravelForm = reactive({
}); });
const agenciesOptions = ref([]); const agenciesOptions = ref([]);
const viewAction = ref();
const warehousesOptions = ref([]); const warehousesOptions = ref([]);
const viewAction = ref();
onBeforeMount(() => { onBeforeMount(() => {
// Esto nos permite decirle a FormModel si queremos observar los cambios o no // Esto nos permite decirle a FormModel si queremos observar los cambios o no
@ -43,19 +43,19 @@ onBeforeMount(() => {
} }
} }
}); });
const onFetchAgencies = (agencies) => {
agenciesOptions.value = [...agencies];
};
const onFetchWarehouses = (warehouses) => {
warehousesOptions.value = [...warehouses];
};
</script> </script>
<template> <template>
<FetchData url="AgencyModes" @on-fetch="(data) => onFetchAgencies(data)" auto-load /> <FetchData
<FetchData url="Warehouses" @on-fetch="(data) => onFetchWarehouses(data)" auto-load /> url="AgencyModes"
@on-fetch="(data) => (agenciesOptions = data)"
auto-load
/>
<FetchData
url="Warehouses"
@on-fetch="(data) => (warehousesOptions = data)"
auto-load
/>
<QPage> <QPage>
<QToolbar class="bg-vn-dark"> <QToolbar class="bg-vn-dark">
<div id="st-data"></div> <div id="st-data"></div>