Merge branch 'develop' into сja

This commit is contained in:
Cja committed 2025-01-23 10:21:41 +03:00
commit 571032eeee
9 files changed
+163 -43

No files matched your search

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

+1 -1
View File
@@ -88,7 +88,7 @@
type="error" type="error"
density="compact" density="compact"
title="Ошибка авторизации" title="Ошибка авторизации"
:text="info"
v-model="alert" v-model="alert"
+1 -1
View File
@@ -14,7 +14,7 @@
class="d-flex pa-1 flex-column " class="d-flex pa-1 flex-column "
> >
<news-card :news="x"/> <news-card :news="x"/>
{{aNewsAll}}
</v-col> </v-col>
</v-row> </v-row>
<v-row class="flex-grow-0 "> <v-row class="flex-grow-0 ">
@@ -42,6 +42,7 @@
</h3> </h3>
<v-row> <v-row>
<div class="v-col align-self-start"> <div class="v-col align-self-start">
<VoteAnimation v-if="!question.file" />
<v-img <v-img
:src="question.file" :src="question.file"
class="cursor-pointer" class="cursor-pointer"
@@ -145,9 +146,11 @@ import {axiosApiInstance, spravURL} from "@/utils/axios-api";
import {computed, ref} from "vue"; import {computed, ref} from "vue";
import {useAccountStore} from "@/store/AccountStore"; import {useAccountStore} from "@/store/AccountStore";
import {checkremote} from "@/utils/universal_functions"; import {checkremote} from "@/utils/universal_functions";
import VoteAnimation from "@/components/vote/VoteAnimation.vue";
export default { export default {
name: 'CurrentVote', name: 'CurrentVote',
components: {VoteAnimation},
methods: { methods: {
checkremote, checkremote,
spravURL() { spravURL() {
@@ -0,0 +1,92 @@
<template>
<v-container class="d-flex flex-column align-center">
<div class="animation-container">
<div class="ballot">
<span class="ballot-text">Голос</span>
</div>
<div class="urn">
<div class="slot"></div>
</div>
</div>
</v-container>
</template>
<script>
export default {
setup() {
return {};
},
};
</script>
<style scoped>
.animation-container {
position: relative;
width: 200px;
height: 300px;
display: flex;
justify-content: center;
align-items: flex-end;
overflow: hidden;
}
.ballot {
position: absolute;
width: 60px;
height: 40px;
background-color: #004D40;
border-radius: 4px;
color: #fff;
font-size: 14px;
font-weight: bold;
text-align: center;
line-height: 40px;
animation: dropBallot 3s cubic-bezier(0.4, 0, 0.2, 1) infinite;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}
.ballot-text {
display: block;
}
.urn {
position: absolute;
bottom: 0;
width: 120px;
height: 80px;
background-color: #546E7A;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
display: flex;
justify-content: center;
align-items: flex-start;
}
.slot {
width: 60px;
height: 10px;
background-color: #455A64;
border-radius: 5px;
}
@keyframes dropBallot {
0% {
top: -50px;
transform: rotate(0deg);
opacity: 1;
}
40% {
transform: rotate(15deg);
}
60% {
top: 220px;
transform: rotate(-10deg);
opacity: 1;
}
100% {
transform: rotate(0deg);
opacity: 0.8;
}
}
</style>
+7 -3
View File
@@ -25,7 +25,7 @@
<v-carousel-item <v-carousel-item
v-for="(picture, index) in images" v-for="(picture, index) in images"
:key="index" :key="index"
:src="`${baseURL.slice(0, -1)}${picture}`"> :src="images[index].length < 1 ? defaultImage : `${baseURL.slice(0, -1)}${picture}`">
</v-carousel-item> </v-carousel-item>
</v-carousel> </v-carousel>
</v-col> </v-col>
@@ -42,12 +42,15 @@
<span>{{ voteCard.description }}</span> <span>{{ voteCard.description }}</span>
</v-tooltip> </v-tooltip>
</v-card-text> </v-card-text>
<div class="px-2">
<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 v-else class="font-weight-bold text-center"> Завершено: {{ <div v-else class="font-weight-bold text-center"> Завершено: {{
new Date(voteCard.dateend).toLocaleDateString() new Date(voteCard.dateend).toLocaleDateString()
}} }}
</div> </div>
</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"
@@ -101,6 +104,7 @@ import Timer from "@/components/UI/Timer.vue"
import {baseURL} from "@/utils/axios-api"; import {baseURL} from "@/utils/axios-api";
import {computed, ref} from 'vue' import {computed, ref} from 'vue'
import {useAccountStore} from "@/store/AccountStore"; import {useAccountStore} from "@/store/AccountStore";
import defaultImage from '../../assets/emblem.png'
export default { export default {
components: {Timer}, components: {Timer},
@@ -132,7 +136,7 @@ export default {
const user = accountStore.user; const user = accountStore.user;
const images = computed(() => { const images = computed(() => {
return props.voteCard.files.length > 0 ? props.voteCard.files : ['/media/defaultimg/vote.png'] return props.voteCard.files.length > 0 ? props.voteCard.files : ['']
}) })
const date = new Date(); const date = new Date();
@@ -143,7 +147,7 @@ export default {
isFinished.value = true; isFinished.value = true;
} }
return {timeChange, baseURL, images, youSure, isFinished, user} return {timeChange, baseURL, images, youSure, isFinished, user, defaultImage}
} }
} }
@@ -100,20 +100,20 @@
<div class="py-2 text-overline text-grey">Настройки вопроса</div> <div class="py-2 text-overline text-grey">Настройки вопроса</div>
<div class="v-row "> <div class="v-row ">
<v-col class="align-self-center font-weight-bold py-0"> <v-col cols="auto" class="align-self-center font-weight-bold py-0">
Тип ответа Тип ответа
</v-col> </v-col>
<v-col cols="3" class="py-0"> <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=[]" @update:model-value="question.answers=[]"
:list-props="{density:'compact'}" :list-props="{density:'compact'}"
item-title="name" item-value="choice" label="" hide-details variant="outlined"></v-select> item-title="name" item-value="choice" label="" hide-details variant="outlined"></v-select>
<!-- choice --> <!-- choice -->
</v-col> </v-col>
</div> <v-spacer/>
<div class="v-row"> <v-col cols="auto" class="align-self-center font-weight-bold">
<v-col class="align-self-center font-weight-bold">
Число возможных ответов Число возможных ответов
</v-col> </v-col>
<v-col cols="1" class=""> <v-col cols="1" class="">
@@ -121,11 +121,13 @@
:rules="[rules.required && question.settings.multiChoice > 0]" hide-details type="number" :rules="[rules.required && question.settings.multiChoice > 0]" hide-details type="number"
min="1" variant="outlined"> min="1" variant="outlined">
<template v-slot:prepend> <template v-slot:prepend>
</template> </template>
</v-text-field> </v-text-field>
</v-col> </v-col>
</div> </div>
<div class="v-row">
</div>
<v-card-text class="px-0"> <v-card-text class="px-0">
<div v-if="question.settings.choice === 'free'"> <div v-if="question.settings.choice === 'free'">
@@ -141,6 +143,7 @@
</div> </div>
</transition-group> </transition-group>
<div class="d-flex justify-start"> <div class="d-flex justify-start">
<v-btn size="small" color="teal-darken-4" @click="addAnswer(index)">Добавить ответ</v-btn> <v-btn size="small" color="teal-darken-4" @click="addAnswer(index)">Добавить ответ</v-btn>
@@ -161,10 +164,7 @@
</v-radio> </v-radio>
</v-radio-group> </v-radio-group>
<!-- <v-switch color="teal-darken-4" v-model="question.settings.withoutDirector"
:label="`Без начальства : ${question.settings.withoutDirector ? 'да ' : 'нет'}`" hide-details
class="v-col-auto"></v-switch> -->
</div> </div>
@@ -400,7 +400,7 @@ export default {
const addQuestion = () => { const addQuestion = () => {
form.value.questions.push({ form.value.questions.push({
text: "", text: "",
settings: { choice: "free", multiChoice: 1, onlyDep: null, withoutDirector: false }, settings: { choice: "free", multiChoice: 1, onlyDep: null },
image: null, image: null,
answers: [], answers: [],
selectedEmployees: [] selectedEmployees: []
@@ -464,17 +464,11 @@ export default {
}); });
const selectedTimeStart = ref( const selectedTimeStart = ref(
`${form.value.startDate.getHours().toString().padStart(2, "0")}:${form.value.startDate `${(form.value.startDate.getHours()+1).toString().padStart(2, "0")}:00`
.getMinutes()
.toString()
.padStart(2, "0")}`
); );
const selectedTimeEnd = ref( const selectedTimeEnd = ref(
`${form.value.endDate.getHours().toString().padStart(2, "0")}:${form.value.endDate `${(form.value.endDate.getHours()+1).toString().padStart(2, "0")}:00`
.getMinutes()
.toString()
.padStart(2, "0")}`
); );
watch(form.value, () => { watch(form.value, () => {
+35 -15
View File
@@ -1,5 +1,5 @@
<template> <template>
<v-container> <v-container style="height: 85vh">
<div class="text-end"> <div class="text-end">
<v-btn class="" color="red-darken-1" density="compact" icon="mdi-close-thick" size="small" <v-btn class="" color="red-darken-1" density="compact" icon="mdi-close-thick" size="small"
@click="$emit('closer')"> @click="$emit('closer')">
@@ -46,7 +46,7 @@
<v-card class="mb-4"> <v-card class="mb-4">
<v-card-title class="text-teal-darken-3">Топ {{ getTopResults(question).length }}</v-card-title> <v-card-title class="text-teal-darken-3">Топ {{ getTopResults(question).length }}</v-card-title>
<v-card-text> <v-card-text>
<v-list style="max-height: 40vh; overflow-y: auto;"> <v-list style="max-height: 45vh; overflow-y: auto;">
<v-list-item <v-list-item
v-for="(answer, answerIndex) in getTopResults(question)" v-for="(answer, answerIndex) in getTopResults(question)"
:key="answerIndex" :key="answerIndex"
@@ -88,18 +88,24 @@
</v-col> </v-col>
</v-row> </v-row>
</v-tabs-window-item> </v-tabs-window-item>
<!-- Не голосовали --> <v-tabs-window-item>
<!-- <v-tabs-window-item v-for="(question, questionIndex) in questions" :key="questionIndex">--> <v-card-title class="text-red-darken-3">Не голосовали:</v-card-title>
<!-- <v-card-title class="text-red-darken-3">Не голосовали:</v-card-title>--> <v-card-item style="max-height: 60vh; overflow-y: auto;">
<!-- <v-list style="max-height: 40vh; overflow-y: auto;">--> <template v-for="(voters, department) in groupedByDepartment" :key="department">
<!-- <v-list-item--> <v-list-item-title class="text-teal-darken-4">{{ department }}</v-list-item-title>
<!-- v-for="(answer, answerIndex) in getTopResults(question)"--> <v-list-item v-for="(voter, voterIndex) in voters" :key="voterIndex">
<!-- :key="answerIndex"--> <!-- {{ voter.fio }}-->
<!-- >--> <p>
<!-- {{answer.employee.fio}}--> <v-avatar :image="checkremote(`${spravURL()}${voter.login}.jpg`)"
<!-- </v-list-item>--> class="cursor-pointer"
<!-- </v-list>--> @click.stop="opendialog(checkremote(`${spravURL()}${voter.login}.jpg`))"/>
<!-- </v-tabs-window-item>--> <strong class="ml-4">{{ voter.fio }}</strong>
(<small>{{ voter.post }}</small>) 👿
</p>
</v-list-item>
</template>
</v-card-item>
</v-tabs-window-item>
</v-tabs-window> </v-tabs-window>
</v-container> </v-container>
@@ -154,6 +160,7 @@ export default {
const title = props.data.name; const title = props.data.name;
const description = props.data.description; const description = props.data.description;
const nonVoters = props.data.nonvoting;
const getWinner = (question) => { const getWinner = (question) => {
return question.answers.reduce( return question.answers.reduce(
@@ -196,6 +203,17 @@ export default {
activepick.value = val activepick.value = val
} }
const groupedByDepartment = computed(() => {
return nonVoters.reduce((groups, voter) => {
const department = voter.department || '';
if (!groups[department]) {
groups[department] = [];
}
groups[department].push(voter);
return groups;
}, {});
});
return { return {
activepick, activepick,
opendialog, opendialog,
@@ -209,7 +227,9 @@ export default {
voteCount, voteCount,
title, title,
description, description,
getPercentage getPercentage,
nonVoters,
groupedByDepartment
}; };
}, },
}; };
+11 -4
View File
@@ -6,9 +6,13 @@
v-model="currentTab" v-model="currentTab"
align="center"> align="center">
<v-tab v-for="x in tabs" :key="x.value" :value="x.value">{{ x.text }}</v-tab> <v-tab v-for="x in tabs" :key="x.value" :value="x.value">{{ x.text }}</v-tab>
<v-tab v-if="accountStore.user.is_staff" value="constructor">Создать новое голосование</v-tab>
</v-tabs> </v-tabs>
</v-col> </v-col>
<v-col class="pa-0 overflow-hidden"> <v-col class="pa-0 overflow-hidden">
<v-window v-model="currentTab" class="h-100"> <v-window v-model="currentTab" class="h-100">
<!-- Текущие голосования --> <!-- Текущие голосования -->
<v-tabs-window-item v-for="x in ['active','completed']" :value="x" class="h-100 overflow-auto"> <v-tabs-window-item v-for="x in ['active','completed']" :value="x" class="h-100 overflow-auto">
@@ -31,11 +35,11 @@
</v-row> </v-row>
</v-tabs-window-item> </v-tabs-window-item>
<!-- Конструктор --> <!-- Конструктор -->
<v-tabs-window-item class="h-100 overflow-auto" value="constructor"> <v-tabs-window-item v-if="accountStore.user.is_staff" class="h-100 overflow-auto" value="constructor">
<VoteConstructor @updating="updating"/> <VoteConstructor @updating="updating"/>
</v-tabs-window-item> </v-tabs-window-item>
</v-window> </v-window>
<!-- Модальные окна --> <!-- Модальные окна -->
<v-dialog v-model="voteModal" @click:outside="closeModal"> <v-dialog v-model="voteModal" @click:outside="closeModal">
<CurrentVote :data="res" @closer="closeModal"/> <CurrentVote :data="res" @closer="closeModal"/>
@@ -63,16 +67,17 @@ import {useRoute, useRouter} from "vue-router";
import VoteResult from "@/components/vote/VoteResult.vue"; import VoteResult from "@/components/vote/VoteResult.vue";
import {deleteVote, getVoteDetail, getVoteResult, getVotes} from "@/utils/axios-api"; import {deleteVote, getVoteDetail, getVoteResult, getVotes} from "@/utils/axios-api";
import {formatDate} from "@vueuse/shared"; import {formatDate} from "@vueuse/shared";
import { useAccountStore } from "@/store/AccountStore";
export default { export default {
methods: {formatDate}, methods: {formatDate},
components: {CurrentVote, VoteConstructor, VoteCardVue, VoteResult}, components: {CurrentVote, VoteConstructor, VoteCardVue, VoteResult},
setup() { setup() {
const accountStore = useAccountStore();
const tabs = [ const tabs = [
{value: "active", text: 'Текущие голосования'}, {value: "active", text: 'Текущие голосования'},
{value: "completed", text: 'Завершенные голосования'}, {value: "completed", text: 'Завершенные голосования'},
{value: "constructor", text: 'Создать новое голосование'},
] ]
const currentTab = ref("active"); const currentTab = ref("active");
@@ -104,6 +109,7 @@ export default {
} catch (error) { } catch (error) {
console.error("Ошибка при загрузке данных голосования:", error); console.error("Ошибка при загрузке данных голосования:", error);
res.value = null; res.value = null;
router.push({ name: "VoteHomePage" });
} }
}; };
@@ -173,6 +179,7 @@ export default {
updating("active"); updating("active");
return { return {
accountStore,
currentTab, currentTab,
votes, votes,
sortedVotes, sortedVotes,