P-92
This commit is contained in:
1 parent
07e3491f73
commit
980b6024c6
8 files changed
+681
-369
No files matched your search
@@ -0,0 +1,170 @@
|
|||||||
|
<template>
|
||||||
|
<template v-if="!isVoteSubmitted">
|
||||||
|
<!-- Заголовок голосовалки -->
|
||||||
|
<v-row class="pt-0">
|
||||||
|
<v-col cols="12">
|
||||||
|
<v-card flat>
|
||||||
|
<v-card-title>{{ title }}</v-card-title>
|
||||||
|
<v-card-subtitle>{{ description }}</v-card-subtitle>
|
||||||
|
</v-card>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
|
||||||
|
<!-- Ожидаемая дата окончания голосования -->
|
||||||
|
<v-row>
|
||||||
|
<v-col cols="12">
|
||||||
|
<v-chip :color="isVotingActive ? 'green' : 'red'">
|
||||||
|
<v-icon>{{ isVotingActive ? 'mdi-check-circle' : 'mdi-clock' }}</v-icon>
|
||||||
|
{{ isVotingActive ? 'Голосование активно' : `Голосование закончится: ${endDateFormatted}` }}
|
||||||
|
</v-chip>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
|
||||||
|
<!-- Вопросы голосования -->
|
||||||
|
<v-row v-for="(question, index) in questions" :key="index">
|
||||||
|
<v-col cols="12">
|
||||||
|
<v-card flat>
|
||||||
|
<v-card-title>{{ question.text }}</v-card-title>
|
||||||
|
|
||||||
|
<!-- Вопросы с типом "Ввести вручную" -->
|
||||||
|
<v-card-text v-if="question.type === 'Ввести вручную'">
|
||||||
|
<v-row v-for="(answer, id) in question.answers" :key="id">
|
||||||
|
<v-checkbox
|
||||||
|
v-model="answers[index]"
|
||||||
|
:value="answer.text"
|
||||||
|
color="teal-darken-4 opacity-100"
|
||||||
|
hide-details
|
||||||
|
>
|
||||||
|
<template #label>
|
||||||
|
<span class="text-black text-subtitle-1 opacity-100">{{ answer.text }}</span>
|
||||||
|
</template>
|
||||||
|
</v-checkbox>
|
||||||
|
</v-row>
|
||||||
|
</v-card-text>
|
||||||
|
|
||||||
|
<!-- Вопросы с типом "Выбрать сотрудника" -->
|
||||||
|
<v-card-text v-if="question.type === 'Выбрать сотрудника'">
|
||||||
|
<v-row v-for="employee in question.selectedEmployees" :key="employee.id">
|
||||||
|
<v-checkbox
|
||||||
|
v-model="selectedEmployees[index]"
|
||||||
|
:value="employee.id"
|
||||||
|
color="teal-darken-4 opacity-100"
|
||||||
|
hide-details
|
||||||
|
>
|
||||||
|
<template #label>
|
||||||
|
<span class="text-black text-subtitle-1 opacity-100">{{ employee.name }}</span>
|
||||||
|
</template>
|
||||||
|
</v-checkbox>
|
||||||
|
</v-row>
|
||||||
|
</v-card-text>
|
||||||
|
</v-card>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
|
||||||
|
<!-- Кнопка для отправки голосования -->
|
||||||
|
<v-row>
|
||||||
|
<v-col cols="12">
|
||||||
|
<v-btn
|
||||||
|
:disabled="!isVotingActive || !isAllQuestionsAnswered"
|
||||||
|
color="teal-darken-4"
|
||||||
|
@click="submitVote"
|
||||||
|
>
|
||||||
|
Отправить голос
|
||||||
|
</v-btn>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<!-- Спасибо за голос -->
|
||||||
|
<template v-else>
|
||||||
|
<v-row align="center" justify="center" style="height: 50vh;">
|
||||||
|
<v-col class="text-center" cols="12">
|
||||||
|
<v-icon color="green" size="64">mdi-check-circle</v-icon>
|
||||||
|
<h2>Спасибо за Ваш голос!</h2>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {computed, ref} from "vue";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
description: String,
|
||||||
|
endDate: String,
|
||||||
|
questions: Array,
|
||||||
|
startDate: String,
|
||||||
|
title: String,
|
||||||
|
},
|
||||||
|
setup(props, {emit}) {
|
||||||
|
// Ответы на вопросы
|
||||||
|
const answers = ref([]);
|
||||||
|
const selectedEmployees = ref(props.questions.map(() => []));
|
||||||
|
|
||||||
|
// Форматированная дата окончания голосования
|
||||||
|
const endDateFormatted = computed(() =>
|
||||||
|
new Date(props.endDate).toLocaleString()
|
||||||
|
);
|
||||||
|
|
||||||
|
// Проверка активности голосования
|
||||||
|
const isVotingActive = computed(() => {
|
||||||
|
const currentDate = new Date();
|
||||||
|
const endDate = new Date(props.endDate);
|
||||||
|
return currentDate < endDate;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Проверка, все ли вопросы были отвечены
|
||||||
|
const isAllQuestionsAnswered = computed(() => {
|
||||||
|
return props.questions.every((question, index) => {
|
||||||
|
if (question.type === "Ввести вручную") {
|
||||||
|
return !!answers.value[index];
|
||||||
|
}
|
||||||
|
if (question.type === "Выбрать сотрудника") {
|
||||||
|
return selectedEmployees.value[index].length > 0;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Состояние для определения отправки голоса
|
||||||
|
const isVoteSubmitted = ref(false);
|
||||||
|
|
||||||
|
// Отправка голосования
|
||||||
|
const submitVote = () => {
|
||||||
|
const voteData = props.questions.map((question, index) => ({
|
||||||
|
question: question.text,
|
||||||
|
type: question.type,
|
||||||
|
answer:
|
||||||
|
question.type === "Ввести вручную"
|
||||||
|
? answers.value[index]
|
||||||
|
: selectedEmployees.value[index],
|
||||||
|
}));
|
||||||
|
console.log("Отправляем данные голосования:", voteData);
|
||||||
|
|
||||||
|
// После успешной отправки
|
||||||
|
isVoteSubmitted.value = true;
|
||||||
|
emit("submit", voteData);
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
answers,
|
||||||
|
selectedEmployees,
|
||||||
|
endDateFormatted,
|
||||||
|
isVotingActive,
|
||||||
|
isVoteSubmitted,
|
||||||
|
isAllQuestionsAnswered,
|
||||||
|
submitVote,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
|
||||||
|
.v-label {
|
||||||
|
color: #000 !important;
|
||||||
|
opacity: 1 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,356 @@
|
|||||||
|
<template>
|
||||||
|
<v-container>
|
||||||
|
<template v-if="isVoteCreated">
|
||||||
|
<v-card class="text-center pa-8" flat>
|
||||||
|
<v-icon color="success" size="48">mdi-check-circle</v-icon>
|
||||||
|
<h2 class="mt-4">Голосование создано!</h2>
|
||||||
|
<v-btn class="mt-4" color="teal-darken-4" @click="resetForm">Создать ещё</v-btn>
|
||||||
|
</v-card>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<v-stepper v-model="step" editable>
|
||||||
|
<v-stepper-header>
|
||||||
|
<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-divider></v-divider>
|
||||||
|
<v-stepper-item step="4">Подтверждение</v-stepper-item>
|
||||||
|
</v-stepper-header>
|
||||||
|
|
||||||
|
<v-stepper-window>
|
||||||
|
<!-- Основная информация -->
|
||||||
|
<v-stepper-window-item step="1">
|
||||||
|
<v-card flat>
|
||||||
|
<v-card-title>Основная информация</v-card-title>
|
||||||
|
<v-card-text>
|
||||||
|
<v-text-field v-model="form.title" label="Название голосования" outlined></v-text-field>
|
||||||
|
<v-textarea v-model="form.description" label="Описание" outlined></v-textarea>
|
||||||
|
<v-text-field
|
||||||
|
:placeholder="form.startDate.toLocaleDateString()"
|
||||||
|
:value="form.startDate.toLocaleDateString()"
|
||||||
|
color="teal-darken-4"
|
||||||
|
label="Дата начала"
|
||||||
|
persistentPlaceholder
|
||||||
|
readonly
|
||||||
|
>
|
||||||
|
<v-menu activator="parent">
|
||||||
|
<v-date-picker
|
||||||
|
v-model="form.startDate"
|
||||||
|
color="teal-darken-4"
|
||||||
|
hideHeader
|
||||||
|
hideWeekdays
|
||||||
|
>
|
||||||
|
</v-date-picker>
|
||||||
|
</v-menu>
|
||||||
|
<v-btn flat icon style="background-color: transparent">
|
||||||
|
<v-icon>mdi-calendar</v-icon>
|
||||||
|
</v-btn>
|
||||||
|
</v-text-field>
|
||||||
|
|
||||||
|
<v-text-field
|
||||||
|
:placeholder="form.endDate.toLocaleDateString()"
|
||||||
|
:value="form.endDate.toLocaleDateString()"
|
||||||
|
color="teal-darken-4"
|
||||||
|
label="Дата окончания"
|
||||||
|
persistentPlaceholder
|
||||||
|
readonly
|
||||||
|
>
|
||||||
|
<v-menu activator="parent">
|
||||||
|
<v-date-picker
|
||||||
|
v-model="form.endDate"
|
||||||
|
color="teal-darken-4"
|
||||||
|
hideHeader
|
||||||
|
hideWeekdays
|
||||||
|
>
|
||||||
|
</v-date-picker>
|
||||||
|
</v-menu>
|
||||||
|
<v-btn flat icon style="background-color: transparent">
|
||||||
|
<v-icon>mdi-calendar</v-icon>
|
||||||
|
</v-btn>
|
||||||
|
</v-text-field>
|
||||||
|
</v-card-text>
|
||||||
|
<v-card-actions>
|
||||||
|
<v-btn color="teal-darken-4" size="medium" @click="step = 1">Далее</v-btn>
|
||||||
|
</v-card-actions>
|
||||||
|
</v-card>
|
||||||
|
</v-stepper-window-item>
|
||||||
|
|
||||||
|
<!-- Создание опроса -->
|
||||||
|
<v-stepper-window-item step="2">
|
||||||
|
<v-card flat>
|
||||||
|
<v-card-title>Создание опроса</v-card-title>
|
||||||
|
<v-card-text>
|
||||||
|
<div v-for="(question, index) in form.questions" :key="index" class="mb-4">
|
||||||
|
<v-text-field
|
||||||
|
v-model="question.text"
|
||||||
|
:label="'Вопрос ' + (index + 1)"
|
||||||
|
outlined
|
||||||
|
></v-text-field>
|
||||||
|
<v-file-input
|
||||||
|
v-model="question.image"
|
||||||
|
accept="image/*"
|
||||||
|
label="Картинка для вопроса"
|
||||||
|
outlined
|
||||||
|
></v-file-input>
|
||||||
|
<v-select
|
||||||
|
v-model="question.type"
|
||||||
|
:items="questionTypes"
|
||||||
|
label="Тип ответа"
|
||||||
|
outlined
|
||||||
|
></v-select>
|
||||||
|
<v-btn color="error" icon @click="removeQuestion(index)">
|
||||||
|
<v-icon>mdi-delete</v-icon>
|
||||||
|
</v-btn>
|
||||||
|
</div>
|
||||||
|
<v-btn color="teal-darken-4" @click="addQuestion">Добавить вопрос</v-btn>
|
||||||
|
</v-card-text>
|
||||||
|
<v-card-actions>
|
||||||
|
<v-btn color="teal-darken-4" size="medium" @click="step -= 1">Назад</v-btn>
|
||||||
|
<v-btn color="teal-darken-4" size="medium" @click="step = 2">Далее</v-btn>
|
||||||
|
</v-card-actions>
|
||||||
|
</v-card>
|
||||||
|
</v-stepper-window-item>
|
||||||
|
|
||||||
|
<!-- Настройка ответов -->
|
||||||
|
<v-stepper-window-item step="3">
|
||||||
|
<v-card flat>
|
||||||
|
<v-card-title>
|
||||||
|
Настройка ответов
|
||||||
|
<v-select
|
||||||
|
v-model="currentQuestionIndex"
|
||||||
|
:items="form.questions.map((q, i) => ({ text: `Вопрос ${i + 1}: ${q.text || 'Без названия'}`, value: i }))"
|
||||||
|
class="ml-4"
|
||||||
|
dense
|
||||||
|
item-title="text"
|
||||||
|
item-value="value"
|
||||||
|
label="Выберите вопрос"
|
||||||
|
outlined
|
||||||
|
></v-select>
|
||||||
|
</v-card-title>
|
||||||
|
<v-card-text>
|
||||||
|
<div v-if="currentQuestion">
|
||||||
|
<div v-if="currentQuestion.type === 'Ввести вручную'">
|
||||||
|
<div
|
||||||
|
v-for="(answer, index) in currentQuestion.answers"
|
||||||
|
:key="index"
|
||||||
|
class="d-flex align-start mb-4"
|
||||||
|
>
|
||||||
|
<v-text-field
|
||||||
|
v-model="answer.text"
|
||||||
|
:label="'Ответ ' + (index + 1)"
|
||||||
|
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>
|
||||||
|
</div>
|
||||||
|
<div v-else>
|
||||||
|
<p>Выберите вопрос, чтобы добавить ответы.</p>
|
||||||
|
</div>
|
||||||
|
</v-card-text>
|
||||||
|
<v-card-actions>
|
||||||
|
<v-btn color="teal-darken-4" size="medium" @click="step -= 1">Назад</v-btn>
|
||||||
|
<v-btn color="teal-darken-4" size="medium" @click="step = 3">Далее</v-btn>
|
||||||
|
</v-card-actions>
|
||||||
|
</v-card>
|
||||||
|
</v-stepper-window-item>
|
||||||
|
|
||||||
|
<!-- Подтверждение -->
|
||||||
|
<v-stepper-window-item step="4">
|
||||||
|
<v-card flat>
|
||||||
|
<v-card-title>Подтверждение</v-card-title>
|
||||||
|
<v-card-text>
|
||||||
|
<p><strong>Название:</strong> {{ form.title }}</p>
|
||||||
|
<p><strong>Описание:</strong> {{ form.description }}</p>
|
||||||
|
<p><strong>Дата начала:</strong> {{ form.startDate.toLocaleDateString() }}</p>
|
||||||
|
<p><strong>Дата окончания:</strong> {{ form.endDate.toLocaleDateString() }}</p>
|
||||||
|
<p><strong>Вопросы:</strong></p>
|
||||||
|
<ul>
|
||||||
|
<li v-for="(question, index) in form.questions" :key="index" class="mb-4">
|
||||||
|
<p><strong>Вопрос {{ index + 1 }}:</strong> {{ question.text }} ({{ question.type }})</p>
|
||||||
|
<div v-if="question.type === 'Ввести вручную' && question.answers.length">
|
||||||
|
<p><strong>Варианты ответов:</strong></p>
|
||||||
|
<ul>
|
||||||
|
<li v-for="(answer, answerIndex) in question.answers" :key="answerIndex">
|
||||||
|
{{ answer.text }}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div v-if="question.type === 'Выбрать сотрудника' && question.selectedEmployees.length">
|
||||||
|
<p><strong>Выбранные сотрудники:</strong></p>
|
||||||
|
<ul>
|
||||||
|
<li
|
||||||
|
v-for="employeeId in question.selectedEmployees"
|
||||||
|
:key="employeeId"
|
||||||
|
>
|
||||||
|
{{ findEmployeeById(employeeId).fio }}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</v-card-text>
|
||||||
|
<v-card-actions>
|
||||||
|
<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-card>
|
||||||
|
</v-stepper-window-item>
|
||||||
|
|
||||||
|
</v-stepper-window>
|
||||||
|
</v-stepper>
|
||||||
|
</template>
|
||||||
|
</v-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {computed, ref} from "vue";
|
||||||
|
import {createVote} from "@/utils/axios-api";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
setup() {
|
||||||
|
const step = ref(0);
|
||||||
|
const isVoteCreated = ref(false);
|
||||||
|
const form = ref({
|
||||||
|
title: "",
|
||||||
|
description: "",
|
||||||
|
startDate: new Date(),
|
||||||
|
endDate: new Date(new Date().setDate(new Date().getDate() + 14)),
|
||||||
|
questions: [],
|
||||||
|
});
|
||||||
|
|
||||||
|
const currentQuestionIndex = ref(0);
|
||||||
|
const questionTypes = ["Ввести вручную", "Выбрать сотрудника"];
|
||||||
|
|
||||||
|
const groupedEmployees = [
|
||||||
|
{id: 1, fio: "Иван Иванов", department: "Отдел A"},
|
||||||
|
{id: 2, fio: "Петр Петров", department: "Отдел B"},
|
||||||
|
];
|
||||||
|
|
||||||
|
const currentQuestion = computed(() =>
|
||||||
|
form.value.questions[currentQuestionIndex.value] || null
|
||||||
|
);
|
||||||
|
|
||||||
|
const findEmployeeById = (id) =>
|
||||||
|
groupedEmployees.find((employee) => employee.id === id) || {};
|
||||||
|
|
||||||
|
const removeEmployee = (index) => {
|
||||||
|
currentQuestion.value.selectedEmployees.splice(index, 1);
|
||||||
|
};
|
||||||
|
|
||||||
|
const addQuestion = () => {
|
||||||
|
form.value.questions.push({
|
||||||
|
text: "",
|
||||||
|
type: "Ввести вручную",
|
||||||
|
image: null,
|
||||||
|
answers: [],
|
||||||
|
selectedEmployees: [],
|
||||||
|
selectedEmployeeImages: {},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const removeQuestion = (index) => {
|
||||||
|
form.value.questions.splice(index, 1);
|
||||||
|
if (currentQuestionIndex.value >= form.value.questions.length) {
|
||||||
|
currentQuestionIndex.value = form.value.questions.length - 1;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const addAnswer = () => {
|
||||||
|
if (currentQuestion.value) {
|
||||||
|
currentQuestion.value.answers.push({text: "", image: null});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const removeAnswer = (index) => {
|
||||||
|
if (currentQuestion.value) {
|
||||||
|
currentQuestion.value.answers.splice(index, 1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const saveVoting = async () => {
|
||||||
|
try {
|
||||||
|
const response = await createVote(form.value);
|
||||||
|
console.log("Голосование успешно создано:", response);
|
||||||
|
isVoteCreated.value = true;
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Ошибка при создании голосования:", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const resetForm = () => {
|
||||||
|
form.value = {
|
||||||
|
title: "",
|
||||||
|
description: "",
|
||||||
|
startDate: new Date(),
|
||||||
|
endDate: new Date(new Date().setDate(new Date().getDate() + 14)),
|
||||||
|
questions: [],
|
||||||
|
};
|
||||||
|
step.value = 0;
|
||||||
|
isVoteCreated.value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
step,
|
||||||
|
form,
|
||||||
|
questionTypes,
|
||||||
|
groupedEmployees,
|
||||||
|
currentQuestionIndex,
|
||||||
|
currentQuestion,
|
||||||
|
addQuestion,
|
||||||
|
removeQuestion,
|
||||||
|
addAnswer,
|
||||||
|
removeAnswer,
|
||||||
|
findEmployeeById,
|
||||||
|
removeEmployee,
|
||||||
|
saveVoting,
|
||||||
|
isVoteCreated,
|
||||||
|
resetForm
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
@@ -1,19 +1,18 @@
|
|||||||
<template>
|
<template>
|
||||||
|
|
||||||
<v-form @submit="voteSend" ref="vot" >
|
<v-form ref="vot" @submit="voteSend">
|
||||||
<v-card id="scroll-window-chekbox" :height="heightel" elevation="0">
|
<v-card id="scroll-window-chekbox" :height="heightel" elevation="0">
|
||||||
<!-- Форма голосования -->
|
<!-- Форма голосования -->
|
||||||
|
|
||||||
<v-virtual-scroll :items="persons">
|
<v-virtual-scroll :items="persons">
|
||||||
<template v-slot:default="{ item }">
|
<template v-slot:default="{ item }">
|
||||||
<v-checkbox hide-details="true" v-model="vote" :id="item.fio" :value="item.fio" :label="item.fio" required />
|
<v-checkbox :id="item.fio" v-model="vote" :label="item.fio" :value="item.fio" hide-details="true" required/>
|
||||||
</template>
|
</template>
|
||||||
</v-virtual-scroll>
|
</v-virtual-scroll>
|
||||||
</v-card>
|
</v-card>
|
||||||
|
|
||||||
<v-dialog max-width="500" v-model="dialog">
|
<v-dialog v-model="dialog" max-width="500">
|
||||||
<!-- <template v-slot:activator>
|
<!-- <template v-slot:activator>
|
||||||
|
|
||||||
</template> -->
|
</template> -->
|
||||||
<template v-slot:default>
|
<template v-slot:default>
|
||||||
<v-card class="justify-center align-center">
|
<v-card class="justify-center align-center">
|
||||||
@@ -24,14 +23,17 @@
|
|||||||
<v-card-title v-else>Кандидат не выбран повторите голосование</v-card-title>
|
<v-card-title v-else>Кандидат не выбран повторите голосование</v-card-title>
|
||||||
<v-col class="d-flex flex-rows justify-center align-center" cols="12">
|
<v-col class="d-flex flex-rows justify-center align-center" cols="12">
|
||||||
<v-col cols="2">
|
<v-col cols="2">
|
||||||
<v-btn v-if="approve_name" variant="elevated" color="green-darken-1"
|
<v-btn v-if="approve_name" color="green-darken-1" variant="elevated"
|
||||||
@click="voteSend">ДА</v-btn>
|
@click="voteSend">ДА
|
||||||
<v-btn v-else variant="elevated" color="green-darken-1" @click="voteSend"
|
</v-btn>
|
||||||
disabled>ДА</v-btn>
|
<v-btn v-else color="green-darken-1" disabled variant="elevated"
|
||||||
|
@click="voteSend">ДА
|
||||||
|
</v-btn>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col cols="2">
|
<v-col cols="2">
|
||||||
<v-btn variant="elevated" color="red-darken-1"
|
<v-btn color="red-darken-1" variant="elevated"
|
||||||
@click="dialog = false">НЕТ</v-btn>
|
@click="dialog = false">НЕТ
|
||||||
|
</v-btn>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-card>
|
</v-card>
|
||||||
@@ -42,21 +44,22 @@
|
|||||||
|
|
||||||
</template>
|
</template>
|
||||||
<script scope>
|
<script scope>
|
||||||
import { ref, computed } from "vue";
|
import {computed, ref} from "vue";
|
||||||
import { clearAxios, axiosApiInstance } from "@/utils/axios-api";
|
import {axiosApiInstance} from "@/utils/axios-api";
|
||||||
import {useAccountStore} from '@/store/AccountStore';
|
import {useAccountStore} from '@/store/AccountStore';
|
||||||
import Vote from "@/views/Vote.vue";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
||||||
props: {type_fetch:{type:String, default:'best'},
|
props: {
|
||||||
|
type_fetch: {type: String, default: 'best'},
|
||||||
persons: {
|
persons: {
|
||||||
type: Array,
|
type: Array,
|
||||||
default: () => []
|
default: () => []
|
||||||
},
|
},
|
||||||
myrealdep: {
|
myrealdep: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default:()=>{}
|
default: () => {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setup(props, {emit}) {
|
setup(props, {emit}) {
|
||||||
@@ -87,7 +90,6 @@ export default {
|
|||||||
// };
|
// };
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const approveCandidate = () => {
|
const approveCandidate = () => {
|
||||||
if (vote.value === 'False' || vote.value === '') {
|
if (vote.value === 'False' || vote.value === '') {
|
||||||
approve_name.value = false;
|
approve_name.value = false;
|
||||||
@@ -112,8 +114,7 @@ export default {
|
|||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
).then(res=>
|
).then(res => {
|
||||||
{
|
|
||||||
dialog.value = false
|
dialog.value = false
|
||||||
window.location.reload()
|
window.location.reload()
|
||||||
});
|
});
|
||||||
@@ -137,8 +138,6 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
@@ -140,14 +140,14 @@ const routes = [
|
|||||||
ico: "mdi-account",
|
ico: "mdi-account",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
// {
|
||||||
|
// path: "/vote",
|
||||||
|
// name: "Vote",
|
||||||
|
// component: () =>
|
||||||
|
// import("@/views/Vote.vue")
|
||||||
|
// },
|
||||||
{
|
{
|
||||||
path: "/vote",
|
path: "/vote",
|
||||||
name: "Vote",
|
|
||||||
component: () =>
|
|
||||||
import("@/views/Vote.vue")
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: "/votehomepage",
|
|
||||||
name: "VoteHomePage",
|
name: "VoteHomePage",
|
||||||
component: () =>
|
component: () =>
|
||||||
import("@/views/VoteHomePage.vue")
|
import("@/views/VoteHomePage.vue")
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
export const votingData = {
|
||||||
|
description: "Описание первой голосовалки",
|
||||||
|
endDate: "2025-01-27T10:43:04+03:00",
|
||||||
|
questions: [
|
||||||
|
{
|
||||||
|
answers: [
|
||||||
|
{
|
||||||
|
text: "аыфавы",
|
||||||
|
image: null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: "оаок5е",
|
||||||
|
image: null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
image: {
|
||||||
|
name: "ed777ac1e74742aa118f59d72e231763d08ac93fv2_hq.jpg",
|
||||||
|
size: 11530
|
||||||
|
},
|
||||||
|
selectedEmployeeImages: {},
|
||||||
|
selectedEmployees: [],
|
||||||
|
text: "Опрос1",
|
||||||
|
type: "Ввести вручную"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
answers: [],
|
||||||
|
image: {
|
||||||
|
name: "ed777ac1e74742aa118f59d72e231763d08ac93fv2_hq.jpg",
|
||||||
|
size: 11530
|
||||||
|
},
|
||||||
|
selectedEmployeeImages: {},
|
||||||
|
selectedEmployees: [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
name: "Сотрудник 1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
name: "Сотрудник 2"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
text: "Опрос2",
|
||||||
|
type: "Выбрать сотрудника"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
startDate: "2025-01-13T10:43:04+03:00",
|
||||||
|
title: "Заголовок голосовалки"
|
||||||
|
}
|
||||||
@@ -90,13 +90,7 @@ async error => {
|
|||||||
|
|
||||||
async function getVotes(status) {
|
async function getVotes(status) {
|
||||||
try {
|
try {
|
||||||
const response = await axiosApiInstance.get(`/api/vote/getvotes?status=${status}`,
|
const response = await axiosApiInstance.get(`/api/vote/getvotes?status=${status}/`);
|
||||||
// {
|
|
||||||
// params: {
|
|
||||||
// status,
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
);
|
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Ошибка запроса голосования:', error);
|
console.error('Ошибка запроса голосования:', error);
|
||||||
@@ -120,6 +114,33 @@ getVotes('active')
|
|||||||
console.error('Ошибка:', err);
|
console.error('Ошибка:', err);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
async function createVote(voteData, files) {
|
||||||
|
try {
|
||||||
|
const formData = new FormData();
|
||||||
|
|
||||||
|
formData.append('title', voteData.title);
|
||||||
|
formData.append('description', voteData.description);
|
||||||
|
formData.append('startDate', new Date(voteData.startDate).toISOString());
|
||||||
|
formData.append('endDate', new Date(voteData.endDate).toISOString());
|
||||||
|
formData.append('questions', voteData.questions);
|
||||||
|
|
||||||
export { axiosApiInstance, clearAxios, baseURL,spravURL, spravURLBase, baseWS, getVotes }
|
const response = await axiosApiInstance.post('/api/vote/votecreate/', formData, {
|
||||||
|
headers: { 'Content-Type': 'multipart/form-data' },
|
||||||
|
});
|
||||||
|
|
||||||
|
getVotes('active')
|
||||||
|
.then(data => {
|
||||||
|
console.log('Активные голосования:', data);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.error('Ошибка:', err);
|
||||||
|
});
|
||||||
|
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Ошибка создания голосования:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export { axiosApiInstance, clearAxios, baseURL,spravURL, spravURLBase, baseWS, getVotes, createVote }
|
||||||
@@ -1,325 +0,0 @@
|
|||||||
<template>
|
|
||||||
<v-container>
|
|
||||||
<v-stepper v-model="step" editable>
|
|
||||||
<v-stepper-header>
|
|
||||||
<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-divider></v-divider>
|
|
||||||
<v-stepper-item step="4">Подтверждение</v-stepper-item>
|
|
||||||
</v-stepper-header>
|
|
||||||
|
|
||||||
<v-stepper-window>
|
|
||||||
<!-- Основная информация -->
|
|
||||||
<v-stepper-window-item step="1">
|
|
||||||
<v-card flat>
|
|
||||||
<v-card-title>Основная информация</v-card-title>
|
|
||||||
<v-card-text>
|
|
||||||
<v-text-field v-model="form.title" label="Название голосования" outlined></v-text-field>
|
|
||||||
<v-textarea v-model="form.description" label="Описание" outlined></v-textarea>
|
|
||||||
<v-text-field
|
|
||||||
:placeholder="form.startDate.toLocaleDateString()"
|
|
||||||
:value="form.startDate.toLocaleDateString()"
|
|
||||||
color="teal-darken-4"
|
|
||||||
label="Дата начала"
|
|
||||||
persistentPlaceholder
|
|
||||||
readonly
|
|
||||||
>
|
|
||||||
<v-menu activator="parent">
|
|
||||||
<v-date-picker
|
|
||||||
v-model="form.startDate"
|
|
||||||
color="teal-darken-4"
|
|
||||||
hideHeader
|
|
||||||
hideWeekdays
|
|
||||||
>
|
|
||||||
</v-date-picker>
|
|
||||||
</v-menu>
|
|
||||||
<v-btn flat icon style="background-color: transparent">
|
|
||||||
<v-icon>mdi-calendar</v-icon>
|
|
||||||
</v-btn>
|
|
||||||
</v-text-field>
|
|
||||||
|
|
||||||
<v-text-field
|
|
||||||
:placeholder="form.endDate.toLocaleDateString()"
|
|
||||||
:value="form.endDate.toLocaleDateString()"
|
|
||||||
color="teal-darken-4"
|
|
||||||
label="Дата окончания"
|
|
||||||
persistentPlaceholder
|
|
||||||
readonly
|
|
||||||
>
|
|
||||||
<v-menu activator="parent">
|
|
||||||
<v-date-picker
|
|
||||||
v-model="form.endDate"
|
|
||||||
color="teal-darken-4"
|
|
||||||
hideHeader
|
|
||||||
hideWeekdays
|
|
||||||
>
|
|
||||||
</v-date-picker>
|
|
||||||
</v-menu>
|
|
||||||
<v-btn flat icon style="background-color: transparent">
|
|
||||||
<v-icon>mdi-calendar</v-icon>
|
|
||||||
</v-btn>
|
|
||||||
</v-text-field>
|
|
||||||
</v-card-text>
|
|
||||||
<v-card-actions>
|
|
||||||
<v-btn color="teal-darken-4" @click="step = 1" size="medium">Далее</v-btn>
|
|
||||||
</v-card-actions>
|
|
||||||
</v-card>
|
|
||||||
</v-stepper-window-item>
|
|
||||||
|
|
||||||
<!-- Создание опроса -->
|
|
||||||
<v-stepper-window-item step="2">
|
|
||||||
<v-card flat>
|
|
||||||
<v-card-title>Создание опроса</v-card-title>
|
|
||||||
<v-card-text>
|
|
||||||
<div v-for="(question, index) in form.questions" :key="index" class="mb-4">
|
|
||||||
<v-text-field
|
|
||||||
v-model="question.text"
|
|
||||||
:label="'Вопрос ' + (index + 1)"
|
|
||||||
outlined
|
|
||||||
></v-text-field>
|
|
||||||
<v-file-input
|
|
||||||
v-model="question.image"
|
|
||||||
accept="image/*"
|
|
||||||
label="Картинка для вопроса"
|
|
||||||
outlined
|
|
||||||
></v-file-input>
|
|
||||||
<v-select
|
|
||||||
v-model="question.type"
|
|
||||||
:items="questionTypes"
|
|
||||||
label="Тип ответа"
|
|
||||||
outlined
|
|
||||||
></v-select>
|
|
||||||
<v-btn color="error" icon @click="removeQuestion(index)">
|
|
||||||
<v-icon>mdi-delete</v-icon>
|
|
||||||
</v-btn>
|
|
||||||
</div>
|
|
||||||
<v-btn color="teal-darken-4" @click="addQuestion">Добавить вопрос</v-btn>
|
|
||||||
</v-card-text>
|
|
||||||
<v-card-actions>
|
|
||||||
<v-btn color="teal-darken-4" size="medium" @click="step -= 1">Назад</v-btn>
|
|
||||||
<v-btn color="teal-darken-4" size="medium" @click="step = 2">Далее</v-btn>
|
|
||||||
</v-card-actions>
|
|
||||||
</v-card>
|
|
||||||
</v-stepper-window-item>
|
|
||||||
|
|
||||||
<!-- Настройка ответов -->
|
|
||||||
<v-stepper-window-item step="3">
|
|
||||||
<v-card flat>
|
|
||||||
<v-card-title>
|
|
||||||
Настройка ответов
|
|
||||||
<v-select
|
|
||||||
v-model="currentQuestionIndex"
|
|
||||||
:items="form.questions.map((q, i) => ({ text: `Вопрос ${i + 1}: ${q.text || 'Без названия'}`, value: i }))"
|
|
||||||
class="ml-4"
|
|
||||||
dense
|
|
||||||
item-title="text"
|
|
||||||
item-value="value"
|
|
||||||
label="Выберите вопрос"
|
|
||||||
outlined
|
|
||||||
></v-select>
|
|
||||||
</v-card-title>
|
|
||||||
<v-card-text>
|
|
||||||
<div v-if="currentQuestion">
|
|
||||||
<div v-if="currentQuestion.type === 'Ввести вручную'">
|
|
||||||
<div
|
|
||||||
v-for="(answer, index) in currentQuestion.answers"
|
|
||||||
:key="index"
|
|
||||||
class="d-flex align-start mb-4"
|
|
||||||
>
|
|
||||||
<v-text-field
|
|
||||||
v-model="answer.text"
|
|
||||||
:label="'Ответ ' + (index + 1)"
|
|
||||||
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="primary" @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>
|
|
||||||
</div>
|
|
||||||
<div v-else>
|
|
||||||
<p>Выберите вопрос, чтобы добавить ответы.</p>
|
|
||||||
</div>
|
|
||||||
</v-card-text>
|
|
||||||
<v-card-actions>
|
|
||||||
<v-btn color="teal-darken-4" size="medium" @click="step -= 1">Назад</v-btn>
|
|
||||||
<v-btn color="teal-darken-4" size="medium" @click="step = 3">Далее</v-btn>
|
|
||||||
</v-card-actions>
|
|
||||||
</v-card>
|
|
||||||
</v-stepper-window-item>
|
|
||||||
|
|
||||||
<!-- Подтверждение -->
|
|
||||||
<v-stepper-window-item step="4">
|
|
||||||
<v-card flat>
|
|
||||||
<v-card-title>Подтверждение</v-card-title>
|
|
||||||
<v-card-text>
|
|
||||||
<p><strong>Название:</strong> {{ form.title }}</p>
|
|
||||||
<p><strong>Описание:</strong> {{ form.description }}</p>
|
|
||||||
<p><strong>Дата начала:</strong> {{ form.startDate.toLocaleDateString() }}</p>
|
|
||||||
<p><strong>Дата окончания:</strong> {{ form.endDate.toLocaleDateString() }}</p>
|
|
||||||
<p><strong>Вопросы:</strong></p>
|
|
||||||
<ul>
|
|
||||||
<li v-for="(question, index) in form.questions" :key="index" class="mb-4">
|
|
||||||
<p><strong>Вопрос {{ index + 1 }}:</strong> {{ question.text }} ({{ question.type }})</p>
|
|
||||||
<div v-if="question.type === 'Ввести вручную' && question.answers.length">
|
|
||||||
<p><strong>Варианты ответов:</strong></p>
|
|
||||||
<ul>
|
|
||||||
<li v-for="(answer, answerIndex) in question.answers" :key="answerIndex">
|
|
||||||
{{ answer.text }}
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div v-if="question.type === 'Выбрать сотрудника' && question.selectedEmployees.length">
|
|
||||||
<p><strong>Выбранные сотрудники:</strong></p>
|
|
||||||
<ul>
|
|
||||||
<li
|
|
||||||
v-for="employeeId in question.selectedEmployees"
|
|
||||||
:key="employeeId"
|
|
||||||
>
|
|
||||||
{{ findEmployeeById(employeeId).fio }}
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</v-card-text>
|
|
||||||
<v-card-actions>
|
|
||||||
<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-card>
|
|
||||||
</v-stepper-window-item>
|
|
||||||
|
|
||||||
</v-stepper-window>
|
|
||||||
</v-stepper>
|
|
||||||
</v-container>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import {computed, ref} from "vue";
|
|
||||||
|
|
||||||
export default {
|
|
||||||
setup() {
|
|
||||||
const step = ref(0);
|
|
||||||
const form = ref({
|
|
||||||
title: "",
|
|
||||||
description: "",
|
|
||||||
startDate: new Date(),
|
|
||||||
endDate: new Date(new Date().setDate(new Date().getDate() + 14)),
|
|
||||||
questions: [],
|
|
||||||
});
|
|
||||||
|
|
||||||
const currentQuestionIndex = ref(0);
|
|
||||||
const questionTypes = ["Ввести вручную", "Выбрать сотрудника"];
|
|
||||||
|
|
||||||
const groupedEmployees = [
|
|
||||||
{id: 1, fio: "Иван Иванов", department: "Отдел A"},
|
|
||||||
{id: 2, fio: "Петр Петров", department: "Отдел B"},
|
|
||||||
];
|
|
||||||
|
|
||||||
const currentQuestion = computed(() =>
|
|
||||||
form.value.questions[currentQuestionIndex.value] || null
|
|
||||||
);
|
|
||||||
|
|
||||||
const findEmployeeById = (id) =>
|
|
||||||
groupedEmployees.find((employee) => employee.id === id) || {};
|
|
||||||
|
|
||||||
const removeEmployee = (index) => {
|
|
||||||
currentQuestion.value.selectedEmployees.splice(index, 1);
|
|
||||||
};
|
|
||||||
|
|
||||||
const addQuestion = () => {
|
|
||||||
form.value.questions.push({
|
|
||||||
text: "",
|
|
||||||
type: "Ввести вручную",
|
|
||||||
image: null,
|
|
||||||
answers: [],
|
|
||||||
selectedEmployees: [],
|
|
||||||
selectedEmployeeImages: {},
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const removeQuestion = (index) => {
|
|
||||||
form.value.questions.splice(index, 1);
|
|
||||||
if (currentQuestionIndex.value >= form.value.questions.length) {
|
|
||||||
currentQuestionIndex.value = form.value.questions.length - 1;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const addAnswer = () => {
|
|
||||||
if (currentQuestion.value) {
|
|
||||||
currentQuestion.value.answers.push({text: "", image: null});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const removeAnswer = (index) => {
|
|
||||||
if (currentQuestion.value) {
|
|
||||||
currentQuestion.value.answers.splice(index, 1);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const saveVoting = () => {
|
|
||||||
console.log("Голосование сохранено:", form.value);
|
|
||||||
};
|
|
||||||
|
|
||||||
return {
|
|
||||||
step,
|
|
||||||
form,
|
|
||||||
questionTypes,
|
|
||||||
groupedEmployees,
|
|
||||||
currentQuestionIndex,
|
|
||||||
currentQuestion,
|
|
||||||
addQuestion,
|
|
||||||
removeQuestion,
|
|
||||||
addAnswer,
|
|
||||||
removeAnswer,
|
|
||||||
findEmployeeById,
|
|
||||||
removeEmployee,
|
|
||||||
saveVoting,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
>
|
>
|
||||||
<v-card :class="{ 'voted-card': voting.voted }">
|
<v-card :class="{ 'voted-card': voting.voted }">
|
||||||
<v-card-title class="d-flex justify-space-between">{{ voting.title }}
|
<v-card-title class="d-flex justify-space-between">{{ voting.title }}
|
||||||
<v-btn flat size="medium">
|
<v-btn flat size="medium" @click="openEditVoteModal(voting)">
|
||||||
<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-title>
|
</v-card-title>
|
||||||
@@ -43,8 +43,8 @@
|
|||||||
>
|
>
|
||||||
Проголосовать
|
Проголосовать
|
||||||
</v-btn>
|
</v-btn>
|
||||||
<v-btn v-else color="teal-darken-4" disabled size="medium">Уже проголосовали</v-btn>
|
<v-btn v-else color="teal-darken-4" disabled size="medium">Проголосовали</v-btn>
|
||||||
<v-btn color="error" @click="deleteVoting(voting.id)" size="medium">
|
<v-btn color="error" size="medium" @click="deleteVoting(voting.id)">
|
||||||
<v-icon>mdi-delete</v-icon>
|
<v-icon>mdi-delete</v-icon>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
@@ -89,21 +89,43 @@
|
|||||||
</v-tabs-window>
|
</v-tabs-window>
|
||||||
|
|
||||||
<!-- Модальное окно для голосования -->
|
<!-- Модальное окно для голосования -->
|
||||||
<v-dialog v-model="voteModal" max-width="600px">
|
<v-dialog v-model="voteModal" max-width="1200px">
|
||||||
|
<v-card>
|
||||||
|
<v-card-actions>
|
||||||
|
<!--<v-btn color="teal-darken-4" @click="submitVote">Проголосовать</v-btn>-->
|
||||||
|
<v-btn color="red-darken-1" size="medium" @click="closeVoteModal">
|
||||||
|
<v-icon>mdi-close-thick</v-icon>
|
||||||
|
</v-btn>
|
||||||
|
</v-card-actions>
|
||||||
|
<v-card-text class="pt-0">
|
||||||
|
<CurrentVote
|
||||||
|
:description="votingData.description"
|
||||||
|
:endDate="votingData.endDate"
|
||||||
|
:questions="votingData.questions"
|
||||||
|
:startDate="votingData.startDate"
|
||||||
|
:title="votingData.title"
|
||||||
|
/>
|
||||||
|
</v-card-text>
|
||||||
|
</v-card>
|
||||||
|
</v-dialog>
|
||||||
|
|
||||||
|
<!-- Модальное окно для редактирования -->
|
||||||
|
<v-dialog v-model="editVoteModal" max-width="1200px">
|
||||||
<v-card>
|
<v-card>
|
||||||
<v-card-title>Голосование: {{ selectedVoting?.title }}</v-card-title>
|
<v-card-title>Голосование: {{ selectedVoting?.title }}</v-card-title>
|
||||||
<v-card-text>
|
<v-card-text>
|
||||||
<p>Описание голосования...</p>
|
<!-- <p>Редактирование голосования...</p> -->
|
||||||
|
<VoteConstructor/>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
<v-card-actions>
|
<v-card-actions>
|
||||||
<v-btn color="primary" @click="submitVote">Проголосовать</v-btn>
|
<v-btn color="teal-darken-4">Сохранить</v-btn>
|
||||||
<v-btn @click="closeVoteModal">Закрыть</v-btn>
|
<v-btn @click="closeEditVoteModal">Закрыть</v-btn>
|
||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
</v-card>
|
</v-card>
|
||||||
</v-dialog>
|
</v-dialog>
|
||||||
|
|
||||||
<!-- Модальное окно для результатов -->
|
<!-- Модальное окно для результатов -->
|
||||||
<v-dialog v-model="resultsModal" max-width="600px">
|
<v-dialog v-model="resultsModal" max-width="1200px">
|
||||||
<v-card>
|
<v-card>
|
||||||
<v-card-title>Результаты голосования: {{ selectedVoting?.title }}</v-card-title>
|
<v-card-title>Результаты голосования: {{ selectedVoting?.title }}</v-card-title>
|
||||||
<v-card-text>
|
<v-card-text>
|
||||||
@@ -119,10 +141,17 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {computed, ref} from "vue";
|
import {computed, ref} from "vue";
|
||||||
import VoteConstructor from "@/views/VoteConstructor.vue";
|
import VoteConstructor from "@/components/vote/VoteConstructor.vue";
|
||||||
|
import CurrentVote from "@/components/vote/CurrentVote.vue";
|
||||||
|
import {votingData} from '@/test/testDataForVote'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {VoteConstructor},
|
computed: {
|
||||||
|
votingData() {
|
||||||
|
return votingData
|
||||||
|
}
|
||||||
|
},
|
||||||
|
components: {CurrentVote, VoteConstructor},
|
||||||
setup() {
|
setup() {
|
||||||
const currentTab = ref("current");
|
const currentTab = ref("current");
|
||||||
const votes = ref([
|
const votes = ref([
|
||||||
@@ -147,6 +176,7 @@ export default {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
const voteModal = ref(false);
|
const voteModal = ref(false);
|
||||||
|
const editVoteModal = ref(false);
|
||||||
const resultsModal = ref(false);
|
const resultsModal = ref(false);
|
||||||
const selectedVoting = ref(null);
|
const selectedVoting = ref(null);
|
||||||
|
|
||||||
@@ -180,6 +210,16 @@ export default {
|
|||||||
selectedVoting.value = null;
|
selectedVoting.value = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const openEditVoteModal = (voting) => {
|
||||||
|
selectedVoting.value = voting;
|
||||||
|
editVoteModal.value = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
const closeEditVoteModal = () => {
|
||||||
|
editVoteModal.value = false;
|
||||||
|
selectedVoting.value = null;
|
||||||
|
};
|
||||||
|
|
||||||
const submitVote = () => {
|
const submitVote = () => {
|
||||||
selectedVoting.value.voted = true;
|
selectedVoting.value.voted = true;
|
||||||
closeVoteModal();
|
closeVoteModal();
|
||||||
@@ -215,6 +255,9 @@ export default {
|
|||||||
openResultsModal,
|
openResultsModal,
|
||||||
closeResultsModal,
|
closeResultsModal,
|
||||||
deleteVoting,
|
deleteVoting,
|
||||||
|
editVoteModal,
|
||||||
|
openEditVoteModal,
|
||||||
|
closeEditVoteModal,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user