diff --git a/src/back/vote/views.py b/src/back/vote/views.py index 99b1682f7..65ddc4ef4 100644 --- a/src/back/vote/views.py +++ b/src/back/vote/views.py @@ -142,7 +142,7 @@ class VoteCreate(APIView): text = f'Пройдите голосование "{vote_url}" до {formatted_date}', cdate = request.data['startDate'], author = request.user, - link = os.path.join(settings.MEDIA_ROOT,'defaultimg','vote.png'), + link = os.path.join('defaultimg','vote.png'), vote = vote ) news.save() diff --git a/src/front/src/components/UI/fiousercard/infoUserCard.vue b/src/front/src/components/UI/fiousercard/infoUserCard.vue index 7d135ba78..dcb9a4b36 100644 --- a/src/front/src/components/UI/fiousercard/infoUserCard.vue +++ b/src/front/src/components/UI/fiousercard/infoUserCard.vue @@ -67,7 +67,7 @@ Закрыть diff --git a/src/front/src/components/vote/NonVoteHappy.vue b/src/front/src/components/vote/NonVoteHappy.vue new file mode 100644 index 000000000..213e2adca --- /dev/null +++ b/src/front/src/components/vote/NonVoteHappy.vue @@ -0,0 +1,143 @@ + + + + + + + + + + + Все проголосовали!тех, кто не голосовал нет + + + + + + + + diff --git a/src/front/src/components/vote/NonVoteSad.vue b/src/front/src/components/vote/NonVoteSad.vue new file mode 100644 index 000000000..9b5ea1715 --- /dev/null +++ b/src/front/src/components/vote/NonVoteSad.vue @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + diff --git a/src/front/src/components/vote/VoteCard.vue b/src/front/src/components/vote/VoteCard.vue index a4cbf9ef3..1ea6e6727 100644 --- a/src/front/src/components/vote/VoteCard.vue +++ b/src/front/src/components/vote/VoteCard.vue @@ -11,10 +11,6 @@ {{ voteCard.name }} - - - - diff --git a/src/front/src/components/vote/VoteConstructor.vue b/src/front/src/components/vote/VoteConstructor.vue index e4a55aeba..bc0e87162 100644 --- a/src/front/src/components/vote/VoteConstructor.vue +++ b/src/front/src/components/vote/VoteConstructor.vue @@ -14,13 +14,13 @@ - + - + Основная информация - + Создание опроса @@ -40,7 +40,7 @@ @@ -70,7 +70,7 @@ - + Далее @@ -82,7 +82,7 @@ Создание опроса: - + @@ -105,12 +105,12 @@ - - + @@ -121,7 +121,7 @@ :rules="[rules.required && question.settings.multiChoice > 0]" hide-details type="number" min="1" variant="outlined"> - + @@ -141,18 +141,18 @@ - + - + Добавить ответ - - - + + + Голосование по отделам: @@ -161,21 +161,21 @@ {{ x.name }} - + - + - - - question.answers=question.answers.filter(e=>selected.includes(e.text))" > @@ -185,38 +185,38 @@ - + > + {{ item.raw.familyname }} - + - + - - + + @@ -232,10 +232,10 @@ - + - - + + @@ -253,7 +253,7 @@ - + Добавить вопрос @@ -263,25 +263,25 @@ Далее - + - + Подтверждение - + {{ errorMessage }} - + Название: {{ form.title }} Описание: {{ form.description }} Дата начала: {{ form.startDate.toLocaleDateString() }} Дата окончания: {{ form.endDate.toLocaleDateString() }} Вопросы: - + @@ -289,8 +289,8 @@ Варианты ответов: - - + + {{ answer.text }} @@ -309,20 +309,20 @@ - + Назад Сохранить - + - + @@ -374,7 +374,7 @@ export default { for (let x of allEmployees.value.sort((a,b)=>a.id_dict_department-b.id_dict_department)){ if(!groupped.includes(x.department))groupped.push(x.department) groupped.push(x) - } + } return groupped }) const findEmployeeById = (id) => @@ -532,7 +532,7 @@ export default { removeQuestion, addAnswer, removeAnswer, - findEmployeeById, + findEmployeeById, saveVoting, isVoteCreated, resetForm, diff --git a/src/front/src/components/vote/VoteResult.vue b/src/front/src/components/vote/VoteResult.vue index 426696733..7da129435 100644 --- a/src/front/src/components/vote/VoteResult.vue +++ b/src/front/src/components/vote/VoteResult.vue @@ -28,10 +28,26 @@ Не голосовали - - + + + + + + {{ department }} + + + Победитель: {{ winner.employee.fio || winner.name }} 🏆 + + + Количество голосов: {{ winner.count }} + + + + + + {{ question.name }} @@ -89,18 +105,25 @@ - Не голосовали: - + + Не голосовали: + + {{ department }} - - + - + + {{ voter.fio }} - ({{ voter.post }}) 👿 @@ -133,9 +156,13 @@ import {computed, ref} from 'vue'; import {baseURL, spravURL} from "@/utils/axios-api"; import {checkremote} from "@/utils/universal_functions"; +import NonVoteHappy from "@/components/vote/NonVoteHappy.vue"; +import NonVoteSad from "@/components/vote/NonVoteSad.vue"; +import InfoUserCard from "@/components/UI/fiousercard/infoUserCard.vue"; export default { name: 'VoteResult', + components: {InfoUserCard, NonVoteSad, NonVoteHappy}, methods: { checkremote, spravURL() { @@ -157,6 +184,7 @@ export default { setup(props) { const activeTab = ref(0); const questions = computed(() => props.data.questions || []); + const userCardIndex = ref(null); const title = props.data.name; const description = props.data.description; @@ -204,7 +232,8 @@ export default { } const groupedByDepartment = computed(() => { - return nonVoters.reduce((groups, voter) => { + // Группируем пользователей по департаментам + const departments = nonVoters.reduce((groups, voter) => { const department = voter.department || ''; if (!groups[department]) { groups[department] = []; @@ -212,9 +241,54 @@ export default { groups[department].push(voter); return groups; }, {}); + + // Сортируем департаменты по id_dict_department + const sortedDepartments = Object.keys(departments).sort((a, b) => { + const idA = nonVoters.find(voter => voter.department === a)?.id_dict_department; + const idB = nonVoters.find(voter => voter.department === b)?.id_dict_department; + return idA - idB; + }); + + // Возвращаем отсортированные департаменты с пользователями + const sortedGroupedByDepartment = {}; + sortedDepartments.forEach(department => { + sortedGroupedByDepartment[department] = departments[department]; + }); + + return sortedGroupedByDepartment; }); + // const groupedByDepartment = {}; + + const getWinnersByDepartment = (question) => { + // Группируем ответы по департаментам + const groupedByDepartment = question.answers.reduce((groups, answer) => { + const department = answer.employee?.department || 'Без отдела'; // Отдел или 'Без отдела' если нет + if (!groups[department]) { + groups[department] = []; + } + groups[department].push(answer); + return groups; + }, {}); + + // Для каждого департамента находим победителя + const winnersByDepartment = {}; + for (const department in groupedByDepartment) { + const answers = groupedByDepartment[department]; + const winner = answers.reduce( + (max, answer) => (answer.count > max.count ? answer : max), + {count: 0, employee: {fio: '', department: '', post: ''}, name: ''} + ); + winnersByDepartment[department] = winner; + } + + return winnersByDepartment; + }; + + return { + getWinnersByDepartment, + userCardIndex, activepick, opendialog, dialog,
тех, кто не голосовал нет
Название: {{ form.title }}
Описание: {{ form.description }}
Дата начала: {{ form.startDate.toLocaleDateString() }}
Дата окончания: {{ form.endDate.toLocaleDateString() }}
Вопросы:
Варианты ответов:
- + + {{ voter.fio }} - ({{ voter.post }}) 👿