P-98 Результаты голосования
This commit is contained in:
1 parent
a8bba7cb8b
commit
86dcc7f375
3 files changed
+110
-80
No files matched your search
@@ -3,8 +3,15 @@
|
|||||||
<v-card variant="text"
|
<v-card variant="text"
|
||||||
:disabled="disabledcard.disabled"
|
:disabled="disabledcard.disabled"
|
||||||
class="py-2 mx-auto">
|
class="py-2 mx-auto">
|
||||||
<v-card-title class="text-body-1"> До {{ disabledcard.text }} голосования осталось: </v-card-title>
|
<v-card-title class="text-body-1">
|
||||||
<v-row no-gutters class="align-baseline">
|
<template v-if="!isFinished">
|
||||||
|
До {{ disabledcard.text }} голосования осталось:
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
Завершено: {{ finishedDate }}
|
||||||
|
</template>
|
||||||
|
</v-card-title>
|
||||||
|
<v-row v-if="!isFinished" no-gutters class="align-baseline">
|
||||||
<v-col class="text-center">
|
<v-col class="text-center">
|
||||||
<v-card class="bg-yellow-darken-4">
|
<v-card class="bg-yellow-darken-4">
|
||||||
<div>{{ displayDays }}</div>
|
<div>{{ displayDays }}</div>
|
||||||
@@ -36,6 +43,7 @@
|
|||||||
</v-card>
|
</v-card>
|
||||||
</v-row>
|
</v-row>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
|
|
||||||
@@ -44,8 +52,8 @@ export default {
|
|||||||
voteTime: {
|
voteTime: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => { return {
|
default: () => { return {
|
||||||
dateend:new Date().setFullYear(),
|
dateend: new Date().setFullYear(),
|
||||||
datestart:new Date().setFullYear()
|
datestart: new Date().setFullYear()
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -54,75 +62,70 @@ export default {
|
|||||||
const displayMinutes = ref(0);
|
const displayMinutes = ref(0);
|
||||||
const displayHours = ref(0);
|
const displayHours = ref(0);
|
||||||
const displayDays = ref(0);
|
const displayDays = ref(0);
|
||||||
const displaySeconds = ref(0)
|
const displaySeconds = ref(0);
|
||||||
|
const isFinished = ref(false);
|
||||||
|
const finishedDate = ref('');
|
||||||
|
|
||||||
const minutes = computed(() => {
|
const minutes = computed(() => seconds * 60);
|
||||||
return seconds * 60
|
const hours = computed(() => minutes.value * 60);
|
||||||
})
|
const days = computed(() => hours.value * 24);
|
||||||
|
|
||||||
const hours = computed(() => {
|
|
||||||
return minutes.value * 60
|
|
||||||
})
|
|
||||||
|
|
||||||
const days = computed(() => {
|
|
||||||
return hours.value * 24
|
|
||||||
})
|
|
||||||
|
|
||||||
function declOfNum(value, titles) {
|
function declOfNum(value, titles) {
|
||||||
const cases = [2, 0, 1, 1, 1, 2]
|
const cases = [2, 0, 1, 1, 1, 2];
|
||||||
return titles[(value % 100 > 4 && value % 100 < 20) ? 2 : cases[(value % 10 < 5) ? value % 10 : 5]]
|
return titles[(value % 100 > 4 && value % 100 < 20) ? 2 : cases[(value % 10 < 5) ? value % 10 : 5]];
|
||||||
}
|
}
|
||||||
|
|
||||||
const disabledcard = ref({
|
const disabledcard = ref({
|
||||||
text: 'окончания',
|
text: 'окончания',
|
||||||
disabled: false
|
disabled: false
|
||||||
})
|
});
|
||||||
|
|
||||||
const dateendorStart = ()=>{
|
const dateendorStart = () => {
|
||||||
let param = 'dateend'
|
let param = 'dateend';
|
||||||
|
|
||||||
if (new Date().getTime() < new Date(props.voteTime.datestart).getTime()) {
|
if (new Date().getTime() < new Date(props.voteTime.datestart).getTime()) {
|
||||||
param='datestart'
|
param = 'datestart';
|
||||||
disabledcard.value= {
|
disabledcard.value = {
|
||||||
text: 'начала',
|
text: 'начала',
|
||||||
disabled: true,
|
disabled: true,
|
||||||
}
|
};
|
||||||
emit('changeBtn', true)
|
emit('changeBtn', true);
|
||||||
} else {
|
} else {
|
||||||
disabledcard.value= {
|
disabledcard.value = {
|
||||||
text: 'окончания',
|
text: 'окончания',
|
||||||
disabled: false,
|
disabled: false,
|
||||||
|
};
|
||||||
|
emit('changeBtn', false);
|
||||||
}
|
}
|
||||||
emit('changeBtn', false)
|
return param;
|
||||||
}
|
};
|
||||||
return param
|
|
||||||
}
|
|
||||||
|
|
||||||
function countDown() {
|
function countDown() {
|
||||||
const timer = setInterval(() => {
|
const timer = setInterval(() => {
|
||||||
const date = new Date()
|
const date = new Date();
|
||||||
const distance = new Date(props.voteTime[dateendorStart()]).getTime() - date.getTime()
|
const endDate = new Date(props.voteTime.dateend);
|
||||||
|
const distance = endDate.getTime() - date.getTime();
|
||||||
|
|
||||||
if (distance <= 1) {
|
if (distance <= 0) {
|
||||||
clearInterval(timer)
|
clearInterval(timer);
|
||||||
setTimeout(()=>countDown(),1000)
|
isFinished.value = true;
|
||||||
|
finishedDate.value = endDate.toLocaleDateString();
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const daysOf = Math.floor(distance / days.value)
|
const daysOf = Math.floor(distance / days.value);
|
||||||
const hoursOf = Math.floor((distance % days.value) / hours.value)
|
const hoursOf = Math.floor((distance % days.value) / hours.value);
|
||||||
const minutesOf = Math.floor((distance % hours.value) / minutes.value)
|
const minutesOf = Math.floor((distance % hours.value) / minutes.value);
|
||||||
const secondsOf = Math.floor((distance % minutes.value) / seconds)
|
const secondsOf = Math.floor((distance % minutes.value) / seconds);
|
||||||
|
|
||||||
displayDays.value = daysOf < 10 ? "0" + daysOf : daysOf
|
displayDays.value = daysOf < 10 ? "0" + daysOf : daysOf;
|
||||||
displayHours.value = hoursOf < 10 ? "0" + hoursOf : hoursOf
|
displayHours.value = hoursOf < 10 ? "0" + hoursOf : hoursOf;
|
||||||
displayMinutes.value = minutesOf < 10 ? "0" + minutesOf : minutesOf
|
displayMinutes.value = minutesOf < 10 ? "0" + minutesOf : minutesOf;
|
||||||
displaySeconds.value = secondsOf < 10 ? "0" + secondsOf : secondsOf
|
displaySeconds.value = secondsOf < 10 ? "0" + secondsOf : secondsOf;
|
||||||
|
}, 1000);
|
||||||
}, 1000)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
countDown()
|
countDown();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
displayMinutes,
|
displayMinutes,
|
||||||
@@ -131,8 +134,10 @@ export default {
|
|||||||
displaySeconds,
|
displaySeconds,
|
||||||
declOfNum,
|
declOfNum,
|
||||||
dateendorStart,
|
dateendorStart,
|
||||||
disabledcard
|
disabledcard,
|
||||||
}
|
isFinished,
|
||||||
|
finishedDate
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -7,11 +7,10 @@
|
|||||||
</v-card-text>
|
</v-card-text>
|
||||||
<v-row>
|
<v-row>
|
||||||
<v-col>
|
<v-col>
|
||||||
|
|
||||||
<v-carousel
|
<v-carousel
|
||||||
show-arrows="hover"
|
cycle
|
||||||
hide-delimiters cycle
|
height="200" hide-delimiters
|
||||||
height="200">
|
show-arrows="hover">
|
||||||
<v-carousel-item
|
<v-carousel-item
|
||||||
v-for="(picture, index) in images"
|
v-for="(picture, index) in images"
|
||||||
:key="index"
|
:key="index"
|
||||||
@@ -21,22 +20,31 @@
|
|||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
<v-card-text class="">{{ voteCard.description }}</v-card-text>
|
<v-card-text class="">{{ voteCard.description }}</v-card-text>
|
||||||
<Timer :voteTime="{ dateend: voteCard.dateend, datestart: voteCard.datestart }" @changeBtn="(time) => timeChange = time" />
|
<Timer :voteTime="{ dateend: voteCard.dateend, datestart: voteCard.datestart }"
|
||||||
|
@changeBtn="(time) => timeChange = time"/>
|
||||||
<v-card-actions class="justify-space-between mt-4 pb-2">
|
<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"
|
<v-btn :disabled="voteCard.is_passed || timeChange" color="teal-darken-4" prepend-icon="mdi-vote-outline"
|
||||||
variant="outlined" rounded="xl" size="small" @click="$emit('openVoteModal', voteCard)">
|
rounded="xl" size="small" variant="outlined" @click="$emit('openVoteModal', voteCard)">
|
||||||
{{ !voteCard.is_passed ? "Проголосовать" : "Уже проголосовали" }}
|
{{ !voteCard.is_passed ? "Проголосовать" : "Уже проголосовали" }}
|
||||||
</v-btn>
|
</v-btn>
|
||||||
<v-btn color="error" @click="youSure=true" size="medium">
|
</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 color="error" size="medium" @click="youSure=true">
|
||||||
<v-icon>mdi-delete</v-icon>
|
<v-icon>mdi-delete</v-icon>
|
||||||
<v-dialog v-model="youSure" width="500">
|
<v-dialog v-model="youSure" width="500">
|
||||||
|
|
||||||
<v-card max-width="450" class="flex">
|
<v-card class="flex" max-width="450">
|
||||||
<v-btn
|
<v-btn
|
||||||
class="align-self-end ma-2 text-red"
|
class="align-self-end ma-2 text-red"
|
||||||
icon="mdi-close"
|
icon="mdi-close"
|
||||||
variant="text"
|
|
||||||
size="medium"
|
size="medium"
|
||||||
|
variant="text"
|
||||||
@click="youSure = false"
|
@click="youSure = false"
|
||||||
/>
|
/>
|
||||||
<div class="ml-5 text-h6">
|
<div class="ml-5 text-h6">
|
||||||
@@ -65,11 +73,12 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Timer from "@/components/UI/Timer.vue"
|
import Timer from "@/components/UI/Timer.vue"
|
||||||
import { baseURL } from "@/utils/axios-api";
|
import {baseURL} from "@/utils/axios-api";
|
||||||
import { ref, computed } from 'vue'
|
import {computed, ref} from 'vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: { Timer },
|
components: {Timer},
|
||||||
emits: ['openVoteModal', 'openEditVoteModal', 'deleteVoting'],
|
emits: ['openVoteModal', 'openEditVoteModal', 'deleteVoting', 'openResultModal'],
|
||||||
props: {
|
props: {
|
||||||
voteCard: {
|
voteCard: {
|
||||||
type: Object,
|
type: Object,
|
||||||
@@ -88,11 +97,21 @@ export default {
|
|||||||
setup(props) {
|
setup(props) {
|
||||||
const timeChange = ref(false)
|
const timeChange = ref(false)
|
||||||
const youSure = ref(false)
|
const youSure = ref(false)
|
||||||
|
const isFinished = ref(false);
|
||||||
|
|
||||||
const images = computed(() => {
|
const images = computed(() => {
|
||||||
return props.voteCard.files.length > 0 ? props.voteCard.files : ['/media/defaultimg/vote.png']
|
return props.voteCard.files.length > 0 ? props.voteCard.files : ['/media/defaultimg/vote.png']
|
||||||
})
|
})
|
||||||
return { timeChange, baseURL, images, youSure }
|
|
||||||
|
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}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,20 +46,27 @@
|
|||||||
lg="3"
|
lg="3"
|
||||||
md="4"
|
md="4"
|
||||||
>
|
>
|
||||||
<v-card>
|
<VoteCardVue
|
||||||
<v-card-title>{{ voting.name }}</v-card-title>
|
:voteCard="voting"
|
||||||
<v-card-subtitle>
|
@deleteVoting="deleteVoting"
|
||||||
Завершено: {{ voting.dateend }}
|
@openEditVoteModal="(voting) => openModal('edit', voting)"
|
||||||
</v-card-subtitle>
|
@openVoteModal="(voting) => openModal('vote', voting)"
|
||||||
<v-card-actions class="justify-space-between">
|
@openResultModal="(voting) => openModal('results', voting)"
|
||||||
<v-btn color="teal-darken-4" size="medium" @click="() => openModal('results', voting)">
|
/>
|
||||||
Результаты
|
<!-- <v-card>-->
|
||||||
</v-btn>
|
<!-- <v-card-title>{{ voting.name }}</v-card-title>-->
|
||||||
<v-btn color="error" size="medium" @click="deleteVoting(voting.id)">
|
<!-- <v-card-subtitle>-->
|
||||||
<v-icon>mdi-delete</v-icon>
|
<!-- Завершено: {{ voting.dateend }}-->
|
||||||
</v-btn>
|
<!-- </v-card-subtitle>-->
|
||||||
</v-card-actions>
|
<!-- <v-card-actions class="justify-space-between">-->
|
||||||
</v-card>
|
<!-- <v-btn color="teal-darken-4" size="medium" @click="() => openModal('results', voting)">-->
|
||||||
|
<!-- Результаты-->
|
||||||
|
<!-- </v-btn>-->
|
||||||
|
<!-- <v-btn color="error" size="medium" @click="deleteVoting(voting.id)">-->
|
||||||
|
<!-- <v-icon>mdi-delete</v-icon>-->
|
||||||
|
<!-- </v-btn>-->
|
||||||
|
<!-- </v-card-actions>-->
|
||||||
|
<!-- </v-card>-->
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
</v-container>
|
</v-container>
|
||||||
@@ -156,8 +163,6 @@ export default {
|
|||||||
.sort((a, b) => new Date(b.dateend) - new Date(a.dateend))
|
.sort((a, b) => new Date(b.dateend) - new Date(a.dateend))
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log(completedVotes.value);
|
|
||||||
|
|
||||||
const loadVoteDetails = async (id) => {
|
const loadVoteDetails = async (id) => {
|
||||||
try {
|
try {
|
||||||
const data = await getVoteDetail(id);
|
const data = await getVoteDetail(id);
|
||||||
@@ -221,6 +226,7 @@ export default {
|
|||||||
|
|
||||||
updating("active");
|
updating("active");
|
||||||
updating("completed");
|
updating("completed");
|
||||||
|
console.log(completedVotes);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
currentTab,
|
currentTab,
|
||||||
|
|||||||
Reference in new issue
Block a user