diff --git a/src/front/src/components/vote/CurrentVote.vue b/src/front/src/components/vote/CurrentVote.vue index c4040b461..975f16248 100644 --- a/src/front/src/components/vote/CurrentVote.vue +++ b/src/front/src/components/vote/CurrentVote.vue @@ -1,81 +1,143 @@ @@ -86,7 +148,7 @@ import { useAccountStore } from "@/store/AccountStore"; export default { name: 'CurrentVote', - emits:['closer'], + emits: ['closer'], props: { data: { type: Object, @@ -96,24 +158,26 @@ export default { }, setup(props, { emit }) { const accountStore = useAccountStore(); - const messeger = ref({good:{icon:'mdi-check-circle',text:'Спасибо за Ваш голос!',color:"green"}, - bad:{icon:'mdi-alert',text:'Произошла ошибка!',color:"red"}, - key:'good' - }) + const messeger = ref({ + good: { icon: 'mdi-check-circle', text: 'Спасибо за Ваш голос!', color: "green" }, + bad: { icon: 'mdi-alert', text: 'Произошла ошибка!', color: "red" }, + key: 'good' + }) const activeStep = ref(0); const answers = ref(props.data.questions.map(() => null)); const isVoteSubmitted = ref(false); const isCurrentQuestionAnswered = computed(() => { - let q = props.data.questions.find(e=>e.numb==activeStep.value+1) - return result.value[q.id].length>0; + let q = props.data.questions.find(e => e.numb == activeStep.value + 1) + return result.value[q.id].length > 0; }); - const getres=()=>{ - return props.data.questions.reduce((acc,item)=> {acc[item.id]=[] - return acc - },{}) + const getres = () => { + return props.data.questions.reduce((acc, item) => { + acc[item.id] = [] + return acc + }, {}) } - const result=ref(getres()) + const result = ref(getres()) const nextStep = () => { if (activeStep.value < props.data.questions.length - 1) { activeStep.value++; @@ -126,26 +190,36 @@ export default { } }; - const submitVote = () => { - console.log(accountStore); + const submitVote = () => { + console.log(props.data); console.log("Отправляем данные голосования:", result.value); - let voteData= [] - for (let val of Object.values(result.value)){ - val.forEach(e=> voteData.push({answer:e,comment:null, user:accountStore.user.id })) + let voteData = [] + for (let val of Object.values(result.value)) { + val.forEach(e => voteData.push({ answer: e, comment: null, user: accountStore.user.id })) } - - axiosApiInstance.post('api/vote/voteresultcreate/',voteData).then(res=>{ - messeger.value.key='good' - console.log(res); - }).catch(e=> { + + axiosApiInstance.post('api/vote/voteresultcreate/', voteData).then(res => { + messeger.value.key = 'good' + + }).catch(e => { console.log(e); - messeger.value.key='bad'} - - ).finally(()=>isVoteSubmitted.value = true) - + messeger.value.key = 'bad' + } + + ).finally(() => isVoteSubmitted.value = true) + }; + const activepick = ref(null) + const dialog=ref(false) + const opendialog=(val)=>{ + dialog.value=true + activepick.value=val + } return { + activepick, + opendialog, + dialog, messeger, activeStep, answers, diff --git a/src/front/src/router/index.js b/src/front/src/router/index.js index 7e38d2556..afaf7e1aa 100644 --- a/src/front/src/router/index.js +++ b/src/front/src/router/index.js @@ -160,7 +160,11 @@ const routes = [ path: "/vote/voting/:id", name: "Voting", component: () => - import("@/views/VoteHomePage.vue") + import("@/views/VoteHomePage.vue"), + meta: { + title: "Голосование", + ico: "mdi-account", + }, }, { path: "/vote/edit-vote/:id", diff --git a/src/front/src/views/VoteHomePage.vue b/src/front/src/views/VoteHomePage.vue index 8b9a0beec..fa53d614d 100644 --- a/src/front/src/views/VoteHomePage.vue +++ b/src/front/src/views/VoteHomePage.vue @@ -72,17 +72,12 @@ - - - - - mdi-close-thick - - - + + + - - + + @@ -172,6 +167,7 @@ export default { resultsModal.value = false; selectedVoting.value = null; router.push({ name: "VoteHomePage" }); + updating("active"); }; const openModal = async (type, voting) => {