feat: create slots for button, universal funcrion
This commit is contained in:
1 parent
016e19d1bf
commit
d125712ee6
4 files changed
+60
-43
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
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
<div class="d-flex ga-4">
|
||||
<div v-for="icon in icons">
|
||||
<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>
|
||||
@@ -44,6 +44,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import moment from 'moment';
|
||||
import { declOfNum } from '@/utils/universal_functions'
|
||||
import { ref, computed } from 'vue';
|
||||
|
||||
export default {
|
||||
@@ -61,10 +63,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,9 +74,10 @@ 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,
|
||||
},
|
||||
]
|
||||
}
|
||||
@@ -82,25 +85,25 @@ export default {
|
||||
setup(props) {
|
||||
const search = ref('');
|
||||
const icons = [
|
||||
{
|
||||
icon: 'mdi-calendar-clock',
|
||||
field: 'dateend',
|
||||
color: 'teal-darken-1',
|
||||
},
|
||||
{
|
||||
icon: 'mdi-clipboard-list-outline',
|
||||
field: 'questionCount',
|
||||
color: 'teal-darken-1',
|
||||
},
|
||||
// иконки для использования на вкладке назначенные использовать можно эти
|
||||
// {
|
||||
// icon: 'mdi-timer-outline',
|
||||
// field: 'time',
|
||||
// icon: 'mdi-calendar-clock',
|
||||
// field: 'dateend',
|
||||
// color: 'teal-darken-1',
|
||||
// },
|
||||
{
|
||||
icon: 'mdi-clipboard-list-outline',
|
||||
field: 'question_count',
|
||||
color: 'teal-darken-1',
|
||||
},
|
||||
{
|
||||
icon: 'mdi-timer-outline',
|
||||
field: 'time',
|
||||
color: 'teal-darken-1',
|
||||
},
|
||||
// {
|
||||
// icon: 'mdi-fire',
|
||||
// field: 'attempts_number',
|
||||
// field: 'attemps_number',
|
||||
// color: '#FF9800'
|
||||
// },
|
||||
]
|
||||
@@ -110,7 +113,20 @@ export default {
|
||||
return props.testingCard.filter(item => item.name.toLowerCase().includes(search.value.toLowerCase()))
|
||||
})
|
||||
|
||||
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 + ' вопросов'
|
||||
}
|
||||
else if (field == 'time') {
|
||||
return val + declOfNum(val, [' минута', ' минуты', ' минут'])
|
||||
}
|
||||
return val
|
||||
}
|
||||
|
||||
return { icons, search, searchTest, momenter }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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]];
|
||||
}
|
||||
@@ -11,14 +11,11 @@
|
||||
<div>Сюда заврешенные!</div>
|
||||
</v-tabs-window-item>
|
||||
<v-tabs-window-item>
|
||||
<CatalogTest title="Каталог">
|
||||
<CatalogTest title="Каталог" :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>
|
||||
@@ -28,7 +25,9 @@
|
||||
|
||||
<script>
|
||||
import CatalogTest from "@/components/testing/CatalogTest.vue";
|
||||
import { ref } from "vue"
|
||||
import { axiosApiInstance } from "@/utils/axios-api";
|
||||
|
||||
import { ref, computed } from "vue"
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@@ -36,25 +35,25 @@ export default {
|
||||
},
|
||||
setup() {
|
||||
const activeTab = ref(0);
|
||||
|
||||
const getAllTests = ref([])
|
||||
|
||||
const test = [
|
||||
{
|
||||
text: 'awdawd',
|
||||
},
|
||||
{
|
||||
text: 'awdawd',
|
||||
},
|
||||
]
|
||||
const getTestById = () => {
|
||||
axiosApiInstance.get('/api/tests/testlist/').then(resp => getAllTests.value = resp.data.results)
|
||||
}
|
||||
|
||||
const tabs = ref([
|
||||
{ value: 0, title: `Назначенные (${test.length})`, },
|
||||
getTestById()
|
||||
|
||||
const tabs = computed(() => [
|
||||
{ value: 0, title: `Назначенные (${getAllTests.value.length})`, },
|
||||
{ value: 1, title: 'Завершенные', },
|
||||
{ value: 2, title: 'Каталог', },
|
||||
])
|
||||
|
||||
return {
|
||||
activeTab,
|
||||
tabs
|
||||
tabs,
|
||||
getAllTests
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user