diff --git a/src/front/src/components/vote/CurrentVote.vue b/src/front/src/components/vote/CurrentVote.vue index 975f16248..85d5043d3 100644 --- a/src/front/src/components/vote/CurrentVote.vue +++ b/src/front/src/components/vote/CurrentVote.vue @@ -11,7 +11,7 @@ - + @@ -24,7 +24,7 @@ - @@ -35,22 +35,22 @@ - + {{ question.question }} - + - - + - + - + @@ -76,23 +76,23 @@ - - + + - + - + - + Назад - + Далее @@ -114,10 +114,10 @@ - + - + @@ -168,9 +168,10 @@ export default { const isVoteSubmitted = ref(false); const isCurrentQuestionAnswered = computed(() => { - let q = props.data.questions.find(e => e.numb == activeStep.value + 1) - return result.value[q.id].length > 0; + let q = props.data.questions.find(e => e.numb === activeStep.value + 1) + return q !== undefined ? result.value[q.id].length > 0 : false; }); + const getres = () => { return props.data.questions.reduce((acc, item) => { acc[item.id] = [] diff --git a/src/front/src/components/vote/VoteResult.vue b/src/front/src/components/vote/VoteResult.vue new file mode 100644 index 000000000..3fac1a4f5 --- /dev/null +++ b/src/front/src/components/vote/VoteResult.vue @@ -0,0 +1,67 @@ + + + + + + + Победитель: {{ winner.name }} + + Количество голосов: {{ winner.votes }} + + + + + + + + + Все результаты + + + + + {{ option.name }}: {{ option.votes }} голосов + + + + + + + + + + + + + diff --git a/src/front/src/utils/axios-api.js b/src/front/src/utils/axios-api.js index dbd1bc69d..7b2134441 100644 --- a/src/front/src/utils/axios-api.js +++ b/src/front/src/utils/axios-api.js @@ -93,11 +93,10 @@ async function getVotes(status) { } } - async function createVote(voteData) { try { - + const formData = new FormData(); voteData.questions.forEach(question => { formData.append('questionsfiles', question.image) @@ -106,9 +105,9 @@ async function createVote(voteData) { const {name,size,lastModified}=question.image question.image={name,size,lastModified} } - + question.answers.forEach(answer=>{ - + formData.append('answersfiles', answer.image) if(!!answer.image){ const {name,size,lastModified}=answer.image @@ -125,8 +124,8 @@ async function createVote(voteData) { formData.append('startDate', new Date(voteData.startDate).toISOString()); formData.append('endDate', new Date(voteData.endDate).toISOString()); formData.append('questions', JSON.stringify(voteData.questions)); - - + + const response = await axiosApiInstance.post('/api/vote/votecreate/', formData, { headers: {'Content-Type': 'multipart/form-data'}, }); @@ -188,9 +187,6 @@ async function getEmployees() { } } -getEmployees() - .then(r => console.log(r)) - export { axiosApiInstance, diff --git a/src/front/src/views/VoteHomePage.vue b/src/front/src/views/VoteHomePage.vue index fa53d614d..a7da61316 100644 --- a/src/front/src/views/VoteHomePage.vue +++ b/src/front/src/views/VoteHomePage.vue @@ -25,9 +25,9 @@ > openModal('vote', voting)" - @openEditVoteModal="(voting) => openModal('edit', voting)" @deleteVoting="deleteVoting" + @openEditVoteModal="(voting) => openModal('edit', voting)" + @openVoteModal="(voting) => openModal('vote', voting)" /> @@ -41,18 +41,18 @@ - {{ voting.title }} + {{ voting.name }} - Завершено: {{ formatDate(voting.endDate) }} + Завершено: {{ voting.dateend }} - openModal('results', voting)"> + openModal('results', voting)"> Результаты @@ -67,24 +67,20 @@ - + - - - - - - + + Редактировать голосование: {{ selectedVoting?.title }} - + Сохранить @@ -97,7 +93,7 @@ Результаты голосования: {{ selectedVoting?.title }} - Здесь отображаются результаты голосования... + Закрыть @@ -108,31 +104,40 @@
+ {{ option.name }}: {{ option.votes }} голосов +
Здесь отображаются результаты голосования...