Merge branch 'develop' into сja
This commit is contained in:
commit
b22474a14a
8 files changed
+500
-412
No files matched your search
@@ -1,103 +1,102 @@
|
||||
<template>
|
||||
<v-row class="px-2">
|
||||
<v-card variant="text"
|
||||
:disabled="disabledcard.disabled"
|
||||
class="py-2 mx-auto">
|
||||
<v-card-title class="text-body-1"> До {{ disabledcard.text }} голосования осталось: </v-card-title>
|
||||
<v-row no-gutters class="align-baseline">
|
||||
<v-col class="text-center">
|
||||
<v-card class="bg-yellow-darken-4">
|
||||
<div>{{ displayDays }}</div>
|
||||
</v-card>
|
||||
<span class="text-caption">{{ declOfNum(displayDays, [' день', ' дня', ' дней']) }}</span>
|
||||
</v-col>
|
||||
<v-col cols="auto" class="px-1">:</v-col>
|
||||
<v-col class="text-center">
|
||||
<v-card class="bg-yellow-darken-4">
|
||||
<div>{{ displayHours }}</div>
|
||||
</v-card>
|
||||
<span class="text-caption">{{ declOfNum(displayHours, [' час', ' часа', ' часов']) }}</span>
|
||||
</v-col>
|
||||
<v-col cols="auto" class="px-1">:</v-col>
|
||||
<v-col class="text-center">
|
||||
<v-card class="bg-yellow-darken-4">
|
||||
<div>{{ displayMinutes }}</div>
|
||||
</v-card>
|
||||
<span class="text-caption">{{ declOfNum(displayMinutes, [' минута', ' минуты', ' минут']) }}</span>
|
||||
</v-col>
|
||||
<v-col cols="auto" class="px-1">:</v-col>
|
||||
<v-col class="text-center">
|
||||
<v-card class="bg-yellow-darken-4">
|
||||
<div>{{ displaySeconds }}</div>
|
||||
</v-card>
|
||||
<span class="text-caption">{{ declOfNum(displaySeconds, [' секунда', ' секунды', ' секунд']) }}</span>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-card>
|
||||
</v-row>
|
||||
<v-row class="px-2">
|
||||
<v-card variant="text"
|
||||
:disabled="disabledcard.disabled"
|
||||
class="py-2 mx-auto">
|
||||
<v-card-title class="text-body-1">
|
||||
До {{ disabledcard.text }} голосования осталось:
|
||||
|
||||
</v-card-title>
|
||||
<v-row no-gutters class="align-baseline">
|
||||
<v-col class="text-center">
|
||||
<v-card class="bg-yellow-darken-4">
|
||||
<div>{{ displayDays }}</div>
|
||||
</v-card>
|
||||
<span class="text-caption">{{ declOfNum(displayDays, [' день', ' дня', ' дней']) }}</span>
|
||||
</v-col>
|
||||
<v-col cols="auto" class="px-1">:</v-col>
|
||||
<v-col class="text-center">
|
||||
<v-card class="bg-yellow-darken-4">
|
||||
<div>{{ displayHours }}</div>
|
||||
</v-card>
|
||||
<span class="text-caption">{{ declOfNum(displayHours, [' час', ' часа', ' часов']) }}</span>
|
||||
</v-col>
|
||||
<v-col cols="auto" class="px-1">:</v-col>
|
||||
<v-col class="text-center">
|
||||
<v-card class="bg-yellow-darken-4">
|
||||
<div>{{ displayMinutes }}</div>
|
||||
</v-card>
|
||||
<span class="text-caption">{{ declOfNum(displayMinutes, [' минута', ' минуты', ' минут']) }}</span>
|
||||
</v-col>
|
||||
<v-col cols="auto" class="px-1">:</v-col>
|
||||
<v-col class="text-center">
|
||||
<v-card class="bg-yellow-darken-4">
|
||||
<div>{{ displaySeconds }}</div>
|
||||
</v-card>
|
||||
<span class="text-caption">{{ declOfNum(displaySeconds, [' секунда', ' секунды', ' секунд']) }}</span>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-card>
|
||||
</v-row>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { computed, ref } from 'vue'
|
||||
|
||||
export default {
|
||||
props: {
|
||||
voteTime: {
|
||||
type: Object,
|
||||
default: () => { return {
|
||||
dateend:new Date().setFullYear(),
|
||||
datestart:new Date().setFullYear()
|
||||
}}
|
||||
}
|
||||
},
|
||||
setup(props, {emit}) {
|
||||
const seconds = 1000
|
||||
const displayMinutes = ref(0);
|
||||
const displayHours = ref(0);
|
||||
const displayDays = ref(0);
|
||||
const displaySeconds = ref(0)
|
||||
props: {
|
||||
voteTime: {
|
||||
type: Object,
|
||||
default: () => { return {
|
||||
dateend: new Date().setFullYear(),
|
||||
datestart: new Date().setFullYear()
|
||||
}}
|
||||
}
|
||||
},
|
||||
setup(props, {emit}) {
|
||||
const seconds = 1000
|
||||
const displayMinutes = ref(0);
|
||||
const displayHours = ref(0);
|
||||
const displayDays = ref(0);
|
||||
const displaySeconds = ref(0);
|
||||
const isFinished = ref(false);
|
||||
|
||||
|
||||
const minutes = computed(() => {
|
||||
return seconds * 60
|
||||
})
|
||||
const minutes = computed(() => seconds * 60);
|
||||
const hours = computed(() => minutes.value * 60);
|
||||
const days = computed(() => hours.value * 24);
|
||||
|
||||
const hours = computed(() => {
|
||||
return minutes.value * 60
|
||||
})
|
||||
function declOfNum(value, titles) {
|
||||
const cases = [2, 0, 1, 1, 1, 2];
|
||||
return titles[(value % 100 > 4 && value % 100 < 20) ? 2 : cases[(value % 10 < 5) ? value % 10 : 5]];
|
||||
}
|
||||
|
||||
const days = computed(() => {
|
||||
return hours.value * 24
|
||||
})
|
||||
|
||||
function declOfNum(value, titles) {
|
||||
const cases = [2, 0, 1, 1, 1, 2]
|
||||
return titles[(value % 100 > 4 && value % 100 < 20) ? 2 : cases[(value % 10 < 5) ? value % 10 : 5]]
|
||||
}
|
||||
const disabledcard = ref({
|
||||
text: 'окончания',
|
||||
disabled: false
|
||||
})
|
||||
|
||||
const dateendorStart = ()=>{
|
||||
let param = 'dateend'
|
||||
|
||||
if (new Date().getTime() < new Date(props.voteTime.datestart).getTime()) {
|
||||
param='datestart'
|
||||
disabledcard.value= {
|
||||
text: 'начала',
|
||||
disabled: true,
|
||||
}
|
||||
emit('changeBtn', true)
|
||||
} else {
|
||||
disabledcard.value= {
|
||||
text: 'окончания',
|
||||
disabled: false,
|
||||
}
|
||||
emit('changeBtn', false)
|
||||
}
|
||||
return param
|
||||
}
|
||||
const disabledcard = ref({
|
||||
text: 'окончания',
|
||||
disabled: false
|
||||
});
|
||||
|
||||
function countDown() {
|
||||
const dateendorStart = () => {
|
||||
let param = 'dateend';
|
||||
|
||||
if (new Date().getTime() < new Date(props.voteTime.datestart).getTime()) {
|
||||
param = 'datestart';
|
||||
disabledcard.value = {
|
||||
text: 'начала',
|
||||
disabled: true,
|
||||
};
|
||||
emit('changeBtn', true);
|
||||
} else {
|
||||
disabledcard.value = {
|
||||
text: 'окончания',
|
||||
disabled: false,
|
||||
};
|
||||
emit('changeBtn', false);
|
||||
}
|
||||
return param;
|
||||
};
|
||||
|
||||
function countDown() {
|
||||
const timer = setInterval(() => {
|
||||
const date = new Date()
|
||||
const distance = new Date(props.voteTime[dateendorStart()]).getTime() - date.getTime()
|
||||
@@ -124,15 +123,16 @@ export default {
|
||||
|
||||
countDown()
|
||||
|
||||
return {
|
||||
displayMinutes,
|
||||
displayHours,
|
||||
displayDays,
|
||||
displaySeconds,
|
||||
declOfNum,
|
||||
dateendorStart,
|
||||
disabledcard
|
||||
}
|
||||
}
|
||||
return {
|
||||
displayMinutes,
|
||||
displayHours,
|
||||
displayDays,
|
||||
displaySeconds,
|
||||
declOfNum,
|
||||
dateendorStart,
|
||||
disabledcard,
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</script>
|
||||
@@ -156,7 +156,7 @@
|
||||
<br />
|
||||
<span class="text-h5 text-grey"
|
||||
>Сейчас вакансий нет, <br />
|
||||
загляните позжет</span
|
||||
загляните позже</span
|
||||
>
|
||||
</v-card-subtitle>
|
||||
</v-card>
|
||||
|
||||
@@ -1,127 +1,110 @@
|
||||
<template>
|
||||
<template v-if="!isVoteSubmitted">
|
||||
<v-card style="height: 85vh;">
|
||||
<div class="d-flex flex-column flex-fill px-2 " >
|
||||
<div class="d-flex flex-column flex-fill px-2 ">
|
||||
<v-col cols="auto">
|
||||
<v-row class="d-flex flex-column">
|
||||
<v-col cols="12" class="d-flex flex-row pa-0">
|
||||
<v-col class="d-flex flex-row pa-0" cols="12">
|
||||
<v-col>
|
||||
<v-card-title>{{ data.name }}</v-card-title>
|
||||
<v-card-subtitle>{{ data.description }}</v-card-subtitle>
|
||||
</v-col>
|
||||
<v-col cols="auto">
|
||||
<v-btn color="red-darken-1" density="compact" size="small" icon="mdi-close-thick" @click="$emit('closer')">
|
||||
|
||||
<v-btn color="red-darken-1" density="compact" icon="mdi-close-thick" size="small"
|
||||
@click="$emit('closer')">
|
||||
</v-btn>
|
||||
</v-col>
|
||||
</v-col>
|
||||
|
||||
|
||||
</v-row>
|
||||
</v-col>
|
||||
<div class="d-flex flex-column flex-fill ">
|
||||
<v-stepper class="d-flex flex-column flex-fill" v-model="activeStep">
|
||||
<v-stepper v-model="activeStep" class="d-flex flex-column flex-fill">
|
||||
<!-- Шаги голосования -->
|
||||
<v-stepper-header class="py-0">
|
||||
<template v-for="question in data.questions" :key="question.numb">
|
||||
<v-stepper-item
|
||||
:color="question.numb < activeStep+1?'success':'warning'"
|
||||
edit-icon="mdi-help"
|
||||
:complete="question.numb < activeStep+1" :step="question.numb">
|
||||
Вопрос {{ question.numb }}
|
||||
</v-stepper-item>
|
||||
</template>
|
||||
<v-stepper-item
|
||||
:color="question.numb < activeStep+1?'success':'warning'"
|
||||
:complete="question.numb < activeStep+1"
|
||||
:step="question.numb" edit-icon="mdi-help">
|
||||
Вопрос {{ question.numb }}
|
||||
</v-stepper-item>
|
||||
</template>
|
||||
</v-stepper-header>
|
||||
|
||||
<v-stepper-window class="d-flex flex-column flex-fill " >
|
||||
<v-stepper-window class="d-flex flex-column flex-fill">
|
||||
<v-stepper-window-item v-for="(question, index) in data.questions" :key="question.numb"
|
||||
class=""
|
||||
:step="question.numb">
|
||||
|
||||
<!-- <v-card class="d-flex flex-fill" > -->
|
||||
:step="question.numb"
|
||||
class="">
|
||||
<div class="">
|
||||
<div class="" >{{ question.name }}</div>
|
||||
|
||||
<h3 class="text-center">{{ question.name }}</h3>
|
||||
<v-row>
|
||||
<div class="v-col align-self-center ">
|
||||
<v-img class=""
|
||||
style="max-height:400px"
|
||||
@click.stop="opendialog({answer:question.question, file:question.file})"
|
||||
:src="question.file"/>
|
||||
<div class="v-col align-self-start">
|
||||
<v-img :src="question.file"
|
||||
class="cursor-pointer"
|
||||
style="max-height:45vh"
|
||||
@click.stop="opendialog({answer:question.question, file:question.file})"/>
|
||||
</div>
|
||||
<div class="v-col-6" style="max-height:50vh">
|
||||
<v-list v-model:selected="result[question.id]" density="compact" select-strategy="leaf" slim style="max-height: 100%; overflow-y: auto;">
|
||||
<v-list-item v-for="answer in question.answers" :key="answer.id" :value="answer.id"
|
||||
density="compact">
|
||||
{{ answer.name }}
|
||||
<template v-slot:prepend="{ isSelected }">
|
||||
<v-list-item-action start>
|
||||
<v-checkbox-btn :model-value="isSelected"></v-checkbox-btn>
|
||||
</v-list-item-action>
|
||||
</template>
|
||||
<template v-slot:append>
|
||||
<v-avatar :image="answer.file" @click.stop="opendialog(answer)"></v-avatar>
|
||||
</template>
|
||||
</v-list-item>
|
||||
</v-list>
|
||||
</div>
|
||||
</v-row>
|
||||
</div>
|
||||
<div class="v-col-6">
|
||||
|
||||
<v-list v-model:selected="result[question.id]" slim density="compact" select-strategy="leaf">
|
||||
|
||||
<v-list-item density="compact" v-for="answer in question.answers" :key="answer.id"
|
||||
:value="answer.id">
|
||||
{{ answer.name }}
|
||||
<template v-slot:prepend="{ isSelected }">
|
||||
<v-list-item-action start>
|
||||
<v-checkbox-btn :model-value="isSelected"></v-checkbox-btn>
|
||||
</v-list-item-action>
|
||||
</template>
|
||||
<template v-slot:append>
|
||||
|
||||
<v-avatar @click.stop="opendialog(answer)" :image="answer.file"></v-avatar>
|
||||
|
||||
</template>
|
||||
|
||||
|
||||
|
||||
|
||||
</v-list-item>
|
||||
|
||||
</v-list>
|
||||
</div>
|
||||
</v-row>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Действия -->
|
||||
<v-card-actions class="">
|
||||
|
||||
</v-card-actions>
|
||||
<!-- </v-card> -->
|
||||
<!-- </v-card> -->
|
||||
</v-stepper-window-item>
|
||||
|
||||
|
||||
</v-stepper-window>
|
||||
<v-stepper-actions >
|
||||
<template v-slot:prev>
|
||||
|
||||
<v-btn @click="prevStep" outlined>Назад</v-btn></template>
|
||||
<template v-slot:next>
|
||||
|
||||
<v-btn v-if="activeStep < data.questions.length - 1" :disabled="!isCurrentQuestionAnswered" @click="nextStep"
|
||||
color="teal-darken-4">
|
||||
Далее
|
||||
</v-btn>
|
||||
<v-btn v-else :disabled="!isCurrentQuestionAnswered" color="teal-darken-4" @click="submitVote">
|
||||
Отправить
|
||||
</v-btn>
|
||||
</template></v-stepper-actions>
|
||||
<v-stepper-actions>
|
||||
<template v-slot:prev>
|
||||
|
||||
<v-btn outlined @click="prevStep">Назад</v-btn>
|
||||
</template>
|
||||
<template v-slot:next>
|
||||
|
||||
<v-btn v-if="activeStep < data.questions.length - 1" :disabled="!isCurrentQuestionAnswered"
|
||||
color="teal-darken-4"
|
||||
@click="nextStep">
|
||||
Далее
|
||||
</v-btn>
|
||||
<v-btn v-else :disabled="!isCurrentQuestionAnswered" color="teal-darken-4" @click="submitVote">
|
||||
Отправить
|
||||
</v-btn>
|
||||
</template>
|
||||
</v-stepper-actions>
|
||||
</v-stepper>
|
||||
</div>
|
||||
</div>
|
||||
</v-card>
|
||||
<v-dialog v-model="dialog">
|
||||
<v-dialog v-model="dialog" max-width="100vh">
|
||||
<v-card max-height="800">
|
||||
<v-card-title class="v-row">
|
||||
<div clas="v-col-auto">
|
||||
<div class="v-col-auto">
|
||||
{{ activepick.answer }}
|
||||
</div>
|
||||
<v-spacer></v-spacer>
|
||||
<div>
|
||||
<v-btn color="red-darken-1" density="compact" icon="mdi-close-thick" size="small" @click="dialog=false"/>
|
||||
</div>
|
||||
|
||||
{{ activepick.answer }} </div>
|
||||
<v-spacer></v-spacer>
|
||||
<div clas="bg-yellow">
|
||||
<v-btn color="red-darken-1" density="compact" size="small" icon="mdi-close-thick" @click="dialog=false">
|
||||
|
||||
</v-btn>
|
||||
</div>
|
||||
|
||||
</v-card-title>
|
||||
<v-card-item>
|
||||
|
||||
<v-img :src="activepick.file" max-height="600" ></v-img>
|
||||
<v-img :src="activepick.file" max-height="600"></v-img>
|
||||
</v-card-item>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
@@ -129,22 +112,22 @@
|
||||
|
||||
<!-- Спасибо за голос -->
|
||||
<template v-else>
|
||||
<v-card width="400" class="mx-auto">
|
||||
<v-row align="center" justify="center" class="pa-3">
|
||||
<v-col class="text-center">
|
||||
<v-icon :color="messeger[messeger.key].color" :icon="messeger[messeger.key].icon" size="64" />
|
||||
<h2>{{ messeger[messeger.key].text }}</h2>
|
||||
<v-btn @click="$emit('closer')" class="ma-3 ">Закрыть</v-btn>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-card>
|
||||
<v-card class="mx-auto" width="400">
|
||||
<v-row align="center" class="pa-3" justify="center">
|
||||
<v-col class="text-center">
|
||||
<v-icon :color="messeger[messeger.key].color" :icon="messeger[messeger.key].icon" size="64"/>
|
||||
<h2>{{ messeger[messeger.key].text }}</h2>
|
||||
<v-btn class="ma-3 " @click="$emit('closer')">Закрыть</v-btn>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-card>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { axiosApiInstance } from "@/utils/axios-api";
|
||||
import { computed, ref } from "vue";
|
||||
import { useAccountStore } from "@/store/AccountStore";
|
||||
import {axiosApiInstance} from "@/utils/axios-api";
|
||||
import {computed, ref} from "vue";
|
||||
import {useAccountStore} from "@/store/AccountStore";
|
||||
|
||||
export default {
|
||||
name: 'CurrentVote',
|
||||
@@ -156,11 +139,11 @@ export default {
|
||||
default: () => ({}),
|
||||
},
|
||||
},
|
||||
setup(props, { emit }) {
|
||||
setup(props, {emit}) {
|
||||
const accountStore = useAccountStore();
|
||||
const messeger = ref({
|
||||
good: { icon: 'mdi-check-circle', text: 'Спасибо за Ваш голос!', color: "green" },
|
||||
bad: { icon: 'mdi-alert', text: 'Произошла ошибка!', color: "red" },
|
||||
good: {icon: 'mdi-check-circle', text: 'Спасибо за Ваш голос!', color: "green"},
|
||||
bad: {icon: 'mdi-alert', text: 'Произошла ошибка!', color: "red"},
|
||||
key: 'good'
|
||||
})
|
||||
const activeStep = ref(0);
|
||||
@@ -168,9 +151,10 @@ export default {
|
||||
const isVoteSubmitted = ref(false);
|
||||
|
||||
const isCurrentQuestionAnswered = computed(() => {
|
||||
let q = props.data.questions.find(e => e.numb == activeStep.value + 1)
|
||||
return result.value[q.id].length > 0;
|
||||
let q = props.data.questions.find(e => e.numb === activeStep.value + 1)
|
||||
return q !== undefined ? result.value[q.id].length > 0 : false;
|
||||
});
|
||||
|
||||
const getres = () => {
|
||||
return props.data.questions.reduce((acc, item) => {
|
||||
acc[item.id] = []
|
||||
@@ -195,25 +179,24 @@ export default {
|
||||
console.log("Отправляем данные голосования:", result.value);
|
||||
let voteData = []
|
||||
for (let val of Object.values(result.value)) {
|
||||
val.forEach(e => voteData.push({ answer: e, comment: null, user: accountStore.user.id }))
|
||||
val.forEach(e => voteData.push({answer: e, comment: null, user: accountStore.user.id}))
|
||||
}
|
||||
|
||||
axiosApiInstance.post('api/vote/voteresultcreate/', voteData).then(res => {
|
||||
messeger.value.key = 'good'
|
||||
|
||||
}).catch(e => {
|
||||
console.log(e);
|
||||
messeger.value.key = 'bad'
|
||||
}
|
||||
|
||||
console.log(e);
|
||||
messeger.value.key = 'bad'
|
||||
}
|
||||
).finally(() => isVoteSubmitted.value = true)
|
||||
|
||||
};
|
||||
const activepick = ref(null)
|
||||
const dialog=ref(false)
|
||||
const opendialog=(val)=>{
|
||||
dialog.value=true
|
||||
activepick.value=val
|
||||
const dialog = ref(false)
|
||||
const opendialog = (val) => {
|
||||
dialog.value = true
|
||||
activepick.value = val
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -1,100 +1,148 @@
|
||||
<template>
|
||||
<v-card>
|
||||
<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-row>
|
||||
<v-col>
|
||||
<v-card>
|
||||
<v-card-text class="d-flex justify-space-between ga-3 text-h6">
|
||||
<v-tooltip bottom>
|
||||
<template v-slot:activator="{ props }">
|
||||
<span
|
||||
v-bind="props"
|
||||
style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">
|
||||
{{ voteCard.name }}
|
||||
</span>
|
||||
</template>
|
||||
<span>{{ voteCard.name }}</span>
|
||||
</v-tooltip>
|
||||
<v-btn v-if="user.id === voteCard.author || user.is_superuser" flat size="medium" @click="$emit('openEditVoteModal', voteCard)">
|
||||
<v-icon color="orange-lighten-1">mdi-pencil</v-icon>
|
||||
</v-btn>
|
||||
</v-card-text>
|
||||
<v-row>
|
||||
<v-col>
|
||||
<v-carousel
|
||||
cycle
|
||||
height="200" hide-delimiters
|
||||
show-arrows="hover">
|
||||
<v-carousel-item
|
||||
v-for="(picture, index) in images"
|
||||
:key="index"
|
||||
:src="`${baseURL.slice(0, -1)}${picture}`">
|
||||
</v-carousel-item>
|
||||
</v-carousel>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-card-text class="">
|
||||
<v-tooltip bottom>
|
||||
<template v-slot:activator="{ props }">
|
||||
<span
|
||||
v-bind="props"
|
||||
style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">
|
||||
{{ voteCard.description }}
|
||||
</span>
|
||||
</template>
|
||||
<span>{{ voteCard.description }}</span>
|
||||
</v-tooltip>
|
||||
</v-card-text>
|
||||
<Timer v-if ="!isFinished" :voteTime="{ dateend: voteCard.dateend, datestart: voteCard.datestart }"
|
||||
@changeBtn="(time) => timeChange = time"/>
|
||||
<div class="font-weight-bold text-center" v-else> Завершено: {{ new Date(voteCard.dateend).toLocaleDateString() }}</div>
|
||||
<v-card-actions class="justify-space-between mt-4 pb-2">
|
||||
<template v-if="!isFinished">
|
||||
<v-btn :disabled="voteCard.is_passed || timeChange" color="teal-darken-4" prepend-icon="mdi-vote-outline"
|
||||
rounded="xl" size="small" variant="outlined" @click="$emit('openVoteModal', voteCard)">
|
||||
{{ !voteCard.is_passed ? "Проголосовать" : "Уже проголосовали" }}
|
||||
</v-btn>
|
||||
</template>
|
||||
<template v-else>
|
||||
<v-btn color="teal-darken-4" prepend-icon="mdi-trophy-outline"
|
||||
rounded="xl" size="small" variant="outlined" @click="$emit('openResultModal', voteCard)">
|
||||
Результаты
|
||||
</v-btn>
|
||||
</template>
|
||||
<v-btn v-if="user.id === voteCard.author || user.is_superuser" color="error" size="medium" @click="youSure=true">
|
||||
<v-icon>mdi-delete</v-icon>
|
||||
<v-dialog v-model="youSure" width="500">
|
||||
|
||||
<v-carousel
|
||||
show-arrows="hover"
|
||||
hide-delimiters cycle
|
||||
height="200">
|
||||
<v-carousel-item
|
||||
v-for="(picture, index) in images"
|
||||
:key="index"
|
||||
:src="`${baseURL.slice(0, -1)}${picture}`">
|
||||
</v-carousel-item>
|
||||
</v-carousel>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-card-text class="">{{ voteCard.description }}</v-card-text>
|
||||
<Timer :voteTime="{ dateend: voteCard.dateend, datestart: voteCard.datestart }" @changeBtn="(time) => timeChange = time" />
|
||||
<v-card-actions class="justify-space-between mt-4 pb-2">
|
||||
<v-btn :disabled="voteCard.is_passed || timeChange" color="teal-darken-4" prepend-icon="mdi-vote-outline"
|
||||
variant="outlined" rounded="xl" size="small" @click="$emit('openVoteModal', voteCard)">
|
||||
{{ !voteCard.is_passed ? "Проголосовать" : "Уже проголосовали" }}
|
||||
</v-btn>
|
||||
<v-btn color="error" @click="youSure=true" size="medium">
|
||||
<v-icon>mdi-delete</v-icon>
|
||||
<v-dialog v-model="youSure" width="500">
|
||||
|
||||
<v-card max-width="450" class="flex">
|
||||
<v-btn
|
||||
class="align-self-end ma-2 text-red"
|
||||
icon="mdi-close"
|
||||
variant="text"
|
||||
size="medium"
|
||||
@click="youSure = false"
|
||||
/>
|
||||
<div class="ml-5 text-h6">
|
||||
Вы действительно хотите удалить голосование?
|
||||
</div>
|
||||
<template v-slot:actions>
|
||||
<v-btn-group>
|
||||
<v-btn
|
||||
class="text-red"
|
||||
@click="$emit('deleteVoting', voteCard.id), youSure = false">
|
||||
Да
|
||||
</v-btn>
|
||||
<v-btn
|
||||
class="text-green"
|
||||
@click="youSure = false">
|
||||
Нет
|
||||
</v-btn>
|
||||
</v-btn-group>
|
||||
</template>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
<v-card class="flex" max-width="450">
|
||||
<v-btn
|
||||
class="align-self-end ma-2 text-red"
|
||||
icon="mdi-close"
|
||||
size="medium"
|
||||
variant="text"
|
||||
@click="youSure = false"
|
||||
/>
|
||||
<div class="ml-5 text-h6">
|
||||
Вы действительно хотите удалить голосование?
|
||||
</div>
|
||||
<template v-slot:actions>
|
||||
<v-btn-group>
|
||||
<v-btn
|
||||
class="text-red"
|
||||
@click="$emit('deleteVoting', voteCard.id), youSure = false">
|
||||
Да
|
||||
</v-btn>
|
||||
<v-btn
|
||||
class="text-green"
|
||||
@click="youSure = false">
|
||||
Нет
|
||||
</v-btn>
|
||||
</v-btn-group>
|
||||
</template>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Timer from "@/components/UI/Timer.vue"
|
||||
import { baseURL } from "@/utils/axios-api";
|
||||
import { ref, computed } from 'vue'
|
||||
export default {
|
||||
components: { Timer },
|
||||
emits: ['openVoteModal', 'openEditVoteModal', 'deleteVoting'],
|
||||
props: {
|
||||
voteCard: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
return {
|
||||
id: 0,
|
||||
name: "",
|
||||
description: "",
|
||||
files: [],
|
||||
dateend: new Date(new Date().getTime() + 600000),
|
||||
is_passed: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
setup(props) {
|
||||
const timeChange = ref(false)
|
||||
const youSure = ref(false)
|
||||
import {baseURL} from "@/utils/axios-api";
|
||||
import {computed, ref} from 'vue'
|
||||
import {useAccountStore} from "@/store/AccountStore";
|
||||
|
||||
const images = computed(() => {
|
||||
return props.voteCard.files.length > 0 ? props.voteCard.files : ['/media/defaultimg/vote.png']
|
||||
})
|
||||
return { timeChange, baseURL, images, youSure }
|
||||
export default {
|
||||
components: {Timer},
|
||||
emits: ['openVoteModal', 'openEditVoteModal', 'deleteVoting', 'openResultModal'],
|
||||
props: {
|
||||
isFinished:{
|
||||
type:Boolean,
|
||||
default: false
|
||||
},
|
||||
voteCard: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
return {
|
||||
id: 0,
|
||||
name: "",
|
||||
description: "",
|
||||
files: [],
|
||||
dateend: new Date(new Date().getTime() + 600000),
|
||||
is_passed: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
setup(props) {
|
||||
const timeChange = ref(false)
|
||||
const youSure = ref(false)
|
||||
const isFinished = ref(false);
|
||||
const accountStore = useAccountStore();
|
||||
const user = accountStore.user;
|
||||
|
||||
const images = computed(() => {
|
||||
return props.voteCard.files.length > 0 ? props.voteCard.files : ['/media/defaultimg/vote.png']
|
||||
})
|
||||
|
||||
const date = new Date();
|
||||
const endDate = new Date(props.voteCard.dateend);
|
||||
const distance = endDate.getTime() - date.getTime();
|
||||
|
||||
if (distance <= 0) {
|
||||
isFinished.value = true;
|
||||
}
|
||||
|
||||
return {timeChange, baseURL, images, youSure, isFinished, user}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
</script>
|
||||
@@ -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>
|
||||
@@ -36,31 +39,30 @@
|
||||
outlined
|
||||
></v-textarea>
|
||||
|
||||
<div>
|
||||
<h6 class="text-h6">Дата начала:</h6>
|
||||
<div class="d-flex ga-10">
|
||||
<div class="d-flex ga-3 align-center">
|
||||
<h6 class="text-subtitle-1">Дата и время начала:</h6>
|
||||
<date-select :datedefault="form.startDate" @returndate="returnstart" />
|
||||
<v-select
|
||||
v-model="selectedTimeStart"
|
||||
:items="timeOptions"
|
||||
dense
|
||||
label="Время начала"
|
||||
outlined
|
||||
prepend-icon="mdi-calendar-clock"
|
||||
hide-details
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<h6 class="text-h6">Дата окончания:</h6>
|
||||
<div class="d-flex ga-3 align-center">
|
||||
<h6 class="text-subtitle-1">Дата и время окончания:</h6>
|
||||
<date-select :datedefault="form.endDate" @returndate="returnend" />
|
||||
<v-select
|
||||
v-model="selectedTimeEnd"
|
||||
:items="timeOptions"
|
||||
dense
|
||||
label="Время окончания"
|
||||
outlined
|
||||
prepend-icon="mdi-calendar-clock"
|
||||
hide-details
|
||||
/>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-btn color="teal-darken-4" size="medium" @click="step = 1">Далее</v-btn>
|
||||
@@ -148,7 +150,7 @@
|
||||
></v-switch>
|
||||
<v-autocomplete
|
||||
clearable
|
||||
v-model="selectedEmployees"
|
||||
v-model="question.selectedEmployees"
|
||||
:items="allEmployees"
|
||||
item-title="fio"
|
||||
item-value="id"
|
||||
@@ -244,22 +246,20 @@
|
||||
|
||||
</v-stepper-window>
|
||||
</v-stepper>
|
||||
</div>
|
||||
</template>
|
||||
</v-container>
|
||||
</v-row>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {computed, ref, watch} from "vue";
|
||||
import {createVote, getEmployees} from "@/utils/axios-api";
|
||||
import DateSelect from "@/components/UI/date-select.vue";
|
||||
import {useAccountStore} from "@/store/AccountStore";
|
||||
|
||||
export default {
|
||||
components: {DateSelect},
|
||||
emits: ['updating'],
|
||||
setup(props, {emit}) {
|
||||
const accountStore = useAccountStore();
|
||||
const user = accountStore.user;
|
||||
const step = ref(0);
|
||||
const isVoteCreated = ref(false);
|
||||
const form = ref({
|
||||
@@ -298,20 +298,13 @@ export default {
|
||||
|
||||
const handleSelectAll = (selected) => {
|
||||
if (selected.includes("all")) {
|
||||
currentQuestion.value.answers = groupedEmployees.value.map((employee) => ({
|
||||
form.value.questions[currentQuestionIndex.value].answers = groupedEmployees.value.map((employee) => ({
|
||||
text: employee.id,
|
||||
image: null
|
||||
image: null,
|
||||
}));
|
||||
selectedEmployees.value = groupedEmployees.value.map(employee => employee.id);
|
||||
} else if (
|
||||
selected.length === groupedEmployees.value.length &&
|
||||
!selected.includes("all")
|
||||
) {
|
||||
currentQuestion.value.answers = selected.map((id) => ({ text: id, image: null }));
|
||||
selectedEmployees.value = groupedEmployees.value.map(employee => employee.id);
|
||||
} else {
|
||||
currentQuestion.value.answers = selected.map((id) => ({ text: id, image: null }));
|
||||
selectedEmployees.value = groupedEmployees.value.map(employee => employee.id);
|
||||
form.value.questions[currentQuestionIndex.value].answers = selected.map((id) => ({ text: id, image: null }));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -320,10 +313,12 @@ export default {
|
||||
const addQuestion = () => {
|
||||
form.value.questions.push({
|
||||
text: "",
|
||||
settings: {type: "Ввести вручную", multiChoice: 1, onlyDep: false, withoutDirector: false},
|
||||
settings: { type: "Ввести вручную", multiChoice: 1, onlyDep: false, withoutDirector: false },
|
||||
image: null,
|
||||
answers: [],
|
||||
selectedEmployees: []
|
||||
});
|
||||
currentQuestionIndex.value = form.value.questions.length - 1;
|
||||
};
|
||||
|
||||
const removeQuestion = (index) => {
|
||||
@@ -335,7 +330,7 @@ export default {
|
||||
|
||||
const addAnswer = () => {
|
||||
if (currentQuestion.value) {
|
||||
currentQuestion.value.answers.push({text: "", image: null});
|
||||
form.value.questions[currentQuestionIndex.value].answers.push({ text: "", image: null });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -429,20 +424,16 @@ export default {
|
||||
const selectedEmployees = ref([]);
|
||||
|
||||
const onEmployeesChange = (selected) => {
|
||||
currentQuestion.value.answers = selected.map((id) => ({ text: id, image: null }));
|
||||
form.value.questions[currentQuestionIndex.value].answers = selected.map((id) => ({ text: id, image: null }));
|
||||
};
|
||||
|
||||
return {
|
||||
selectedEmployees,
|
||||
onEmployeesChange,
|
||||
returnend,
|
||||
returnstart,
|
||||
step,
|
||||
form,
|
||||
questionTypes,
|
||||
groupedEmployees,
|
||||
currentQuestionIndex,
|
||||
currentQuestion,
|
||||
addQuestion,
|
||||
removeQuestion,
|
||||
addAnswer,
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
<template>
|
||||
<v-container>
|
||||
|
||||
<v-row>
|
||||
<v-col cols="12">
|
||||
<v-card class="mb-4" outlined>
|
||||
<v-card-title>Победитель: {{ winner.name }}</v-card-title>
|
||||
<v-card-subtitle>
|
||||
Количество голосов: {{ winner.votes }}
|
||||
</v-card-subtitle>
|
||||
</v-card>
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
<v-row>
|
||||
<v-col cols="12">
|
||||
<v-card class="mb-4" outlined>
|
||||
<v-card-title>Все результаты</v-card-title>
|
||||
<v-card-text>
|
||||
<v-list>
|
||||
<v-list-item v-for="(option, index) in sortedResults" :key="index">
|
||||
<p>
|
||||
<strong>{{ option.name }}</strong>: {{ option.votes }} голосов
|
||||
</p>
|
||||
</v-list-item>
|
||||
</v-list>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-container>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { computed } from 'vue';
|
||||
|
||||
export default {
|
||||
name: 'VoteResult',
|
||||
props: {
|
||||
results: {
|
||||
type: Array,
|
||||
required: true,
|
||||
default: () => []
|
||||
}
|
||||
},
|
||||
setup(props) {
|
||||
const winner = computed(() => {
|
||||
return props.results.reduce((max, option) => (option.votes > max.votes ? option : max), { name: '', votes: 0 });
|
||||
});
|
||||
|
||||
const sortedResults = computed(() => {
|
||||
return [...props.results].sort((a, b) => b.votes - a.votes);
|
||||
});
|
||||
|
||||
return {
|
||||
winner,
|
||||
sortedResults
|
||||
};
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
h1 {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
</style>
|
||||
@@ -93,22 +93,20 @@ async function getVotes(status) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async function createVote(voteData) {
|
||||
|
||||
try {
|
||||
|
||||
|
||||
const formData = new FormData();
|
||||
voteData.questions.forEach(question => {
|
||||
formData.append('questionsfiles', question.image)
|
||||
console.log(question.image);
|
||||
if(!!question.image){
|
||||
const {name,size,lastModified}=question.image
|
||||
question.image={name,size,lastModified}
|
||||
}
|
||||
|
||||
|
||||
question.answers.forEach(answer=>{
|
||||
|
||||
|
||||
formData.append('answersfiles', answer.image)
|
||||
if(!!answer.image){
|
||||
const {name,size,lastModified}=answer.image
|
||||
@@ -125,8 +123,8 @@ async function createVote(voteData) {
|
||||
formData.append('startDate', new Date(voteData.startDate).toISOString());
|
||||
formData.append('endDate', new Date(voteData.endDate).toISOString());
|
||||
formData.append('questions', JSON.stringify(voteData.questions));
|
||||
|
||||
|
||||
|
||||
|
||||
const response = await axiosApiInstance.post('/api/vote/votecreate/', formData, {
|
||||
headers: {'Content-Type': 'multipart/form-data'},
|
||||
});
|
||||
@@ -188,9 +186,6 @@ async function getEmployees() {
|
||||
}
|
||||
}
|
||||
|
||||
getEmployees()
|
||||
.then(r => console.log(r))
|
||||
|
||||
|
||||
export {
|
||||
axiosApiInstance,
|
||||
|
||||
@@ -1,79 +1,56 @@
|
||||
<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-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 v-for="x in ['active','completed']" :value="x" class="h-100 overflow-auto">
|
||||
<v-row class="mx-2">
|
||||
<v-col
|
||||
v-for="voting in sortedCurrentVotes"
|
||||
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-container>
|
||||
</v-row>
|
||||
</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"
|
||||
:class="{ 'voted-card': voting.voted }"
|
||||
>
|
||||
<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-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"/>
|
||||
|
||||
@@ -97,13 +74,22 @@
|
||||
<v-card>
|
||||
<v-card-title>Результаты голосования: {{ selectedVoting?.title }}</v-card-title>
|
||||
<v-card-text>
|
||||
<p>Здесь отображаются результаты голосования...</p>
|
||||
<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>
|
||||
|
||||
@@ -113,15 +99,30 @@ 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 VoteResult from "@/components/vote/VoteResult.vue";
|
||||
import { deleteVote, getVoteDetail, getVotes } from "@/utils/axios-api";
|
||||
import { formatDate } from "@vueuse/shared";
|
||||
|
||||
export default {
|
||||
methods: { formatDate },
|
||||
|
||||
components: { CurrentVote, VoteConstructor, VoteCardVue },
|
||||
components: { CurrentVote, VoteConstructor, VoteCardVue, VoteResult },
|
||||
setup() {
|
||||
const currentTab = ref("current");
|
||||
const tabs=[
|
||||
{value:"active", text:'Текущие голосования'},
|
||||
{value:"completed", text:'Завершенные голосования'},
|
||||
{value:"constructor", text:'Создать новое голосование'},
|
||||
|
||||
]
|
||||
|
||||
|
||||
const testResults = [
|
||||
{name: 'Дональд Трамп', votes: 99},
|
||||
{name: 'Иван Иванов', votes: 30},
|
||||
{name: 'Аркадий Упукник', votes: 95},
|
||||
];
|
||||
|
||||
const currentTab = ref("active");
|
||||
const votes = ref([]);
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
@@ -139,17 +140,13 @@ export default {
|
||||
const resultsModal = ref(false);
|
||||
const selectedVoting = ref(null);
|
||||
|
||||
const sortedCurrentVotes = computed(() =>
|
||||
votes.value
|
||||
.filter((v) => new Date(v.dateend) > new Date())
|
||||
.sort((a, b) => new Date(a.dateend) - new Date(b.dateend))
|
||||
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 sortedCompletedVotes = computed(() =>
|
||||
votes.value
|
||||
.filter((v) => new Date(v.dateend) <= new Date())
|
||||
.sort((a, b) => new Date(b.dateend) - new Date(a.dateend))
|
||||
);
|
||||
|
||||
|
||||
const loadVoteDetails = async (id) => {
|
||||
try {
|
||||
@@ -194,6 +191,12 @@ export default {
|
||||
console.error("Ошибка при удалении голосования:", error);
|
||||
}
|
||||
};
|
||||
watch(currentTab,
|
||||
async () =>{
|
||||
|
||||
votes.value=[]
|
||||
await updating(currentTab.value)}
|
||||
)
|
||||
|
||||
watch(
|
||||
() => route,
|
||||
@@ -217,8 +220,8 @@ export default {
|
||||
return {
|
||||
currentTab,
|
||||
votes,
|
||||
sortedCurrentVotes,
|
||||
sortedCompletedVotes,
|
||||
sortedVotes,
|
||||
testResults,
|
||||
voteModal,
|
||||
editVoteModal,
|
||||
resultsModal,
|
||||
@@ -228,6 +231,7 @@ export default {
|
||||
deleteVoting,
|
||||
updating,
|
||||
res,
|
||||
tabs
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user