ref
This commit is contained in:
1 parent
38f8e00918
commit
db63350978
2 files changed
+92
-126
No files matched your search
@@ -3,9 +3,9 @@
|
||||
<v-card variant="text"
|
||||
:disabled="disabledcard.disabled"
|
||||
class="py-2 mx-auto">
|
||||
<v-card-title class="text-body-1">
|
||||
До {{ disabledcard.text }} голосования осталось:
|
||||
|
||||
<v-card-title class="text-body-1">
|
||||
До {{ disabledcard.text }} голосования осталось:
|
||||
|
||||
</v-card-title>
|
||||
<v-row no-gutters class="align-baseline">
|
||||
<v-col class="text-center">
|
||||
@@ -60,7 +60,7 @@ export default {
|
||||
const displayDays = ref(0);
|
||||
const displaySeconds = ref(0);
|
||||
const isFinished = ref(false);
|
||||
|
||||
|
||||
|
||||
const minutes = computed(() => seconds * 60);
|
||||
const hours = computed(() => minutes.value * 60);
|
||||
@@ -104,7 +104,6 @@ export default {
|
||||
if (distance <= 1) {
|
||||
clearInterval(timer)
|
||||
setTimeout(()=>countDown(),1000)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -118,7 +117,7 @@ export default {
|
||||
displayMinutes.value = minutesOf < 10 ? "0" + minutesOf : minutesOf
|
||||
displaySeconds.value = secondsOf < 10 ? "0" + secondsOf : secondsOf
|
||||
|
||||
}, 1000)
|
||||
})
|
||||
}
|
||||
|
||||
countDown()
|
||||
@@ -131,7 +130,7 @@ export default {
|
||||
declOfNum,
|
||||
dateendorStart,
|
||||
disabledcard,
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,122 +1,99 @@
|
||||
<template>
|
||||
<v-container fluid class="pt-2 d-flex flex-column">
|
||||
<v-container class="pt-2 d-flex flex-column" fluid>
|
||||
<v-row class="flex-column">
|
||||
<v-col cols="auto">
|
||||
<v-tabs
|
||||
align="center"
|
||||
v-model="currentTab">
|
||||
<v-tab
|
||||
|
||||
v-for="x in tabs" :key="x.value" :value="x.value">{{ x.text }}</v-tab>
|
||||
|
||||
</v-tabs>
|
||||
</v-col>
|
||||
<v-col class="overflow-auto pa-0">
|
||||
<v-window v-model="currentTab" class=" h-100" >
|
||||
<!-- Текущие голосования -->
|
||||
<!-- <v-tabs-window v-model="currentTab"> -->
|
||||
<!-- Текущие голосования -->
|
||||
<v-tabs-window-item v-for="x in ['active','completed']" :value="x" class="h-100 overflow-auto">
|
||||
<v-row class="mx-2">
|
||||
<v-col
|
||||
v-for="voting in sortedVotes"
|
||||
:key="voting.id"
|
||||
cols="12"
|
||||
lg="3"
|
||||
md="4"
|
||||
>
|
||||
<VoteCardVue
|
||||
:isFinished="currentTab=='active'"
|
||||
:voteCard="voting"
|
||||
@openVoteModal="(voting) => openModal('vote', voting)"
|
||||
@openEditVoteModal="(voting) => openModal('edit', voting)"
|
||||
@openResultModal="(voting) => openModal('results', voting)"
|
||||
@deleteVoting="deleteVoting"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-tabs-window-item>
|
||||
<v-tabs
|
||||
v-model="currentTab"
|
||||
align="center">
|
||||
<v-tab v-for="x in tabs" :key="x.value" :value="x.value">{{ x.text }}</v-tab>
|
||||
</v-tabs>
|
||||
</v-col>
|
||||
<v-col class="overflow-auto pa-0">
|
||||
<v-window v-model="currentTab" class=" h-100">
|
||||
<!-- Текущие голосования -->
|
||||
<v-tabs-window-item v-for="x in ['active','completed']" :value="x" class="h-100 overflow-auto">
|
||||
<v-row class="mx-2">
|
||||
<v-col
|
||||
v-for="voting in sortedVotes"
|
||||
:key="voting.id"
|
||||
cols="12"
|
||||
lg="3"
|
||||
md="4"
|
||||
>
|
||||
<VoteCardVue
|
||||
:isFinished="currentTab==='active'"
|
||||
:voteCard="voting"
|
||||
@deleteVoting="deleteVoting"
|
||||
@openEditVoteModal="(voting) => openModal('edit', voting)"
|
||||
@openResultModal="(voting) => openModal('results', voting)"
|
||||
@openVoteModal="(voting) => openModal('vote', voting)"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-tabs-window-item>
|
||||
|
||||
<!-- Завершенные голосования -->
|
||||
|
||||
<!-- Конструктор -->
|
||||
<v-tabs-window-item class="h-100 overflow-auto bg-yellow" value="constructor">
|
||||
<VoteConstructor @updating="updating"/>
|
||||
</v-tabs-window-item>
|
||||
</v-window>
|
||||
|
||||
<!-- Конструктор -->
|
||||
<v-tabs-window-item value="constructor" class="h-100 overflow-auto bg-yellow">
|
||||
<VoteConstructor @updating="updating" />
|
||||
</v-tabs-window-item>
|
||||
<!-- </v-tabs-window> -->
|
||||
|
||||
</v-window>
|
||||
|
||||
<!-- Модальные окна -->
|
||||
<v-dialog v-model="voteModal" @click:outside="closeModal">
|
||||
|
||||
|
||||
<!-- Модальные окна -->
|
||||
<v-dialog v-model="voteModal" @click:outside="closeModal">
|
||||
<CurrentVote :data="res" @closer="closeModal"/>
|
||||
|
||||
|
||||
</v-dialog>
|
||||
</v-dialog>
|
||||
|
||||
<v-dialog v-model="editVoteModal" max-width="1200px" @click:outside="closeModal">
|
||||
<v-card>
|
||||
<v-card-title>Редактировать голосование: {{ selectedVoting?.title }}</v-card-title>
|
||||
<v-card-text>
|
||||
<VoteConstructor />
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-btn color="teal-darken-4">Сохранить</v-btn>
|
||||
<v-btn @click="closeModal">Закрыть</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
<v-dialog v-model="editVoteModal" max-width="1200px" @click:outside="closeModal">
|
||||
<v-card>
|
||||
<v-card-title>Редактировать голосование: {{ selectedVoting?.title }}</v-card-title>
|
||||
<v-card-text>
|
||||
<VoteConstructor/>
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-btn color="teal-darken-4">Сохранить</v-btn>
|
||||
<v-btn @click="closeModal">Закрыть</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
|
||||
<v-dialog v-model="resultsModal" max-width="1200px" @click:outside="closeModal">
|
||||
<v-card>
|
||||
<v-card-title>Результаты голосования: {{ selectedVoting?.title }}</v-card-title>
|
||||
<v-card-text>
|
||||
<VoteResult :results="testResults"/>
|
||||
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-btn @click="closeModal">Закрыть</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-dialog v-model="resultsModal" max-width="1200px" @click:outside="closeModal">
|
||||
<v-card>
|
||||
<v-card-title>Результаты голосования: {{ selectedVoting?.title }}</v-card-title>
|
||||
<v-card-text>
|
||||
<VoteResult :results="testResults"/>
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-btn @click="closeModal">Закрыть</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-container>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ref, computed, watch } from "vue";
|
||||
import {computed, 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";
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import {useRoute, useRouter} from "vue-router";
|
||||
import VoteResult from "@/components/vote/VoteResult.vue";
|
||||
import { deleteVote, getVoteDetail, getVotes } from "@/utils/axios-api";
|
||||
import { formatDate } from "@vueuse/shared";
|
||||
import {deleteVote, getVoteDetail, getVotes} from "@/utils/axios-api";
|
||||
import {formatDate} from "@vueuse/shared";
|
||||
|
||||
export default {
|
||||
methods: { formatDate },
|
||||
|
||||
components: { CurrentVote, VoteConstructor, VoteCardVue, VoteResult },
|
||||
methods: {formatDate},
|
||||
|
||||
components: {CurrentVote, VoteConstructor, VoteCardVue, VoteResult},
|
||||
setup() {
|
||||
const tabs=[
|
||||
{value:"active", text:'Текущие голосования'},
|
||||
{value:"completed", text:'Завершенные голосования'},
|
||||
{value:"constructor", text:'Создать новое голосование'},
|
||||
|
||||
]
|
||||
const tabs = [
|
||||
{value: "active", text: 'Текущие голосования'},
|
||||
{value: "completed", text: 'Завершенные голосования'},
|
||||
{value: "constructor", text: 'Создать новое голосование'},
|
||||
]
|
||||
|
||||
|
||||
const testResults = [
|
||||
const testResults = [
|
||||
{name: 'Дональд Трамп', votes: 99},
|
||||
{name: 'Иван Иванов', votes: 30},
|
||||
{name: 'Аркадий Упукник', votes: 95},
|
||||
@@ -140,13 +117,9 @@ export default {
|
||||
const resultsModal = ref(false);
|
||||
const selectedVoting = ref(null);
|
||||
|
||||
const sortedVotes = computed(() =>{
|
||||
return currentTab.value=='active'?votes.value.sort((a, b) => new Date(a.dateend) - new Date(b.dateend)):votes.value.sort((a, b) => new Date(b.dateend) - new Date(a.dateend))
|
||||
}
|
||||
|
||||
);
|
||||
|
||||
|
||||
const sortedVotes = computed(() => currentTab.value === 'active' ? votes.value.sort((a, b) =>
|
||||
new Date(a.dateend) - new Date(b.dateend)) :
|
||||
votes.value.sort((a, b) => new Date(b.dateend) - new Date(a.dateend)));
|
||||
|
||||
const loadVoteDetails = async (id) => {
|
||||
try {
|
||||
@@ -163,23 +136,21 @@ export default {
|
||||
editVoteModal.value = false;
|
||||
resultsModal.value = false;
|
||||
selectedVoting.value = null;
|
||||
router.push({ name: "VoteHomePage" });
|
||||
updating("active");
|
||||
router.push({name: "VoteHomePage"});
|
||||
};
|
||||
|
||||
const openModal = async (type, voting) => {
|
||||
selectedVoting.value = voting;
|
||||
|
||||
if (type === "vote") {
|
||||
await loadVoteDetails(voting.id);
|
||||
voteModal.value = true;
|
||||
router.push({ name: "Voting", params: { id: voting.id } });
|
||||
router.push({name: "Voting", params: {id: voting.id}});
|
||||
} else if (type === "edit") {
|
||||
editVoteModal.value = true;
|
||||
router.push({ name: "EditVote", params: { id: voting.id } });
|
||||
router.push({name: "EditVote", params: {id: voting.id}});
|
||||
} else if (type === "results") {
|
||||
resultsModal.value = true;
|
||||
router.push({ name: "VoteResults", params: { id: voting.id } });
|
||||
router.push({name: "VoteResults", params: {id: voting.id}});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -191,12 +162,8 @@ export default {
|
||||
console.error("Ошибка при удалении голосования:", error);
|
||||
}
|
||||
};
|
||||
watch(currentTab,
|
||||
async () =>{
|
||||
|
||||
votes.value=[]
|
||||
await updating(currentTab.value)}
|
||||
)
|
||||
|
||||
watch(currentTab,async () => await updating(currentTab.value))
|
||||
|
||||
watch(
|
||||
() => route,
|
||||
@@ -212,7 +179,7 @@ export default {
|
||||
selectedVoting.value = voting || null;
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
{immediate: true}
|
||||
);
|
||||
|
||||
updating("active");
|
||||
|
||||
Reference in new issue
Block a user