Приложение голосование сделано!
This commit is contained in:
1 parent
e3661db5cb
commit
2108058a6b
5 files changed
+83
-26
No files matched your search
@@ -11,7 +11,6 @@ class ThanksVote(models.Model):
|
|||||||
vote_thanks_date = models.DateTimeField(auto_now_add=True)
|
vote_thanks_date = models.DateTimeField(auto_now_add=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
# unique_together = ('cand_name', 'voted_user')
|
|
||||||
verbose_name = "Голосование, хочу сказать спасибо!"
|
verbose_name = "Голосование, хочу сказать спасибо!"
|
||||||
verbose_name_plural = "Голосование, хочу сказать спасибо!"
|
verbose_name_plural = "Голосование, хочу сказать спасибо!"
|
||||||
|
|
||||||
@@ -27,7 +26,6 @@ class BestVote(models.Model):
|
|||||||
vote_best_date = models.DateTimeField(auto_now_add=True)
|
vote_best_date = models.DateTimeField(auto_now_add=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
# unique_together = ('cand_name', 'voted_user')
|
|
||||||
verbose_name = "Голосование, мой коллега самый лучший"
|
verbose_name = "Голосование, мой коллега самый лучший"
|
||||||
verbose_name_plural = "Голосование, мой коллега самый лучший"
|
verbose_name_plural = "Голосование, мой коллега самый лучший"
|
||||||
|
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ class SetThanks(APIView):
|
|||||||
class GetThanks(APIView):
|
class GetThanks(APIView):
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
# Группировка кандидатов по имени и подсчет каждого
|
# Группировка кандидатов по имени и подсчет каждого
|
||||||
count_thanks = ThanksVote.objects.values(
|
count_thanks = ThanksVote.objects.values('voted_user',
|
||||||
'cand_name').annotate(total=Count('id'))
|
'cand_name').annotate(total=Count('id'))
|
||||||
return Response(count_thanks)
|
return Response(count_thanks)
|
||||||
|
|
||||||
|
|
||||||
@@ -63,8 +63,8 @@ class SetBest(APIView):
|
|||||||
class GetBest(APIView):
|
class GetBest(APIView):
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
# Группировка кандидатов по имени и подсчет каждого
|
# Группировка кандидатов по имени и подсчет каждого
|
||||||
count_bests = BestVote.objects.values(
|
count_bests = BestVote.objects.values('voted_user',
|
||||||
'department_user', 'cand_name').annotate(total=Count('id'))
|
'department_user', 'cand_name').annotate(total=Count('id'))
|
||||||
return Response(count_bests)
|
return Response(count_bests)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,26 +10,26 @@
|
|||||||
<v-card-title>Процент проголосовавших</v-card-title>
|
<v-card-title>Процент проголосовавших</v-card-title>
|
||||||
</v-card>
|
</v-card>
|
||||||
<v-card elevation="0">
|
<v-card elevation="0">
|
||||||
<v-card-text>
|
<v-card-text class="perc-voted">
|
||||||
{{ perc_bst }}%
|
{{ perc_bst }}%
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
</v-card>
|
</v-card>
|
||||||
<v-card color="teal-darken-1" class="ma-2">
|
<v-card color="teal-darken-1" class="mb-2">
|
||||||
<v-card-title>Лидер номинации</v-card-title>
|
<v-card-title>Лидер номинации</v-card-title>
|
||||||
</v-card>
|
</v-card>
|
||||||
<v-card v-for="(employees, department) in max_bst" :key="department" elevation="0">
|
<v-card class="scroll-leaders" elevation="0">
|
||||||
<v-card-title>{{ department }}</v-card-title>
|
<v-card v-for="(employees, department) in max_bst" :key="department" elevation="0">
|
||||||
<v-card-text>
|
<v-card-title>{{ department }}</v-card-title>
|
||||||
<div v-for="employee in employees" :key="employee.name">
|
<div v-for="employee in employees" :key="employee.name">
|
||||||
{{ employee.name }}
|
{{ employee.name }}
|
||||||
</div>
|
</div>
|
||||||
</v-card-text>
|
</v-card>
|
||||||
</v-card>
|
</v-card>
|
||||||
<v-card color="teal-darken-1" class="ma-2">
|
<v-card color="teal-darken-1" class="ma-2">
|
||||||
<v-card-title>ФИО не участвовавших в голосовании</v-card-title>
|
<v-card-title>ФИО не участвовавших в голосовании</v-card-title>
|
||||||
</v-card>
|
</v-card>
|
||||||
<v-card elevation="0">
|
<v-card elevation="0">
|
||||||
<v-card id="scroll-window" elevation="0">
|
<v-card class="scroll-window" elevation="0">
|
||||||
<v-card v-for="[key, val] of Object.entries(result_bst)">
|
<v-card v-for="[key, val] of Object.entries(result_bst)">
|
||||||
<v-card-title>{{ key }}</v-card-title>
|
<v-card-title>{{ key }}</v-card-title>
|
||||||
<div v-for="item_fio in val">
|
<div v-for="item_fio in val">
|
||||||
@@ -51,14 +51,14 @@
|
|||||||
<v-card-title>Процент проголосовавших</v-card-title>
|
<v-card-title>Процент проголосовавших</v-card-title>
|
||||||
</v-card>
|
</v-card>
|
||||||
<v-card elevation="0">
|
<v-card elevation="0">
|
||||||
<v-card-text>
|
<v-card-text class="perc-voted">
|
||||||
<perc-thn />
|
<perc-thn />
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
</v-card>
|
</v-card>
|
||||||
<v-card color="teal-darken-1" class="ma-2">
|
<v-card color="teal-darken-1" class="mb-2">
|
||||||
<v-card-title>Лидер номинации</v-card-title>
|
<v-card-title>Лидер номинации</v-card-title>
|
||||||
</v-card>
|
</v-card>
|
||||||
<v-card elevation="0">
|
<v-card class="scroll-leaders pt-4" elevation="0">
|
||||||
<div v-for="leader in max_thn">
|
<div v-for="leader in max_thn">
|
||||||
{{ leader }}
|
{{ leader }}
|
||||||
</div>
|
</div>
|
||||||
@@ -66,7 +66,7 @@
|
|||||||
<v-card color="teal-darken-1" class="ma-2">
|
<v-card color="teal-darken-1" class="ma-2">
|
||||||
<v-card-title>ФИО не участвовавших в голосовании</v-card-title>
|
<v-card-title>ФИО не участвовавших в голосовании</v-card-title>
|
||||||
</v-card>
|
</v-card>
|
||||||
<v-card id="scroll-window" elevation="0">
|
<v-card class="scroll-window" elevation="0">
|
||||||
<v-card v-for="[key, val] of Object.entries(result_thn)">
|
<v-card v-for="[key, val] of Object.entries(result_thn)">
|
||||||
<v-card-title>{{ key }}</v-card-title>
|
<v-card-title>{{ key }}</v-card-title>
|
||||||
<div v-for="item_fio in val">
|
<div v-for="item_fio in val">
|
||||||
@@ -176,8 +176,17 @@ export default {
|
|||||||
margin-left: 10%;
|
margin-left: 10%;
|
||||||
}
|
}
|
||||||
|
|
||||||
#scroll-window {
|
.scroll-leaders {
|
||||||
overflow-y: scroll;
|
overflow-y: scroll;
|
||||||
height: 400px;
|
height: 95px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.scroll-window {
|
||||||
|
overflow-y: scroll;
|
||||||
|
height: 378px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.perc-voted {
|
||||||
|
font-size: 1.2em;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-form @submit="voteSend">
|
<v-form @submit="voteSend">
|
||||||
<v-card height="520" variant="none">
|
<v-card id="scroll-window-chekbox" height="520" elevation="0">
|
||||||
<!-- Форма голосования -->
|
<!-- Форма голосования -->
|
||||||
<v-virtual-scroll :items="vote_data" :height="500" :item-height="40">
|
<v-virtual-scroll :items="vote_data" :item-height="40">
|
||||||
<template v-slot:default="{ item }">
|
<template v-slot:default="{ item }">
|
||||||
<v-checkbox v-model="vote" :id="item.fio" :value="item.fio" :label="item.fio" />
|
<v-checkbox v-model="vote" :id="item.fio" :value="item.fio" :label="item.fio" />
|
||||||
</template>
|
</template>
|
||||||
@@ -103,4 +103,9 @@ export default {
|
|||||||
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style></style>
|
<style>
|
||||||
|
#scroll-window-chekbox {
|
||||||
|
overflow-y: scroll !important;
|
||||||
|
height: 400px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -28,9 +28,13 @@
|
|||||||
</v-card-title>
|
</v-card-title>
|
||||||
<!-- Кнопка активации поворота -->
|
<!-- Кнопка активации поворота -->
|
||||||
<v-card-actions class="justify-center vote-button">
|
<v-card-actions class="justify-center vote-button">
|
||||||
<v-btn size="x-large" @click="toggleFlip1" variant="elevated" color="teal-darken-1"
|
<v-card-title class="you-voted" v-if="voted_bst">
|
||||||
|
<div>Вы уже проголосовали!</div>
|
||||||
|
</v-card-title>
|
||||||
|
<v-btn v-else size="x-large" @click="toggleFlip1" variant="elevated" color="teal-darken-1"
|
||||||
type="button">ОТДАТЬ
|
type="button">ОТДАТЬ
|
||||||
ГОЛОС!</v-btn>
|
ГОЛОС!</v-btn>
|
||||||
|
|
||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
<!-- Кнопка активации поворота КОНЕЦ-->
|
<!-- Кнопка активации поворота КОНЕЦ-->
|
||||||
</v-card>
|
</v-card>
|
||||||
@@ -58,7 +62,7 @@
|
|||||||
<!-- Задняя сторона карточки КОНЕЦ-->
|
<!-- Задняя сторона карточки КОНЕЦ-->
|
||||||
</v-col>
|
</v-col>
|
||||||
<!-- Голосование Лучший сотрудник КОНЕЦ-->
|
<!-- Голосование Лучший сотрудник КОНЕЦ-->
|
||||||
<v-col cols="2" v-if="admin_panel" justify="center" align="center">
|
<v-col class="w-15" cols="2" v-if="admin_panel" justify="center" align="center">
|
||||||
<v-dialog>
|
<v-dialog>
|
||||||
<template v-slot:activator="{ props: VoteAdmin }">
|
<template v-slot:activator="{ props: VoteAdmin }">
|
||||||
<v-btn variant="elevated" v-bind="VoteAdmin" color="teal-darken-1">ИНФОРМАЦИЯ О ХОДЕ <br>
|
<v-btn variant="elevated" v-bind="VoteAdmin" color="teal-darken-1">ИНФОРМАЦИЯ О ХОДЕ <br>
|
||||||
@@ -92,7 +96,11 @@
|
|||||||
</v-card-title>
|
</v-card-title>
|
||||||
<!-- Кнопка активации поворота -->
|
<!-- Кнопка активации поворота -->
|
||||||
<v-card-actions class="justify-center vote-button">
|
<v-card-actions class="justify-center vote-button">
|
||||||
<v-btn size="x-large" @click="toggleFlip2" variant="elevated" color="teal-darken-1">ОТДАТЬ
|
<v-card-title class="you-voted" v-if="voted_thn">
|
||||||
|
<div>Вы уже проголосовали!</div>
|
||||||
|
</v-card-title>
|
||||||
|
<v-btn v-else size="x-large" @click="toggleFlip2" variant="elevated"
|
||||||
|
color="teal-darken-1">ОТДАТЬ
|
||||||
ГОЛОС!</v-btn>
|
ГОЛОС!</v-btn>
|
||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
<!-- Кнопка активации поворота КОНЕЦ-->
|
<!-- Кнопка активации поворота КОНЕЦ-->
|
||||||
@@ -126,6 +134,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
|
import { clearAxios } from "@/utils/axios-api";
|
||||||
import VoteForm from '@/components/vote/VoteForm.vue';
|
import VoteForm from '@/components/vote/VoteForm.vue';
|
||||||
import PercBst from '@/components/vote/PercBst.vue';
|
import PercBst from '@/components/vote/PercBst.vue';
|
||||||
import PercThn from '@/components/vote/PercThn.vue';
|
import PercThn from '@/components/vote/PercThn.vue';
|
||||||
@@ -137,6 +146,7 @@ let account_login = useAccountStore().user.login;
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
VoteForm,
|
VoteForm,
|
||||||
CountDown,
|
CountDown,
|
||||||
@@ -147,10 +157,36 @@ export default {
|
|||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
|
|
||||||
|
let votedListBst = ref([]);
|
||||||
|
let votedListThn = ref([]);
|
||||||
|
let voted_thn = ref(false);
|
||||||
|
let voted_bst = ref(false);
|
||||||
|
|
||||||
const isFlipped1 = ref(false);
|
const isFlipped1 = ref(false);
|
||||||
const isFlipped2 = ref(false);
|
const isFlipped2 = ref(false);
|
||||||
|
|
||||||
|
|
||||||
|
const isVoted = () => {
|
||||||
|
clearAxios.get(`/api/vote/getthanks/`).then((data) => {
|
||||||
|
votedListThn = data.data;
|
||||||
|
let finded_thn = votedListThn.find(({ voted_user }) => voted_user === account_login)
|
||||||
|
if (finded_thn.voted_user === account_login) {
|
||||||
|
voted_thn.value = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
clearAxios.get(`/api/vote/getbest/`).then((data) => {
|
||||||
|
votedListBst = data.data;
|
||||||
|
let finded_bst = votedListBst.find(({ voted_user }) => voted_user === account_login)
|
||||||
|
if (finded_bst.voted_user === account_login) {
|
||||||
|
voted_bst.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const toggleFlip1 = () => {
|
const toggleFlip1 = () => {
|
||||||
isFlipped1.value = !isFlipped1.value;
|
isFlipped1.value = !isFlipped1.value;
|
||||||
|
|
||||||
@@ -163,6 +199,7 @@ export default {
|
|||||||
admin_panel = true;
|
admin_panel = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isVoted();
|
||||||
return {
|
return {
|
||||||
isFlipped1,
|
isFlipped1,
|
||||||
toggleFlip1,
|
toggleFlip1,
|
||||||
@@ -170,6 +207,8 @@ export default {
|
|||||||
toggleFlip2,
|
toggleFlip2,
|
||||||
account_login,
|
account_login,
|
||||||
admin_panel,
|
admin_panel,
|
||||||
|
voted_bst,
|
||||||
|
voted_thn,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -212,7 +251,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.vote-button {
|
.vote-button {
|
||||||
margin-top: 572px;
|
margin-top: 577px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.vote-cards_cell {
|
.vote-cards_cell {
|
||||||
@@ -230,4 +269,10 @@ export default {
|
|||||||
.card-count {
|
.card-count {
|
||||||
font-size: 4em;
|
font-size: 4em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.you-voted {
|
||||||
|
background-color: rgba(182, 182, 182, 0.4);
|
||||||
|
color: #ffff;
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
Reference in new issue
Block a user