Merge branch 'develop' into сja
This commit is contained in:
commit
df2f96367c
8 files changed
+418
-68
No files matched your search
@@ -142,7 +142,7 @@ class VoteCreate(APIView):
|
||||
text = f'Пройдите голосование "{vote_url}" до {formatted_date}',
|
||||
cdate = request.data['startDate'],
|
||||
author = request.user,
|
||||
link = os.path.join(settings.MEDIA_ROOT,'defaultimg','vote.png'),
|
||||
link = os.path.join('defaultimg','vote.png'),
|
||||
vote = vote
|
||||
)
|
||||
news.save()
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
<v-btn
|
||||
color="modal_btn"
|
||||
variant="text"
|
||||
@click= "$emit('update:opendialog', value)"
|
||||
@click= "$emit('update:opendialog', false)"
|
||||
>
|
||||
Закрыть
|
||||
</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>
|
||||
<span>{{ voteCard.name }}</span>
|
||||
</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-row>
|
||||
<v-col>
|
||||
|
||||
@@ -14,13 +14,13 @@
|
||||
</v-card>
|
||||
</template>
|
||||
<template v-else>
|
||||
|
||||
|
||||
<div class="v-col flex-grow-1 flex-shrink-0 ">
|
||||
|
||||
|
||||
<v-stepper v-model="step" editable class="d-flex flex-column fill-height">
|
||||
<v-stepper-header class="flex-grow-0 flex-shrink-1">
|
||||
<v-stepper-item :complete="step > 0" step="1">Основная информация
|
||||
|
||||
|
||||
</v-stepper-item>
|
||||
<v-divider></v-divider>
|
||||
<v-stepper-item :complete="step > 1" step="2">Создание опроса</v-stepper-item>
|
||||
@@ -40,7 +40,7 @@
|
||||
<div class="flex-grow-1 flex-shrink-0">
|
||||
|
||||
<v-textarea v-model="form.description" :rules="[rules.required]" label="Описание"
|
||||
|
||||
|
||||
variant="outlined"></v-textarea>
|
||||
</div>
|
||||
<v-divider></v-divider>
|
||||
@@ -70,7 +70,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</v-card-text>
|
||||
|
||||
|
||||
<v-card-actions>
|
||||
<v-btn color="teal-darken-4" size="medium" @click="step = 1">Далее</v-btn>
|
||||
</v-card-actions>
|
||||
@@ -82,7 +82,7 @@
|
||||
|
||||
<v-card flat class="fill-height d-flex flex-column">
|
||||
<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">
|
||||
<div v-for="(question, index) in form.questions" :key="index" class="mb-4">
|
||||
<div class="d-flex">
|
||||
@@ -105,12 +105,12 @@
|
||||
</v-col>
|
||||
<v-col cols="3" class="py-0 align-self-center ">
|
||||
|
||||
<v-select density="compact" v-model="question.settings.choice" :items="questionTypes"
|
||||
<v-select density="compact" v-model="question.settings.choice" :items="questionTypes"
|
||||
@update:model-value="question.answers=[]"
|
||||
:list-props="{density:'compact'}"
|
||||
item-title="name" item-value="choice" label="" hide-details variant="outlined"></v-select>
|
||||
<!-- choice -->
|
||||
|
||||
|
||||
</v-col>
|
||||
<v-spacer/>
|
||||
<v-col cols="auto" class="align-self-center font-weight-bold">
|
||||
@@ -121,7 +121,7 @@
|
||||
:rules="[rules.required && question.settings.multiChoice > 0]" hide-details type="number"
|
||||
min="1" variant="outlined">
|
||||
<template v-slot:prepend>
|
||||
|
||||
|
||||
</template>
|
||||
</v-text-field>
|
||||
</v-col>
|
||||
@@ -141,18 +141,18 @@
|
||||
|
||||
</v-btn>
|
||||
</div>
|
||||
|
||||
|
||||
</transition-group>
|
||||
|
||||
|
||||
<div class="d-flex justify-start">
|
||||
<v-btn size="small" color="teal-darken-4" @click="addAnswer(index)">Добавить ответ</v-btn>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div v-else>
|
||||
|
||||
<div class="v-row">
|
||||
|
||||
|
||||
<div class="v-row">
|
||||
|
||||
<v-radio-group class="text-caption" inline v-model="question.settings.onlyDep">
|
||||
<template v-slot:label>
|
||||
<div class="text-body-2 font-weight-bold">Голосование по отделам:</div>
|
||||
@@ -161,21 +161,21 @@
|
||||
<template v-slot:label>
|
||||
<div class="text-caption">{{ x.name }}</div>
|
||||
</template>
|
||||
</v-radio>
|
||||
</v-radio>
|
||||
</v-radio-group>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<v-autocomplete
|
||||
|
||||
|
||||
<v-autocomplete
|
||||
class=" text-no-wrap"
|
||||
v-model="question.selectedEmployees" :items="allEmployeesgroupedbydep"
|
||||
item-title="fio" item-value="id" label="Выберите сотрудников" multiple variant="outlined"
|
||||
density="compact"
|
||||
density="compact"
|
||||
@update:model-value="(selected)=>question.answers=question.answers.filter(e=>selected.includes(e.text))"
|
||||
>
|
||||
<template #prepend-item>
|
||||
@@ -185,38 +185,38 @@
|
||||
<template #selection="{item}">
|
||||
<v-chip
|
||||
:prepend-avatar="checkremote(`${spravURL}${item.raw.login}.jpg`)"
|
||||
>
|
||||
|
||||
>
|
||||
|
||||
{{ item.raw.familyname }}</v-chip>
|
||||
</template>
|
||||
|
||||
|
||||
|
||||
<template #item="data">
|
||||
|
||||
|
||||
<template v-if="typeof data.item.raw !== 'object'">
|
||||
<v-divider/>
|
||||
<v-list-group class='pa-4 text-overline text-grey' v-text="data.item.raw"></v-list-group>
|
||||
</template>
|
||||
<template v-else>
|
||||
<v-list-item
|
||||
|
||||
|
||||
slim
|
||||
density="compact"
|
||||
:append-avatar="checkremote(`${spravURL}${data.item.raw.login}.jpg`)"
|
||||
@click="onEmployeesChange(data.item.raw.id, index)"
|
||||
>
|
||||
<template #prepend>
|
||||
|
||||
|
||||
<v-checkbox hide-details
|
||||
|
||||
:model-value="question.selectedEmployees.includes(data.item.raw.id)"
|
||||
|
||||
:model-value="question.selectedEmployees.includes(data.item.raw.id)"
|
||||
density="compact"></v-checkbox>
|
||||
</template>
|
||||
<v-list-item-title class="text-third" v-text="data.item.raw.fio"></v-list-item-title>
|
||||
</v-list-item>
|
||||
|
||||
|
||||
|
||||
|
||||
</template>
|
||||
</template>
|
||||
|
||||
@@ -232,10 +232,10 @@
|
||||
<transition-group name="list" tag="div">
|
||||
<div v-for="(person, ind) in question.answers" :key="person" class="v-row align-center mb-4">
|
||||
<v-col cols="7" class="py-0" >
|
||||
|
||||
|
||||
<v-chip :prepend-avatar="checkremote(`${spravURL}${findEmployeeById(person.text)?.login}.jpg`)" :text="findEmployeeById(person.text)?.fio ">
|
||||
|
||||
|
||||
|
||||
|
||||
</v-chip>
|
||||
</v-col>
|
||||
<v-col class="py-0 d-flex" cols="5">
|
||||
@@ -253,7 +253,7 @@
|
||||
</div>
|
||||
</transition-group>
|
||||
<v-divider class="ma-2 pa-1"></v-divider>
|
||||
<div class="d-flex justify-center">
|
||||
<div class="d-flex justify-center">
|
||||
|
||||
<v-btn size="small" color="orange-darken-4" @click="addQuestion">Добавить вопрос</v-btn>
|
||||
</div>
|
||||
@@ -263,25 +263,25 @@
|
||||
<v-btn color="teal-darken-4" size="medium" @click="step = 2">Далее</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
|
||||
|
||||
</v-stepper-window-item>
|
||||
|
||||
<!-- Подтверждение -->
|
||||
<v-stepper-window-item step="3" class="fill-height">
|
||||
|
||||
|
||||
<v-card flat class="fill-height d-flex flex-column">
|
||||
<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">
|
||||
{{ errorMessage }}
|
||||
</v-alert>
|
||||
|
||||
|
||||
<p><v-icon size="xsmall" :class="form.title===null||form.title.length==0?'':'opacity-0'" color='red' icon="mdi-alert"/><strong class="px-2">Название:</strong> {{ form.title }}</p>
|
||||
<p><v-icon size="xsmall" :class="form.description===null||form.description.length==0?'':'opacity-0'" color='red' icon="mdi-alert"/><strong class="px-2">Описание:</strong> {{ form.description }}</p>
|
||||
<p><strong class="px-2">Дата начала:</strong> {{ form.startDate.toLocaleDateString() }}</p>
|
||||
<p><strong class="px-2">Дата окончания:</strong> {{ form.endDate.toLocaleDateString() }}</p>
|
||||
<p><strong class="px-2">Вопросы:</strong></p>
|
||||
|
||||
|
||||
<v-card v-for="(question, index) in form.questions" :key="index" class="mb-4 pa-3">
|
||||
<div class="pa-2">
|
||||
|
||||
@@ -289,8 +289,8 @@
|
||||
|
||||
<div v-if="question.settings.choice === 'free' && question.answers.length">
|
||||
<p><strong>Варианты ответов:</strong></p>
|
||||
|
||||
|
||||
|
||||
|
||||
<ul>
|
||||
<li v-for="(answer, answerIndex) in question.answers" :key="answerIndex">
|
||||
{{ answer.text }}
|
||||
@@ -309,20 +309,20 @@
|
||||
</div>
|
||||
</div>
|
||||
</v-card>
|
||||
|
||||
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-btn color="teal-darken-4" size="medium" @click="step -= 1">Назад</v-btn>
|
||||
<v-btn :disabled="errorMessage!=''" color="teal-darken-4" size="medium" @click="saveVoting">Сохранить</v-btn>
|
||||
</v-card-actions>
|
||||
|
||||
|
||||
</v-card>
|
||||
</v-stepper-window-item>
|
||||
|
||||
</v-stepper-window>
|
||||
</v-stepper>
|
||||
</div>
|
||||
|
||||
|
||||
</template>
|
||||
</v-row>
|
||||
|
||||
@@ -374,7 +374,7 @@ export default {
|
||||
for (let x of allEmployees.value.sort((a,b)=>a.id_dict_department-b.id_dict_department)){
|
||||
if(!groupped.includes(x.department))groupped.push(x.department)
|
||||
groupped.push(x)
|
||||
}
|
||||
}
|
||||
return groupped
|
||||
})
|
||||
const findEmployeeById = (id) =>
|
||||
@@ -532,7 +532,7 @@ export default {
|
||||
removeQuestion,
|
||||
addAnswer,
|
||||
removeAnswer,
|
||||
findEmployeeById,
|
||||
findEmployeeById,
|
||||
saveVoting,
|
||||
isVoteCreated,
|
||||
resetForm,
|
||||
|
||||
@@ -28,10 +28,26 @@
|
||||
</v-tab>
|
||||
<v-tab>Не голосовали</v-tab>
|
||||
</v-tabs>
|
||||
|
||||
<v-tabs-window v-model="activeTab">
|
||||
<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">
|
||||
<h3 class="text-center">{{ question.name }}</h3>
|
||||
<v-card-title class="d-flex ga-2 align-center">
|
||||
@@ -89,18 +105,25 @@
|
||||
</v-row>
|
||||
</v-tabs-window-item>
|
||||
<v-tabs-window-item>
|
||||
<v-card-title class="text-red-darken-3">Не голосовали:</v-card-title>
|
||||
<v-card-item style="max-height: 60vh; overflow-y: auto;">
|
||||
<NonVoteSad v-if="Object.keys(groupedByDepartment).length > 0" />
|
||||
<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">
|
||||
<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">
|
||||
<!-- {{ voter.fio }}-->
|
||||
<v-list-item v-for="(voter, voterIndex) in voters" :key="`${department}-${voterIndex}`">
|
||||
<p>
|
||||
<v-avatar :image="checkremote(`${spravURL()}${voter.login}.jpg`)"
|
||||
class="cursor-pointer"
|
||||
@click.stop="opendialog(checkremote(`${spravURL()}${voter.login}.jpg`))"/>
|
||||
<v-avatar
|
||||
:image="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>
|
||||
(<small>{{ voter.post }}</small>) 👿
|
||||
</p>
|
||||
</v-list-item>
|
||||
</template>
|
||||
@@ -133,9 +156,13 @@
|
||||
import {computed, ref} from 'vue';
|
||||
import {baseURL, spravURL} from "@/utils/axios-api";
|
||||
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 {
|
||||
name: 'VoteResult',
|
||||
components: {InfoUserCard, NonVoteSad, NonVoteHappy},
|
||||
methods: {
|
||||
checkremote,
|
||||
spravURL() {
|
||||
@@ -157,6 +184,7 @@ export default {
|
||||
setup(props) {
|
||||
const activeTab = ref(0);
|
||||
const questions = computed(() => props.data.questions || []);
|
||||
const userCardIndex = ref(null);
|
||||
|
||||
const title = props.data.name;
|
||||
const description = props.data.description;
|
||||
@@ -204,7 +232,8 @@ export default {
|
||||
}
|
||||
|
||||
const groupedByDepartment = computed(() => {
|
||||
return nonVoters.reduce((groups, voter) => {
|
||||
// Группируем пользователей по департаментам
|
||||
const departments = nonVoters.reduce((groups, voter) => {
|
||||
const department = voter.department || '';
|
||||
if (!groups[department]) {
|
||||
groups[department] = [];
|
||||
@@ -212,9 +241,54 @@ export default {
|
||||
groups[department].push(voter);
|
||||
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 {
|
||||
getWinnersByDepartment,
|
||||
userCardIndex,
|
||||
activepick,
|
||||
opendialog,
|
||||
dialog,
|
||||
|
||||
@@ -108,8 +108,9 @@ export default {
|
||||
res.value = data;
|
||||
} catch (error) {
|
||||
console.error("Ошибка при загрузке данных голосования:", error);
|
||||
res.value = null;
|
||||
router.push({ name: "VoteHomePage" });
|
||||
// res.value = {};
|
||||
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -119,7 +120,7 @@ export default {
|
||||
result.value = data;
|
||||
} catch (error) {
|
||||
console.error("Ошибка при загрузке данных голосования:", error);
|
||||
res.value = null;
|
||||
res.value = {};
|
||||
}
|
||||
};
|
||||
|
||||
@@ -135,9 +136,14 @@ export default {
|
||||
const openModal = async (type, voting) => {
|
||||
selectedVoting.value = voting;
|
||||
if (type === "vote") {
|
||||
await loadVoteDetails(voting.id);
|
||||
voteModal.value = true;
|
||||
try{
|
||||
await loadVoteDetails(voting.id);
|
||||
console.log("sd;lkjs;ljlmnjlk");
|
||||
voteModal.value = true;
|
||||
router.push({name: "Voting", params: {id: voting.id}});
|
||||
}catch(e){
|
||||
router.push({ name: "VoteHomePage" })
|
||||
}
|
||||
} else if (type === "results") {
|
||||
await loadVoteResult(voting.id);
|
||||
resultsModal.value = true;
|
||||
@@ -162,8 +168,12 @@ export default {
|
||||
if (!voteModal.value && !resultsModal.value) {
|
||||
const voting = votes.value.find((v) => v.id === route.params.id);
|
||||
if (route.name === "Voting") {
|
||||
try{
|
||||
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 === "VoteResults") {
|
||||
|
||||
Reference in new issue
Block a user