This commit is contained in:
Nukeap committed 2024-11-11 13:12:06 +03:00
1 parent c9626e61b8
commit 7f7b30fa8c
8 files changed
+400 -251

No files matched your search

+6 -5
View File
@@ -10,25 +10,26 @@ class GetEmpSerializer(serializers.ModelSerializer):
'fio', 'post', 'department']
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")
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")
department = serializers.CharField(source="id_dict_department.name")
login=serializers.CharField(source='id_dict_employee.login')
class Meta:
model = DictEmplyeeR
fields = ['id', 'id_dict_department',
'fio', 'post', 'department']
'fio', 'post', 'department','login']
class ThanksVoteSerializer(serializers.ModelSerializer):
class Meta:
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 Meta:
model = BestVote
fields = ('id', 'voted_user', 'cand_name', 'vote_best_date')
fields = ('id', 'voted_user', 'cand_name', 'vote_best_date', 'department_user')
+6
View File
@@ -12,4 +12,10 @@ urlpatterns = [
path('getbest/', GetBest.as_view(), name=''),
path('getnotvotethn/', GetNotVoteThn.as_view()),
path('getnotvotebst/', GetNotVoteBst.as_view()),
path('getvoteinfo/', GetVoteInfo.as_view()),
]
+28 -8
View File
@@ -12,7 +12,7 @@ from .serializers import *
class GetForThn(APIView):
def get(self, request):
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)
@@ -26,12 +26,12 @@ class GetForBst(APIView):
class SetThanks(APIView):
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']
depuser = DictEmplyeeR.objects.get(id_dict_employee__fio=cand_name)
ThanksVote.objects.create(
voted_user=voted_user,
department_user=department_user,
voted_user=request.user,
department_user=depuser.id_dict_department.name,
cand_name=cand_name
)
return Response("Ваш голос добавлен!")
@@ -47,12 +47,13 @@ class GetThanks(APIView):
class SetBest(APIView):
def post(self, request):
voted_user = request.data['voted_user']
department_user = request.data['department_user']
voted_user = request.user
# department_user = request.data['department_user']
cand_name = request.data['cand_name_id']
depuser = DictEmplyeeR.objects.get(id_dict_employee__fio=cand_name)
BestVote.objects.create(
voted_user=voted_user,
department_user=department_user,
department_user=depuser.id_dict_department.name,
cand_name=cand_name
)
return Response("Ваш голос добавлен!")
@@ -80,3 +81,22 @@ class GetNotVoteBst(APIView):
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')
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,
}
}
)
-47
View File
@@ -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>
-46
View File
@@ -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>
+195 -57
View File
@@ -11,7 +11,8 @@
</v-card>
<v-card elevation="0">
<v-card-text class="perc-voted">
{{ perc_bst }}%
{{ perc_best }}%
</v-card-text>
</v-card>
<v-card color="teal-darken-1" class="mb-2">
@@ -21,7 +22,7 @@
<v-card v-for="(employees, department) in max_bst" :key="department" elevation="0">
<v-card-title>{{ department }}</v-card-title>
<div v-for="employee in employees" :key="employee.name">
{{ employee.name }}
{{ employee.cand_name }} - {{ employee.total }}
</div>
</v-card>
</v-card>
@@ -30,7 +31,7 @@
</v-card>
<v-card 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>
<div v-for="item_fio in val">
{{ item_fio.fio }}
@@ -52,7 +53,7 @@
</v-card>
<v-card elevation="0">
<v-card-text class="perc-voted">
<perc-thn />
{{ perc_thanks }}%
</v-card-text>
</v-card>
<v-card color="teal-darken-1" class="mb-2">
@@ -60,14 +61,15 @@
</v-card>
<v-card class="scroll-leaders pt-4" elevation="0">
<div v-for="leader in max_thn">
{{ leader }}
{{ leader.cand_name }} - {{ leader.total }}
</div>
</v-card>
<v-card color="teal-darken-1" class="ma-2">
<v-card-title>ФИО не участвовавших в голосовании</v-card-title>
</v-card>
<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>
<div v-for="item_fio in val">
{{ item_fio.fio }}
@@ -85,84 +87,220 @@ 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';
import { el } from "date-fns/locale";
export default {
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 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 max_thn = ref({});
// let max_bst = ref({});
let perc_bst = ref();
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);
});
};
// const
const perc_thanks = computed({
get(){
// console.log(props.all_cod);
return Math.round(props.uservotedthanks.length*100/(props.all_cod.length+1))
}
})
const perc_best = computed({
get(){
const getPercAndWin = () => {
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)
});
return Math.round(props.usersvotedbest.length*100/(props.all_cod.length+1))
}
})
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);
const max_bst= computed({
get(){
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 a.total-b.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 a.total-b.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 a.total-b.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();
getNotVoted();
// const getPercAndWin = () => {
// 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 {
max_thn,
max_bst,
perc_bst,
perc_best,
result_thn,
result_bst,
perc_thanks,
notvotedthanks,
notvotedbest
}
}
+50 -33
View File
@@ -2,19 +2,20 @@
<v-form @submit="voteSend">
<v-card id="scroll-window-chekbox" height="300" elevation="0">
<!-- Форма голосования -->
<v-virtual-scroll :items="vote_data" :item-height="40">
<v-virtual-scroll :items="persons" :item-height="40">
<template v-slot:default="{ item }">
<v-checkbox v-model="vote" :id="item.fio" :value="item.fio" :label="item.fio" required />
</template>
</v-virtual-scroll>
</v-card>
<v-card-actions class="justify-center vote-button-back">
<v-dialog max-width="500">
<template v-slot:activator="{ props: activatorProps }">
<v-btn variant="elevated" v-bind="activatorProps" color="teal-darken-1"
<v-dialog max-width="500" v-model="dialog">
<template v-slot:activator>
<v-btn variant="elevated" color="teal-darken-1"
@click="approveCandidate">Подтвердить выбор</v-btn>
</template>
<template v-slot:default="{ isActive }">
<template v-slot:default>
<v-card class="justify-center align-center">
<v-card-title>Вы подтверждаете выбор?</v-card-title>
<v-card-text>После подтверждения внесение измений станет невозможным.</v-card-text>
@@ -30,7 +31,7 @@
</v-col>
<v-col cols="2">
<v-btn variant="elevated" color="red-darken-1"
@click="isActive.value = false">НЕТ</v-btn>
@click="dialog = false">НЕТ</v-btn>
</v-col>
</v-col>
</v-card>
@@ -41,39 +42,50 @@
</template>
<script scope>
import { ref } from "vue";
import { clearAxios } from "@/utils/axios-api";
import { clearAxios, axiosApiInstance } from "@/utils/axios-api";
import { useAccountStore } from '@/store/AccountStore';
import Vote from "@/views/Vote.vue";
export default {
props: ['type_fetch'],
setup(props) {
let account_login = useAccountStore().user.login;
let department_id = useAccountStore().user.id_dict_department;
let department_name = useAccountStore().user.department
let type_fetch = props.type_fetch;
props: {type_fetch:{type:String, default:'best'},
persons:{
type:Array,
default:()=>[]
},
myrealdep:{
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 get_address = ref();
// let get_address = ref();
let send_address = ref();
let vote_data = ref([]);
// let vote_data = ref([]);
let approve_name = ref();
let aproveFalseMessage = ref();
if (type_fetch == "thn") {
get_address = `api/vote/get_for_thn/?login=${account_login}`;
if (props.type_fetch == "thanks") {
send_address = `api/vote/setthanks/`;
} else if (type_fetch == "bst") {
get_address = `api/vote/get_for_bst/?login=${account_login}&dep=${department_id}`;
} else if (props.type_fetch == "best") {
send_address = `api/vote/setbest/`;
}
const getVotesData = () => {
clearAxios.get(get_address).then((data) => {
vote_data.value = data.data;
});
};
// const getVotesData = () => {
// clearAxios.get(get_address).then((data) => {
// vote_data.value = data.data;
// });
// };
const approveCandidate = () => {
if (vote.value === 'False' || vote.value === '') {
@@ -84,34 +96,39 @@ export default {
}
dialog.value=true
}
const voteSend = () => {
window.location.reload();
clearAxios.post(send_address, {
console.log(vote.value);
axiosApiInstance.post(send_address, {
cand_name_id: vote.value,
department_user: department_name,
voted_user: account_login
// department_user: props.myrealdep.department,
},
{
headers: {
'Content-Type': 'application/json'
}
}
);
).then(res=>
{
dialog.value=false
window.location.reload()
});
};
getVotesData();
// getVotesData();
return {
approveCandidate,
voteSend,
vote_data,
// vote_data,
vote,
approve_name,
aproveFalseMessage,
dialog
}
},
+115 -55
View File
@@ -8,13 +8,13 @@
<v-col cols="6" justify="center" align="center">
<div class="flip-card" :class="{ 'flipped': isFlipped1 }">
<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>
<div class="justify-center">
<div>
<v-card class="vote-card-information" variant="flat">
<v-card class="vote-card-information" flat>
<v-card-text
class="justify-center align-center vote-card-information-title">
@@ -29,7 +29,7 @@
</div>
<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>
<div class="justify-center">
<div>
@@ -63,7 +63,7 @@
МОЙ КОЛЛЕГА САМЫЙ ЛУЧШИЙ
</v-card-title>
<v-card-text>
<vote-form :type_fetch="'bst'" />
<vote-form :type_fetch="'best'" :persons="mydepartment" :myrealdep="myrealdep" @voted="toggleFlip1" />
</v-card-text>
<!-- Кнопка активации поворота -->
<v-card-actions class="justify-center vote-button-back">
@@ -82,7 +82,7 @@
<v-col cols="6" justify="center" align="center">
<div class="flip-card" :class="{ 'flipped': isFlipped2 }">
<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-title class="vote-title">ХОЧУ СКАЗАТЬ СПАСИБО</v-card-title>
@@ -136,7 +136,7 @@
ХОЧУ СКАЗАТЬ СПАСИБО
</v-card-title>
<v-card-text>
<vote-form :type_fetch="'thn'" />
<vote-form :type_fetch="'thanks'" :persons="allsorted" :myrealdep="myrealdep" @voted="toggleFlip2" />
</v-card-text>
<!-- Кнопка активации поворота -->
<v-card-actions class="justify-center vote-button-back">
@@ -155,21 +155,23 @@
<h1>ПРИНЯЛИ УЧАСТИЕ В ГОЛОСОВАНИИ</h1>
</v-col> -->
<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-dialog>
<template v-slot:activator="{ props: VoteAdmin }">
<v-btn variant="transparent" v-bind="VoteAdmin"
class="procent-card-font pa-0">
<perc-bst />
<template v-slot:activator="{ props: activatorProps }">
<v-btn v-bind="activatorProps "
class="procent_card_font pa-0">
<span>{{ Math.round(voteresults.usersvotedbest.length*100/(mydepartment.length+1))}}%</span>
</v-btn>
</template>
<template v-slot:default="{ isActive }">
<v-row justify="center" class="h-100 admin-vote">
<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-btn variant="elevated" color="teal-darken-1"
<v-btn color="teal-darken-1"
@click="isActive.value = false">ЗАКРЫТЬ</v-btn>
</v-row>
@@ -178,22 +180,25 @@
</template>
</v-dialog>
</v-col>
<v-col v-else justify="center" align="center" cols="6" class="procent-card-font pa-0">
<!-- <perc-bst /> -->
<v-col v-else justify="center" align="center" cols="6" class="procent_card_font pa-0">
<span>{{ Math.round(voteresults.usersvotedbest.length*100/(mydepartment.length+1))}}%</span>
</v-col>
<v-col v-if="admin_panel" justify="center" align="center" cols="6" class=" pa-0">
<v-dialog>
<template v-slot:activator="{ props: VoteAdmin }">
<v-btn variant="transparent" v-bind="VoteAdmin"
class="procent-card-font pa-0"><perc-thn /></v-btn>
<template v-slot:activator="{ props: activatorProps }">
<v-btn v-bind="activatorProps "
class="procent_card_font pa-0">
<span>{{ Math.round(voteresults.uservotedthanks.length*100/(allsorted.length+1))}}%</span>
</v-btn>
</template>
<template v-slot:default="{ isActive }">
<v-row justify="center" class="h-100 admin-vote">
<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-btn variant="elevated" color="teal-darken-1"
<v-btn color="teal-darken-1"
@click="isActive.value = false">ЗАКРЫТЬ</v-btn>
</v-row>
@@ -202,9 +207,9 @@
</template>
</v-dialog>
</v-col>
<!-- <v-col v-else justify="center" align="center" cols="6" class="procent-card-font pa-0">
<perc-thn />
</v-col> -->
<v-col v-else justify="center" align="center" cols="6" class="procent_card_font pa-0">
<span>{{ Math.round(voteresults.uservotedthanks.length*100/(allsorted.length+1))}}%</span>
</v-col>
</v-col>
<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 ">
@@ -216,16 +221,15 @@
</v-row>
</template>
<script>
import { ref } from "vue";
import { clearAxios } from "@/utils/axios-api";
import { ref, computed } from "vue";
import { clearAxios, axiosApiInstance } from "@/utils/axios-api";
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 CountDown from '@/components/CountDown.vue';
import { useAccountStore } from '@/store/AccountStore';
let admin_panel = ref(false);
let account_login = useAccountStore().user.login;
let account_login = useAccountStore();
export default {
@@ -233,58 +237,110 @@ export default {
components: {
VoteForm,
CountDown,
PercBst,
PercThn,
VoteAdmin,
},
setup() {
const voted_best=ref([])
const full_list_pers=ref([])
let votedListBst = ref([]);
let votedListThn = ref([]);
let voted_thn = 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 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;
let finded_thn = votedListThn.find(({ voted_user }) => voted_user === account_login)
if (finded_thn.voted_user === account_login) {
voted_thn.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;
}
});
}
// }
// });
// 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 = () => {
isFlipped1.value = !isFlipped1.value;
};
const toggleFlip2 = () => {
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-001'].includes(account_login.user.login)) {
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(){
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 {
myrealdep,
allsorted,
mydepartment,
isFlipped1,
toggleFlip1,
isFlipped2,
@@ -293,6 +349,10 @@ export default {
admin_panel,
voted_bst,
voted_thn,
uservotedthanks,
uservotedbest,
voteresults
};
},
};
@@ -302,7 +362,7 @@ export default {
height: 600px !important;
}
.flip-card {}
.flip-card-inner {
display: flex;
@@ -341,7 +401,7 @@ export default {
}
.procent-card-font {
.procent_card_font {
font-size: 5em;
color: #008000;
}