d
This commit is contained in:
1 parent
c9626e61b8
commit
7f7b30fa8c
8 files changed
+400
-251
No files matched your search
@@ -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>
|
||||
@@ -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
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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
@@ -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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user