Merge branch 'dev-denzel' into сja
This commit is contained in:
commit
ec24d51b65
8 files changed
+286
-222
No files matched your search
@@ -2,3 +2,5 @@ from django.contrib import admin
|
|||||||
from .models import *
|
from .models import *
|
||||||
|
|
||||||
admin.site.register(Vote)
|
admin.site.register(Vote)
|
||||||
|
admin.site.register(Question)
|
||||||
|
admin.site.register(Answer)
|
||||||
+54
-22
@@ -1,32 +1,34 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-row dense class="ma-1 ">
|
<v-row class="px-2">
|
||||||
<v-card variant="text" class="py-1">
|
<v-card variant="text"
|
||||||
<v-card-title class="text-body-1"> До окончания голосования осталось: </v-card-title>
|
:disabled="disabledcard.disabled"
|
||||||
<v-row dense class="align-baseline justify-center">
|
class="py-2 mx-auto">
|
||||||
<v-col cols="auto" class="text-center">
|
<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">
|
<v-card class="bg-yellow-darken-4">
|
||||||
<v-card-title>{{ displayDays }}</v-card-title>
|
<div>{{ displayDays }}</div>
|
||||||
</v-card>
|
</v-card>
|
||||||
<span class="text-caption">{{ declOfNum(displayDays, [' день', ' дня', ' дней']) }}</span>
|
<span class="text-caption">{{ declOfNum(displayDays, [' день', ' дня', ' дней']) }}</span>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col cols="auto">:</v-col>
|
<v-col cols="auto" class="px-1">:</v-col>
|
||||||
<v-col cols="auto" class="text-center">
|
<v-col class="text-center">
|
||||||
<v-card class="bg-yellow-darken-4">
|
<v-card class="bg-yellow-darken-4">
|
||||||
<v-card-title>{{ displayHours }}</v-card-title>
|
<div>{{ displayHours }}</div>
|
||||||
</v-card>
|
</v-card>
|
||||||
<span class="text-caption">{{ declOfNum(displayHours, [' час', ' часа', ' часов']) }}</span>
|
<span class="text-caption">{{ declOfNum(displayHours, [' час', ' часа', ' часов']) }}</span>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col cols="auto">:</v-col>
|
<v-col cols="auto" class="px-1">:</v-col>
|
||||||
<v-col cols="auto" class="text-center">
|
<v-col class="text-center">
|
||||||
<v-card class="bg-yellow-darken-4">
|
<v-card class="bg-yellow-darken-4">
|
||||||
<v-card-title>{{ displayMinutes }}</v-card-title>
|
<div>{{ displayMinutes }}</div>
|
||||||
</v-card>
|
</v-card>
|
||||||
<span class="text-caption">{{ declOfNum(displayMinutes, [' минута', ' минуты', ' минут']) }}</span>
|
<span class="text-caption">{{ declOfNum(displayMinutes, [' минута', ' минуты', ' минут']) }}</span>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col cols="auto">:</v-col>
|
<v-col cols="auto" class="px-1">:</v-col>
|
||||||
<v-col cols="auto" class="text-center">
|
<v-col class="text-center">
|
||||||
<v-card class="bg-yellow-darken-4">
|
<v-card class="bg-yellow-darken-4">
|
||||||
<v-card-title>{{ displaySeconds }}</v-card-title>
|
<div>{{ displaySeconds }}</div>
|
||||||
</v-card>
|
</v-card>
|
||||||
<span class="text-caption">{{ declOfNum(displaySeconds, [' секунда', ' секунды', ' секунд']) }}</span>
|
<span class="text-caption">{{ declOfNum(displaySeconds, [' секунда', ' секунды', ' секунд']) }}</span>
|
||||||
</v-col>
|
</v-col>
|
||||||
@@ -39,13 +41,15 @@ import { computed, ref } from 'vue'
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
endTime: {
|
voteTime: {
|
||||||
type: String,
|
type: Object,
|
||||||
default: () => { return new Date(props.endTime).setFullYear() }
|
default: () => { return {
|
||||||
|
dateend:new Date().setFullYear(),
|
||||||
|
datestart:new Date().setFullYear()
|
||||||
|
}}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
setup(props, {emit}) {
|
||||||
setup(props) {
|
|
||||||
const seconds = 1000
|
const seconds = 1000
|
||||||
const displayMinutes = ref(0);
|
const displayMinutes = ref(0);
|
||||||
const displayHours = ref(0);
|
const displayHours = ref(0);
|
||||||
@@ -68,14 +72,40 @@ export default {
|
|||||||
const cases = [2, 0, 1, 1, 1, 2]
|
const cases = [2, 0, 1, 1, 1, 2]
|
||||||
return titles[(value % 100 > 4 && value % 100 < 20) ? 2 : cases[(value % 10 < 5) ? value % 10 : 5]]
|
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
|
||||||
|
}
|
||||||
|
|
||||||
function countDown() {
|
function countDown() {
|
||||||
const timer = setInterval(() => {
|
const timer = setInterval(() => {
|
||||||
const date = new Date()
|
const date = new Date()
|
||||||
const distance = new Date(props.endTime).getTime() - date.getTime()
|
const distance = new Date(props.voteTime[dateendorStart()]).getTime() - date.getTime()
|
||||||
|
|
||||||
if (distance < 0) {
|
if (distance <= 1) {
|
||||||
clearInterval(timer)
|
clearInterval(timer)
|
||||||
|
setTimeout(()=>countDown(),1000)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,6 +130,8 @@ export default {
|
|||||||
displayDays,
|
displayDays,
|
||||||
displaySeconds,
|
displaySeconds,
|
||||||
declOfNum,
|
declOfNum,
|
||||||
|
dateendorStart,
|
||||||
|
disabledcard
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -19,14 +19,14 @@
|
|||||||
density="compact"
|
density="compact"
|
||||||
v-bind="props"
|
v-bind="props"
|
||||||
>
|
>
|
||||||
<template v-slot:prepend-inner>
|
<template v-slot:prepend-inner>
|
||||||
<v-icon
|
<v-icon
|
||||||
v-bind="props"
|
v-bind="props"
|
||||||
icon='mdi-calendar-today'
|
icon='mdi-calendar-today'
|
||||||
color="cyan-darken-3"
|
color="cyan-darken-3"
|
||||||
size="x-small"
|
size="x-small"
|
||||||
|
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</v-textarea>
|
</v-textarea>
|
||||||
</template>
|
</template>
|
||||||
@@ -37,8 +37,6 @@
|
|||||||
hide-header
|
hide-header
|
||||||
@update:modelValue="dateStart"
|
@update:modelValue="dateStart"
|
||||||
border
|
border
|
||||||
:max="formatDash(new Date())"
|
|
||||||
:min="formatDash(appStore.countvisitor.visitdate)"
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</v-locale-provider>
|
</v-locale-provider>
|
||||||
@@ -59,14 +57,14 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
setup(props, {emit}) {
|
setup(props, {emit}) {
|
||||||
const appStore = useAppStore()
|
const appStore = useAppStore()
|
||||||
const maxdate = formatDash(new Date())
|
const maxdate = formatDash(new Date())
|
||||||
const menudate = ref(false)
|
const menudate = ref(false)
|
||||||
const selectedDate = ref(null)
|
const selectedDate = ref(null)
|
||||||
|
|
||||||
const dateStart = () => {
|
const dateStart = () => {
|
||||||
emit('returndate', selectedDate.value)
|
emit('returndate', selectedDate.value)
|
||||||
menudate.value=false
|
menudate.value=false
|
||||||
@@ -102,4 +100,4 @@ export default {
|
|||||||
.v-field__prepend-inner {
|
.v-field__prepend-inner {
|
||||||
align-items: center!important;
|
align-items: center!important;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -3,39 +3,40 @@
|
|||||||
<v-stepper v-model="activeStep">
|
<v-stepper v-model="activeStep">
|
||||||
<v-card-title>{{ data.name }}</v-card-title>
|
<v-card-title>{{ data.name }}</v-card-title>
|
||||||
<v-card-subtitle>{{ data.description }}</v-card-subtitle>
|
<v-card-subtitle>{{ data.description }}</v-card-subtitle>
|
||||||
|
{{ data }}
|
||||||
<!-- Шаги голосования -->
|
<!-- Шаги голосования -->
|
||||||
<v-stepper-header>
|
<v-stepper-header>
|
||||||
<v-stepper-item
|
<v-stepper-item
|
||||||
v-for="(question, index) in data.questions"
|
v-for="question in data.questions"
|
||||||
:key="index"
|
:key="question.numb"
|
||||||
:complete="index < activeStep"
|
:complete="question.numb < activeStep"
|
||||||
:step="index + 1"
|
:step="question.numb"
|
||||||
>
|
>
|
||||||
Вопрос {{ index + 1 }}
|
Вопрос {{ question.numb }}
|
||||||
</v-stepper-item>
|
</v-stepper-item>
|
||||||
</v-stepper-header>
|
</v-stepper-header>
|
||||||
|
|
||||||
<v-stepper-window>
|
<v-stepper-window>
|
||||||
<v-stepper-window-item
|
<v-stepper-window-item
|
||||||
v-for="(question, index) in data.questions"
|
v-for="(question, index) in data.questions"
|
||||||
:key="index"
|
:key="question.numb"
|
||||||
:step="index + 1"
|
:step="question.numb"
|
||||||
>
|
>
|
||||||
<v-card flat>
|
<v-card flat>
|
||||||
<v-card-title>{{ question.question }}</v-card-title>
|
<v-card-title>{{ question.question }}</v-card-title>
|
||||||
<v-card-text>
|
<v-card-text>
|
||||||
<!-- Ответы на вопрос -->
|
<!-- Ответы на вопрос -->
|
||||||
|
|
||||||
|
{{ result }}--
|
||||||
<v-row v-for="(answer, id) in question.answers" :key="id">
|
<v-row v-for="(answer, id) in question.answers" :key="id">
|
||||||
<v-checkbox
|
<v-checkbox
|
||||||
v-model="answers[index]"
|
v-model="result[question.id]"
|
||||||
:value="answer.answer"
|
:label="answer.answer"
|
||||||
|
:value="answer.id"
|
||||||
color="teal-darken-4"
|
color="teal-darken-4"
|
||||||
hide-details
|
hide-details
|
||||||
>
|
>
|
||||||
<template #label>
|
|
||||||
<span class="text-black">{{ answer.answer }}</span>
|
|
||||||
</template>
|
|
||||||
</v-checkbox>
|
</v-checkbox>
|
||||||
</v-row>
|
</v-row>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
@@ -94,9 +95,15 @@ export default {
|
|||||||
const isVoteSubmitted = ref(false);
|
const isVoteSubmitted = ref(false);
|
||||||
|
|
||||||
const isCurrentQuestionAnswered = computed(() => {
|
const isCurrentQuestionAnswered = computed(() => {
|
||||||
return !!answers.value[activeStep.value];
|
let q = props.data.questions.find(e=>e.numb==activeStep.value+1)
|
||||||
|
return result.value[q.id].length>0;
|
||||||
});
|
});
|
||||||
|
const getres=()=>{
|
||||||
|
return props.data.questions.reduce((acc,item)=> {acc[item.id]=[]
|
||||||
|
return acc
|
||||||
|
},{})
|
||||||
|
}
|
||||||
|
const result=ref(getres())
|
||||||
const nextStep = () => {
|
const nextStep = () => {
|
||||||
if (activeStep.value < props.data.questions.length - 1) {
|
if (activeStep.value < props.data.questions.length - 1) {
|
||||||
activeStep.value++;
|
activeStep.value++;
|
||||||
@@ -110,14 +117,15 @@ export default {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const submitVote = () => {
|
const submitVote = () => {
|
||||||
const voteData = props.data.questions.map((question, index) => ({
|
// const voteData = props.data.questions.map((question, index) => ({
|
||||||
question: question.question,
|
// question: question.id,
|
||||||
answer: answers.value[index],
|
// answer: answers.value[index],
|
||||||
}));
|
// }));
|
||||||
console.log("Отправляем данные голосования:", voteData);
|
result.value
|
||||||
|
console.log("Отправляем данные голосования:", result.value);
|
||||||
|
|
||||||
isVoteSubmitted.value = true;
|
// isVoteSubmitted.value = true;
|
||||||
emit("submit", voteData);
|
// emit("submit", voteData);
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -128,6 +136,7 @@ export default {
|
|||||||
prevStep,
|
prevStep,
|
||||||
submitVote,
|
submitVote,
|
||||||
isVoteSubmitted,
|
isVoteSubmitted,
|
||||||
|
result
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,16 +1,26 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-card>
|
<v-card>
|
||||||
<v-card-text class="d-flex justify-space-between ga-3 text-h6"> {{ voteCard.name }}
|
<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-btn flat size="medium" @click="$emit('openEditVoteModal', voteCard)">
|
||||||
<v-icon color="orange-lighten-1">mdi-pencil</v-icon>
|
<v-icon color="orange-lighten-1">mdi-pencil</v-icon>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
<v-img cover :src="voteCard.pictures" />
|
<v-row>
|
||||||
<v-card-text class="text-body-1">{{ voteCard.description }}</v-card-text>
|
<v-col>
|
||||||
<TimerUI :endTime="voteCard.dateend" />
|
|
||||||
<v-card-actions class="justify-space-between">
|
<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
|
<v-btn
|
||||||
v-if="!voteCard.is_passed"
|
:disabled="voteCard.is_passed || timeChange"
|
||||||
color="teal-darken-4"
|
color="teal-darken-4"
|
||||||
prepend-icon="mdi-vote-outline"
|
prepend-icon="mdi-vote-outline"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
@@ -18,9 +28,8 @@
|
|||||||
size="medium"
|
size="medium"
|
||||||
class="pa-2"
|
class="pa-2"
|
||||||
@click="$emit('openVoteModal', voteCard)">
|
@click="$emit('openVoteModal', voteCard)">
|
||||||
Проголосовать
|
{{!voteCard.is_passed?"Проголосовать":"Уже проголосовали"}}
|
||||||
</v-btn>
|
</v-btn>
|
||||||
<v-btn v-else color="teal-darken-4" disabled size="medium">Уже проголосовали</v-btn>
|
|
||||||
<v-btn color="error" @click="$emit('deleteVoting', voteCard.id)" size="medium">
|
<v-btn color="error" @click="$emit('deleteVoting', voteCard.id)" size="medium">
|
||||||
<v-icon>mdi-delete</v-icon>
|
<v-icon>mdi-delete</v-icon>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
@@ -29,10 +38,11 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import TimerUI from '../secret/TimerUI.vue';
|
import Timer from "@/components/UI/Timer.vue"
|
||||||
|
import { baseURL } from "@/utils/axios-api";
|
||||||
|
import { ref, computed } from 'vue'
|
||||||
export default {
|
export default {
|
||||||
components: { TimerUI },
|
components: { Timer },
|
||||||
emits: ['openVoteModal', 'openEditVoteModal', 'deleteVoting'],
|
emits: ['openVoteModal', 'openEditVoteModal', 'deleteVoting'],
|
||||||
props: {
|
props: {
|
||||||
voteCard: {
|
voteCard: {
|
||||||
@@ -40,15 +50,23 @@ export default {
|
|||||||
default: () => {
|
default: () => {
|
||||||
return {
|
return {
|
||||||
id: 0,
|
id: 0,
|
||||||
name: "Допустим, здесь могла быть ваша реклама",
|
name: "",
|
||||||
description: "Но таких денег у вас нет, чтобы получить ее на нашем прекрасном голосовании",
|
description: "",
|
||||||
pictures: "https://cdn.vuetifyjs.com/images/parallax/material.jpg",
|
files: [],
|
||||||
dateend: new Date(new Date().getTime() + 600000),
|
dateend: new Date(new Date().getTime() + 600000),
|
||||||
is_passed: false,
|
is_passed: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
setup(props) {
|
||||||
|
const timeChange = ref(false)
|
||||||
|
const images = computed(()=>{
|
||||||
|
return props.voteCard.files.length>0? props.voteCard.files:['/media/defaultimg/vote.png']
|
||||||
|
})
|
||||||
|
return { timeChange, baseURL ,images}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
@@ -25,58 +25,41 @@
|
|||||||
<v-card-text>
|
<v-card-text>
|
||||||
<v-text-field
|
<v-text-field
|
||||||
v-model="form.title"
|
v-model="form.title"
|
||||||
|
:rules="[rules.required]"
|
||||||
label="Название голосования"
|
label="Название голосования"
|
||||||
outlined
|
outlined
|
||||||
:rules="[rules.required]"
|
|
||||||
></v-text-field>
|
></v-text-field>
|
||||||
<v-textarea
|
<v-textarea
|
||||||
v-model="form.description"
|
v-model="form.description"
|
||||||
|
:rules="[rules.required]"
|
||||||
label="Описание"
|
label="Описание"
|
||||||
outlined
|
outlined
|
||||||
:rules="[rules.required]"
|
|
||||||
></v-textarea>
|
></v-textarea>
|
||||||
|
|
||||||
<v-text-field
|
<div>
|
||||||
:placeholder="`${form.startDate.toLocaleDateString()} ${form.startDate.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}`"
|
<h6 class="text-h6">Дата начала:</h6>
|
||||||
:value="`${form.startDate.toLocaleDateString()} ${form.startDate.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}`"
|
<date-select :datedefault="form.startDate" @returndate="returnstart" />
|
||||||
color="teal-darken-4"
|
<v-select
|
||||||
label="Дата и время начала"
|
v-model="selectedTimeStart"
|
||||||
persistentPlaceholder
|
:items="timeOptions"
|
||||||
readonly
|
dense
|
||||||
>
|
label="Время начала"
|
||||||
<v-menu activator="parent">
|
outlined
|
||||||
<v-date-picker
|
prepend-icon="mdi-calendar-clock"
|
||||||
v-model="form.startDate"
|
|
||||||
color="teal-darken-4"
|
|
||||||
hideHeader
|
|
||||||
hideWeekdays
|
|
||||||
/>
|
/>
|
||||||
</v-menu>
|
</div>
|
||||||
<v-btn flat icon style="background-color: transparent">
|
<div>
|
||||||
<v-icon>mdi-calendar-clock</v-icon>
|
<h6 class="text-h6">Дата окончания:</h6>
|
||||||
</v-btn>
|
<date-select :datedefault="form.endDate" @returndate="returnend" />
|
||||||
</v-text-field>
|
<v-select
|
||||||
|
v-model="selectedTimeEnd"
|
||||||
<v-text-field
|
:items="timeOptions"
|
||||||
:placeholder="`${form.endDate.toLocaleDateString()} ${form.endDate.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}`"
|
dense
|
||||||
:value="`${form.endDate.toLocaleDateString()} ${form.endDate.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}`"
|
label="Время окончания"
|
||||||
color="teal-darken-4"
|
outlined
|
||||||
label="Дата и время окончания"
|
prepend-icon="mdi-calendar-clock"
|
||||||
persistentPlaceholder
|
|
||||||
readonly
|
|
||||||
>
|
|
||||||
<v-menu activator="parent">
|
|
||||||
<v-date-picker
|
|
||||||
v-model="form.endDate"
|
|
||||||
color="teal-darken-4"
|
|
||||||
hideHeader
|
|
||||||
hideWeekdays
|
|
||||||
/>
|
/>
|
||||||
</v-menu>
|
</div>
|
||||||
<v-btn flat icon style="background-color: transparent">
|
|
||||||
<v-icon>mdi-calendar-clock</v-icon>
|
|
||||||
</v-btn>
|
|
||||||
</v-text-field>
|
|
||||||
|
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
<v-card-actions>
|
<v-card-actions>
|
||||||
@@ -95,92 +78,92 @@
|
|||||||
<v-text-field
|
<v-text-field
|
||||||
v-model="question.text"
|
v-model="question.text"
|
||||||
:label="'Вопрос ' + (index + 1)"
|
:label="'Вопрос ' + (index + 1)"
|
||||||
outlined
|
|
||||||
:rules="[rules.required]"
|
:rules="[rules.required]"
|
||||||
|
outlined
|
||||||
></v-text-field>
|
></v-text-field>
|
||||||
<v-btn color="error" icon @click="removeQuestion(index)">
|
<v-btn color="error" icon @click="removeQuestion(index)">
|
||||||
<v-icon>mdi-delete</v-icon>
|
<v-icon>mdi-delete</v-icon>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</div>
|
</div>
|
||||||
<v-file-input
|
<v-file-input
|
||||||
v-model="question.image"
|
v-model="question.image"
|
||||||
accept="image/*"
|
accept="image/*"
|
||||||
label="Картинка для вопроса"
|
label="Картинка для вопроса"
|
||||||
outlined
|
outlined
|
||||||
></v-file-input>
|
></v-file-input>
|
||||||
<v-select
|
<v-select
|
||||||
v-model="question.type"
|
v-model="question.type"
|
||||||
:items="questionTypes"
|
:items="questionTypes"
|
||||||
label="Тип ответа"
|
label="Тип ответа"
|
||||||
outlined
|
outlined
|
||||||
></v-select>
|
></v-select>
|
||||||
<v-switch
|
<v-switch
|
||||||
v-model="question.multiChoice"
|
v-model="question.multiChoice"
|
||||||
color="teal-darken-4"
|
|
||||||
:label="`Множественный выбор: ${question.multiChoice ? 'да' : 'нет'}`"
|
|
||||||
:false-value="false"
|
:false-value="false"
|
||||||
|
:label="`Множественный выбор: ${question.multiChoice ? 'да' : 'нет'}`"
|
||||||
:true-value="true"
|
:true-value="true"
|
||||||
|
color="teal-darken-4"
|
||||||
hide-details
|
hide-details
|
||||||
></v-switch>
|
></v-switch>
|
||||||
<v-card-text>
|
<v-card-text>
|
||||||
<div v-if="question.type === 'Ввести вручную'">
|
<div v-if="question.type === 'Ввести вручную'">
|
||||||
<div
|
<div
|
||||||
v-for="(answer, index) in question.answers"
|
v-for="(answer, index) in question.answers"
|
||||||
:key="index"
|
:key="index"
|
||||||
class="d-flex align-start mb-4"
|
class="d-flex align-start mb-4"
|
||||||
>
|
>
|
||||||
<v-text-field
|
<v-text-field
|
||||||
v-model="answer.text"
|
v-model="answer.text"
|
||||||
:label="'Ответ ' + (index + 1)"
|
:label="'Ответ ' + (index + 1)"
|
||||||
class="mr-4"
|
:rules="[rules.required]"
|
||||||
outlined
|
class="mr-4"
|
||||||
:rules="[rules.required]"
|
outlined
|
||||||
></v-text-field>
|
></v-text-field>
|
||||||
<v-file-input
|
<v-file-input
|
||||||
v-model="answer.image"
|
v-model="answer.image"
|
||||||
accept="image/*"
|
accept="image/*"
|
||||||
dense
|
dense
|
||||||
hide-details
|
hide-details
|
||||||
label="Картинка"
|
label="Картинка"
|
||||||
outlined
|
outlined
|
||||||
></v-file-input>
|
></v-file-input>
|
||||||
<v-btn color="error" icon @click="removeAnswer(index)">
|
<v-btn color="error" icon @click="removeAnswer(index)">
|
||||||
<v-icon>mdi-delete</v-icon>
|
<v-icon>mdi-delete</v-icon>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</div>
|
</div>
|
||||||
<v-btn color="teal-darken-4" @click="addAnswer">Добавить ответ</v-btn>
|
<v-btn color="teal-darken-4" @click="addAnswer">Добавить ответ</v-btn>
|
||||||
</div>
|
</div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<v-autocomplete
|
<v-autocomplete
|
||||||
v-model="currentQuestion.selectedEmployees"
|
v-model="currentQuestion.selectedEmployees"
|
||||||
:items="groupedEmployees"
|
:items="groupedEmployees"
|
||||||
item-title="fio"
|
item-title="fio"
|
||||||
item-value="id"
|
item-value="id"
|
||||||
label="Выберите сотрудников"
|
label="Выберите сотрудников"
|
||||||
multiple
|
multiple
|
||||||
outlined
|
outlined
|
||||||
></v-autocomplete>
|
></v-autocomplete>
|
||||||
<div
|
<div
|
||||||
v-for="(person, index) in currentQuestion.selectedEmployees"
|
v-for="(person, index) in currentQuestion.selectedEmployees"
|
||||||
:key="person.id"
|
:key="person.id"
|
||||||
class="d-flex align-center mb-4"
|
class="d-flex align-center mb-4"
|
||||||
>
|
>
|
||||||
<v-chip>{{ findEmployeeById(person).fio }}</v-chip>
|
<v-chip>{{ findEmployeeById(person).fio }}</v-chip>
|
||||||
<v-file-input
|
<v-file-input
|
||||||
v-model="currentQuestion.selectedEmployeeImages[person]"
|
v-model="currentQuestion.selectedEmployeeImages[person]"
|
||||||
accept="image/*"
|
accept="image/*"
|
||||||
class="ml-4"
|
class="ml-4"
|
||||||
dense
|
dense
|
||||||
hide-details
|
hide-details
|
||||||
label="Картинка"
|
label="Картинка"
|
||||||
outlined
|
outlined
|
||||||
></v-file-input>
|
></v-file-input>
|
||||||
<v-btn color="error" icon @click="removeEmployee(index)">
|
<v-btn color="error" icon @click="removeEmployee(index)">
|
||||||
<v-icon>mdi-delete</v-icon>
|
<v-icon>mdi-delete</v-icon>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
</div>
|
</div>
|
||||||
<v-btn color="teal-darken-4" @click="addQuestion">Добавить вопрос</v-btn>
|
<v-btn color="teal-darken-4" @click="addQuestion">Добавить вопрос</v-btn>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
@@ -216,8 +199,8 @@
|
|||||||
<p><strong>Выбранные сотрудники:</strong></p>
|
<p><strong>Выбранные сотрудники:</strong></p>
|
||||||
<ul>
|
<ul>
|
||||||
<li
|
<li
|
||||||
v-for="employeeId in question.selectedEmployees"
|
v-for="employeeId in question.selectedEmployees"
|
||||||
:key="employeeId"
|
:key="employeeId"
|
||||||
>
|
>
|
||||||
{{ findEmployeeById(employeeId).fio }}
|
{{ findEmployeeById(employeeId).fio }}
|
||||||
</li>
|
</li>
|
||||||
@@ -230,7 +213,7 @@
|
|||||||
<v-btn color="teal-darken-4" size="medium" @click="step -= 1">Назад</v-btn>
|
<v-btn color="teal-darken-4" size="medium" @click="step -= 1">Назад</v-btn>
|
||||||
<v-btn color="teal-darken-4" size="medium" @click="saveVoting">Сохранить</v-btn>
|
<v-btn color="teal-darken-4" size="medium" @click="saveVoting">Сохранить</v-btn>
|
||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
<v-alert v-if="errorMessage" type="error" class="mb-4">
|
<v-alert v-if="errorMessage" class="mb-4" type="error">
|
||||||
{{ errorMessage }}
|
{{ errorMessage }}
|
||||||
</v-alert>
|
</v-alert>
|
||||||
</v-card>
|
</v-card>
|
||||||
@@ -243,10 +226,12 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {computed, ref} from "vue";
|
import {computed, ref, watch} from "vue";
|
||||||
import { createVote } from "@/utils/axios-api";
|
import {createVote} from "@/utils/axios-api";
|
||||||
|
import DateSelect from "@/components/UI/date-select.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
components: {DateSelect},
|
||||||
emits: ['updating'],
|
emits: ['updating'],
|
||||||
setup(props, {emit}) {
|
setup(props, {emit}) {
|
||||||
const step = ref(0);
|
const step = ref(0);
|
||||||
@@ -272,11 +257,11 @@ export default {
|
|||||||
];
|
];
|
||||||
|
|
||||||
const currentQuestion = computed(() =>
|
const currentQuestion = computed(() =>
|
||||||
form.value.questions[currentQuestionIndex.value] || null
|
form.value.questions[currentQuestionIndex.value] || null
|
||||||
);
|
);
|
||||||
|
|
||||||
const findEmployeeById = (id) =>
|
const findEmployeeById = (id) =>
|
||||||
groupedEmployees.find((employee) => employee.id === id) || {};
|
groupedEmployees.find((employee) => employee.id === id) || {};
|
||||||
|
|
||||||
const removeEmployee = (index) => {
|
const removeEmployee = (index) => {
|
||||||
currentQuestion.value.selectedEmployees.splice(index, 1);
|
currentQuestion.value.selectedEmployees.splice(index, 1);
|
||||||
@@ -342,7 +327,55 @@ export default {
|
|||||||
isVoteCreated.value = false;
|
isVoteCreated.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const timeOptions = Array.from({length: 48}, (_, i) => {
|
||||||
|
const hours = String(Math.floor(i / 2)).padStart(2, "0");
|
||||||
|
const minutes = i % 2 === 0 ? "00" : "30";
|
||||||
|
return `${hours}:${minutes}`;
|
||||||
|
});
|
||||||
|
|
||||||
|
const selectedTimeStart = ref(
|
||||||
|
`${form.value.startDate.getHours().toString().padStart(2, "0")}:${form.value.startDate
|
||||||
|
.getMinutes()
|
||||||
|
.toString()
|
||||||
|
.padStart(2, "0")}`
|
||||||
|
);
|
||||||
|
|
||||||
|
const selectedTimeEnd = ref(
|
||||||
|
`${form.value.endDate.getHours().toString().padStart(2, "0")}:${form.value.endDate
|
||||||
|
.getMinutes()
|
||||||
|
.toString()
|
||||||
|
.padStart(2, "0")}`
|
||||||
|
);
|
||||||
|
|
||||||
|
watch(selectedTimeStart, () => {
|
||||||
|
updateStartDate()
|
||||||
|
})
|
||||||
|
watch(selectedTimeEnd, () => {
|
||||||
|
|
||||||
|
updateEndDate()
|
||||||
|
})
|
||||||
|
|
||||||
|
const updateStartDate = () => {
|
||||||
|
const [hours, minutes] = selectedTimeStart.value.split(":").map(Number);
|
||||||
|
form.value.startDate.setHours(hours, minutes);
|
||||||
|
};
|
||||||
|
const updateEndDate = () => {
|
||||||
|
const [hours, minutes] = selectedTimeEnd.value.split(":").map(Number);
|
||||||
|
console.log( form.value.endDate);
|
||||||
|
form.value.endDate.setHours(hours, minutes);
|
||||||
|
};
|
||||||
|
|
||||||
|
const returnstart = (dates) => {
|
||||||
|
form.value.startDate = dates
|
||||||
|
}
|
||||||
|
|
||||||
|
const returnend = (dates) => {
|
||||||
|
form.value.endtDate = dates
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
returnend,
|
||||||
|
returnstart,
|
||||||
step,
|
step,
|
||||||
form,
|
form,
|
||||||
questionTypes,
|
questionTypes,
|
||||||
@@ -359,29 +392,17 @@ export default {
|
|||||||
isVoteCreated,
|
isVoteCreated,
|
||||||
resetForm,
|
resetForm,
|
||||||
rules,
|
rules,
|
||||||
errorMessage
|
errorMessage,
|
||||||
|
timeOptions,
|
||||||
|
selectedTimeStart,
|
||||||
|
selectedTimeEnd
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.t-datetime-picker {
|
.v-input--horizontal .v-input__prepend {
|
||||||
.v-tabs-slider-wrapper {
|
margin-inline-end: 4px;
|
||||||
top: 0;
|
|
||||||
}
|
|
||||||
.v-picker__title {
|
|
||||||
height: 90px;
|
|
||||||
}
|
|
||||||
.v-time-picker-title__time * {
|
|
||||||
font-size: 60px;
|
|
||||||
height: 60px;
|
|
||||||
}
|
|
||||||
.v-picker__body {
|
|
||||||
height: 290px;
|
|
||||||
}
|
|
||||||
.v-tabs-items {
|
|
||||||
height: 380px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -93,22 +93,6 @@ async function getVotes(status) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// getVotes('completed')
|
|
||||||
// .then(data => {
|
|
||||||
// console.log('Завершённые голосования:', data);
|
|
||||||
// })
|
|
||||||
// .catch(err => {
|
|
||||||
// console.error('Ошибка:', err);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// getVotes('active')
|
|
||||||
// .then(data => {
|
|
||||||
// console.log('Активные голосования:', data);
|
|
||||||
// })
|
|
||||||
// .catch(err => {
|
|
||||||
// console.error('Ошибка:', err);
|
|
||||||
// });
|
|
||||||
|
|
||||||
async function createVote(voteData, files) {
|
async function createVote(voteData, files) {
|
||||||
try {
|
try {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-container>
|
<v-container class="py-0">
|
||||||
<v-toolbar color="transparent">
|
<v-toolbar color="transparent">
|
||||||
<v-toolbar-title>Голосования</v-toolbar-title>
|
<v-toolbar-title>Голосования</v-toolbar-title>
|
||||||
<template v-slot:extension>
|
<template v-slot:extension>
|
||||||
@@ -84,7 +84,7 @@
|
|||||||
</v-card-text>
|
</v-card-text>
|
||||||
</v-card>
|
</v-card>
|
||||||
</v-dialog>
|
</v-dialog>
|
||||||
{{res}}
|
|
||||||
<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>
|
||||||
|
|||||||
Reference in new issue
Block a user