148 lines
4.7 KiB
Vue
148 lines
4.7 KiB
Vue
<template>
|
|
|
|
<v-form @submit="voteSend" ref="vot" >
|
|
<v-card id="scroll-window-chekbox" :height="heightel" elevation="0">
|
|
<!-- Форма голосования -->
|
|
|
|
<v-virtual-scroll :items="persons">
|
|
<template v-slot:default="{ item }">
|
|
<v-checkbox hide-details="true" v-model="vote" :id="item.fio" :value="item.fio" :label="item.fio" required />
|
|
</template>
|
|
</v-virtual-scroll>
|
|
</v-card>
|
|
|
|
<v-dialog max-width="500" v-model="dialog">
|
|
<!-- <template v-slot:activator>
|
|
|
|
</template> -->
|
|
<template v-slot:default>
|
|
<v-card class="justify-center align-center">
|
|
<v-card-title>Вы подтверждаете выбор?</v-card-title>
|
|
<v-card-text>После подтверждения внесение измений станет невозможным.</v-card-text>
|
|
<p>Выбранный кандидат</p>
|
|
<v-card-title v-if="approve_name">{{ approve_name }}</v-card-title>
|
|
<v-card-title v-else>Кандидат не выбран повторите голосование</v-card-title>
|
|
<v-col class="d-flex flex-rows justify-center align-center" cols="12">
|
|
<v-col cols="2">
|
|
<v-btn v-if="approve_name" variant="elevated" color="green-darken-1"
|
|
@click="voteSend">ДА</v-btn>
|
|
<v-btn v-else variant="elevated" color="green-darken-1" @click="voteSend"
|
|
disabled>ДА</v-btn>
|
|
</v-col>
|
|
<v-col cols="2">
|
|
<v-btn variant="elevated" color="red-darken-1"
|
|
@click="dialog = false">НЕТ</v-btn>
|
|
</v-col>
|
|
</v-col>
|
|
</v-card>
|
|
</template>
|
|
</v-dialog>
|
|
</v-form>
|
|
|
|
|
|
</template>
|
|
<script scope>
|
|
import { ref, computed } from "vue";
|
|
import { clearAxios, axiosApiInstance } from "@/utils/axios-api";
|
|
import { useAccountStore } from '@/store/AccountStore';
|
|
import Vote from "@/views/Vote.vue";
|
|
|
|
export default {
|
|
|
|
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 send_address = ref();
|
|
// let vote_data = ref([]);
|
|
let approve_name = ref();
|
|
let aproveFalseMessage = ref();
|
|
|
|
if (props.type_fetch == "thanks") {
|
|
|
|
send_address = `api/vote/setthanks/`;
|
|
} 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 approveCandidate = () => {
|
|
if (vote.value === 'False' || vote.value === '') {
|
|
approve_name.value = false;
|
|
|
|
} else {
|
|
approve_name.value = vote.value;
|
|
|
|
}
|
|
|
|
dialog.value=true
|
|
}
|
|
|
|
const voteSend = () => {
|
|
console.log(vote.value);
|
|
axiosApiInstance.post(send_address, {
|
|
cand_name_id: vote.value,
|
|
// department_user: props.myrealdep.department,
|
|
|
|
},
|
|
{
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
}
|
|
}
|
|
).then(res=>
|
|
{
|
|
dialog.value=false
|
|
window.location.reload()
|
|
});
|
|
};
|
|
|
|
|
|
// getVotesData();
|
|
const vot = ref(null)
|
|
const heightel = computed(()=>!!vot.value?vot.value.clientHeight:300)
|
|
return {
|
|
vot,
|
|
heightel,
|
|
approveCandidate,
|
|
voteSend,
|
|
// vote_data,
|
|
vote,
|
|
approve_name,
|
|
aproveFalseMessage,
|
|
dialog
|
|
}
|
|
},
|
|
|
|
|
|
|
|
|
|
}
|
|
</script>
|
|
<style>
|
|
#scroll-window-chekbox {
|
|
overflow-y: scroll !important;
|
|
}
|
|
</style> |