Merge branch 'develop' into сja
This commit is contained in:
commit
b355c9777f
4 files changed
+123
-53
No files matched your search
@@ -41,6 +41,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { declOfNum } from '@/utils/universal_functions'
|
||||
import { computed, ref } from 'vue'
|
||||
|
||||
export default {
|
||||
@@ -66,11 +67,6 @@ export default {
|
||||
const hours = computed(() => minutes.value * 60);
|
||||
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({
|
||||
text: 'окончания',
|
||||
disabled: false
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
</v-row>
|
||||
</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-col cols="1">
|
||||
<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 text-disabled mb-2">{{ cardValue.description }}</div>
|
||||
<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" />
|
||||
<span class="ml-1">{{ cardValue[icon.field] }}</span>
|
||||
<span class="ml-1">{{ momenter(cardValue[icon.field], icon.field) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -35,6 +36,7 @@
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-card>
|
||||
<!-- Если данные отсутствуют, выводим сообщение об этом -->
|
||||
<v-container v-if="!searchTest.length" :fluid="true">
|
||||
<v-row class="align-center flex-column">
|
||||
<v-icon icon="mdi-note-off-outline" color="grey-lighten-1" size="x-large" />
|
||||
@@ -44,13 +46,20 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import moment from 'moment';
|
||||
import { declOfNum } from '@/utils/universal_functions'
|
||||
import { baseURL } from "@/utils/axios-api";
|
||||
import { ref, computed } from 'vue';
|
||||
|
||||
export default {
|
||||
props: {
|
||||
title: {
|
||||
type: String,
|
||||
default: 'Не забыть передать тайтл сюда!'
|
||||
default: 'Не забыть передать тайтл сюда!',
|
||||
},
|
||||
activeTab: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
testingCard: {
|
||||
type: Array,
|
||||
@@ -61,10 +70,10 @@ export default {
|
||||
type: 'test',
|
||||
description: 'Краткое описание тестирования',
|
||||
file: 'https://icdn.lenta.ru/images/2024/03/27/12/20240327123127525/square_1280_63e6b3d7acbfce65d885ae4cf216dfe2.jpg',
|
||||
dateend: `до ${'31.02.2025'}`,
|
||||
questionCount: 20,
|
||||
time: '15 минут',
|
||||
attempts_number: 1,
|
||||
dateend: new Date(),
|
||||
question_count: 20,
|
||||
time: 20,
|
||||
attemps_number: 3,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
@@ -72,16 +81,25 @@ export default {
|
||||
type: 'test',
|
||||
description: 'Опрос среди сотрудников ЦОД МФ',
|
||||
file: 'https://icdn.lenta.ru/images/2024/03/27/12/20240327123127525/square_1280_63e6b3d7acbfce65d885ae4cf216dfe2.jpg',
|
||||
dateend: `до ${'31.06.2025'}`,
|
||||
questionCount: 28,
|
||||
time: '15 минут',
|
||||
dateend: new Date(),
|
||||
question_count: 28,
|
||||
time: 15,
|
||||
attemps_number: 1,
|
||||
},
|
||||
]
|
||||
}
|
||||
},
|
||||
setup(props) {
|
||||
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',
|
||||
field: 'dateend',
|
||||
@@ -89,28 +107,41 @@ export default {
|
||||
},
|
||||
{
|
||||
icon: 'mdi-clipboard-list-outline',
|
||||
field: 'questionCount',
|
||||
field: 'question_count',
|
||||
color: 'teal-darken-1',
|
||||
},
|
||||
// иконки для использования на вкладке назначенные использовать можно эти
|
||||
// {
|
||||
// icon: 'mdi-timer-outline',
|
||||
// field: 'time',
|
||||
// color: 'teal-darken-1',
|
||||
// },
|
||||
// {
|
||||
// icon: 'mdi-fire',
|
||||
// field: 'attempts_number',
|
||||
// color: '#FF9800'
|
||||
// },
|
||||
{
|
||||
icon: 'mdi-timer-outline',
|
||||
field: 'time',
|
||||
color: 'teal-darken-1',
|
||||
},
|
||||
{
|
||||
icon: 'mdi-fire',
|
||||
field: 'attemps_number',
|
||||
color: '#FF9800'
|
||||
},
|
||||
]
|
||||
|
||||
const searchTest = computed(() => {
|
||||
if (!search.value) return props.testingCard
|
||||
return props.testingCard.filter(item => item.name.toLowerCase().includes(search.value.toLowerCase()))
|
||||
if (props.activeTab == 0) {
|
||||
return icons
|
||||
} else {
|
||||
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 }
|
||||
// }
|
||||
|
||||
// Функция склонения числительных
|
||||
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]];
|
||||
}
|
||||
@@ -4,14 +4,9 @@
|
||||
<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 />
|
||||
</v-tabs-window-item>
|
||||
<v-tabs-window-item>
|
||||
<div>Сюда заврешенные!</div>
|
||||
</v-tabs-window-item>
|
||||
<v-tabs-window-item>
|
||||
<CatalogTest title="Каталог">
|
||||
<CatalogTest title="Назначенные" :activeTab="activeTab" :testingCard="getAllTests">
|
||||
<template #buttons>
|
||||
<v-btn color="#00897B1F" class="mr-2 text-teal-darken-1" elevation="0">
|
||||
Тренироваться
|
||||
@@ -22,13 +17,42 @@
|
||||
</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>
|
||||
{{ getAllTests }}
|
||||
</v-container>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
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 {
|
||||
components: {
|
||||
@@ -36,25 +60,38 @@ export default {
|
||||
},
|
||||
setup() {
|
||||
const activeTab = ref(0);
|
||||
const currentTest = ref('')
|
||||
|
||||
const getAllTests = ref([])
|
||||
|
||||
const test = [
|
||||
{
|
||||
text: 'awdawd',
|
||||
},
|
||||
{
|
||||
text: 'awdawd',
|
||||
},
|
||||
]
|
||||
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 = ref([
|
||||
{ value: 0, title: `Назначенные (${test.length})`, },
|
||||
getTestById()
|
||||
|
||||
watch (() => activeTab.value,
|
||||
() => {
|
||||
getTestById()
|
||||
}
|
||||
)
|
||||
|
||||
const tabs = computed(() => [
|
||||
{ value: 0, title: `Назначенные (${currentTest.value})`, },
|
||||
{ value: 1, title: 'Завершенные', },
|
||||
{ value: 2, title: 'Каталог', },
|
||||
])
|
||||
|
||||
|
||||
return {
|
||||
activeTab,
|
||||
tabs
|
||||
tabs,
|
||||
getAllTests,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user