fix
This commit is contained in:
1 parent
5e831cc6ac
commit
fd051aa28d
3 files changed
+65
-27
No files matched your search
@@ -1,32 +1,34 @@
|
||||
<template>
|
||||
<v-row dense class="ma-1 ">
|
||||
<v-card variant="text" class="py-1">
|
||||
<v-card-title class="text-body-1"> До окончания голосования осталось: </v-card-title>
|
||||
<v-row dense>
|
||||
<v-card variant="text"
|
||||
:disabled="disabledcard.disabled"
|
||||
class="py-1">
|
||||
<v-card-title class="text-body-1"> До {{ disabledcard.text }} голосования осталось: </v-card-title>
|
||||
<v-row dense class="align-baseline justify-center">
|
||||
<v-col cols="auto" class="text-center">
|
||||
<v-col cols="2" class="text-center">
|
||||
<v-card class="bg-yellow-darken-4">
|
||||
<v-card-title>{{ displayDays }}</v-card-title>
|
||||
<div>{{ displayDays }}</div>
|
||||
</v-card>
|
||||
<span class="text-caption">{{ declOfNum(displayDays, [' день', ' дня', ' дней']) }}</span>
|
||||
</v-col>
|
||||
<v-col cols="auto">:</v-col>
|
||||
<v-col cols="auto" class="text-center">
|
||||
<v-col cols="2" class="text-center">
|
||||
<v-card class="bg-yellow-darken-4">
|
||||
<v-card-title>{{ displayHours }}</v-card-title>
|
||||
<div>{{ displayHours }}</div>
|
||||
</v-card>
|
||||
<span class="text-caption">{{ declOfNum(displayHours, [' час', ' часа', ' часов']) }}</span>
|
||||
</v-col>
|
||||
<v-col cols="auto">:</v-col>
|
||||
<v-col cols="auto" class="text-center">
|
||||
<v-col cols="2" class="text-center">
|
||||
<v-card class="bg-yellow-darken-4">
|
||||
<v-card-title>{{ displayMinutes }}</v-card-title>
|
||||
<div>{{ displayMinutes }}</div>
|
||||
</v-card>
|
||||
<span class="text-caption">{{ declOfNum(displayMinutes, [' минута', ' минуты', ' минут']) }}</span>
|
||||
</v-col>
|
||||
<v-col cols="auto">:</v-col>
|
||||
<v-col cols="auto" class="text-center">
|
||||
<v-col cols="2" class="text-center">
|
||||
<v-card class="bg-yellow-darken-4">
|
||||
<v-card-title>{{ displaySeconds }}</v-card-title>
|
||||
<div>{{ displaySeconds }}</div>
|
||||
</v-card>
|
||||
<span class="text-caption">{{ declOfNum(displaySeconds, [' секунда', ' секунды', ' секунд']) }}</span>
|
||||
</v-col>
|
||||
@@ -39,9 +41,11 @@ import { computed, ref } from 'vue'
|
||||
|
||||
export default {
|
||||
props: {
|
||||
endTime: {
|
||||
type: String,
|
||||
default: () => { return new Date(props.endTime).setFullYear() }
|
||||
voteTime: {
|
||||
type: Object,
|
||||
default: () => { return {dateend:new Date().setFullYear(),
|
||||
datestart:new Date().setFullYear()
|
||||
}}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -68,14 +72,37 @@ export default {
|
||||
const cases = [2, 0, 1, 1, 1, 2]
|
||||
return titles[(value % 100 > 4 && value % 100 < 20) ? 2 : cases[(value % 10 < 5) ? value % 10 : 5]]
|
||||
}
|
||||
const disabledcard = ref({
|
||||
text: 'окончания',
|
||||
disabled: false
|
||||
})
|
||||
|
||||
const dateendorStart = ()=>{
|
||||
let param = 'dateend'
|
||||
|
||||
if (new Date().getTime()<new Date(props.voteTime.datestart).getTime()){
|
||||
param='datestart'
|
||||
disabledcard.value={text: 'начала',
|
||||
disabled:true
|
||||
}
|
||||
}else{
|
||||
disabledcard.value={text: 'окончания',
|
||||
disabled:false
|
||||
}
|
||||
}
|
||||
return param
|
||||
}
|
||||
|
||||
function countDown() {
|
||||
const timer = setInterval(() => {
|
||||
const date = new Date()
|
||||
const distance = new Date(props.endTime).getTime() - date.getTime()
|
||||
// console.log(dateendorStart.value);
|
||||
const distance = new Date(props.voteTime[dateendorStart()]).getTime() - date.getTime()
|
||||
|
||||
if (distance < 0) {
|
||||
if (distance <= 1) {
|
||||
clearInterval(timer)
|
||||
setTimeout(()=>countDown(),1000)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -100,6 +127,8 @@ export default {
|
||||
displayDays,
|
||||
displaySeconds,
|
||||
declOfNum,
|
||||
dateendorStart,
|
||||
disabledcard
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
<template>
|
||||
<v-card>
|
||||
<v-card-text class="d-flex justify-space-between ga-3 text-h6"> {{ voteCard.name }}
|
||||
<v-card-text class=" d-flex justify-space-between ga-3 text-h6"> {{ voteCard.name }}
|
||||
<v-btn flat size="medium" @click="$emit('openEditVoteModal', voteCard)">
|
||||
<v-icon color="orange-lighten-1">mdi-pencil</v-icon>
|
||||
</v-btn>
|
||||
</v-card-text>
|
||||
<v-img cover :src="voteCard.pictures" />
|
||||
<v-card-text class="text-body-1">{{ voteCard.description }}</v-card-text>
|
||||
<TimerUI :endTime="voteCard.dateend" />
|
||||
<v-card-text class="">{{ voteCard.description }}</v-card-text>
|
||||
<TimerUI :voteTime="{dateend:voteCard.dateend,datestart:voteCard.datestart}" />
|
||||
<v-card-actions class="justify-space-between">
|
||||
<v-btn
|
||||
v-if="!voteCard.is_passed"
|
||||
:disabled="voteCard.is_passed || new Date(voteCard.datestart).getTime()>new Date().getTime()"
|
||||
color="teal-darken-4"
|
||||
prepend-icon="mdi-vote-outline"
|
||||
variant="outlined"
|
||||
@@ -18,9 +18,8 @@
|
||||
size="medium"
|
||||
class="pa-2"
|
||||
@click="$emit('openVoteModal', voteCard)">
|
||||
Проголосовать
|
||||
{{!voteCard.is_passed?"Проголосовать":"Уже проголосовали"}}
|
||||
</v-btn>
|
||||
<v-btn v-else color="teal-darken-4" disabled size="medium">Уже проголосовали</v-btn>
|
||||
<v-btn color="error" @click="$emit('deleteVoting', voteCard.id)" size="medium">
|
||||
<v-icon>mdi-delete</v-icon>
|
||||
</v-btn>
|
||||
@@ -44,7 +43,7 @@ export default {
|
||||
description: "Но таких денег у вас нет, чтобы получить ее на нашем прекрасном голосовании",
|
||||
pictures: "https://cdn.vuetifyjs.com/images/parallax/material.jpg",
|
||||
dateend: new Date(new Date().getTime() + 600000),
|
||||
is_passed: false,
|
||||
is_passed: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
<template v-slot:extension>
|
||||
<v-tabs v-model="currentTab">
|
||||
<v-tab :key="0" value="current">Текущие голосования</v-tab>
|
||||
<v-tab :key="0" value="active">Текущие голосования</v-tab>
|
||||
<v-tab :key="1" value="completed">Завершенные голосования</v-tab>
|
||||
<v-tab :key="2" value="constructor">Создать новое голосование</v-tab>
|
||||
</v-tabs>
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
<v-tabs-window v-model="currentTab">
|
||||
<!-- Текущие голосования -->
|
||||
<v-tabs-window-item value="current">
|
||||
<v-tabs-window-item value="active">
|
||||
<v-container>
|
||||
<v-row>
|
||||
<v-col v-for="voting in votes" :key="voting.id" cols="12" lg="3" md="4">
|
||||
@@ -102,7 +102,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ref } from "vue";
|
||||
import { ref, watch } from "vue";
|
||||
import VoteConstructor from "@/components/vote/VoteConstructor.vue";
|
||||
import CurrentVote from "@/components/vote/CurrentVote.vue";
|
||||
import VoteCardVue from "@/components/vote/VoteCard.vue";
|
||||
@@ -112,7 +112,7 @@ import { votingData } from "@/test/testDataForVote"
|
||||
export default {
|
||||
components: { CurrentVote, VoteConstructor, VoteCardVue },
|
||||
setup() {
|
||||
const currentTab = ref("current");
|
||||
const currentTab = ref("active");
|
||||
const votes = ref([])
|
||||
|
||||
function updating(param) {
|
||||
@@ -125,6 +125,16 @@ export default {
|
||||
|
||||
updating('active')
|
||||
|
||||
watch(
|
||||
() => currentTab.value,
|
||||
(newValue) => {
|
||||
if (newValue !== 'constructor') {
|
||||
console.log(newValue);
|
||||
updating(newValue)
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
const voteModal = ref(false);
|
||||
const editVoteModal = ref(false);
|
||||
const resultsModal = ref(false);
|
||||
|
||||
Reference in new issue
Block a user