Merge branch 'dev-denzel' into develop

This commit is contained in:
Nukeap committed 2025-01-15 12:38:31 +03:00
commit 07b2140e7d
3 files changed
+230 -198

No files matched your search

+110 -108
View File
@@ -14,9 +14,7 @@
<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-item :complete="step > 2" step="3">Подтверждение</v-stepper-item>
</v-stepper-header>
<v-stepper-window>
@@ -37,11 +35,12 @@
outlined
:rules="[rules.required]"
></v-textarea>
<v-text-field
:placeholder="form.startDate.toLocaleDateString()"
:value="form.startDate.toLocaleDateString()"
: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="Дата начала"
label="Дата и время начала"
persistentPlaceholder
readonly
>
@@ -51,19 +50,18 @@
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-icon>mdi-calendar-clock</v-icon>
</v-btn>
</v-text-field>
<v-text-field
:placeholder="form.endDate.toLocaleDateString()"
:value="form.endDate.toLocaleDateString()"
: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="Дата окончания"
label="Дата и время окончания"
persistentPlaceholder
readonly
>
@@ -73,13 +71,13 @@
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-icon>mdi-calendar-clock</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>
@@ -93,12 +91,17 @@
<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
<div class="d-flex">
<v-text-field
v-model="question.text"
:label="'Вопрос ' + (index + 1)"
outlined
:rules="[rules.required]"
></v-text-field>
></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/*"
@@ -111,9 +114,73 @@
label="Тип ответа"
outlined
></v-select>
<v-btn color="error" icon @click="removeQuestion(index)">
<v-icon>mdi-delete</v-icon>
</v-btn>
<v-switch
v-model="question.multiChoice"
color="teal-darken-4"
:label="`Множественный выбор: ${question.multiChoice ? 'да' : 'нет'}`"
:false-value="false"
:true-value="true"
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>
</div>
<v-btn color="teal-darken-4" @click="addQuestion">Добавить вопрос</v-btn>
</v-card-text>
@@ -124,95 +191,8 @@
</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
: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>
</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-stepper-window-item step="3">
<v-card flat>
<v-card-title>Подтверждение</v-card-title>
<v-card-text>
@@ -310,6 +290,7 @@ export default {
answers: [],
selectedEmployees: [],
selectedEmployeeImages: {},
multiChoice: false
});
};
@@ -383,3 +364,24 @@ export default {
},
};
</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;
}
}
</style>
+1
View File
@@ -118,6 +118,7 @@ async function createVote(voteData, files) {
formData.append('startDate', new Date(voteData.startDate).toISOString());
formData.append('endDate', new Date(voteData.endDate).toISOString());
formData.append('questions', JSON.stringify(voteData.questions));
formData.append('settings', {...voteData.type});
const response = await axiosApiInstance.post('/api/vote/votecreate/', formData, {
headers: {'Content-Type': 'multipart/form-data'},
+119 -90
View File
@@ -2,27 +2,33 @@
<v-container>
<v-toolbar color="transparent">
<v-toolbar-title>Голосования</v-toolbar-title>
<template v-slot:extension>
<v-tabs v-model="currentTab">
<v-tab :key="0" value="active">Текущие голосования</v-tab>
<v-tab :key="1" value="completed">Завершенные голосования</v-tab>
<v-tab :key="2" value="constructor">Создать новое голосование</v-tab>
<v-tab value="current">Текущие голосования</v-tab>
<v-tab value="completed">Завершенные голосования</v-tab>
<v-tab value="constructor">Создать новое голосование</v-tab>
</v-tabs>
</template>
</v-toolbar>
<v-tabs-window v-model="currentTab">
<!-- Текущие голосования -->
<v-tabs-window-item value="active">
<v-tabs-window-item value="current">
<v-container>
<v-row>
<v-col v-for="voting in votes" :key="voting.id" cols="12" xl="3" lg="4" md="6">
<VoteCardVue
<v-col
v-for="voting in sortedCurrentVotes"
:key="voting.id"
cols="12"
lg="3"
md="4"
>
<VoteCardVue
:voteCard="voting"
@openVoteModal="openVoteModal"
@openEditVoteModal="openEditVoteModal"
@deleteVoting="deleteVoting" />
@openVoteModal="(voting) => openModal('vote', voting)"
@openEditVoteModal="(voting) => openModal('edit', voting)"
@deleteVoting="deleteVoting"
/>
</v-col>
</v-row>
</v-container>
@@ -32,14 +38,21 @@
<v-tabs-window-item value="completed">
<v-container>
<v-row>
<v-col v-for="voting in votes" :key="voting.id" cols="12" lg="3" md="4">
<v-col
v-for="voting in sortedCompletedVotes"
:key="voting.id"
cols="12"
lg="3"
md="4"
:class="{ 'voted-card': voting.voted }"
>
<v-card>
<v-card-title>{{ voting.title }}</v-card-title>
<v-card-subtitle>
Завершено: {{ formatDate(voting.endDate) }}
</v-card-subtitle>
<v-card-actions class="justify-space-between">
<v-btn color="teal-darken-4" size="medium" @click="openResultsModal(voting)">
<v-btn color="teal-darken-4" size="medium" @click="(voting) => openModal('results', voting)">
Результаты
</v-btn>
<v-btn color="error" size="medium" @click="deleteVoting(voting.id)">
@@ -58,46 +71,41 @@
</v-tabs-window-item>
</v-tabs-window>
<!-- Модальное окно для голосования -->
<v-dialog v-model="voteModal" max-width="1200px">
<!-- Модальные окна -->
<v-dialog v-model="voteModal" max-width="1200px" @click:outside="closeModal">
<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-btn color="red-darken-1" size="medium" @click="closeModal">
<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" />
<CurrentVote :data="res" />
</v-card-text>
</v-card>
</v-dialog>
<!-- Модальное окно для редактирования -->
<v-dialog v-model="editVoteModal" max-width="1200px">
{{res}}
<v-dialog v-model="editVoteModal" max-width="1200px" @click:outside="closeModal">
<v-card>
<v-card-title>Голосование: {{ selectedVoting?.title }}</v-card-title>
<v-card-title>Редактировать голосование: {{ selectedVoting?.title }}</v-card-title>
<v-card-text>
<!-- <p>Редактирование голосования...</p> -->
<VoteConstructor />
</v-card-text>
<v-card-actions>
<v-btn color="teal-darken-4">Сохранить</v-btn>
<v-btn @click="closeEditVoteModal">Закрыть</v-btn>
<v-btn @click="closeModal">Закрыть</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<!-- Модальное окно для результатов -->
<v-dialog v-model="resultsModal" max-width="1200px">
<v-dialog v-model="resultsModal" max-width="1200px" @click:outside="closeModal">
<v-card>
<v-card-title>Результаты голосования: {{ selectedVoting?.title }}</v-card-title>
<v-card-text>
<p>Здесь отображаются результаты голосования...</p>
</v-card-text>
<v-card-actions>
<v-btn @click="closeResultsModal">Закрыть</v-btn>
<v-btn @click="closeModal">Закрыть</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
@@ -105,103 +113,124 @@
</template>
<script>
import { ref, watch } from "vue";
import { ref, computed, watch } from "vue";
import VoteConstructor from "@/components/vote/VoteConstructor.vue";
import CurrentVote from "@/components/vote/CurrentVote.vue";
import VoteCardVue from "@/components/vote/VoteCard.vue";
import { getVotes } from "@/utils/axios-api"
// import { votingData } from "@/test/testDataForVote"
import { useRoute, useRouter } from "vue-router";
import { deleteVote, getVoteDetail, getVotes } from "@/utils/axios-api";
import { formatDate } from "@vueuse/shared";
export default {
methods: { formatDate },
components: { CurrentVote, VoteConstructor, VoteCardVue },
setup() {
const currentTab = ref("active");
const votes = ref([])
const currentTab = ref("current");
const votes = ref([]);
const router = useRouter();
const route = useRoute();
const res = ref(null);
function updating(param) {
getVotes(param)
.then(data => {
console.log(data);
votes.value = data;
})
}
const updating = async (param) => {
const data = await getVotes(param);
votes.value = data;
};
updating('active')
watch(
() => currentTab.value,
(newValue) => {
if (newValue !== 'constructor') {
console.log(newValue);
updating(newValue)
}
}
);
updating("active");
const voteModal = ref(false);
const editVoteModal = ref(false);
const resultsModal = ref(false);
const selectedVoting = ref(null);
const formatDate = (date) => new Date(date).toLocaleString();
const sortedCurrentVotes = computed(() =>
votes.value
.filter((v) => new Date(v.dateend) > new Date())
.sort((a, b) => new Date(a.dateend) - new Date(b.dateend))
);
const openVoteModal = (voting) => {
selectedVoting.value = voting;
voteModal.value = true;
const sortedCompletedVotes = computed(() =>
votes.value
.filter((v) => new Date(v.dateend) <= new Date())
.sort((a, b) => new Date(b.dateend) - new Date(a.dateend))
);
const loadVoteDetails = async (id) => {
try {
const data = await getVoteDetail(id);
res.value = data;
} catch (error) {
console.error("Ошибка при загрузке данных голосования:", error);
res.value = null;
}
};
const closeVoteModal = () => {
const closeModal = () => {
voteModal.value = false;
selectedVoting.value = null;
};
const openEditVoteModal = (voting) => {
selectedVoting.value = voting;
editVoteModal.value = true;
};
const closeEditVoteModal = () => {
editVoteModal.value = false;
selectedVoting.value = null;
};
const submitVote = () => {
selectedVoting.value.voted = true;
closeVoteModal();
};
const openResultsModal = (voting) => {
selectedVoting.value = voting;
resultsModal.value = true;
};
const closeResultsModal = () => {
resultsModal.value = false;
selectedVoting.value = null;
router.push({ name: "VoteHomePage" });
};
const deleteVoting = (id) => {
votes.value = votes.value.filter((v) => v.id !== id);
const openModal = async (type, voting) => {
selectedVoting.value = voting;
if (type === "vote") {
await loadVoteDetails(voting.id);
voteModal.value = true;
router.push({ name: "Voting", params: { id: voting.id } });
} else if (type === "edit") {
editVoteModal.value = true;
router.push({ name: "EditVote", params: { id: voting.id } });
} else if (type === "results") {
resultsModal.value = true;
router.push({ name: "VoteResults", params: { id: voting.id } });
}
};
const deleteVoting = async (id) => {
try {
await deleteVote(id);
votes.value = votes.value.filter((v) => v.id !== id);
} catch (error) {
console.error("Ошибка при удалении голосования:", error);
}
};
watch(
() => route,
async () => {
if (!voteModal.value && !editVoteModal.value && !resultsModal.value) {
const voting = votes.value.find((v) => v.id === route.params.id);
if (route.name === "Voting") {
await loadVoteDetails(route.params.id);
voteModal.value = true;
}
if (route.name === "EditVote") editVoteModal.value = true;
if (route.name === "VoteResults") resultsModal.value = true;
selectedVoting.value = voting || null;
}
},
{ immediate: true }
);
updating("active");
return {
currentTab,
votes,
sortedCurrentVotes,
sortedCompletedVotes,
voteModal,
editVoteModal,
resultsModal,
selectedVoting,
formatDate,
openVoteModal,
closeVoteModal,
submitVote,
openResultsModal,
closeResultsModal,
openModal,
closeModal,
deleteVoting,
editVoteModal,
openEditVoteModal,
closeEditVoteModal,
updating,
res,
};
},
};