Merge branch 'develop' into Vit

This commit is contained in:
Nukeap committed 2025-01-21 16:59:36 +03:00
commit d38e3721b6
1 file changed
+25 -6
+25 -6
View File
@@ -1,5 +1,7 @@
<template>
<v-container>
<v-card-title class="text-subtitle-1">Результат голосования: {{ title }}</v-card-title>
<v-card-subtitle class="text-subtitle-2">{{ description }}</v-card-subtitle>
<v-tabs v-model="activeTab" class="mb-4">
<v-tab
v-for="(question, questionIndex) in questions"
@@ -24,9 +26,8 @@
<v-tabs-window v-model="activeTab">
<v-tabs-window-item v-for="(question, questionIndex) in questions" :key="questionIndex">
<v-row>
<!-- Победитель -->
<v-col cols="12">
<h3>{{ question.name }}</h3>
<h3 class="text-center">{{ question.name }}</h3>
<v-card-title class="d-flex ga-2 align-center">
<h4 class="text-teal-darken-4">Победитель:</h4>
<h3>{{ getWinner(question).employee?.fio || getWinner(question).name }} 🏆</h3>
@@ -37,7 +38,7 @@
</v-col>
<v-col cols="12">
<v-card class="mb-4">
<v-card-title class="text-teal-darken-3">Топ {{getTopResults(question).length}}</v-card-title>
<v-card-title class="text-teal-darken-3">Топ {{ getTopResults(question).length }}</v-card-title>
<v-card-text>
<v-list style="max-height: 40vh; overflow-y: auto;">
<v-list-item
@@ -46,7 +47,7 @@
>
<p>
<strong>{{ answer.employee ? answer.employee.fio : answer.name }}</strong>: {{ answer.count }}
{{voteCount(answer.count)}}
{{ voteCount(answer.count) }}
<template v-if="answer.employee">
<br/>
<small>Отдел: {{ answer.employee ? answer.employee.department : '' }}</small>
@@ -54,6 +55,13 @@
<small>Должность: {{ answer.employee ? answer.employee.post : '' }}</small>
</template>
</p>
<v-progress-linear
:model-value="getPercentage(answer.count, question)"
height="10"
color="teal-darken-4"
striped
rounded
/>
</v-list-item>
</v-list>
</v-card-text>
@@ -80,6 +88,9 @@ export default {
const activeTab = ref(0);
const questions = computed(() => props.data.questions || []);
const title = props.data.name;
const description = props.data.description;
const getWinner = (question) => {
return question.answers.reduce(
(max, answer) => (answer.count > max.count ? answer : max),
@@ -105,10 +116,15 @@ export default {
const lastDigit = count % 10;
if (lastDigit === 1) currentVote = 'голос'
if (lastDigit > 1) currentVote = 'голоса'
if (lastDigit > 4 || count === 0) currentVote = 'голосов'
if (lastDigit > 4 || count === 0 || count === 11 || count === 12 || count === 13 || count === 14) currentVote = 'голосов'
return currentVote
}
const getPercentage = (count, question) => {
const totalVotes = question.answers.reduce((sum, answer) => sum + answer.count, 0);
return totalVotes > 0 ? (count / totalVotes) * 100 : 0;
};
return {
activeTab,
questions,
@@ -116,7 +132,10 @@ export default {
getTopResults,
truncateText,
shouldShowTooltip,
voteCount
voteCount,
title,
description,
getPercentage
};
},
};