P-86 базовая разметка создана

This commit is contained in:
Denzel committed 2025-01-10 10:12:38 +03:00
1 parent 7103396d69
commit 4887ae9cb5
3 files changed
+217 -5

No files matched your search

+3 -3
View File
@@ -147,10 +147,10 @@ const routes = [
import("@/views/Vote.vue")
},
{
path: "/voteconstructor",
name: "VoteConstructor",
path: "/votehomepage",
name: "VoteHomePage",
component: () =>
import("@/views/VoteConstructor.vue")
import("@/views/VoteHomePage.vue")
},
],
},
+2 -2
View File
@@ -127,7 +127,8 @@
outlined
></v-autocomplete>
<div v-for="(person, index) in form.selectedEmployees" :key="person.id"
style="display: flex; align-items: center; gap: 16px; margin-bottom: 8px;">
class="d-flex align-center"
style="gap: 16px; margin-bottom: 8px;">
<v-chip>{{ findEmployeeById(person).fio }}</v-chip>
<v-file-input
v-model="employeeImages[person]"
@@ -136,7 +137,6 @@
hide-details
label="Картинка"
outlined
style="flex-grow: 1;"
></v-file-input>
<v-btn
color="red-lighten-2"
+212
View File
@@ -0,0 +1,212 @@
<template>
<v-container>
<v-toolbar color="transparent">
<v-toolbar-title>Голосования</v-toolbar-title>
<template v-slot:extension>
<v-tabs v-model="currentTab">
<v-tab :key="0" value="current">Текущие голосования</v-tab>
<v-tab :key="1" value="completed">Завершенные голосования</v-tab>
<v-tab :key="2" value="constructor">Создать новое голосование</v-tab>
</v-tabs>
</template>
</v-toolbar>
<v-tabs-window v-model="currentTab">
<!-- Текущие голосования -->
<v-tabs-window-item value="current">
<v-container>
<v-row>
<v-col
v-for="voting in sortedCurrentVotes"
:key="voting.id"
cols="12" lg="3" md="4"
>
<v-card :class="{ 'voted-card': voting.voted }">
<v-card-title>{{ voting.title }}</v-card-title>
<v-card-subtitle>
Окончание: {{ formatDate(voting.endDate) }}
</v-card-subtitle>
<v-card-text>
Осталось: {{ timeRemaining(voting.endDate) }}
</v-card-text>
<v-card-actions>
<v-btn
v-if="!voting.voted"
color="primary"
@click="openVoteModal(voting)"
>
Проголосовать
</v-btn>
<v-btn v-else disabled>Вы уже проголосовали</v-btn>
</v-card-actions>
</v-card>
</v-col>
</v-row>
</v-container>
</v-tabs-window-item>
<!-- Завершенные голосования -->
<v-tabs-window-item value="completed">
<v-container>
<v-row>
<v-col
v-for="voting in sortedCompletedVotes"
:key="voting.id"
cols="12" lg="3" md="4"
>
<v-card>
<v-card-title>{{ voting.title }}</v-card-title>
<v-card-subtitle>
Завершено: {{ formatDate(voting.endDate) }}
</v-card-subtitle>
<v-card-actions>
<v-btn color="primary" @click="openResultsModal(voting)">
Смотреть результаты
</v-btn>
</v-card-actions>
</v-card>
</v-col>
</v-row>
</v-container>
</v-tabs-window-item>
<!-- Конструктор -->
<v-tabs-window-item value="constructor">
<VoteConstructor />
</v-tabs-window-item>
</v-tabs-window>
<!-- Модальное окно для голосования -->
<v-dialog v-model="voteModal" max-width="600px">
<v-card>
<v-card-title>Голосование: {{ selectedVoting?.title }}</v-card-title>
<v-card-text>
<p>Описание голосования...</p>
</v-card-text>
<v-card-actions>
<v-btn color="primary" @click="submitVote">Проголосовать</v-btn>
<v-btn @click="closeVoteModal">Закрыть</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<!-- Модальное окно для результатов -->
<v-dialog v-model="resultsModal" max-width="600px">
<v-card>
<v-card-title>Результаты голосования: {{ selectedVoting?.title }}</v-card-title>
<v-card-text>
<p>Здесь отображаются результаты голосования...</p>
</v-card-text>
<v-card-actions>
<v-btn @click="closeResultsModal">Закрыть</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</v-container>
</template>
<script>
import { computed, ref } from "vue";
import VoteConstructor from "@/views/VoteConstructor.vue";
export default {
components: { VoteConstructor },
setup() {
const currentTab = ref("current");
const votes = ref([
{
id: 1,
title: "Голосование 1",
endDate: new Date(new Date().getTime() + 600000), // 10 минут
voted: false,
},
{
id: 2,
title: "Голосование 2",
endDate: new Date(new Date().getTime() - 600000), // Уже завершено
voted: true,
},
{
id: 3,
title: "Голосование 3",
endDate: new Date(new Date().getTime() + 3600000), // 1 час
voted: true,
},
]);
const voteModal = ref(false);
const resultsModal = ref(false);
const selectedVoting = ref(null);
const sortedCurrentVotes = computed(() => {
return votes.value
.filter((v) => new Date(v.endDate) > new Date())
.sort((a, b) => new Date(a.endDate) - new Date(b.endDate));
});
const sortedCompletedVotes = computed(() => {
return votes.value
.filter((v) => new Date(v.endDate) <= new Date())
.sort((a, b) => new Date(b.endDate) - new Date(a.endDate));
});
const timeRemaining = (endDate) => {
const now = new Date();
const diff = new Date(endDate) - now;
return diff > 0 ? `${Math.floor(diff / 60000)} минут` : "Завершено";
};
const formatDate = (date) => new Date(date).toLocaleString();
const openVoteModal = (voting) => {
selectedVoting.value = voting;
voteModal.value = true;
};
const closeVoteModal = () => {
voteModal.value = false;
selectedVoting.value = null;
};
const submitVote = () => {
selectedVoting.value.voted = true;
closeVoteModal();
};
const openResultsModal = (voting) => {
selectedVoting.value = voting;
resultsModal.value = true;
};
const closeResultsModal = () => {
resultsModal.value = false;
selectedVoting.value = null;
};
return {
currentTab,
votes,
sortedCurrentVotes,
sortedCompletedVotes,
voteModal,
resultsModal,
selectedVoting,
timeRemaining,
formatDate,
openVoteModal,
closeVoteModal,
submitVote,
openResultsModal,
closeResultsModal,
};
},
};
</script>
<style>
.voted-card {
opacity: 0.6;
pointer-events: none;
}
</style>