Merge branch 'dev-denzel' into develop

This commit is contained in:
Nukeap committed 2025-01-23 15:48:47 +03:00
commit 68dbc1938b
2 files changed
+52 -7

No files matched your search

@@ -110,7 +110,7 @@
:list-props="{density:'compact'}" :list-props="{density:'compact'}"
item-title="name" item-value="choice" label="" hide-details variant="outlined"></v-select> item-title="name" item-value="choice" label="" hide-details variant="outlined"></v-select>
<!-- choice --> <!-- choice -->
</v-col> </v-col>
<v-spacer/> <v-spacer/>
<v-col cols="auto" class="align-self-center font-weight-bold"> <v-col cols="auto" class="align-self-center font-weight-bold">
@@ -121,7 +121,7 @@
:rules="[rules.required && question.settings.multiChoice > 0]" hide-details type="number" :rules="[rules.required && question.settings.multiChoice > 0]" hide-details type="number"
min="1" variant="outlined"> min="1" variant="outlined">
<template v-slot:prepend> <template v-slot:prepend>
</template> </template>
</v-text-field> </v-text-field>
</v-col> </v-col>
@@ -143,7 +143,7 @@
</div> </div>
</transition-group> </transition-group>
<div class="d-flex justify-start"> <div class="d-flex justify-start">
<v-btn size="small" color="teal-darken-4" @click="addAnswer(index)">Добавить ответ</v-btn> <v-btn size="small" color="teal-darken-4" @click="addAnswer(index)">Добавить ответ</v-btn>
@@ -164,7 +164,7 @@
</v-radio> </v-radio>
</v-radio-group> </v-radio-group>
</div> </div>
@@ -271,7 +271,7 @@
<v-card flat class="fill-height d-flex flex-column"> <v-card flat class="fill-height d-flex flex-column">
<v-card-title>Подтверждение</v-card-title> <v-card-title>Подтверждение</v-card-title>
<v-card-text> <v-card-text style="max-height: 62vh; overflow-y: auto;">
<v-alert v-if="errorMessage" class="mb-4 " type="error"> <v-alert v-if="errorMessage" class="mb-4 " type="error">
{{ errorMessage }} {{ errorMessage }}
</v-alert> </v-alert>
+47 -2
View File
@@ -30,8 +30,24 @@
</v-tabs> </v-tabs>
<v-tabs-window v-model="activeTab"> <v-tabs-window v-model="activeTab">
<v-tabs-window-item v-for="(question, questionIndex) in questions" :key="questionIndex"> <v-tabs-window-item v-for="(question, questionIndex) in questions" :key="questionIndex">
<v-row> <v-row v-if="question.settings.onlyDep">
<v-col v-for="(winner, department) in getWinnersByDepartment(question)" :key="department">
<v-card>
<v-card-title>
<strong class="text-teal-darken-4">{{ department }}</strong>
</v-card-title>
<v-card-subtitle>
Победитель: {{ winner.employee.fio || winner.name }} 🏆
</v-card-subtitle>
<v-card-text>
Количество голосов: {{ winner.count }}
</v-card-text>
</v-card>
</v-col>
</v-row>
<v-row v-else>
<v-col cols="12"> <v-col cols="12">
<h3 class="text-center">{{ question.name }}</h3> <h3 class="text-center">{{ question.name }}</h3>
<v-card-title class="d-flex ga-2 align-center"> <v-card-title class="d-flex ga-2 align-center">
@@ -242,7 +258,36 @@ export default {
return sortedGroupedByDepartment; 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 { return {
getWinnersByDepartment,
userCardIndex, userCardIndex,
activepick, activepick,
opendialog, opendialog,