Merge branch 'develop' into Vit
This commit is contained in:
commit
d38e3721b6
1 file changed
+23
-4
@@ -1,5 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-container>
|
<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-tabs v-model="activeTab" class="mb-4">
|
||||||
<v-tab
|
<v-tab
|
||||||
v-for="(question, questionIndex) in questions"
|
v-for="(question, questionIndex) in questions"
|
||||||
@@ -24,9 +26,8 @@
|
|||||||
<v-tabs-window v-model="activeTab">
|
<v-tabs-window v-model="activeTab">
|
||||||
<v-tabs-window-item v-for="(question, questionIndex) in questions" :key="questionIndex">
|
<v-tabs-window-item v-for="(question, questionIndex) in questions" :key="questionIndex">
|
||||||
<v-row>
|
<v-row>
|
||||||
<!-- Победитель -->
|
|
||||||
<v-col cols="12">
|
<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">
|
<v-card-title class="d-flex ga-2 align-center">
|
||||||
<h4 class="text-teal-darken-4">Победитель:</h4>
|
<h4 class="text-teal-darken-4">Победитель:</h4>
|
||||||
<h3>{{ getWinner(question).employee?.fio || getWinner(question).name }} 🏆</h3>
|
<h3>{{ getWinner(question).employee?.fio || getWinner(question).name }} 🏆</h3>
|
||||||
@@ -54,6 +55,13 @@
|
|||||||
<small>Должность: {{ answer.employee ? answer.employee.post : '' }}</small>
|
<small>Должность: {{ answer.employee ? answer.employee.post : '' }}</small>
|
||||||
</template>
|
</template>
|
||||||
</p>
|
</p>
|
||||||
|
<v-progress-linear
|
||||||
|
:model-value="getPercentage(answer.count, question)"
|
||||||
|
height="10"
|
||||||
|
color="teal-darken-4"
|
||||||
|
striped
|
||||||
|
rounded
|
||||||
|
/>
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
</v-list>
|
</v-list>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
@@ -80,6 +88,9 @@ export default {
|
|||||||
const activeTab = ref(0);
|
const activeTab = ref(0);
|
||||||
const questions = computed(() => props.data.questions || []);
|
const questions = computed(() => props.data.questions || []);
|
||||||
|
|
||||||
|
const title = props.data.name;
|
||||||
|
const description = props.data.description;
|
||||||
|
|
||||||
const getWinner = (question) => {
|
const getWinner = (question) => {
|
||||||
return question.answers.reduce(
|
return question.answers.reduce(
|
||||||
(max, answer) => (answer.count > max.count ? answer : max),
|
(max, answer) => (answer.count > max.count ? answer : max),
|
||||||
@@ -105,10 +116,15 @@ export default {
|
|||||||
const lastDigit = count % 10;
|
const lastDigit = count % 10;
|
||||||
if (lastDigit === 1) currentVote = 'голос'
|
if (lastDigit === 1) currentVote = 'голос'
|
||||||
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
|
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 {
|
return {
|
||||||
activeTab,
|
activeTab,
|
||||||
questions,
|
questions,
|
||||||
@@ -116,7 +132,10 @@ export default {
|
|||||||
getTopResults,
|
getTopResults,
|
||||||
truncateText,
|
truncateText,
|
||||||
shouldShowTooltip,
|
shouldShowTooltip,
|
||||||
voteCount
|
voteCount,
|
||||||
|
title,
|
||||||
|
description,
|
||||||
|
getPercentage
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user