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
+84 -71

No files matched your search

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