Добавлены компоненты подсчета процентов в главном окне и кона подтверждения выбора
This commit is contained in:
1 parent
928a014ce4
commit
4168c7b100
7 files changed
+155
-20
No files matched your search
@@ -5,11 +5,13 @@ from django.db import models
|
|||||||
|
|
||||||
class ThanksVote(models.Model):
|
class ThanksVote(models.Model):
|
||||||
voted_user = models.CharField(blank=False, max_length=255)
|
voted_user = models.CharField(blank=False, max_length=255)
|
||||||
|
department_user = models.CharField(
|
||||||
|
blank=False, default=None, max_length=255)
|
||||||
cand_name = models.CharField(blank=False, default=None, max_length=255)
|
cand_name = models.CharField(blank=False, default=None, max_length=255)
|
||||||
vote_thanks_date = models.DateTimeField(auto_now_add=True)
|
vote_thanks_date = models.DateTimeField(auto_now_add=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
unique_together = ('voted_user', 'cand_name')
|
# unique_together = ('cand_name', 'voted_user')
|
||||||
verbose_name = "Голосование, хочу сказать спасибо!"
|
verbose_name = "Голосование, хочу сказать спасибо!"
|
||||||
verbose_name_plural = "Голосование, хочу сказать спасибо!"
|
verbose_name_plural = "Голосование, хочу сказать спасибо!"
|
||||||
|
|
||||||
@@ -19,11 +21,13 @@ class ThanksVote(models.Model):
|
|||||||
|
|
||||||
class BestVote(models.Model):
|
class BestVote(models.Model):
|
||||||
voted_user = models.CharField(blank=False, max_length=255)
|
voted_user = models.CharField(blank=False, max_length=255)
|
||||||
|
department_user = models.CharField(
|
||||||
|
blank=False, default=None, max_length=255)
|
||||||
cand_name = models.CharField(blank=False, default=None, max_length=255)
|
cand_name = models.CharField(blank=False, default=None, max_length=255)
|
||||||
vote_best_date = models.DateTimeField(auto_now_add=True)
|
vote_best_date = models.DateTimeField(auto_now_add=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
unique_together = ('voted_user', 'cand_name')
|
# unique_together = ('cand_name', 'voted_user')
|
||||||
verbose_name = "Голосование, мой коллега самый лучший"
|
verbose_name = "Голосование, мой коллега самый лучший"
|
||||||
verbose_name_plural = "Голосование, мой коллега самый лучший"
|
verbose_name_plural = "Голосование, мой коллега самый лучший"
|
||||||
|
|
||||||
|
|||||||
@@ -29,9 +29,11 @@ class GetForBst(APIView):
|
|||||||
class SetThanks(APIView):
|
class SetThanks(APIView):
|
||||||
def post(self, request):
|
def post(self, request):
|
||||||
voted_user = request.data['voted_user']
|
voted_user = request.data['voted_user']
|
||||||
|
department_user = request.data['department_user']
|
||||||
cand_name = request.data['cand_name_id']
|
cand_name = request.data['cand_name_id']
|
||||||
ThanksVote.objects.create(
|
ThanksVote.objects.create(
|
||||||
voted_user=voted_user,
|
voted_user=voted_user,
|
||||||
|
department_user=department_user,
|
||||||
cand_name=cand_name
|
cand_name=cand_name
|
||||||
)
|
)
|
||||||
return Response("Ваш голос добавлен!")
|
return Response("Ваш голос добавлен!")
|
||||||
@@ -39,7 +41,7 @@ class SetThanks(APIView):
|
|||||||
|
|
||||||
class GetThanks(APIView):
|
class GetThanks(APIView):
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
# Группировка товаров по имени и подсчет каждого
|
# Группировка кандидатов по имени и подсчет каждого
|
||||||
count_thanks = ThanksVote.objects.values(
|
count_thanks = ThanksVote.objects.values(
|
||||||
'cand_name').annotate(total=Count('id'))
|
'cand_name').annotate(total=Count('id'))
|
||||||
return Response(count_thanks)
|
return Response(count_thanks)
|
||||||
@@ -48,9 +50,11 @@ 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.data['voted_user']
|
||||||
|
department_user = request.data['department_user']
|
||||||
cand_name = request.data['cand_name_id']
|
cand_name = request.data['cand_name_id']
|
||||||
BestVote.objects.create(
|
BestVote.objects.create(
|
||||||
voted_user=voted_user,
|
voted_user=voted_user,
|
||||||
|
department_user=department_user,
|
||||||
cand_name=cand_name
|
cand_name=cand_name
|
||||||
)
|
)
|
||||||
return Response("Ваш голос добавлен!")
|
return Response("Ваш голос добавлен!")
|
||||||
@@ -58,6 +62,7 @@ class SetBest(APIView):
|
|||||||
|
|
||||||
class GetBest(APIView):
|
class GetBest(APIView):
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
count_bests = ThanksVote.objects.values(
|
# Группировка кандидатов по имени и подсчет каждого
|
||||||
|
count_bests = BestVote.objects.values(
|
||||||
'cand_name').annotate(total=Count('id'))
|
'cand_name').annotate(total=Count('id'))
|
||||||
return Response(count_bests)
|
return Response(count_bests)
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
<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>
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
<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>
|
||||||
@@ -7,10 +7,31 @@
|
|||||||
<v-checkbox v-model="vote" :id="item.fio" :value="item.fio" :label="item.fio" />
|
<v-checkbox v-model="vote" :id="item.fio" :value="item.fio" :label="item.fio" />
|
||||||
</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-btn variant="elevated" color="teal-darken-1" type="submit">ПРОГОЛОСОВАТЬ</v-btn>
|
<v-dialog max-width="500">
|
||||||
|
<template v-slot:activator="{ props: activatorProps }">
|
||||||
|
<v-btn variant="elevated" v-bind="activatorProps" color="teal-darken-1"
|
||||||
|
@click="approveCandidate">Подтвердить выбор</v-btn>
|
||||||
|
</template>
|
||||||
|
<template v-slot:default="{ isActive }">
|
||||||
|
<v-card class="justify-center align-center">
|
||||||
|
<v-card-title>Вы подтверждаете выбор?</v-card-title>
|
||||||
|
<v-card-text>После подтверждения внесение измений станет невозможным.</v-card-text>
|
||||||
|
<p>Выбранный кандидат</p>
|
||||||
|
<v-card-title>{{ approve_name }}</v-card-title>
|
||||||
|
<v-col class="d-flex flex-rows justify-center align-center" cols="12">
|
||||||
|
<v-col cols="2">
|
||||||
|
<v-btn variant="elevated" color="green-darken-1" @click="voteSend">ДА</v-btn>
|
||||||
|
</v-col>
|
||||||
|
<v-col cols="2">
|
||||||
|
<v-btn variant="elevated" color="red-darken-1" @click="isActive.value = false">НЕТ</v-btn>
|
||||||
|
</v-col>
|
||||||
|
</v-col>
|
||||||
|
</v-card>
|
||||||
|
</template>
|
||||||
|
</v-dialog>
|
||||||
|
<!-- <v-btn variant="elevated" color="teal-darken-1" type="submit">Подтвердить выбор</v-btn> -->
|
||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
</v-form>
|
</v-form>
|
||||||
</template>
|
</template>
|
||||||
@@ -25,11 +46,13 @@ export default {
|
|||||||
setup(props) {
|
setup(props) {
|
||||||
let account_login = useAccountStore().user.login;
|
let account_login = useAccountStore().user.login;
|
||||||
let department_id = useAccountStore().user.id_dict_department;
|
let department_id = useAccountStore().user.id_dict_department;
|
||||||
|
let department_name = useAccountStore().user.department
|
||||||
let type_fetch = props.type_fetch;
|
let type_fetch = props.type_fetch;
|
||||||
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();
|
||||||
|
|
||||||
if (type_fetch == "thn") {
|
if (type_fetch == "thn") {
|
||||||
get_address = `api/vote/get_for_thn/?login=${account_login}`;
|
get_address = `api/vote/get_for_thn/?login=${account_login}`;
|
||||||
@@ -45,9 +68,15 @@ export default {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const approveCandidate = () => {
|
||||||
|
approve_name.value = vote.value;
|
||||||
|
}
|
||||||
|
|
||||||
const voteSend = () => {
|
const voteSend = () => {
|
||||||
|
window.location.reload();
|
||||||
clearAxios.post(send_address, {
|
clearAxios.post(send_address, {
|
||||||
cand_name_id: vote.value,
|
cand_name_id: vote.value,
|
||||||
|
department_user: department_name,
|
||||||
voted_user: account_login
|
voted_user: account_login
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -58,11 +87,15 @@ export default {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
getVotesData();
|
getVotesData();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
approveCandidate,
|
||||||
voteSend,
|
voteSend,
|
||||||
vote_data,
|
vote_data,
|
||||||
vote,
|
vote,
|
||||||
|
approve_name,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -1,11 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-row class="justify-center ma-0 ">
|
<v-row class="justify-center ma-0 ">
|
||||||
<v-col
|
<v-col class="flex-column d-flex">
|
||||||
class="flex-column d-flex"
|
|
||||||
|
<news-crossroad />
|
||||||
>
|
|
||||||
|
|
||||||
<news-crossroad/>
|
|
||||||
|
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
@@ -13,18 +10,17 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
import {pagecounter} from '@/utils/universal_functions'
|
import { pagecounter } from '@/utils/universal_functions'
|
||||||
import newsCrossroad from '../components/news-crossroad.vue'
|
import newsCrossroad from '../components/news-crossroad.vue'
|
||||||
// import NewsListNews from '../components/news-list-news.vue'
|
// import NewsListNews from '../components/news-list-news.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
newsCrossroad
|
newsCrossroad
|
||||||
|
|
||||||
},
|
},
|
||||||
setup(){
|
setup() {
|
||||||
pagecounter()
|
pagecounter()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<v-col cols="12" class="h-15 d-flex justify-center proc-count_cell">
|
<v-col cols="12" class="h-15 d-flex justify-center proc-count_cell">
|
||||||
<v-col justify="center" align="center" cols="2">
|
<v-col justify="center" align="center" cols="2">
|
||||||
<v-card color="teal-darken-1" width="200" height="100" elevation="24" class="procent-card-font">
|
<v-card color="teal-darken-1" width="200" height="100" elevation="24" class="procent-card-font">
|
||||||
<span>45%</span>
|
<perc-bst />
|
||||||
</v-card>
|
</v-card>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col justify="center" align="center" cols="4" class="vote-cards_cell ">
|
<v-col justify="center" align="center" cols="4" class="vote-cards_cell ">
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
</v-col>
|
</v-col>
|
||||||
<v-col justify="center" align="center" cols="2">
|
<v-col justify="center" align="center" cols="2">
|
||||||
<v-card color="teal-darken-1" width="200" height="100" elevation="24" class="procent-card-font">
|
<v-card color="teal-darken-1" width="200" height="100" elevation="24" class="procent-card-font">
|
||||||
<span>55%</span>
|
<perc-thn />
|
||||||
</v-card>
|
</v-card>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-col>
|
</v-col>
|
||||||
@@ -105,7 +105,9 @@
|
|||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
import VoteForm from '@/components/VoteForm.vue';
|
import VoteForm from '@/components/vote/VoteForm.vue';
|
||||||
|
import PercBst from '@/components/vote/PercBst.vue';
|
||||||
|
import PercThn from '@/components/vote/PercThn.vue';
|
||||||
import CountDown from '@/components/CountDown.vue';
|
import CountDown from '@/components/CountDown.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -113,6 +115,8 @@ export default {
|
|||||||
components: {
|
components: {
|
||||||
VoteForm,
|
VoteForm,
|
||||||
CountDown,
|
CountDown,
|
||||||
|
PercBst,
|
||||||
|
PercThn,
|
||||||
},
|
},
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
|
|||||||
Reference in new issue
Block a user