изменения в редакторе для голосования
This commit is contained in:
1 parent
c35882b0af
commit
a5d22094f7
2 files changed
+80
-76
No files matched your search
@@ -25,58 +25,54 @@
|
|||||||
<v-card-text>
|
<v-card-text>
|
||||||
<v-text-field
|
<v-text-field
|
||||||
v-model="form.title"
|
v-model="form.title"
|
||||||
|
:rules="[rules.required]"
|
||||||
label="Название голосования"
|
label="Название голосования"
|
||||||
outlined
|
outlined
|
||||||
:rules="[rules.required]"
|
|
||||||
></v-text-field>
|
></v-text-field>
|
||||||
<v-textarea
|
<v-textarea
|
||||||
v-model="form.description"
|
v-model="form.description"
|
||||||
|
:rules="[rules.required]"
|
||||||
label="Описание"
|
label="Описание"
|
||||||
outlined
|
outlined
|
||||||
:rules="[rules.required]"
|
|
||||||
></v-textarea>
|
></v-textarea>
|
||||||
|
|
||||||
<v-text-field
|
<div class="d-flex ga-xl-16">
|
||||||
:placeholder="`${form.startDate.toLocaleDateString()} ${form.startDate.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}`"
|
<div>
|
||||||
:value="`${form.startDate.toLocaleDateString()} ${form.startDate.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}`"
|
|
||||||
color="teal-darken-4"
|
|
||||||
label="Дата и время начала"
|
|
||||||
persistentPlaceholder
|
|
||||||
readonly
|
|
||||||
>
|
|
||||||
<v-menu activator="parent">
|
|
||||||
<v-date-picker
|
<v-date-picker
|
||||||
v-model="form.startDate"
|
v-model="form.startDate"
|
||||||
color="teal-darken-4"
|
color="teal-darken-4"
|
||||||
hideHeader
|
hide-weekdays
|
||||||
hideWeekdays
|
title="дата начала"
|
||||||
/>
|
/>
|
||||||
</v-menu>
|
<v-select
|
||||||
<v-btn flat icon style="background-color: transparent">
|
v-model="selectedTimeStart"
|
||||||
<v-icon>mdi-calendar-clock</v-icon>
|
:items="timeOptions"
|
||||||
</v-btn>
|
dense
|
||||||
</v-text-field>
|
label="Время начала"
|
||||||
|
outlined
|
||||||
<v-text-field
|
prepend-icon="mdi-calendar-clock"
|
||||||
:placeholder="`${form.endDate.toLocaleDateString()} ${form.endDate.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}`"
|
/>
|
||||||
:value="`${form.endDate.toLocaleDateString()} ${form.endDate.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}`"
|
</div>
|
||||||
color="teal-darken-4"
|
<div>
|
||||||
label="Дата и время окончания"
|
|
||||||
persistentPlaceholder
|
|
||||||
readonly
|
|
||||||
>
|
|
||||||
<v-menu activator="parent">
|
|
||||||
<v-date-picker
|
<v-date-picker
|
||||||
v-model="form.endDate"
|
v-model="form.endDate"
|
||||||
color="teal-darken-4"
|
color="teal-darken-4"
|
||||||
hideHeader
|
hide-weekdays
|
||||||
hideWeekdays
|
title="дата окончания"
|
||||||
/>
|
/>
|
||||||
</v-menu>
|
<v-select
|
||||||
<v-btn flat icon style="background-color: transparent">
|
v-model="selectedTimeEnd"
|
||||||
<v-icon>mdi-calendar-clock</v-icon>
|
:items="timeOptions"
|
||||||
</v-btn>
|
dense
|
||||||
</v-text-field>
|
label="Время окончания"
|
||||||
|
outlined
|
||||||
|
prepend-icon="mdi-calendar-clock"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<pre>начало {{ form.startDate }}</pre>
|
||||||
|
<pre>окончание {{ form.endDate }}</pre>
|
||||||
|
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
<v-card-actions>
|
<v-card-actions>
|
||||||
@@ -95,8 +91,8 @@
|
|||||||
<v-text-field
|
<v-text-field
|
||||||
v-model="question.text"
|
v-model="question.text"
|
||||||
:label="'Вопрос ' + (index + 1)"
|
:label="'Вопрос ' + (index + 1)"
|
||||||
outlined
|
|
||||||
:rules="[rules.required]"
|
:rules="[rules.required]"
|
||||||
|
outlined
|
||||||
></v-text-field>
|
></v-text-field>
|
||||||
<v-btn color="error" icon @click="removeQuestion(index)">
|
<v-btn color="error" icon @click="removeQuestion(index)">
|
||||||
<v-icon>mdi-delete</v-icon>
|
<v-icon>mdi-delete</v-icon>
|
||||||
@@ -116,10 +112,10 @@
|
|||||||
></v-select>
|
></v-select>
|
||||||
<v-switch
|
<v-switch
|
||||||
v-model="question.multiChoice"
|
v-model="question.multiChoice"
|
||||||
color="teal-darken-4"
|
|
||||||
:label="`Множественный выбор: ${question.multiChoice ? 'да' : 'нет'}`"
|
|
||||||
:false-value="false"
|
:false-value="false"
|
||||||
|
:label="`Множественный выбор: ${question.multiChoice ? 'да' : 'нет'}`"
|
||||||
:true-value="true"
|
:true-value="true"
|
||||||
|
color="teal-darken-4"
|
||||||
hide-details
|
hide-details
|
||||||
></v-switch>
|
></v-switch>
|
||||||
<v-card-text>
|
<v-card-text>
|
||||||
@@ -132,9 +128,9 @@
|
|||||||
<v-text-field
|
<v-text-field
|
||||||
v-model="answer.text"
|
v-model="answer.text"
|
||||||
:label="'Ответ ' + (index + 1)"
|
:label="'Ответ ' + (index + 1)"
|
||||||
|
:rules="[rules.required]"
|
||||||
class="mr-4"
|
class="mr-4"
|
||||||
outlined
|
outlined
|
||||||
:rules="[rules.required]"
|
|
||||||
></v-text-field>
|
></v-text-field>
|
||||||
<v-file-input
|
<v-file-input
|
||||||
v-model="answer.image"
|
v-model="answer.image"
|
||||||
@@ -230,7 +226,7 @@
|
|||||||
<v-btn color="teal-darken-4" size="medium" @click="step -= 1">Назад</v-btn>
|
<v-btn color="teal-darken-4" size="medium" @click="step -= 1">Назад</v-btn>
|
||||||
<v-btn color="teal-darken-4" size="medium" @click="saveVoting">Сохранить</v-btn>
|
<v-btn color="teal-darken-4" size="medium" @click="saveVoting">Сохранить</v-btn>
|
||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
<v-alert v-if="errorMessage" type="error" class="mb-4">
|
<v-alert v-if="errorMessage" class="mb-4" type="error">
|
||||||
{{ errorMessage }}
|
{{ errorMessage }}
|
||||||
</v-alert>
|
</v-alert>
|
||||||
</v-card>
|
</v-card>
|
||||||
@@ -243,8 +239,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {computed, ref} from "vue";
|
import {computed, ref, watch} from "vue";
|
||||||
import { createVote } from "@/utils/axios-api";
|
import {createVote} from "@/utils/axios-api";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
emits: ['updating'],
|
emits: ['updating'],
|
||||||
@@ -342,6 +338,42 @@ export default {
|
|||||||
isVoteCreated.value = false;
|
isVoteCreated.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const timeOptions = Array.from({length: 48}, (_, i) => {
|
||||||
|
const hours = String(Math.floor(i / 2)).padStart(2, "0");
|
||||||
|
const minutes = i % 2 === 0 ? "00" : "30";
|
||||||
|
return `${hours}:${minutes}`;
|
||||||
|
});
|
||||||
|
|
||||||
|
const selectedTimeStart = ref(
|
||||||
|
`${form.value.startDate.getHours().toString().padStart(2, "0")}:${form.value.startDate
|
||||||
|
.getMinutes()
|
||||||
|
.toString()
|
||||||
|
.padStart(2, "0")}`
|
||||||
|
);
|
||||||
|
|
||||||
|
const selectedTimeEnd = ref(
|
||||||
|
`${form.value.endDate.getHours().toString().padStart(2, "0")}:${form.value.endDate
|
||||||
|
.getMinutes()
|
||||||
|
.toString()
|
||||||
|
.padStart(2, "0")}`
|
||||||
|
);
|
||||||
|
|
||||||
|
watch(selectedTimeStart, () => {
|
||||||
|
updateStartDate()
|
||||||
|
})
|
||||||
|
watch(selectedTimeEnd, () => {
|
||||||
|
updateEndDate()
|
||||||
|
})
|
||||||
|
|
||||||
|
const updateStartDate = () => {
|
||||||
|
const [hours, minutes] = selectedTimeStart.value.split(":").map(Number);
|
||||||
|
form.value.startDate.setHours(hours, minutes);
|
||||||
|
};
|
||||||
|
const updateEndDate = () => {
|
||||||
|
const [hours, minutes] = selectedTimeStart.value.split(":").map(Number);
|
||||||
|
form.value.endDate.setHours(hours, minutes);
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
step,
|
step,
|
||||||
form,
|
form,
|
||||||
@@ -359,29 +391,17 @@ export default {
|
|||||||
isVoteCreated,
|
isVoteCreated,
|
||||||
resetForm,
|
resetForm,
|
||||||
rules,
|
rules,
|
||||||
errorMessage
|
errorMessage,
|
||||||
|
timeOptions,
|
||||||
|
selectedTimeStart,
|
||||||
|
selectedTimeEnd
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.t-datetime-picker {
|
.v-input--horizontal .v-input__prepend {
|
||||||
.v-tabs-slider-wrapper {
|
margin-inline-end: 4px;
|
||||||
top: 0;
|
|
||||||
}
|
|
||||||
.v-picker__title {
|
|
||||||
height: 90px;
|
|
||||||
}
|
|
||||||
.v-time-picker-title__time * {
|
|
||||||
font-size: 60px;
|
|
||||||
height: 60px;
|
|
||||||
}
|
|
||||||
.v-picker__body {
|
|
||||||
height: 290px;
|
|
||||||
}
|
|
||||||
.v-tabs-items {
|
|
||||||
height: 380px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -93,22 +93,6 @@ async function getVotes(status) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// getVotes('completed')
|
|
||||||
// .then(data => {
|
|
||||||
// console.log('Завершённые голосования:', data);
|
|
||||||
// })
|
|
||||||
// .catch(err => {
|
|
||||||
// console.error('Ошибка:', err);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// getVotes('active')
|
|
||||||
// .then(data => {
|
|
||||||
// console.log('Активные голосования:', data);
|
|
||||||
// })
|
|
||||||
// .catch(err => {
|
|
||||||
// console.error('Ошибка:', err);
|
|
||||||
// });
|
|
||||||
|
|
||||||
async function createVote(voteData, files) {
|
async function createVote(voteData, files) {
|
||||||
try {
|
try {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
|
|||||||
Reference in new issue
Block a user