-
Дата начала:
+
+
+
Дата и время начала:
-
-
Дата окончания:
+
+
Дата и время окончания:
-
+
Далее
@@ -148,7 +150,7 @@
>
+
-
+
+
+
diff --git a/src/front/src/utils/axios-api.js b/src/front/src/utils/axios-api.js
index dbd1bc69d..3973b0652 100644
--- a/src/front/src/utils/axios-api.js
+++ b/src/front/src/utils/axios-api.js
@@ -93,22 +93,20 @@ async function getVotes(status) {
}
}
-
async function createVote(voteData) {
try {
-
+
const formData = new FormData();
voteData.questions.forEach(question => {
formData.append('questionsfiles', question.image)
- console.log(question.image);
if(!!question.image){
const {name,size,lastModified}=question.image
question.image={name,size,lastModified}
}
-
+
question.answers.forEach(answer=>{
-
+
formData.append('answersfiles', answer.image)
if(!!answer.image){
const {name,size,lastModified}=answer.image
@@ -125,8 +123,8 @@ async function createVote(voteData) {
formData.append('startDate', new Date(voteData.startDate).toISOString());
formData.append('endDate', new Date(voteData.endDate).toISOString());
formData.append('questions', JSON.stringify(voteData.questions));
-
-
+
+
const response = await axiosApiInstance.post('/api/vote/votecreate/', formData, {
headers: {'Content-Type': 'multipart/form-data'},
});
@@ -188,9 +186,6 @@ async function getEmployees() {
}
}
-getEmployees()
- .then(r => console.log(r))
-
export {
axiosApiInstance,
diff --git a/src/front/src/views/VoteHomePage.vue b/src/front/src/views/VoteHomePage.vue
index fa53d614d..8e7f678ba 100644
--- a/src/front/src/views/VoteHomePage.vue
+++ b/src/front/src/views/VoteHomePage.vue
@@ -1,79 +1,56 @@
-
-
- Голосования
-
-
- Текущие голосования
- Завершенные голосования
- Создать новое голосование
-
-
-
-
-
+
+
+
+
+ {{ x.text }}
+
+
+
+
+
-
-
-
+
+
+
+
openModal('vote', voting)"
@openEditVoteModal="(voting) => openModal('edit', voting)"
+ @openResultModal="(voting) => openModal('results', voting)"
@deleteVoting="deleteVoting"
/>
-
-
+
-
-
-
-
-
- {{ voting.title }}
-
- Завершено: {{ formatDate(voting.endDate) }}
-
-
- openModal('results', voting)">
- Результаты
-
-
- mdi-delete
-
-
-
-
-
-
-
+
-
+
-
+
+
+
-
+
@@ -97,13 +74,22 @@
Результаты голосования: {{ selectedVoting?.title }}
- Здесь отображаются результаты голосования...
+
+
Закрыть
+
+
+
+
+
+
+
+
@@ -113,15 +99,30 @@ import VoteConstructor from "@/components/vote/VoteConstructor.vue";
import CurrentVote from "@/components/vote/CurrentVote.vue";
import VoteCardVue from "@/components/vote/VoteCard.vue";
import { useRoute, useRouter } from "vue-router";
+import VoteResult from "@/components/vote/VoteResult.vue";
import { deleteVote, getVoteDetail, getVotes } from "@/utils/axios-api";
import { formatDate } from "@vueuse/shared";
export default {
methods: { formatDate },
- components: { CurrentVote, VoteConstructor, VoteCardVue },
+ components: { CurrentVote, VoteConstructor, VoteCardVue, VoteResult },
setup() {
- const currentTab = ref("current");
+ const tabs=[
+ {value:"active", text:'Текущие голосования'},
+ {value:"completed", text:'Завершенные голосования'},
+ {value:"constructor", text:'Создать новое голосование'},
+
+ ]
+
+
+ const testResults = [
+ {name: 'Дональд Трамп', votes: 99},
+ {name: 'Иван Иванов', votes: 30},
+ {name: 'Аркадий Упукник', votes: 95},
+ ];
+
+ const currentTab = ref("active");
const votes = ref([]);
const router = useRouter();
const route = useRoute();
@@ -139,17 +140,13 @@ export default {
const resultsModal = ref(false);
const selectedVoting = ref(null);
- const sortedCurrentVotes = computed(() =>
- votes.value
- .filter((v) => new Date(v.dateend) > new Date())
- .sort((a, b) => new Date(a.dateend) - new Date(b.dateend))
+ const sortedVotes = computed(() =>{
+ return currentTab.value=='active'?votes.value.sort((a, b) => new Date(a.dateend) - new Date(b.dateend)):votes.value.sort((a, b) => new Date(b.dateend) - new Date(a.dateend))
+ }
+
);
- const sortedCompletedVotes = computed(() =>
- votes.value
- .filter((v) => new Date(v.dateend) <= new Date())
- .sort((a, b) => new Date(b.dateend) - new Date(a.dateend))
- );
+
const loadVoteDetails = async (id) => {
try {
@@ -194,6 +191,12 @@ export default {
console.error("Ошибка при удалении голосования:", error);
}
};
+ watch(currentTab,
+ async () =>{
+
+ votes.value=[]
+ await updating(currentTab.value)}
+ )
watch(
() => route,
@@ -217,8 +220,8 @@ export default {
return {
currentTab,
votes,
- sortedCurrentVotes,
- sortedCompletedVotes,
+ sortedVotes,
+ testResults,
voteModal,
editVoteModal,
resultsModal,
@@ -228,6 +231,7 @@ export default {
deleteVoting,
updating,
res,
+ tabs
};
},
};