From 980b6024c6fd626ab22316de04ef33622c479840 Mon Sep 17 00:00:00 2001 From: Denzel Date: Tue, 14 Jan 2025 07:43:49 +0300 Subject: [PATCH 1/3] P-92 --- src/front/src/components/vote/CurrentVote.vue | 170 +++++++++ .../src/components/vote/VoteConstructor.vue | 356 ++++++++++++++++++ src/front/src/components/vote/VoteForm.vue | 259 +++++++------ src/front/src/router/index.js | 12 +- src/front/src/test/testDataForVote.js | 48 +++ src/front/src/utils/axios-api.js | 37 +- src/front/src/views/VoteConstructor.vue | 325 ---------------- src/front/src/views/VoteHomePage.vue | 91 +++-- 8 files changed, 805 insertions(+), 493 deletions(-) create mode 100644 src/front/src/components/vote/CurrentVote.vue create mode 100644 src/front/src/components/vote/VoteConstructor.vue create mode 100644 src/front/src/test/testDataForVote.js delete mode 100644 src/front/src/views/VoteConstructor.vue diff --git a/src/front/src/components/vote/CurrentVote.vue b/src/front/src/components/vote/CurrentVote.vue new file mode 100644 index 000000000..ac56960fa --- /dev/null +++ b/src/front/src/components/vote/CurrentVote.vue @@ -0,0 +1,170 @@ + + + + + diff --git a/src/front/src/components/vote/VoteConstructor.vue b/src/front/src/components/vote/VoteConstructor.vue new file mode 100644 index 000000000..1cd2261a4 --- /dev/null +++ b/src/front/src/components/vote/VoteConstructor.vue @@ -0,0 +1,356 @@ + + + diff --git a/src/front/src/components/vote/VoteForm.vue b/src/front/src/components/vote/VoteForm.vue index 55fe248d0..af235cb07 100644 --- a/src/front/src/components/vote/VoteForm.vue +++ b/src/front/src/components/vote/VoteForm.vue @@ -1,148 +1,147 @@ \ No newline at end of file + diff --git a/src/front/src/router/index.js b/src/front/src/router/index.js index b48ed3f02..df4371b8e 100644 --- a/src/front/src/router/index.js +++ b/src/front/src/router/index.js @@ -140,14 +140,14 @@ const routes = [ ico: "mdi-account", }, }, + // { + // path: "/vote", + // name: "Vote", + // component: () => + // import("@/views/Vote.vue") + // }, { path: "/vote", - name: "Vote", - component: () => - import("@/views/Vote.vue") - }, - { - path: "/votehomepage", name: "VoteHomePage", component: () => import("@/views/VoteHomePage.vue") diff --git a/src/front/src/test/testDataForVote.js b/src/front/src/test/testDataForVote.js new file mode 100644 index 000000000..f436ff040 --- /dev/null +++ b/src/front/src/test/testDataForVote.js @@ -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: "Заголовок голосовалки" +} diff --git a/src/front/src/utils/axios-api.js b/src/front/src/utils/axios-api.js index 6d88670c9..66a723d99 100644 --- a/src/front/src/utils/axios-api.js +++ b/src/front/src/utils/axios-api.js @@ -90,13 +90,7 @@ async error => { async function getVotes(status) { try { - const response = await axiosApiInstance.get(`/api/vote/getvotes?status=${status}`, - // { - // params: { - // status, - // } - // } - ); + const response = await axiosApiInstance.get(`/api/vote/getvotes?status=${status}/`); return response.data; } catch (error) { console.error('Ошибка запроса голосования:', error); @@ -120,6 +114,33 @@ getVotes('active') 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 } diff --git a/src/front/src/views/VoteConstructor.vue b/src/front/src/views/VoteConstructor.vue deleted file mode 100644 index c4586668e..000000000 --- a/src/front/src/views/VoteConstructor.vue +++ /dev/null @@ -1,325 +0,0 @@ - - - diff --git a/src/front/src/views/VoteHomePage.vue b/src/front/src/views/VoteHomePage.vue index cab3df511..2a8160870 100644 --- a/src/front/src/views/VoteHomePage.vue +++ b/src/front/src/views/VoteHomePage.vue @@ -18,13 +18,13 @@ {{ voting.title }} - + mdi-pencil @@ -36,15 +36,15 @@ Проголосовать - Уже проголосовали - + Проголосовали + mdi-delete @@ -59,9 +59,9 @@ {{ voting.title }} @@ -89,21 +89,43 @@ - + + + + + + mdi-close-thick + + + + + + + + + + Голосование: {{ selectedVoting?.title }} -

Описание голосования...

+ +
- Проголосовать - Закрыть + Сохранить + Закрыть
- + Результаты голосования: {{ selectedVoting?.title }} @@ -119,10 +141,17 @@