156 lines
4.9 KiB
Vue
156 lines
4.9 KiB
Vue
<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-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>
|
|
<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>
|