update values in loop
This commit is contained in:
parent
b45d0029ae
commit
f63a9ef6b3
|
@ -22,7 +22,7 @@ class TmcElementSerializer(serializers.Serializer):
|
||||||
|
|
||||||
|
|
||||||
class TerritorySerializer(serializers.Serializer):
|
class TerritorySerializer(serializers.Serializer):
|
||||||
id = serializers.IntegerField(required=False)
|
id = serializers.IntegerField()
|
||||||
name = serializers.CharField()
|
name = serializers.CharField()
|
||||||
count = serializers.IntegerField(required=False)
|
count = serializers.IntegerField(required=False)
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ class TgStatItemSerializer(serializers.Serializer):
|
||||||
return None
|
return None
|
||||||
if isinstance(obj.get("location__parent"), list):
|
if isinstance(obj.get("location__parent"), list):
|
||||||
location_parent_ids = obj.get("location__parent")
|
location_parent_ids = obj.get("location__parent")
|
||||||
queryset = Territory.objects.filter(id__in=obj.get("location__parent")).values('name')
|
queryset = Territory.objects.filter(id__in=obj.get("location__parent"))
|
||||||
for q in queryset:
|
for q in queryset:
|
||||||
q.count = location_parent_ids.count(q.id)
|
q.count = location_parent_ids.count(q.id)
|
||||||
serializer = TerritorySerializer(queryset, many=True)
|
serializer = TerritorySerializer(queryset, many=True)
|
||||||
|
|
|
@ -154,8 +154,7 @@ class TmcStatViewset(viewsets.ViewSet):
|
||||||
tmc=ArrayAgg("tmc"),
|
tmc=ArrayAgg("tmc"),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
logger.info(queryset)
|
# logger.info(queryset)
|
||||||
# logger.info(TgItem.objects.all().values())
|
# logger.info(TgItem.objects.all().values())
|
||||||
serializer = TgStatItemSerializer(queryset, many=True)
|
serializer = TgStatItemSerializer(queryset, many=True)
|
||||||
return Response(serializer.data)
|
return Response(serializer.data)
|
||||||
# return Response()
|
|
||||||
|
|
|
@ -34,20 +34,21 @@ const getData = async () => {
|
||||||
<UButton :disabled="!isOrg" @click="getData">По продуктам</UButton>
|
<UButton :disabled="!isOrg" @click="getData">По продуктам</UButton>
|
||||||
</UButtonGroup>
|
</UButtonGroup>
|
||||||
</div>
|
</div>
|
||||||
<UCard v-for="item in data" class="col-span-4" v-if="data && isOrg">
|
<UCard v-for="item in data" class="col-span-4" v-if="data && isOrg == true">
|
||||||
<template #header>
|
<template #header>
|
||||||
{{ item.location.name }} <UBadge>{{ item.inv_count }}</UBadge>
|
{{ item.location.name }} <UBadge>{{ item.inv_count }}</UBadge>
|
||||||
</template>
|
</template>
|
||||||
<UTable :rows="item.tmc" />
|
<UTable :rows="item.tmc" />
|
||||||
</UCard>
|
</UCard>
|
||||||
<UCard v-for="item in data" class="col-span-6" v-if="data && !isOrg">
|
<UCard v-for="item in data" class="col-span-6" v-if="data && isOrg == false">
|
||||||
<template #header>
|
<template #header>
|
||||||
<template v-for="el in item.tmc">
|
<template v-for="el in item.tmc">
|
||||||
{{ el.tmc__name }}, всего {{ el.count }}
|
{{ el.tmc__name }}, всего {{ el.count }}
|
||||||
</template>
|
</template>
|
||||||
<UBadge>{{ item.inv_count }}</UBadge>
|
<UBadge>{{ item.inv_count }}</UBadge>
|
||||||
</template>
|
</template>
|
||||||
<UTable :rows="item.location" />
|
<UTable :rows="item.location"
|
||||||
|
:columns="[{ key: 'name', label: 'name' }, { key: 'count', label: 'count' }]" />
|
||||||
</UCard>
|
</UCard>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
Loading…
Reference in New Issue