Merge branch 'develop'
This commit is contained in:
commit
5bf1a23ca3
10 files changed
+425
-277
No files matched your search
@@ -10,25 +10,26 @@ class GetEmpSerializer(serializers.ModelSerializer):
|
|||||||
'fio', 'post', 'department']
|
'fio', 'post', 'department']
|
||||||
|
|
||||||
class GetEmpSerializerR(serializers.ModelSerializer):
|
class GetEmpSerializerR(serializers.ModelSerializer):
|
||||||
id = serializers.CharField(source="id_dict_employee.id")
|
id = serializers.IntegerField(source="id_dict_employee.id")
|
||||||
fio = serializers.CharField(source="id_dict_employee.fio")
|
fio = serializers.CharField(source="id_dict_employee.fio")
|
||||||
id_dict_department = serializers.CharField(source="id_dict_department.id")
|
id_dict_department = serializers.IntegerField(source="id_dict_department.id")
|
||||||
post = serializers.CharField(source="id_dict_employee.post")
|
post = serializers.CharField(source="id_dict_employee.post")
|
||||||
department = serializers.CharField(source="id_dict_department.name")
|
department = serializers.CharField(source="id_dict_department.name")
|
||||||
|
login=serializers.CharField(source='id_dict_employee.login')
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = DictEmplyeeR
|
model = DictEmplyeeR
|
||||||
fields = ['id', 'id_dict_department',
|
fields = ['id', 'id_dict_department',
|
||||||
'fio', 'post', 'department']
|
'fio', 'post', 'department','login']
|
||||||
|
|
||||||
|
|
||||||
class ThanksVoteSerializer(serializers.ModelSerializer):
|
class ThanksVoteSerializer(serializers.ModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = ThanksVote
|
model = ThanksVote
|
||||||
fields = ('id', 'voted_user', 'cand_name', 'vote_thanks_date')
|
fields = ('id', 'voted_user', 'cand_name', 'vote_thanks_date','department_user')
|
||||||
|
|
||||||
|
|
||||||
class BestVoteSerializer(serializers.ModelSerializer):
|
class BestVoteSerializer(serializers.ModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = BestVote
|
model = BestVote
|
||||||
fields = ('id', 'voted_user', 'cand_name', 'vote_best_date')
|
fields = ('id', 'voted_user', 'cand_name', 'vote_best_date', 'department_user')
|
||||||
@@ -12,4 +12,10 @@ urlpatterns = [
|
|||||||
path('getbest/', GetBest.as_view(), name=''),
|
path('getbest/', GetBest.as_view(), name=''),
|
||||||
path('getnotvotethn/', GetNotVoteThn.as_view()),
|
path('getnotvotethn/', GetNotVoteThn.as_view()),
|
||||||
path('getnotvotebst/', GetNotVoteBst.as_view()),
|
path('getnotvotebst/', GetNotVoteBst.as_view()),
|
||||||
|
|
||||||
|
|
||||||
|
path('getvoteinfo/', GetVoteInfo.as_view()),
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
]
|
]
|
||||||
+28
-8
@@ -12,7 +12,7 @@ from .serializers import *
|
|||||||
class GetForThn(APIView):
|
class GetForThn(APIView):
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
user_login = request.GET.get('login')
|
user_login = request.GET.get('login')
|
||||||
all_emps = DictEmplyeeR.objects.exclude(id_dict_employee__login=user_login).exclude(id_dict_employee__department='Руководство').exclude(id_dict_employee__deleted=1).order_by('id_dict_employee__fio')
|
all_emps = DictEmplyeeR.objects.exclude(id_dict_employee__login=user_login).exclude(id_dict_department__name='Руководство').exclude(id_dict_employee__deleted=1).order_by('id_dict_employee__fio')
|
||||||
return Response(GetEmpSerializerR(all_emps, many=True).data)
|
return Response(GetEmpSerializerR(all_emps, many=True).data)
|
||||||
|
|
||||||
|
|
||||||
@@ -26,12 +26,12 @@ class GetForBst(APIView):
|
|||||||
|
|
||||||
class SetThanks(APIView):
|
class SetThanks(APIView):
|
||||||
def post(self, request):
|
def post(self, request):
|
||||||
voted_user = request.data['voted_user']
|
# department_user = request.data['department_user']
|
||||||
department_user = request.data['department_user']
|
|
||||||
cand_name = request.data['cand_name_id']
|
cand_name = request.data['cand_name_id']
|
||||||
|
depuser = DictEmplyeeR.objects.get(id_dict_employee__fio=cand_name)
|
||||||
ThanksVote.objects.create(
|
ThanksVote.objects.create(
|
||||||
voted_user=voted_user,
|
voted_user=request.user,
|
||||||
department_user=department_user,
|
department_user=depuser.id_dict_department.name,
|
||||||
cand_name=cand_name
|
cand_name=cand_name
|
||||||
)
|
)
|
||||||
return Response("Ваш голос добавлен!")
|
return Response("Ваш голос добавлен!")
|
||||||
@@ -47,12 +47,13 @@ class GetThanks(APIView):
|
|||||||
|
|
||||||
class SetBest(APIView):
|
class SetBest(APIView):
|
||||||
def post(self, request):
|
def post(self, request):
|
||||||
voted_user = request.data['voted_user']
|
voted_user = request.user
|
||||||
department_user = request.data['department_user']
|
# department_user = request.data['department_user']
|
||||||
cand_name = request.data['cand_name_id']
|
cand_name = request.data['cand_name_id']
|
||||||
|
depuser = DictEmplyeeR.objects.get(id_dict_employee__fio=cand_name)
|
||||||
BestVote.objects.create(
|
BestVote.objects.create(
|
||||||
voted_user=voted_user,
|
voted_user=voted_user,
|
||||||
department_user=department_user,
|
department_user=depuser.id_dict_department.name,
|
||||||
cand_name=cand_name
|
cand_name=cand_name
|
||||||
)
|
)
|
||||||
return Response("Ваш голос добавлен!")
|
return Response("Ваш голос добавлен!")
|
||||||
@@ -80,3 +81,22 @@ class GetNotVoteBst(APIView):
|
|||||||
list_emp_bst = DictEmplyeeR.objects.filter(
|
list_emp_bst = DictEmplyeeR.objects.filter(
|
||||||
id_dict_employee__deleted=0).exclude(id_dict_employee__login__in=list_bst_users).exclude(id_dict_employee__department='Руководство').order_by('id_dict_employee__fio')
|
id_dict_employee__deleted=0).exclude(id_dict_employee__login__in=list_bst_users).exclude(id_dict_employee__department='Руководство').order_by('id_dict_employee__fio')
|
||||||
return Response(GetEmpSerializerR(list_emp_bst, many=True).data)
|
return Response(GetEmpSerializerR(list_emp_bst, many=True).data)
|
||||||
|
|
||||||
|
class GetVoteInfo(APIView):
|
||||||
|
def get(self, request):
|
||||||
|
print(request.user)
|
||||||
|
allcod = DictEmplyeeR.objects.filter( id_dict_employee__deleted=0)
|
||||||
|
|
||||||
|
# try:
|
||||||
|
realdep = allcod.get(id_dict_employee__login=request.user)
|
||||||
|
|
||||||
|
usersvotedbest=BestVote.objects.filter()
|
||||||
|
|
||||||
|
uservotedthanks=ThanksVote.objects.all()
|
||||||
|
|
||||||
|
return Response({'allcod':GetEmpSerializerR(allcod, many=True).data,
|
||||||
|
'voteresults':{'uservotedthanks': ThanksVoteSerializer(uservotedthanks,many=True).data,
|
||||||
|
'usersvotedbest':BestVoteSerializer(usersvotedbest, many=True).data,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "front",
|
"name": "front",
|
||||||
"version": "0.0.76",
|
"version": "0.0.77",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "front",
|
"name": "front",
|
||||||
"version": "0.0.76",
|
"version": "0.0.77",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"-": "^0.0.1",
|
"-": "^0.0.1",
|
||||||
"@ckeditor/ckeditor5-build-classic": "^41.4.2",
|
"@ckeditor/ckeditor5-build-classic": "^41.4.2",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "front",
|
"name": "front",
|
||||||
"version": "0.0.76",
|
"version": "0.0.77",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
|
|||||||
@@ -1,47 +0,0 @@
|
|||||||
<template>
|
|
||||||
<span>{{ perc_best }}%</span>
|
|
||||||
</template>
|
|
||||||
<script>
|
|
||||||
import { ref } from "vue";
|
|
||||||
import { computed } from "vue";
|
|
||||||
import { clearAxios } from "@/utils/axios-api";
|
|
||||||
import { useAccountStore } from '@/store/AccountStore';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
setup() {
|
|
||||||
let account_login = useAccountStore().user.login;
|
|
||||||
let department_id = useAccountStore().user.id_dict_department;
|
|
||||||
let all_dep = ref([]);
|
|
||||||
let all_voted = ref([]);
|
|
||||||
let perc_best = ref();
|
|
||||||
|
|
||||||
const getAllDep = () => {
|
|
||||||
clearAxios.get(`api/vote/get_for_bst/?login=${account_login}&dep=${department_id}`).then((data) => {
|
|
||||||
all_dep.value = data.data;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const getVoted = () => {
|
|
||||||
clearAxios.get(`api/vote/getbest/`).then((data) => {
|
|
||||||
all_voted.value = data.data;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
getAllDep();
|
|
||||||
getVoted();
|
|
||||||
|
|
||||||
|
|
||||||
perc_best = computed(() => Math.round(all_voted.value.length / all_dep.value.length * 100))
|
|
||||||
|
|
||||||
return {
|
|
||||||
all_dep,
|
|
||||||
all_voted,
|
|
||||||
perc_best,
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
|
||||||
<style></style>
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
<template>
|
|
||||||
<span>{{ perc_thn }}%</span>
|
|
||||||
</template>
|
|
||||||
<script>
|
|
||||||
import { ref } from "vue";
|
|
||||||
import { computed } from "vue";
|
|
||||||
import { clearAxios } from "@/utils/axios-api";
|
|
||||||
import { useAccountStore } from '@/store/AccountStore';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
setup() {
|
|
||||||
let account_login = useAccountStore().user.login;
|
|
||||||
let all_cod = ref([]);
|
|
||||||
let all_voted = ref([]);
|
|
||||||
let perc_thn = ref();
|
|
||||||
|
|
||||||
const getAllCod = () => {
|
|
||||||
clearAxios.get(`api/vote/get_for_thn/?login=${account_login}`).then((data) => {
|
|
||||||
all_cod.value = data.data;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const getVoted = () => {
|
|
||||||
clearAxios.get(`api/vote/getthanks/`).then((data) => {
|
|
||||||
all_voted.value = data.data;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
getAllCod();
|
|
||||||
getVoted();
|
|
||||||
|
|
||||||
|
|
||||||
perc_thn = computed(() => Math.round(all_voted.value.length / all_cod.value.length * 100))
|
|
||||||
|
|
||||||
return {
|
|
||||||
all_cod,
|
|
||||||
all_voted,
|
|
||||||
perc_thn,
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
|
||||||
<style></style>
|
|
||||||
@@ -1,27 +1,28 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-row justify="center" align="center">
|
<v-row justify="center" align="center" class="pa-2">
|
||||||
<v-col justify="center" align="center" class="ma-3">
|
<v-col justify="center" align="center" class="flex-column">
|
||||||
|
|
||||||
<v-card width="700" height="820" class="elevation-12">
|
<v-card width="700" height="820" class="elevation-12">
|
||||||
<v-card class="mb-2" color="teal-darken-1" elevation="0">
|
<v-card class="mb-2" color="teal-darken-1" elevation="0">
|
||||||
<v-card-title>Голосование</v-card-title>
|
<!-- <v-card-title>Голосование</v-card-title> -->
|
||||||
<v-card-title color="teal-darken-1">«Мой коллега самый лучший»</v-card-title>
|
<v-card-title color="teal-darken-1">«Мой коллега самый лучший»</v-card-title>
|
||||||
</v-card>
|
</v-card>
|
||||||
<v-card color="teal-darken-1" class="ma-2">
|
<v-card class="px-2">
|
||||||
<v-card-title>Процент проголосовавших</v-card-title>
|
<v-card-title class="bg-teal-darken-1">Процент проголосовавших</v-card-title>
|
||||||
</v-card>
|
<v-card-text class="text-h6 pa-1">
|
||||||
<v-card elevation="0">
|
{{ perc_best }}%
|
||||||
<v-card-text class="perc-voted">
|
|
||||||
{{ perc_bst }}%
|
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
|
|
||||||
</v-card>
|
</v-card>
|
||||||
<v-card color="teal-darken-1" class="mb-2">
|
|
||||||
<v-card-title>Лидер номинации</v-card-title>
|
<v-card class="mb-2">
|
||||||
|
<v-card-title class="bg-teal-darken-1">Лидер номинации</v-card-title>
|
||||||
</v-card>
|
</v-card>
|
||||||
<v-card class="scroll-leaders" elevation="0">
|
<v-card class="scroll-leaders" elevation="0">
|
||||||
<v-card v-for="(employees, department) in max_bst" :key="department" elevation="0">
|
<v-card v-for="(employees, department) in max_bst" :key="department" elevation="0">
|
||||||
<v-card-title>{{ department }}</v-card-title>
|
<v-card-title>{{ department }}</v-card-title>
|
||||||
<div v-for="employee in employees" :key="employee.name">
|
<div v-for="employee in employees.slice(0,3)" :key="employee.name">
|
||||||
{{ employee.name }}
|
{{ employee.cand_name }} - {{ employee.total }}
|
||||||
</div>
|
</div>
|
||||||
</v-card>
|
</v-card>
|
||||||
</v-card>
|
</v-card>
|
||||||
@@ -30,7 +31,7 @@
|
|||||||
</v-card>
|
</v-card>
|
||||||
<v-card elevation="0">
|
<v-card elevation="0">
|
||||||
<v-card class="scroll-window" elevation="0">
|
<v-card class="scroll-window" elevation="0">
|
||||||
<v-card v-for="[key, val] of Object.entries(result_bst)">
|
<v-card v-for="[key, val] of Object.entries(notvotedbest)">
|
||||||
<v-card-title>{{ key }}</v-card-title>
|
<v-card-title>{{ key }}</v-card-title>
|
||||||
<div v-for="item_fio in val">
|
<div v-for="item_fio in val">
|
||||||
{{ item_fio.fio }}
|
{{ item_fio.fio }}
|
||||||
@@ -44,30 +45,30 @@
|
|||||||
<v-col justify="center" align="center">
|
<v-col justify="center" align="center">
|
||||||
<v-card width="700" height="820" class="elevation-12">
|
<v-card width="700" height="820" class="elevation-12">
|
||||||
<v-card class="mb-2" color="teal-darken-1" elevation="0">
|
<v-card class="mb-2" color="teal-darken-1" elevation="0">
|
||||||
<v-card-title>Голосование</v-card-title>
|
<!-- <v-card-title>Голосование</v-card-title> -->
|
||||||
<v-card-title>«Хочу сказать Спасибо!»</v-card-title>
|
<v-card-title>«Хочу сказать Спасибо!»</v-card-title>
|
||||||
</v-card>
|
</v-card>
|
||||||
<v-card color="teal-darken-1" class="ma-2">
|
<v-card class="px-2">
|
||||||
<v-card-title>Процент проголосовавших</v-card-title>
|
<v-card-title class="bg-teal-darken-1">Процент проголосовавших</v-card-title>
|
||||||
</v-card>
|
<v-card-text class="text-h6 pa-1">
|
||||||
<v-card elevation="0">
|
{{ perc_thanks }}%
|
||||||
<v-card-text class="perc-voted">
|
|
||||||
<perc-thn />
|
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
</v-card>
|
</v-card>
|
||||||
<v-card color="teal-darken-1" class="mb-2">
|
|
||||||
|
<v-card color="teal-darken-1" >
|
||||||
<v-card-title>Лидер номинации</v-card-title>
|
<v-card-title>Лидер номинации</v-card-title>
|
||||||
</v-card>
|
</v-card>
|
||||||
<v-card class="scroll-leaders pt-4" elevation="0">
|
<v-card class="scroll-leaders pt-4" elevation="0">
|
||||||
<div v-for="leader in max_thn">
|
<div v-for="leader in max_thn.slice(0,3)">
|
||||||
{{ leader }}
|
{{ leader.cand_name }} - {{ leader.total }}
|
||||||
</div>
|
</div>
|
||||||
</v-card>
|
</v-card>
|
||||||
<v-card color="teal-darken-1" class="ma-2">
|
<v-card color="teal-darken-1" class="ma-2">
|
||||||
<v-card-title>ФИО не участвовавших в голосовании</v-card-title>
|
<v-card-title>ФИО не участвовавших в голосовании</v-card-title>
|
||||||
</v-card>
|
</v-card>
|
||||||
<v-card class="scroll-window" elevation="0">
|
<v-card class="scroll-window" elevation="0">
|
||||||
<v-card v-for="[key, val] of Object.entries(result_thn)">
|
|
||||||
|
<v-card v-for="[key, val] of Object.entries(notvotedthanks)">
|
||||||
<v-card-title>{{ key }}</v-card-title>
|
<v-card-title>{{ key }}</v-card-title>
|
||||||
<div v-for="item_fio in val">
|
<div v-for="item_fio in val">
|
||||||
{{ item_fio.fio }}
|
{{ item_fio.fio }}
|
||||||
@@ -85,84 +86,220 @@ import { computed } from "vue";
|
|||||||
import { clearAxios } from "@/utils/axios-api";
|
import { clearAxios } from "@/utils/axios-api";
|
||||||
import { objectToString } from "@vue/shared";
|
import { objectToString } from "@vue/shared";
|
||||||
import { useAccountStore } from '@/store/AccountStore';
|
import { useAccountStore } from '@/store/AccountStore';
|
||||||
import PercThn from '@/components/vote/PercThn.vue';
|
import { el } from "date-fns/locale";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
PercThn,
|
|
||||||
},
|
},
|
||||||
setup() {
|
props:{
|
||||||
|
usersvotedbest:{
|
||||||
|
type:Array,
|
||||||
|
default:()=>[]
|
||||||
|
},
|
||||||
|
uservotedthanks:{
|
||||||
|
type:Array,
|
||||||
|
default:()=>[]
|
||||||
|
},
|
||||||
|
all_cod:{
|
||||||
|
type:Array,
|
||||||
|
default:()=>[]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
setup(props) {
|
||||||
let account_login = useAccountStore().user.login;
|
let account_login = useAccountStore().user.login;
|
||||||
let result_thn = ref([]);
|
let result_thn = ref([]);
|
||||||
let result_bst = ref([]);
|
let result_bst = ref([]);
|
||||||
let all_voted_bst = ref([]);
|
let all_voted_bst = ref([]);
|
||||||
let all_voted_thn = ref([]);
|
let all_voted_thn = ref([]);
|
||||||
let max_thn = ref();
|
// let max_thn = ref({});
|
||||||
let max_bst = ref({});
|
// let max_bst = ref({});
|
||||||
let all_cod = ref([]);
|
|
||||||
let perc_bst = ref();
|
let perc_bst = ref();
|
||||||
|
|
||||||
const getNotVoted = () => {
|
// const
|
||||||
clearAxios.get(`/api/vote/getnotvotethn/`).then((data) => {
|
const perc_thanks = computed({
|
||||||
let not_voted_thn = data.data;
|
get(){
|
||||||
result_thn.value = Object.groupBy(not_voted_thn, ({ department }) => department);
|
// console.log(props.all_cod);
|
||||||
});
|
return Math.round(props.uservotedthanks.length*100/(props.all_cod.length+1))
|
||||||
clearAxios.get(`/api/vote/getnotvotebst/`).then((data) => {
|
}
|
||||||
let not_voted_bst = data.data;
|
})
|
||||||
result_bst.value = Object.groupBy(not_voted_bst, ({ department }) => department);
|
const perc_best = computed({
|
||||||
});
|
get(){
|
||||||
};
|
|
||||||
|
|
||||||
const getPercAndWin = () => {
|
return Math.round(props.usersvotedbest.length*100/(props.all_cod.length+1))
|
||||||
clearAxios.get(`/api/vote/getthanks/`).then((data) => {
|
}
|
||||||
all_voted_thn = data.data;
|
})
|
||||||
let max_total = Math.max(...all_voted_thn.map(item => item.total));
|
|
||||||
max_thn.value = all_voted_thn.filter(item => item.total === max_total).map(item => item.cand_name)
|
|
||||||
});
|
|
||||||
|
|
||||||
clearAxios.get(`api/vote/get_for_thn/?login=${account_login}`).then((data) => {
|
const max_bst= computed({
|
||||||
all_cod.value = data.data;
|
get(){
|
||||||
});
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
|
return getmax(props.usersvotedbest)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const max_thn= computed({
|
||||||
|
get(){
|
||||||
|
let nob = []
|
||||||
|
props.uservotedthanks.forEach((n)=>{
|
||||||
|
let ind = nob.findIndex(e=>e.cand_name==n.cand_name)
|
||||||
|
if (ind==-1){
|
||||||
|
nob.push({...n, total:1})
|
||||||
|
}else{
|
||||||
|
nob[ind].total+=1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
return nob.sort((a,b)=>{return b.total-a.total})
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const groupit=(grpd)=>{
|
||||||
|
let nob = {}
|
||||||
|
for(let [key, val] of Object.entries(grpd) ){
|
||||||
|
if (!(key in nob)){
|
||||||
|
nob[key]=[]
|
||||||
|
}
|
||||||
|
val.forEach((n)=>{
|
||||||
|
let ind = nob[key].findIndex(elm=>elm.cand_name==n.cand_name)
|
||||||
|
if (ind>-1){
|
||||||
|
nob[key][ind].total+=1
|
||||||
|
}else{
|
||||||
|
nob[key].push(n)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
nob[key]=nob[key].sort((a,b)=>{return b.total-a.total})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return nob
|
||||||
|
}
|
||||||
|
|
||||||
|
const getmax=(data)=>{
|
||||||
|
let ob = []
|
||||||
|
data.forEach(el => {
|
||||||
|
|
||||||
|
ob.push({...el, total:1})
|
||||||
});
|
});
|
||||||
console.log(max_bst);
|
let grpd = Object.groupBy(ob, ({ department_user }) => department_user);
|
||||||
|
|
||||||
|
|
||||||
|
return groupit(grpd)
|
||||||
|
}
|
||||||
|
const thanksleader = computed({get(){
|
||||||
|
// u
|
||||||
|
return []
|
||||||
|
}})
|
||||||
|
const notvotedbest= computed({
|
||||||
|
get(){
|
||||||
|
|
||||||
|
let logins = props.usersvotedbest.reduce((arr,elm)=>[...arr,elm.login],[])
|
||||||
|
|
||||||
|
let grpd = Object.groupBy(props.all_cod.filter(el=>!logins.includes(el.login)), ({ department }) => department);
|
||||||
|
|
||||||
|
return novoted(grpd)
|
||||||
|
}})
|
||||||
|
|
||||||
|
const notvotedthanks = computed({
|
||||||
|
get(){
|
||||||
|
|
||||||
|
console.log(props.usersvotedbest);
|
||||||
|
let logins = props.usersvotedbest.reduce((arr,elm)=>[...arr,elm.voted_user],[])
|
||||||
|
console.log(logins,"ssssssssssssssssss");
|
||||||
|
let grpd = Object.groupBy(props.all_cod.filter(el=>!logins.includes(el.login)), ({ department }) => department);
|
||||||
|
console.log(grpd);
|
||||||
|
|
||||||
|
return novoted(grpd)
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
};
|
const novoted=(grpd)=>{
|
||||||
|
let nob = {}
|
||||||
|
for(let [key, val] of Object.entries(grpd) ){
|
||||||
|
if (!(key in nob)){
|
||||||
|
nob[key]=[]
|
||||||
|
}
|
||||||
|
val.forEach((n)=>{
|
||||||
|
|
||||||
|
nob[key].push(n)
|
||||||
|
|
||||||
|
})
|
||||||
|
nob[key]=nob[key].sort((a,b)=>{return b.total-a.total})
|
||||||
|
|
||||||
perc_bst = computed(() => Math.round(all_voted_bst.value.length / all_cod.value.length * 100))
|
}
|
||||||
|
return nob
|
||||||
|
}
|
||||||
|
// const getNotVoted = () => {
|
||||||
|
// clearAxios.get(`/api/vote/getnotvotethn/`).then((data) => {
|
||||||
|
// let not_voted_thn = data.data;
|
||||||
|
// result_thn.value = Object.groupBy(not_voted_thn, ({ department }) => department);
|
||||||
|
// });
|
||||||
|
// clearAxios.get(`/api/vote/getnotvotebst/`).then((data) => {
|
||||||
|
// let not_voted_bst = data.data;
|
||||||
|
// result_bst.value = Object.groupBy(not_voted_bst, ({ department }) => department);
|
||||||
|
// });
|
||||||
|
// };
|
||||||
|
|
||||||
getPercAndWin();
|
// const getPercAndWin = () => {
|
||||||
getNotVoted();
|
// clearAxios.get(`/api/vote/getthanks/`).then((data) => {
|
||||||
|
// all_voted_thn = data.data;
|
||||||
|
// let max_total = Math.max(...all_voted_thn.map(item => item.total));
|
||||||
|
// max_thn.value = all_voted_thn.filter(item => item.total === max_total).map(item => item.cand_name)
|
||||||
|
// });
|
||||||
|
|
||||||
|
// 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 {
|
return {
|
||||||
max_thn,
|
max_thn,
|
||||||
max_bst,
|
max_bst,
|
||||||
perc_bst,
|
perc_best,
|
||||||
result_thn,
|
result_thn,
|
||||||
result_bst,
|
result_bst,
|
||||||
|
perc_thanks,
|
||||||
|
notvotedthanks,
|
||||||
|
notvotedbest
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -178,7 +315,7 @@ export default {
|
|||||||
|
|
||||||
.scroll-leaders {
|
.scroll-leaders {
|
||||||
overflow-y: scroll;
|
overflow-y: scroll;
|
||||||
height: 95px;
|
height: 125px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.scroll-window {
|
.scroll-window {
|
||||||
@@ -186,7 +323,5 @@ export default {
|
|||||||
height: 378px;
|
height: 378px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.perc-voted {
|
|
||||||
font-size: 1.2em;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
@@ -2,19 +2,20 @@
|
|||||||
<v-form @submit="voteSend">
|
<v-form @submit="voteSend">
|
||||||
<v-card id="scroll-window-chekbox" height="300" elevation="0">
|
<v-card id="scroll-window-chekbox" height="300" elevation="0">
|
||||||
<!-- Форма голосования -->
|
<!-- Форма голосования -->
|
||||||
<v-virtual-scroll :items="vote_data" :item-height="40">
|
|
||||||
|
<v-virtual-scroll :items="persons.filter(e=>e.id_dict_department!=1)" :item-height="40">
|
||||||
<template v-slot:default="{ item }">
|
<template v-slot:default="{ item }">
|
||||||
<v-checkbox v-model="vote" :id="item.fio" :value="item.fio" :label="item.fio" required />
|
<v-checkbox v-model="vote" :id="item.fio" :value="item.fio" :label="item.fio" required />
|
||||||
</template>
|
</template>
|
||||||
</v-virtual-scroll>
|
</v-virtual-scroll>
|
||||||
</v-card>
|
</v-card>
|
||||||
<v-card-actions class="justify-center vote-button-back">
|
<v-card-actions class="justify-center vote-button-back">
|
||||||
<v-dialog max-width="500">
|
<v-dialog max-width="500" v-model="dialog">
|
||||||
<template v-slot:activator="{ props: activatorProps }">
|
<template v-slot:activator>
|
||||||
<v-btn variant="elevated" v-bind="activatorProps" color="teal-darken-1"
|
<v-btn variant="elevated" color="teal-darken-1"
|
||||||
@click="approveCandidate">Подтвердить выбор</v-btn>
|
@click="approveCandidate">Подтвердить выбор</v-btn>
|
||||||
</template>
|
</template>
|
||||||
<template v-slot:default="{ isActive }">
|
<template v-slot:default>
|
||||||
<v-card class="justify-center align-center">
|
<v-card class="justify-center align-center">
|
||||||
<v-card-title>Вы подтверждаете выбор?</v-card-title>
|
<v-card-title>Вы подтверждаете выбор?</v-card-title>
|
||||||
<v-card-text>После подтверждения внесение измений станет невозможным.</v-card-text>
|
<v-card-text>После подтверждения внесение измений станет невозможным.</v-card-text>
|
||||||
@@ -30,7 +31,7 @@
|
|||||||
</v-col>
|
</v-col>
|
||||||
<v-col cols="2">
|
<v-col cols="2">
|
||||||
<v-btn variant="elevated" color="red-darken-1"
|
<v-btn variant="elevated" color="red-darken-1"
|
||||||
@click="isActive.value = false">НЕТ</v-btn>
|
@click="dialog = false">НЕТ</v-btn>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-card>
|
</v-card>
|
||||||
@@ -41,39 +42,50 @@
|
|||||||
</template>
|
</template>
|
||||||
<script scope>
|
<script scope>
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
import { clearAxios } from "@/utils/axios-api";
|
import { clearAxios, axiosApiInstance } from "@/utils/axios-api";
|
||||||
import { useAccountStore } from '@/store/AccountStore';
|
import { useAccountStore } from '@/store/AccountStore';
|
||||||
import Vote from "@/views/Vote.vue";
|
import Vote from "@/views/Vote.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
||||||
props: ['type_fetch'],
|
props: {type_fetch:{type:String, default:'best'},
|
||||||
|
persons:{
|
||||||
setup(props) {
|
type:Array,
|
||||||
let account_login = useAccountStore().user.login;
|
default:()=>[]
|
||||||
let department_id = useAccountStore().user.id_dict_department;
|
},
|
||||||
let department_name = useAccountStore().user.department
|
myrealdep:{
|
||||||
let type_fetch = props.type_fetch;
|
type:Object,
|
||||||
|
default:()=>{}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
setup(props, {emit}) {
|
||||||
|
let account_login = useAccountStore();
|
||||||
|
// let department_id = useAccountStore().user.id_dict_department;
|
||||||
|
// let department_name = useAccountStore().user.department
|
||||||
|
// let type_fetch = props.type_fetch;
|
||||||
|
const dialog=ref(false)
|
||||||
let vote = ref();
|
let vote = ref();
|
||||||
let get_address = ref();
|
// let get_address = ref();
|
||||||
let send_address = ref();
|
let send_address = ref();
|
||||||
let vote_data = ref([]);
|
// let vote_data = ref([]);
|
||||||
let approve_name = ref();
|
let approve_name = ref();
|
||||||
let aproveFalseMessage = ref();
|
let aproveFalseMessage = ref();
|
||||||
|
|
||||||
if (type_fetch == "thn") {
|
if (props.type_fetch == "thanks") {
|
||||||
get_address = `api/vote/get_for_thn/?login=${account_login}`;
|
|
||||||
send_address = `api/vote/setthanks/`;
|
send_address = `api/vote/setthanks/`;
|
||||||
} else if (type_fetch == "bst") {
|
} else if (props.type_fetch == "best") {
|
||||||
get_address = `api/vote/get_for_bst/?login=${account_login}&dep=${department_id}`;
|
|
||||||
send_address = `api/vote/setbest/`;
|
send_address = `api/vote/setbest/`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const getVotesData = () => {
|
// const getVotesData = () => {
|
||||||
clearAxios.get(get_address).then((data) => {
|
// clearAxios.get(get_address).then((data) => {
|
||||||
vote_data.value = data.data;
|
// vote_data.value = data.data;
|
||||||
});
|
// });
|
||||||
};
|
// };
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const approveCandidate = () => {
|
const approveCandidate = () => {
|
||||||
if (vote.value === 'False' || vote.value === '') {
|
if (vote.value === 'False' || vote.value === '') {
|
||||||
@@ -84,34 +96,39 @@ export default {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dialog.value=true
|
||||||
}
|
}
|
||||||
|
|
||||||
const voteSend = () => {
|
const voteSend = () => {
|
||||||
window.location.reload();
|
console.log(vote.value);
|
||||||
clearAxios.post(send_address, {
|
axiosApiInstance.post(send_address, {
|
||||||
cand_name_id: vote.value,
|
cand_name_id: vote.value,
|
||||||
department_user: department_name,
|
// department_user: props.myrealdep.department,
|
||||||
voted_user: account_login
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
).then(res=>
|
||||||
|
{
|
||||||
|
dialog.value=false
|
||||||
|
window.location.reload()
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
getVotesData();
|
// getVotesData();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
approveCandidate,
|
approveCandidate,
|
||||||
voteSend,
|
voteSend,
|
||||||
vote_data,
|
// vote_data,
|
||||||
vote,
|
vote,
|
||||||
approve_name,
|
approve_name,
|
||||||
aproveFalseMessage,
|
aproveFalseMessage,
|
||||||
|
dialog
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
+117
-55
@@ -8,13 +8,13 @@
|
|||||||
<v-col cols="6" justify="center" align="center">
|
<v-col cols="6" justify="center" align="center">
|
||||||
<div class="flip-card" :class="{ 'flipped': isFlipped1 }">
|
<div class="flip-card" :class="{ 'flipped': isFlipped1 }">
|
||||||
<div class="flip-card-inner">
|
<div class="flip-card-inner">
|
||||||
<div v-if="voted_bst" class="flip-card-front">
|
<div v-if="!uservotedbest" class="flip-card-front">
|
||||||
<!-- Передняя сторона карточки -->
|
<!-- Передняя сторона карточки -->
|
||||||
<v-card class="justify-center elevation-24" width="500" height="510" variant="elevated">
|
<v-card class="justify-center elevation-24" width="500" height="510" elevated>
|
||||||
<v-card-title class="vote-title">ЛУЧШИЙ В ОТДЕЛЕ</v-card-title>
|
<v-card-title class="vote-title">ЛУЧШИЙ В ОТДЕЛЕ</v-card-title>
|
||||||
<div class="justify-center">
|
<div class="justify-center">
|
||||||
<div>
|
<div>
|
||||||
<v-card class="vote-card-information" variant="flat">
|
<v-card class="vote-card-information" flat>
|
||||||
|
|
||||||
<v-card-text
|
<v-card-text
|
||||||
class="justify-center align-center vote-card-information-title">
|
class="justify-center align-center vote-card-information-title">
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div v-else class="flip-card-front" @click="toggleFlip1">
|
<div v-else class="flip-card-front" @click="toggleFlip1">
|
||||||
<!-- Передняя сторона карточки -->
|
<!-- Передняя сторона карточки -->
|
||||||
<v-card class="justify-center elevation-24" width="500" height="510" variant="elevated">
|
<v-card class="justify-center elevation-24" width="500" height="510" elevated>
|
||||||
<v-card-title class="vote-title">ЛУЧШИЙ В ОТДЕЛЕ</v-card-title>
|
<v-card-title class="vote-title">ЛУЧШИЙ В ОТДЕЛЕ</v-card-title>
|
||||||
<div class="justify-center">
|
<div class="justify-center">
|
||||||
<div>
|
<div>
|
||||||
@@ -63,7 +63,7 @@
|
|||||||
МОЙ КОЛЛЕГА САМЫЙ ЛУЧШИЙ
|
МОЙ КОЛЛЕГА САМЫЙ ЛУЧШИЙ
|
||||||
</v-card-title>
|
</v-card-title>
|
||||||
<v-card-text>
|
<v-card-text>
|
||||||
<vote-form :type_fetch="'bst'" />
|
<vote-form :type_fetch="'best'" :persons="mydepartment" :myrealdep="myrealdep" @voted="toggleFlip1" />
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
<!-- Кнопка активации поворота -->
|
<!-- Кнопка активации поворота -->
|
||||||
<v-card-actions class="justify-center vote-button-back">
|
<v-card-actions class="justify-center vote-button-back">
|
||||||
@@ -82,7 +82,7 @@
|
|||||||
<v-col cols="6" justify="center" align="center">
|
<v-col cols="6" justify="center" align="center">
|
||||||
<div class="flip-card" :class="{ 'flipped': isFlipped2 }">
|
<div class="flip-card" :class="{ 'flipped': isFlipped2 }">
|
||||||
<div class="flip-card-inner">
|
<div class="flip-card-inner">
|
||||||
<div v-if="voted_thn" class="flip-card-front">
|
<div v-if="!uservotedthanks" class="flip-card-front">
|
||||||
<!-- Передняя сторона карточки -->
|
<!-- Передняя сторона карточки -->
|
||||||
<v-card class="justify-center elevation-24" width="500" height="510" variant="elevated">
|
<v-card class="justify-center elevation-24" width="500" height="510" variant="elevated">
|
||||||
<v-card-title class="vote-title">ХОЧУ СКАЗАТЬ СПАСИБО</v-card-title>
|
<v-card-title class="vote-title">ХОЧУ СКАЗАТЬ СПАСИБО</v-card-title>
|
||||||
@@ -136,7 +136,7 @@
|
|||||||
ХОЧУ СКАЗАТЬ СПАСИБО
|
ХОЧУ СКАЗАТЬ СПАСИБО
|
||||||
</v-card-title>
|
</v-card-title>
|
||||||
<v-card-text>
|
<v-card-text>
|
||||||
<vote-form :type_fetch="'thn'" />
|
<vote-form :type_fetch="'thanks'" :persons="allsorted" :myrealdep="myrealdep" @voted="toggleFlip2" />
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
<!-- Кнопка активации поворота -->
|
<!-- Кнопка активации поворота -->
|
||||||
<v-card-actions class="justify-center vote-button-back">
|
<v-card-actions class="justify-center vote-button-back">
|
||||||
@@ -155,21 +155,23 @@
|
|||||||
<h1>ПРИНЯЛИ УЧАСТИЕ В ГОЛОСОВАНИИ</h1>
|
<h1>ПРИНЯЛИ УЧАСТИЕ В ГОЛОСОВАНИИ</h1>
|
||||||
</v-col> -->
|
</v-col> -->
|
||||||
<v-col cols="12" class="d-flex justify-center align-end pa-0">
|
<v-col cols="12" class="d-flex justify-center align-end pa-0">
|
||||||
|
|
||||||
<v-col v-if="admin_panel" justify="center" align="center" cols="6" class=" pa-0">
|
<v-col v-if="admin_panel" justify="center" align="center" cols="6" class=" pa-0">
|
||||||
<v-dialog>
|
<v-dialog>
|
||||||
<template v-slot:activator="{ props: VoteAdmin }">
|
<template v-slot:activator="{ props: activatorProps }">
|
||||||
<v-btn variant="transparent" v-bind="VoteAdmin"
|
<v-btn v-bind="activatorProps " variant='plain'
|
||||||
class="procent-card-font pa-0">
|
class="procent_card_font pa-0">
|
||||||
<perc-bst />
|
{{ Math.round((voteresults.usersvotedbest.length*100/(mydepartment.length+1)).toFixed(2))}}%
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</template>
|
</template>
|
||||||
<template v-slot:default="{ isActive }">
|
<template v-slot:default="{ isActive }">
|
||||||
<v-row justify="center" class="h-100 admin-vote">
|
<v-row justify="center" class="h-100 admin-vote">
|
||||||
<v-card width="1500" height="900">
|
<v-card width="1500" height="900">
|
||||||
<vote-admin />
|
|
||||||
|
<vote-admin :usersvotedbest="voteresults.usersvotedbest" :uservotedthanks="voteresults.uservotedthanks" :all_cod="allsorted"/>
|
||||||
<v-row justify="center" align="center">
|
<v-row justify="center" align="center">
|
||||||
|
|
||||||
<v-btn variant="elevated" color="teal-darken-1"
|
<v-btn color="teal-darken-1"
|
||||||
@click="isActive.value = false">ЗАКРЫТЬ</v-btn>
|
@click="isActive.value = false">ЗАКРЫТЬ</v-btn>
|
||||||
|
|
||||||
</v-row>
|
</v-row>
|
||||||
@@ -178,22 +180,26 @@
|
|||||||
</template>
|
</template>
|
||||||
</v-dialog>
|
</v-dialog>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col v-else justify="center" align="center" cols="6" class="procent-card-font pa-0">
|
<v-col v-else justify="center" align="center" cols="6" class="procent_card_font pa-0">
|
||||||
<!-- <perc-bst /> -->
|
|
||||||
|
<span>{{ (Math.round(((voteresults.usersvotedbest.filter(e=>e.department_user==mydepartment[0].department).length )*100/(mydepartment.length+1)).toFixed(2)))}}%</span>
|
||||||
|
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col v-if="admin_panel" justify="center" align="center" cols="6" class=" pa-0">
|
<v-col v-if="admin_panel" justify="center" align="center" cols="6" class=" pa-0">
|
||||||
<v-dialog>
|
<v-dialog>
|
||||||
<template v-slot:activator="{ props: VoteAdmin }">
|
<template v-slot:activator="{ props: activatorProps }">
|
||||||
<v-btn variant="transparent" v-bind="VoteAdmin"
|
<v-btn v-bind="activatorProps " variant='plain'
|
||||||
class="procent-card-font pa-0"><perc-thn /></v-btn>
|
class="procent_card_font pa-0" >
|
||||||
|
<span>{{ Math.round((voteresults.uservotedthanks.length*100/(allsorted.length+1)).toFixed(2))}}%</span>
|
||||||
|
</v-btn>
|
||||||
</template>
|
</template>
|
||||||
<template v-slot:default="{ isActive }">
|
<template v-slot:default="{ isActive }">
|
||||||
<v-row justify="center" class="h-100 admin-vote">
|
<v-row justify="center" class="h-100 admin-vote">
|
||||||
<v-card width="1500" height="900">
|
<v-card width="1500" height="900">
|
||||||
<vote-admin />
|
<vote-admin :usersvotedbest="voteresults.usersvotedbest" :uservotedthanks="voteresults.uservotedthanks" :all_cod="allsorted" />
|
||||||
<v-row justify="center" align="center">
|
<v-row justify="center" align="center">
|
||||||
|
|
||||||
<v-btn variant="elevated" color="teal-darken-1"
|
<v-btn color="teal-darken-1"
|
||||||
@click="isActive.value = false">ЗАКРЫТЬ</v-btn>
|
@click="isActive.value = false">ЗАКРЫТЬ</v-btn>
|
||||||
|
|
||||||
</v-row>
|
</v-row>
|
||||||
@@ -202,9 +208,9 @@
|
|||||||
</template>
|
</template>
|
||||||
</v-dialog>
|
</v-dialog>
|
||||||
</v-col>
|
</v-col>
|
||||||
<!-- <v-col v-else justify="center" align="center" cols="6" class="procent-card-font pa-0">
|
<v-col v-else justify="center" align="center" cols="6" class="procent_card_font pa-0">
|
||||||
<perc-thn />
|
<span>{{ Math.round((voteresults.uservotedthanks.length*100/(allsorted.length+1)).toFixed(2))}}%</span>
|
||||||
</v-col> -->
|
</v-col>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col cols="12" class="d-flex justify-center align-start pa-0">
|
<v-col cols="12" class="d-flex justify-center align-start pa-0">
|
||||||
<v-col justify="center" align="center" cols="6" class="vote-cards_cell ">
|
<v-col justify="center" align="center" cols="6" class="vote-cards_cell ">
|
||||||
@@ -216,16 +222,15 @@
|
|||||||
</v-row>
|
</v-row>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { ref } from "vue";
|
import { ref, computed } from "vue";
|
||||||
import { clearAxios } from "@/utils/axios-api";
|
import { clearAxios, axiosApiInstance } from "@/utils/axios-api";
|
||||||
import VoteForm from '@/components/vote/VoteForm.vue';
|
import VoteForm from '@/components/vote/VoteForm.vue';
|
||||||
import PercBst from '@/components/vote/PercBst.vue';
|
|
||||||
import PercThn from '@/components/vote/PercThn.vue';
|
|
||||||
import VoteAdmin from '@/components/vote/VoteAdmin.vue';
|
import VoteAdmin from '@/components/vote/VoteAdmin.vue';
|
||||||
import CountDown from '@/components/CountDown.vue';
|
import CountDown from '@/components/CountDown.vue';
|
||||||
import { useAccountStore } from '@/store/AccountStore';
|
import { useAccountStore } from '@/store/AccountStore';
|
||||||
let admin_panel = ref(false);
|
let admin_panel = ref(false);
|
||||||
let account_login = useAccountStore().user.login;
|
let account_login = useAccountStore();
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
||||||
@@ -233,59 +238,112 @@ export default {
|
|||||||
components: {
|
components: {
|
||||||
VoteForm,
|
VoteForm,
|
||||||
CountDown,
|
CountDown,
|
||||||
PercBst,
|
|
||||||
PercThn,
|
|
||||||
VoteAdmin,
|
VoteAdmin,
|
||||||
},
|
},
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
|
const voted_best=ref([])
|
||||||
|
const full_list_pers=ref([])
|
||||||
let votedListBst = ref([]);
|
let votedListBst = ref([]);
|
||||||
let votedListThn = ref([]);
|
let votedListThn = ref([]);
|
||||||
let voted_thn = ref(false);
|
let voted_thn = ref(false);
|
||||||
let voted_bst = ref(false);
|
let voted_bst = ref(false);
|
||||||
|
const myrealdep = ref({id_dict_department:0, id:0})
|
||||||
|
const uservoted=ref([true,true])
|
||||||
|
const allcod = ref([])
|
||||||
const isFlipped1 = ref(false);
|
const isFlipped1 = ref(false);
|
||||||
const isFlipped2 = ref(false);
|
const isFlipped2 = ref(false);
|
||||||
|
const voteresults=ref({usersvotedbest:[],uservotedthanks:[]} )
|
||||||
|
|
||||||
|
// const isVoted = () => {
|
||||||
|
// clearAxios.get(`/api/vote/getthanks/`).then((data) => {
|
||||||
|
// votedListThn = data.data;
|
||||||
|
// let finded_thn = votedListThn.find(({ voted_user }) => voted_user === account_login)
|
||||||
|
// if (finded_thn.voted_user === account_login) {
|
||||||
|
// voted_thn.value = true;
|
||||||
|
|
||||||
const isVoted = () => {
|
// }
|
||||||
clearAxios.get(`/api/vote/getthanks/`).then((data) => {
|
// });
|
||||||
votedListThn = data.data;
|
// clearAxios.get(`/api/vote/getbest/`).then((data) => {
|
||||||
let finded_thn = votedListThn.find(({ voted_user }) => voted_user === account_login)
|
// votedListBst = data.data;
|
||||||
if (finded_thn.voted_user === account_login) {
|
// let finded_bst = votedListBst.find(({ voted_user }) => voted_user === account_login)
|
||||||
voted_thn.value = true;
|
// if (finded_bst.voted_user === account_login) {
|
||||||
|
// voted_bst.value = true;
|
||||||
}
|
// }
|
||||||
});
|
|
||||||
clearAxios.get(`/api/vote/getbest/`).then((data) => {
|
|
||||||
votedListBst = data.data;
|
|
||||||
let finded_bst = votedListBst.find(({ voted_user }) => voted_user === account_login)
|
|
||||||
if (finded_bst.voted_user === account_login) {
|
|
||||||
voted_bst.value = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
|
axiosApiInstance.get('/api/vote/getvoteinfo/').then((res)=>{
|
||||||
|
allcod.value = res.data.allcod
|
||||||
|
// console.log(account_login.user);
|
||||||
|
myrealdep.value = allcod.value.find(e=>e.login === account_login.user.login)
|
||||||
|
console.log(myrealdep.value);
|
||||||
|
// uservoted.value = res.data.uservoted
|
||||||
|
voteresults.value = res.data.voteresults
|
||||||
|
console.log(res.data.voteresults);
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
const toggleFlip1 = () => {
|
const toggleFlip1 = () => {
|
||||||
|
|
||||||
isFlipped1.value = !isFlipped1.value;
|
isFlipped1.value = !isFlipped1.value;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
const toggleFlip2 = () => {
|
const toggleFlip2 = () => {
|
||||||
isFlipped2.value = !isFlipped2.value;
|
isFlipped2.value = !isFlipped2.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (account_login == '9966-00-134' || account_login == '9966-00-141' || account_login == '9966-00-011') {
|
if (['9966-00-134', '9966-00-141','9966-00-011','9966-00-125'].includes(account_login.user.login)) {
|
||||||
admin_panel = true;
|
admin_panel = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
const allsorted = computed({
|
||||||
|
get(){
|
||||||
|
let all = allcod.value.filter(e=> e.id!=myrealdep.value.id)
|
||||||
|
return all.sort((a,b)=>{if(b.fio>a.fio) return -1
|
||||||
|
else if(b.fio<a.fio)return 1
|
||||||
|
return 0
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// isVoted();
|
||||||
|
|
||||||
isVoted();
|
|
||||||
|
const uservotedthanks = computed({
|
||||||
|
get(){
|
||||||
|
|
||||||
|
let ind = voteresults.value.uservotedthanks.findIndex(e=>e.voted_user===account_login.user.login)
|
||||||
|
|
||||||
|
if (ind>-1) return false
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
const uservotedbest= computed({
|
||||||
|
get(){
|
||||||
|
|
||||||
|
let ind = voteresults.value.usersvotedbest.findIndex(e=>e.voted_user===account_login.user.login)
|
||||||
|
if (ind>-1) return false
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const mydepartment = computed({
|
||||||
|
get(){
|
||||||
|
console.log(allcod.value);
|
||||||
|
let ac= allcod.value.filter(e=> e.id_dict_department===myrealdep.value.id_dict_department && e.id!=myrealdep.value.id )
|
||||||
|
return ac.sort((a,b)=>{if(b.fio>a.fio) return -1
|
||||||
|
else if(b.fio<a.fio)return 1
|
||||||
|
return 0
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
return {
|
return {
|
||||||
|
myrealdep,
|
||||||
|
allsorted,
|
||||||
|
mydepartment,
|
||||||
isFlipped1,
|
isFlipped1,
|
||||||
toggleFlip1,
|
toggleFlip1,
|
||||||
isFlipped2,
|
isFlipped2,
|
||||||
@@ -294,6 +352,10 @@ export default {
|
|||||||
admin_panel,
|
admin_panel,
|
||||||
voted_bst,
|
voted_bst,
|
||||||
voted_thn,
|
voted_thn,
|
||||||
|
uservotedthanks,
|
||||||
|
uservotedbest,
|
||||||
|
voteresults
|
||||||
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -303,7 +365,7 @@ export default {
|
|||||||
height: 600px !important;
|
height: 600px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.flip-card {}
|
|
||||||
|
|
||||||
.flip-card-inner {
|
.flip-card-inner {
|
||||||
|
|
||||||
@@ -343,7 +405,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.procent-card-font {
|
.procent_card_font {
|
||||||
font-size: 5em;
|
font-size: 5em;
|
||||||
color: #008000;
|
color: #008000;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user