В админ панель добавлены итоги голосования, процент проголосовавших Мой коллега самый лучший
This commit is contained in:
1 parent
af1f9f752c
commit
e3661db5cb
2 files changed
+45
-7
No files matched your search
@@ -11,15 +11,18 @@
|
||||
</v-card>
|
||||
<v-card elevation="0">
|
||||
<v-card-text>
|
||||
88
|
||||
{{ perc_bst }}%
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
<v-card color="teal-darken-1" class="ma-2">
|
||||
<v-card-title>Лидер номинации</v-card-title>
|
||||
</v-card>
|
||||
<v-card elevation="0">
|
||||
<v-card v-for="(employees, department) in max_bst" :key="department" elevation="0">
|
||||
<v-card-title>{{ department }}</v-card-title>
|
||||
<v-card-text>
|
||||
ФИО
|
||||
<div v-for="employee in employees" :key="employee.name">
|
||||
{{ employee.name }}
|
||||
</div>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
<v-card color="teal-darken-1" class="ma-2">
|
||||
@@ -78,8 +81,10 @@
|
||||
</template>
|
||||
<script>
|
||||
import { ref } from "vue";
|
||||
import { computed } from "vue";
|
||||
import { clearAxios } from "@/utils/axios-api";
|
||||
import { objectToString } from "@vue/shared";
|
||||
import { useAccountStore } from '@/store/AccountStore';
|
||||
import PercThn from '@/components/vote/PercThn.vue';
|
||||
|
||||
|
||||
@@ -88,11 +93,15 @@ export default {
|
||||
PercThn,
|
||||
},
|
||||
setup() {
|
||||
let account_login = useAccountStore().user.login;
|
||||
let result_thn = ref([]);
|
||||
let result_bst = ref([]);
|
||||
let all_voted_bst = ref([]);
|
||||
let all_voted_thn = ref([]);
|
||||
let max_thn = ref();
|
||||
let max_bst = ref({});
|
||||
let all_cod = ref([]);
|
||||
let perc_bst = ref();
|
||||
|
||||
const getNotVoted = () => {
|
||||
clearAxios.get(`/api/vote/getnotvotethn/`).then((data) => {
|
||||
@@ -112,17 +121,46 @@ export default {
|
||||
max_thn.value = all_voted_thn.filter(item => item.total === max_total).map(item => item.cand_name)
|
||||
});
|
||||
|
||||
clearAxios.get(`/api/vote/getbest/`).then((data) => {
|
||||
all_voted_bst = data.data;
|
||||
|
||||
clearAxios.get(`api/vote/get_for_thn/?login=${account_login}`).then((data) => {
|
||||
all_cod.value = data.data;
|
||||
});
|
||||
|
||||
clearAxios.get(`/api/vote/getbest/`).then((data) => {
|
||||
all_voted_bst.value = data.data;
|
||||
// Групировка по департаметам
|
||||
const groupedEmployees = {}
|
||||
all_voted_bst.value.forEach(item => {
|
||||
const { department_user, cand_name, total } = item;
|
||||
if (!groupedEmployees[department_user]) {
|
||||
groupedEmployees[department_user] = [];
|
||||
}
|
||||
groupedEmployees[department_user].push({ name: cand_name, total });
|
||||
});
|
||||
// Нахождение лучших сотрудников в каждом департаменте
|
||||
for (const department in groupedEmployees) {
|
||||
const employees = groupedEmployees[department];
|
||||
// Поиск максимального количества голосов
|
||||
const maxTotal = Math.max(...employees.map(emp => emp.total));
|
||||
|
||||
// Фильтрация сотрудников с максимальным количетсвом голосов
|
||||
max_bst.value[department] = employees.filter(emp => emp.total === maxTotal);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
console.log(max_bst);
|
||||
|
||||
|
||||
};
|
||||
|
||||
perc_bst = computed(() => Math.round(all_voted_bst.value.length / all_cod.value.length * 100))
|
||||
|
||||
getPercAndWin();
|
||||
getNotVoted();
|
||||
return {
|
||||
max_thn,
|
||||
max_bst,
|
||||
perc_bst,
|
||||
result_thn,
|
||||
result_bst,
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user