Files
PORTAL_COD2/src/front/src/views/Vote.vue
T

295 lines
13 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<v-row justify="center" class="d-flex align-start h-100" :style="{ backgroundImage: `url('${bgImage}')`, backgroundSize: 'cover' }">
<v-col cols="12" class="d-flex align-center justify-center text-h5 py-3 ma-0">
<!-- <v-col class="pb-0 mb-0 text-center">ТЕКУЩИЕ ГОЛОСОВАНИЯ</v-col> -->
</v-col>
<!-- Голосование Лучший сотрудник -->
<v-col cols="12" justify="center" class="d-flex vote-card-container">
<!-- Голосование Лучший сотрудник КОНЕЦ-->
<!-- Голосование Спасибо -->
<v-col cols="12" justify="center" align="center">
<div class="flip-card" :class="{ 'flipped': isFlipped2 }">
<div class="flip-card-inner">
<div v-if="!uservotedthanks" class="flip-card-front">
<!-- Передняя сторона карточки -->
<v-card class="justify-center elevation-24" width="500" height="510" variant="elevated">
<v-card-title class="text-h5 my-2">ЛУЧШИЙ НОВОГОДНИЙ КОСТЮМ</v-card-title>
<div class="justify-center">
<div>
<v-card class="vote-card-information" variant="flat">
<v-card-text class="justify-center align-center vote-card-information-title">
<p>ВЫ УЖЕ ПРОГОЛОСОВАЛИ.</p>
<p>СПАСИБО!</p>
</v-card-text>
<v-dialog >
<template v-slot:activator="{ props: activatorProps }">
<span class="text-h5">Проголосовало</span> <span
v-bind="admin_panel ? activatorProps : ''" class="text-green text-h4"
:class="{ 'cursor-pointer': admin_panel }">
{{
Math.round((voteresults.uservotedthanks.length * 100 / (allsorted.length + 1)).toFixed(2)) }}%</span>
</template>
<template v-slot:default="{ isActive }">
<v-row justify="center" class="h-100 admin-vote">
<v-card width="1500" height="900">
<vote-admin :usersvotedbest="voteresults.usersvotedbest"
:uservotedthanks="voteresults.uservotedthanks"
:all_cod="allsorted" />
<v-row justify="center" align="center">
<v-btn color="teal-darken-1"
@click="isActive.value = false">ЗАКРЫТЬ</v-btn>
</v-row>
</v-card>
</v-row>
</template>
</v-dialog>
</v-card>
</div>
</div>
<!-- Кнопка активации поворота КОНЕЦ-->
</v-card>
</div>
<div v-else class="flip-card-front" @click="toggleFlip2">
<!-- Передняя сторона карточки -->
<v-card
class="elevation-24 d-flex align-сenter justify-space-between flex-column" width="500" height="510" variant="elevated" >
<div class="">
<div class="text-h5 my-2">ЛУЧШИЙ НОВОГОДНИЙ КОСТЮМ</div>
<div class="mt-4 ">
<div class=" align-center font-weight-bold">
Выберите сотрудника,
костюм которого вам больше всего понравился
</div>
</div>
</div>
<div class="mt-4">
<v-btn :height="100" variant="flat" type="button">
<v-img :width="100" cover src="@/assets/click3.gif"></v-img>
</v-btn>
</div>
<div align="center" class="">
<v-dialog >
<template v-slot:activator="{ props: activatorProps }">
<span class="text-h5">Проголосовало</span> <span
v-bind="admin_panel ? activatorProps : ''" class="text-green text-h4"
:class="{ 'cursor-pointer': admin_panel }">
{{
Math.round((voteresults.uservotedthanks.length * 100 / (allsorted.length + 1)).toFixed(2)) }}%</span>
</template>
<template v-slot:default="{ isActive }">
<v-row justify="center" class="h-100 admin-vote">
<v-card width="1500" height="900">
<vote-admin :usersvotedbest="voteresults.usersvotedbest"
:uservotedthanks="voteresults.uservotedthanks"
:all_cod="allsorted" />
<v-row justify="center" align="center">
<v-btn color="teal-darken-1"
@click="isActive.value = false">ЗАКРЫТЬ</v-btn>
</v-row>
</v-card>
</v-row>
</template>
</v-dialog>
<div class="my-4"><count-down /></div>
</div>
<!-- Кнопка активации поворота КОНЕЦ-->
</v-card>
</div>
<!-- Передняя сторона карточки КОНЕЦ-->
<!-- Задняя сторона карточки -->
<div class="flip-card-back">
<v-card class="d-flex align-сenter justify-space-between elevated-24 flex-column" width="500" height="510" variant="elevated">
<div class="text-h5 my-2">ЛУЧШИЙ НОВОГОДНИЙ КОСТЮМ</div>
<!-- <v-card-text class=""> -->
<vote-form class="flex-grow-1 " ref="voteform" :type_fetch="'thanks'"
:persons="allsorted"
:myrealdep="myrealdep" @voted="toggleFlip2" />
<!-- </v-card-text> -->
<!-- Кнопка активации поворота -->
<v-card-actions class="justify-center">
<v-btn @click="toggleFlip2" variant="elevated" color="red-darken-4"
type="button">назад</v-btn>
<v-btn variant="elevated" color="teal-darken-1"
@click="approveCandidate">Подтвердить выбор</v-btn>
</v-card-actions>
<!-- Кнопка активации поворота КОНЕЦ-->
</v-card>
</div>
<!-- Задняя сторона карточки КОНЕЦ-->
</div>
</div>
</v-col>
</v-col>
</v-row>
</template>
<script>
import { ref, computed } from "vue";
import { clearAxios, axiosApiInstance } from "@/utils/axios-api";
import VoteForm from '@/components/vote/VoteForm.vue';
import bgImage from '@/assets/bg/bg.png';
import VoteAdmin from '@/components/vote/VoteAdmin.vue';
import CountDown from '@/components/CountDown.vue';
import { useAccountStore } from '@/store/AccountStore';
let admin_panel = ref(false);
let account_login = useAccountStore();
export default {
components: {
VoteForm,
CountDown,
VoteAdmin,
},
setup() {
const voteform=ref(null)
const voted_best = ref([])
const full_list_pers = ref([])
let votedListBst = ref([]);
let votedListThn = ref([]);
let voted_thn = ref(false);
let voted_bst = ref(false);
const myrealdep = ref({ id_dict_department: 0, id: 0 })
const uservoted = ref([true, true])
const allcod = ref([])
const isFlipped1 = ref(false);
const isFlipped2 = ref(false);
const voteresults = ref({ usersvotedbest: [], uservotedthanks: [] })
axiosApiInstance.get('/api/vote/getvoteinfo/').then((res) => {
allcod.value = res.data.allcod
myrealdep.value = allcod.value.find(e => e.login === account_login.user.login)
voteresults.value = res.data.voteresults
})
const toggleFlip1 = () => {
isFlipped1.value = !isFlipped1.value;
};
const toggleFlip2 = () => {
isFlipped2.value = !isFlipped2.value;
}
if (['9966-00-134', '9966-00-141', '9966-00-011', '9966-00-125'].includes(account_login.user.login)) {
admin_panel.value = true;
}
const allsorted = computed({
get() {
let all = allcod.value.filter(e => e.id !== myrealdep.value.id)
return all.sort((a, b) => {
if (b.fio > a.fio) return -1
else if (b.fio < a.fio) return 1
return 0
})
}
})
const uservotedthanks = computed({
get() {
let ind = voteresults.value.uservotedthanks.findIndex(e => e.voted_user === account_login.user.login)
if (ind > -1) return false
return true
}
})
const uservotedbest = computed({
get() {
let ind = voteresults.value.usersvotedbest.findIndex(e => e.voted_user === account_login.user.login)
if (ind > -1) return false
return true
}
})
const mydepartment = computed({
get() {
let ac = allcod.value.filter(e => e.id_dict_department === myrealdep.value.id_dict_department && e.id != myrealdep.value.id)
return ac.sort((a, b) => {
if (b.fio > a.fio) return -1
else if (b.fio < a.fio) return 1
return 0
})
}
})
const approveCandidate=()=>{
if (voteform.value!==null) voteform.value.approveCandidate()
}
return {
approveCandidate,
voteform,
myrealdep,
allsorted,
mydepartment,
isFlipped1,
toggleFlip1,
isFlipped2,
toggleFlip2,
account_login,
admin_panel,
voted_bst,
voted_thn,
uservotedthanks,
uservotedbest,
voteresults,
bgImage
};
},
};
</script>
<style scoped>
.vote-card-container {
height: 600px !important;
}
.flip-card-inner {
display: flex;
position: relative;
transition: transform 0.8s;
transform-style: preserve-3d;
}
.flipped .flip-card-inner {
transform: rotateY(-180deg);
}
.flip-card-front,
.flip-card-back {
position: absolute;
width: 100%;
backface-visibility: hidden;
}
.flip-card-back {
transform: rotateY(-180deg);
}
.vote-card-information {
background-color: rgba(255, 255, 255, 0.7);
margin-top: 20%;
width: 460px;
height: 200px;
}
.vote-card-information-title {
font-size: 1.2em;
}
</style>