Merge branch 'develop' into Vit

This commit is contained in:
Nukeap committed 2025-01-21 13:00:16 +03:00
commit 264c532915
4 files changed
+50 -17

No files matched your search

+2 -2
View File
@@ -113,7 +113,7 @@ class VoteCreate(APIView):
questions = json.loads(request.data['questions']) questions = json.loads(request.data['questions'])
for count, question_data in enumerate(questions, start=1): for count, question_data in enumerate(questions, start=1):
question_image = questions_files.get(question_data['image']['name']) if 'image' in question_data else None question_image = questions_files.get(question_data['image']['name']) if 'image' in question_data and question_data['image'] is not None else None
question = Question.objects.create( question = Question.objects.create(
name=question_data['text'], name=question_data['text'],
vote=vote, vote=vote,
@@ -123,7 +123,7 @@ class VoteCreate(APIView):
) )
for answer in question_data['answers']: for answer in question_data['answers']:
answer_image = answers_files.get(answer['image']['name']) if 'image' in answer else None answer_image = answers_files.get(answer['image']['name']) if 'image' in answer and answer['image'] is not None else None
Answer.objects.create( Answer.objects.create(
name=answer['text'], name=answer['text'],
file=answer_image, file=answer_image,
@@ -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>
+45 -9
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>
@@ -19,11 +35,9 @@
Количество голосов: {{ getWinner(question)?.count || 0 }} Количество голосов: {{ getWinner(question)?.count || 0 }}
</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">Топ {{getTopResults(question).length}}</v-card-title>
<v-card-text> <v-card-text>
<v-list style="max-height: 40vh; overflow-y: auto;"> <v-list style="max-height: 40vh; overflow-y: auto;">
<v-list-item <v-list-item
@@ -31,11 +45,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 }}
{{voteCount(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 +66,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 +91,32 @@ 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;
};
const voteCount = (count) => {
let currentVote = '';
const lastDigit = count % 10;
if (lastDigit === 1) currentVote = 'голос'
if (lastDigit > 1) currentVote = 'голоса'
if (lastDigit > 4 || count === 0) currentVote = 'голосов'
return currentVote
}
return { return {
activeTab, activeTab,
questions, questions,
getWinner, getWinner,
getTopResults, getTopResults,
truncateText,
shouldShowTooltip,
voteCount
}; };
}, },
}; };
-1
View File
@@ -68,7 +68,6 @@
<v-dialog v-model="resultsModal" max-width="1200px" @click:outside="closeModal"> <v-dialog v-model="resultsModal" max-width="1200px" @click:outside="closeModal">
<v-card> <v-card>
<v-card-title>Результаты голосования: {{ selectedVoting?.title }}</v-card-title>
<VoteResult :data="result"/> <VoteResult :data="result"/>
<v-card-actions> <v-card-actions>
<v-btn @click="closeModal">Закрыть</v-btn> <v-btn @click="closeModal">Закрыть</v-btn>