Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

81
Visualizações
Filter in vue computed

I have a dashboard with different leads that are also sorted under different statuses.

For now all the different leads get sorted under the different statuses and it looks like this in my setup(). The changeStatus is for dragging the leads in to other statuses. (They are sorted under different "cards")

    const leads = ref<Leads[]>([])
    const sellerFilter = ref<number | null>(null)


    const statuses = useStore(leadStatuses)

    const leadsByStatus = computed(() =>
        Object.assign(
            fromPairs(statuses.value.map(s => [s.id, []])),
            groupBy(
                leads.value.filter(lead => lead.id),
                'idStatus',
            ),
        ),
    )

    const changeStatus = async (evt: any) => {
        const idStatus = evt.target.getAttribute('status-id')
        const id = evt.item.getAttribute('lead-id')

        await ('lead/update', { id }, { idStatus })
        const lead = find(leads.value, ['id', parseInt(id)])
        assert(!!lead)
        lead.idStatus = idStatus
    }

This works just fine. But now I want to add the possibility to filter on the seller assigned to the lead and I can't manage to work together in the opportunities computed. I have a seller-select that I'm importing and using in the template:

        <user-select
            v-model="sellerFilter"
            :label="$tc('Filter on sales person')"
        />

I've tried doing something like this in the "opportunities" computed:

    const leadsByStatus = computed(() => {
        function filterOnSeller(filterSeller: number | null, leadSeller: number | null) {
            return filterSeller && filterSeller !== dealSeller
        }
        return Object.assign(
            fromPairs(statuses.value.map(s => [s.id, []])),
            groupBy(
                opportunities.value.filter(lead => {
                    if (filterSeller(sellerFilter.value, lead.salesId)) {
                        return true
                    }
                    return lead.salesId
                }),
                'idStatus',
            ),
        )
    })

But I can't manage to get above work when I want to make the filter on seller part work.

In the template I'm also using a v-for to iterate through all the leads:

                <v-card
                    v-for="lead in leadsByStatus[status.id]"
                    :key="lead.id"
                   
                    :lead-id="lead.id"
                >

So if there's anyone that's know what I'm doing wrong? :)

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda