Merge pull request 'test' (#122) from test into develop
Reviewed-on: https://sulaco.nodered.ru:5333/COD2/PORTAL_COD2/pulls/122
This commit is contained in:
commit
fed7886d82
8 files changed
+447
-106
No files matched your search
@@ -13,7 +13,6 @@ https://docs.djangoproject.com/en/4.2/ref/settings/
|
||||
from pathlib import Path
|
||||
import os
|
||||
|
||||
DATA_UPLOAD_MAX_NUMBER_FIELDS=100000
|
||||
CORS_ORIGIN_ALLOW_ALL=True
|
||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
@@ -38,6 +37,8 @@ SWAGGER_SETTINGS = {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ALLOWED_HOSTS = str(os.getenv('DJANGO_ALLOWED_HOSTS')).split(', ')
|
||||
CSRF_TRUSTED_ORIGINS = str(os.getenv('DJANGO_CSRF_TRUSTED_ORIGINS')).split(', ')
|
||||
CHANNEL_LAYERS = {
|
||||
|
||||
@@ -15,7 +15,11 @@
|
||||
<template v-for="(x, i) in carous" :key="i">
|
||||
<v-carousel-item v-if="!x.link.endsWith('mp4')" :src="`${burl}${x.link}`" cover eager>
|
||||
<v-container fill-height fluid pa-0 ma-0 pb-3 class="flex-column h-100 d-flex">
|
||||
<v-card v-if="x.text !== '' || x.title != null" class="bgCard h-100 d-flex flex-column">
|
||||
<v-card
|
||||
v-if="x.text !== '' || x.title != null"
|
||||
class="bgCard h-100 d-flex flex-column"
|
||||
style="background: rgba(255, 255, 255, 0.3) !important; background-color: rgba(255, 255, 255, 0.3) !important;"
|
||||
>
|
||||
<v-card-title
|
||||
v-if="x.title != null"
|
||||
class="text-h3 text-uppercase titles text-text_carous ma-1 mb-0"
|
||||
@@ -176,7 +180,17 @@ export default {
|
||||
<style>
|
||||
.titles {
|
||||
font-family: cursive !important;
|
||||
background: #ffffff8c;
|
||||
background: rgba(255, 255, 255, 0.7) !important;
|
||||
}
|
||||
|
||||
.bgCard {
|
||||
background: rgba(255, 255, 255, 0.5) !important;
|
||||
background-color: rgba(255, 255, 255, 0.5) !important;
|
||||
}
|
||||
|
||||
.v-card.bgCard {
|
||||
background: rgba(255, 255, 255, 0.5) !important;
|
||||
background-color: rgba(255, 255, 255, 0.5) !important;
|
||||
}
|
||||
|
||||
.textareas .v-field__input {
|
||||
@@ -188,6 +202,16 @@ export default {
|
||||
}
|
||||
</style>
|
||||
<style scoped>
|
||||
.bgCard {
|
||||
background: rgba(255, 255, 255, 0.3) !important;
|
||||
background-color: rgba(255, 255, 255, 0.3) !important;
|
||||
}
|
||||
|
||||
.v-card.bgCard {
|
||||
background: rgba(255, 255, 255, 0.3) !important;
|
||||
background-color: rgba(255, 255, 255, 0.3) !important;
|
||||
}
|
||||
|
||||
.titles, .text-text_carous, .text-text_caroustext-black, .v-card-title, .v-card-text, .v-textarea .v-field__input {
|
||||
color: #111 !important;
|
||||
text-shadow: none !important;
|
||||
|
||||
@@ -125,20 +125,26 @@ export default {
|
||||
|
||||
const time = Number(props.data.time);
|
||||
|
||||
// Если число больше 60, значит это секунды (таймер запущен)
|
||||
if (time > 60) {
|
||||
const minutes = Math.floor(time / 60);
|
||||
const seconds = time % 60;
|
||||
return {
|
||||
value: `${minutes} мин. ${seconds}`,
|
||||
unit: "сек.",
|
||||
};
|
||||
// Всегда считаем, что время приходит в минутах
|
||||
if (time >= 60) {
|
||||
const hours = Math.floor(time / 60);
|
||||
const minutes = time % 60;
|
||||
if (minutes === 0) {
|
||||
return {
|
||||
value: hours,
|
||||
unit: hours === 1 ? "час" : hours >= 2 && hours <= 4 ? "часа" : "часов",
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
value: `${hours} ч. ${minutes}`,
|
||||
unit: minutes === 1 ? "мин." : "мин.",
|
||||
};
|
||||
}
|
||||
} else {
|
||||
// Если меньше 60, значит это минуты (таймер не запущен)
|
||||
// Если меньше 60, значит это просто минуты
|
||||
return {
|
||||
value: time,
|
||||
unit:
|
||||
time === 1 ? "минута" : time >= 2 && time <= 4 ? "минуты" : "минут",
|
||||
unit: time === 1 ? "минута" : time >= 2 && time <= 4 ? "минуты" : "минут",
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
@@ -18,6 +18,50 @@
|
||||
class="scrollable-textarea"
|
||||
></v-textarea>
|
||||
</div>
|
||||
<div v-if="isTest" class="pt-2">
|
||||
<div class="text-overline text-grey mb-2">Материалы к тесту:</div>
|
||||
|
||||
<!-- Кнопка добавления файла -->
|
||||
<v-btn
|
||||
variant="outlined"
|
||||
color="teal-darken-4"
|
||||
prepend-icon="mdi-plus"
|
||||
class="mb-3"
|
||||
@click="triggerFileInput"
|
||||
>
|
||||
Добавить файл
|
||||
</v-btn>
|
||||
|
||||
<!-- Скрытый input для выбора файлов -->
|
||||
<input
|
||||
ref="fileInput"
|
||||
type="file"
|
||||
multiple
|
||||
style="display: none"
|
||||
@change="addFiles"
|
||||
/>
|
||||
|
||||
<!-- Список добавленных файлов -->
|
||||
<div v-if="testFilesCount > 0" class="mb-2">
|
||||
<v-card variant="outlined" class="pa-2">
|
||||
<div class="text-caption text-grey mb-2">
|
||||
Выбрано файлов: {{ testFilesCount }}
|
||||
</div>
|
||||
<v-chip
|
||||
v-for="(file, index) in testFiles"
|
||||
:key="`file-${index}-${file.name}-${file.size}`"
|
||||
color="teal-darken-4"
|
||||
closable
|
||||
class="ma-1"
|
||||
@click:close="removeFile(index)"
|
||||
>
|
||||
<v-icon start>mdi-file</v-icon>
|
||||
{{ file.name }}
|
||||
<span class="text-caption ml-2">({{ Math.round(file.size / 1024) }} KB)</span>
|
||||
</v-chip>
|
||||
</v-card>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="!isTest" class="pt-2 d-flex align-center">
|
||||
<span class="text-overline text-grey text-center">Публикация новости: </span>
|
||||
<v-switch
|
||||
@@ -98,6 +142,7 @@ export default {
|
||||
emits: ['update:form'],
|
||||
setup(props, { emit }) {
|
||||
const route = useRoute();
|
||||
const fileInput = ref(null);
|
||||
const isTestRoute = computed(() => {
|
||||
return route.path && String(route.path).includes('test');
|
||||
});
|
||||
@@ -112,10 +157,10 @@ export default {
|
||||
appoint: false,
|
||||
startDate: new Date(),
|
||||
endDate: new Date(),
|
||||
test_files: [],
|
||||
}
|
||||
);
|
||||
|
||||
// Отправляем изменения в родителя
|
||||
watch(
|
||||
localForm,
|
||||
(newForm) => {
|
||||
@@ -145,7 +190,7 @@ export default {
|
||||
localForm.value.startDate instanceof Date
|
||||
? localForm.value.startDate
|
||||
: new Date();
|
||||
const newDate = new Date(oldDate); // создаём новый объект с копией даты
|
||||
const newDate = new Date(oldDate);
|
||||
newDate.setHours(hours, minutes, 0, 0);
|
||||
localForm.value.startDate = newDate;
|
||||
},
|
||||
@@ -169,6 +214,50 @@ export default {
|
||||
return `${hours}:${minutes}`;
|
||||
});
|
||||
|
||||
// Обработчики для файлов
|
||||
const triggerFileInput = () => {
|
||||
fileInput.value?.click();
|
||||
};
|
||||
|
||||
const addFiles = (event) => {
|
||||
const files = Array.from(event.target.files || []);
|
||||
|
||||
if (files.length > 0) {
|
||||
// Инициализируем массив файлов если его нет
|
||||
if (!localForm.value.test_files) {
|
||||
localForm.value.test_files = [];
|
||||
}
|
||||
|
||||
// Добавляем новые файлы к существующим
|
||||
const currentFiles = [...localForm.value.test_files]; // Создаем копию
|
||||
const newFiles = [...currentFiles, ...files];
|
||||
localForm.value.test_files = newFiles;
|
||||
}
|
||||
|
||||
// Очищаем input для возможности выбора тех же файлов снова
|
||||
event.target.value = '';
|
||||
};
|
||||
|
||||
const removeFile = (index) => {
|
||||
const currentFiles = [...(localForm.value.test_files || [])];
|
||||
const fileToRemove = currentFiles[index];
|
||||
|
||||
if (index >= 0 && index < currentFiles.length) {
|
||||
currentFiles.splice(index, 1);
|
||||
localForm.value.test_files = currentFiles;
|
||||
}
|
||||
};
|
||||
|
||||
// Computed для корректного отображения файлов
|
||||
const testFiles = computed(() => {
|
||||
const files = localForm.value.test_files;
|
||||
return Array.isArray(files) ? files : [];
|
||||
});
|
||||
|
||||
const testFilesCount = computed(() => {
|
||||
return testFiles.value.length;
|
||||
});
|
||||
|
||||
return {
|
||||
localForm,
|
||||
returnstart,
|
||||
@@ -177,7 +266,13 @@ export default {
|
||||
selectedTimeEnd,
|
||||
timeOptions,
|
||||
isTestRoute,
|
||||
isTest: props.isTest
|
||||
isTest: props.isTest,
|
||||
fileInput,
|
||||
triggerFileInput,
|
||||
addFiles,
|
||||
removeFile,
|
||||
testFiles,
|
||||
testFilesCount
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
@@ -197,6 +197,24 @@
|
||||
</div>
|
||||
<p v-else class="text-grey text-center mt-2">Не выбрано</p>
|
||||
</div>
|
||||
|
||||
<!-- Материалы к тесту на странице подтверждения -->
|
||||
<div class="mt-2 mb-4">
|
||||
<p><strong class="px-2">Материалы к тесту:</strong></p>
|
||||
<div v-if="form.test_files && form.test_files.length > 0" class="mt-2">
|
||||
<v-chip
|
||||
v-for="(file, index) in form.test_files"
|
||||
:key="index"
|
||||
color="primary"
|
||||
size="small"
|
||||
class="me-2 mb-2"
|
||||
>
|
||||
<v-icon start icon="mdi-paperclip"></v-icon>
|
||||
{{ file.name }}
|
||||
</v-chip>
|
||||
</div>
|
||||
<p v-else class="text-grey text-center mt-2">Не выбрано</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<p><strong class="px-2">Вопросы:</strong></p>
|
||||
@@ -341,7 +359,8 @@ export default {
|
||||
endDate: props.isTest ? null : new Date(new Date().setDate(new Date().getDate() + 14)),
|
||||
questions: [],
|
||||
news: false,
|
||||
appoint: false
|
||||
appoint: false,
|
||||
test_files: []
|
||||
});
|
||||
|
||||
const testSettings = ref({
|
||||
@@ -525,6 +544,7 @@ export default {
|
||||
}))
|
||||
})),
|
||||
image: testImage.value,
|
||||
test_files: (form.value.test_files && form.value.test_files.length > 0) ? form.value.test_files : undefined,
|
||||
pass_perc: Number(testSettings.value.pass_perc),
|
||||
time: Number(testSettings.value.time),
|
||||
question_count: actualTestQuestionCount.value,
|
||||
@@ -577,7 +597,8 @@ export default {
|
||||
endDate: props.isTest ? null : new Date(new Date().setDate(new Date().getDate() + 14)),
|
||||
questions: [],
|
||||
news: false,
|
||||
appoint: false
|
||||
appoint: false,
|
||||
test_files: []
|
||||
};
|
||||
testSettings.value = {
|
||||
pass_perc: '70',
|
||||
|
||||
@@ -152,13 +152,22 @@
|
||||
</v-main>
|
||||
<v-main v-else class="d-flex align-center text-h3 bg-teal-lighten-2">
|
||||
<v-card class="h-100 w-100 d-flex justify-center rounded-0 flex-column" :image="`${burl}${scrimg}`">
|
||||
<v-card-text class="justify-center bgCard h-100 ma-3 d-flex flex-column">
|
||||
<v-row class="bgText flex-grow-0">
|
||||
<v-card-text
|
||||
class="justify-center bgCard h-100 ma-3 d-flex flex-column"
|
||||
style="background: rgba(255, 255, 255, 0.3) !important; background-color: rgba(255, 255, 255, 0.3) !important;"
|
||||
>
|
||||
<v-row
|
||||
class="bgText flex-grow-0"
|
||||
style="background: rgba(255, 255, 255, 0.5) !important; background-color: rgba(255, 255, 255, 0.5) !important;"
|
||||
>
|
||||
<v-col class="text-center textcolor font-weight-black text-h3 pb-0">
|
||||
Добро пожаловать на портал МИ ФНС России по ЦОД № 2
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row class="bgText flex-grow-0">
|
||||
<v-row
|
||||
class="bgText flex-grow-0"
|
||||
style="background: rgba(255, 255, 255, 0.5) !important; background-color: rgba(255, 255, 255, 0.5) !important;"
|
||||
>
|
||||
<v-col class="text-subtitle-1 text-center textcolor pt-0">
|
||||
Авторизуйтесь для получения доступа к контенту портала
|
||||
</v-col>
|
||||
@@ -382,6 +391,25 @@ export default {
|
||||
};
|
||||
</script>
|
||||
<style lang="scss">
|
||||
.bgCard {
|
||||
background: rgba(255, 255, 255, 0.3) !important;
|
||||
background-color: rgba(255, 255, 255, 0.3) !important;
|
||||
}
|
||||
|
||||
.v-card.bgCard {
|
||||
background: rgba(255, 255, 255, 0.3) !important;
|
||||
background-color: rgba(255, 255, 255, 0.3) !important;
|
||||
}
|
||||
|
||||
.bgText {
|
||||
background: rgba(255, 255, 255, 0.5) !important;
|
||||
background-color: rgba(255, 255, 255, 0.5) !important;
|
||||
}
|
||||
|
||||
.textcolor {
|
||||
color: #2f535e !important;
|
||||
}
|
||||
|
||||
.mystat {
|
||||
position: fixed;
|
||||
right: 10px;
|
||||
|
||||
@@ -149,26 +149,6 @@ async function getVoteDetail(id) {
|
||||
}
|
||||
}
|
||||
|
||||
// async function updateVote(id, updatedData) {
|
||||
// try {
|
||||
// const response = await axiosApiInstance.put(`/api/vote/votedetail/${id}/`, updatedData);
|
||||
// return response.data;
|
||||
// } catch (error) {
|
||||
// console.error("Ошибка обновления голосования:", error);
|
||||
// throw error;
|
||||
// }
|
||||
// }
|
||||
|
||||
// async function patchVote(id, partialData) {
|
||||
// try {
|
||||
// const response = await axiosApiInstance.patch(`/api/vote/votedetail/${id}/`, partialData);
|
||||
// return response.data;
|
||||
// } catch (error) {
|
||||
// console.error("Ошибка частичного обновления голосования:", error);
|
||||
// throw error;
|
||||
// }
|
||||
// }
|
||||
|
||||
async function deleteVote(id) {
|
||||
try {
|
||||
await axiosApiInstance.delete(`/api/vote/votedetail/${id}/`);
|
||||
@@ -210,12 +190,20 @@ async function getVoteResult(id) {
|
||||
|
||||
async function createTest(testData) {
|
||||
try {
|
||||
|
||||
const formData = new FormData();
|
||||
|
||||
if (testData.image) {
|
||||
formData.append('image', testData.image);
|
||||
}
|
||||
|
||||
// Добавляем файлы материалов теста
|
||||
if (testData.test_files && testData.test_files.length > 0) {
|
||||
testData.test_files.forEach((file) => {
|
||||
formData.append('test_files', file);
|
||||
});
|
||||
}
|
||||
|
||||
testData.questions.forEach((question, qIndex) => {
|
||||
if (question.image) {
|
||||
formData.append('questionsfiles', question.image);
|
||||
|
||||
@@ -16,28 +16,73 @@
|
||||
<v-window-item class="my-2 mx-auto h-100" :class="{'w-100': $vuetify.display.smAndDown, 'w-75': $vuetify.display.mdAndUp}">
|
||||
<CatalogTest :activeTab="activeTab" :testingCard="getAllTests" title="Назначенные">
|
||||
<template #buttons="{ cardValue }">
|
||||
<v-btn
|
||||
class="mr-2 custom-btn"
|
||||
:color="$vuetify.theme.dark ? 'teal' : 'teal-lighten-5'"
|
||||
variant="flat"
|
||||
:size="$vuetify.display.smAndDown ? 'small' : 'default'"
|
||||
elevation="0"
|
||||
@click="goToTest(cardValue.id)"
|
||||
>
|
||||
<v-icon start icon="mdi-pencil" :class="$vuetify.theme.dark ? 'text-teal-lighten-1' : 'text-teal-darken-1'" />
|
||||
<span :class="$vuetify.theme.dark ? 'text-teal-lighten-1' : 'text-teal-darken-1'">Тренироваться</span>
|
||||
</v-btn>
|
||||
<v-btn
|
||||
class="custom-btn"
|
||||
:color="$vuetify.theme.dark ? 'teal' : 'teal-darken-1'"
|
||||
variant="flat"
|
||||
:size="$vuetify.display.smAndDown ? 'small' : 'default'"
|
||||
elevation="0"
|
||||
@click="startTest(cardValue.id)"
|
||||
>
|
||||
<v-icon start icon="mdi-play" :class="$vuetify.theme.dark ? 'text-teal-lighten-1' : undefined" />
|
||||
<span :class="$vuetify.theme.dark ? 'text-teal-lighten-1' : undefined">Пройти тест</span>
|
||||
</v-btn>
|
||||
<div class="d-flex flex-column gap-2">
|
||||
<div class="d-flex gap-2">
|
||||
<v-btn
|
||||
v-if="cardValue.files && cardValue.files.length > 0"
|
||||
class="mr-2 custom-btn"
|
||||
:color="$vuetify.theme.dark ? 'blue' : 'blue-lighten-5'"
|
||||
variant="flat"
|
||||
:size="$vuetify.display.smAndDown ? 'small' : 'default'"
|
||||
elevation="0"
|
||||
@click="toggleMaterials(cardValue.id)"
|
||||
>
|
||||
<v-icon start :icon="expandedMaterials.has(cardValue.id) ? 'mdi-chevron-up' : 'mdi-chevron-down'" :class="$vuetify.theme.dark ? 'text-blue-lighten-1' : 'text-blue-darken-1'" />
|
||||
<span :class="$vuetify.theme.dark ? 'text-blue-lighten-1' : 'text-blue-darken-1'">Материалы</span>
|
||||
</v-btn>
|
||||
<v-btn
|
||||
class="mr-2 custom-btn"
|
||||
:color="$vuetify.theme.dark ? 'teal' : 'teal-lighten-5'"
|
||||
variant="flat"
|
||||
:size="$vuetify.display.smAndDown ? 'small' : 'default'"
|
||||
elevation="0"
|
||||
@click="goToTest(cardValue.id)"
|
||||
>
|
||||
<v-icon start icon="mdi-pencil" :class="$vuetify.theme.dark ? 'text-teal-lighten-1' : 'text-teal-darken-1'" />
|
||||
<span :class="$vuetify.theme.dark ? 'text-teal-lighten-1' : 'text-teal-darken-1'">Тренироваться</span>
|
||||
</v-btn>
|
||||
<v-btn
|
||||
class="custom-btn"
|
||||
:color="$vuetify.theme.dark ? 'teal' : 'teal-darken-1'"
|
||||
variant="flat"
|
||||
:size="$vuetify.display.smAndDown ? 'small' : 'default'"
|
||||
elevation="0"
|
||||
@click="startTest(cardValue.id)"
|
||||
>
|
||||
<v-icon start icon="mdi-play" :class="$vuetify.theme.dark ? 'text-teal-lighten-1' : undefined" />
|
||||
<span :class="$vuetify.theme.dark ? 'text-teal-lighten-1' : undefined">Пройти тест</span>
|
||||
</v-btn>
|
||||
</div>
|
||||
<!-- Аккордеон с материалами -->
|
||||
<v-expand-transition>
|
||||
<div v-if="expandedMaterials.has(cardValue.id) && cardValue.files && cardValue.files.length > 0">
|
||||
<v-card class="mt-2">
|
||||
<v-card-text class="py-0">
|
||||
<v-list density="compact">
|
||||
<v-list-item
|
||||
v-for="(file, index) in cardValue.files"
|
||||
:key="index"
|
||||
class="px-2"
|
||||
@click="downloadFile(file.file, file.filename)"
|
||||
>
|
||||
<template v-slot:prepend>
|
||||
<v-icon
|
||||
:icon="getFileIcon(file.filename)"
|
||||
:color="getFileColor(file.filename)"
|
||||
class="mr-3"
|
||||
/>
|
||||
</template>
|
||||
<v-list-item-title class="text-body-2">{{ file.filename }}</v-list-item-title>
|
||||
<template v-slot:append>
|
||||
<v-icon icon="mdi-download" color="primary" />
|
||||
</template>
|
||||
</v-list-item>
|
||||
</v-list>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</div>
|
||||
</v-expand-transition>
|
||||
</div>
|
||||
</template>
|
||||
</CatalogTest>
|
||||
</v-window-item>
|
||||
@@ -65,49 +110,98 @@
|
||||
<v-window-item :class="{'w-100': $vuetify.display.smAndDown, 'w-75': $vuetify.display.mdAndUp, 'mx-auto': true, 'h-100': true}">
|
||||
<CatalogTest :activeTab="activeTab" :testingCard="getAllTests" class="position-relative" title="Каталог">
|
||||
<template #buttons="{ cardValue }">
|
||||
<div v-if="accountStore.user.is_staff" class="d-flex" :class="{'position-relative': $vuetify.display.smAndDown, 'position-absolute top-0 right-0': $vuetify.display.mdAndUp}">
|
||||
<v-btn
|
||||
class="mr-2 custom-btn"
|
||||
:color="$vuetify.theme.dark ? 'amber' : 'amber-lighten-5'"
|
||||
variant="flat"
|
||||
:size="$vuetify.display.smAndDown ? 'small' : 'default'"
|
||||
elevation="0"
|
||||
@click="openAddDialog(cardValue.id)"
|
||||
>
|
||||
<v-icon icon="mdi-account-plus" :class="$vuetify.theme.dark ? 'text-amber-lighten-1' : 'text-amber-darken-2'" />
|
||||
<v-tooltip
|
||||
activator="parent"
|
||||
location="top"
|
||||
>Назначить сотрудникам</v-tooltip>
|
||||
</v-btn>
|
||||
<v-btn
|
||||
v-if="cardValue.author === accountStore.user.id"
|
||||
class="mr-2 custom-btn"
|
||||
:color="$vuetify.theme.dark ? 'red' : 'red-lighten-5'"
|
||||
variant="flat"
|
||||
:size="$vuetify.display.smAndDown ? 'small' : 'default'"
|
||||
elevation="0"
|
||||
@click="openDeleteDialog(cardValue.id)"
|
||||
>
|
||||
<v-icon icon="mdi-delete" :class="$vuetify.theme.dark ? 'text-red-lighten-1' : 'text-red-darken-2'" />
|
||||
<v-tooltip
|
||||
activator="parent"
|
||||
location="top"
|
||||
>Удалить тестирование</v-tooltip>
|
||||
</v-btn>
|
||||
</div>
|
||||
<div class="d-flex flex-column gap-2">
|
||||
<div class="d-flex flex-wrap gap-2 align-start justify-space-between">
|
||||
<!-- Основные кнопки пользователя -->
|
||||
<div class="d-flex gap-2 flex-wrap">
|
||||
<v-btn
|
||||
v-if="cardValue.files && cardValue.files.length > 0"
|
||||
class="mr-2 custom-btn"
|
||||
:color="$vuetify.theme.dark ? 'blue' : 'blue-lighten-5'"
|
||||
variant="flat"
|
||||
:size="$vuetify.display.smAndDown ? 'small' : 'default'"
|
||||
elevation="0"
|
||||
@click="toggleMaterials(cardValue.id)"
|
||||
>
|
||||
<v-icon start :icon="expandedMaterials.has(cardValue.id) ? 'mdi-chevron-up' : 'mdi-chevron-down'" :class="$vuetify.theme.dark ? 'text-blue-lighten-1' : 'text-blue-darken-1'" />
|
||||
<span :class="$vuetify.theme.dark ? 'text-blue-lighten-1' : 'text-blue-darken-1'">Материалы</span>
|
||||
</v-btn>
|
||||
<v-btn
|
||||
class="mr-2 custom-btn"
|
||||
:color="$vuetify.theme.dark ? 'teal' : 'teal-lighten-5'"
|
||||
variant="flat"
|
||||
:size="$vuetify.display.smAndDown ? 'small' : 'default'"
|
||||
elevation="0"
|
||||
@click="goToTest(cardValue.id)"
|
||||
>
|
||||
<v-icon start icon="mdi-pencil" :class="$vuetify.theme.dark ? 'text-teal-lighten-1' : 'text-teal-darken-1'" />
|
||||
<span :class="$vuetify.theme.dark ? 'text-teal-lighten-1' : 'text-teal-darken-1'">Тренироваться</span>
|
||||
</v-btn>
|
||||
</div>
|
||||
|
||||
<v-btn
|
||||
class="mr-2 custom-btn"
|
||||
:color="$vuetify.theme.dark ? 'teal' : 'teal-lighten-5'"
|
||||
variant="flat"
|
||||
:size="$vuetify.display.smAndDown ? 'small' : 'default'"
|
||||
elevation="0"
|
||||
@click="goToTest(cardValue.id)"
|
||||
>
|
||||
<v-icon start icon="mdi-pencil" :class="$vuetify.theme.dark ? 'text-teal-lighten-1' : 'text-teal-darken-1'" />
|
||||
<span :class="$vuetify.theme.dark ? 'text-teal-lighten-1' : 'text-teal-darken-1'">Тренироваться</span>
|
||||
</v-btn>
|
||||
<!-- Служебные кнопки администратора -->
|
||||
<div v-if="accountStore.user.is_staff" class="d-flex gap-2">
|
||||
<v-btn
|
||||
class="custom-btn"
|
||||
:color="$vuetify.theme.dark ? 'amber' : 'amber-lighten-5'"
|
||||
variant="flat"
|
||||
:size="$vuetify.display.smAndDown ? 'small' : 'default'"
|
||||
elevation="0"
|
||||
@click="openAddDialog(cardValue.id)"
|
||||
>
|
||||
<v-icon icon="mdi-account-plus" :class="$vuetify.theme.dark ? 'text-amber-lighten-1' : 'text-amber-darken-2'" />
|
||||
<v-tooltip
|
||||
activator="parent"
|
||||
location="top"
|
||||
>Назначить сотрудникам</v-tooltip>
|
||||
</v-btn>
|
||||
<v-btn
|
||||
v-if="cardValue.author === accountStore.user.id"
|
||||
class="custom-btn"
|
||||
:color="$vuetify.theme.dark ? 'red' : 'red-lighten-5'"
|
||||
variant="flat"
|
||||
:size="$vuetify.display.smAndDown ? 'small' : 'default'"
|
||||
elevation="0"
|
||||
@click="openDeleteDialog(cardValue.id)"
|
||||
>
|
||||
<v-icon icon="mdi-delete" :class="$vuetify.theme.dark ? 'text-red-lighten-1' : 'text-red-darken-2'" />
|
||||
<v-tooltip
|
||||
activator="parent"
|
||||
location="top"
|
||||
>Удалить тестирование</v-tooltip>
|
||||
</v-btn>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Аккордеон с материалами -->
|
||||
<v-expand-transition>
|
||||
<div v-if="expandedMaterials.has(cardValue.id) && cardValue.files && cardValue.files.length > 0">
|
||||
<v-card class="mt-2">
|
||||
<v-card-text class="py-0">
|
||||
<v-list density="compact">
|
||||
<v-list-item
|
||||
v-for="(file, index) in cardValue.files"
|
||||
:key="index"
|
||||
class="px-2"
|
||||
@click="downloadFile(file.file, file.filename)"
|
||||
>
|
||||
<template v-slot:prepend>
|
||||
<v-icon
|
||||
:icon="getFileIcon(file.filename)"
|
||||
:color="getFileColor(file.filename)"
|
||||
class="mr-3"
|
||||
/>
|
||||
</template>
|
||||
<v-list-item-title class="text-body-2">{{ file.filename }}</v-list-item-title>
|
||||
<template v-slot:append>
|
||||
<v-icon icon="mdi-download" color="primary" />
|
||||
</template>
|
||||
</v-list-item>
|
||||
</v-list>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</div>
|
||||
</v-expand-transition>
|
||||
</div>
|
||||
</template>
|
||||
</CatalogTest>
|
||||
</v-window-item>
|
||||
@@ -234,6 +328,7 @@ export default {
|
||||
const assignedEmployeesDetails = ref([]);
|
||||
const showResultsDialog = ref(false);
|
||||
const testResults = ref(null);
|
||||
const expandedMaterials = ref(new Set()); // Для управления раскрытием материалов по ID теста
|
||||
const snackbar = ref({
|
||||
show: false,
|
||||
text: '',
|
||||
@@ -494,6 +589,84 @@ export default {
|
||||
}
|
||||
};
|
||||
|
||||
const toggleMaterials = (testId) => {
|
||||
const newExpanded = new Set(expandedMaterials.value);
|
||||
if (newExpanded.has(testId)) {
|
||||
newExpanded.delete(testId);
|
||||
} else {
|
||||
newExpanded.add(testId);
|
||||
}
|
||||
expandedMaterials.value = newExpanded;
|
||||
};
|
||||
|
||||
const downloadFile = (fileUrl, filename) => {
|
||||
const link = document.createElement('a');
|
||||
link.href = fileUrl;
|
||||
link.download = filename;
|
||||
link.target = '_blank';
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
};
|
||||
|
||||
const getFileIcon = (filename) => {
|
||||
const extension = filename.split('.').pop().toLowerCase();
|
||||
switch (extension) {
|
||||
case 'pdf':
|
||||
return 'mdi-file-pdf-box';
|
||||
case 'doc':
|
||||
case 'docx':
|
||||
return 'mdi-file-word-box';
|
||||
case 'xls':
|
||||
case 'xlsx':
|
||||
return 'mdi-file-excel-box';
|
||||
case 'ppt':
|
||||
case 'pptx':
|
||||
return 'mdi-file-powerpoint-box';
|
||||
case 'txt':
|
||||
return 'mdi-file-document';
|
||||
case 'zip':
|
||||
case 'rar':
|
||||
case '7z':
|
||||
return 'mdi-file-zip-box';
|
||||
case 'jpg':
|
||||
case 'jpeg':
|
||||
case 'png':
|
||||
case 'gif':
|
||||
return 'mdi-file-image-box';
|
||||
default:
|
||||
return 'mdi-file-document-outline';
|
||||
}
|
||||
};
|
||||
|
||||
const getFileColor = (filename) => {
|
||||
const extension = filename.split('.').pop().toLowerCase();
|
||||
switch (extension) {
|
||||
case 'pdf':
|
||||
return 'red';
|
||||
case 'doc':
|
||||
case 'docx':
|
||||
return 'blue';
|
||||
case 'xls':
|
||||
case 'xlsx':
|
||||
return 'green';
|
||||
case 'ppt':
|
||||
case 'pptx':
|
||||
return 'orange';
|
||||
case 'zip':
|
||||
case 'rar':
|
||||
case '7z':
|
||||
return 'purple';
|
||||
case 'jpg':
|
||||
case 'jpeg':
|
||||
case 'png':
|
||||
case 'gif':
|
||||
return 'pink';
|
||||
default:
|
||||
return 'grey';
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
activeTab,
|
||||
tabs,
|
||||
@@ -516,6 +689,11 @@ export default {
|
||||
assignedEmployees,
|
||||
assignedEmployeesDetails,
|
||||
assignedEmployeesCount,
|
||||
expandedMaterials,
|
||||
toggleMaterials,
|
||||
downloadFile,
|
||||
getFileIcon,
|
||||
getFileColor,
|
||||
snackbar
|
||||
};
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user