Update TestHomePage.vue

This commit is contained in:
Nukeap committed 2025-02-05 08:46:08 +03:00
1 parent 1e34447b1e
commit c8c465f5cc
1 file changed
+76 -75
+76 -75
View File
@@ -1,99 +1,100 @@
<template>
<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 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 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-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>
</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-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 CatalogTest from "@/components/testing/CatalogTest.vue";
import { axiosApiInstance } from "@/utils/axios-api";
import CatalogTest from '@/components/testing/CatalogTest.vue';
import { axiosApiInstance } from '@/utils/axios-api';
import { ref, computed, watch } from "vue"
import { ref, computed, watch } from 'vue';
export default {
components: {
CatalogTest
CatalogTest,
},
setup() {
const activeTab = ref(0);
const currentTest = ref('')
const getAllTests = ref([])
const activeTab = ref(0);
const currentTest = ref('');
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
}
})
}
const getAllTests = ref([]);
getTestById()
watch (() => activeTab.value,
() => {
getTestById()
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;
}
)
});
};
const tabs = computed(() => [
{ value: 0, title: `Назначенные (${currentTest.value})`, },
{ value: 1, title: 'Завершенные', },
{ value: 2, title: 'Каталог', },
])
getTestById();
watch(
() => activeTab.value,
() => {
getTestById();
},
);
return {
activeTab,
tabs,
getAllTests,
}
}
}
</script>
const tabs = computed(() => [
{ value: 0, title: `Назначенные (${currentTest.value})` },
{ value: 1, title: 'Завершенные' },
{ value: 2, title: 'Каталог' },
]);
return {
activeTab,
tabs,
getAllTests,
};
},
};
</script>