P-129 Вывод всех результатов
This commit is contained in:
1 parent
6ccb2fc7c3
commit
2ef1572788
1 file changed
+77
-6
@@ -30,10 +30,12 @@
|
||||
</v-tabs>
|
||||
<v-tabs-window v-model="activeTab">
|
||||
<v-tabs-window-item v-for="(question, questionIndex) in questions" :key="questionIndex">
|
||||
|
||||
<v-row v-if="question.settings.onlyDep">
|
||||
<v-col v-for="(winner, department) in getWinnersByDepartment(question)" :key="department">
|
||||
<v-card>
|
||||
<v-col
|
||||
v-for="(winner, department) in getWinnersByDepartment(question).winnersByDepartment"
|
||||
:key="department"
|
||||
>
|
||||
<v-card class="cursor-pointer" @click="opendialogWinn(department, getWinnersByDepartment(question).groupedByDepartment[department])" style="max-height: 50vh; overflow-y: auto;">
|
||||
<v-card-title>
|
||||
<strong class="text-teal-darken-4">{{ department }}</strong>
|
||||
</v-card-title>
|
||||
@@ -153,6 +155,60 @@
|
||||
</v-card-item>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
|
||||
<v-dialog v-model="dialogWinner" max-width="800">
|
||||
<v-card>
|
||||
<v-card-title class="d-flex">
|
||||
<strong class="text-teal-darken-4">Результаты голосования: {{ activeDepartment }}</strong>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn color="red-darken-1" density="compact" icon="mdi-close-thick" size="small" @click="dialogWinner=false"/>
|
||||
</v-card-title>
|
||||
<v-card-text>
|
||||
<v-list>
|
||||
<v-list-item
|
||||
v-for="(answer, index) in activeDepartmentResults.filter(el => el.count > 0)"
|
||||
:key="index"
|
||||
>
|
||||
|
||||
<p>
|
||||
<strong class="mr-4">{{ index + 1 }}.</strong>
|
||||
<v-avatar v-if="answer.file === null && answer.employee"
|
||||
:image="checkremote(`${spravURL()}${answer.employee.login}.jpg`)"
|
||||
class="cursor-pointer"
|
||||
@click.stop="opendialog(checkremote(`${spravURL()}${answer.employee.login}.jpg`))"/>
|
||||
<v-avatar v-if="answer.file !== null" :image="baseURL.slice(0, -1) + answer.file"
|
||||
class="cursor-pointer"
|
||||
@click.stop="opendialog(answer)"/>
|
||||
<strong class="ml-4">{{ answer.employee ? answer.employee.fio : answer.name }}</strong>:
|
||||
{{ answer.count }}
|
||||
<template v-if="answer.employee">
|
||||
<br/>
|
||||
<small>Отдел: {{ answer.employee ? answer.employee.department : '' }}</small>
|
||||
<br/>
|
||||
<small>Должность: {{ answer.employee ? answer.employee.post : '' }}</small>
|
||||
</template>
|
||||
</p>
|
||||
|
||||
<v-progress-linear
|
||||
:model-value="getPercentage(answer.count, questions[index])"
|
||||
color="teal-darken-4"
|
||||
height="13"
|
||||
rounded
|
||||
striped
|
||||
>
|
||||
<template v-slot:default="{ value }">
|
||||
<strong v-if="value < 50" class="text-grey-darken-3">{{ Math.ceil(value) }}%</strong>
|
||||
<strong v-else class="text-grey-lighten-5">{{ Math.ceil(value) }}%</strong>
|
||||
</template>
|
||||
</v-progress-linear>
|
||||
|
||||
</v-list-item>
|
||||
|
||||
</v-list>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@@ -193,6 +249,17 @@ export default {
|
||||
const description = props.data.description;
|
||||
const nonVoters = props.data.nonvoting;
|
||||
|
||||
const activeDepartment = ref(null);
|
||||
const activeDepartmentResults = ref([]);
|
||||
const dialog = ref(false);
|
||||
const dialogWinner = ref(false);
|
||||
|
||||
const opendialogWinn = (department, results) => {
|
||||
activeDepartment.value = department;
|
||||
activeDepartmentResults.value = results;
|
||||
dialogWinner.value = true;
|
||||
};
|
||||
|
||||
const getWinner = (question) => {
|
||||
return question.answers.reduce(
|
||||
(max, answer) => (answer.count > max.count ? answer : max),
|
||||
@@ -201,7 +268,7 @@ export default {
|
||||
};
|
||||
|
||||
const getTopResults = (question) => {
|
||||
return [...question.answers].sort((a, b) => b.count - a.count);
|
||||
return [...question?.answers].sort((a, b) => b.count - a.count);
|
||||
};
|
||||
|
||||
const truncateText = (text, maxLength) => {
|
||||
@@ -228,7 +295,7 @@ export default {
|
||||
};
|
||||
|
||||
const activepick = ref(null)
|
||||
const dialog = ref(false)
|
||||
// const dialog = ref(false)
|
||||
const opendialog = (val) => {
|
||||
dialog.value = true
|
||||
activepick.value = val
|
||||
@@ -292,11 +359,15 @@ export default {
|
||||
winnersByDepartment[department] = winner;
|
||||
}
|
||||
|
||||
return winnersByDepartment;
|
||||
return { groupedByDepartment, winnersByDepartment };
|
||||
};
|
||||
|
||||
|
||||
return {
|
||||
opendialogWinn,
|
||||
dialogWinner,
|
||||
activeDepartmentResults,
|
||||
activeDepartment,
|
||||
getWinnersByDepartment,
|
||||
userCardIndex,
|
||||
activepick,
|
||||
|
||||
Reference in new issue
Block a user