[ { "title": "Запрашиваемый код детали",
"brands": [ {
"code": "123456",
"name": "FILTR",
"description": "Фильтр масляный",
"positions": [ {
"price": "221 ₽",
"availability": "8 шт."
},{
"price": "236 ₽",
"availability": "2 шт."
} ],
} ],
} ],
props:{
groups: Array,
},
computed: {
filtered() {
let filters = this.filters;
return this.groups.filter((group) => {
let brands = group.brands.filter((brand) => {
if (!filters['brands'].value.includes(brand.name) && filters['brands'].value !== [] && !brand.positions) return false;
let positions = brand.positions.filter(function (position) {
Object.keys(filters).forEach((index) => {
if (index !== 'brands'){
if (!filters[index].value[0] <= parseInt(position[index]) || !filters[index].value[1] >= parseInt(position[index])) {
return false;
}
}
});
return true;
});
return positions !== [];
});
return brands !== [];
});
},
filters() { return this.$store.state.search.filters },
}