реф результатов (одни голоса, одни места)

This commit is contained in:
Denzel committed 2025-01-24 14:29:55 +03:00
1 parent 59eb528db8
commit 9673fdacfa
1 file changed
+16 -3
+16 -3
View File
@@ -1,5 +1,5 @@
<template> <template>
<v-container style="height: 85vh"> <v-container style="height: 85vh;">
<div class="text-end"> <div class="text-end">
<v-btn class="" color="red-darken-1" density="compact" icon="mdi-close-thick" size="small" <v-btn class="" color="red-darken-1" density="compact" icon="mdi-close-thick" size="small"
@click="$emit('closer')"> @click="$emit('closer')">
@@ -172,7 +172,6 @@
v-for="(answer, index) in activeDepartmentResults.filter(el => el.count > 0)" v-for="(answer, index) in activeDepartmentResults.filter(el => el.count > 0)"
:key="index" :key="index"
> >
<p> <p>
<strong class="mr-4">{{ index + 1 }}.</strong> <strong class="mr-4">{{ index + 1 }}.</strong>
<v-avatar v-if="answer.file === null && answer.employee" <v-avatar v-if="answer.file === null && answer.employee"
@@ -272,7 +271,21 @@ export default {
}; };
const getTopResults = (question) => { const getTopResults = (question) => {
return [...question?.answers].sort((a, b) => b.count - a.count); const sortedAnswers = [...question.answers].sort((a, b) => b.count - a.count);
// Присваиваем одинаковые индексы для одинаковых значений count
let rank = 1;
let previousCount = null;
return sortedAnswers.map((answer, index) => {
if (answer.count !== previousCount) {
rank = index + 1;
previousCount = answer.count;
}
return {
...answer,
rank
};
});
}; };
const truncateText = (text, maxLength) => { const truncateText = (text, maxLength) => {