Merge branch 'Vit' into dev-denzel
This commit is contained in:
commit
5478986520
3 files changed
+33
-23
No files matched your search
@@ -3,3 +3,4 @@ from .models import *
|
||||
|
||||
admin.site.register(Vote)
|
||||
admin.site.register(Question)
|
||||
admin.site.register(Answer)
|
||||
@@ -3,39 +3,40 @@
|
||||
<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
|
||||
v-for="(question, index) in data.questions"
|
||||
:key="index"
|
||||
:complete="index < activeStep"
|
||||
:step="index + 1"
|
||||
v-for="question in data.questions"
|
||||
:key="question.numb"
|
||||
:complete="question.numb < activeStep"
|
||||
:step="question.numb"
|
||||
>
|
||||
Вопрос {{ index + 1 }}
|
||||
Вопрос {{ question.numb }}
|
||||
</v-stepper-item>
|
||||
</v-stepper-header>
|
||||
|
||||
<v-stepper-window>
|
||||
<v-stepper-window-item
|
||||
v-for="(question, index) in data.questions"
|
||||
:key="index"
|
||||
:step="index + 1"
|
||||
:key="question.numb"
|
||||
:step="question.numb"
|
||||
>
|
||||
<v-card flat>
|
||||
<v-card-title>{{ question.question }}</v-card-title>
|
||||
<v-card-text>
|
||||
<!-- Ответы на вопрос -->
|
||||
|
||||
{{ result }}--
|
||||
<v-row v-for="(answer, id) in question.answers" :key="id">
|
||||
<v-checkbox
|
||||
v-model="answers[index]"
|
||||
:value="answer.answer"
|
||||
v-model="result[question.id]"
|
||||
:label="answer.answer"
|
||||
:value="answer.id"
|
||||
color="teal-darken-4"
|
||||
hide-details
|
||||
>
|
||||
<template #label>
|
||||
<span class="text-black">{{ answer.answer }}</span>
|
||||
</template>
|
||||
|
||||
</v-checkbox>
|
||||
</v-row>
|
||||
</v-card-text>
|
||||
@@ -94,9 +95,15 @@ export default {
|
||||
const isVoteSubmitted = ref(false);
|
||||
|
||||
const isCurrentQuestionAnswered = computed(() => {
|
||||
return !!answers.value[activeStep.value];
|
||||
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 result=ref(getres())
|
||||
const nextStep = () => {
|
||||
if (activeStep.value < props.data.questions.length - 1) {
|
||||
activeStep.value++;
|
||||
@@ -110,14 +117,15 @@ export default {
|
||||
};
|
||||
|
||||
const submitVote = () => {
|
||||
const voteData = props.data.questions.map((question, index) => ({
|
||||
question: question.question,
|
||||
answer: answers.value[index],
|
||||
}));
|
||||
console.log("Отправляем данные голосования:", voteData);
|
||||
// const voteData = props.data.questions.map((question, index) => ({
|
||||
// question: question.id,
|
||||
// answer: answers.value[index],
|
||||
// }));
|
||||
result.value
|
||||
console.log("Отправляем данные голосования:", result.value);
|
||||
|
||||
isVoteSubmitted.value = true;
|
||||
emit("submit", voteData);
|
||||
// isVoteSubmitted.value = true;
|
||||
// emit("submit", voteData);
|
||||
};
|
||||
|
||||
return {
|
||||
@@ -128,6 +136,7 @@ export default {
|
||||
prevStep,
|
||||
submitVote,
|
||||
isVoteSubmitted,
|
||||
result
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-card-text class="">{{ voteCard.description }}</v-card-text>
|
||||
<TimerUI :voteTime="{dateend:voteCard.dateend,datestart:voteCard.datestart}" @changeBtn="(time) => timeChange = time"/>
|
||||
<Timer :voteTime="{dateend:voteCard.dateend,datestart:voteCard.datestart}" @changeBtn="(time) => timeChange = time"/>
|
||||
<v-card-actions class="justify-space-between mt-4 pb-2">
|
||||
<v-btn
|
||||
:disabled="voteCard.is_passed || timeChange"
|
||||
|
||||
Reference in new issue
Block a user