This commit is contained in:
Alex committed 2025-01-30 14:47:01 +03:00
1 parent 271d9c4f47
commit f85e65c89a
1 file changed
+88 -213
+88 -213
View File
@@ -1,223 +1,98 @@
<template>
<v-container>
<v-tabs v-model="activeTab" class="mb-4 text-teal-darken-4">
<v-tab>Назначенные ({{ scheduledTests.length }})</v-tab>
<v-tab>Завершенные ({{ completedTests.length }})</v-tab>
<v-tab>Каталог</v-tab>
</v-tabs>
<v-tabs-window v-model="activeTab">
<!-- Назначенные -->
<v-tabs-window-item>
<v-card outlined>
<v-card-title>
Назначенные
</v-card-title>
<v-text-field
v-model="search"
class="mx-4"
clearable
label="Найти тестирование по названию"
variant="outlined"
/>
<v-data-table
:headers="headers"
:items="filteredScheduledTests"
hide-default-footer
hide-default-header
item-value="id"
>
<template #item.image="{ item }">
<v-img :src="item.image" alt="Test Image" height="100" width="100"/>
</template>
<template #item.title="{ item }">
<TestCard :item="item"/>
</template>
<template #item.actions="{ item }">
<v-btn v-if="item.type === 'test'" class="mr-4" color="teal-darken-4" variant="tonal">Тренироваться
</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>
<v-data-table
:headers="headers"
:items="filteredCompletedTests"
hide-default-footer
hide-default-header
item-value="id"
>
<template #item.image="{ item }">
<v-img :src="item.image" alt="Test Image" height="100" width="100"/>
</template>
<template #item.title="{ item }">
<TestCard :item="item"/>
</template>
<template #item.actions="{ item }">
<v-btn color="teal-darken-4">Посмотреть результаты</v-btn>
</template>
</v-data-table>
</v-card>
</v-tabs-window-item>
<!-- Каталог -->
<v-tabs-window-item>
<v-card outlined>
<v-card-title>
Каталог
</v-card-title>
<v-text-field
v-model="search"
class="mx-4"
clearable
label="Найти тестирование по названию"
variant="outlined"
/>
<v-data-table
:headers="headers"
:items="filteredTests"
hide-default-footer
hide-default-header
item-value="id"
>
<template #item.image="{ item }">
<v-img :src="item.image" alt="Test Image" height="100" width="100"/>
</template>
<template #item.title="{ item }">
<TestCard :item="item"/>
</template>
<template #item.actions="{ item }">
<v-btn v-if="item.type === 'test'" class="mr-4" color="teal-darken-4" variant="tonal">Тренироваться
</v-btn>
<v-btn color="teal-darken-4">Пройти</v-btn>
</template>
</v-data-table>
</v-card>
</v-tabs-window-item>
</v-tabs-window>
<v-container :fluid="true">
<v-tabs v-model="activeTab" class="mb-2 text-teal-darken-4">
<v-tab v-for="tab in tabs" :key="tab.value" :value="tab.value"> {{ tab.title }} </v-tab>
</v-tabs>
<v-tabs-window v-model="activeTab" class="border-t-thin">
<!-- Вкладка назначенные -->
<v-tabs-window-item class="my-2 ">
<CatalogTest title="Назначенные" :activeTab="activeTab" :testingCard="getAllTests">
<template #buttons>
<v-btn color="#00897B1F" class="mr-2 text-teal-darken-1" elevation="0">
Тренироваться
</v-btn>
<v-btn color="teal-darken-1" elevation="0">
Пройти
</v-btn>
</template>
</CatalogTest>
</v-tabs-window-item>
<!-- Вкладка завершенных -->
<v-tabs-window-item>
<CatalogTest title="Завершенные" :activeTab="activeTab" :testingCard="getAllTests">
<!-- Здесь отобразить результат теста после того как будет готов БЭК и УМТ -->
<template #results>
<!-- <div>
<v-icon icon="mdi-calendar-clock" size="large" />
<span class="ml-1">12354</span>
</div> -->
</template>
<template #buttons>
<v-btn color="#00897B1F" class="mr-2 text-teal-darken-1" elevation="0">
Результаты
</v-btn>
</template>
</CatalogTest>
</v-tabs-window-item>
<!-- Вкладка каталога -->
<v-tabs-window-item>
<CatalogTest title="Каталог" :activeTab="activeTab" :testingCard="getAllTests">
<template #buttons>
<v-btn color="#00897B1F" class="mr-2 text-teal-darken-1" elevation="0">
Тренироваться
</v-btn>
</template>
</CatalogTest>
</v-tabs-window-item>
</v-tabs-window>
</v-container>
</template>
<script>
import {computed, ref} from 'vue';
import TestCard from "@/components/tests/TestCard.vue";
import CatalogTest from "@/components/testing/CatalogTest.vue";
import { axiosApiInstance } from "@/utils/axios-api";
import { ref, computed, watch } from "vue"
export default {
components: {TestCard},
setup() {
const activeTab = ref(0);
const search = ref('');
const headers = [
{text: 'Картинка', value: 'image', sortable: false},
{text: 'Название', value: 'title', align: 'start'},
{text: 'Действия', value: 'actions', sortable: false},
];
const tests = ref([
{
id: 1,
title: 'Комплекс тестовых вопросов на знание в области информационно-коммуникационных технологий',
type: 'test',
description: 'Краткое описание тестирования',
date: '2025-02-28',
questions: 20,
time: '15 минут',
attempts: 1,
image: 'https://icdn.lenta.ru/images/2024/03/27/12/20240327123127525/square_1280_63e6b3d7acbfce65d885ae4cf216dfe2.jpg',
},
{
id: 2,
title: 'Удобство раздела тестирования',
type: 'survey',
description: 'Опрос среди сотрудников ЦОД МФ',
date: '2025-06-22',
questions: 28,
time: null,
attempts: null,
image: 'https://icdn.lenta.ru/images/2024/03/27/12/20240327123127525/square_1280_63e6b3d7acbfce65d885ae4cf216dfe2.jpg',
},
{
id: 3,
title: 'Законченная карточка законченного тестирования',
type: 'survey',
description: 'законченное описание законченного тестирования',
date: '2024-06-22',
questions: 1,
time: null,
attempts: null,
image: 'https://icdn.lenta.ru/images/2024/03/27/12/20240327123127525/square_1280_63e6b3d7acbfce65d885ae4cf216dfe2.jpg',
},
]);
const currentDate = new Date();
const scheduledTests = computed(() => {
return tests.value.filter(test => new Date(test.date) > currentDate);
});
const completedTests = computed(() => {
return tests.value.filter(test => new Date(test.date) <= currentDate);
});
const filteredScheduledTests = computed(() => {
if (!search.value) return scheduledTests.value;
return scheduledTests.value.filter(test =>
test.title.toLowerCase().includes(search.value.toLowerCase())
);
});
const filteredCompletedTests = computed(() => {
if (!search.value) return completedTests.value;
return completedTests.value.filter(test =>
test.title.toLowerCase().includes(search.value.toLowerCase())
);
});
const filteredTests = computed(() => {
if (!search.value) return tests.value.filter(test => new Date(test.date) > currentDate);
return tests.value.filter(test => new Date(test.date) > currentDate)
.filter((test) =>
test.title.toLowerCase().includes(search.value.toLowerCase())
);
});
return {
activeTab,
search,
headers,
tests,
filteredTests,
filteredScheduledTests,
filteredCompletedTests,
scheduledTests,
completedTests,
};
components: {
CatalogTest
},
};
</script>
setup() {
const activeTab = ref(0);
const currentTest = ref('')
const getAllTests = ref([])
<style>
.v-data-table__wrapper {
overflow-x: auto;
const getTestById = () => {
let status = activeTab.value == 0 ? '?status=active' : activeTab.value == 1 ? '?status=completed' : ''
axiosApiInstance.get(`/api/tests/gettests/${status}`).then(resp => getAllTests.value = resp.data).finally(() => {
if (activeTab.value == 0) {
currentTest.value = getAllTests.value.length
}
})
}
getTestById()
watch (() => activeTab.value,
() => {
getTestById()
}
)
const tabs = computed(() => [
{ value: 0, title: `Назначенные (${currentTest.value})`, },
{ value: 1, title: 'Завершенные', },
{ value: 2, title: 'Каталог', },
])
return {
activeTab,
tabs,
getAllTests,
}
}
}
</style>
</script>