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