diff --git a/src/front/src/components/UI/Timer.vue b/src/front/src/components/UI/Timer.vue index 5d8898713..279cbda77 100644 --- a/src/front/src/components/UI/Timer.vue +++ b/src/front/src/components/UI/Timer.vue @@ -1,103 +1,102 @@ + \ No newline at end of file + diff --git a/src/front/src/components/about_inspection/open_vacancies/OpenVacancies.vue b/src/front/src/components/about_inspection/open_vacancies/OpenVacancies.vue index 5a70ad1b2..b4695c483 100644 --- a/src/front/src/components/about_inspection/open_vacancies/OpenVacancies.vue +++ b/src/front/src/components/about_inspection/open_vacancies/OpenVacancies.vue @@ -156,7 +156,7 @@
Сейчас вакансий нет,
- загляните позжет
diff --git a/src/front/src/components/vote/CurrentVote.vue b/src/front/src/components/vote/CurrentVote.vue index 74dca5e33..f04fd170f 100644 --- a/src/front/src/components/vote/CurrentVote.vue +++ b/src/front/src/components/vote/CurrentVote.vue @@ -1,127 +1,110 @@ \ No newline at end of file + diff --git a/src/front/src/components/vote/VoteConstructor.vue b/src/front/src/components/vote/VoteConstructor.vue index f4ffc5925..25f79c3ac 100644 --- a/src/front/src/components/vote/VoteConstructor.vue +++ b/src/front/src/components/vote/VoteConstructor.vue @@ -1,5 +1,5 @@ + + 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 @@ @@ -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 }; }, };