From e063d5c755146c1914e9775c748faaaddcb1c8a0 Mon Sep 17 00:00:00 2001 From: Nukeap <53114367+Nukeap@users.noreply.github.com> Date: Tue, 21 Jan 2025 09:44:56 +0300 Subject: [PATCH] Update VoteResult.vue --- src/front/src/components/vote/VoteResult.vue | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/front/src/components/vote/VoteResult.vue b/src/front/src/components/vote/VoteResult.vue index fef88c673..0cbcf210d 100644 --- a/src/front/src/components/vote/VoteResult.vue +++ b/src/front/src/components/vote/VoteResult.vue @@ -3,7 +3,8 @@ - Победитель: {{ winner?.employee.fio || 'Нет данных' }} + Победитель: {{ winner.employee?.fio || winner.name }} + Количество голосов: {{ winner?.count || 0 }} @@ -14,16 +15,16 @@ - Топ 5 + Топ 10

- {{ answer.employee.fio }}: {{ answer.count }} голосов + {{ answer.employee?answer.employee.fio:answer.name }}: {{ answer.count }} голосов
- Отдел: {{ answer.employee.department }} + Отдел: {{ answer.employee?answer.employee.department:'' }}
- Должность: {{ answer.employee.post }} + Должность: {{ answer.employee?answer.employee.post:'' }}

@@ -51,17 +52,20 @@ export default { // Находим победителя const winner = computed(() => { + if(props.data.questions[0].settings.choice=='employee'){ return answers.value.reduce( (max, answer) => (answer.count > max.count ? answer : max), {count: 0, employee: {fio: '', department: '', post: ''}} ); + } + return answers.value.reduce( (max, answer) => (answer.count > max.count ? answer : max),{count:0,name:""}) }); // Сортируем результаты и выбираем топ-5 const topResults = computed(() => { return [...answers.value] .sort((a, b) => b.count - a.count) - .slice(0, 5); // Берем первые 5 элементов + .slice(0, 10); // Берем первые 5 элементов }); return {