I'm trying do a array filtering with multiples values, when i select the first filter(ALAMEDA CLUBE RESIDENCIAL(BEERSERV-01, BEERSERV-02) passing through that select the machine value(BEERSERV-01,BEERSERV-02) i receive in my filtered array the product linked with BEERSERV-01, and linked with BEERSERV-02. But if i add the another value in filter(PARQUE ECOVILLE(BEERSERV-03)) my array will be null(because when pass all theses values in filtering, will be nufied because isn't tested one by one. How i can fix that?
public async gerarListaPDV(){
let filtered = []
this.filterarr = []
console.log(this.filterarr.length)
for(var x in this.pdvs_selecionados){
for(var y in this.pdvs_selecionados[x].equipamentos){
this.filterarr.push(this.pdvs_selecionados[x].equipamentos[y].nome_equipamento)
}
}
this.lista_vendas_filtrada.filter((obj)=>{
if(this.filterarr.includes(obj.equipamento)){
console.log(this.filterarr)
filtered.push(obj)
}
})
this.exibir_por_pdv = filtered
console.log(this.filterarr)
if(this.filterarr.length >= 1){
this.lista_vendas_filtrada = this.exibir_por_pdv
}
else{
this.lista_vendas_filtrada = this.lista_vendas_constante
}
this.carregarRelatorioTotal(true)
}
your problem statement is hard to understand. I don't know what your issue is, but based on your code , there's an issue:
you're calling filter
on this.lista_vendas_filtrada
, but you're not returning anything in the callback. Please take a look at what filter
method does - link
filter
callback should return true
if you want to keep the value in the new array that it returns, or false
if you want to remove it from the new array it returns . filter
does not modify the array it's called on.
Hope this helps. If you need more concrete answer, please edit your question to be minimal reproduceable example , write code in English, and format your question so it's not all in one unformatted paragraph.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.