изменения в редакторе для голосования
This commit is contained in:
1 parent
c35882b0af
commit
a5d22094f7
2 files changed
+155
-151
No files matched your search
@@ -25,58 +25,54 @@
|
||||
<v-card-text>
|
||||
<v-text-field
|
||||
v-model="form.title"
|
||||
:rules="[rules.required]"
|
||||
label="Название голосования"
|
||||
outlined
|
||||
:rules="[rules.required]"
|
||||
></v-text-field>
|
||||
<v-textarea
|
||||
v-model="form.description"
|
||||
:rules="[rules.required]"
|
||||
label="Описание"
|
||||
outlined
|
||||
:rules="[rules.required]"
|
||||
></v-textarea>
|
||||
|
||||
<v-text-field
|
||||
:placeholder="`${form.startDate.toLocaleDateString()} ${form.startDate.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}`"
|
||||
:value="`${form.startDate.toLocaleDateString()} ${form.startDate.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}`"
|
||||
color="teal-darken-4"
|
||||
label="Дата и время начала"
|
||||
persistentPlaceholder
|
||||
readonly
|
||||
>
|
||||
<v-menu activator="parent">
|
||||
<div class="d-flex ga-xl-16">
|
||||
<div>
|
||||
<v-date-picker
|
||||
v-model="form.startDate"
|
||||
color="teal-darken-4"
|
||||
hideHeader
|
||||
hideWeekdays
|
||||
v-model="form.startDate"
|
||||
color="teal-darken-4"
|
||||
hide-weekdays
|
||||
title="дата начала"
|
||||
/>
|
||||
</v-menu>
|
||||
<v-btn flat icon style="background-color: transparent">
|
||||
<v-icon>mdi-calendar-clock</v-icon>
|
||||
</v-btn>
|
||||
</v-text-field>
|
||||
<v-select
|
||||
v-model="selectedTimeStart"
|
||||
:items="timeOptions"
|
||||
dense
|
||||
label="Время начала"
|
||||
outlined
|
||||
prepend-icon="mdi-calendar-clock"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<v-date-picker
|
||||
v-model="form.endDate"
|
||||
color="teal-darken-4"
|
||||
hide-weekdays
|
||||
title="дата окончания"
|
||||
/>
|
||||
<v-select
|
||||
v-model="selectedTimeEnd"
|
||||
:items="timeOptions"
|
||||
dense
|
||||
label="Время окончания"
|
||||
outlined
|
||||
prepend-icon="mdi-calendar-clock"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<v-text-field
|
||||
: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' })}`"
|
||||
color="teal-darken-4"
|
||||
label="Дата и время окончания"
|
||||
persistentPlaceholder
|
||||
readonly
|
||||
>
|
||||
<v-menu activator="parent">
|
||||
<v-date-picker
|
||||
v-model="form.endDate"
|
||||
color="teal-darken-4"
|
||||
hideHeader
|
||||
hideWeekdays
|
||||
/>
|
||||
</v-menu>
|
||||
<v-btn flat icon style="background-color: transparent">
|
||||
<v-icon>mdi-calendar-clock</v-icon>
|
||||
</v-btn>
|
||||
</v-text-field>
|
||||
<pre>начало {{ form.startDate }}</pre>
|
||||
<pre>окончание {{ form.endDate }}</pre>
|
||||
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
@@ -95,92 +91,92 @@
|
||||
<v-text-field
|
||||
v-model="question.text"
|
||||
:label="'Вопрос ' + (index + 1)"
|
||||
outlined
|
||||
:rules="[rules.required]"
|
||||
outlined
|
||||
></v-text-field>
|
||||
<v-btn color="error" icon @click="removeQuestion(index)">
|
||||
<v-icon>mdi-delete</v-icon>
|
||||
</v-btn>
|
||||
</div>
|
||||
<v-file-input
|
||||
v-model="question.image"
|
||||
accept="image/*"
|
||||
label="Картинка для вопроса"
|
||||
outlined
|
||||
v-model="question.image"
|
||||
accept="image/*"
|
||||
label="Картинка для вопроса"
|
||||
outlined
|
||||
></v-file-input>
|
||||
<v-select
|
||||
v-model="question.type"
|
||||
:items="questionTypes"
|
||||
label="Тип ответа"
|
||||
outlined
|
||||
v-model="question.type"
|
||||
:items="questionTypes"
|
||||
label="Тип ответа"
|
||||
outlined
|
||||
></v-select>
|
||||
<v-switch
|
||||
v-model="question.multiChoice"
|
||||
color="teal-darken-4"
|
||||
:label="`Множественный выбор: ${question.multiChoice ? 'да' : 'нет'}`"
|
||||
:false-value="false"
|
||||
:label="`Множественный выбор: ${question.multiChoice ? 'да' : 'нет'}`"
|
||||
:true-value="true"
|
||||
color="teal-darken-4"
|
||||
hide-details
|
||||
></v-switch>
|
||||
<v-card-text>
|
||||
<div v-if="question.type === 'Ввести вручную'">
|
||||
<div
|
||||
v-for="(answer, index) in question.answers"
|
||||
:key="index"
|
||||
class="d-flex align-start mb-4"
|
||||
>
|
||||
<v-text-field
|
||||
v-model="answer.text"
|
||||
:label="'Ответ ' + (index + 1)"
|
||||
class="mr-4"
|
||||
outlined
|
||||
:rules="[rules.required]"
|
||||
></v-text-field>
|
||||
<v-file-input
|
||||
v-model="answer.image"
|
||||
accept="image/*"
|
||||
dense
|
||||
hide-details
|
||||
label="Картинка"
|
||||
outlined
|
||||
></v-file-input>
|
||||
<v-btn color="error" icon @click="removeAnswer(index)">
|
||||
<v-icon>mdi-delete</v-icon>
|
||||
</v-btn>
|
||||
</div>
|
||||
<v-btn color="teal-darken-4" @click="addAnswer">Добавить ответ</v-btn>
|
||||
</div>
|
||||
<div v-else>
|
||||
<v-autocomplete
|
||||
v-model="currentQuestion.selectedEmployees"
|
||||
:items="groupedEmployees"
|
||||
item-title="fio"
|
||||
item-value="id"
|
||||
label="Выберите сотрудников"
|
||||
multiple
|
||||
outlined
|
||||
></v-autocomplete>
|
||||
<div
|
||||
v-for="(person, index) in currentQuestion.selectedEmployees"
|
||||
:key="person.id"
|
||||
class="d-flex align-center mb-4"
|
||||
>
|
||||
<v-chip>{{ findEmployeeById(person).fio }}</v-chip>
|
||||
<v-file-input
|
||||
v-model="currentQuestion.selectedEmployeeImages[person]"
|
||||
accept="image/*"
|
||||
class="ml-4"
|
||||
dense
|
||||
hide-details
|
||||
label="Картинка"
|
||||
outlined
|
||||
></v-file-input>
|
||||
<v-btn color="error" icon @click="removeEmployee(index)">
|
||||
<v-icon>mdi-delete</v-icon>
|
||||
</v-btn>
|
||||
</div>
|
||||
</div>
|
||||
</v-card-text>
|
||||
<v-card-text>
|
||||
<div v-if="question.type === 'Ввести вручную'">
|
||||
<div
|
||||
v-for="(answer, index) in question.answers"
|
||||
:key="index"
|
||||
class="d-flex align-start mb-4"
|
||||
>
|
||||
<v-text-field
|
||||
v-model="answer.text"
|
||||
:label="'Ответ ' + (index + 1)"
|
||||
:rules="[rules.required]"
|
||||
class="mr-4"
|
||||
outlined
|
||||
></v-text-field>
|
||||
<v-file-input
|
||||
v-model="answer.image"
|
||||
accept="image/*"
|
||||
dense
|
||||
hide-details
|
||||
label="Картинка"
|
||||
outlined
|
||||
></v-file-input>
|
||||
<v-btn color="error" icon @click="removeAnswer(index)">
|
||||
<v-icon>mdi-delete</v-icon>
|
||||
</v-btn>
|
||||
</div>
|
||||
<v-btn color="teal-darken-4" @click="addAnswer">Добавить ответ</v-btn>
|
||||
</div>
|
||||
<div v-else>
|
||||
<v-autocomplete
|
||||
v-model="currentQuestion.selectedEmployees"
|
||||
:items="groupedEmployees"
|
||||
item-title="fio"
|
||||
item-value="id"
|
||||
label="Выберите сотрудников"
|
||||
multiple
|
||||
outlined
|
||||
></v-autocomplete>
|
||||
<div
|
||||
v-for="(person, index) in currentQuestion.selectedEmployees"
|
||||
:key="person.id"
|
||||
class="d-flex align-center mb-4"
|
||||
>
|
||||
<v-chip>{{ findEmployeeById(person).fio }}</v-chip>
|
||||
<v-file-input
|
||||
v-model="currentQuestion.selectedEmployeeImages[person]"
|
||||
accept="image/*"
|
||||
class="ml-4"
|
||||
dense
|
||||
hide-details
|
||||
label="Картинка"
|
||||
outlined
|
||||
></v-file-input>
|
||||
<v-btn color="error" icon @click="removeEmployee(index)">
|
||||
<v-icon>mdi-delete</v-icon>
|
||||
</v-btn>
|
||||
</div>
|
||||
</div>
|
||||
</v-card-text>
|
||||
</div>
|
||||
<v-btn color="teal-darken-4" @click="addQuestion">Добавить вопрос</v-btn>
|
||||
</v-card-text>
|
||||
@@ -216,8 +212,8 @@
|
||||
<p><strong>Выбранные сотрудники:</strong></p>
|
||||
<ul>
|
||||
<li
|
||||
v-for="employeeId in question.selectedEmployees"
|
||||
:key="employeeId"
|
||||
v-for="employeeId in question.selectedEmployees"
|
||||
:key="employeeId"
|
||||
>
|
||||
{{ findEmployeeById(employeeId).fio }}
|
||||
</li>
|
||||
@@ -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="saveVoting">Сохранить</v-btn>
|
||||
</v-card-actions>
|
||||
<v-alert v-if="errorMessage" type="error" class="mb-4">
|
||||
<v-alert v-if="errorMessage" class="mb-4" type="error">
|
||||
{{ errorMessage }}
|
||||
</v-alert>
|
||||
</v-card>
|
||||
@@ -243,8 +239,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {computed, ref} from "vue";
|
||||
import { createVote } from "@/utils/axios-api";
|
||||
import {computed, ref, watch} from "vue";
|
||||
import {createVote} from "@/utils/axios-api";
|
||||
|
||||
export default {
|
||||
emits: ['updating'],
|
||||
@@ -272,11 +268,11 @@ export default {
|
||||
];
|
||||
|
||||
const currentQuestion = computed(() =>
|
||||
form.value.questions[currentQuestionIndex.value] || null
|
||||
form.value.questions[currentQuestionIndex.value] || null
|
||||
);
|
||||
|
||||
const findEmployeeById = (id) =>
|
||||
groupedEmployees.find((employee) => employee.id === id) || {};
|
||||
groupedEmployees.find((employee) => employee.id === id) || {};
|
||||
|
||||
const removeEmployee = (index) => {
|
||||
currentQuestion.value.selectedEmployees.splice(index, 1);
|
||||
@@ -342,6 +338,42 @@ export default {
|
||||
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 {
|
||||
step,
|
||||
form,
|
||||
@@ -359,29 +391,17 @@ export default {
|
||||
isVoteCreated,
|
||||
resetForm,
|
||||
rules,
|
||||
errorMessage
|
||||
errorMessage,
|
||||
timeOptions,
|
||||
selectedTimeStart,
|
||||
selectedTimeEnd
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.t-datetime-picker {
|
||||
.v-tabs-slider-wrapper {
|
||||
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;
|
||||
}
|
||||
.v-input--horizontal .v-input__prepend {
|
||||
margin-inline-end: 4px;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user