Merge branch 'Andr' into develop
This commit is contained in:
commit
18b41141e8
6 files changed
+221
-41
No files matched your search
@@ -11,7 +11,6 @@ class ThanksVote(models.Model):
|
||||
vote_thanks_date = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
class Meta:
|
||||
# unique_together = ('cand_name', 'voted_user')
|
||||
verbose_name = "Голосование, хочу сказать спасибо!"
|
||||
verbose_name_plural = "Голосование, хочу сказать спасибо!"
|
||||
|
||||
@@ -27,7 +26,6 @@ class BestVote(models.Model):
|
||||
vote_best_date = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
class Meta:
|
||||
# unique_together = ('cand_name', 'voted_user')
|
||||
verbose_name = "Голосование, мой коллега самый лучший"
|
||||
verbose_name_plural = "Голосование, мой коллега самый лучший"
|
||||
|
||||
|
||||
@@ -10,4 +10,6 @@ urlpatterns = [
|
||||
path('getthanks/', GetThanks.as_view(), name=''),
|
||||
path('setbest/', SetBest.as_view(), name=''),
|
||||
path('getbest/', GetBest.as_view(), name=''),
|
||||
path('getnotvotethn/', GetNotVoteThn.as_view()),
|
||||
path('getnotvotebst/', GetNotVoteBst.as_view()),
|
||||
]
|
||||
+20
-4
@@ -42,8 +42,8 @@ class SetThanks(APIView):
|
||||
class GetThanks(APIView):
|
||||
def get(self, request):
|
||||
# Группировка кандидатов по имени и подсчет каждого
|
||||
count_thanks = ThanksVote.objects.values(
|
||||
'cand_name').annotate(total=Count('id'))
|
||||
count_thanks = ThanksVote.objects.values('voted_user',
|
||||
'cand_name').annotate(total=Count('id'))
|
||||
return Response(count_thanks)
|
||||
|
||||
|
||||
@@ -64,6 +64,22 @@ class SetBest(APIView):
|
||||
class GetBest(APIView):
|
||||
def get(self, request):
|
||||
# Группировка кандидатов по имени и подсчет каждого
|
||||
count_bests = BestVote.objects.values(
|
||||
'cand_name').annotate(total=Count('id'))
|
||||
count_bests = BestVote.objects.values('voted_user',
|
||||
'department_user', 'cand_name').annotate(total=Count('id'))
|
||||
return Response(count_bests)
|
||||
|
||||
|
||||
class GetNotVoteThn(APIView):
|
||||
def get(self, request):
|
||||
list_thn_users = ThanksVote.objects.values('voted_user')
|
||||
list_emp = DictEmployee.objects.filter(
|
||||
deleted=0).exclude(login__in=list_thn_users)
|
||||
return Response(GetEmpSerializer(list_emp, many=True).data)
|
||||
|
||||
|
||||
class GetNotVoteBst(APIView):
|
||||
def get(self, request):
|
||||
list_bst_users = BestVote.objects.values('voted_user')
|
||||
list_emp_bst = DictEmployee.objects.filter(
|
||||
deleted=0).exclude(login__in=list_bst_users)
|
||||
return Response(GetEmpSerializer(list_emp_bst, many=True).data)
|
||||
@@ -10,26 +10,35 @@
|
||||
<v-card-title>Процент проголосовавших</v-card-title>
|
||||
</v-card>
|
||||
<v-card elevation="0">
|
||||
<v-card-text>
|
||||
88
|
||||
<v-card-text class="perc-voted">
|
||||
{{ perc_bst }}%
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
<v-card color="teal-darken-1" class="mb-2">
|
||||
<v-card-title>Лидер номинации</v-card-title>
|
||||
</v-card>
|
||||
<v-card class="scroll-leaders" elevation="0">
|
||||
<v-card v-for="(employees, department) in max_bst" :key="department" elevation="0">
|
||||
<v-card-title>{{ department }}</v-card-title>
|
||||
<div v-for="employee in employees" :key="employee.name">
|
||||
{{ employee.name }}
|
||||
</div>
|
||||
</v-card>
|
||||
</v-card>
|
||||
<v-card color="teal-darken-1" class="ma-2">
|
||||
<v-card-title>ФИО не участвовавших в голосовании</v-card-title>
|
||||
</v-card>
|
||||
<v-card elevation="0">
|
||||
<v-card-text>
|
||||
ФИО
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
<v-card color="teal-darken-1" class="ma-2">
|
||||
<v-card-title>Лидер номинации</v-card-title>
|
||||
</v-card>
|
||||
<v-card elevation="0">
|
||||
<v-card-text>
|
||||
ФИО
|
||||
</v-card-text>
|
||||
<v-card class="scroll-window" elevation="0">
|
||||
<v-card v-for="[key, val] of Object.entries(result_bst)">
|
||||
<v-card-title>{{ key }}</v-card-title>
|
||||
<div v-for="item_fio in val">
|
||||
{{ item_fio.fio }}
|
||||
</div>
|
||||
</v-card>
|
||||
</v-card>
|
||||
</v-card>
|
||||
|
||||
</v-card>
|
||||
</v-col>
|
||||
<v-col justify="center" align="center">
|
||||
@@ -42,36 +51,142 @@
|
||||
<v-card-title>Процент проголосовавших</v-card-title>
|
||||
</v-card>
|
||||
<v-card elevation="0">
|
||||
<v-card-text>
|
||||
88
|
||||
<v-card-text class="perc-voted">
|
||||
<perc-thn />
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
<v-card color="teal-darken-1" class="mb-2">
|
||||
<v-card-title>Лидер номинации</v-card-title>
|
||||
</v-card>
|
||||
<v-card class="scroll-leaders pt-4" elevation="0">
|
||||
<div v-for="leader in max_thn">
|
||||
{{ leader }}
|
||||
</div>
|
||||
</v-card>
|
||||
<v-card color="teal-darken-1" class="ma-2">
|
||||
<v-card-title>ФИО не участвовавших в голосовании</v-card-title>
|
||||
</v-card>
|
||||
<v-card elevation="0">
|
||||
<v-card-text>
|
||||
ФИО
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
<v-card color="teal-darken-1" class="ma-2">
|
||||
<v-card-title>Лидер номинации</v-card-title>
|
||||
</v-card>
|
||||
<v-card elevation="0">
|
||||
<v-card-text>
|
||||
ФИО
|
||||
</v-card-text>
|
||||
<v-card class="scroll-window" elevation="0">
|
||||
<v-card v-for="[key, val] of Object.entries(result_thn)">
|
||||
<v-card-title>{{ key }}</v-card-title>
|
||||
<div v-for="item_fio in val">
|
||||
{{ item_fio.fio }}
|
||||
</div>
|
||||
</v-card>
|
||||
</v-card>
|
||||
|
||||
</v-card>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</template>
|
||||
<script>
|
||||
import { ref } from "vue";
|
||||
import { computed } from "vue";
|
||||
import { clearAxios } from "@/utils/axios-api";
|
||||
import { objectToString } from "@vue/shared";
|
||||
import { useAccountStore } from '@/store/AccountStore';
|
||||
import PercThn from '@/components/vote/PercThn.vue';
|
||||
|
||||
|
||||
export default {
|
||||
components: {
|
||||
PercThn,
|
||||
},
|
||||
setup() {
|
||||
let account_login = useAccountStore().user.login;
|
||||
let result_thn = ref([]);
|
||||
let result_bst = ref([]);
|
||||
let all_voted_bst = ref([]);
|
||||
let all_voted_thn = ref([]);
|
||||
let max_thn = ref();
|
||||
let max_bst = ref({});
|
||||
let all_cod = ref([]);
|
||||
let perc_bst = ref();
|
||||
|
||||
const getNotVoted = () => {
|
||||
clearAxios.get(`/api/vote/getnotvotethn/`).then((data) => {
|
||||
let not_voted_thn = data.data;
|
||||
result_thn.value = Object.groupBy(not_voted_thn, ({ department }) => department);
|
||||
});
|
||||
clearAxios.get(`/api/vote/getnotvotebst/`).then((data) => {
|
||||
let not_voted_bst = data.data;
|
||||
result_bst.value = Object.groupBy(not_voted_bst, ({ department }) => department);
|
||||
});
|
||||
};
|
||||
|
||||
const getPercAndWin = () => {
|
||||
clearAxios.get(`/api/vote/getthanks/`).then((data) => {
|
||||
all_voted_thn = data.data;
|
||||
let max_total = Math.max(...all_voted_thn.map(item => item.total));
|
||||
max_thn.value = all_voted_thn.filter(item => item.total === max_total).map(item => item.cand_name)
|
||||
});
|
||||
|
||||
clearAxios.get(`api/vote/get_for_thn/?login=${account_login}`).then((data) => {
|
||||
all_cod.value = data.data;
|
||||
});
|
||||
|
||||
clearAxios.get(`/api/vote/getbest/`).then((data) => {
|
||||
all_voted_bst.value = data.data;
|
||||
// Групировка по департаметам
|
||||
const groupedEmployees = {}
|
||||
all_voted_bst.value.forEach(item => {
|
||||
const { department_user, cand_name, total } = item;
|
||||
if (!groupedEmployees[department_user]) {
|
||||
groupedEmployees[department_user] = [];
|
||||
}
|
||||
groupedEmployees[department_user].push({ name: cand_name, total });
|
||||
});
|
||||
// Нахождение лучших сотрудников в каждом департаменте
|
||||
for (const department in groupedEmployees) {
|
||||
const employees = groupedEmployees[department];
|
||||
// Поиск максимального количества голосов
|
||||
const maxTotal = Math.max(...employees.map(emp => emp.total));
|
||||
|
||||
// Фильтрация сотрудников с максимальным количетсвом голосов
|
||||
max_bst.value[department] = employees.filter(emp => emp.total === maxTotal);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
console.log(max_bst);
|
||||
|
||||
|
||||
};
|
||||
|
||||
perc_bst = computed(() => Math.round(all_voted_bst.value.length / all_cod.value.length * 100))
|
||||
|
||||
getPercAndWin();
|
||||
getNotVoted();
|
||||
return {
|
||||
max_thn,
|
||||
max_bst,
|
||||
perc_bst,
|
||||
result_thn,
|
||||
result_bst,
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
<style>
|
||||
.admin-vote {
|
||||
margin-left: 10%;
|
||||
}
|
||||
|
||||
.scroll-leaders {
|
||||
overflow-y: scroll;
|
||||
height: 95px;
|
||||
}
|
||||
|
||||
.scroll-window {
|
||||
overflow-y: scroll;
|
||||
height: 378px;
|
||||
}
|
||||
|
||||
.perc-voted {
|
||||
font-size: 1.2em;
|
||||
}
|
||||
</style>
|
||||
@@ -1,8 +1,8 @@
|
||||
<template>
|
||||
<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 }">
|
||||
<v-checkbox v-model="vote" :id="item.fio" :value="item.fio" :label="item.fio" />
|
||||
</template>
|
||||
@@ -104,4 +104,9 @@ export default {
|
||||
|
||||
}
|
||||
</script>
|
||||
<style></style>
|
||||
<style>
|
||||
#scroll-window-chekbox {
|
||||
overflow-y: scroll !important;
|
||||
height: 400px;
|
||||
}
|
||||
</style>
|
||||
@@ -28,9 +28,13 @@
|
||||
</v-card-title>
|
||||
<!-- Кнопка активации поворота -->
|
||||
<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">ОТДАТЬ
|
||||
ГОЛОС!</v-btn>
|
||||
|
||||
</v-card-actions>
|
||||
<!-- Кнопка активации поворота КОНЕЦ-->
|
||||
</v-card>
|
||||
@@ -58,7 +62,7 @@
|
||||
<!-- Задняя сторона карточки КОНЕЦ-->
|
||||
</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>
|
||||
<template v-slot:activator="{ props: VoteAdmin }">
|
||||
<v-btn variant="elevated" v-bind="VoteAdmin" color="teal-darken-1">ИНФОРМАЦИЯ О ХОДЕ <br>
|
||||
@@ -92,7 +96,11 @@
|
||||
</v-card-title>
|
||||
<!-- Кнопка активации поворота -->
|
||||
<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-card-actions>
|
||||
<!-- Кнопка активации поворота КОНЕЦ-->
|
||||
@@ -126,6 +134,7 @@
|
||||
</template>
|
||||
<script>
|
||||
import { ref } from "vue";
|
||||
import { clearAxios } from "@/utils/axios-api";
|
||||
import VoteForm from '@/components/vote/VoteForm.vue';
|
||||
import PercBst from '@/components/vote/PercBst.vue';
|
||||
import PercThn from '@/components/vote/PercThn.vue';
|
||||
@@ -137,6 +146,7 @@ let account_login = useAccountStore().user.login;
|
||||
|
||||
export default {
|
||||
|
||||
|
||||
components: {
|
||||
VoteForm,
|
||||
CountDown,
|
||||
@@ -147,10 +157,36 @@ export default {
|
||||
|
||||
setup() {
|
||||
|
||||
let votedListBst = ref([]);
|
||||
let votedListThn = ref([]);
|
||||
let voted_thn = ref(false);
|
||||
let voted_bst = ref(false);
|
||||
|
||||
const isFlipped1 = 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 = () => {
|
||||
isFlipped1.value = !isFlipped1.value;
|
||||
|
||||
@@ -161,9 +197,9 @@ export default {
|
||||
|
||||
if (account_login == '9966-00-011') {
|
||||
admin_panel = true;
|
||||
console.log(admin_panel);
|
||||
}
|
||||
|
||||
isVoted();
|
||||
return {
|
||||
isFlipped1,
|
||||
toggleFlip1,
|
||||
@@ -171,6 +207,8 @@ export default {
|
||||
toggleFlip2,
|
||||
account_login,
|
||||
admin_panel,
|
||||
voted_bst,
|
||||
voted_thn,
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -213,7 +251,7 @@ export default {
|
||||
}
|
||||
|
||||
.vote-button {
|
||||
margin-top: 572px;
|
||||
margin-top: 577px;
|
||||
}
|
||||
|
||||
.vote-cards_cell {
|
||||
@@ -231,4 +269,10 @@ export default {
|
||||
.card-count {
|
||||
font-size: 4em;
|
||||
}
|
||||
|
||||
.you-voted {
|
||||
background-color: rgba(182, 182, 182, 0.4);
|
||||
color: #ffff;
|
||||
border-radius: 5px;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user