Merge branch 'denz' into dkr
This commit is contained in:
commit
6fceeeb804
340 files changed
+155901
-1965
No files matched your search
@@ -4,4 +4,4 @@ module.exports = {
|
||||
node: true,
|
||||
},
|
||||
extends: ['plugin:vue/vue3-essential', 'eslint:recommended', 'plugin:storybook/recommended'],
|
||||
}
|
||||
};
|
||||
@@ -1,11 +1,14 @@
|
||||
<template>
|
||||
<!-- Инициализация проекта -->
|
||||
<router-view />
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { useAccountStore } from '@/store/AccountStore';
|
||||
/**
|
||||
* Получаем информацию о юзере из стора.
|
||||
*/
|
||||
const accountStore = useAccountStore();
|
||||
|
||||
accountStore.setUser(accountStore.getuserFromStorage());
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,66 +1,97 @@
|
||||
<!-- Обратный отсчет: Компонент для отображения оставшегося времени голосования -->
|
||||
<template>
|
||||
<h6>ДО КОНЦА ГОЛОСОВАНИЯ ОСТАЛОСЬ:</h6>
|
||||
<div class="text-red text-h6">{{ displayDays }} дней {{ displayHours }} часов {{ displayMinutes }} минут</div>
|
||||
<h6>ДО КОНЦА ГОЛОСОВАНИЯ ОСТАЛОСЬ:</h6>
|
||||
<div class="text-red text-h6">
|
||||
{{ displayDays }} дней {{ displayHours }} часов {{ displayMinutes }} минут
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { onMounted, ref } from 'vue';
|
||||
|
||||
export default {
|
||||
data: () => ({
|
||||
displayDays: 0,
|
||||
displayHours: 0,
|
||||
displayMinutes: 0
|
||||
}),
|
||||
setup() {
|
||||
/**
|
||||
* Хранит количество оставшихся дней.
|
||||
*/
|
||||
const displayDays = ref(0);
|
||||
|
||||
computed: {
|
||||
_seconds: () => 1000,
|
||||
_minutes() {
|
||||
return this._seconds * 60
|
||||
},
|
||||
_hours() {
|
||||
return this._minutes * 60
|
||||
},
|
||||
_days() {
|
||||
return this._hours * 24
|
||||
/**
|
||||
* Хранит количество оставшихся часов.
|
||||
*/
|
||||
const displayHours = ref(0);
|
||||
|
||||
/**
|
||||
* Хранит количество оставшихся минут.
|
||||
*/
|
||||
const displayMinutes = ref(0);
|
||||
|
||||
/**
|
||||
* Определяет количество миллисекунд в одной секунде.
|
||||
*/
|
||||
const _seconds = 1000;
|
||||
|
||||
/**
|
||||
* Определяет количество миллисекунд в одной минуте.
|
||||
*/
|
||||
const _minutes = _seconds * 60;
|
||||
|
||||
/**
|
||||
* Определяет количество миллисекунд в одном часе.
|
||||
*/
|
||||
const _hours = _minutes * 60;
|
||||
|
||||
/**
|
||||
* Определяет количество миллисекунд в одном дне.
|
||||
*/
|
||||
const _days = _hours * 24;
|
||||
|
||||
/**
|
||||
* @arrowFunc
|
||||
* Обрабатывает обратный отсчет до окончания голосования.
|
||||
*/
|
||||
const countDown = () => {
|
||||
const timer = setInterval(() => {
|
||||
const now = new Date();
|
||||
// Здесь задается конец отчета (год, месяц, день, часы, минуты, секунды)
|
||||
const end = new Date(2025, 0, 13, 23, 59, 59);
|
||||
const distance = end.getTime() - now.getTime();
|
||||
|
||||
if (distance < 0) {
|
||||
clearInterval(timer);
|
||||
return;
|
||||
}
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.countDown();
|
||||
},
|
||||
const daysLeft = Math.floor(distance / _days);
|
||||
const hoursLeft = Math.floor((distance % _days) / _hours);
|
||||
const minutesLeft = Math.floor((distance % _hours) / _minutes);
|
||||
|
||||
methods: {
|
||||
countDown() {
|
||||
const timer = setInterval(() => {
|
||||
const now = new Date();
|
||||
// здесь задается конец отчета (гггг, мм, дд, остальные цифры не меняются)
|
||||
const end = new Date(2025, 0, 13, 23, 59, 59);
|
||||
const distance = end.getTime() - now.getTime();
|
||||
|
||||
if (distance < 0) {
|
||||
clearInterval(timer);
|
||||
return
|
||||
}
|
||||
|
||||
const days = Math.floor(distance / this._days);
|
||||
const hours = Math.floor((distance % this._days) / this._hours);
|
||||
const minutes = Math.floor((distance % this._hours) / this._minutes);
|
||||
|
||||
this.displayMinutes = minutes < 10 ? "0" + minutes : minutes;
|
||||
this.displayHours = minutes < 10 & minutes > 10 ? "0" + hours : hours;
|
||||
this.displayDays = days;
|
||||
}, 1000)
|
||||
}
|
||||
}
|
||||
displayDays.value = daysLeft;
|
||||
displayHours.value = hoursLeft < 10 ? '0' + hoursLeft : hoursLeft;
|
||||
displayMinutes.value = minutesLeft < 10 ? '0' + minutesLeft : minutesLeft;
|
||||
}, 1000);
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
countDown();
|
||||
});
|
||||
|
||||
return {
|
||||
displayDays,
|
||||
displayHours,
|
||||
displayMinutes,
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.card-count {
|
||||
font-size: 3em;
|
||||
color: #ff0000;
|
||||
font-size: 3em;
|
||||
color: #ff0000;
|
||||
}
|
||||
|
||||
.card-sub-title {
|
||||
font-size: 1.2em;
|
||||
font-size: 1.2em;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
@@ -1,4 +1,5 @@
|
||||
<template>
|
||||
<!-- Карусель: Компонент для отображения изображений и видео с сервера в виде карусели -->
|
||||
<v-carousel
|
||||
v-model="currentslide"
|
||||
:interval="interval"
|
||||
@@ -14,7 +15,7 @@
|
||||
<template v-for="(x, i) in carous" :key="i">
|
||||
<v-carousel-item v-if="!x.link.endsWith('mp4')" :src="`${burl}${x.link}`" cover eager>
|
||||
<v-container fill-height fluid pa-0 ma-0 pb-3 class="flex-column h-100 d-flex">
|
||||
<v-card v-if="x.text != '' || x.title != null" class="bgCard h-100 d-flex flex-column">
|
||||
<v-card v-if="x.text !== '' || x.title != null" class="bgCard h-100 d-flex flex-column">
|
||||
<v-card-title
|
||||
v-if="x.title != null"
|
||||
class="text-h3 text-uppercase titles text-text_carous ma-1 mb-0"
|
||||
@@ -29,7 +30,7 @@
|
||||
</v-row>
|
||||
</v-card-title>
|
||||
<v-card-text
|
||||
v-if="x.text != ''"
|
||||
v-if="x.text !== ''"
|
||||
class="w-50 flex-grow-0 text-h6 bgText overflow-auto ma-1 pa-0"
|
||||
>
|
||||
<v-textarea
|
||||
@@ -58,11 +59,9 @@
|
||||
@loadedmetadata="interval = 10000000000"
|
||||
>
|
||||
<source :src="`${burl}${x.link}`" type="video/mp4" />
|
||||
|
||||
Текущий браузер не поддерживает воспроизведение этого видео.
|
||||
</video>
|
||||
</div>
|
||||
<!-- currentslide=currentslide<carous.length-1?currentslide+1:0 -->
|
||||
</v-carousel-item>
|
||||
</template>
|
||||
</v-carousel>
|
||||
@@ -76,15 +75,43 @@ import { useAlertStore } from '@/store/useAlertStore';
|
||||
|
||||
export default {
|
||||
setup() {
|
||||
/**
|
||||
* Хранит индекс текущего слайда карусели.
|
||||
*/
|
||||
const currentslide = ref(0);
|
||||
|
||||
/**
|
||||
* Базовый URL для загрузки медиа.
|
||||
*/
|
||||
const burl = baseURL.slice(0, -1);
|
||||
|
||||
/**
|
||||
* Ссылка на элемент видео.
|
||||
*/
|
||||
const videoElement = ref(null);
|
||||
|
||||
/**
|
||||
* Хранит массив данных карусели, по умолчанию содержит одно изображение.
|
||||
*/
|
||||
const carous = ref([{ link: `/media/newsimage/scales.jpg`, title: null, text: '' }]);
|
||||
|
||||
/**
|
||||
* Получает объект alert из хранилища alert для уведомлений.
|
||||
*/
|
||||
const feedalert = useAlertStore().alert;
|
||||
|
||||
/**
|
||||
* Интервал переключения слайдов в миллисекундах.
|
||||
*/
|
||||
const interval = ref(10000);
|
||||
|
||||
/**
|
||||
* @arrowFunc
|
||||
* Обрабатывает запрос для получения данных карусели с сервера.
|
||||
*/
|
||||
const getfromserver = () => {
|
||||
axiosApiInstance.get('api/navigation/carousels/').then((result) => {
|
||||
if (result.data.mess != '') {
|
||||
if (result.data.mess !== '') {
|
||||
feedalert.alert = true;
|
||||
feedalert.text = result.data.mess;
|
||||
feedalert.color = 'red-darken-2';
|
||||
@@ -98,18 +125,18 @@ export default {
|
||||
};
|
||||
|
||||
getfromserver();
|
||||
const interval = ref(10000);
|
||||
|
||||
/**
|
||||
* @arrowFunc
|
||||
* Управляет изменением слайда и переключением интервала в зависимости от типа медиа.
|
||||
*/
|
||||
const slidechanged = () => {
|
||||
if (carous.value[currentslide.value].link.endsWith('mp4')) {
|
||||
// При переключении на видео, останавливаем все другие видео
|
||||
videoElement.value.forEach((e) => {
|
||||
if (e.currentSrc != burl + carous.value[currentslide.value].link) {
|
||||
if (e.currentSrc !== burl + carous.value[currentslide.value].link) {
|
||||
e.pause();
|
||||
}
|
||||
// else{
|
||||
// console.log("sdflkhlh");
|
||||
// e.play()
|
||||
// }
|
||||
});
|
||||
}
|
||||
|
||||
@@ -119,6 +146,12 @@ export default {
|
||||
interval.value = 10000;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @arrowFunc
|
||||
* Обрабатывает окончание воспроизведения видео и переключает слайд.
|
||||
* @param {Object} val Событие окончания воспроизведения видео.
|
||||
*/
|
||||
const ended = (val) => {
|
||||
val.target.currentTime = 0;
|
||||
val.target.pause();
|
||||
@@ -131,8 +164,8 @@ export default {
|
||||
slidechanged,
|
||||
videoElement,
|
||||
currentslide,
|
||||
getfromserver,
|
||||
interval,
|
||||
|
||||
burl,
|
||||
carous,
|
||||
ended,
|
||||
@@ -140,7 +173,6 @@ export default {
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.titles {
|
||||
font-family: cursive !important;
|
||||
|
||||
@@ -1,101 +1,73 @@
|
||||
<template>
|
||||
<v-card class="d-flex ml-3">
|
||||
<v-sheet
|
||||
class="mx-auto"
|
||||
elevation="0"
|
||||
max-width="813"
|
||||
|
||||
>
|
||||
<v-slide-group
|
||||
v-model="model"
|
||||
class="pa-0"
|
||||
selected-class="bg-primary"
|
||||
mandatory
|
||||
show-arrows
|
||||
|
||||
>
|
||||
|
||||
<v-slide-group-item
|
||||
v-for="n in digitalData"
|
||||
:key="n"
|
||||
|
||||
>
|
||||
|
||||
|
||||
<v-card
|
||||
|
||||
class="ma-2 mt-4 d-flex flex-column"
|
||||
height="100"
|
||||
width="169"
|
||||
elevation="0"
|
||||
|
||||
>
|
||||
<!-- <v-img
|
||||
height="100"
|
||||
:src="`${burl}${n.img}`"
|
||||
cover
|
||||
class="text-white"
|
||||
> -->
|
||||
<v-card class="h-100 text-center g text-black_grey">
|
||||
<v-card-title class="statstyle my-2 py-0 text-overline font-weight-bold">
|
||||
{{n.status}}
|
||||
</v-card-title>
|
||||
<v-card-text class="numstyle mt-4 py-0 font-weight-bold">
|
||||
<vue3-autocounter ref='counter' :startAmount='0' :endAmount='Number(n.num)' :duration='1'/>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
|
||||
<!-- </v-img> -->
|
||||
</v-card>
|
||||
|
||||
|
||||
</v-slide-group-item>
|
||||
</v-slide-group>
|
||||
</v-sheet>
|
||||
<!-- Компонент данных: Отображает цифры в виде слайд-группы карточек с анимацией счетчика -->
|
||||
<v-card class="d-flex ml-3">
|
||||
<v-sheet class="mx-auto" elevation="0" max-width="813">
|
||||
<v-slide-group v-model="model" class="pa-0" mandatory selected-class="bg-primary" show-arrows>
|
||||
<v-slide-group-item v-for="n in digitalData" :key="n">
|
||||
<v-card class="ma-2 mt-4 d-flex flex-column" elevation="0" height="100" width="169">
|
||||
<v-card class="h-100 text-center g text-black_grey">
|
||||
<v-card-title class="statstyle my-2 py-0 text-overline font-weight-bold">
|
||||
{{ n.status }}
|
||||
</v-card-title>
|
||||
<v-card-text class="numstyle mt-4 py-0 font-weight-bold">
|
||||
<vue3-autocounter
|
||||
ref="counter"
|
||||
:duration="1"
|
||||
:endAmount="Number(n.num)"
|
||||
:startAmount="0"
|
||||
/>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</v-card>
|
||||
</v-slide-group-item>
|
||||
</v-slide-group>
|
||||
</v-sheet>
|
||||
</v-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ref } from 'vue'
|
||||
import { baseURL } from '@/utils/axios-api'
|
||||
|
||||
import { ref } from 'vue';
|
||||
import { baseURL } from '@/utils/axios-api';
|
||||
|
||||
export default {
|
||||
|
||||
|
||||
|
||||
props: {
|
||||
digitalData: {
|
||||
type: Object,
|
||||
default: {}
|
||||
}
|
||||
props: {
|
||||
digitalData: {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
comment: 'Объект с данными для отображения',
|
||||
},
|
||||
},
|
||||
|
||||
setup() {
|
||||
const burl = baseURL.slice(0,-1)
|
||||
const model = ref(false)
|
||||
|
||||
setup() {
|
||||
/**
|
||||
* Получает базовый URL из конфигурации axios.
|
||||
*/
|
||||
const burl = baseURL.slice(0, -1);
|
||||
|
||||
return {model, burl}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Хранит выбранное значение модели для v-slide-group.
|
||||
*/
|
||||
const model = ref(false);
|
||||
|
||||
return { model, burl };
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.numstyle {
|
||||
font-size: 2.875rem!important;
|
||||
line-height: 2.5rem!important;
|
||||
font-family: cursive !important;
|
||||
background: #ffffffb0;
|
||||
font-size: 2.875rem !important;
|
||||
line-height: 2.5rem !important;
|
||||
font-family: cursive !important;
|
||||
background: #ffffffb0;
|
||||
}
|
||||
|
||||
.statstyle {
|
||||
background: #ffffffb0;
|
||||
font-size: 1rem!important;
|
||||
background: #ffffffb0;
|
||||
font-size: 1rem !important;
|
||||
}
|
||||
|
||||
.g {
|
||||
/* background-color: rgb(240 248 255 / 35%);; */
|
||||
background-color: rgb(255 255 255);;
|
||||
background-color: rgb(255, 255, 255);
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
File renamed without changes.
@@ -1,10 +1,8 @@
|
||||
|
||||
|
||||
<template>
|
||||
<Line :data="data" :options="options" />
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
<script>
|
||||
import {
|
||||
Chart as ChartJS,
|
||||
CategoryScale,
|
||||
@@ -14,12 +12,12 @@ import {
|
||||
Title,
|
||||
Tooltip,
|
||||
Legend,
|
||||
TimeScale
|
||||
} from 'chart.js'
|
||||
import { Line } from 'vue-chartjs'
|
||||
import * as chartConfig from './chartConfig.js'
|
||||
import ChartDataLabels from 'chartjs-plugin-datalabels'
|
||||
import 'chartjs-adapter-moment'
|
||||
TimeScale,
|
||||
} from 'chart.js';
|
||||
import { Line } from 'vue-chartjs';
|
||||
import * as chartConfig from './chartConfig.js';
|
||||
import ChartDataLabels from 'chartjs-plugin-datalabels';
|
||||
import 'chartjs-adapter-moment';
|
||||
ChartJS.register(
|
||||
ChartDataLabels,
|
||||
CategoryScale,
|
||||
@@ -29,16 +27,16 @@ ChartJS.register(
|
||||
Title,
|
||||
Tooltip,
|
||||
Legend,
|
||||
TimeScale
|
||||
)
|
||||
TimeScale,
|
||||
);
|
||||
|
||||
export default {
|
||||
name: 'App',
|
||||
components: {
|
||||
Line
|
||||
Line,
|
||||
},
|
||||
data() {
|
||||
return chartConfig
|
||||
}
|
||||
}
|
||||
return chartConfig;
|
||||
},
|
||||
};
|
||||
</script>
|
||||
@@ -0,0 +1,37 @@
|
||||
<template>
|
||||
<v-container class="pa-4">
|
||||
<v-row class="justify-center mt-6">
|
||||
<v-col cols="12" md="8" lg="6">
|
||||
<v-card elevation="2">
|
||||
<v-card-title class="text-h6 font-weight-bold">Информация</v-card-title>
|
||||
<v-card-text class="d-flex flex-lg-column ga-6 border-b-thin">
|
||||
<p>
|
||||
{{ data?.description }}
|
||||
</p>
|
||||
<p>
|
||||
<strong>Время на прохождение — {{ data?.time }} минут</strong>
|
||||
</p>
|
||||
<p>
|
||||
<strong>Срок окончания — {{ new Date(data?.dateend).toLocaleDateString() }}</strong>
|
||||
</p>
|
||||
</v-card-text>
|
||||
<v-card-actions class="mx-2 my-4">
|
||||
<p>Попытка 1 из {{ data?.attemps_number }}</p>
|
||||
<v-btn color="white" class="ml-auto bg-teal-darken-1 px-9" @click="startTest">
|
||||
Начать
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-container>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
startTest: Function,
|
||||
data: Object,
|
||||
},
|
||||
};
|
||||
</script>
|
||||
@@ -1,156 +1,150 @@
|
||||
<!-- Раздел с назначенным тестированием -->
|
||||
<template>
|
||||
<div class="my-4 text-h5"> {{ title }} </div>
|
||||
<v-container :fluid="true">
|
||||
<v-row>
|
||||
<v-text-field
|
||||
v-model="search"
|
||||
append-inner-icon="mdi-magnify"
|
||||
label="Найти тестирование по названию"
|
||||
variant="solo"
|
||||
|
||||
@click:append-inner="searchTest"
|
||||
clearable/>
|
||||
</v-row>
|
||||
|
||||
</v-container>
|
||||
|
||||
|
||||
<!-- Карточка где буду отрисовываться тесты в цикле -->
|
||||
<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-col>
|
||||
<v-col cols="auto" class="d-flex flex-grow-1">
|
||||
<div class="d-flex flex-column justify-center flex-grow-1">
|
||||
<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">
|
||||
|
||||
<slot name="results"></slot>
|
||||
|
||||
<div v-for="icon in activeTabIcon">
|
||||
<v-icon :color="icon.color" :icon="icon.icon" size="large" />
|
||||
<span class="ml-1">{{ momenter(cardValue[icon.field], icon.field) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</v-col>
|
||||
<v-col cols="auto" class="align-self-center">
|
||||
<slot name="buttons"></slot>
|
||||
</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" />
|
||||
<v-card-title class="text-h4 text-grey-lighten-1">Данные не найдены</v-card-title>
|
||||
</v-row>
|
||||
</v-container>
|
||||
<div class="my-4 text-h5">{{ title }}</div>
|
||||
<v-container :fluid="true">
|
||||
<v-row>
|
||||
<v-text-field
|
||||
v-model="search"
|
||||
append-inner-icon="mdi-magnify"
|
||||
label="Найти тестирование по названию"
|
||||
variant="solo"
|
||||
@click:append-inner="searchTest"
|
||||
clearable
|
||||
/>
|
||||
</v-row>
|
||||
</v-container>
|
||||
<!-- Карточка где буду отрисовываться тесты в цикле -->
|
||||
<v-card v-for="cardValue in searchTest" :key="cardValue.id" class="my-2 border-sm">
|
||||
<v-row class="pa-2">
|
||||
<v-col cols="2" class="justify-center my-auto">
|
||||
<v-img :src="cardValue.file" class="mx-auto" />
|
||||
</v-col>
|
||||
<v-col cols="auto" class="d-flex flex-grow-1">
|
||||
<div class="d-flex flex-column justify-center flex-grow-1">
|
||||
<div class="text-body-1 font-weight-medium mb-2">{{ cardValue.name }}</div>
|
||||
<div class="text-body-1 text-disabled mb-2" style="max-width: 600px">
|
||||
{{ cardValue.description }}
|
||||
</div>
|
||||
<div class="d-flex ga-4">
|
||||
<slot name="results"></slot>
|
||||
<div v-for="icon in activeTabIcon">
|
||||
<v-icon :color="icon.color" :icon="icon.icon" size="large" />
|
||||
<span class="ml-1">{{ momenter(cardValue[icon.field], icon.field) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</v-col>
|
||||
<v-col cols="auto" class="align-self-center">
|
||||
<slot name="buttons" :cardValue="cardValue"></slot>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-card>
|
||||
<!-- Если данные отсутствуют, выводим сообщение об этом -->
|
||||
<v-container v-if="!searchTest.length" :fluid="true" class="h-100">
|
||||
<v-row class="align-center flex-column">
|
||||
<v-icon icon="mdi-note-off-outline" color="grey-lighten-1" size="x-large" />
|
||||
<v-card-title class="text-h4 text-grey-lighten-1">Данные не найдены</v-card-title>
|
||||
</v-row>
|
||||
</v-container>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import moment from 'moment';
|
||||
import { declOfNum } from '@/utils/universal_functions'
|
||||
import { baseURL } from "@/utils/axios-api";
|
||||
import { declOfNum } from '@/utils/universal_functions';
|
||||
import { baseURL } from '@/utils/axios-api';
|
||||
import { ref, computed } from 'vue';
|
||||
|
||||
export default {
|
||||
props: {
|
||||
title: {
|
||||
type: String,
|
||||
default: 'Не забыть передать тайтл сюда!',
|
||||
},
|
||||
activeTab: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
testingCard: {
|
||||
type: Array,
|
||||
default: () => [
|
||||
{
|
||||
id: 1,
|
||||
name: 'Комплекс тестовых вопросов на знание в области информационно-коммуникационных технологий',
|
||||
type: 'test',
|
||||
description: 'Краткое описание тестирования',
|
||||
file: 'https://icdn.lenta.ru/images/2024/03/27/12/20240327123127525/square_1280_63e6b3d7acbfce65d885ae4cf216dfe2.jpg',
|
||||
dateend: new Date(),
|
||||
question_count: 20,
|
||||
time: 20,
|
||||
attemps_number: 3,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: 'Удобство раздела тестирования',
|
||||
type: 'test',
|
||||
description: 'Опрос среди сотрудников ЦОД МФ',
|
||||
file: 'https://icdn.lenta.ru/images/2024/03/27/12/20240327123127525/square_1280_63e6b3d7acbfce65d885ae4cf216dfe2.jpg',
|
||||
dateend: new Date(),
|
||||
question_count: 28,
|
||||
time: 15,
|
||||
attemps_number: 1,
|
||||
},
|
||||
]
|
||||
}
|
||||
props: {
|
||||
title: {
|
||||
type: String,
|
||||
default: 'Не забыть передать тайтл сюда!',
|
||||
},
|
||||
setup(props) {
|
||||
const search = ref('');
|
||||
|
||||
const searchTest = computed(() => {
|
||||
if (!search.value) return props.testingCard
|
||||
return props.testingCard.filter(item => item.name.toLowerCase().includes(search.value.toLowerCase()))
|
||||
})
|
||||
activeTab: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
testingCard: {
|
||||
type: Array,
|
||||
default: () => [
|
||||
{
|
||||
id: 1,
|
||||
name: 'Комплекс тестовых вопросов на знание в области информационно-коммуникационных технологий',
|
||||
type: 'test',
|
||||
description: 'Краткое описание тестирования',
|
||||
file: 'https://icdn.lenta.ru/images/2024/03/27/12/20240327123127525/square_1280_63e6b3d7acbfce65d885ae4cf216dfe2.jpg',
|
||||
dateend: new Date(),
|
||||
question_count: 20,
|
||||
time: 20,
|
||||
attemps_number: 3,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: 'Удобство раздела тестирования',
|
||||
type: 'test',
|
||||
description: 'Опрос среди сотрудников ЦОД МФ',
|
||||
file: 'https://icdn.lenta.ru/images/2024/03/27/12/20240327123127525/square_1280_63e6b3d7acbfce65d885ae4cf216dfe2.jpg',
|
||||
dateend: new Date(),
|
||||
question_count: 28,
|
||||
time: 15,
|
||||
attemps_number: 1,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
setup(props) {
|
||||
const search = ref('');
|
||||
|
||||
const activeTabIcon = computed(() => {
|
||||
let icons = [
|
||||
// иконки для использования в карточках
|
||||
{
|
||||
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: 'attemps_number',
|
||||
color: '#FF9800'
|
||||
},
|
||||
]
|
||||
if (props.activeTab == 0) {
|
||||
return icons
|
||||
} else {
|
||||
return icons.splice(1,2)
|
||||
}
|
||||
})
|
||||
const searchTest = computed(() => {
|
||||
if (!search.value) return props.testingCard;
|
||||
return props.testingCard.filter((item) =>
|
||||
item.name.toLowerCase().includes(search.value.toLowerCase()),
|
||||
);
|
||||
});
|
||||
|
||||
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
|
||||
}
|
||||
const activeTabIcon = computed(() => {
|
||||
let icons = [
|
||||
// иконки для использования в карточках
|
||||
{
|
||||
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: 'attemps_number',
|
||||
color: '#FF9800',
|
||||
},
|
||||
];
|
||||
if (props.activeTab === 0) {
|
||||
return icons;
|
||||
} else {
|
||||
return icons.splice(1, 2);
|
||||
}
|
||||
});
|
||||
|
||||
return { search, searchTest, momenter, activeTabIcon, baseURL }
|
||||
}
|
||||
}
|
||||
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;
|
||||
};
|
||||
|
||||
</script>
|
||||
return { search, searchTest, momenter, activeTabIcon, baseURL };
|
||||
},
|
||||
};
|
||||
</script>
|
||||
@@ -1,18 +1,191 @@
|
||||
<template>
|
||||
<v-container>
|
||||
<HeaderDetailTesting />
|
||||
<v-container class="pa-4">
|
||||
<!-- Верхняя панель -->
|
||||
<HeaderDetailTesting
|
||||
:testStarted="testStarted"
|
||||
:formattedTime="formattedTime"
|
||||
:finishTest="openFinishDialog"
|
||||
:currentQuestion="currentQuestion"
|
||||
:totalQuestions="data?.question_count"
|
||||
@change-question="changeQuestion"
|
||||
:data="data"
|
||||
/>
|
||||
|
||||
</v-container>
|
||||
<!-- Блок информации о тесте -->
|
||||
<BodyDetailTesting v-if="!testStarted && !testFinished" :data="data" :startTest="startTest" />
|
||||
|
||||
<!-- Вопросы теста -->
|
||||
<QuestionBlock
|
||||
v-if="testStarted"
|
||||
:question="data.questions[currentQuestion]"
|
||||
:currentQuestion="currentQuestion"
|
||||
:totalQuestions="data.question_count"
|
||||
:answers="answers"
|
||||
:finishTest="openFinishDialog"
|
||||
@change-question="changeQuestion"
|
||||
/>
|
||||
|
||||
<!-- Результаты теста -->
|
||||
<TestResults
|
||||
v-if="testFinished"
|
||||
:testFinished="testFinished"
|
||||
:testPassed="testPassed"
|
||||
:correctAnswers="correctAnswers"
|
||||
:answeredQuestions="answeredQuestions"
|
||||
:totalQuestions="data.question_count"
|
||||
:formattedTime="formattedTime"
|
||||
/>
|
||||
|
||||
<!-- Диалог подтверждения завершения теста -->
|
||||
<v-dialog v-model="showFinishDialog" persistent max-width="400px">
|
||||
<v-card>
|
||||
<v-card-title class="text-h6">Завершить тест?</v-card-title>
|
||||
<v-card-text>Вы уверены, что хотите завершить тестирование?</v-card-text>
|
||||
<v-card-actions class="d-flex justify-end">
|
||||
<v-btn color="teal-darken-4" @click="finishTest">Да, завершить</v-btn>
|
||||
<v-btn color="grey" @click="showFinishDialog = false">Отмена</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</v-container>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import HeaderDetailTesting from './HeaderDetailTesting.vue';
|
||||
|
||||
import { computed, ref, onUnmounted, onMounted, watch } from 'vue';
|
||||
import HeaderDetailTesting from '@/components/testing/HeaderDetailTesting.vue';
|
||||
import BodyDetailTesting from '@/components/testing/BodyDetailTesting.vue';
|
||||
import QuestionBlock from '@/components/testing/QuestionBlock.vue';
|
||||
import TestResults from '@/components/testing/TestResults.vue';
|
||||
import { axiosApiInstance } from '@/utils/axios-api';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
HeaderDetailTesting,
|
||||
}
|
||||
}
|
||||
components: { BodyDetailTesting, HeaderDetailTesting, QuestionBlock, TestResults },
|
||||
setup() {
|
||||
const route = useRoute();
|
||||
const testId = route.params.id;
|
||||
const testStarted = ref(false);
|
||||
const testFinished = ref(false);
|
||||
const showFinishDialog = ref(false);
|
||||
const currentQuestion = ref(0);
|
||||
let timer = null;
|
||||
const data = ref(null);
|
||||
|
||||
</script>
|
||||
const getTestById = async (id) => {
|
||||
const resp = await axiosApiInstance.get(`/api/tests/testdetail/${id}`);
|
||||
data.value = resp.data;
|
||||
// console.log(data.value);
|
||||
};
|
||||
|
||||
const formattedTime = computed(() => {
|
||||
if (!data.value?.time) return '00:00';
|
||||
|
||||
// Если тест не запущен и не завершён — считаем, что время в data.value.time в минутах
|
||||
if (!testStarted.value && !testFinished.value) {
|
||||
return `${String(data.value.time).padStart(2, '0')}:00`;
|
||||
}
|
||||
|
||||
// Если тест запущен или завершён — data.value.time уже в секундах
|
||||
const minutes = Math.floor(data.value.time / 60);
|
||||
const seconds = data.value.time % 60;
|
||||
return `${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}`;
|
||||
});
|
||||
|
||||
const startTest = () => {
|
||||
testStarted.value = true;
|
||||
testFinished.value = false;
|
||||
|
||||
// Переводим минуты в секунды перед запуском таймера
|
||||
data.value = { ...data.value, time: data.value.time * 60 };
|
||||
|
||||
timer = setInterval(() => {
|
||||
if (data.value?.time > 0) {
|
||||
data.value = { ...data.value, time: data.value.time - 1 };
|
||||
} else {
|
||||
finishTest(); // Завершаем тест, если время закончилось
|
||||
}
|
||||
}, 1000);
|
||||
};
|
||||
|
||||
const finishTest = () => {
|
||||
clearInterval(timer);
|
||||
testStarted.value = false;
|
||||
testFinished.value = true;
|
||||
showFinishDialog.value = false;
|
||||
};
|
||||
|
||||
const answers = ref([]);
|
||||
|
||||
watch(data.value?.questions, (newData) => {
|
||||
if (newData && Array.isArray(newData.questions)) {
|
||||
answers.value = newData.questions.map(() => null);
|
||||
}
|
||||
});
|
||||
|
||||
const correctAnswers = computed(
|
||||
() =>
|
||||
answers.value.filter((answer, index) => {
|
||||
const correctAnswerObjs = data?.value.questions[index].answers.filter(
|
||||
(a) => a.right_wrong,
|
||||
);
|
||||
|
||||
if (!correctAnswerObjs.length) return false; // Если нет правильных ответов, пропускаем
|
||||
|
||||
const correctNames = correctAnswerObjs.map((a) => a.name); // Все правильные варианты
|
||||
|
||||
// Если пользователь выбрал несколько вариантов, сравниваем как массивы
|
||||
if (Array.isArray(answer)) {
|
||||
return (
|
||||
answer.length === correctNames.length && // Должно совпадать количество
|
||||
answer.every((ans) => correctNames.includes(ans)) // Все варианты должны быть правильными
|
||||
);
|
||||
}
|
||||
|
||||
// Если один вариант ответа — сравниваем просто строку
|
||||
return correctNames.includes(answer);
|
||||
}).length,
|
||||
);
|
||||
|
||||
const answeredQuestions = computed(
|
||||
() => answers.value.filter((answer) => answer !== null).length,
|
||||
);
|
||||
|
||||
const testPassed = computed(() => correctAnswers.value >= data?.value.questions.length / 2);
|
||||
|
||||
const changeQuestion = (newIndex) => {
|
||||
if (newIndex >= 0 && newIndex < data?.value.questions.length) {
|
||||
currentQuestion.value = newIndex;
|
||||
}
|
||||
};
|
||||
|
||||
const openFinishDialog = () => {
|
||||
showFinishDialog.value = true;
|
||||
};
|
||||
|
||||
onUnmounted(() => {
|
||||
if (timer) clearInterval(timer);
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
getTestById(testId);
|
||||
});
|
||||
|
||||
return {
|
||||
testStarted,
|
||||
testFinished,
|
||||
formattedTime,
|
||||
startTest,
|
||||
finishTest,
|
||||
answers,
|
||||
currentQuestion,
|
||||
changeQuestion,
|
||||
showFinishDialog,
|
||||
openFinishDialog,
|
||||
correctAnswers,
|
||||
answeredQuestions,
|
||||
testPassed,
|
||||
data,
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
@@ -1,43 +1,97 @@
|
||||
<template>
|
||||
<v-row class="ma-0 border-b-thin">
|
||||
<v-col cols="auto" class="flex-grow-1">
|
||||
<div class="text-subtitle-1 text-grey-lighten-1">Тест</div>
|
||||
<div class="text-h5">{{ title }}</div>
|
||||
</v-col>
|
||||
<v-col cols="auto" class="d-flex flex-column">
|
||||
<div class="align-self-end text-grey-lighten-1">!!!</div>
|
||||
<div class="text-h4 text-grey-lighten-1">{{ time }}Таймер сюдаааа!!!</div>
|
||||
</v-col>
|
||||
<v-container class="pa-4">
|
||||
<v-row align="center" class="border-b-thin">
|
||||
<v-col class="text-h6 font-weight-regular">
|
||||
{{ data?.name }}
|
||||
</v-col>
|
||||
<span class="text-h6 text-grey-darken-1 font-weight-bold mr-4">{{ formattedTime }}</span>
|
||||
</v-row>
|
||||
<v-row class="ma-0 border-b-thin">
|
||||
<v-col cols="auto" class="flex-grow-1">
|
||||
<v-container class="d-flex align-center max-width">
|
||||
<v-btn elevation="1" color="teal-darken-1" size="x-small" rounded icon="mdi-information-outline" />
|
||||
<v-pagination :length="25" :total-visible="20" next-icon="mdi-menu-right" prev-icon="mdi-menu-left">
|
||||
<template #item="item">
|
||||
{{ item }}
|
||||
</template>
|
||||
</v-pagination>
|
||||
</v-container>
|
||||
</v-col>
|
||||
<v-col cols="auto" class="align-self-center">
|
||||
<v-btn elevation="0" color="#0000001F" rounded="1">Выйти</v-btn>
|
||||
</v-col>
|
||||
|
||||
<v-row align="center" class="border-b-thin pa-2">
|
||||
<v-btn
|
||||
elevation="1"
|
||||
color="teal-darken-1"
|
||||
size="x-small"
|
||||
rounded
|
||||
icon="mdi-information-outline"
|
||||
/>
|
||||
|
||||
<!-- Пагинация только при запущенном тесте -->
|
||||
<v-pagination
|
||||
v-if="testStarted"
|
||||
:length="totalQuestions"
|
||||
:total-visible="5"
|
||||
active-color="teal-darken-4"
|
||||
:model-value="currentQuestion + 1"
|
||||
@update:model-value="changePage"
|
||||
></v-pagination>
|
||||
|
||||
<v-btn
|
||||
v-if="testStarted"
|
||||
elevation="0"
|
||||
color="red-darken-1"
|
||||
rounded="lg"
|
||||
class="ml-auto"
|
||||
@click="finishTest"
|
||||
>
|
||||
Завершить
|
||||
</v-btn>
|
||||
<v-btn
|
||||
v-else
|
||||
elevation="0"
|
||||
color="grey-lighten-3"
|
||||
rounded="lg"
|
||||
class="ml-auto"
|
||||
@click="showExitDialog = true"
|
||||
>
|
||||
Выйти
|
||||
</v-btn>
|
||||
</v-row>
|
||||
|
||||
<!-- Диалоговое окно выхода -->
|
||||
<v-dialog v-model="showExitDialog" width="400">
|
||||
<v-card>
|
||||
<v-card-title class="text-h6">Вы действительно хотите выйти?</v-card-title>
|
||||
<v-card-actions>
|
||||
<v-btn color="red" @click="exitTest">Да</v-btn>
|
||||
<v-btn color="grey" @click="showExitDialog = false">Отмена</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</v-container>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ref } from 'vue';
|
||||
|
||||
export default {
|
||||
props: {
|
||||
title: {
|
||||
type: String,
|
||||
default: 'Название теста здесь',
|
||||
},
|
||||
time: {
|
||||
props: {
|
||||
testStarted: Boolean,
|
||||
formattedTime: String,
|
||||
finishTest: Function,
|
||||
currentQuestion: Number,
|
||||
totalQuestions: Number,
|
||||
data: {
|
||||
name: {
|
||||
type: String,
|
||||
default: 'Тест',
|
||||
},
|
||||
},
|
||||
},
|
||||
emits: ['change-question'],
|
||||
setup(props, { emit }) {
|
||||
const showExitDialog = ref(false);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
const exitTest = () => {
|
||||
showExitDialog.value = false;
|
||||
window.history.back();
|
||||
};
|
||||
|
||||
</script>
|
||||
const changePage = (newPage) => {
|
||||
emit('change-question', newPage - 1);
|
||||
};
|
||||
|
||||
return { showExitDialog, exitTest, changePage };
|
||||
},
|
||||
};
|
||||
</script>
|
||||
@@ -0,0 +1,119 @@
|
||||
<template>
|
||||
<v-card
|
||||
class="mt-4 w-75 mx-auto d-flex flex-lg-column"
|
||||
style="min-height: 450px; max-height: 700px"
|
||||
>
|
||||
<v-card-title class="text-h6 font-weight-bold">
|
||||
Вопрос {{ currentQuestion + 1 }} из {{ totalQuestions }}
|
||||
</v-card-title>
|
||||
<h3 class="mb-2 px-4">{{ question.name }}</h3>
|
||||
<v-card-text style="overflow-y: scroll">
|
||||
<v-img
|
||||
v-if="question.file"
|
||||
:src="`http://127.0.0.1:8000${question.file}`"
|
||||
class="w-50 mx-auto"
|
||||
/>
|
||||
|
||||
<!-- Одиночный выбор -->
|
||||
<v-radio-group v-if="!isMultipleChoice" v-model="answers[currentQuestion]">
|
||||
<v-radio v-for="(option, index) in question.answers" :key="index" :value="option.name">
|
||||
<template v-slot:label>
|
||||
<div class="text-center">
|
||||
<v-img
|
||||
v-if="option.file"
|
||||
:src="`http://127.0.0.1:8000${option.file}`"
|
||||
class="mb-4"
|
||||
max-height="140"
|
||||
contain
|
||||
/>
|
||||
<span>{{ option.name }}</span>
|
||||
</div>
|
||||
</template>
|
||||
</v-radio>
|
||||
</v-radio-group>
|
||||
|
||||
<!-- Множественный выбор -->
|
||||
<div v-else>
|
||||
<v-checkbox
|
||||
v-for="(option, index) in question.answers"
|
||||
:key="index"
|
||||
v-model="answers[currentQuestion]"
|
||||
:value="option.name"
|
||||
style="margin-bottom: -25px"
|
||||
>
|
||||
<template v-slot:label>
|
||||
<div class="text-center">
|
||||
<v-img
|
||||
v-if="option.file"
|
||||
:src="`http://127.0.0.1:8000${option.file}`"
|
||||
class="mb-4"
|
||||
max-height="140"
|
||||
contain
|
||||
/>
|
||||
<span>{{ option.name }}</span>
|
||||
</div>
|
||||
</template>
|
||||
</v-checkbox>
|
||||
</div>
|
||||
</v-card-text>
|
||||
<v-card-actions class="d-flex">
|
||||
<v-btn
|
||||
:disabled="currentQuestion === 0"
|
||||
@click="$emit('change-question', currentQuestion - 1)"
|
||||
>
|
||||
Назад
|
||||
</v-btn>
|
||||
<v-btn
|
||||
v-if="currentQuestion !== totalQuestions - 1"
|
||||
color="teal-darken-1"
|
||||
@click="$emit('change-question', currentQuestion + 1)"
|
||||
>
|
||||
Далее
|
||||
</v-btn>
|
||||
<v-btn
|
||||
v-if="currentQuestion === totalQuestions - 1"
|
||||
elevation="0"
|
||||
color="white"
|
||||
rounded="lg"
|
||||
class="bg-teal-darken-4"
|
||||
@click="finishTest"
|
||||
>
|
||||
Завершить
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { computed, watch } from 'vue';
|
||||
|
||||
export default {
|
||||
props: {
|
||||
question: Object,
|
||||
currentQuestion: Number,
|
||||
totalQuestions: Number,
|
||||
finishTest: Function,
|
||||
answers: Array,
|
||||
},
|
||||
setup(props) {
|
||||
// Определяем, является ли вопрос с множественным выбором
|
||||
const isMultipleChoice = computed(() => props.question.settings?.multiply === 'true');
|
||||
|
||||
// Следим за изменением текущего вопроса и создаем пустой массив, если множественный выбор
|
||||
watch(
|
||||
() => props.currentQuestion,
|
||||
(newVal) => {
|
||||
if (isMultipleChoice.value && !Array.isArray(props.answers[newVal])) {
|
||||
props.answers[newVal] = [];
|
||||
}
|
||||
},
|
||||
{ immediate: true }, // Устанавливаем сразу при инициализации
|
||||
);
|
||||
|
||||
return {
|
||||
isMultipleChoice,
|
||||
};
|
||||
},
|
||||
emits: ['change-question'],
|
||||
};
|
||||
</script>
|
||||
@@ -0,0 +1,45 @@
|
||||
<template>
|
||||
<v-card v-if="testFinished" class="mt-4 pa-4" flat>
|
||||
<v-card-title class="text-h6 font-weight-bold">Результаты тестирования</v-card-title>
|
||||
<v-card-text>
|
||||
<v-alert v-if="testPassed" type="success"> Тест успешно пройден </v-alert>
|
||||
<v-alert v-if="!testPassed" type="error"> Тест не пройден </v-alert>
|
||||
</v-card-text>
|
||||
|
||||
<v-row class="mt-2">
|
||||
<v-col cols="4">
|
||||
<v-card class="pa-2 text-center">
|
||||
<p class="text-h6">{{ correctAnswers }}/{{ totalQuestions }}</p>
|
||||
<small>Правильных ответов</small>
|
||||
</v-card>
|
||||
</v-col>
|
||||
|
||||
<v-col cols="4">
|
||||
<v-card class="pa-2 text-center">
|
||||
<p class="text-h6">{{ answeredQuestions }}/{{ totalQuestions }}</p>
|
||||
<small>Ответов дано</small>
|
||||
</v-card>
|
||||
</v-col>
|
||||
|
||||
<v-col cols="4">
|
||||
<v-card class="pa-2 text-center">
|
||||
<p class="text-h6">{{ formattedTime }}</p>
|
||||
<small>Оставшееся время</small>
|
||||
</v-card>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
testFinished: Boolean,
|
||||
testPassed: Boolean,
|
||||
correctAnswers: Number,
|
||||
answeredQuestions: Number,
|
||||
totalQuestions: Number,
|
||||
formattedTime: String,
|
||||
},
|
||||
};
|
||||
</script>
|
||||
@@ -1,35 +0,0 @@
|
||||
<template>
|
||||
<v-card-title>{{ item.title }}</v-card-title>
|
||||
<v-card-subtitle>
|
||||
<div>{{ item.description }}</div>
|
||||
</v-card-subtitle>
|
||||
<v-card-actions class="ga-4">
|
||||
<div>
|
||||
<v-icon color="teal-darken-4">mdi-calendar</v-icon>
|
||||
<strong> До:</strong> {{ new Date(item.date).toLocaleDateString() }}
|
||||
</div>
|
||||
<div>
|
||||
<v-icon color="teal-darken-4">mdi-calendar-text</v-icon>
|
||||
<strong> Вопросов:</strong> {{ item.questions }}
|
||||
</div>
|
||||
<div v-if="item.time">
|
||||
<v-icon color="teal-darken-4">mdi-clock</v-icon>
|
||||
<strong> Время:</strong> {{ item.time }}
|
||||
</div>
|
||||
<div v-if="item.attempts">
|
||||
<v-icon color="deep-orange-accent-4">mdi-alert-outline</v-icon>
|
||||
<strong> Попытки:</strong> {{ item.attempts }}
|
||||
</div>
|
||||
</v-card-actions>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
item: {
|
||||
type: Object,
|
||||
required: true
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
@@ -1,6 +1,5 @@
|
||||
<template>
|
||||
|
||||
<v-row class="pt-2 mx-1 flex-column fill-height flex-grow-0 ">
|
||||
<v-row class="pt-2 mx-1 flex-column fill-height flex-grow-0">
|
||||
<template v-if="isVoteCreated">
|
||||
<v-card class="d-flex flex-column flex-grow-1 flex-shrink-0 text-center pa-8" flat>
|
||||
<v-spacer></v-spacer>
|
||||
@@ -8,18 +7,15 @@
|
||||
<v-icon color="success" size="48">mdi-check-circle</v-icon>
|
||||
<h2 class="mt-4">Голосование создано!</h2>
|
||||
<v-btn class="mt-4" color="teal-darken-4" @click="resetForm">Создать ещё</v-btn>
|
||||
|
||||
</div>
|
||||
<v-spacer></v-spacer>
|
||||
</v-card>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="v-col flex-grow-1 flex-shrink-0 ">
|
||||
<div class="v-col flex-grow-1 flex-shrink-0">
|
||||
<v-stepper v-model="step" class="d-flex flex-column fill-height" editable>
|
||||
<v-stepper-header class="flex-grow-0 flex-shrink-1">
|
||||
<v-stepper-item :complete="step > 0" step="1">Основная информация
|
||||
|
||||
</v-stepper-item>
|
||||
<v-stepper-item :complete="step > 0" step="1">Основная информация </v-stepper-item>
|
||||
<v-divider></v-divider>
|
||||
<v-stepper-item :complete="step > 1" step="2">Создание опроса</v-stepper-item>
|
||||
<v-divider></v-divider>
|
||||
@@ -29,35 +25,49 @@
|
||||
<v-stepper-window class="fill-height">
|
||||
<!-- Основная информация -->
|
||||
<v-stepper-window-item class="fill-height" step="1">
|
||||
<v-card class="fill-height d-flex flex-column " flat>
|
||||
<v-card class="fill-height d-flex flex-column" flat>
|
||||
<v-card-title>Основная информация</v-card-title>
|
||||
<v-card-text class="d-flex flex-column overflow-auto">
|
||||
<v-text-field v-model="form.title" :rules="[rules.required]" class="flex-grow-0 flex-shrink-1"
|
||||
label="Название голосования"
|
||||
variant="underlined"></v-text-field>
|
||||
<v-text-field
|
||||
v-model="form.title"
|
||||
:rules="[rules.required]"
|
||||
class="flex-grow-0 flex-shrink-1"
|
||||
label="Название голосования"
|
||||
variant="underlined"
|
||||
></v-text-field>
|
||||
<div class="flex-grow-1 flex-shrink-0">
|
||||
|
||||
<v-textarea v-model="form.description" :rules="[rules.required]" label="Описание"
|
||||
|
||||
variant="outlined"></v-textarea>
|
||||
<v-textarea
|
||||
v-model="form.description"
|
||||
:rules="[rules.required]"
|
||||
label="Описание"
|
||||
variant="outlined"
|
||||
></v-textarea>
|
||||
</div>
|
||||
<v-divider></v-divider>
|
||||
<div class="flex-grow-0 flex-shrink-1">
|
||||
<div class="pt-2 d-flex align-center"><span class="text-overline text-grey text-center">Публикация новости: </span>
|
||||
<v-switch v-model="form.createnews"
|
||||
class="px-2"
|
||||
density="comfortable"
|
||||
hide-details
|
||||
color="primary"
|
||||
:label="form.createnews?'да':'нет'"
|
||||
></v-switch></div>
|
||||
<div class="pt-2 d-flex align-center">
|
||||
<span class="text-overline text-grey text-center">Публикация новости: </span>
|
||||
<v-switch
|
||||
v-model="form.createnews"
|
||||
class="px-2"
|
||||
density="comfortable"
|
||||
hide-details
|
||||
color="primary"
|
||||
:label="form.createnews ? 'да' : 'нет'"
|
||||
></v-switch>
|
||||
</div>
|
||||
<div class="pt-2 text-overline text-grey">Дата и время:</div>
|
||||
<div class="d-flex justify-space-around">
|
||||
<div class="d-flex ga-3 align-center">
|
||||
<h6 class="text-subtitle-1 pt-2">начало:</h6>
|
||||
<date-select :datedefault="form.startDate" @returndate="returnstart"/>
|
||||
<v-select v-model="selectedTimeStart" :items="timeOptions" density="compact" hide-details
|
||||
variant="plain">
|
||||
<date-select :datedefault="form.startDate" @returndate="returnstart" />
|
||||
<v-select
|
||||
v-model="selectedTimeStart"
|
||||
:items="timeOptions"
|
||||
density="compact"
|
||||
hide-details
|
||||
variant="plain"
|
||||
>
|
||||
<template v-slot:prepend-inner>
|
||||
<v-icon color="red" icon="mdi-timer" size="xsmall"></v-icon>
|
||||
</template>
|
||||
@@ -65,10 +75,15 @@
|
||||
</div>
|
||||
<div class="d-flex ga-3 align-center">
|
||||
<h6 class="text-subtitle-1 pt-2">окончание:</h6>
|
||||
<date-select :datedefault="form.endDate" @returndate="returnend"/>
|
||||
<v-select v-model="selectedTimeEnd" :items="timeOptions" density="compact" hide-details
|
||||
outlined
|
||||
variant="plain">
|
||||
<date-select :datedefault="form.endDate" @returndate="returnend" />
|
||||
<v-select
|
||||
v-model="selectedTimeEnd"
|
||||
:items="timeOptions"
|
||||
density="compact"
|
||||
hide-details
|
||||
outlined
|
||||
variant="plain"
|
||||
>
|
||||
<template v-slot:prepend-inner>
|
||||
<v-icon color="red" icon="mdi-timer" size="xsmall"></v-icon>
|
||||
</template>
|
||||
@@ -86,15 +101,14 @@
|
||||
|
||||
<!-- Создание опроса -->
|
||||
<v-stepper-window-item class="fill-height" step="2">
|
||||
|
||||
<v-card class="fill-height d-flex flex-column" flat>
|
||||
<v-card-title>Создание опроса:</v-card-title>
|
||||
<v-card-text style="max-height: 62vh; overflow-y: auto;">
|
||||
<v-card-text style="max-height: 62vh; overflow-y: auto">
|
||||
<transition-group name="list" tag="div">
|
||||
<div v-for="(question, index) in form.questions" :key="index" class="mb-4">
|
||||
<div class="d-flex">
|
||||
<!-- <v-text-field v-model="question.text" :label="'Вопрос ' + (index + 1)" :rules="[rules.required]"-->
|
||||
<!-- density="comfortable" variant="underlined">-->
|
||||
<!-- <v-text-field v-model="question.text" :label="'Вопрос ' + (index + 1)" :rules="[rules.required]"-->
|
||||
<!-- density="comfortable" variant="underlined">-->
|
||||
<v-text-field
|
||||
v-model="question.text"
|
||||
:label="'Вопрос ' + (index + 1)"
|
||||
@@ -104,59 +118,79 @@
|
||||
@input="updateQuest(index)"
|
||||
>
|
||||
<template v-slot:append>
|
||||
<v-btn color="error" icon="mdi-delete" size="small" @click="removeQuestion(index)"/>
|
||||
<v-btn
|
||||
color="error"
|
||||
icon="mdi-delete"
|
||||
size="small"
|
||||
@click="removeQuestion(index)"
|
||||
/>
|
||||
</template>
|
||||
|
||||
</v-text-field>
|
||||
</div>
|
||||
<v-file-input v-model="question.image" accept="image/*" density="comfortable"
|
||||
label="Картинка для вопроса" variant="outlined"></v-file-input>
|
||||
<v-file-input
|
||||
v-model="question.image"
|
||||
accept="image/*"
|
||||
density="comfortable"
|
||||
label="Картинка для вопроса"
|
||||
variant="outlined"
|
||||
></v-file-input>
|
||||
<v-divider></v-divider>
|
||||
<div class="py-2 text-overline text-grey">Настройки вопроса</div>
|
||||
<div class="v-row ">
|
||||
|
||||
<div class="v-row">
|
||||
<v-col class="align-self-center font-weight-bold py-0" cols="auto">
|
||||
Тип ответа
|
||||
</v-col>
|
||||
<v-col class="py-0 align-self-center " cols="3">
|
||||
|
||||
<v-select v-model="question.settings.choice" :items="questionTypes" :list-props="{density:'compact'}"
|
||||
density="compact"
|
||||
hide-details
|
||||
item-title="name" item-value="choice" label="" variant="outlined"
|
||||
@update:model-value="question.answers=[]"></v-select>
|
||||
<v-col class="py-0 align-self-center" cols="3">
|
||||
<v-select
|
||||
v-model="question.settings.choice"
|
||||
:items="questionTypes"
|
||||
:list-props="{ density: 'compact' }"
|
||||
density="compact"
|
||||
hide-details
|
||||
item-title="name"
|
||||
item-value="choice"
|
||||
label=""
|
||||
variant="outlined"
|
||||
@update:model-value="question.answers = []"
|
||||
></v-select>
|
||||
<!-- choice -->
|
||||
|
||||
</v-col>
|
||||
<v-spacer/>
|
||||
<v-spacer />
|
||||
<v-col class="align-self-center font-weight-bold" cols="auto">
|
||||
Число возможных ответов
|
||||
</v-col>
|
||||
<v-col class="" cols="1">
|
||||
<v-text-field v-model="question.settings.multiChoice" :rules="[rules.required && question.settings.multiChoice > 0]"
|
||||
density="compact" hide-details
|
||||
min="1"
|
||||
type="number" variant="outlined">
|
||||
<template v-slot:prepend>
|
||||
|
||||
</template>
|
||||
<v-text-field
|
||||
v-model="question.settings.multiChoice"
|
||||
:rules="[rules.required && question.settings.multiChoice > 0]"
|
||||
density="compact"
|
||||
hide-details
|
||||
min="1"
|
||||
type="number"
|
||||
variant="outlined"
|
||||
>
|
||||
<template v-slot:prepend> </template>
|
||||
</v-text-field>
|
||||
</v-col>
|
||||
</div>
|
||||
<div class="v-row">
|
||||
</div>
|
||||
<div class="v-row"></div>
|
||||
|
||||
<v-card-text class="px-0">
|
||||
<div v-if="question.settings.choice === 'free'">
|
||||
<transition-group name="list" tag="div">
|
||||
<div v-for="(answer, ind) in question.answers" :key="ind" class="d-flex align-start mb-4">
|
||||
<div
|
||||
v-for="(answer, ind) in question.answers"
|
||||
:key="ind"
|
||||
class="d-flex align-start mb-4"
|
||||
>
|
||||
<v-text-field
|
||||
v-model="answer.text"
|
||||
:label="'Ответ ' + (ind + 1)"
|
||||
:rules="[rules.required]"
|
||||
class="mr-4"
|
||||
density="compact"
|
||||
variant="outlined">
|
||||
variant="outlined"
|
||||
>
|
||||
</v-text-field>
|
||||
<v-file-input
|
||||
v-model="answer.image"
|
||||
@@ -165,28 +199,38 @@
|
||||
density="compact"
|
||||
hide-details
|
||||
label="Картинка"
|
||||
variant="outlined">
|
||||
variant="outlined"
|
||||
>
|
||||
</v-file-input>
|
||||
<v-btn
|
||||
class="ms-1"
|
||||
color="error"
|
||||
icon="mdi-delete"
|
||||
size="small"
|
||||
@click="removeAnswer(index, ind)">
|
||||
@click="removeAnswer(index, ind)"
|
||||
>
|
||||
</v-btn>
|
||||
</div>
|
||||
</transition-group>
|
||||
<div class="d-flex justify-start">
|
||||
<v-btn color="teal-darken-4" size="small" @click="addAnswer(index)">Добавить ответ</v-btn>
|
||||
<v-btn color="teal-darken-4" size="small" @click="addAnswer(index)"
|
||||
>Добавить ответ</v-btn
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else>
|
||||
<div class="v-row">
|
||||
<v-radio-group v-model="question.settings.onlyDep" class="text-caption" inline>
|
||||
<v-radio-group
|
||||
v-model="question.settings.onlyDep"
|
||||
class="text-caption"
|
||||
inline
|
||||
>
|
||||
<template v-slot:label>
|
||||
<div class="text-body-2 font-weight-bold">Голосование по отделам:</div>
|
||||
<div class="text-body-2 font-weight-bold">
|
||||
Голосование по отделам:
|
||||
</div>
|
||||
</template>
|
||||
<v-radio v-for="x in onlyDepdict" :key="x.name" :value=x.value>
|
||||
<v-radio v-for="x in onlyDepdict" :key="x.name" :value="x.value">
|
||||
<template v-slot:label>
|
||||
<div class="text-caption">{{ x.name }}</div>
|
||||
</template>
|
||||
@@ -195,66 +239,114 @@
|
||||
</div>
|
||||
<v-autocomplete
|
||||
v-model="question.selectedEmployees"
|
||||
:items="allEmployeesgroupedbydep" class=" text-no-wrap"
|
||||
density="compact" item-title="fio" item-value="id" label="Выберите сотрудников" multiple
|
||||
:items="allEmployeesgroupedbydep"
|
||||
class="text-no-wrap"
|
||||
density="compact"
|
||||
item-title="fio"
|
||||
item-value="id"
|
||||
label="Выберите сотрудников"
|
||||
multiple
|
||||
variant="outlined"
|
||||
@update:model-value="(selected)=>question.answers=question.answers.filter(e=>selected.includes(e.text))"
|
||||
@update:model-value="
|
||||
(selected) =>
|
||||
(question.answers = question.answers.filter((e) =>
|
||||
selected.includes(e.text),
|
||||
))
|
||||
"
|
||||
>
|
||||
<template #prepend-item>
|
||||
<v-checkbox :model-value="question.selectedEmployees.length===allEmployees.length"
|
||||
class="pa-0"
|
||||
label="Все"
|
||||
@update:model-value="handleSelectAll(question.selectedEmployees.length===allEmployees.length, index)"></v-checkbox>
|
||||
<v-checkbox
|
||||
:model-value="
|
||||
question.selectedEmployees.length === allEmployees.length
|
||||
"
|
||||
class="pa-0"
|
||||
label="Все"
|
||||
@update:model-value="
|
||||
handleSelectAll(
|
||||
question.selectedEmployees.length === allEmployees.length,
|
||||
index,
|
||||
)
|
||||
"
|
||||
></v-checkbox>
|
||||
</template>
|
||||
<template #selection="{item}">
|
||||
<template #selection="{ item }">
|
||||
<v-chip
|
||||
:prepend-avatar="checkremote(`${spravURL}${item.raw.login}.jpg`)"
|
||||
>
|
||||
|
||||
{{ item.raw.familyname }}
|
||||
</v-chip>
|
||||
</template>
|
||||
<template #item="data">
|
||||
<template v-if="typeof data.item.raw !== 'object'">
|
||||
<v-divider/>
|
||||
<v-list-group class='pa-4 text-overline text-grey'
|
||||
v-text="data.item.raw"></v-list-group>
|
||||
<v-divider />
|
||||
<v-list-group
|
||||
class="pa-4 text-overline text-grey"
|
||||
v-text="data.item.raw"
|
||||
></v-list-group>
|
||||
</template>
|
||||
<template v-else>
|
||||
<v-list-item
|
||||
|
||||
:append-avatar="checkremote(`${spravURL}${data.item.raw.login}.jpg`)"
|
||||
:append-avatar="
|
||||
checkremote(`${spravURL}${data.item.raw.login}.jpg`)
|
||||
"
|
||||
density="compact"
|
||||
slim
|
||||
@click="onEmployeesChange(data.item.raw.id, index)"
|
||||
>
|
||||
<template #prepend>
|
||||
|
||||
<v-checkbox :model-value="question.selectedEmployees.includes(data.item.raw.id)"
|
||||
|
||||
density="compact"
|
||||
hide-details></v-checkbox>
|
||||
<v-checkbox
|
||||
:model-value="
|
||||
question.selectedEmployees.includes(data.item.raw.id)
|
||||
"
|
||||
density="compact"
|
||||
hide-details
|
||||
></v-checkbox>
|
||||
</template>
|
||||
<v-list-item-title class="text-third" v-text="data.item.raw.fio"></v-list-item-title>
|
||||
<v-list-item-title
|
||||
class="text-third"
|
||||
v-text="data.item.raw.fio"
|
||||
></v-list-item-title>
|
||||
</v-list-item>
|
||||
</template>
|
||||
</template>
|
||||
</v-autocomplete>
|
||||
<transition-group name="list" tag="div">
|
||||
<div v-for="(person, ind) in question.answers" :key="person"
|
||||
class="v-row align-center mb-4">
|
||||
<div
|
||||
v-for="(person, ind) in question.answers"
|
||||
:key="person"
|
||||
class="v-row align-center mb-4"
|
||||
>
|
||||
<v-col class="py-0" cols="7">
|
||||
<v-chip
|
||||
:prepend-avatar="checkremote(`${spravURL}${findEmployeeById(person.text)?.login}.jpg`)"
|
||||
:text="findEmployeeById(person.text)?.fio ">
|
||||
:prepend-avatar="
|
||||
checkremote(
|
||||
`${spravURL}${findEmployeeById(person.text)?.login}.jpg`,
|
||||
)
|
||||
"
|
||||
:text="findEmployeeById(person.text)?.fio"
|
||||
>
|
||||
</v-chip>
|
||||
</v-col>
|
||||
<v-col class="py-0 d-flex" cols="5">
|
||||
<v-file-input v-model="person.image" accept="image/*" dense density="compact"
|
||||
hide-details
|
||||
label="Картинка" variant="outlined"></v-file-input>
|
||||
<v-btn class="ms-1" color="error" icon="mdi-delete" size="small"
|
||||
@click="question.selectedEmployees.splice(ind,1); removeAnswer(index,ind)">
|
||||
<v-file-input
|
||||
v-model="person.image"
|
||||
accept="image/*"
|
||||
dense
|
||||
density="compact"
|
||||
hide-details
|
||||
label="Картинка"
|
||||
variant="outlined"
|
||||
></v-file-input>
|
||||
<v-btn
|
||||
class="ms-1"
|
||||
color="error"
|
||||
icon="mdi-delete"
|
||||
size="small"
|
||||
@click="
|
||||
question.selectedEmployees.splice(ind, 1);
|
||||
removeAnswer(index, ind);
|
||||
"
|
||||
>
|
||||
</v-btn>
|
||||
</v-col>
|
||||
</div>
|
||||
@@ -265,7 +357,9 @@
|
||||
</transition-group>
|
||||
<v-divider class="ma-2 pa-1"></v-divider>
|
||||
<div class="d-flex justify-center">
|
||||
<v-btn color="orange-darken-4" size="small" @click="addQuestion">Добавить вопрос</v-btn>
|
||||
<v-btn color="orange-darken-4" size="small" @click="addQuestion"
|
||||
>Добавить вопрос</v-btn
|
||||
>
|
||||
</div>
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
@@ -273,52 +367,79 @@
|
||||
<v-btn color="teal-darken-4" size="medium" @click="step = 2">Далее</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
|
||||
</v-stepper-window-item>
|
||||
|
||||
<!-- Подтверждение -->
|
||||
<v-stepper-window-item class="fill-height" step="3">
|
||||
|
||||
<v-card class="fill-height d-flex flex-column" flat>
|
||||
<v-card-title>Подтверждение</v-card-title>
|
||||
<v-card-text style="max-height: 62vh; overflow-y: auto;">
|
||||
<v-alert v-if="errorMessage" class="mb-4 " type="error">
|
||||
<v-card-text style="max-height: 62vh; overflow-y: auto">
|
||||
<v-alert v-if="errorMessage" class="mb-4" type="error">
|
||||
{{ errorMessage }}
|
||||
</v-alert>
|
||||
|
||||
<p>
|
||||
<v-icon :class="form.title===null||form.title.length===0?'':'opacity-0'" color='red' icon="mdi-alert"
|
||||
size="xsmall"/>
|
||||
<v-icon
|
||||
:class="form.title === null || form.title.length === 0 ? '' : 'opacity-0'"
|
||||
color="red"
|
||||
icon="mdi-alert"
|
||||
size="xsmall"
|
||||
/>
|
||||
<strong class="px-2">Название:</strong> {{ form.title }}
|
||||
</p>
|
||||
<p>
|
||||
<v-icon :class="form.description===null||form.description.length===0?'':'opacity-0'" color='red'
|
||||
icon="mdi-alert" size="xsmall"/>
|
||||
<v-icon
|
||||
:class="
|
||||
form.description === null || form.description.length === 0
|
||||
? ''
|
||||
: 'opacity-0'
|
||||
"
|
||||
color="red"
|
||||
icon="mdi-alert"
|
||||
size="xsmall"
|
||||
/>
|
||||
<strong class="px-2">Описание:</strong> {{ form.description }}
|
||||
</p>
|
||||
<p><strong class="px-2">Дата начала:</strong> {{ form.startDate.toLocaleDateString() }}</p>
|
||||
<p><strong class="px-2">Дата окончания:</strong> {{ form.endDate.toLocaleDateString() }}</p>
|
||||
<p>
|
||||
<strong class="px-2">Дата начала:</strong>
|
||||
{{ form.startDate.toLocaleDateString() }}
|
||||
</p>
|
||||
<p>
|
||||
<strong class="px-2">Дата окончания:</strong>
|
||||
{{ form.endDate.toLocaleDateString() }}
|
||||
</p>
|
||||
<p><strong class="px-2">Вопросы:</strong></p>
|
||||
|
||||
<v-card v-for="(question, index) in form.questions" :key="index" class="mb-4 pa-3">
|
||||
<v-card
|
||||
v-for="(question, index) in form.questions"
|
||||
:key="index"
|
||||
class="mb-4 pa-3"
|
||||
>
|
||||
<div class="pa-2">
|
||||
|
||||
<p><strong>Вопрос {{ index + 1 }}:</strong> {{ question.text }} ({{ question.type }})</p>
|
||||
<p>
|
||||
<strong>Вопрос {{ index + 1 }}:</strong> {{ question.text }} ({{
|
||||
question.type
|
||||
}})
|
||||
</p>
|
||||
|
||||
<div v-if="question.settings.choice === 'free' && question.answers.length">
|
||||
<p><strong>Варианты ответов:</strong></p>
|
||||
|
||||
|
||||
<ul>
|
||||
<li v-for="(answer, answerIndex) in question.answers" :key="answerIndex">
|
||||
{{ answer.text }}
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div v-if="question.settings.choice === 'employee' && question.answers.length">
|
||||
<div>Количество допустимых ответов: {{ question.settings.multiChoice }}</div>
|
||||
<div class="">Голосование по отделам:
|
||||
{{ onlyDepdict.find(e => e.value === question.settings.onlyDep).name }}
|
||||
<div
|
||||
v-if="question.settings.choice === 'employee' && question.answers.length"
|
||||
>
|
||||
<div>
|
||||
Количество допустимых ответов: {{ question.settings.multiChoice }}
|
||||
</div>
|
||||
<div class="">
|
||||
Голосование по отделам:
|
||||
{{ onlyDepdict.find((e) => e.value === question.settings.onlyDep).name }}
|
||||
</div>
|
||||
<p><strong>Выбранные сотрудники:</strong></p>
|
||||
<ul>
|
||||
@@ -329,100 +450,105 @@
|
||||
</div>
|
||||
</div>
|
||||
</v-card>
|
||||
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-btn color="teal-darken-4" size="medium" @click="step -= 1">Назад</v-btn>
|
||||
<v-btn :disabled="errorMessage!=''" color="teal-darken-4" size="medium" @click="saveVoting">
|
||||
<v-btn
|
||||
:disabled="errorMessage != ''"
|
||||
color="teal-darken-4"
|
||||
size="medium"
|
||||
@click="saveVoting"
|
||||
>
|
||||
Сохранить
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
|
||||
</v-card>
|
||||
</v-stepper-window-item>
|
||||
|
||||
</v-stepper-window>
|
||||
</v-stepper>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
</v-row>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {computed, ref, watch} from "vue";
|
||||
import {createVote, getEmployees, spravURL} from "@/utils/axios-api";
|
||||
import DateSelect from "@/components/UI/date-select.vue";
|
||||
import {checkremote} from "@/utils/universal_functions";
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { createVote, getEmployees, spravURL } from '@/utils/axios-api';
|
||||
import DateSelect from '@/components/UI/date-select.vue';
|
||||
import { checkremote } from '@/utils/universal_functions';
|
||||
|
||||
export default {
|
||||
components: {DateSelect},
|
||||
components: { DateSelect },
|
||||
emits: ['updating'],
|
||||
setup(props, {emit}) {
|
||||
setup(props, { emit }) {
|
||||
const step = ref(0);
|
||||
const isVoteCreated = ref(false);
|
||||
const form = ref({
|
||||
title: "",
|
||||
description: "",
|
||||
title: '',
|
||||
description: '',
|
||||
startDate: new Date(),
|
||||
endDate: new Date(new Date().setDate(new Date().getDate() + 14)),
|
||||
questions: [],
|
||||
createnews:false
|
||||
createnews: false,
|
||||
});
|
||||
|
||||
const rules = {
|
||||
required: (value) => !!value || "Это поле обязательно для заполнения",
|
||||
required: (value) => !!value || 'Это поле обязательно для заполнения',
|
||||
};
|
||||
|
||||
const currentQuestionIndex = ref(0);
|
||||
const questionTypes = [{name: "Ввести вручную", choice: 'free'}, {name: "Выбрать сотрудника", choice: 'employee'}];
|
||||
const questionTypes = [
|
||||
{ name: 'Ввести вручную', choice: 'free' },
|
||||
{ name: 'Выбрать сотрудника', choice: 'employee' },
|
||||
];
|
||||
|
||||
const groupedEmployees = ref([]);
|
||||
const allEmployees = computed(() => [
|
||||
...groupedEmployees.value,
|
||||
]);
|
||||
const allEmployees = computed(() => [...groupedEmployees.value]);
|
||||
|
||||
getEmployees()
|
||||
.then(r => groupedEmployees.value = r)
|
||||
getEmployees().then((r) => (groupedEmployees.value = r));
|
||||
|
||||
const currentQuestion = computed(() =>
|
||||
form.value.questions[currentQuestionIndex.value] || null
|
||||
const currentQuestion = computed(
|
||||
() => form.value.questions[currentQuestionIndex.value] || null,
|
||||
);
|
||||
const allEmployeesgroupedbydep = computed(() => {
|
||||
let groupped = []
|
||||
for (let x of allEmployees.value.sort((a, b) => a.id_dict_department - b.id_dict_department)) {
|
||||
if (!groupped.includes(x.department)) groupped.push(x.department)
|
||||
groupped.push(x)
|
||||
let groupped = [];
|
||||
for (let x of allEmployees.value.sort(
|
||||
(a, b) => a.id_dict_department - b.id_dict_department,
|
||||
)) {
|
||||
if (!groupped.includes(x.department)) groupped.push(x.department);
|
||||
groupped.push(x);
|
||||
}
|
||||
return groupped
|
||||
})
|
||||
return groupped;
|
||||
});
|
||||
const findEmployeeById = (id) =>
|
||||
groupedEmployees.value.find((employee) => employee.id === id) || {};
|
||||
|
||||
|
||||
const handleSelectAll = (selected, index) => {
|
||||
if (!selected) {
|
||||
form.value.questions[index].answers = groupedEmployees.value.map((employee) => ({
|
||||
text: employee.id,
|
||||
image: null,
|
||||
}));
|
||||
form.value.questions[index].selectedEmployees = groupedEmployees.value.map(employee => employee.id);
|
||||
form.value.questions[index].selectedEmployees = groupedEmployees.value.map(
|
||||
(employee) => employee.id,
|
||||
);
|
||||
} else {
|
||||
form.value.questions[index].answers = [];
|
||||
form.value.questions[index].selectedEmployees = []
|
||||
form.value.questions[index].selectedEmployees = [];
|
||||
}
|
||||
};
|
||||
|
||||
const isAllSelected = computed(() => currentQuestion.value.answers.length === groupedEmployees.value.length);
|
||||
const isAllSelected = computed(
|
||||
() => currentQuestion.value.answers.length === groupedEmployees.value.length,
|
||||
);
|
||||
|
||||
const addQuestion = () => {
|
||||
form.value.questions.push({
|
||||
text: "",
|
||||
settings: {choice: "free", multiChoice: 1, onlyDep: null},
|
||||
text: '',
|
||||
settings: { choice: 'free', multiChoice: 1, onlyDep: null },
|
||||
image: null,
|
||||
answers: [],
|
||||
selectedEmployees: []
|
||||
selectedEmployees: [],
|
||||
});
|
||||
currentQuestionIndex.value = form.value.questions.length - 1;
|
||||
};
|
||||
@@ -440,22 +566,20 @@ export default {
|
||||
|
||||
const addAnswer = (index) => {
|
||||
if (currentQuestion.value) {
|
||||
form.value.questions[index].answers.push({text: "", image: null});
|
||||
form.value.questions[index].answers.push({ text: '', image: null });
|
||||
}
|
||||
};
|
||||
|
||||
const removeAnswer = (index, ind) => {
|
||||
form.value.questions[index].answers.splice(ind, 1)
|
||||
form.value.questions[index].answers.splice(ind, 1);
|
||||
};
|
||||
|
||||
const errorMessage = ref("");
|
||||
const errorMessage = ref('');
|
||||
|
||||
const validateAnswers = () => {
|
||||
return form.value.questions.some((question) => {
|
||||
if (question.settings.choice === "free") {
|
||||
return question.answers.some(
|
||||
(answer) => !answer.text || answer.text.trim() === ""
|
||||
);
|
||||
if (question.settings.choice === 'free') {
|
||||
return question.answers.some((answer) => !answer.text || answer.text.trim() === '');
|
||||
}
|
||||
return false;
|
||||
});
|
||||
@@ -472,25 +596,24 @@ export default {
|
||||
hasEmptyQuestions ||
|
||||
hasInvalidAnswers
|
||||
) {
|
||||
errorMessage.value = "Все обязательные поля и ответы должны быть заполнены";
|
||||
errorMessage.value = 'Все обязательные поля и ответы должны быть заполнены';
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await createVote(form.value);
|
||||
console.log("Голосование успешно создано:", response);
|
||||
console.log('Голосование успешно создано:', response);
|
||||
isVoteCreated.value = true;
|
||||
emit("updating", "active");
|
||||
emit('updating', 'active');
|
||||
} catch (error) {
|
||||
console.error("Ошибка при создании голосования:", error);
|
||||
console.error('Ошибка при создании голосования:', error);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const resetForm = () => {
|
||||
form.value = {
|
||||
title: "",
|
||||
description: "",
|
||||
title: '',
|
||||
description: '',
|
||||
startDate: new Date(),
|
||||
endDate: new Date(new Date().setDate(new Date().getDate() + 14)),
|
||||
questions: [],
|
||||
@@ -499,94 +622,94 @@ export default {
|
||||
isVoteCreated.value = false;
|
||||
};
|
||||
|
||||
const timeOptions = Array.from({length: 48}, (_, i) => {
|
||||
const hours = String(Math.floor(i / 2)).padStart(2, "0");
|
||||
const minutes = i % 2 === 0 ? "00" : "30";
|
||||
const timeOptions = Array.from({ length: 48 }, (_, i) => {
|
||||
const hours = String(Math.floor(i / 2)).padStart(2, '0');
|
||||
const minutes = i % 2 === 0 ? '00' : '30';
|
||||
return `${hours}:${minutes}`;
|
||||
});
|
||||
|
||||
const selectedTimeStart = ref(
|
||||
`${(form.value.startDate.getHours() + 1).toString().padStart(2, "0")}:00`
|
||||
`${(form.value.startDate.getHours() + 1).toString().padStart(2, '0')}:00`,
|
||||
);
|
||||
|
||||
const selectedTimeEnd = ref(
|
||||
`${(form.value.endDate.getHours() + 1).toString().padStart(2, "0")}:00`
|
||||
`${(form.value.endDate.getHours() + 1).toString().padStart(2, '0')}:00`,
|
||||
);
|
||||
|
||||
watch(form.value, () => {
|
||||
if (!form.value.title || !form.value.description || form.value.questions.length < 1) {
|
||||
errorMessage.value = "Все обязательные поля должны быть заполнены";
|
||||
} else {
|
||||
errorMessage.value = "";
|
||||
}
|
||||
}, { deep: true });
|
||||
|
||||
const updateQuests = () => {
|
||||
quests.value = form.value.questions.map((q) => !!q.text.trim());
|
||||
};
|
||||
|
||||
watch(() => form.value.questions, updateQuests, { deep: true });
|
||||
watch(
|
||||
form.value,
|
||||
() => {
|
||||
if (!form.value.title || !form.value.description || form.value.questions.length < 1) {
|
||||
errorMessage.value = 'Все обязательные поля должны быть заполнены';
|
||||
} else {
|
||||
errorMessage.value = '';
|
||||
}
|
||||
},
|
||||
{ deep: true },
|
||||
);
|
||||
|
||||
watch(
|
||||
() => form.value.questions,
|
||||
(newQuestions) => {
|
||||
const hasEmptyQuestions = newQuestions.some((q) => !q.text || q.text.trim() === "");
|
||||
// Обновляем quests
|
||||
quests.value = newQuestions.map((q) => !!q.text.trim());
|
||||
|
||||
// Проверяем, есть ли пустые вопросы или невалидные ответы
|
||||
const hasEmptyQuestions = newQuestions.some((q) => !q.text || q.text.trim() === '');
|
||||
const hasInvalidAnswers = validateAnswers();
|
||||
|
||||
if (hasEmptyQuestions || hasInvalidAnswers) {
|
||||
errorMessage.value = "Все вопросы и ответы должны быть заполнены";
|
||||
} else {
|
||||
errorMessage.value = "";
|
||||
}
|
||||
errorMessage.value =
|
||||
hasEmptyQuestions || hasInvalidAnswers
|
||||
? 'Все вопросы и ответы должны быть заполнены'
|
||||
: '';
|
||||
},
|
||||
{ deep: true }
|
||||
{ deep: true },
|
||||
);
|
||||
|
||||
|
||||
watch(selectedTimeStart, () => {
|
||||
updateStartDate()
|
||||
})
|
||||
watch(selectedTimeEnd, () => {
|
||||
updateEndDate()
|
||||
})
|
||||
watch([selectedTimeStart, selectedTimeEnd], ([newStart, newEnd]) => {
|
||||
updateStartDate();
|
||||
updateEndDate();
|
||||
});
|
||||
|
||||
const updateStartDate = () => {
|
||||
const [hours, minutes] = selectedTimeStart.value.split(":").map(Number);
|
||||
const [hours, minutes] = selectedTimeStart.value.split(':').map(Number);
|
||||
form.value.startDate.setHours(hours, minutes);
|
||||
};
|
||||
const updateEndDate = () => {
|
||||
const [hours, minutes] = selectedTimeEnd.value.split(":").map(Number);
|
||||
const [hours, minutes] = selectedTimeEnd.value.split(':').map(Number);
|
||||
form.value.endDate.setHours(hours, minutes);
|
||||
};
|
||||
|
||||
const returnstart = (dates) => {
|
||||
form.value.startDate = dates
|
||||
}
|
||||
form.value.startDate = dates;
|
||||
};
|
||||
|
||||
const returnend = (dates) => {
|
||||
form.value.endDate = dates
|
||||
}
|
||||
form.value.endDate = dates;
|
||||
};
|
||||
|
||||
const onEmployeesChange = (selected, index) => {
|
||||
let ind = form.value.questions[index].selectedEmployees.findIndex(e => e === selected)
|
||||
let ind = form.value.questions[index].selectedEmployees.findIndex((e) => e === selected);
|
||||
if (ind > -1) {
|
||||
form.value.questions[index].selectedEmployees.splice(ind, 1)
|
||||
let answ = form.value.questions[index].answers.findIndex(a => a.text === selected)
|
||||
form.value.questions[index].answers.splice(answ, 1)
|
||||
form.value.questions[index].selectedEmployees.splice(ind, 1);
|
||||
let answ = form.value.questions[index].answers.findIndex((a) => a.text === selected);
|
||||
form.value.questions[index].answers.splice(answ, 1);
|
||||
} else {
|
||||
form.value.questions[index].selectedEmployees.push(selected)
|
||||
form.value.questions[index].answers.push({text: selected, image: null});
|
||||
form.value.questions[index].selectedEmployees.push(selected);
|
||||
form.value.questions[index].answers.push({ text: selected, image: null });
|
||||
}
|
||||
};
|
||||
|
||||
const onlyDepdict = [{name: 'За любого сотрудника', value: null}, {
|
||||
name: "Кроме своего отдела",
|
||||
value: false
|
||||
}, {name: "Только за свой отдел", value: true}]
|
||||
const onlyDepdict = [
|
||||
{ name: 'За любого сотрудника', value: null },
|
||||
{
|
||||
name: 'Кроме своего отдела',
|
||||
value: false,
|
||||
},
|
||||
{ name: 'Только за свой отдел', value: true },
|
||||
];
|
||||
|
||||
const quests = computed(() =>
|
||||
form.value.questions.map((question) => question.text.length > 0)
|
||||
);
|
||||
const quests = computed(() => form.value.questions.map((question) => question.text.length > 0));
|
||||
|
||||
return {
|
||||
quests,
|
||||
@@ -616,7 +739,7 @@ export default {
|
||||
handleSelectAll,
|
||||
isAllSelected,
|
||||
checkremote,
|
||||
spravURL
|
||||
spravURL,
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -637,5 +760,4 @@ export default {
|
||||
opacity: 0;
|
||||
transform: translateX(50px);
|
||||
}
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,85 @@
|
||||
import { mount } from '../../../../documentation/node_modules/@vue/test-utils';
|
||||
import CarouselList from '@/components/carousel-list.vue';
|
||||
|
||||
// Мок axios
|
||||
jest.mock('@/utils/axios-api', () => ({
|
||||
baseURL: 'http://example.com/',
|
||||
axiosApiInstance: {
|
||||
get: jest.fn(),
|
||||
},
|
||||
}));
|
||||
|
||||
// Мок alert store
|
||||
jest.mock('@/store/useAlertStore', () => ({
|
||||
useAlertStore: () => ({
|
||||
alert: {
|
||||
alert: false,
|
||||
text: '',
|
||||
color: '',
|
||||
ico: '',
|
||||
},
|
||||
}),
|
||||
}));
|
||||
|
||||
describe('CarouselList.vue', () => {
|
||||
beforeEach(() => {
|
||||
const { axiosApiInstance } = require('@/utils/axios-api');
|
||||
axiosApiInstance.get.mockClear();
|
||||
Object.defineProperty(document, 'exitFullscreen', {
|
||||
writable: true,
|
||||
value: jest.fn(),
|
||||
});
|
||||
});
|
||||
|
||||
it('вызывает axiosApiInstance.get при монтировании', async () => {
|
||||
const { axiosApiInstance } = require('@/utils/axios-api');
|
||||
axiosApiInstance.get.mockResolvedValue({ data: { mess: '', result: [] } });
|
||||
|
||||
const wrapper = mount(CarouselList, {
|
||||
global: {
|
||||
stubs: ['v-carousel', 'v-carousel-item'],
|
||||
},
|
||||
});
|
||||
|
||||
await wrapper.vm.$nextTick();
|
||||
expect(axiosApiInstance.get).toHaveBeenCalledWith('api/navigation/carousels/');
|
||||
});
|
||||
|
||||
it('устанавливает большой интервал, если текущий слайд – видео', async () => {
|
||||
const wrapper = mount(CarouselList, {
|
||||
global: {
|
||||
stubs: ['v-carousel', 'v-carousel-item'],
|
||||
},
|
||||
});
|
||||
|
||||
// Создаём фейковый элемент видео
|
||||
wrapper.vm.videoElement = [{ pause: jest.fn(), currentSrc: '' }];
|
||||
|
||||
wrapper.vm.carous = [{ link: '/video.mp4' }];
|
||||
wrapper.vm.currentslide = 0;
|
||||
await wrapper.vm.$nextTick();
|
||||
|
||||
wrapper.vm.slidechanged();
|
||||
expect(wrapper.vm.interval).toBe(10000000000);
|
||||
});
|
||||
|
||||
it('обрабатывает событие ended', async () => {
|
||||
const wrapper = mount(CarouselList, {
|
||||
global: {
|
||||
stubs: ['v-carousel', 'v-carousel-item'],
|
||||
},
|
||||
});
|
||||
|
||||
const fakeEvent = {
|
||||
target: {
|
||||
currentTime: 5,
|
||||
pause: jest.fn(),
|
||||
},
|
||||
};
|
||||
|
||||
wrapper.vm.ended(fakeEvent);
|
||||
expect(fakeEvent.target.currentTime).toBe(0);
|
||||
expect(fakeEvent.target.pause).toHaveBeenCalled();
|
||||
expect(document.exitFullscreen).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
@@ -1,44 +1,44 @@
|
||||
<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-container :fluid="true" class="pa-2 d-flex flex-column h-100">
|
||||
<v-tabs v-model="activeTab" class="mx-2">
|
||||
<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 v-model="activeTab">
|
||||
<!-- Вкладка назначенные -->
|
||||
<v-tabs-window-item class="my-2">
|
||||
<CatalogTest title="Назначенные" :activeTab="activeTab" :testingCard="getAllTests">
|
||||
<v-tabs-window-item class="my-2 w-75 mx-auto h-100">
|
||||
<CatalogTest :activeTab="activeTab" :testingCard="getAllTests" title="Назначенные">
|
||||
<template #buttons>
|
||||
<v-btn color="#00897B1F" class="mr-2 text-teal-darken-1" elevation="0">
|
||||
<v-btn class="mr-2 text-teal-darken-1" color="#00897B1F" elevation="0">
|
||||
Тренироваться
|
||||
|
||||
|
||||
</v-btn>
|
||||
<v-btn color="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">
|
||||
<v-tabs-window-item class="w-75 mx-auto">
|
||||
<CatalogTest :activeTab="activeTab" :testingCard="getAllTests" title="Завершенные">
|
||||
<!-- Здесь отобразить результат теста после того как будет готов БЭК и УМТ -->
|
||||
<template #results>
|
||||
<!-- <div>
|
||||
<v-icon icon="mdi-calendar-clock" size="large" />
|
||||
<span class="ml-1">12354</span>
|
||||
</div> -->
|
||||
</template>
|
||||
<template #results></template>
|
||||
<template #buttons>
|
||||
<v-btn color="#00897B1F" class="mr-2 text-teal-darken-1" elevation="0">
|
||||
<v-btn class="mr-2 text-teal-darken-1" color="#00897B1F" 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-tabs-window-item class="w-75 mx-auto h-100">
|
||||
<CatalogTest :activeTab="activeTab" :testingCard="getAllTests" title="Каталог">
|
||||
<template #buttons="{ cardValue }">
|
||||
<v-btn
|
||||
class="mr-2 text-teal-darken-1"
|
||||
color="#00897B1F"
|
||||
elevation="0"
|
||||
@click="goToTest(cardValue.id)"
|
||||
>
|
||||
Тренироваться
|
||||
</v-btn>
|
||||
</template>
|
||||
@@ -52,13 +52,15 @@
|
||||
import CatalogTest from '@/components/testing/CatalogTest.vue';
|
||||
import { axiosApiInstance } from '@/utils/axios-api';
|
||||
|
||||
import { ref, computed, watch } from 'vue';
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
CatalogTest,
|
||||
},
|
||||
setup() {
|
||||
const router = useRouter();
|
||||
const activeTab = ref(0);
|
||||
const currentTest = ref('');
|
||||
console.log('tag', 'dsd')
|
||||
@@ -66,12 +68,12 @@ export default {
|
||||
|
||||
const getTestById = () => {
|
||||
let status =
|
||||
activeTab.value == 0 ? '?status=active' : activeTab.value == 1 ? '?status=completed' : '';
|
||||
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) {
|
||||
if (activeTab.value === 0) {
|
||||
currentTest.value = getAllTests.value.length;
|
||||
}
|
||||
});
|
||||
@@ -92,10 +94,13 @@ export default {
|
||||
{ value: 2, title: 'Каталог' },
|
||||
]);
|
||||
|
||||
const goToTest = (id) => router.push(`/test/testdetail/${id}`);
|
||||
|
||||
return {
|
||||
activeTab,
|
||||
tabs,
|
||||
getAllTests,
|
||||
goToTest,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
@@ -2,30 +2,25 @@
|
||||
<v-container class="pt-2 d-flex flex-column" fluid>
|
||||
<v-row class="flex-column">
|
||||
<v-col cols="auto">
|
||||
<v-tabs
|
||||
v-model="currentTab"
|
||||
align="center">
|
||||
<v-tabs v-model="currentTab" align="center">
|
||||
<v-tab v-for="x in tabs" :key="x.value" :value="x.value">{{ x.text }}</v-tab>
|
||||
<v-tab v-if="accountStore.user.is_staff" value="constructor">Создать новое голосование</v-tab>
|
||||
|
||||
<v-tab v-if="accountStore.user.is_staff" value="constructor"
|
||||
>Создать новое голосование</v-tab
|
||||
>
|
||||
</v-tabs>
|
||||
|
||||
</v-col>
|
||||
<v-col class="pa-0 overflow-hidden">
|
||||
|
||||
<v-window v-model="currentTab" class="h-100">
|
||||
<!-- Текущие голосования -->
|
||||
<v-tabs-window-item v-for="x in ['active','completed']" :value="x" class="h-100 overflow-auto">
|
||||
<v-window-item
|
||||
v-for="x in ['active', 'completed']"
|
||||
:value="x"
|
||||
class="h-100 overflow-auto"
|
||||
>
|
||||
<v-row v-if="sortedVotes.length > 0" class="mx-2">
|
||||
<v-col
|
||||
v-for="voting in sortedVotes"
|
||||
:key="voting.id"
|
||||
cols="12"
|
||||
lg="3"
|
||||
md="4"
|
||||
>
|
||||
<v-col v-for="voting in sortedVotes" :key="voting.id" cols="12" lg="3" md="4">
|
||||
<VoteCardVue
|
||||
:isFinished="currentTab==='active'"
|
||||
:isFinished="currentTab === 'active'"
|
||||
:voteCard="voting"
|
||||
@deleteVoting="deleteVoting"
|
||||
@openResultModal="(voting) => openModal('results', voting)"
|
||||
@@ -33,17 +28,21 @@
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<NoneVote v-else :current="currentTab == 'active' ? 'Текущих' : 'Завершенных'"/>
|
||||
</v-tabs-window-item>
|
||||
<NoneVote v-else :current="currentTab === 'active' ? 'Текущих' : 'Завершенных'" />
|
||||
</v-window-item>
|
||||
<!-- Конструктор -->
|
||||
<v-tabs-window-item v-if="accountStore.user.is_staff" class="h-100 overflow-auto" value="constructor">
|
||||
<VoteConstructor @updating="updating" ref="constructor"/>
|
||||
</v-tabs-window-item>
|
||||
<v-window-item
|
||||
v-if="accountStore.user.is_staff"
|
||||
class="h-100 overflow-auto"
|
||||
value="constructor"
|
||||
>
|
||||
<VoteConstructor @updating="updating" ref="constructor" />
|
||||
</v-window-item>
|
||||
</v-window>
|
||||
|
||||
<!-- Модальные окна -->
|
||||
<v-dialog v-model="voteModal" @click:outside="closeModal">
|
||||
<CurrentVote :data="res" @closer="closeModal"/>
|
||||
<CurrentVote :data="res" @closer="closeModal" />
|
||||
</v-dialog>
|
||||
|
||||
<v-dialog v-model="resultsModal" max-width="1200px" @click:outside="closeModal">
|
||||
@@ -57,60 +56,59 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {computed, ref, watch} from "vue";
|
||||
import VoteConstructor from "@/components/vote/VoteConstructor.vue";
|
||||
import CurrentVote from "@/components/vote/CurrentVote.vue";
|
||||
import VoteCardVue from "@/components/vote/VoteCard.vue";
|
||||
import NoneVote from "@/components/vote/NoneVote.vue"
|
||||
import {useRoute, useRouter} from "vue-router";
|
||||
import VoteResult from "@/components/vote/VoteResult.vue";
|
||||
import {deleteVote, getVoteDetail, getVoteResult, getVotes} from "@/utils/axios-api";
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import VoteConstructor from '@/components/vote/VoteConstructor.vue';
|
||||
import CurrentVote from '@/components/vote/CurrentVote.vue';
|
||||
import VoteCardVue from '@/components/vote/VoteCard.vue';
|
||||
import NoneVote from '@/components/vote/NoneVote.vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import VoteResult from '@/components/vote/VoteResult.vue';
|
||||
import { deleteVote, getVoteDetail, getVoteResult, getVotes } from '@/utils/axios-api';
|
||||
// import {formatDate} from "@vueuse/shared";
|
||||
import { useAccountStore } from "@/store/AccountStore";
|
||||
import {pagecounter} from '@/utils/universal_functions'
|
||||
import { useAccountStore } from '@/store/AccountStore';
|
||||
import { pagecounter } from '@/utils/universal_functions';
|
||||
|
||||
export default {
|
||||
|
||||
|
||||
components: {CurrentVote, VoteConstructor, VoteCardVue, VoteResult, NoneVote},
|
||||
components: { CurrentVote, VoteConstructor, VoteCardVue, VoteResult, NoneVote },
|
||||
setup() {
|
||||
pagecounter()
|
||||
pagecounter();
|
||||
const accountStore = useAccountStore();
|
||||
const tabs = [
|
||||
{value: "active", text: 'Текущие голосования'},
|
||||
{value: "completed", text: 'Завершенные голосования'},
|
||||
{ value: 'active', text: 'Текущие голосования' },
|
||||
{ value: 'completed', text: 'Завершенные голосования' },
|
||||
];
|
||||
|
||||
]
|
||||
|
||||
const currentTab = ref("active");
|
||||
const currentTab = ref('active');
|
||||
const votes = ref([]);
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
const res = ref(null);
|
||||
const result = ref(null);
|
||||
const constructor = ref(null)
|
||||
const constructor = ref(null);
|
||||
|
||||
const updating = async (param) => {
|
||||
const data = await getVotes(param);
|
||||
votes.value = data;
|
||||
};
|
||||
|
||||
updating("active");
|
||||
updating('active');
|
||||
|
||||
const voteModal = ref(false);
|
||||
const resultsModal = ref(false);
|
||||
const selectedVoting = ref(null);
|
||||
|
||||
const sortedVotes = computed(() => currentTab.value === 'active' ? votes.value.sort((a, b) =>
|
||||
new Date(a.dateend) - new Date(b.dateend)) :
|
||||
votes.value.sort((a, b) => new Date(b.dateend) - new Date(a.dateend)));
|
||||
const sortedVotes = computed(() =>
|
||||
currentTab.value === 'active'
|
||||
? votes.value.sort((a, b) => new Date(a.dateend) - new Date(b.dateend))
|
||||
: votes.value.sort((a, b) => new Date(b.dateend) - new Date(a.dateend)),
|
||||
);
|
||||
|
||||
const loadVoteDetails = async (id) => {
|
||||
try {
|
||||
const data = await getVoteDetail(id);
|
||||
res.value = data;
|
||||
} catch (error) {
|
||||
console.error("Ошибка при загрузке данных голосования:", error);
|
||||
console.error('Ошибка при загрузке данных голосования:', error);
|
||||
// res.value = {};
|
||||
|
||||
throw error;
|
||||
@@ -122,7 +120,7 @@ export default {
|
||||
const data = await getVoteResult(id);
|
||||
result.value = data;
|
||||
} catch (error) {
|
||||
console.error("Ошибка при загрузке данных голосования:", error);
|
||||
console.error('Ошибка при загрузке данных голосования:', error);
|
||||
res.value = {};
|
||||
}
|
||||
};
|
||||
@@ -131,26 +129,26 @@ export default {
|
||||
voteModal.value = false;
|
||||
resultsModal.value = false;
|
||||
selectedVoting.value = null;
|
||||
router.push({name: "VoteHomePage"});
|
||||
if (route.name === "Voting") updating('active')
|
||||
if (route.name === "VoteResults") updating('completed')
|
||||
router.push({ name: 'VoteHomePage' });
|
||||
if (route.name === 'Voting') updating('active');
|
||||
if (route.name === 'VoteResults') updating('completed');
|
||||
};
|
||||
|
||||
const openModal = async (type, voting) => {
|
||||
selectedVoting.value = voting;
|
||||
if (type === "vote") {
|
||||
try{
|
||||
if (type === 'vote') {
|
||||
try {
|
||||
await loadVoteDetails(voting.id);
|
||||
console.log("sd;lkjs;ljlmnjlk");
|
||||
console.log('sd;lkjs;ljlmnjlk');
|
||||
voteModal.value = true;
|
||||
router.push({name: "Voting", params: {id: voting.id}});
|
||||
}catch(e){
|
||||
router.push({ name: "VoteHomePage" })
|
||||
router.push({ name: 'Voting', params: { id: voting.id } });
|
||||
} catch (e) {
|
||||
router.push({ name: 'VoteHomePage' });
|
||||
}
|
||||
} else if (type === "results") {
|
||||
} else if (type === 'results') {
|
||||
await loadVoteResult(voting.id);
|
||||
resultsModal.value = true;
|
||||
router.push({name: "VoteResults", params: {id: voting.id}});
|
||||
router.push({ name: 'VoteResults', params: { id: voting.id } });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -159,45 +157,45 @@ export default {
|
||||
await deleteVote(id);
|
||||
votes.value = votes.value.filter((v) => v.id !== id);
|
||||
} catch (error) {
|
||||
console.error("Ошибка при удалении голосования:", error);
|
||||
console.error('Ошибка при удалении голосования:', error);
|
||||
}
|
||||
};
|
||||
|
||||
watch(currentTab, async () => {
|
||||
if (currentTab.value !== 'constructor') {
|
||||
await updating(currentTab.value)
|
||||
await updating(currentTab.value);
|
||||
console.log(constructor.value, '!!!');
|
||||
if (constructor.value !== null) {
|
||||
constructor.value.resetForm()
|
||||
constructor.value.resetForm();
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
watch(
|
||||
() => route,
|
||||
async () => {
|
||||
if (!voteModal.value && !resultsModal.value) {
|
||||
const voting = votes.value.find((v) => v.id === route.params.id);
|
||||
if (route.name === "Voting") {
|
||||
try{
|
||||
await loadVoteDetails(route.params.id);
|
||||
voteModal.value = true;}
|
||||
catch(e){
|
||||
router.push({ name: "VoteHomePage" })
|
||||
if (route.name === 'Voting') {
|
||||
try {
|
||||
await loadVoteDetails(route.params.id);
|
||||
voteModal.value = true;
|
||||
} catch (e) {
|
||||
router.push({ name: 'VoteHomePage' });
|
||||
}
|
||||
}
|
||||
// if (route.name === "EditVote") editVoteModal.value = true;
|
||||
if (route.name === "VoteResults") {
|
||||
await loadVoteResult(route.params.id)
|
||||
if (route.name === 'VoteResults') {
|
||||
await loadVoteResult(route.params.id);
|
||||
resultsModal.value = true;
|
||||
}
|
||||
selectedVoting.value = voting || null;
|
||||
}
|
||||
},
|
||||
{immediate: true}
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
updating("active");
|
||||
updating('active');
|
||||
|
||||
return {
|
||||
accountStore,
|
||||
@@ -214,7 +212,7 @@ export default {
|
||||
res,
|
||||
tabs,
|
||||
result,
|
||||
constructor
|
||||
constructor,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user