From 502f860a8de9eb26a43bc97c954a0f714a221503 Mon Sep 17 00:00:00 2001 From: Denzel Date: Wed, 22 Jan 2025 13:59:09 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D1=84=D0=B8=D0=BB=D1=8C=D1=82=D1=80=D0=B0=D1=86?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=B8=20=D0=B3=D1=80=D1=83=D0=BF=D0=BF=D0=B8?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=BA=D0=B0,=20=D0=BA=D0=BD=D0=BE=D0=BF?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=B7=D0=B0=D0=BA=D1=80=D1=8B=D1=82=D1=8C=20?= =?UTF-8?q?=D0=B2=20=D1=80=D0=B5=D0=B7=D1=83=D0=BB=D1=8C=D1=82=D0=B0=D1=82?= =?UTF-8?q?=D0=B0=D1=85=20=D0=B8=20=D1=83=D0=B1=D1=80=D0=B0=D0=BD=20=D1=81?= =?UTF-8?q?=D0=B2=D0=B8=D1=82=D1=87=D0=B5=D1=80=20=D0=B8=D0=B7=20=D0=BA?= =?UTF-8?q?=D0=BE=D0=BD=D1=81=D1=82=D1=80=D1=83=D0=BA=D1=82=D0=BE=D1=80?= =?UTF-8?q?=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/front/src/components/vote/CurrentVote.vue | 101 ++++-- .../src/components/vote/VoteConstructor.vue | 289 +++++++++--------- src/front/src/components/vote/VoteResult.vue | 30 +- src/front/src/views/VoteHomePage.vue | 7 +- 4 files changed, 240 insertions(+), 187 deletions(-) diff --git a/src/front/src/components/vote/CurrentVote.vue b/src/front/src/components/vote/CurrentVote.vue index 52e9b18d8..be2299224 100644 --- a/src/front/src/components/vote/CurrentVote.vue +++ b/src/front/src/components/vote/CurrentVote.vue @@ -31,37 +31,54 @@ - +
-

{{ question.name }} (вариантов ответа: {{question.settings.multiChoice}})

+

+ {{ question.name }} + (вариантов ответа: {{ question.settings.multiChoice }}) +

- +
- - {{ answer.employee?.fio || answer.name }} - - - +
@@ -181,8 +198,6 @@ export default { }; const submitVote = () => { - console.log(props.data); - console.log("Отправляем данные голосования:", result.value); let voteData = [] for (let val of Object.values(result.value)) { val.forEach(e => voteData.push({answer: e, comment: null, user: accountStore.user.id})) @@ -198,6 +213,7 @@ export default { ).finally(() => isVoteSubmitted.value = true) }; + const activepick = ref(null) const dialog = ref(false) const opendialog = (val) => { @@ -205,7 +221,38 @@ export default { activepick.value = val } + const groupedAnswers = (question) => { + const filtered = question.answers.filter(answer => answer.employee?.id !== accountStore.user.is_idEmployee); + + if (question.settings.onlyDep === null) { + return groupByDepartment(filtered); + } else if (question.settings.onlyDep) { + const byDepartment = filtered.filter( + (answer) => answer.employee?.department === accountStore.user.department + ); + return groupByDepartment(byDepartment); + } else { + const notByDepartment = filtered.filter( + (answer) => answer.employee?.department !== accountStore.user.department + ); + return groupByDepartment(notByDepartment); + } + }; + + const groupByDepartment = (answers) => { + return answers.reduce((groups, answer) => { + const department = answer.employee?.department || ""; + if (!groups[department]) { + groups[department] = []; + } + groups[department].push(answer); + return groups; + }, {}); + }; + + return { + groupedAnswers, activepick, opendialog, dialog, diff --git a/src/front/src/components/vote/VoteConstructor.vue b/src/front/src/components/vote/VoteConstructor.vue index 9a3e14516..43d3a2256 100644 --- a/src/front/src/components/vote/VoteConstructor.vue +++ b/src/front/src/components/vote/VoteConstructor.vue @@ -1,6 +1,6 @@