Merge branch 'develop' into сja

This commit is contained in:
Cja committed 2025-01-30 12:00:15 +03:00
commit b355c9777f
4 files changed
+123 -53

No files matched your search

+1 -5
View File
@@ -41,6 +41,7 @@
</template> </template>
<script> <script>
import { declOfNum } from '@/utils/universal_functions'
import { computed, ref } from 'vue' import { computed, ref } from 'vue'
export default { export default {
@@ -66,11 +67,6 @@ export default {
const hours = computed(() => minutes.value * 60); const hours = computed(() => minutes.value * 60);
const days = computed(() => hours.value * 24); const days = computed(() => hours.value * 24);
function declOfNum(value, titles) {
const cases = [2, 0, 1, 1, 1, 2];
return titles[(value % 100 > 4 && value % 100 < 20) ? 2 : cases[(value % 10 < 5) ? value % 10 : 5]];
}
const disabledcard = ref({ const disabledcard = ref({
text: 'окончания', text: 'окончания',
disabled: false disabled: false
@@ -13,7 +13,7 @@
</v-row> </v-row>
</v-container> </v-container>
<!-- Карточка где буду отрисовываться тесты в цикле --> <!-- Карточка где буду отрисовываться тесты в цикле -->
<v-card v-for="cardValue in searchTest" :key="cardValue.id" class="my-2"> <v-card v-for="cardValue in searchTest" :key="cardValue.id" class="my-2 border-sm">
<v-row class="pa-2"> <v-row class="pa-2">
<v-col cols="1"> <v-col cols="1">
<v-img height="125" :src="cardValue.file" /> <v-img height="125" :src="cardValue.file" />
@@ -23,9 +23,10 @@
<div class="text-body-1 font-weight-medium mb-2">{{ cardValue.name }}</div> <div class="text-body-1 font-weight-medium mb-2">{{ cardValue.name }}</div>
<div class="text-body-1 text-disabled mb-2">{{ cardValue.description }}</div> <div class="text-body-1 text-disabled mb-2">{{ cardValue.description }}</div>
<div class="d-flex ga-4"> <div class="d-flex ga-4">
<div v-for="icon in icons"> <slot name="results"></slot>
<div v-for="icon in activeTabIcon">
<v-icon :color="icon.color" :icon="icon.icon" size="large" /> <v-icon :color="icon.color" :icon="icon.icon" size="large" />
<span class="ml-1">{{ cardValue[icon.field] }}</span> <span class="ml-1">{{ momenter(cardValue[icon.field], icon.field) }}</span>
</div> </div>
</div> </div>
</div> </div>
@@ -35,6 +36,7 @@
</v-col> </v-col>
</v-row> </v-row>
</v-card> </v-card>
<!-- Если данные отсутствуют, выводим сообщение об этом -->
<v-container v-if="!searchTest.length" :fluid="true"> <v-container v-if="!searchTest.length" :fluid="true">
<v-row class="align-center flex-column"> <v-row class="align-center flex-column">
<v-icon icon="mdi-note-off-outline" color="grey-lighten-1" size="x-large" /> <v-icon icon="mdi-note-off-outline" color="grey-lighten-1" size="x-large" />
@@ -44,13 +46,20 @@
</template> </template>
<script> <script>
import moment from 'moment';
import { declOfNum } from '@/utils/universal_functions'
import { baseURL } from "@/utils/axios-api";
import { ref, computed } from 'vue'; import { ref, computed } from 'vue';
export default { export default {
props: { props: {
title: { title: {
type: String, type: String,
default: 'Не забыть передать тайтл сюда!' default: 'Не забыть передать тайтл сюда!',
},
activeTab: {
type: Number,
default: 0,
}, },
testingCard: { testingCard: {
type: Array, type: Array,
@@ -61,10 +70,10 @@ export default {
type: 'test', type: 'test',
description: 'Краткое описание тестирования', description: 'Краткое описание тестирования',
file: 'https://icdn.lenta.ru/images/2024/03/27/12/20240327123127525/square_1280_63e6b3d7acbfce65d885ae4cf216dfe2.jpg', file: 'https://icdn.lenta.ru/images/2024/03/27/12/20240327123127525/square_1280_63e6b3d7acbfce65d885ae4cf216dfe2.jpg',
dateend: `до ${'31.02.2025'}`, dateend: new Date(),
questionCount: 20, question_count: 20,
time: '15 минут', time: 20,
attempts_number: 1, attemps_number: 3,
}, },
{ {
id: 2, id: 2,
@@ -72,16 +81,25 @@ export default {
type: 'test', type: 'test',
description: 'Опрос среди сотрудников ЦОД МФ', description: 'Опрос среди сотрудников ЦОД МФ',
file: 'https://icdn.lenta.ru/images/2024/03/27/12/20240327123127525/square_1280_63e6b3d7acbfce65d885ae4cf216dfe2.jpg', file: 'https://icdn.lenta.ru/images/2024/03/27/12/20240327123127525/square_1280_63e6b3d7acbfce65d885ae4cf216dfe2.jpg',
dateend: `до ${'31.06.2025'}`, dateend: new Date(),
questionCount: 28, question_count: 28,
time: '15 минут', time: 15,
attemps_number: 1,
}, },
] ]
} }
}, },
setup(props) { setup(props) {
const search = ref(''); const search = ref('');
const icons = [
const searchTest = computed(() => {
if (!search.value) return props.testingCard
return props.testingCard.filter(item => item.name.toLowerCase().includes(search.value.toLowerCase()))
})
const activeTabIcon = computed(() => {
let icons = [
// иконки для использования в карточках
{ {
icon: 'mdi-calendar-clock', icon: 'mdi-calendar-clock',
field: 'dateend', field: 'dateend',
@@ -89,28 +107,41 @@ export default {
}, },
{ {
icon: 'mdi-clipboard-list-outline', icon: 'mdi-clipboard-list-outline',
field: 'questionCount', field: 'question_count',
color: 'teal-darken-1', color: 'teal-darken-1',
}, },
// иконки для использования на вкладке назначенные использовать можно эти {
// { icon: 'mdi-timer-outline',
// icon: 'mdi-timer-outline', field: 'time',
// field: 'time', color: 'teal-darken-1',
// color: 'teal-darken-1', },
// }, {
// { icon: 'mdi-fire',
// icon: 'mdi-fire', field: 'attemps_number',
// field: 'attempts_number', color: '#FF9800'
// color: '#FF9800' },
// },
] ]
if (props.activeTab == 0) {
const searchTest = computed(() => { return icons
if (!search.value) return props.testingCard } else {
return props.testingCard.filter(item => item.name.toLowerCase().includes(search.value.toLowerCase())) return icons.splice(1,2)
}
}) })
return { icons, search, searchTest } const momenter = (val, field)=>{
if (field == 'dateend'){
return 'до ' + moment(val).format('DD.MM.YYYY, HH:mm')
}
else if (field == 'question_count') {
return val + declOfNum(val, [' вопрос', ' вопроса', ' вопросов'])
}
else if (field == 'time') {
return val + declOfNum(val, [' минута', ' минуты', ' минут'])
}
return val
}
return { search, searchTest, momenter, activeTabIcon, baseURL }
} }
} }
@@ -172,3 +172,9 @@ export function useICalReader(url) {
// return { icsContent, fetchICalFile } // return { icsContent, fetchICalFile }
// } // }
// Функция склонения числительных
export function declOfNum(value, titles) {
const cases = [2, 0, 1, 1, 1, 2];
return titles[(value % 100 > 4 && value % 100 < 20) ? 2 : cases[(value % 10 < 5) ? value % 10 : 5]];
}
+56 -19
View File
@@ -4,14 +4,9 @@
<v-tab v-for="tab in tabs" :key="tab.value" :value="tab.value"> {{ tab.title }} </v-tab> <v-tab v-for="tab in tabs" :key="tab.value" :value="tab.value"> {{ tab.title }} </v-tab>
</v-tabs> </v-tabs>
<v-tabs-window v-model="activeTab" class="border-t-thin"> <v-tabs-window v-model="activeTab" class="border-t-thin">
<!-- Вкладка назначенные -->
<v-tabs-window-item class="my-2 "> <v-tabs-window-item class="my-2 ">
<CatalogTest /> <CatalogTest title="Назначенные" :activeTab="activeTab" :testingCard="getAllTests">
</v-tabs-window-item>
<v-tabs-window-item>
<div>Сюда заврешенные!</div>
</v-tabs-window-item>
<v-tabs-window-item>
<CatalogTest title="Каталог">
<template #buttons> <template #buttons>
<v-btn color="#00897B1F" class="mr-2 text-teal-darken-1" elevation="0"> <v-btn color="#00897B1F" class="mr-2 text-teal-darken-1" elevation="0">
Тренироваться Тренироваться
@@ -22,13 +17,42 @@
</template> </template>
</CatalogTest> </CatalogTest>
</v-tabs-window-item> </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-tabs-window>
{{ getAllTests }}
</v-container> </v-container>
</template> </template>
<script> <script>
import CatalogTest from "@/components/testing/CatalogTest.vue"; import CatalogTest from "@/components/testing/CatalogTest.vue";
import { ref } from "vue" import { axiosApiInstance } from "@/utils/axios-api";
import { ref, computed, watch } from "vue"
export default { export default {
components: { components: {
@@ -36,25 +60,38 @@ export default {
}, },
setup() { setup() {
const activeTab = ref(0); const activeTab = ref(0);
const currentTest = ref('')
const getAllTests = ref([])
const test = [ const getTestById = () => {
{ let status = activeTab.value == 0 ? '?status=active' : activeTab.value == 1 ? '?status=completed' : ''
text: 'awdawd', axiosApiInstance.get(`/api/tests/gettests/${status}`).then(resp => getAllTests.value = resp.data).finally(() => {
}, if (activeTab.value == 0) {
{ currentTest.value = getAllTests.value.length
text: 'awdawd', }
}, })
] }
const tabs = ref([ getTestById()
{ value: 0, title: `Назначенные (${test.length})`, },
watch (() => activeTab.value,
() => {
getTestById()
}
)
const tabs = computed(() => [
{ value: 0, title: `Назначенные (${currentTest.value})`, },
{ value: 1, title: 'Завершенные', }, { value: 1, title: 'Завершенные', },
{ value: 2, title: 'Каталог', }, { value: 2, title: 'Каталог', },
]) ])
return { return {
activeTab, activeTab,
tabs tabs,
getAllTests,
} }
} }
} }