Merge branch 'develop' into сja
This commit is contained in:
commit
cf527a6919
4 files changed
+212
-48
No files matched your search
@@ -142,13 +142,29 @@
|
||||
<div v-if="question.settings.choice === 'free'">
|
||||
<transition-group name="list" tag="div">
|
||||
<div v-for="(answer, ind) in question.answers" :key="ind" class="d-flex align-start mb-4">
|
||||
<v-text-field v-model="answer.text" :label="'Ответ ' + (ind + 1)"
|
||||
:rules="[rules.required]"
|
||||
class="mr-4" density="compact" variant="outlined"></v-text-field>
|
||||
<v-file-input v-model="answer.image" accept="image/*" dense density="compact" hide-details
|
||||
label="Картинка" variant="outlined"></v-file-input>
|
||||
<v-btn class="ms-1" color="error" icon="mdi-delete" size="small"
|
||||
@click="removeAnswer(index,ind)">
|
||||
<v-text-field
|
||||
v-model="answer.text"
|
||||
:label="'Ответ ' + (ind + 1)"
|
||||
:rules="[rules.required]"
|
||||
class="mr-4"
|
||||
density="compact"
|
||||
variant="outlined">
|
||||
</v-text-field>
|
||||
<v-file-input
|
||||
v-model="answer.image"
|
||||
accept="image/*"
|
||||
dense
|
||||
density="compact"
|
||||
hide-details
|
||||
label="Картинка"
|
||||
variant="outlined">
|
||||
</v-file-input>
|
||||
<v-btn
|
||||
class="ms-1"
|
||||
color="error"
|
||||
icon="mdi-delete"
|
||||
size="small"
|
||||
@click="removeAnswer(index, ind)">
|
||||
</v-btn>
|
||||
</div>
|
||||
</transition-group>
|
||||
@@ -425,17 +441,37 @@ export default {
|
||||
|
||||
const errorMessage = ref("");
|
||||
|
||||
const validateAnswers = () => {
|
||||
return form.value.questions.some((question) => {
|
||||
if (question.settings.choice === "free") {
|
||||
return question.answers.some(
|
||||
(answer) => !answer.text || answer.text.trim() === ""
|
||||
);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
const saveVoting = async () => {
|
||||
const hasEmptyQuestions = quests.value.includes(false);
|
||||
if (!form.value.title || !form.value.description || form.value.questions.length < 1 || hasEmptyQuestions) {
|
||||
errorMessage.value = "Все обязательные поля должны быть заполнены";
|
||||
const hasInvalidAnswers = validateAnswers();
|
||||
|
||||
if (
|
||||
!form.value.title ||
|
||||
!form.value.description ||
|
||||
form.value.questions.length < 1 ||
|
||||
hasEmptyQuestions ||
|
||||
hasInvalidAnswers
|
||||
) {
|
||||
errorMessage.value = "Все обязательные поля и ответы должны быть заполнены";
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await createVote(form.value);
|
||||
console.log("Голосование успешно создано:", response);
|
||||
isVoteCreated.value = true;
|
||||
emit('updating', 'active');
|
||||
emit("updating", "active");
|
||||
} catch (error) {
|
||||
console.error("Ошибка при создании голосования:", error);
|
||||
}
|
||||
@@ -469,8 +505,7 @@ export default {
|
||||
);
|
||||
|
||||
watch(form.value, () => {
|
||||
const hasEmptyQuestions = quests.value.includes(false);
|
||||
if (!form.value.title || !form.value.description || form.value.questions.length < 1 || hasEmptyQuestions) {
|
||||
if (!form.value.title || !form.value.description || form.value.questions.length < 1) {
|
||||
errorMessage.value = "Все обязательные поля должны быть заполнены";
|
||||
} else {
|
||||
errorMessage.value = "";
|
||||
@@ -483,12 +518,20 @@ export default {
|
||||
|
||||
watch(() => form.value.questions, updateQuests, { deep: true });
|
||||
|
||||
watch(() => form.value.questions, (newQuestions) => {
|
||||
const hasEmptyQuestions = newQuestions.some((q) => !q.text || q.text.trim() === "");
|
||||
errorMessage.value = hasEmptyQuestions
|
||||
? "Все вопросы должны быть заполнены"
|
||||
: "";
|
||||
}, { deep: true });
|
||||
watch(
|
||||
() => form.value.questions,
|
||||
(newQuestions) => {
|
||||
const hasEmptyQuestions = newQuestions.some((q) => !q.text || q.text.trim() === "");
|
||||
const hasInvalidAnswers = validateAnswers();
|
||||
|
||||
if (hasEmptyQuestions || hasInvalidAnswers) {
|
||||
errorMessage.value = "Все вопросы и ответы должны быть заполнены";
|
||||
} else {
|
||||
errorMessage.value = "";
|
||||
}
|
||||
},
|
||||
{ deep: true }
|
||||
);
|
||||
|
||||
|
||||
watch(selectedTimeStart, () => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<v-container style="height: 85vh">
|
||||
<v-container style="height: 85vh;">
|
||||
<div class="text-end">
|
||||
<v-btn class="" color="red-darken-1" density="compact" icon="mdi-close-thick" size="small"
|
||||
@click="$emit('closer')">
|
||||
@@ -35,7 +35,10 @@
|
||||
v-for="(winner, department) in getWinnersByDepartment(question).winnersByDepartment"
|
||||
:key="department"
|
||||
>
|
||||
<v-card class="cursor-pointer" @click="opendialogWinn(department, getWinnersByDepartment(question).groupedByDepartment[department])" style="max-height: 50vh; overflow-y: auto;">
|
||||
<v-card
|
||||
class="cursor-pointer"
|
||||
@click="opendialogWinn(department, getWinnersByDepartment(question).groupedByDepartment[department])"
|
||||
style="max-height: 50vh; overflow-y: auto;">
|
||||
<v-card-title>
|
||||
<strong class="text-teal-darken-4">{{ department }}</strong>
|
||||
</v-card-title>
|
||||
@@ -169,9 +172,8 @@
|
||||
v-for="(answer, index) in activeDepartmentResults.filter(el => el.count > 0)"
|
||||
:key="index"
|
||||
>
|
||||
|
||||
<p>
|
||||
<strong class="mr-4">{{ index + 1 }}.</strong>
|
||||
<strong class="mr-4">{{ index + 1 }}.</strong>
|
||||
<v-avatar v-if="answer.file === null && answer.employee"
|
||||
:image="checkremote(`${spravURL()}${answer.employee.login}.jpg`)"
|
||||
class="cursor-pointer"
|
||||
@@ -181,6 +183,7 @@
|
||||
@click.stop="opendialog(answer)"/>
|
||||
<strong class="ml-4">{{ answer.employee ? answer.employee.fio : answer.name }}</strong>:
|
||||
{{ answer.count }}
|
||||
{{ voteCount(answer.count) }}
|
||||
<template v-if="answer.employee">
|
||||
<br/>
|
||||
<small>Отдел: {{ answer.employee ? answer.employee.department : '' }}</small>
|
||||
@@ -268,7 +271,21 @@ export default {
|
||||
};
|
||||
|
||||
const getTopResults = (question) => {
|
||||
return [...question?.answers].sort((a, b) => b.count - a.count);
|
||||
const sortedAnswers = [...question.answers].sort((a, b) => b.count - a.count);
|
||||
|
||||
// Присваиваем одинаковые индексы для одинаковых значений count
|
||||
let rank = 1;
|
||||
let previousCount = null;
|
||||
return sortedAnswers.map((answer, index) => {
|
||||
if (answer.count !== previousCount) {
|
||||
rank = index + 1;
|
||||
previousCount = answer.count;
|
||||
}
|
||||
return {
|
||||
...answer,
|
||||
rank
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
const truncateText = (text, maxLength) => {
|
||||
|
||||
@@ -1,23 +1,130 @@
|
||||
<template>
|
||||
<v-row>
|
||||
<v-col
|
||||
class="text-h6 text-grey text-center align-self-center text--lighten-1 font-weight-light"
|
||||
>
|
||||
Тестирование
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-container>
|
||||
<v-tabs v-model="activeTab" class="mb-4 text-teal-darken-4">
|
||||
<v-tab>Назначенные ({{tests.length}})</v-tab>
|
||||
<v-tab>Завершенные</v-tab>
|
||||
<v-tab>Каталог</v-tab>
|
||||
</v-tabs>
|
||||
|
||||
<v-tabs-window v-model="activeTab">
|
||||
<v-tabs-window-item>
|
||||
<v-card class="mb-6" outlined>
|
||||
<v-card-title>
|
||||
Назначенные
|
||||
</v-card-title>
|
||||
|
||||
<v-text-field
|
||||
v-model="search"
|
||||
label="Найти тестирование по названию"
|
||||
variant="outlined"
|
||||
clearable
|
||||
class="mb-4"
|
||||
></v-text-field>
|
||||
|
||||
<v-data-table
|
||||
:items="filteredTests"
|
||||
item-value="id"
|
||||
class="elevation-1"
|
||||
:headers="headers"
|
||||
hide-default-footer
|
||||
>
|
||||
<template #item.image="{ item }">
|
||||
<v-avatar size="48">
|
||||
<img :src="item.image" alt="Test Image" />
|
||||
</v-avatar>
|
||||
</template>
|
||||
|
||||
<template #item.actions="{ item }">
|
||||
<v-btn v-if="item.type === 'test'" color="teal-darken-4" variant="tonal" class="mr-4">Тренироваться</v-btn>
|
||||
<v-btn color="teal-darken-4">Пройти</v-btn>
|
||||
</template>
|
||||
</v-data-table>
|
||||
</v-card>
|
||||
</v-tabs-window-item>
|
||||
|
||||
<v-tabs-window-item>
|
||||
<v-card class="mb-6" outlined>
|
||||
<v-card-title>
|
||||
Завершенные
|
||||
</v-card-title>
|
||||
<p>Список завершенных тестов будет здесь.</p>
|
||||
</v-card>
|
||||
</v-tabs-window-item>
|
||||
|
||||
<v-tabs-window-item>
|
||||
<v-card class="mb-6" outlined>
|
||||
<v-card-title>
|
||||
Каталог
|
||||
</v-card-title>
|
||||
<p>Список доступных тестов будет здесь.</p>
|
||||
</v-card>
|
||||
</v-tabs-window-item>
|
||||
</v-tabs-window>
|
||||
</v-container>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {pagecounter} from '@/utils/universal_functions'
|
||||
import { ref, computed } from 'vue';
|
||||
|
||||
export default {
|
||||
setup(){
|
||||
pagecounter()
|
||||
}
|
||||
}
|
||||
setup() {
|
||||
const activeTab = ref(0);
|
||||
const search = ref('');
|
||||
|
||||
const headers = [
|
||||
{ text: 'Картинка', value: 'image', sortable: false },
|
||||
{ text: 'Название', value: 'title', align: 'start' },
|
||||
{ text: 'Тип', value: 'type' },
|
||||
{ text: 'Описание', value: 'description' },
|
||||
{ text: 'Дата', value: 'date' },
|
||||
{ text: 'Действия', value: 'actions', sortable: false },
|
||||
];
|
||||
|
||||
const tests = ref([
|
||||
{
|
||||
id: 1,
|
||||
title: 'Комплекс тестовых вопросов на знание в области информационно-коммуникационных технологий',
|
||||
type: 'test',
|
||||
description: 'Краткое описание тестирования',
|
||||
date: '22.06.2024',
|
||||
questions: 20,
|
||||
time: '15 минут',
|
||||
attempts: 1,
|
||||
image: 'https://via.placeholder.com/48',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
title: 'Удобство раздела тестирования',
|
||||
type: 'survey',
|
||||
description: 'Опрос среди сотрудников ЦОД МФ',
|
||||
date: '22.06.2024',
|
||||
questions: 28,
|
||||
time: null,
|
||||
attempts: null,
|
||||
image: 'https://via.placeholder.com/48',
|
||||
},
|
||||
]);
|
||||
|
||||
const filteredTests = computed(() => {
|
||||
if (!search.value) return tests.value;
|
||||
return tests.value.filter((test) =>
|
||||
test.title.toLowerCase().includes(search.value.toLowerCase())
|
||||
);
|
||||
});
|
||||
|
||||
return {
|
||||
activeTab,
|
||||
search,
|
||||
headers,
|
||||
tests,
|
||||
filteredTests,
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
|
||||
</style>
|
||||
.v-data-table__wrapper {
|
||||
overflow-x: auto;
|
||||
}
|
||||
</style>
|
||||
@@ -7,12 +7,12 @@
|
||||
align="center">
|
||||
<v-tab v-for="x in tabs" :key="x.value" :value="x.value">{{ x.text }}</v-tab>
|
||||
<v-tab v-if="accountStore.user.is_staff" value="constructor">Создать новое голосование</v-tab>
|
||||
|
||||
|
||||
</v-tabs>
|
||||
|
||||
|
||||
</v-col>
|
||||
<v-col class="pa-0 overflow-hidden">
|
||||
|
||||
|
||||
<v-window v-model="currentTab" class="h-100">
|
||||
<!-- Текущие голосования -->
|
||||
<v-tabs-window-item v-for="x in ['active','completed']" :value="x" class="h-100 overflow-auto">
|
||||
@@ -40,7 +40,7 @@
|
||||
<VoteConstructor @updating="updating" ref="constructor"/>
|
||||
</v-tabs-window-item>
|
||||
</v-window>
|
||||
|
||||
|
||||
<!-- Модальные окна -->
|
||||
<v-dialog v-model="voteModal" @click:outside="closeModal">
|
||||
<CurrentVote :data="res" @closer="closeModal"/>
|
||||
@@ -49,9 +49,6 @@
|
||||
<v-dialog v-model="resultsModal" max-width="1200px" @click:outside="closeModal">
|
||||
<v-card>
|
||||
<VoteResult :data="result" @closer="closeModal" />
|
||||
<v-card-actions>
|
||||
<v-btn @click="closeModal">Закрыть</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</v-col>
|
||||
@@ -82,7 +79,7 @@ export default {
|
||||
const tabs = [
|
||||
{value: "active", text: 'Текущие голосования'},
|
||||
{value: "completed", text: 'Завершенные голосования'},
|
||||
|
||||
|
||||
]
|
||||
|
||||
const currentTab = ref("active");
|
||||
@@ -115,7 +112,7 @@ export default {
|
||||
} catch (error) {
|
||||
console.error("Ошибка при загрузке данных голосования:", error);
|
||||
// res.value = {};
|
||||
|
||||
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
@@ -173,7 +170,7 @@ export default {
|
||||
if (constructor.value !== null) {
|
||||
constructor.value.resetForm()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
watch(
|
||||
|
||||
Reference in new issue
Block a user