This commit is contained in:
Alex committed 2025-01-14 13:41:15 +03:00
1 parent a851885bcf
commit 29e11dedae
4 files changed
+40 -92

No files matched your search

+3 -4
View File
@@ -40,13 +40,12 @@ import { computed, ref } from 'vue'
export default {
props: {
endTime: {
type: Date,
default: () => { return new Date.setFullYear() }
type: String,
default: () => { return new Date(props.endTime).setFullYear() }
}
},
setup(props) {
const seconds = 1000
const displayMinutes = ref(0);
const displayHours = ref(0);
@@ -73,7 +72,7 @@ export default {
function countDown() {
const timer = setInterval(() => {
const date = new Date()
const distance = props.endTime.getTime() - date.getTime()
const distance = new Date(props.endTime).getTime() - date.getTime()
if (distance < 0) {
clearInterval(timer)
+10 -9
View File
@@ -1,27 +1,27 @@
<template>
<v-card>
<v-card-text class="d-flex justify-space-between ga-3 text-h6"> {{ voteCard.title }}
<v-btn flat size="medium">
<v-card-text class="d-flex justify-space-between ga-3 text-h6"> {{ voteCard.name }}
<v-btn flat size="medium" @click="$emit('openEditVoteModal', voteCard)">
<v-icon color="orange-lighten-1">mdi-pencil</v-icon>
</v-btn>
</v-card-text>
<v-img cover :src="voteCard.pictures" />
<v-card-text class="text-body-1">{{ voteCard.subtitle }}</v-card-text>
<v-card-text class="text-body-1">{{ voteCard.description }}</v-card-text>
<TimerUI :endTime="voteCard.dateend" />
<v-card-actions class="justify-space-between">
<v-btn
v-if="!voteCard.voted"
v-if="!voteCard.is_passed"
color="teal-darken-4"
prepend-icon="mdi-vote-outline"
variant="outlined"
rounded="xl"
size="medium"
class="pa-2"
@click="openVoteModal(voting)">
@click="$emit('openVoteModal', voteCard)">
Проголосовать
</v-btn>
<v-btn v-else color="teal-darken-4" disabled size="medium">Уже проголосовали</v-btn>
<v-btn color="error" @click="deleteVoting(voting.id)" size="medium">
<v-btn color="error" @click="$emit('deleteVoting', voteCard.id)" size="medium">
<v-icon>mdi-delete</v-icon>
</v-btn>
</v-card-actions>
@@ -33,17 +33,18 @@ import TimerUI from '../secret/TimerUI.vue';
export default {
components: { TimerUI },
emits: ['openVoteModal', 'openEditVoteModal', 'deleteVoting'],
props: {
voteCard: {
type: Object,
default: () => {
return {
id: 0,
title: "Допустим, здесь могла быть ваша реклама",
subtitle: "Но таких денег у вас нет, чтобы получить ее на нашем прекрасном голосовании",
name: "Допустим, здесь могла быть ваша реклама",
description: "Но таких денег у вас нет, чтобы получить ее на нашем прекрасном голосовании",
pictures: "https://cdn.vuetifyjs.com/images/parallax/material.jpg",
dateend: new Date(new Date().getTime() + 600000),
voted: false,
is_passed: false,
}
}
}
@@ -249,10 +249,11 @@
<script>
import {computed, ref} from "vue";
import {createVote, getVotes} from "@/utils/axios-api";
import { createVote } from "@/utils/axios-api";
export default {
setup() {
emits: ['updating'],
setup(props, {emit}) {
const step = ref(0);
const isVoteCreated = ref(false);
const form = ref({
@@ -317,13 +318,7 @@ export default {
const response = await createVote(form.value);
console.log("Голосование успешно создано:", response);
isVoteCreated.value = true;
getVotes('active')
.then(data => {
console.log('Активные голосования:', data);
})
.catch(err => {
console.error('Ошибка:', err);
});
emit('updating', 'active')
} catch (error) {
console.error("Ошибка при создании голосования:", error);
}
+23 -70
View File
@@ -17,39 +17,9 @@
<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"
>
<VoteCardVue :voteCard="voting"/>
<!-- <v-card :class="{ 'voted-card': voting.voted }">
<v-card-title class="d-flex justify-space-between">{{ voting.title }}
<v-btn flat size="medium" @click="openEditVoteModal(voting)">
<v-icon color="orange-lighten-1">mdi-pencil</v-icon>
</v-btn>
</v-card-title>
<v-card-subtitle>
Окончание: {{ formatDate(voting.endDate) }}
</v-card-subtitle>
<v-card-text>
Осталось: {{ timeRemaining(voting.endDate) }}
</v-card-text>
<v-card-actions class="justify-space-between">
<v-btn
v-if="!voting.voted"
color="teal-darken-4"
size="medium"
@click="openVoteModal(voting)"
>
Проголосовать
</v-btn>
<v-btn v-else color="teal-darken-4" disabled size="medium">Проголосовали</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-for="voting in sortedCurrentVotes" :key="voting.id" cols="12" lg="3" md="4">
<VoteCardVue :voteCard="voting" @openVoteModal="openVoteModal" @openEditVoteModal="openEditVoteModal"
@deleteVoting="deleteVoting" />
</v-col>
</v-row>
</v-container>
@@ -59,11 +29,7 @@
<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-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>
@@ -85,7 +51,7 @@
<!-- Конструктор -->
<v-tabs-window-item value="constructor">
<VoteConstructor/>
<VoteConstructor @updating="updating" />
</v-tabs-window-item>
</v-tabs-window>
@@ -99,13 +65,8 @@
</v-btn>
</v-card-actions>
<v-card-text class="pt-0">
<CurrentVote
:description="votingData.description"
:endDate="votingData.endDate"
:questions="votingData.questions"
:startDate="votingData.startDate"
:title="votingData.title"
/>
<CurrentVote :description="votingData.description" :endDate="votingData.endDate"
:questions="votingData.questions" :startDate="votingData.startDate" :title="votingData.title" />
</v-card-text>
</v-card>
</v-dialog>
@@ -116,7 +77,7 @@
<v-card-title>Голосование: {{ selectedVoting?.title }}</v-card-title>
<v-card-text>
<!-- <p>Редактирование голосования...</p> -->
<VoteConstructor/>
<VoteConstructor />
</v-card-text>
<v-card-actions>
<v-btn color="teal-darken-4">Сохранить</v-btn>
@@ -141,36 +102,27 @@
</template>
<script>
import {computed, ref} from "vue";
import { computed, ref } from "vue";
import VoteConstructor from "@/components/vote/VoteConstructor.vue";
import CurrentVote from "@/components/vote/CurrentVote.vue";
import VoteCardVue from "@/components/vote/VoteCard.vue";
import {votingData} from '@/test/testDataForVote'
import { getVotes } from "@/utils/axios-api"
import { votingData } from "@/test/testDataForVote"
export default {
components: {CurrentVote, VoteConstructor, VoteCardVue},
components: { CurrentVote, VoteConstructor, VoteCardVue },
setup() {
const currentTab = ref("current");
const votes = ref([
{
id: 1,
title: "Голосование 1",
dateend: new Date(new Date().getTime() + 600000), // 10 минут
voted: false,
},
{
id: 2,
title: "Голосование 2",
dateend: new Date(new Date().getTime() - 600000), // Уже завершено
voted: true,
},
{
id: 3,
title: "Голосование 3",
dateend: new Date(new Date().getTime() + 3600000), // 1 час
voted: true,
},
]);
const votes = ref([])
function updating(param) {
getVotes(param)
.then(data => {
votes.value = data.votes;
})
}
updating('active')
const voteModal = ref(false);
const editVoteModal = ref(false);
@@ -255,6 +207,7 @@ export default {
editVoteModal,
openEditVoteModal,
closeEditVoteModal,
updating
};
},
};