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