This commit is contained in:
Denzel committed 2025-01-21 11:46:28 +03:00
1 parent d551f80c77
commit 0ef6ed21e0
2 files changed
+37 -12

No files matched your search

@@ -32,10 +32,9 @@
</v-stepper-header> </v-stepper-header>
<v-stepper-window class="d-flex flex-column flex-fill"> <v-stepper-window class="d-flex flex-column flex-fill">
<v-stepper-window-item v-for="(question, index) in data.questions" :key="question.numb" <v-stepper-window-item v-for="(question, index) in data.questions" :key="question.numb"
:step="question.numb" :step="question.numb">
class=""> <div>
<div class=""> <h3 class="text-center">{{ question.name }} <span class="text-subtitle-1">(вариантов ответа: {{question.settings.multiChoice}})</span></h3>
<h3 class="text-center">{{ question.name }}</h3>
<v-row> <v-row>
<div class="v-col align-self-start"> <div class="v-col align-self-start">
<v-img :src="question.file" <v-img :src="question.file"
@@ -63,7 +62,6 @@
</template> </template>
</v-list-item> </v-list-item>
</v-list> </v-list>
</div> </div>
</v-row> </v-row>
</div> </div>
+34 -7
View File
@@ -1,8 +1,23 @@
<template> <template>
<v-container> <v-container>
<v-tabs v-model="activeTab" class="mb-4"> <v-tabs v-model="activeTab" class="mb-4">
<v-tab v-for="(question, questionIndex) in questions" :key="questionIndex"> <v-tab
Опрос {{ question.numb }}: {{ question.name || 'Без названия' }} v-for="(question, questionIndex) in questions"
:key="questionIndex"
>
<template v-if="shouldShowTooltip(question.name || 'Без названия', 10)">
<v-tooltip bottom>
<template v-slot:activator="{ props }">
<span v-bind="props">
{{ truncateText(question.name || 'Без названия', 10) }}
</span>
</template>
<span>{{ question.name || 'Без названия' }}</span>
</v-tooltip>
</template>
<template v-else>
<span>{{ truncateText(question.name || 'Без названия', 10) }}</span>
</template>
</v-tab> </v-tab>
</v-tabs> </v-tabs>
@@ -11,6 +26,7 @@
<v-row> <v-row>
<!-- Победитель --> <!-- Победитель -->
<v-col cols="12"> <v-col cols="12">
<h3>{{ 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>
@@ -20,7 +36,6 @@
</v-card-subtitle> </v-card-subtitle>
</v-col> </v-col>
<!-- Топ 10 -->
<v-col cols="12"> <v-col cols="12">
<v-card class="mb-4"> <v-card class="mb-4">
<v-card-title class="text-teal-darken-3">Топ 10</v-card-title> <v-card-title class="text-teal-darken-3">Топ 10</v-card-title>
@@ -31,11 +46,12 @@
:key="answerIndex" :key="answerIndex"
> >
<p> <p>
<strong>{{ answer.employee ? answer.employee.fio : answer.name }}</strong>: {{ answer.count }} голосов <strong>{{ answer.employee ? answer.employee.fio : answer.name }}</strong>: {{ answer.count }}
голосов
<template v-if="answer.employee"> <template v-if="answer.employee">
<br /> <br/>
<small>Отдел: {{ answer.employee ? answer.employee.department : '' }}</small> <small>Отдел: {{ answer.employee ? answer.employee.department : '' }}</small>
<br /> <br/>
<small>Должность: {{ answer.employee ? answer.employee.post : '' }}</small> <small>Должность: {{ answer.employee ? answer.employee.post : '' }}</small>
</template> </template>
</p> </p>
@@ -51,7 +67,7 @@
</template> </template>
<script> <script>
import { computed, ref } from 'vue'; import {computed, ref} from 'vue';
export default { export default {
name: 'VoteResult', name: 'VoteResult',
@@ -76,11 +92,22 @@ export default {
return [...question.answers].sort((a, b) => b.count - a.count).slice(0, 10); return [...question.answers].sort((a, b) => b.count - a.count).slice(0, 10);
}; };
const truncateText = (text, maxLength) => {
if (!text) return '';
return text.length > maxLength ? text.slice(0, maxLength) + '…' : text;
};
const shouldShowTooltip = (text, maxLength) => {
return text && text.length > maxLength;
};
return { return {
activeTab, activeTab,
questions, questions,
getWinner, getWinner,
getTopResults, getTopResults,
truncateText,
shouldShowTooltip
}; };
}, },
}; };