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 @@