forked from verdnatura/salix-front
refactor: refs #5447 changed warehouse filter
This commit is contained in:
parent
a8fef3fa84
commit
1558b600be
|
@ -7,6 +7,7 @@ import VnFilterPanel from 'src/components/ui/VnFilterPanel.vue';
|
|||
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
import VnInputDate from 'components/common/VnInputDate.vue';
|
||||
import axios from 'axios';
|
||||
|
||||
const { t } = useI18n();
|
||||
const props = defineProps({
|
||||
|
@ -34,6 +35,30 @@ const decrement = (paramsObj, key) => {
|
|||
|
||||
paramsObj[key]--;
|
||||
};
|
||||
|
||||
const warehouseAm = ref([]);
|
||||
const warehouses = async () => {
|
||||
const warehouses = await axios.get('Warehouses');
|
||||
const countries = await axios.get('Countries');
|
||||
const continents = await axios.get('Continents');
|
||||
|
||||
const countryContinent = countries.data.reduce((acc, c) => {
|
||||
acc[c.id] = c.continentFk;
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
const continentAMId = continents.data.find((continent) => continent.code === 'AM').id;
|
||||
|
||||
const countriesInAM = Object.keys(countryContinent).filter(
|
||||
(countryId) => countryContinent[countryId] === continentAMId.toString()
|
||||
);
|
||||
|
||||
warehouseAm.value = warehouses.data.filter((w) =>
|
||||
countriesInAM.includes(w.countryFk.toString())
|
||||
);
|
||||
console.log('warehouseAm: ', warehouseAm.value);
|
||||
};
|
||||
warehouses();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -150,6 +175,20 @@ const decrement = (paramsObj, key) => {
|
|||
<QItem>
|
||||
<QItemSection>
|
||||
<VnSelect
|
||||
v-if="params.continent === 'AM'"
|
||||
:label="t('params.warehouseOutFk')"
|
||||
v-model="params.warehouseOutFk"
|
||||
@update:model-value="searchFn()"
|
||||
:options="warehouseAm"
|
||||
option-value="id"
|
||||
option-label="name"
|
||||
hide-selected
|
||||
dense
|
||||
outlined
|
||||
rounded
|
||||
/>
|
||||
<VnSelect
|
||||
v-else
|
||||
:label="t('params.warehouseOutFk')"
|
||||
v-model="params.warehouseOutFk"
|
||||
@update:model-value="searchFn()"
|
||||
|
|
Loading…
Reference in New Issue