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