update values in loop

This commit is contained in:
Kseninia Mikhaylova 2024-08-22 16:28:15 +03:00
parent ecc886689e
commit 5404f44fbc
2 changed files with 6 additions and 3 deletions

View File

@ -44,7 +44,7 @@ class TgStatItemSerializer(serializers.Serializer):
return None
if isinstance(obj.get("location__parent"), list):
location_parent_ids = obj.get("location__parent")
queryset = Territory.objects.filter(id__in=obj.get("location__parent"))
queryset = Territory.objects.filter(id__in=obj.get("location__parent")).values('name')
for q in queryset:
q.count = location_parent_ids.count(q.id)
serializer = TerritorySerializer(queryset, many=True)

View File

@ -4,7 +4,7 @@ const data = ref([] as RootObject[])
data.value = await apiCall<RootObject[]>(`stat/?type=location`, 'get')
interface RootObject {
location: Location;
location: Location | Location[];
inv_count: number;
tmc: Tmc[];
}
@ -42,7 +42,10 @@ const getData = async () => {
</UCard>
<UCard v-for="item in data" class="col-span-6" v-if="data && !isOrg">
<template #header>
{{ item.tmc[0].tmc__name }} <UBadge>{{ item.tmc[0].count }}</UBadge>
<template v-for="el in item.tmc">
{{ el.tmc__name }}, всего {{ el.count }}
</template>
<UBadge>{{ item.inv_count }}</UBadge>
</template>
<UTable :rows="item.location" />
</UCard>