From 135c5fb87d7a4cbfcb2efb659c2daebf3c8fadb5 Mon Sep 17 00:00:00 2001 From: Denzel Date: Tue, 14 Jan 2025 15:07:30 +0300 Subject: [PATCH] =?UTF-8?q?P-92=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=80=D0=BE=D1=83=D1=82=D0=BE=D0=B2?= =?UTF-8?q?=20=D0=B2=20=D0=BC=D0=BE=D0=B4=D0=B0=D0=BB=D0=BA=D0=B8=20+=20?= =?UTF-8?q?=D0=B2=D0=B0=D0=BB=D0=B8=D0=B4=D0=B0=D1=86=D0=B8=D1=8F=20=D1=84?= =?UTF-8?q?=D0=BE=D1=80=D0=BC=D1=8B=20=D0=BA=D0=BE=D0=BD=D1=81=D1=82=D1=80?= =?UTF-8?q?=D1=83=D0=BA=D1=82=D0=BE=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/back/vote/views.py | 1 - .../src/components/vote/VoteConstructor.vue | 33 +++- src/front/src/router/index.js | 18 ++ src/front/src/utils/axios-api.js | 5 - src/front/src/views/VoteHomePage.vue | 182 +++++++++--------- 5 files changed, 143 insertions(+), 96 deletions(-) diff --git a/src/back/vote/views.py b/src/back/vote/views.py index 8c4627fe5..8b90b251f 100644 --- a/src/back/vote/views.py +++ b/src/back/vote/views.py @@ -15,7 +15,6 @@ class GetVotes(APIView): def get(self, request): user = request.user - print(type(user)) # user = User.objects.get(username='9966-00-125') now = datetime.now() status = request.query_params.get('status') diff --git a/src/front/src/components/vote/VoteConstructor.vue b/src/front/src/components/vote/VoteConstructor.vue index 9ea073c40..6f288a63d 100644 --- a/src/front/src/components/vote/VoteConstructor.vue +++ b/src/front/src/components/vote/VoteConstructor.vue @@ -25,8 +25,18 @@ Основная информация - - + + Назад Сохранить + + {{ errorMessage }} + @@ -264,6 +279,10 @@ export default { questions: [], }); + const rules = { + required: (value) => !!value || "Это поле обязательно для заполнения", + }; + const currentQuestionIndex = ref(0); const questionTypes = ["Ввести вручную", "Выбрать сотрудника"]; @@ -313,7 +332,13 @@ export default { } }; + const errorMessage = ref(""); + const saveVoting = async () => { + if (!form.value.title || !form.value.description || form.value.questions < 1) { + errorMessage.value = "Все обязательные поля должны быть заполнены"; + return; + } try { const response = await createVote(form.value); console.log("Голосование успешно создано:", response); @@ -351,7 +376,9 @@ export default { removeEmployee, saveVoting, isVoteCreated, - resetForm + resetForm, + rules, + errorMessage }; }, }; diff --git a/src/front/src/router/index.js b/src/front/src/router/index.js index 49a51de25..f156a59b4 100644 --- a/src/front/src/router/index.js +++ b/src/front/src/router/index.js @@ -152,6 +152,24 @@ const routes = [ component: () => import("@/views/VoteHomePage.vue") }, + { + path: "/vote/voting/:id", + name: "Voting", + component: () => + import("@/views/VoteHomePage.vue") + }, + { + path: "/vote/edit-vote/:id", + name: "EditVote", + component: () => + import("@/views/VoteHomePage.vue") + }, + { + path: "/vote/vote-results/:id", + name: "VoteResults", + component: () => + import("@/views/VoteHomePage.vue") + }, { path: '/secret', name: 'Secret Page', diff --git a/src/front/src/utils/axios-api.js b/src/front/src/utils/axios-api.js index 919d71896..bdf61e4c6 100644 --- a/src/front/src/utils/axios-api.js +++ b/src/front/src/utils/axios-api.js @@ -77,11 +77,6 @@ async error => { return axiosApiInstance(originalRequest); } catch(e) { - - // - // if (window.location.pathname!='/auth') window.location.reload() - // window.location.reload() - return Promise.reject(error); } } diff --git a/src/front/src/views/VoteHomePage.vue b/src/front/src/views/VoteHomePage.vue index 3e1754c39..f64531ab6 100644 --- a/src/front/src/views/VoteHomePage.vue +++ b/src/front/src/views/VoteHomePage.vue @@ -2,12 +2,11 @@ Голосования - @@ -17,9 +16,19 @@ - - + + @@ -29,14 +38,21 @@ - + {{ voting.title }} Завершено: {{ formatDate(voting.endDate) }} - + Результаты @@ -55,12 +71,11 @@ - - + + - - + mdi-close-thick @@ -71,30 +86,27 @@ - - + - Голосование: {{ selectedVoting?.title }} + Редактировать голосование: {{ selectedVoting?.title }} - Сохранить - Закрыть + Закрыть - - + Результаты голосования: {{ selectedVoting?.title }}

Здесь отображаются результаты голосования...

- Закрыть + Закрыть
@@ -102,25 +114,33 @@