vote-pre-send
This commit is contained in:
1 parent
1638833dd8
commit
16b331a901
2 files changed
+29
-13
No files matched your search
@@ -3,7 +3,7 @@
|
||||
<v-stepper v-model="activeStep">
|
||||
<v-card-title>{{ data.name }}</v-card-title>
|
||||
<v-card-subtitle>{{ data.description }}</v-card-subtitle>
|
||||
{{ data }}
|
||||
|
||||
<!-- Шаги голосования -->
|
||||
<v-stepper-header>
|
||||
<v-stepper-item
|
||||
@@ -27,7 +27,7 @@
|
||||
<v-card-text>
|
||||
<!-- Ответы на вопрос -->
|
||||
|
||||
{{ result }}--
|
||||
|
||||
<v-row v-for="(answer, id) in question.answers" :key="id">
|
||||
<v-checkbox
|
||||
v-model="result[question.id]"
|
||||
@@ -71,17 +71,21 @@
|
||||
<template v-else>
|
||||
<v-row align="center" justify="center" style="height: 50vh;">
|
||||
<v-col class="text-center" cols="12">
|
||||
<v-icon color="green" size="64">mdi-check-circle</v-icon>
|
||||
<h2>Спасибо за Ваш голос!</h2>
|
||||
<v-icon :color="messeger[messeger.key].color" :icon="messeger[messeger.key].icon" size="64"/>
|
||||
<h2>{{ messeger[messeger.key].text }}</h2>
|
||||
<v-btn @click="$emit('closer')" class="ma-3 ">Закрыть</v-btn>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { axiosApiInstance } from "@/utils/axios-api";
|
||||
import { computed, ref } from "vue";
|
||||
|
||||
export default {
|
||||
name: 'CurrentVote',
|
||||
emits:['closer'],
|
||||
props: {
|
||||
data: {
|
||||
type: Object,
|
||||
@@ -90,6 +94,10 @@ export default {
|
||||
},
|
||||
},
|
||||
setup(props, { emit }) {
|
||||
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);
|
||||
@@ -116,19 +124,26 @@ export default {
|
||||
}
|
||||
};
|
||||
|
||||
const submitVote = () => {
|
||||
// const voteData = props.data.questions.map((question, index) => ({
|
||||
// question: question.id,
|
||||
// answer: answers.value[index],
|
||||
// }));
|
||||
const submitVote = () => {
|
||||
result.value
|
||||
console.log("Отправляем данные голосования:", result.value);
|
||||
|
||||
// isVoteSubmitted.value = true;
|
||||
// emit("submit", voteData);
|
||||
let voteData= []
|
||||
for (let val of Object.values(result.value)){
|
||||
val.forEach(e=> voteData.push({answer_id:e,comment:null}))
|
||||
}
|
||||
console.log(voteData);
|
||||
axiosApiInstance.post('api/voter',voteData).then(res=>{
|
||||
messeger.value.key='good'
|
||||
|
||||
}).catch(e=> {
|
||||
messeger.value.key='bad'}
|
||||
|
||||
).finally(()=>isVoteSubmitted.value = true)
|
||||
|
||||
};
|
||||
|
||||
return {
|
||||
messeger,
|
||||
activeStep,
|
||||
answers,
|
||||
isCurrentQuestionAnswered,
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
<v-card-text class="pt-0">
|
||||
<CurrentVote :data="res" />
|
||||
<CurrentVote :data="res" @closer="closeModal"/>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
@@ -123,6 +123,7 @@ import { formatDate } from "@vueuse/shared";
|
||||
|
||||
export default {
|
||||
methods: { formatDate },
|
||||
|
||||
components: { CurrentVote, VoteConstructor, VoteCardVue },
|
||||
setup() {
|
||||
const currentTab = ref("current");
|
||||
|
||||
Reference in new issue
Block a user