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 | <template>
<v-card>
<v-card-text class="d-flex justify-space-between ga-3 text-h6">
<v-tooltip bottom>
<template v-slot:activator="{ props }">
<span
style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"
v-bind="props">
{{ voteCard.name }}
</span>
</template>
<span>{{ voteCard.name }}</span>
</v-tooltip>
</v-card-text>
<v-row>
<v-col>
<v-carousel
cycle
height="200" hide-delimiters
show-arrows="hover">
<v-carousel-item
v-for="(picture, index) in images"
:key="index"
:src="images[index].length < 1 ? defaultImage : `${baseURL.slice(0, -1)}${picture}`">
</v-carousel-item>
</v-carousel>
</v-col>
</v-row>
<v-card-text class="">
<v-tooltip bottom>
<template v-slot:activator="{ props }">
<span
style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"
v-bind="props">
{{ voteCard.description }}
</span>
</template>
<span>{{ voteCard.description }}</span>
</v-tooltip>
</v-card-text>
<div class="px-2">
<Timer v-if="!isFinished" :voteTime="{ dateend: voteCard.dateend, datestart: voteCard.datestart }"
@changeBtn="(time) => timeChange = time"/>
<div v-else class="font-weight-bold text-center"> Завершено: {{
new Date(voteCard.dateend).toLocaleDateString()
}}
</div>
</div>
<v-card-actions class="justify-space-between mt-4 pb-2">
<template v-if="!isFinished">
<v-btn :disabled="voteCard.is_passed || timeChange" color="teal-darken-4" prepend-icon="mdi-vote-outline"
rounded="xl" size="small" variant="outlined" @click="$emit('openVoteModal', voteCard)">
{{ !voteCard.is_passed ? "Проголосовать" : "Уже проголосовали" }}
</v-btn>
</template>
<template v-else>
<v-btn color="teal-darken-4" prepend-icon="mdi-trophy-outline"
rounded="xl" size="small" variant="outlined" @click="$emit('openResultModal', voteCard)">
Результаты
</v-btn>
</template>
<v-btn v-if="user.id === voteCard.author || user.is_superuser" color="error" size="medium" @click="youSure=true">
<v-icon>mdi-delete</v-icon>
<v-dialog v-model="youSure" width="500">
<v-card class="flex" max-width="450">
<v-btn
class="align-self-end ma-2 text-red"
icon="mdi-close"
size="medium"
variant="text"
@click="youSure = false"
/>
<div class="ml-5 text-h6">
Вы действительно хотите удалить голосование?
</div>
<template v-slot:actions>
<v-btn-group>
<v-btn
class="text-red"
@click="$emit('deleteVoting', voteCard.id), youSure = false">
Да
</v-btn>
<v-btn
class="text-green"
@click="youSure = false">
Нет
</v-btn>
</v-btn-group>
</template>
</v-card>
</v-dialog>
</v-btn>
</v-card-actions>
</v-card>
</template>
<script>
import Timer from "@/components/UI/Timer.vue"
import {baseURL} from "@/utils/axios-api";
import {computed, ref} from 'vue'
import {useAccountStore} from "@/store/AccountStore";
import defaultImage from '@/assets/emblem.png'
export default {
components: {Timer},
emits: ['openVoteModal', 'openEditVoteModal', 'deleteVoting', 'openResultModal'],
props: {
isFinished: {
type: Boolean,
default: false
},
voteCard: {
type: Object,
default: () => {
return {
id: 0,
name: "",
description: "",
files: [],
dateend: new Date(new Date().getTime() + 600000),
is_passed: true,
}
}
}
},
setup(props) {
const timeChange = ref(false)
const youSure = ref(false)
const isFinished = ref(false);
const accountStore = useAccountStore();
const user = accountStore.user;
const images = computed(() => {
return props.voteCard.files.length > 0 ? props.voteCard.files : ['']
})
const date = new Date();
const endDate = new Date(props.voteCard.dateend);
const distance = endDate.getTime() - date.getTime();
if (distance <= 0) {
isFinished.value = true;
}
return {timeChange, baseURL, images, youSure, isFinished, user, defaultImage}
}
}
</script>
|