P-98 Результаты голосования
This commit is contained in:
1 parent
f75ec3cd73
commit
3ed8723673
4 files changed
+75
-75
No files matched your search
@@ -49,7 +49,7 @@
|
|||||||
<v-list v-model:selected="result[question.id]" density="compact" select-strategy="leaf" slim style="max-height: 100%; overflow-y: auto;">
|
<v-list v-model:selected="result[question.id]" density="compact" select-strategy="leaf" slim style="max-height: 100%; overflow-y: auto;">
|
||||||
<v-list-item v-for="answer in question.answers" :key="answer.id" :value="answer.id"
|
<v-list-item v-for="answer in question.answers" :key="answer.id" :value="answer.id"
|
||||||
density="compact">
|
density="compact">
|
||||||
{{ answer.name }}
|
{{ answer.employee?.fio || answer.name }}
|
||||||
<template v-slot:prepend="{ isSelected }">
|
<template v-slot:prepend="{ isSelected }">
|
||||||
<v-list-item-action start>
|
<v-list-item-action start>
|
||||||
<v-checkbox-btn :model-value="isSelected"></v-checkbox-btn>
|
<v-checkbox-btn :model-value="isSelected"></v-checkbox-btn>
|
||||||
|
|||||||
@@ -4,14 +4,15 @@
|
|||||||
<v-tooltip bottom>
|
<v-tooltip bottom>
|
||||||
<template v-slot:activator="{ props }">
|
<template v-slot:activator="{ props }">
|
||||||
<span
|
<span
|
||||||
v-bind="props"
|
style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"
|
||||||
style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">
|
v-bind="props">
|
||||||
{{ voteCard.name }}
|
{{ voteCard.name }}
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
<span>{{ voteCard.name }}</span>
|
<span>{{ voteCard.name }}</span>
|
||||||
</v-tooltip>
|
</v-tooltip>
|
||||||
<v-btn v-if="user.id === voteCard.author || user.is_superuser" flat size="medium" @click="$emit('openEditVoteModal', voteCard)">
|
<v-btn v-if="user.id === voteCard.author || user.is_superuser" flat size="medium"
|
||||||
|
@click="$emit('openEditVoteModal', voteCard)">
|
||||||
<v-icon color="orange-lighten-1">mdi-pencil</v-icon>
|
<v-icon color="orange-lighten-1">mdi-pencil</v-icon>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
@@ -33,17 +34,20 @@
|
|||||||
<v-tooltip bottom>
|
<v-tooltip bottom>
|
||||||
<template v-slot:activator="{ props }">
|
<template v-slot:activator="{ props }">
|
||||||
<span
|
<span
|
||||||
v-bind="props"
|
style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"
|
||||||
style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">
|
v-bind="props">
|
||||||
{{ voteCard.description }}
|
{{ voteCard.description }}
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
<span>{{ voteCard.description }}</span>
|
<span>{{ voteCard.description }}</span>
|
||||||
</v-tooltip>
|
</v-tooltip>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
<Timer v-if ="!isFinished" :voteTime="{ dateend: voteCard.dateend, datestart: voteCard.datestart }"
|
<Timer v-if="!isFinished" :voteTime="{ dateend: voteCard.dateend, datestart: voteCard.datestart }"
|
||||||
@changeBtn="(time) => timeChange = time"/>
|
@changeBtn="(time) => timeChange = time"/>
|
||||||
<div class="font-weight-bold text-center" v-else> Завершено: {{ new Date(voteCard.dateend).toLocaleDateString() }}</div>
|
<div v-else class="font-weight-bold text-center"> Завершено: {{
|
||||||
|
new Date(voteCard.dateend).toLocaleDateString()
|
||||||
|
}}
|
||||||
|
</div>
|
||||||
<v-card-actions class="justify-space-between mt-4 pb-2">
|
<v-card-actions class="justify-space-between mt-4 pb-2">
|
||||||
<template v-if="!isFinished">
|
<template v-if="!isFinished">
|
||||||
<v-btn :disabled="voteCard.is_passed || timeChange" color="teal-darken-4" prepend-icon="mdi-vote-outline"
|
<v-btn :disabled="voteCard.is_passed || timeChange" color="teal-darken-4" prepend-icon="mdi-vote-outline"
|
||||||
@@ -102,8 +106,8 @@ export default {
|
|||||||
components: {Timer},
|
components: {Timer},
|
||||||
emits: ['openVoteModal', 'openEditVoteModal', 'deleteVoting', 'openResultModal'],
|
emits: ['openVoteModal', 'openEditVoteModal', 'deleteVoting', 'openResultModal'],
|
||||||
props: {
|
props: {
|
||||||
isFinished:{
|
isFinished: {
|
||||||
type:Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
},
|
},
|
||||||
voteCard: {
|
voteCard: {
|
||||||
|
|||||||
@@ -1,48 +1,55 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-container>
|
<v-container>
|
||||||
<v-row v-for="(question, questionIndex) in questions" :key="questionIndex">
|
<v-tabs v-model="activeTab" class="mb-4">
|
||||||
<v-card flat>
|
<v-tab v-for="(question, questionIndex) in questions" :key="questionIndex">
|
||||||
<v-card-title>
|
Опрос {{ question.numb }}: {{ question.name || 'Без названия' }}
|
||||||
Опрос {{ question.numb }}: {{ question.name || 'Без названия' }}
|
</v-tab>
|
||||||
</v-card-title>
|
</v-tabs>
|
||||||
</v-card>
|
|
||||||
|
|
||||||
<v-col cols="12">
|
<v-tabs-window v-model="activeTab">
|
||||||
<v-card-title class="d-flex ga-2 align-center">
|
<v-tabs-window-item v-for="(question, questionIndex) in questions" :key="questionIndex">
|
||||||
<h4 class="text-teal-darken-4">Победитель:</h4> <h3>{{ getWinner(question).employee?.fio || getWinner(question).name }} 🏆</h3>
|
<v-row>
|
||||||
</v-card-title>
|
<!-- Победитель -->
|
||||||
<v-card-subtitle>
|
<v-col cols="12">
|
||||||
Количество голосов: {{ getWinner(question)?.count || 0 }}
|
<v-card-title class="d-flex ga-2 align-center">
|
||||||
</v-card-subtitle>
|
<h4 class="text-teal-darken-4">Победитель:</h4>
|
||||||
</v-col>
|
<h3>{{ getWinner(question).employee?.fio || getWinner(question).name }} 🏆</h3>
|
||||||
|
</v-card-title>
|
||||||
|
<v-card-subtitle>
|
||||||
|
Количество голосов: {{ getWinner(question)?.count || 0 }}
|
||||||
|
</v-card-subtitle>
|
||||||
|
</v-col>
|
||||||
|
|
||||||
<v-col cols="12">
|
<!-- Топ 10 -->
|
||||||
<v-card class="mb-4" outlined>
|
<v-col cols="12">
|
||||||
<v-card-title class="text-teal-darken-3">Топ 10</v-card-title>
|
<v-card class="mb-4">
|
||||||
<v-card-text>
|
<v-card-title class="text-teal-darken-3">Топ 10</v-card-title>
|
||||||
<v-list>
|
<v-card-text>
|
||||||
<v-list-item
|
<v-list style="max-height: 40vh; overflow-y: auto;">
|
||||||
v-for="(answer, answerIndex) in getTopResults(question)"
|
<v-list-item
|
||||||
:key="answerIndex"
|
v-for="(answer, answerIndex) in getTopResults(question)"
|
||||||
>
|
:key="answerIndex"
|
||||||
<p>
|
>
|
||||||
<strong>{{ answer.employee ? answer.employee.fio : answer.name }}</strong>: {{ answer.count }} голосов
|
<p>
|
||||||
<br/>
|
<strong>{{ answer.employee ? answer.employee.fio : answer.name }}</strong>: {{ answer.count }} голосов
|
||||||
<small>Отдел: {{ answer.employee ? answer.employee.department : '' }}</small>
|
<br />
|
||||||
<br/>
|
<small>Отдел: {{ answer.employee ? answer.employee.department : '' }}</small>
|
||||||
<small>Должность: {{ answer.employee ? answer.employee.post : '' }}</small>
|
<br />
|
||||||
</p>
|
<small>Должность: {{ answer.employee ? answer.employee.post : '' }}</small>
|
||||||
</v-list-item>
|
</p>
|
||||||
</v-list>
|
</v-list-item>
|
||||||
</v-card-text>
|
</v-list>
|
||||||
</v-card>
|
</v-card-text>
|
||||||
</v-col>
|
</v-card>
|
||||||
</v-row>
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
</v-tabs-window-item>
|
||||||
|
</v-tabs-window>
|
||||||
</v-container>
|
</v-container>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {computed} from 'vue';
|
import { computed, ref } from 'vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'VoteResult',
|
name: 'VoteResult',
|
||||||
@@ -53,10 +60,9 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
setup(props) {
|
setup(props) {
|
||||||
// Извлекаем вопросы
|
const activeTab = ref(0);
|
||||||
const questions = computed(() => props.data.questions || []);
|
const questions = computed(() => props.data.questions || []);
|
||||||
|
|
||||||
// Функция для поиска победителя по вопросу
|
|
||||||
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),
|
||||||
@@ -64,14 +70,12 @@ export default {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Функция для получения топ-10 результатов по вопросу
|
|
||||||
const getTopResults = (question) => {
|
const getTopResults = (question) => {
|
||||||
return [...question.answers]
|
return [...question.answers].sort((a, b) => b.count - a.count).slice(0, 10);
|
||||||
.sort((a, b) => b.count - a.count)
|
|
||||||
.slice(0, 10);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
activeTab,
|
||||||
questions,
|
questions,
|
||||||
getWinner,
|
getWinner,
|
||||||
getTopResults,
|
getTopResults,
|
||||||
@@ -79,9 +83,3 @@ export default {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
h1 {
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -36,20 +36,20 @@
|
|||||||
<v-tabs-window-item class="h-100 overflow-auto bg-yellow" value="constructor">
|
<v-tabs-window-item class="h-100 overflow-auto bg-yellow" value="constructor">
|
||||||
<VoteConstructor @updating="updating"/>
|
<VoteConstructor @updating="updating"/>
|
||||||
</v-tabs-window-item>
|
</v-tabs-window-item>
|
||||||
|
|
||||||
|
|
||||||
<!-- Конструктор -->
|
|
||||||
<v-tabs-window-item value="constructor" class="h-100 overflow-auto">
|
|
||||||
<VoteConstructor @updating="updating" />
|
|
||||||
</v-tabs-window-item>
|
|
||||||
<!-- </v-tabs-window> -->
|
|
||||||
|
|
||||||
</v-window>
|
|
||||||
|
|
||||||
<!-- Модальные окна -->
|
<!-- Конструктор -->
|
||||||
<v-dialog v-model="voteModal" @click:outside="closeModal">
|
<v-tabs-window-item class="h-100 overflow-auto" value="constructor">
|
||||||
|
<VoteConstructor @updating="updating"/>
|
||||||
|
</v-tabs-window-item>
|
||||||
|
<!-- </v-tabs-window> -->
|
||||||
|
|
||||||
|
</v-window>
|
||||||
|
|
||||||
|
<!-- Модальные окна -->
|
||||||
|
<v-dialog v-model="voteModal" @click:outside="closeModal">
|
||||||
|
|
||||||
|
|
||||||
<CurrentVote :data="res" @closer="closeModal"/>
|
<CurrentVote :data="res" @closer="closeModal"/>
|
||||||
</v-dialog>
|
</v-dialog>
|
||||||
|
|
||||||
@@ -69,9 +69,7 @@
|
|||||||
<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>
|
<v-card-title>Результаты голосования: {{ selectedVoting?.title }}</v-card-title>
|
||||||
<v-card-text>
|
<VoteResult :data="result"/>
|
||||||
<VoteResult :data="result"/>
|
|
||||||
</v-card-text>
|
|
||||||
<v-card-actions>
|
<v-card-actions>
|
||||||
<v-btn @click="closeModal">Закрыть</v-btn>
|
<v-btn @click="closeModal">Закрыть</v-btn>
|
||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
@@ -179,7 +177,7 @@ export default {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
watch(currentTab,async () => await updating(currentTab.value))
|
watch(currentTab, async () => await updating(currentTab.value))
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => route,
|
() => route,
|
||||||
|
|||||||
Reference in new issue
Block a user