Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

80
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda