сохранялка
This commit is contained in:
1 parent
bd60ac7578
commit
5f70a73221
3 files changed
+15
-8
No files matched your search
@@ -82,6 +82,7 @@
|
||||
<script>
|
||||
import { axiosApiInstance } from "@/utils/axios-api";
|
||||
import { computed, ref } from "vue";
|
||||
import { useAccountStore } from "@/store/AccountStore";
|
||||
|
||||
export default {
|
||||
name: 'CurrentVote',
|
||||
@@ -94,6 +95,7 @@ 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'
|
||||
@@ -125,17 +127,18 @@ export default {
|
||||
};
|
||||
|
||||
const submitVote = () => {
|
||||
result.value
|
||||
console.log(accountStore);
|
||||
console.log("Отправляем данные голосования:", result.value);
|
||||
let voteData= []
|
||||
for (let val of Object.values(result.value)){
|
||||
val.forEach(e=> voteData.push({answer_id:e,comment:null}))
|
||||
val.forEach(e=> voteData.push({answer:e,comment:null, user:accountStore.user.id }))
|
||||
}
|
||||
console.log(voteData);
|
||||
|
||||
axiosApiInstance.post('api/vote/voteresultcreate/',voteData).then(res=>{
|
||||
messeger.value.key='good'
|
||||
|
||||
console.log(res);
|
||||
}).catch(e=> {
|
||||
console.log(e);
|
||||
messeger.value.key='bad'}
|
||||
|
||||
).finally(()=>isVoteSubmitted.value = true)
|
||||
|
||||
Reference in new issue
Block a user