Merge branch 'develop' into сja

This commit is contained in:
Cja committed 2025-01-23 15:53:25 +03:00
commit df2f96367c
8 files changed
+375 -25

No files matched your search

+1 -1
View File
@@ -142,7 +142,7 @@ class VoteCreate(APIView):
text = f'Пройдите голосование "{vote_url}" до {formatted_date}', text = f'Пройдите голосование "{vote_url}" до {formatted_date}',
cdate = request.data['startDate'], cdate = request.data['startDate'],
author = request.user, author = request.user,
link = os.path.join(settings.MEDIA_ROOT,'defaultimg','vote.png'), link = os.path.join('defaultimg','vote.png'),
vote = vote vote = vote
) )
news.save() news.save()
@@ -67,7 +67,7 @@
<v-btn <v-btn
color="modal_btn" color="modal_btn"
variant="text" variant="text"
@click= "$emit('update:opendialog', value)" @click= "$emit('update:opendialog', false)"
> >
Закрыть Закрыть
</v-btn> </v-btn>
@@ -0,0 +1,143 @@
<template>
<v-container class="d-flex flex-column align-center">
<div id="container">
<div id="success-box">
<div class="face">
<div class="eye"></div>
<div class="eye right"></div>
<div class="mouth happy"></div>
</div>
<div class="shadow scale"></div>
<div class="message"><h1 class="alert">Все проголосовали!</h1><p>тех, кто не голосовал нет</p></div>
</div>
</div>
</v-container>
</template>
<script>
export default {
setup() {
return {};
},
};
</script>
<style lang="scss" scoped>
$white: #80CBC4;
$gray: #CBCDD3;
$dark: #000000;
@import url('https://fonts.googleapis.com/css?family=Lato:400,700');
$font: 'Lato', sans-serif;
#container {
position: relative;
margin: auto;
overflow: hidden;
width: 50vw;
height: 40vh;
}
#success-box {
position: absolute;
width: 100%;
height: 80vh;
top: -50px;
}
.message {
position: absolute;
width: 100%;
text-align: center;
height: 40%;
top: 47%;
color: #004D40;
}
.face {
position: absolute;
width: 22%;
height: 22%;
background: $white;
border-radius: 50%;
border: 1px solid $dark;
top: 21%;
left: 37.5%;
z-index: 2;
animation: bounce 1s ease-in infinite;
}
.eye {
position: absolute;
width: 5px;
height: 5px;
background: $dark;
border-radius: 50%;
top: 40%;
left: 20%;
}
.right {
left: 68%;
}
.mouth {
position:absolute;
top: 43%;
left: 41%;
width: 7px;
height: 7px;
border-radius: 50%;
}
.happy {
border: 2px solid;
border-color: transparent $dark $dark transparent;
transform: rotate(45deg);
}
.shadow {
position: absolute;
width: 21%;
height: 3%;
opacity: .5;
background: $dark;
left: 40%;
top: 43%;
border-radius: 50%;
z-index: 1;
}
.scale {
animation: scale 1s ease-in infinite;
}
.move {
animation: move 3s ease-in-out infinite;
}
@keyframes bounce {
50% {
transform: translateY(-10px);
}
}
@keyframes scale {
50% {
transform: scale(0.9);
}
}
@keyframes move {
0% {
left: 25%;
}
50% {
left: 60%;
}
100% {
left: 25%;
}
}
</style>
@@ -0,0 +1,127 @@
<template>
<div id="container">
<div id="error-box">
<div class="face2">
<div class="eye"></div>
<div class="eye right"></div>
<div class="mouth sad"></div>
</div>
<div class="shadow move"></div>
</div>
</div>
</template>
<style lang="scss" scoped>
$white: #EF5350;
$gray: #CBCDD3;
$dark: #000000;
#container {
position: relative;
overflow: hidden;
width: 200px;
height: 110px;
}
#error-box {
position: absolute;
width: 350px;
height: 350px;
right: -32%;
}
.face2 {
position: absolute;
width: 22%;
height: 22%;
background: $white;
border-radius: 50%;
border: 1px solid $dark;
top: 7%;
left: 37.5%;
z-index: 2;
animation: roll 3s ease-in-out infinite;
}
.eye {
position: absolute;
width: 5px;
height: 5px;
background: $dark;
border-radius: 50%;
top: 40%;
left: 20%;
}
.right {
left: 68%;
}
.mouth {
position:absolute;
top: 43%;
left: 41%;
width: 7px;
height: 7px;
border-radius: 50%;
}
.sad {
top: 49%;
border: 2px solid;
border-color: $dark transparent transparent $dark;
transform: rotate(45deg);
}
.shadow {
position: absolute;
width: 21%;
height: 3%;
opacity: .5;
background: $dark;
left: 40%;
top: 28%;
border-radius: 50%;
z-index: 1;
}
.scale {
animation: scale 1s ease-in infinite;
}
.move {
animation: move 3s ease-in-out infinite;
}
@keyframes scale {
50% {
transform: scale(0.9);
}
}
@keyframes roll {
0% {
transform: rotate(0deg);
left: 25%;
}
50% {
left: 60%;
transform: rotate(168deg);
}
100% {
transform: rotate(0deg);
left: 25%;
}
}
@keyframes move {
0% {
left: 25%;
}
50% {
left: 60%;
}
100% {
left: 25%;
}
}
</style>
@@ -11,10 +11,6 @@
</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-icon color="orange-lighten-1">mdi-pencil</v-icon>-->
<!-- </v-btn>-->
</v-card-text> </v-card-text>
<v-row> <v-row>
<v-col> <v-col>
@@ -82,7 +82,7 @@
<v-card flat class="fill-height d-flex flex-column"> <v-card flat class="fill-height d-flex flex-column">
<v-card-title>Создание опроса:</v-card-title> <v-card-title>Создание опроса:</v-card-title>
<v-card-text> <v-card-text style="max-height: 62vh; overflow-y: auto;">
<transition-group name="list" tag="div"> <transition-group name="list" tag="div">
<div v-for="(question, index) in form.questions" :key="index" class="mb-4"> <div v-for="(question, index) in form.questions" :key="index" class="mb-4">
<div class="d-flex"> <div class="d-flex">
@@ -271,7 +271,7 @@
<v-card flat class="fill-height d-flex flex-column"> <v-card flat class="fill-height d-flex flex-column">
<v-card-title>Подтверждение</v-card-title> <v-card-title>Подтверждение</v-card-title>
<v-card-text> <v-card-text style="max-height: 62vh; overflow-y: auto;">
<v-alert v-if="errorMessage" class="mb-4 " type="error"> <v-alert v-if="errorMessage" class="mb-4 " type="error">
{{ errorMessage }} {{ errorMessage }}
</v-alert> </v-alert>
+85 -11
View File
@@ -28,10 +28,26 @@
</v-tab> </v-tab>
<v-tab>Не голосовали</v-tab> <v-tab>Не голосовали</v-tab>
</v-tabs> </v-tabs>
<v-tabs-window v-model="activeTab"> <v-tabs-window v-model="activeTab">
<v-tabs-window-item v-for="(question, questionIndex) in questions" :key="questionIndex"> <v-tabs-window-item v-for="(question, questionIndex) in questions" :key="questionIndex">
<v-row>
<v-row v-if="question.settings.onlyDep">
<v-col v-for="(winner, department) in getWinnersByDepartment(question)" :key="department">
<v-card>
<v-card-title>
<strong class="text-teal-darken-4">{{ department }}</strong>
</v-card-title>
<v-card-subtitle>
Победитель: {{ winner.employee.fio || winner.name }} 🏆
</v-card-subtitle>
<v-card-text>
Количество голосов: {{ winner.count }}
</v-card-text>
</v-card>
</v-col>
</v-row>
<v-row v-else>
<v-col cols="12"> <v-col cols="12">
<h3 class="text-center">{{ question.name }}</h3> <h3 class="text-center">{{ question.name }}</h3>
<v-card-title class="d-flex ga-2 align-center"> <v-card-title class="d-flex ga-2 align-center">
@@ -89,18 +105,25 @@
</v-row> </v-row>
</v-tabs-window-item> </v-tabs-window-item>
<v-tabs-window-item> <v-tabs-window-item>
<v-card-title class="text-red-darken-3">Не голосовали:</v-card-title> <NonVoteSad v-if="Object.keys(groupedByDepartment).length > 0" />
<v-card-item style="max-height: 60vh; overflow-y: auto;"> <v-card-title v-if="Object.keys(groupedByDepartment).length > 0" class="text-red-darken-3">Не голосовали:</v-card-title>
<v-card-item style="max-height: 50vh; overflow-y: auto;">
<NonVoteHappy v-if="Object.keys(groupedByDepartment).length < 1"/>
<template v-for="(voters, department) in groupedByDepartment" :key="department"> <template v-for="(voters, department) in groupedByDepartment" :key="department">
<v-list-item-title class="text-teal-darken-4">{{ department }}</v-list-item-title> <v-list-item-title class="text-teal-darken-4">{{ department }}</v-list-item-title>
<v-list-item v-for="(voter, voterIndex) in voters" :key="voterIndex"> <v-list-item v-for="(voter, voterIndex) in voters" :key="`${department}-${voterIndex}`">
<!-- {{ voter.fio }}-->
<p> <p>
<v-avatar :image="checkremote(`${spravURL()}${voter.login}.jpg`)" <v-avatar
class="cursor-pointer" :image="checkremote(`${spravURL()}${voter.login}.jpg`)"
@click.stop="opendialog(checkremote(`${spravURL()}${voter.login}.jpg`))"/> class="cursor-pointer"
@click="userCardIndex = `${department}-${voterIndex}`"
/>
<InfoUserCard
:opendialog="userCardIndex === `${department}-${voterIndex}`"
@update:opendialog="userCardIndex = $event ? `${department}-${voterIndex}` : null"
:author="voter"
/>
<strong class="ml-4">{{ voter.fio }}</strong> <strong class="ml-4">{{ voter.fio }}</strong>
(<small>{{ voter.post }}</small>) 👿
</p> </p>
</v-list-item> </v-list-item>
</template> </template>
@@ -133,9 +156,13 @@
import {computed, ref} from 'vue'; import {computed, ref} from 'vue';
import {baseURL, spravURL} from "@/utils/axios-api"; import {baseURL, spravURL} from "@/utils/axios-api";
import {checkremote} from "@/utils/universal_functions"; import {checkremote} from "@/utils/universal_functions";
import NonVoteHappy from "@/components/vote/NonVoteHappy.vue";
import NonVoteSad from "@/components/vote/NonVoteSad.vue";
import InfoUserCard from "@/components/UI/fiousercard/infoUserCard.vue";
export default { export default {
name: 'VoteResult', name: 'VoteResult',
components: {InfoUserCard, NonVoteSad, NonVoteHappy},
methods: { methods: {
checkremote, checkremote,
spravURL() { spravURL() {
@@ -157,6 +184,7 @@ export default {
setup(props) { setup(props) {
const activeTab = ref(0); const activeTab = ref(0);
const questions = computed(() => props.data.questions || []); const questions = computed(() => props.data.questions || []);
const userCardIndex = ref(null);
const title = props.data.name; const title = props.data.name;
const description = props.data.description; const description = props.data.description;
@@ -204,7 +232,8 @@ export default {
} }
const groupedByDepartment = computed(() => { const groupedByDepartment = computed(() => {
return nonVoters.reduce((groups, voter) => { // Группируем пользователей по департаментам
const departments = nonVoters.reduce((groups, voter) => {
const department = voter.department || ''; const department = voter.department || '';
if (!groups[department]) { if (!groups[department]) {
groups[department] = []; groups[department] = [];
@@ -212,9 +241,54 @@ export default {
groups[department].push(voter); groups[department].push(voter);
return groups; return groups;
}, {}); }, {});
// Сортируем департаменты по id_dict_department
const sortedDepartments = Object.keys(departments).sort((a, b) => {
const idA = nonVoters.find(voter => voter.department === a)?.id_dict_department;
const idB = nonVoters.find(voter => voter.department === b)?.id_dict_department;
return idA - idB;
});
// Возвращаем отсортированные департаменты с пользователями
const sortedGroupedByDepartment = {};
sortedDepartments.forEach(department => {
sortedGroupedByDepartment[department] = departments[department];
});
return sortedGroupedByDepartment;
}); });
// const groupedByDepartment = {};
const getWinnersByDepartment = (question) => {
// Группируем ответы по департаментам
const groupedByDepartment = question.answers.reduce((groups, answer) => {
const department = answer.employee?.department || 'Без отдела'; // Отдел или 'Без отдела' если нет
if (!groups[department]) {
groups[department] = [];
}
groups[department].push(answer);
return groups;
}, {});
// Для каждого департамента находим победителя
const winnersByDepartment = {};
for (const department in groupedByDepartment) {
const answers = groupedByDepartment[department];
const winner = answers.reduce(
(max, answer) => (answer.count > max.count ? answer : max),
{count: 0, employee: {fio: '', department: '', post: ''}, name: ''}
);
winnersByDepartment[department] = winner;
}
return winnersByDepartment;
};
return { return {
getWinnersByDepartment,
userCardIndex,
activepick, activepick,
opendialog, opendialog,
dialog, dialog,
+16 -6
View File
@@ -108,8 +108,9 @@ export default {
res.value = data; res.value = data;
} catch (error) { } catch (error) {
console.error("Ошибка при загрузке данных голосования:", error); console.error("Ошибка при загрузке данных голосования:", error);
res.value = null; // res.value = {};
router.push({ name: "VoteHomePage" });
throw error;
} }
}; };
@@ -119,7 +120,7 @@ export default {
result.value = data; result.value = data;
} catch (error) { } catch (error) {
console.error("Ошибка при загрузке данных голосования:", error); console.error("Ошибка при загрузке данных голосования:", error);
res.value = null; res.value = {};
} }
}; };
@@ -135,9 +136,14 @@ export default {
const openModal = async (type, voting) => { const openModal = async (type, voting) => {
selectedVoting.value = voting; selectedVoting.value = voting;
if (type === "vote") { if (type === "vote") {
await loadVoteDetails(voting.id); try{
voteModal.value = true; await loadVoteDetails(voting.id);
console.log("sd;lkjs;ljlmnjlk");
voteModal.value = true;
router.push({name: "Voting", params: {id: voting.id}}); router.push({name: "Voting", params: {id: voting.id}});
}catch(e){
router.push({ name: "VoteHomePage" })
}
} else if (type === "results") { } else if (type === "results") {
await loadVoteResult(voting.id); await loadVoteResult(voting.id);
resultsModal.value = true; resultsModal.value = true;
@@ -162,8 +168,12 @@ export default {
if (!voteModal.value && !resultsModal.value) { if (!voteModal.value && !resultsModal.value) {
const voting = votes.value.find((v) => v.id === route.params.id); const voting = votes.value.find((v) => v.id === route.params.id);
if (route.name === "Voting") { if (route.name === "Voting") {
try{
await loadVoteDetails(route.params.id); await loadVoteDetails(route.params.id);
voteModal.value = true; voteModal.value = true;}
catch(e){
router.push({ name: "VoteHomePage" })
}
} }
// if (route.name === "EditVote") editVoteModal.value = true; // if (route.name === "EditVote") editVoteModal.value = true;
if (route.name === "VoteResults") { if (route.name === "VoteResults") {