#5447 changed warehouse out filter #397

Merged
jon merged 20 commits from 5447-travelExtraCommunity into dev 2024-06-28 12:57:03 +00:00
1 changed files with 9 additions and 7 deletions
Showing only changes of commit 45a6c49907 - Show all commits

View File

@ -36,24 +36,26 @@ const decrement = (paramsObj, key) => {
paramsObj[key]--; paramsObj[key]--;
}; };
const warehouseAm = ref([]); const warehousesAm = ref([]);
const warehouses = async () => { const warehouses = async () => {
const warehouses = await axios.get('Warehouses'); const warehouses = await axios.get('Warehouses');
const countries = await axios.get('Countries'); const countries = await axios.get('Countries');
const continents = await axios.get('Continents'); const continents = await axios.get('Continents', {
params: {
filter: { where: { code: 'AM' } },
},
});
const countryContinent = countries.data.reduce((acc, c) => { const countryContinent = countries.data.reduce((acc, c) => {
acc[c.id] = c.continentFk; acc[c.id] = c.continentFk;
return acc; return acc;
}, {}); }, {});
const continentAMId = continents.data.find((continent) => continent.code === 'AM').id;
const countriesInAM = Object.keys(countryContinent).filter( const countriesInAM = Object.keys(countryContinent).filter(
(countryId) => countryContinent[countryId] === continentAMId.toString() (countryId) => countryContinent[countryId] === continents.data[0].id.toString()
); );
warehouseAm.value = warehouses.data.filter((w) => warehousesAm.value = warehouses.data.filter((w) =>
countriesInAM.includes(w.countryFk.toString()) countriesInAM.includes(w.countryFk.toString())
jgallego marked this conversation as resolved
Review

Consolelog?

Consolelog?
); );
}; };
@ -178,7 +180,7 @@ warehouses();
:label="t('params.warehouseOutFk')" :label="t('params.warehouseOutFk')"
v-model="params.warehouseOutFk" v-model="params.warehouseOutFk"
@update:model-value="searchFn()" @update:model-value="searchFn()"
:options="warehouseAm" :options="warehousesAm"
option-value="id" option-value="id"
option-label="name" option-label="name"
hide-selected hide-selected