P-92 добавление роутов в модалки + валидация формы конструктора
This commit is contained in:
1 parent
99dc314a1f
commit
135c5fb87d
5 files changed
+143
-96
No files matched your search
@@ -25,8 +25,18 @@
|
||||
<v-card flat>
|
||||
<v-card-title>Основная информация</v-card-title>
|
||||
<v-card-text>
|
||||
<v-text-field v-model="form.title" label="Название голосования" outlined></v-text-field>
|
||||
<v-textarea v-model="form.description" label="Описание" outlined></v-textarea>
|
||||
<v-text-field
|
||||
v-model="form.title"
|
||||
label="Название голосования"
|
||||
outlined
|
||||
:rules="[rules.required]"
|
||||
></v-text-field>
|
||||
<v-textarea
|
||||
v-model="form.description"
|
||||
label="Описание"
|
||||
outlined
|
||||
:rules="[rules.required]"
|
||||
></v-textarea>
|
||||
<v-text-field
|
||||
:placeholder="form.startDate.toLocaleDateString()"
|
||||
:value="form.startDate.toLocaleDateString()"
|
||||
@@ -87,6 +97,7 @@
|
||||
v-model="question.text"
|
||||
:label="'Вопрос ' + (index + 1)"
|
||||
outlined
|
||||
:rules="[rules.required]"
|
||||
></v-text-field>
|
||||
<v-file-input
|
||||
v-model="question.image"
|
||||
@@ -142,6 +153,7 @@
|
||||
:label="'Ответ ' + (index + 1)"
|
||||
class="mr-4"
|
||||
outlined
|
||||
:rules="[rules.required]"
|
||||
></v-text-field>
|
||||
<v-file-input
|
||||
v-model="answer.image"
|
||||
@@ -238,6 +250,9 @@
|
||||
<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">
|
||||
{{ errorMessage }}
|
||||
</v-alert>
|
||||
</v-card>
|
||||
</v-stepper-window-item>
|
||||
|
||||
@@ -264,6 +279,10 @@ export default {
|
||||
questions: [],
|
||||
});
|
||||
|
||||
const rules = {
|
||||
required: (value) => !!value || "Это поле обязательно для заполнения",
|
||||
};
|
||||
|
||||
const currentQuestionIndex = ref(0);
|
||||
const questionTypes = ["Ввести вручную", "Выбрать сотрудника"];
|
||||
|
||||
@@ -313,7 +332,13 @@ export default {
|
||||
}
|
||||
};
|
||||
|
||||
const errorMessage = ref("");
|
||||
|
||||
const saveVoting = async () => {
|
||||
if (!form.value.title || !form.value.description || form.value.questions < 1) {
|
||||
errorMessage.value = "Все обязательные поля должны быть заполнены";
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const response = await createVote(form.value);
|
||||
console.log("Голосование успешно создано:", response);
|
||||
@@ -351,7 +376,9 @@ export default {
|
||||
removeEmployee,
|
||||
saveVoting,
|
||||
isVoteCreated,
|
||||
resetForm
|
||||
resetForm,
|
||||
rules,
|
||||
errorMessage
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user