All files / src/views Vote.vue

0% Statements 0/113
0% Branches 0/50
0% Functions 0/46
0% Lines 0/104

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
<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>