SPA-126 готово

This commit is contained in:
Alex committed 2025-01-29 12:56:38 +03:00
1 parent 8f9f49b8ee
commit ffe9142621
3 files changed
+22 -20

No files matched your search

@@ -16,7 +16,7 @@
<v-card v-for="cardValue in searchTest" :key="cardValue.id" class="my-2 border-sm">
<v-row class="pa-2">
<v-col cols="1">
<v-img height="125" :src="cardValue.file" />
<v-img height="125" :src="`${baseURL.slice(0, -1)}` + cardValue.file" />
</v-col>
<v-col cols="auto" class="d-flex flex-grow-1">
<div class="d-flex flex-column justify-center flex-grow-1">
@@ -48,6 +48,7 @@
<script>
import moment from 'moment';
import { declOfNum } from '@/utils/universal_functions'
import { baseURL } from "@/utils/axios-api";
import { ref, computed } from 'vue';
export default {
@@ -140,7 +141,7 @@ export default {
return val
}
return { search, searchTest, momenter, activeTabIcon }
return { search, searchTest, momenter, activeTabIcon, baseURL }
}
}
+18 -17
View File
@@ -6,7 +6,7 @@
<v-tabs-window v-model="activeTab" class="border-t-thin">
<!-- Вкладка назначенные -->
<v-tabs-window-item class="my-2 ">
<CatalogTest title="Назначенные" :activeTab="activeTab" :testingCard="sortedTests">
<CatalogTest title="Назначенные" :activeTab="activeTab" :testingCard="getAllTests">
<template #buttons>
<v-btn color="#00897B1F" class="mr-2 text-teal-darken-1" elevation="0">
Тренироваться
@@ -19,7 +19,7 @@
</v-tabs-window-item>
<!-- Вкладка завершенных -->
<v-tabs-window-item>
<CatalogTest title="Завершенные" :activeTab="activeTab" :testingCard="sortedTests">
<CatalogTest title="Завершенные" :activeTab="activeTab" :testingCard="getAllTests">
<template #results>
<div>
<v-icon icon="mdi-calendar-clock" size="large" />
@@ -44,7 +44,7 @@
</CatalogTest>
</v-tabs-window-item>
</v-tabs-window>
{{ sortedTests }}
{{ getAllTests }}
</v-container>
</template>
@@ -52,7 +52,7 @@
import CatalogTest from "@/components/testing/CatalogTest.vue";
import { axiosApiInstance } from "@/utils/axios-api";
import { ref, computed } from "vue"
import { ref, computed, watch } from "vue"
export default {
components: {
@@ -60,37 +60,38 @@ export default {
},
setup() {
const activeTab = ref(0);
const currentTest = ref('')
const getAllTests = ref([])
const getTestById = () => {
axiosApiInstance.get('/api/tests/testlist/').then(resp => getAllTests.value = resp.data.results)
let status = activeTab.value == 0 ? '?status=active' : activeTab.value == 1 ? '?status=completed' : ''
axiosApiInstance.get(`/api/tests/testlistcreate/${status}`).then(resp => getAllTests.value = resp.data).finally(() => {
if (activeTab.value == 0) {
currentTest.value = getAllTests.value.length
}})
}
getTestById()
const sortedTests = computed(() => {
let sorted = []
return getAllTests.value.filter( test => {
if (test.datesart !== test.dateend) {
return sorted = test
} else if (new Date() > test.dateend) {
return sorted = test
}
})
})
watch (() => activeTab.value,
() => {
getTestById()
}
)
const tabs = computed(() => [
{ value: 0, title: `Назначенные (${getAllTests.value.length})`, },
{ value: 0, title: `Назначенные (${currentTest.value})`, },
{ value: 1, title: 'Завершенные', },
{ value: 2, title: 'Каталог', },
])
return {
activeTab,
tabs,
getAllTests,
sortedTests
}
}
}