Merge branch 'Vit' into develop

This commit is contained in:
Nukeap committed 2025-01-20 12:11:13 +03:00
commit 1e809af8b7
2 files changed
+79 -66

No files matched your search

@@ -1,5 +1,5 @@
<template> <template>
<v-container> <v-row class="pt-2 mx-2 h-100 flex-column">
<template v-if="isVoteCreated"> <template v-if="isVoteCreated">
<v-card class="text-center pa-8" flat> <v-card class="text-center pa-8" flat>
<v-icon color="success" size="48">mdi-check-circle</v-icon> <v-icon color="success" size="48">mdi-check-circle</v-icon>
@@ -8,8 +8,10 @@
</v-card> </v-card>
</template> </template>
<template v-else> <template v-else>
<v-stepper v-model="step" editable> <div class="v-col">
<v-stepper-header>
<v-stepper class="h-100 v-row flex-column" v-model="step" editable>
<v-stepper-header class="v-col-auto pa-0">
<v-stepper-item :complete="step > 0" step="1">Основная информация</v-stepper-item> <v-stepper-item :complete="step > 0" step="1">Основная информация</v-stepper-item>
<v-divider></v-divider> <v-divider></v-divider>
<v-stepper-item :complete="step > 1" step="2">Создание опроса</v-stepper-item> <v-stepper-item :complete="step > 1" step="2">Создание опроса</v-stepper-item>
@@ -17,9 +19,10 @@
<v-stepper-item :complete="step > 2" step="3">Подтверждение</v-stepper-item> <v-stepper-item :complete="step > 2" step="3">Подтверждение</v-stepper-item>
</v-stepper-header> </v-stepper-header>
<v-stepper-window> <v-stepper-window class="v-col d-flex">
<!-- Основная информация --> <!-- Основная информация -->
<v-stepper-window-item step="1"> <v-stepper-window-item step="1" class="">
<v-card flat> <v-card flat>
<v-card-title>Основная информация</v-card-title> <v-card-title>Основная информация</v-card-title>
<v-card-text> <v-card-text>
@@ -243,8 +246,9 @@
</v-stepper-window> </v-stepper-window>
</v-stepper> </v-stepper>
</div>
</template> </template>
</v-container> </v-row>
</template> </template>
<script> <script>
+69 -60
View File
@@ -1,21 +1,23 @@
<template> <template>
<v-container class="py-0"> <v-container fluid class="pt-2 d-flex flex-column">
<v-toolbar color="transparent"> <v-row class="flex-column">
<v-toolbar-title>Голосования</v-toolbar-title> <v-col cols="auto">
<template v-slot:extension> <v-tabs
<v-tabs v-model="currentTab"> align="center"
<v-tab value="current">Текущие голосования</v-tab> v-model="currentTab">
<v-tab value="completed">Завершенные голосования</v-tab> <v-tab
<v-tab value="constructor" v-if="user.is_superuser || user.is_staff">Создать новое голосование</v-tab>
</v-tabs>
</template>
</v-toolbar>
<v-tabs-window v-model="currentTab"> 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 value="current"> <!-- <v-tabs-window v-model="currentTab"> -->
<v-container> <!-- Текущие голосования -->
<v-row> <v-tabs-window-item value="current" class="h-100 overflow-auto">
<v-row class="mx-2">
<v-col <v-col
v-for="voting in sortedCurrentVotes" v-for="voting in sortedCurrentVotes"
:key="voting.id" :key="voting.id"
@@ -25,55 +27,68 @@
> >
<VoteCardVue <VoteCardVue
:voteCard="voting" :voteCard="voting"
@deleteVoting="deleteVoting"
@openEditVoteModal="(voting) => openModal('edit', voting)"
@openVoteModal="(voting) => openModal('vote', voting)" @openVoteModal="(voting) => openModal('vote', voting)"
@openEditVoteModal="(voting) => openModal('edit', voting)"
@deleteVoting="deleteVoting"
/> />
</v-col> </v-col>
</v-row> </v-row>
</v-container>
</v-tabs-window-item> </v-tabs-window-item>
<!-- Завершенные голосования --> <!-- Завершенные голосования -->
<v-tabs-window-item value="completed"> <v-tabs-window-item value="completed" class="h-100 overflow-auto">
<v-container> <v-container>
<v-row> <v-row>
<v-col <v-col
v-for="voting in sortedCompletedVotes" v-for="voting in sortedCompletedVotes"
:key="voting.id" :key="voting.id"
:class="{ 'voted-card': voting.voted }"
cols="12" cols="12"
lg="3" lg="3"
md="4" md="4"
:class="{ 'voted-card': voting.voted }"
> >
<VoteCardVue <v-card>
:voteCard="voting" <v-card-title>{{ voting.title }}</v-card-title>
@deleteVoting="deleteVoting" <v-card-subtitle>
@openEditVoteModal="(voting) => openModal('edit', voting)" Завершено: {{ formatDate(voting.endDate) }}
@openVoteModal="(voting) => openModal('vote', voting)" </v-card-subtitle>
@openResultModal="(voting) => openModal('results', voting)" <v-card-actions class="justify-space-between">
/> <v-btn color="teal-darken-4" size="medium" @click="(voting) => 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>
</v-tabs-window-item> </v-tabs-window-item>
<!-- Конструктор --> <!-- Конструктор -->
<v-tabs-window-item value="constructor" v-if="user.is_superuser || user.is_staff"> <v-tabs-window-item value="constructor" class="h-100 overflow-auto bg-yellow">
<VoteConstructor @updating="updating"/> <VoteConstructor @updating="updating" />
</v-tabs-window-item> </v-tabs-window-item>
</v-tabs-window> <!-- </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"/> <CurrentVote :data="res" @closer="closeModal"/>
</v-dialog> </v-dialog>
<v-dialog v-model="editVoteModal" max-width="1200px" @click:outside="closeModal"> <v-dialog v-model="editVoteModal" max-width="1200px" @click:outside="closeModal">
<v-card> <v-card>
<v-card-title>Редактировать голосование: {{ selectedVoting?.title }}</v-card-title> <v-card-title>Редактировать голосование: {{ selectedVoting?.title }}</v-card-title>
<v-card-text> <v-card-text>
<VoteConstructor/> <VoteConstructor />
</v-card-text> </v-card-text>
<v-card-actions> <v-card-actions>
<v-btn color="teal-darken-4">Сохранить</v-btn> <v-btn color="teal-darken-4">Сохранить</v-btn>
@@ -86,54 +101,50 @@
<v-card> <v-card>
<v-card-title>Результаты голосования: {{ selectedVoting?.title }}</v-card-title> <v-card-title>Результаты голосования: {{ selectedVoting?.title }}</v-card-title>
<v-card-text> <v-card-text>
<VoteResult :results="testResults"/> <p>Здесь отображаются результаты голосования...</p>
</v-card-text> </v-card-text>
<v-card-actions> <v-card-actions>
<v-btn @click="closeModal">Закрыть</v-btn> <v-btn @click="closeModal">Закрыть</v-btn>
</v-card-actions> </v-card-actions>
</v-card> </v-card>
</v-dialog> </v-dialog>
</v-col>
</v-row>
</v-container> </v-container>
</template> </template>
<script> <script>
import {computed, ref, watch} from "vue"; import { ref, computed, watch } from "vue";
import VoteConstructor from "@/components/vote/VoteConstructor.vue"; import VoteConstructor from "@/components/vote/VoteConstructor.vue";
import CurrentVote from "@/components/vote/CurrentVote.vue"; import CurrentVote from "@/components/vote/CurrentVote.vue";
import VoteCardVue from "@/components/vote/VoteCard.vue"; import VoteCardVue from "@/components/vote/VoteCard.vue";
import {useRoute, useRouter} from "vue-router"; import { useRoute, useRouter } from "vue-router";
import {deleteVote, getVoteDetail, getVotes} from "@/utils/axios-api"; import { deleteVote, getVoteDetail, getVotes } from "@/utils/axios-api";
import {formatDate} from "@vueuse/shared"; import { formatDate } from "@vueuse/shared";
import VoteResult from "@/components/vote/VoteResult.vue";
import {useAccountStore} from "@/store/AccountStore";
export default { export default {
methods: {formatDate}, methods: { formatDate },
components: {VoteResult, CurrentVote, VoteConstructor, VoteCardVue}, components: { CurrentVote, VoteConstructor, VoteCardVue },
setup() { setup() {
const accountStore = useAccountStore(); const tabs=[
const user = accountStore.user; {value:"current", text:'Текущие голосования'},
const testResults = [ {value:"completed", text:'Завершенные голосования'},
{name: 'Дональд Трамп', votes: 99}, {value:"constructor", text:'Создать новое голосование'},
{name: 'Иван Иванов', votes: 30},
{name: 'Аркадий Упукник', votes: 95}, ]
];
const currentTab = ref("current"); const currentTab = ref("current");
const votes = ref([]); const votes = ref([]);
const completedVotes = ref([]);
const router = useRouter(); const router = useRouter();
const route = useRoute(); const route = useRoute();
const res = ref(null); const res = ref(null);
const updating = async (param) => { const updating = async (param) => {
const data = await getVotes(param); const data = await getVotes(param);
if (param === 'active') votes.value = data; votes.value = data;
else completedVotes.value = data;
}; };
updating("active"); updating("active");
updating('completed')
const voteModal = ref(false); const voteModal = ref(false);
const editVoteModal = ref(false); const editVoteModal = ref(false);
@@ -147,7 +158,7 @@ export default {
); );
const sortedCompletedVotes = computed(() => const sortedCompletedVotes = computed(() =>
completedVotes.value votes.value
.filter((v) => new Date(v.dateend) <= new Date()) .filter((v) => new Date(v.dateend) <= new Date())
.sort((a, b) => new Date(b.dateend) - new Date(a.dateend)) .sort((a, b) => new Date(b.dateend) - new Date(a.dateend))
); );
@@ -167,7 +178,7 @@ export default {
editVoteModal.value = false; editVoteModal.value = false;
resultsModal.value = false; resultsModal.value = false;
selectedVoting.value = null; selectedVoting.value = null;
router.push({name: "VoteHomePage"}); router.push({ name: "VoteHomePage" });
updating("active"); updating("active");
}; };
@@ -177,13 +188,13 @@ export default {
if (type === "vote") { if (type === "vote") {
await loadVoteDetails(voting.id); await loadVoteDetails(voting.id);
voteModal.value = true; voteModal.value = true;
router.push({name: "Voting", params: {id: voting.id}}); router.push({ name: "Voting", params: { id: voting.id } });
} else if (type === "edit") { } else if (type === "edit") {
editVoteModal.value = true; editVoteModal.value = true;
router.push({name: "EditVote", params: {id: voting.id}}); router.push({ name: "EditVote", params: { id: voting.id } });
} else if (type === "results") { } else if (type === "results") {
resultsModal.value = true; resultsModal.value = true;
router.push({name: "VoteResults", params: {id: voting.id}}); router.push({ name: "VoteResults", params: { id: voting.id } });
} }
}; };
@@ -210,11 +221,10 @@ export default {
selectedVoting.value = voting || null; selectedVoting.value = voting || null;
} }
}, },
{immediate: true} { immediate: true }
); );
updating("active"); updating("active");
updating("completed");
return { return {
currentTab, currentTab,
@@ -230,8 +240,7 @@ export default {
deleteVoting, deleteVoting,
updating, updating,
res, res,
testResults, tabs
user
}; };
}, },
}; };