{{ key }}
{{ item_fio.fio }}
@@ -85,84 +86,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 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();
- 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
}
}
@@ -178,7 +315,7 @@ export default {
.scroll-leaders {
overflow-y: scroll;
- height: 95px;
+ height: 125px;
}
.scroll-window {
@@ -186,7 +323,5 @@ export default {
height: 378px;
}
-.perc-voted {
- font-size: 1.2em;
-}
+
\ No newline at end of file
diff --git a/src/front/src/components/vote/VoteForm.vue b/src/front/src/components/vote/VoteForm.vue
index 2a828ca20..971d9be03 100644
--- a/src/front/src/components/vote/VoteForm.vue
+++ b/src/front/src/components/vote/VoteForm.vue
@@ -2,19 +2,20 @@
-
+
+
-
-
-
+
+ Подтвердить выбор
-
+
Вы подтверждаете выбор?
После подтверждения внесение измений станет невозможным.
@@ -30,7 +31,7 @@
НЕТ
+ @click="dialog = false">НЕТ
@@ -41,39 +42,50 @@