Merge branch 'develop' into test
This commit is contained in:
commit
0036b0e85b
44 files changed
+4624
-21920
No files matched your search
@@ -129,6 +129,7 @@ class OrderResponsibility(models.Model):
|
|||||||
return f'{self.number} - {self.name}'
|
return f'{self.number} - {self.name}'
|
||||||
|
|
||||||
class OrderResponsibilityEmployee(models.Model):
|
class OrderResponsibilityEmployee(models.Model):
|
||||||
|
id = models.PositiveIntegerField(primary_key=True, db_comment='╥рсхы№э√щ эюьхЁ')
|
||||||
id_order_responsibility = models.OneToOneField(OrderResponsibility, models.DO_NOTHING, db_column='id_order_responsibility', db_comment='╚─ яЁшърчр ю эрчэрўхэшш юЄтхЄёЄтхээ√ї ёюЄЁєфэшъют',related_name="respons_users") # The composite primary key (id_order_responsibility, id_dict_employee) found, that is not supported. The first column is selected.
|
id_order_responsibility = models.OneToOneField(OrderResponsibility, models.DO_NOTHING, db_column='id_order_responsibility', db_comment='╚─ яЁшърчр ю эрчэрўхэшш юЄтхЄёЄтхээ√ї ёюЄЁєфэшъют',related_name="respons_users") # The composite primary key (id_order_responsibility, id_dict_employee) found, that is not supported. The first column is selected.
|
||||||
employee = models.ForeignKey('userauth.DictEmployee', models.DO_NOTHING, db_column='id_dict_employee', db_comment='╚─ ёюЄЁєфэшър, ъюЄюЁ√щ эрчэрўхэ юЄтхЄёЄтхээ√ь яю фрээюьє яЁшърчє', related_name="user_respons")
|
employee = models.ForeignKey('userauth.DictEmployee', models.DO_NOTHING, db_column='id_dict_employee', db_comment='╚─ ёюЄЁєфэшър, ъюЄюЁ√щ эрчэрўхэ юЄтхЄёЄтхээ√ь яю фрээюьє яЁшърчє', related_name="user_respons")
|
||||||
|
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ class Carousels(models.Model):
|
|||||||
text= models.TextField(max_length=260, blank=True, null=True, verbose_name='Сообщение')
|
text= models.TextField(max_length=260, blank=True, null=True, verbose_name='Сообщение')
|
||||||
cdate =models.DateTimeField(default=now, verbose_name='Дата создания')
|
cdate =models.DateTimeField(default=now, verbose_name='Дата создания')
|
||||||
author = models.ForeignKey(settings.AUTH_USER_MODEL, editable=False, on_delete=models.PROTECT, verbose_name='Автор новости')
|
author = models.ForeignKey(settings.AUTH_USER_MODEL, editable=False, on_delete=models.PROTECT, verbose_name='Автор новости')
|
||||||
link = models.ImageField(upload_to='newsimage/%Y/%m/%d', null=True, default="newsimage/default.jpg", verbose_name='Картинка')
|
link = models.FileField(upload_to='newsimage/%Y/%m/%d', null=True, default="newsimage/default.jpg", verbose_name='Картинка')
|
||||||
published = models.BooleanField(default=True, verbose_name='Опубликован')
|
published = models.BooleanField(default=True, verbose_name='Опубликован')
|
||||||
enddate = models.DateTimeField(default=default_end_date, verbose_name='Дата снятия с публикации')
|
enddate = models.DateTimeField(default=default_end_date, verbose_name='Дата снятия с публикации')
|
||||||
sender = models.ForeignKey(BaseSender, on_delete=models.PROTECT, related_name='get_base_sender', verbose_name='Тематика')
|
sender = models.ForeignKey(BaseSender, on_delete=models.PROTECT, related_name='get_base_sender', verbose_name='Тематика')
|
||||||
|
|||||||
@@ -65,10 +65,10 @@ INSTALLED_APPS = [
|
|||||||
'navigation.apps.NavigationConfig',
|
'navigation.apps.NavigationConfig',
|
||||||
'drf_yasg',
|
'drf_yasg',
|
||||||
'accounts',
|
'accounts',
|
||||||
'safety',
|
|
||||||
|
|
||||||
'vote.apps.VoteConfig',
|
|
||||||
'commeteresp',
|
'commeteresp',
|
||||||
|
'safety',
|
||||||
|
'vote.apps.VoteConfig',
|
||||||
|
|
||||||
# 'orgmanagment',
|
# 'orgmanagment',
|
||||||
'corsheaders',
|
'corsheaders',
|
||||||
'watcher.apps.WatcherConfig',
|
'watcher.apps.WatcherConfig',
|
||||||
|
|||||||
@@ -20,21 +20,4 @@ class SafetyAPIView(APIView):
|
|||||||
chapters = self.request.query_params.get('chapter', "fire")
|
chapters = self.request.query_params.get('chapter', "fire")
|
||||||
safety_group = SafetyType.objects.get(path=chapters)
|
safety_group = SafetyType.objects.get(path=chapters)
|
||||||
return Response(SafetySerializer(safety_group).data)
|
return Response(SafetySerializer(safety_group).data)
|
||||||
|
|
||||||
# class SafetyResponsebilityAPIView(APIView):
|
|
||||||
|
|
||||||
# def get(self, request):
|
|
||||||
|
|
||||||
# fireuser = OrderResponsibility.objects.get(id=54)
|
|
||||||
# responsobility_users = OrderResponsibilitySerializer(fireuser)
|
|
||||||
|
|
||||||
# return Response(responsobility_users.data)
|
|
||||||
|
|
||||||
# class CommitteeFilesAPIView(APIView):
|
|
||||||
|
|
||||||
# def get(self, request):
|
|
||||||
|
|
||||||
# committee_files = Committee1.objects.get(id=106)
|
|
||||||
# files = Committee1Serializer(committee_files)
|
|
||||||
|
|
||||||
# return Response(files.data)
|
|
||||||
+9
-29
@@ -1,41 +1,21 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from .models import *
|
from .models import *
|
||||||
|
|
||||||
|
class TestAnswerInline(admin.StackedInline):
|
||||||
|
model = TestAnswer
|
||||||
class InlineAppointment(admin.StackedInline):
|
|
||||||
|
|
||||||
fields = ('link_on_user',)
|
|
||||||
model = SavedResultTest
|
|
||||||
extra = 0
|
extra = 0
|
||||||
|
|
||||||
|
class TestQuestionAdmin(admin.ModelAdmin):
|
||||||
|
inlines = [TestAnswerInline]
|
||||||
|
|
||||||
class AppointmentAdmin(admin.ModelAdmin):
|
class TestQuestionInline(admin.StackedInline):
|
||||||
inlines = [InlineAppointment]
|
model = TestQuestion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class InlineQuestion(admin.StackedInline):
|
|
||||||
fields = ('question_name', 'name_of_test', 'description', 'question_image',)
|
|
||||||
model = Question
|
|
||||||
extra = 0
|
extra = 0
|
||||||
|
|
||||||
|
|
||||||
class InlineAnswer(admin.StackedInline):
|
|
||||||
fields = ('answer_variant', 'right_wrong', 'name_of_question'),
|
|
||||||
model = Answer
|
|
||||||
extra = 0
|
|
||||||
|
|
||||||
|
|
||||||
class TestAdmin(admin.ModelAdmin):
|
class TestAdmin(admin.ModelAdmin):
|
||||||
inlines = [InlineQuestion, InlineAnswer]
|
inlines = [TestQuestionInline]
|
||||||
|
|
||||||
# Dunmmy добавлен временно пока не будет придумано как надо.
|
|
||||||
admin.site.register(Dummy)
|
|
||||||
|
|
||||||
|
|
||||||
admin.site.register(AppointmentTest, AppointmentAdmin)
|
|
||||||
admin.site.register(Test, TestAdmin)
|
admin.site.register(Test, TestAdmin)
|
||||||
admin.site.register(Question)
|
admin.site.register(TestQuestion, TestQuestionAdmin)
|
||||||
admin.site.register(Answer)
|
admin.site.register(TestAnswer)
|
||||||
admin.site.register(SavedResultTest)
|
|
||||||
+63
-57
@@ -1,81 +1,87 @@
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
from userauth.models import DictEmployee
|
from userauth.models import DictEmployee
|
||||||
|
from django.db import models
|
||||||
|
from userauth.models import *
|
||||||
|
from accounts.models import User
|
||||||
|
import datetime
|
||||||
|
|
||||||
# Заглушка для type_test(ключ ИБ/ОТ...) модель тестов Test
|
class Test(models.Model):
|
||||||
class Dummy(models.Model):
|
file = models.ImageField(upload_to='tests/files/', null=True, blank=True, verbose_name='Лого Теста')
|
||||||
dummy = models.CharField(max_length=255, verbose_name="Заглушка")
|
name = models.CharField(max_length=255, blank=False, verbose_name="Название теста")
|
||||||
|
description = models.TextField(verbose_name='Описание')
|
||||||
|
datestart = models.DateTimeField(default=datetime.datetime.now, verbose_name='Дата и время начала периода')
|
||||||
|
dateend = models.DateTimeField(default=datetime.datetime.now, verbose_name='Дата и время окончания периода')
|
||||||
|
author = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name='Создатель тестирования')
|
||||||
|
pass_perc = models.FloatField(blank=False, verbose_name="Мин. кол-во правильных ответов")
|
||||||
|
time = models.FloatField(blank=False, verbose_name="Время прохождения теста")
|
||||||
|
question_count = models.PositiveIntegerField(blank=False, verbose_name="Количество вопросов")
|
||||||
|
attemps_number = models.PositiveIntegerField(blank=False, verbose_name="Количество попыток")
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.dummy
|
return self.name
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Модель тестов
|
|
||||||
class Test(models.Model):
|
|
||||||
title_image = models.ImageField(verbose_name='Лого Теста')
|
|
||||||
name_test = models.CharField(max_length=255, blank=False, verbose_name="Назание теста")
|
|
||||||
type_test = models.ForeignKey(Dummy,on_delete=models.PROTECT, verbose_name="Тип теста")# ссылается на модель заглушку Dummy
|
|
||||||
pass_perc = models.FloatField(blank=False, verbose_name="Проходной процент")
|
|
||||||
max_time = models.FloatField(blank=False, verbose_name="Время прохождения теста")
|
|
||||||
attemps_number = models.IntegerField(blank=False, verbose_name="Количество попыток")
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = "Тест"
|
verbose_name = "Тест"
|
||||||
verbose_name_plural = "Тест"
|
verbose_name_plural = "Тесты"
|
||||||
def __str__(self):
|
|
||||||
return self.name_test
|
|
||||||
|
|
||||||
# Модель вопросов
|
class TestQuestion(models.Model):
|
||||||
class Question(models.Model):
|
name = models.CharField(max_length=255, blank=False, verbose_name="Вопрос")
|
||||||
question_name = models.CharField(max_length=255, blank=False, verbose_name="Название вопроса")
|
test = models.ForeignKey(Test, related_name='questions', on_delete=models.CASCADE, verbose_name="Тест")
|
||||||
name_of_test = models.ForeignKey(Test,on_delete=models.PROTECT, verbose_name="Тест")
|
file = models.ImageField(upload_to='tests/question_images/', null=True, blank=True, verbose_name='Картинка')
|
||||||
description = models.CharField(max_length=255, blank=False, verbose_name="Описание")
|
numb = models.PositiveIntegerField(verbose_name="Порядковый номер вопроса")
|
||||||
question_image = models.ImageField()
|
settings = models.JSONField(default=dict, verbose_name='Json настроек тестирования')
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = "Вопрос"
|
verbose_name = "Вопрос"
|
||||||
verbose_name_plural = "Вопрос"
|
verbose_name_plural = "Вопросы"
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.question_name
|
return self.name
|
||||||
|
|
||||||
# Модель ответов
|
class TestAnswer(models.Model):
|
||||||
class Answer(models.Model):
|
name = models.CharField(max_length=255, blank=False, verbose_name="Ответ")
|
||||||
answer_variant = models.CharField(max_length=255, blank=False, verbose_name="Вариант ответа")
|
file = models.FileField(upload_to='tests/answer_files/', null=True, blank=True, verbose_name='Картинка')
|
||||||
|
question = models.ForeignKey(TestQuestion, related_name='answers', on_delete=models.CASCADE, verbose_name="Вопрос")
|
||||||
right_wrong = models.BooleanField(blank=False, verbose_name="Правильно/Неправильно")
|
right_wrong = models.BooleanField(blank=False, verbose_name="Правильно/Неправильно")
|
||||||
name_of_test = models.ForeignKey(Test, default=None, on_delete=models.PROTECT, verbose_name="Тест")
|
|
||||||
name_of_question = models.ForeignKey(Question, on_delete=models.PROTECT, verbose_name="Вопрос")
|
|
||||||
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = "Ответ"
|
verbose_name = "Ответ"
|
||||||
verbose_name_plural = "Ответ"
|
verbose_name_plural = "Ответы"
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.answer_variant
|
return self.name
|
||||||
|
|
||||||
|
class TestAttempt(models.Model):
|
||||||
|
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='test_attempts')
|
||||||
# Модель назначения тестов
|
test = models.ForeignKey(Test, on_delete=models.CASCADE)
|
||||||
class AppointmentTest(models.Model):
|
score = models.FloatField(verbose_name='Результат', default=0.0)
|
||||||
dedline_date = models.DateField(blank=True, null=True, verbose_name="Дата окончания тестирования" )
|
attempt_number = models.IntegerField(verbose_name='Номер попытки', default=1)
|
||||||
tests = models.ForeignKey(Test, on_delete=models.PROTECT, blank=False, verbose_name="Тест")
|
completion_date = models.DateTimeField(default=datetime.datetime.now, verbose_name="Дата прохождения теста")
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = "Назначение теста"
|
verbose_name = 'Попытка прохождения теста'
|
||||||
verbose_name_plural = "Назначение теста"
|
verbose_name_plural = 'Попытки прохождения тестов'
|
||||||
|
|
||||||
|
class TestResult(models.Model):
|
||||||
|
attempt = models.ForeignKey(TestAttempt, on_delete=models.CASCADE, related_name='test_results')
|
||||||
|
answer = models.ForeignKey(TestAnswer, on_delete=models.CASCADE)
|
||||||
|
comment = models.TextField(null=True, blank=True)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.tests.name_test
|
return self.answer.name
|
||||||
|
|
||||||
|
|
||||||
# Модель Сохраненных результатов
|
|
||||||
class SavedResultTest(models.Model):
|
|
||||||
accomplish_date = models.DateTimeField(verbose_name="Дата и завершения тестирования")
|
|
||||||
perc_result = models.FloatField(blank=False, verbose_name="Результат(%)")
|
|
||||||
accomp_wrong = models.BooleanField(blank=False, default=False, verbose_name="Тест пройден/не пройден")
|
|
||||||
link_on_user = models.ForeignKey(DictEmployee, on_delete=models.PROTECT, blank=False, verbose_name="Сотрудник")
|
|
||||||
link_on_test = models.ForeignKey(AppointmentTest,on_delete=models.PROTECT, blank=False, verbose_name="Тест")
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = "Результаты тестирования"
|
verbose_name = "Результат"
|
||||||
verbose_name_plural = "Результаты тестирования"
|
verbose_name_plural = "Результаты"
|
||||||
|
|
||||||
|
|
||||||
|
class Testing(models.Model):
|
||||||
|
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
||||||
|
test = models.ForeignKey(Test, on_delete=models.PROTECT, blank=False, verbose_name="Тест")
|
||||||
|
completion_date = models.DateTimeField(blank=True, null=True, verbose_name="Дата завершения тестирования")
|
||||||
|
test_passed = models.BooleanField(blank=False, verbose_name="Тест пройден")
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
verbose_name = "Тестирование"
|
||||||
|
verbose_name_plural = "Тестирования"
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.link_on_user.fio
|
return self.test.name
|
||||||
@@ -1,42 +1,89 @@
|
|||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
from .models import *
|
from .models import *
|
||||||
|
from userauth.models import *
|
||||||
|
import base64
|
||||||
|
import hashlib
|
||||||
|
from cryptography.fernet import Fernet
|
||||||
|
|
||||||
# Dummy временно
|
class TestAnswerSerializer(serializers.ModelSerializer):
|
||||||
class DummySerializer(serializers.ModelSerializer):
|
class Meta:
|
||||||
|
model = TestAnswer
|
||||||
class Meat:
|
|
||||||
model = Dummy
|
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
|
||||||
|
def encrypt_data(self, data, user_login):
|
||||||
|
key = hashlib.sha256(user_login.encode()).digest()
|
||||||
|
fernet = Fernet(base64.urlsafe_b64encode(key))
|
||||||
|
return fernet.encrypt(data.encode()).decode()
|
||||||
|
|
||||||
class QuestionSearilizer(serializers.ModelSerializer):
|
def decrypt_data(self, encrypted_data, user_login):
|
||||||
|
key = hashlib.sha256(user_login.encode()).digest()
|
||||||
|
fernet = Fernet(base64.urlsafe_b64encode(key))
|
||||||
|
return fernet.decrypt(encrypted_data.encode()).decode()
|
||||||
|
|
||||||
class Meta:
|
def create(self, validated_data):
|
||||||
model = Question
|
user_login = self.context['request'].user.username
|
||||||
fields = ['question_name','name_of_test','description']
|
validated_data['right_wrong'] = self.decrypt_data(str(validated_data['right_wrong']), user_login)
|
||||||
|
return validated_data
|
||||||
class AnswerSerializer(serializers.ModelSerializer):
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
model= Answer
|
|
||||||
fields = '__all__'
|
|
||||||
|
|
||||||
|
|
||||||
class AppointmentTestSerializer(serializers.ModelSerializer):
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
model= AppointmentTest
|
|
||||||
fields = '__all__'
|
|
||||||
|
|
||||||
|
|
||||||
class SavedResultTestSerializer(serializers.ModelSerializer):
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
model = SavedResultTest
|
|
||||||
fields = '__all__'
|
|
||||||
|
|
||||||
class TestSerializer(serializers.ModelSerializer):
|
|
||||||
|
|
||||||
|
def update(self, instance, validated_data):
|
||||||
|
user_login = self.context['request'].user.username
|
||||||
|
validated_data['right_wrong'] = self.decrypt_data(str(validated_data['right_wrong']), user_login)
|
||||||
|
return validated_data
|
||||||
|
|
||||||
|
def to_representation(self, instance):
|
||||||
|
user_login = self.context['request'].user.username
|
||||||
|
representation = super().to_representation(instance)
|
||||||
|
representation['right_wrong'] = self.encrypt_data(str(representation['right_wrong']), user_login)
|
||||||
|
|
||||||
|
return representation
|
||||||
|
|
||||||
|
class TestQuestionSerializer(serializers.ModelSerializer):
|
||||||
|
answers = TestAnswerSerializer(many=True, read_only=True)
|
||||||
|
class Meta:
|
||||||
|
model = TestQuestion
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
class TestSerializer(serializers.ModelSerializer):
|
||||||
|
questions = TestQuestionSerializer(many=True, read_only=True)
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Test
|
model = Test
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
|
||||||
|
def create(self, validated_data):
|
||||||
|
user = self.context['request'].user
|
||||||
|
if user.is_authenticated:
|
||||||
|
validated_data['author'] = user
|
||||||
|
|
||||||
|
return super().create(validated_data)
|
||||||
|
|
||||||
|
class TestingSeriaizer(serializers.ModelSerializer):
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = Testing
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
class TestAttemptSerializer(serializers.ModelSerializer):
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = TestAttempt
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
class TestResultSerializer(serializers.ModelSerializer):
|
||||||
|
attempt = TestAttemptSerializer(read_only=True)
|
||||||
|
answer=serializers.PrimaryKeyRelatedField( queryset=TestAnswer.objects.all(),many=False)
|
||||||
|
comment = serializers.CharField(allow_null=True)
|
||||||
|
class Meta:
|
||||||
|
model = TestResult
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
class TestsSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = Test
|
||||||
|
fields = '__all__'
|
||||||
|
|
||||||
|
def create(self, validated_data):
|
||||||
|
user = self.context['request'].user
|
||||||
|
if user.is_authenticated:
|
||||||
|
validated_data['author'] = user
|
||||||
|
|
||||||
|
return super().create(validated_data)
|
||||||
@@ -3,8 +3,9 @@ from .views import *
|
|||||||
|
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('alltests/', GetAllTests.as_view(), name="getalltests"),
|
path('testdetail/<int:id>/', TestDetail.as_view(),name='TestDetail'),
|
||||||
path('appointmentusers/', GetAppointmentsUsers.as_view(), name="getappointmentusers"),
|
path('gettests/', GetTests.as_view(), name="GetTests"),
|
||||||
path('accomplished/', GetAccompishedTests.as_view(), name="getaccomplished"),
|
path('gettesting/', GetTesting.as_view(), name="GetTesting"),
|
||||||
|
path('testresultcreate/', TestResultCreate.as_view(), name="TestResultCreate"),
|
||||||
]
|
]
|
||||||
|
|
||||||
+171
-27
@@ -1,39 +1,183 @@
|
|||||||
from django.views.decorators.http import require_GET
|
|
||||||
from rest_framework.views import APIView
|
from rest_framework.views import APIView
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
|
from django.db.models import Count
|
||||||
|
from django.db.models import Q
|
||||||
from .models import *
|
from .models import *
|
||||||
|
from userauth.models import *
|
||||||
from .serializers import *
|
from .serializers import *
|
||||||
from .pagination import *
|
from datetime import datetime
|
||||||
|
from rest_framework import generics
|
||||||
|
from navigation.models import News
|
||||||
|
import json
|
||||||
|
from collections import defaultdict
|
||||||
|
import os
|
||||||
|
from django.conf import settings
|
||||||
|
from django.urls import reverse
|
||||||
|
import html
|
||||||
|
from rest_framework.permissions import IsAuthenticated
|
||||||
|
import base64
|
||||||
|
import hashlib
|
||||||
|
from cryptography.fernet import Fernet
|
||||||
|
from django.db.models import F
|
||||||
|
|
||||||
# Create your views here.
|
class GetTests(generics.ListAPIView):
|
||||||
|
queryset = Test.objects.all()
|
||||||
|
serializer_class = TestsSerializer
|
||||||
|
|
||||||
|
def get (self, request, *args, **kwargs):
|
||||||
|
user = request.user
|
||||||
|
# user = User.objects.get(username='9966-00-125')
|
||||||
|
status = request.query_params.get('status')
|
||||||
|
tests = self.get_tests_by_status(status, datetime.now(), user)
|
||||||
|
if status != None:
|
||||||
|
self.set_attemps_number(user, tests)
|
||||||
|
serialized_tests = self.get_serializer(tests, many=True).data
|
||||||
|
|
||||||
class GetAllTests(APIView):
|
return Response(serialized_tests)
|
||||||
|
|
||||||
|
def get_tests_by_status(self, status, now, user):
|
||||||
|
print(status)
|
||||||
|
if status is None:
|
||||||
|
return Test.objects.all().order_by('dateend')
|
||||||
|
|
||||||
|
status_filters = {
|
||||||
|
'active' : Test.objects.filter(
|
||||||
|
testing__user=user,
|
||||||
|
testing__completion_date__gte=now
|
||||||
|
).distinct(),
|
||||||
|
|
||||||
|
'completed' : Test.objects.filter(
|
||||||
|
testing__user=user,
|
||||||
|
testing__completion_date__lt=now
|
||||||
|
).distinct()
|
||||||
|
}
|
||||||
|
|
||||||
|
return status_filters.get(status, Test.objects.none()).order_by('dateend')
|
||||||
|
|
||||||
|
def set_attemps_number(self, user, tests):
|
||||||
|
for test in tests:
|
||||||
|
test.attemps_number = get_attempt_count(user=user, test=test)
|
||||||
|
|
||||||
|
class TestDetail(generics.RetrieveUpdateDestroyAPIView):
|
||||||
|
queryset = Test.objects.all()
|
||||||
|
serializer_class = TestSerializer
|
||||||
|
lookup_url_kwarg = 'id'
|
||||||
|
lookup_field = 'id'
|
||||||
|
|
||||||
|
def get(self, request, *args, **kwargs):
|
||||||
|
test = self.get_object()
|
||||||
|
number_of_questions = test.question_count
|
||||||
|
random_questions = test.questions.order_by('?')[:number_of_questions]
|
||||||
|
test_serialized = TestSerializer(test).data
|
||||||
|
test_serialized['questions'] = TestQuestionSerializer(random_questions, many=True).data
|
||||||
|
|
||||||
|
return Response(test_serialized)
|
||||||
|
|
||||||
|
# class TestListCreate(generics.ListCreateAPIView):
|
||||||
|
# queryset = Test.objects.all()
|
||||||
|
# serializer_class = TestSerializer
|
||||||
|
|
||||||
|
# def get(self, request):
|
||||||
|
# user = request.user
|
||||||
|
# now = datetime.now()
|
||||||
|
# status = request.query_params.get('status')
|
||||||
|
# tests = self.get_tests_by_status(status, now)
|
||||||
|
# serialized_tests = TestSerializer(tests, many=True).data
|
||||||
|
# questions = TestQuestion.objects.filter(test__in=tests)
|
||||||
|
|
||||||
|
# questions_by_test_id = defaultdict(list)
|
||||||
|
# for question in questions:
|
||||||
|
# questions_by_test_id[question.test.id].append(question)
|
||||||
|
|
||||||
|
# for test in serialized_tests:
|
||||||
|
# test['is_passed'] = self.has_participated(user, test['id'])
|
||||||
|
# related_questions = questions_by_test_id[test['id']]
|
||||||
|
# test['files'] = [question.file.url for question in related_questions if question.file]
|
||||||
|
|
||||||
|
# return Response(serialized_tests)
|
||||||
|
|
||||||
|
# def get_tests_by_status(self, status, now):
|
||||||
|
# print(status)
|
||||||
|
# if status is None:
|
||||||
|
# return Test.objects.all().order_by('dateend')
|
||||||
|
|
||||||
|
# status_filters = {
|
||||||
|
# 'active': Test.objects.filter(dateend__gt=now),
|
||||||
|
# 'completed': Test.objects.filter(dateend__lt=now),
|
||||||
|
# }
|
||||||
|
|
||||||
|
# return status_filters.get(status, Test.objects.none()).order_by('dateend')
|
||||||
|
|
||||||
|
# def has_participated(self, employee, test):
|
||||||
|
# return TestResult.objects.filter(user=employee, answer__question__test=test).exists()
|
||||||
|
|
||||||
|
class GetTesting(APIView):
|
||||||
|
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
queryset = Test.objects.all()
|
user = request.user
|
||||||
paginator = AllTestsPagination()
|
tests = Testing.objects.filter(user=user)
|
||||||
paginated_queryset = paginator.paginate_queryset(queryset,request)
|
test_names = {test.id: test.test.name for test in tests}
|
||||||
serializer = TestSerializer(paginated_queryset, many=True)
|
serializer = TestingSeriaizer(tests, many=True).data
|
||||||
return paginator.get_paginated_response(serializer.data)
|
for test in serializer:
|
||||||
|
if test['id'] in test_names:
|
||||||
|
test['test_name'] = test_names[test['id']]
|
||||||
|
return Response(serializer)
|
||||||
|
|
||||||
|
class TestResultCreate(generics.ListCreateAPIView):
|
||||||
|
|
||||||
|
queryset = TestResult.objects.all()
|
||||||
|
serializer_class = TestResultSerializer
|
||||||
|
|
||||||
# Количество страниц передавать с фронта
|
def post(self, request, *args, **kwargs):
|
||||||
class GetAppointmentsUsers(APIView):
|
user = request.user
|
||||||
def get(self, request):
|
# user = User.objects.get(username = "9966-00-125")
|
||||||
id_user = request.GET.get('id')
|
|
||||||
queryset = SavedResultTest.objects.filter(link_on_user=id_user)
|
test_info = self.get_test_info(request)
|
||||||
paginator = AppointmentUserPagination()
|
test_attempt = self.create_test_attempt(user, test_info)
|
||||||
paginated_queryset = paginator.paginate_queryset(queryset, request)
|
|
||||||
serializer = SavedResultTestSerializer(paginated_queryset, many=True)
|
|
||||||
return paginator.get_paginated_response(serializer.data)
|
|
||||||
|
|
||||||
# Количество страниц передавать с фронта
|
serializer = self.get_serializer(data=request.data, many=True)
|
||||||
class GetAccompishedTests(APIView):
|
if serializer.is_valid():
|
||||||
def get(self, request):
|
serializer.save(attempt=test_attempt)
|
||||||
id_user = request.GET.get('id')
|
self.update_testing(user, test_info)
|
||||||
queryset = SavedResultTest.objects.filter(link_on_user=id_user,accomp_wrong=True)
|
|
||||||
paginator = AccomplishedPagination()
|
return Response(test_info['is_passed'])
|
||||||
paginated_queryset = paginator.paginate_queryset(queryset, request)
|
|
||||||
serializer = SavedResultTestSerializer(paginated_queryset, many=True)
|
def create_test_attempt(self, user, test_info):
|
||||||
return paginator.get_paginated_response(serializer.data)
|
test = test_info['test']
|
||||||
|
score = test_info['score']
|
||||||
|
attempt_count = get_attempt_count(user=user, test=test)+ 1
|
||||||
|
test_attempt = TestAttempt.objects.create(user=user, test=test , score=score , attempt_number=attempt_count , completion_date= datetime.now())
|
||||||
|
return test_attempt
|
||||||
|
|
||||||
|
def update_testing(self, user, test_info):
|
||||||
|
test = test_info['test']
|
||||||
|
test_passed = test_info['is_passed']
|
||||||
|
Testing.objects.update_or_create(user=user, test=test, defaults = {"completion_date": test.dateend,"test_passed":test_passed})
|
||||||
|
|
||||||
|
def get_test_info(self, request):
|
||||||
|
|
||||||
|
answer_ids = [item['answer'] for item in request.data]
|
||||||
|
test_answers = TestAnswer.objects.filter(id__in=answer_ids)
|
||||||
|
test = test_answers[0].question.test
|
||||||
|
|
||||||
|
correct_questions = sum(
|
||||||
|
TestAnswer.objects.filter(
|
||||||
|
question=question, id__in=test_answers, right_wrong=True
|
||||||
|
).count() == TestAnswer.objects.filter(
|
||||||
|
question=question, right_wrong=True
|
||||||
|
).count() and TestAnswer.objects.filter(
|
||||||
|
question=question, id__in=test_answers, right_wrong=False
|
||||||
|
).count() == 0
|
||||||
|
for question in set(test_answers.values_list('question', flat=True))
|
||||||
|
)
|
||||||
|
|
||||||
|
pass_perc = test_answers[0].question.test.pass_perc
|
||||||
|
result = {
|
||||||
|
"is_passed": correct_questions >= pass_perc,
|
||||||
|
"score": correct_questions,
|
||||||
|
"test": test
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
|
||||||
|
def get_attempt_count(user, test):
|
||||||
|
return TestAttempt.objects.filter(user=user, test=test).count()
|
||||||
@@ -155,3 +155,11 @@ class Table14(models.Model):
|
|||||||
class Meta:
|
class Meta:
|
||||||
managed = False
|
managed = False
|
||||||
db_table = 'table 14'
|
db_table = 'table 14'
|
||||||
|
|
||||||
|
class EmployeeDepartment(models.Model):
|
||||||
|
employee = models.OneToOneField(DictEmployee, on_delete=models.CASCADE, related_name='real_department')
|
||||||
|
department = models.ForeignKey(DictDepartment, on_delete=models.CASCADE)
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
verbose_name = "Сотрудник и его реальный отдел"
|
||||||
|
verbose_name_plural = "Сотрудники и их реальные отделы"
|
||||||
@@ -21,7 +21,7 @@ class Vote(models.Model):
|
|||||||
class Question(models.Model):
|
class Question(models.Model):
|
||||||
name = models.CharField(max_length=255)
|
name = models.CharField(max_length=255)
|
||||||
vote = models.ForeignKey(Vote, related_name='questions', on_delete=models.CASCADE)
|
vote = models.ForeignKey(Vote, related_name='questions', on_delete=models.CASCADE)
|
||||||
file = models.ImageField(upload_to='question_images/', null=True, blank=True)
|
file = models.ImageField(upload_to='vote/question_images/', null=True, blank=True)
|
||||||
numb = models.PositiveIntegerField()
|
numb = models.PositiveIntegerField()
|
||||||
settings = models.JSONField(default=dict, verbose_name='Json настроек голосования')
|
settings = models.JSONField(default=dict, verbose_name='Json настроек голосования')
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ class Question(models.Model):
|
|||||||
|
|
||||||
class Answer(models.Model):
|
class Answer(models.Model):
|
||||||
name = models.CharField(max_length=255)
|
name = models.CharField(max_length=255)
|
||||||
file = models.FileField(upload_to='answer_files/', null=True, blank=True)
|
file = models.FileField(upload_to='vote/answer_files/', null=True, blank=True)
|
||||||
question = models.ForeignKey(Question, related_name='answers', on_delete=models.CASCADE)
|
question = models.ForeignKey(Question, related_name='answers', on_delete=models.CASCADE)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ class ResultSerializer(serializers.ModelSerializer):
|
|||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
|
||||||
class DictEmployeeSerializer(serializers.ModelSerializer):
|
class DictEmployeeSerializer(serializers.ModelSerializer):
|
||||||
|
order_position = serializers.IntegerField(source = 'id_dict_position.order_position', read_only=True)
|
||||||
class Meta:
|
class Meta:
|
||||||
model = DictEmployee
|
model = DictEmployee
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
|||||||
+32
-17
@@ -14,6 +14,7 @@ import os
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
import html
|
import html
|
||||||
|
from datetime import datetime, timezone
|
||||||
|
|
||||||
class GetVotes(APIView):
|
class GetVotes(APIView):
|
||||||
|
|
||||||
@@ -65,6 +66,8 @@ class VoteDetail(generics.RetrieveUpdateDestroyAPIView):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
vote = Vote.objects.get(id=kwargs['id'])
|
vote = Vote.objects.get(id=kwargs['id'])
|
||||||
|
if vote.dateend < datetime.now(timezone.utc):
|
||||||
|
return Response({'status': 'error', 'message': 'Voting is over'}, status=400)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return Response({'status': 'error', 'message': str(e)}, status=400)
|
return Response({'status': 'error', 'message': str(e)}, status=400)
|
||||||
|
|
||||||
@@ -74,8 +77,8 @@ class VoteDetail(generics.RetrieveUpdateDestroyAPIView):
|
|||||||
question_ids = [item['question'] for item in answers_employee]
|
question_ids = [item['question'] for item in answers_employee]
|
||||||
|
|
||||||
if answers_employee:
|
if answers_employee:
|
||||||
employees = DictEmployee.objects.filter(id__in=answers_names)
|
employees_serializer = get_employees_serializer(answers_names)
|
||||||
employee_dict = {employee['id']: employee for employee in DictEmployeeSerializer(employees, many=True).data}
|
employee_dict = {employee['id']: employee for employee in employees_serializer}
|
||||||
|
|
||||||
serialized_data = self.retrieve(request, *args, **kwargs).data
|
serialized_data = self.retrieve(request, *args, **kwargs).data
|
||||||
|
|
||||||
@@ -155,6 +158,7 @@ def make_clickable(text, url):
|
|||||||
class GetDictEmployee(APIView):
|
class GetDictEmployee(APIView):
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
employees = DictEmployee.objects.filter(deleted=0)
|
employees = DictEmployee.objects.filter(deleted=0)
|
||||||
|
set_real_departments(employees)
|
||||||
employees_serializer = DictEmployeeSerializer(employees, many=True).data
|
employees_serializer = DictEmployeeSerializer(employees, many=True).data
|
||||||
return Response(employees_serializer)
|
return Response(employees_serializer)
|
||||||
|
|
||||||
@@ -178,8 +182,8 @@ class GetResults(APIView):
|
|||||||
|
|
||||||
employee_dict = {}
|
employee_dict = {}
|
||||||
if answers_employee:
|
if answers_employee:
|
||||||
employees = DictEmployee.objects.filter(id__in=answers_names)
|
employees_serializer = get_employees_serializer(answers_names)
|
||||||
employee_dict = {employee['id']: employee for employee in DictEmployeeSerializer(employees, many=True).data}
|
employee_dict = {employee['id']: employee for employee in employees_serializer}
|
||||||
|
|
||||||
results = Result.objects.filter(
|
results = Result.objects.filter(
|
||||||
answer__question__vote=vote
|
answer__question__vote=vote
|
||||||
@@ -197,21 +201,32 @@ class GetResults(APIView):
|
|||||||
users = Result.objects.filter(answer__question__vote=vote).values('user_id')
|
users = Result.objects.filter(answer__question__vote=vote).values('user_id')
|
||||||
users = User.objects.filter(created_at__lt=vote.dateend).exclude(id__in=users)
|
users = User.objects.filter(created_at__lt=vote.dateend).exclude(id__in=users)
|
||||||
employee_ids = users.values_list('user_id', flat=True)
|
employee_ids = users.values_list('user_id', flat=True)
|
||||||
employees = DictEmployee.objects.filter(id__in=employee_ids)
|
serialized_data['nonvoting'] = get_employees_serializer(employee_ids)
|
||||||
serialized_data['nonvoting'] = DictEmployeeSerializer(employees, many=True).data
|
|
||||||
|
|
||||||
return Response(serialized_data)
|
return Response(serialized_data)
|
||||||
|
|
||||||
from rest_framework.views import exception_handler
|
class VoteResultCreate(generics.ListCreateAPIView):
|
||||||
class VoteResultCreate(APIView):
|
queryset = Result.objects.all()
|
||||||
|
serializer_class = ResultSerializer
|
||||||
|
|
||||||
def post(self, request):
|
def create(self, request, *args, **kwargs):
|
||||||
user_id = request.user.id
|
serializer = self.get_serializer(data=request.data, many=True)
|
||||||
answer_ids = [item['answer'] for item in request.data]
|
if serializer.is_valid():
|
||||||
answers = Answer.objects.in_bulk(answer_ids)
|
serializer.save()
|
||||||
vote = list(answers.values())[0].question.vote
|
|
||||||
results = Result.objects.bulk_create(
|
|
||||||
[Result(answer=answers[answer_id], user_id=user_id) for answer_id in answer_ids]
|
|
||||||
)
|
|
||||||
serializer = ResultSerializer(results, many=True)
|
|
||||||
return Response(serializer.data)
|
return Response(serializer.data)
|
||||||
|
|
||||||
|
def get_employees_serializer(ids):
|
||||||
|
employees = DictEmployee.objects.filter(id__in=ids)
|
||||||
|
set_real_departments(employees)
|
||||||
|
employees_serializer = DictEmployeeSerializer(employees, many=True).data
|
||||||
|
return employees_serializer
|
||||||
|
|
||||||
|
def set_real_departments(employees):
|
||||||
|
employee_departments = EmployeeDepartment.objects.filter(employee__in=employees)
|
||||||
|
departments = DictDepartment.objects.in_bulk([ed.department.id for ed in employee_departments])
|
||||||
|
department_map = {ed.employee.id: {'name': ed.department.name, 'id': departments[ed.department.id]} for ed in employee_departments}
|
||||||
|
|
||||||
|
for employee in employees:
|
||||||
|
if employee.id in department_map:
|
||||||
|
employee.department = department_map[employee.id]['name']
|
||||||
|
employee.id_dict_department = department_map[employee.id]['id']
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"target": "es5",
|
|
||||||
"module": "esnext",
|
|
||||||
"baseUrl": "./",
|
|
||||||
"moduleResolution": "node",
|
|
||||||
"paths": {
|
|
||||||
"@/*": [
|
|
||||||
"src/*"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"lib": [
|
|
||||||
"esnext",
|
|
||||||
"dom",
|
|
||||||
"dom.iterable",
|
|
||||||
"scripthost"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Generated
+3019
-21123
File diff suppressed because it is too large.
Load diff
+26
-48
@@ -1,72 +1,50 @@
|
|||||||
{
|
{
|
||||||
"name": "front",
|
"name": "front",
|
||||||
"version": "0.0.83",
|
"version": "0.0.84",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"lint": "eslint . --fix --ignore-path .gitignore",
|
"lint": "eslint . --fix --ignore-path .gitignore",
|
||||||
"storybook": "storybook dev -p 6006",
|
"docs": "vuepress build docs"
|
||||||
"build-storybook": "storybook build"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"-": "^0.0.1",
|
"@ckeditor/ckeditor5-build-classic": "^44.1.0",
|
||||||
"@ckeditor/ckeditor5-build-classic": "^41.4.2",
|
"@ckeditor/ckeditor5-dev-translations": "^43.0.1",
|
||||||
"@ckeditor/ckeditor5-dev-translations": "^40.0.0",
|
"@ckeditor/ckeditor5-vue": "^7.3.0",
|
||||||
"@ckeditor/ckeditor5-vue": "^5.1.0",
|
"@mdi/font": "7.4.47",
|
||||||
"@mdi/font": "7.0.96",
|
|
||||||
"@vue-flow/background": "^1.3.0",
|
|
||||||
"@vue-flow/controls": "^1.1.1",
|
|
||||||
"@vue-flow/core": "^1.33.5",
|
|
||||||
"@vue-flow/minimap": "^1.4.0",
|
|
||||||
"@vue-flow/node-resizer": "^1.3.6",
|
|
||||||
"@vuelidate/core": "^2.0.3",
|
"@vuelidate/core": "^2.0.3",
|
||||||
"@vuelidate/validators": "^2.0.3",
|
"@vuelidate/validators": "^2.0.4",
|
||||||
"adapter": "^1.0.0-beta.10",
|
"adapter": "^1.0.0-beta.10",
|
||||||
"axios": "^1.4.0",
|
"axios": "^1.7.9",
|
||||||
"chart.js": "^4.4.1",
|
"chart.js": "^4.4.7",
|
||||||
"chartjs": "^0.3.24",
|
|
||||||
"chartjs-adapter-moment": "^1.0.1",
|
"chartjs-adapter-moment": "^1.0.1",
|
||||||
"chartjs-plugin-datalabels": "^2.2.0",
|
"chartjs-plugin-datalabels": "^2.2.0",
|
||||||
"date-fns": "^2.30.0",
|
"date-fns": "^4.1.0",
|
||||||
"express-vue": "^5.12.0",
|
|
||||||
"file-saver": "^2.0.5",
|
"file-saver": "^2.0.5",
|
||||||
"ical.js": "^2.0.0",
|
"ical.js": "^2.1.0",
|
||||||
"moment": "^2.30.1",
|
"moment": "^2.30.1",
|
||||||
"pinia": "^2.0.23",
|
"pinia": "^2.3.1",
|
||||||
"roboto-fontface": "*",
|
|
||||||
"rrule": "^2.8.1",
|
"rrule": "^2.8.1",
|
||||||
"v-tooltip": "^2.1.3",
|
"vue": "^3.5.13",
|
||||||
"vee-validate": "^4.12.8",
|
"vue-cal": "^4.10.2",
|
||||||
"vue": "^3.2.0",
|
"vue-chartjs": "^5.3.2",
|
||||||
"vue-cal": "^4.8.1",
|
|
||||||
"vue-chartjs": "^5.3.0",
|
|
||||||
"vue-jwt-decode": "^0.1.0",
|
"vue-jwt-decode": "^0.1.0",
|
||||||
"vue-pdf-embed": "^2.0.3",
|
"vue-pdf-embed": "^2.1.2",
|
||||||
"vue-router": "^4.0.0",
|
"vue-router": "^4.5.0",
|
||||||
"vue3-autocounter": "^1.0.6",
|
"vue3-autocounter": "^1.0.8",
|
||||||
"vuelidate": "^0.7.7",
|
"vuelidate": "^0.7.7",
|
||||||
"vuetify": "^3.6.11",
|
"vuetify": "^3.7.8",
|
||||||
"webfontloader": "^1.0.0",
|
"webfontloader": "^1.6.28"
|
||||||
"yup": "^1.4.0"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@storybook/addon-essentials": "^7.4.6",
|
"@vitejs/plugin-vue": "^5.2.1",
|
||||||
"@storybook/addon-interactions": "^7.4.6",
|
|
||||||
"@storybook/addon-links": "^7.4.6",
|
|
||||||
"@storybook/blocks": "^7.4.6",
|
|
||||||
"@storybook/testing-library": "^0.2.2",
|
|
||||||
"@storybook/vue3": "^7.4.6",
|
|
||||||
"@storybook/vue3-vite": "^7.4.6",
|
|
||||||
"@vitejs/plugin-vue": "^4.0.0",
|
|
||||||
"@vue-leaflet/vue-leaflet": "^0.10.1",
|
"@vue-leaflet/vue-leaflet": "^0.10.1",
|
||||||
"eslint": "^8.22.0",
|
"eslint": "^9.19.0",
|
||||||
"eslint-plugin-storybook": "^0.6.14",
|
"eslint-plugin-vue": "^9.32.0",
|
||||||
"eslint-plugin-vue": "^9.3.0",
|
|
||||||
"leaflet": "^1.9.4",
|
"leaflet": "^1.9.4",
|
||||||
"react": "^18.2.0",
|
"sass-embedded": "^1.83.4",
|
||||||
"react-dom": "^18.2.0",
|
"vite": "^6.0.11",
|
||||||
"vite": "^4.2.0",
|
"vite-plugin-vuetify": "^2.0.4"
|
||||||
"vite-plugin-vuetify": "^1.0.0"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 16 KiB |
+12
-10
@@ -1,17 +1,18 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-card
|
<v-card
|
||||||
class="rounded-0 h-100 flex-column d-flex"
|
class="rounded-0 h-100 flex-column d-flex"
|
||||||
min-height="410"
|
min-height="400"
|
||||||
max-height="410"
|
max-height="400"
|
||||||
|
|
||||||
>
|
>
|
||||||
<v-card-title class="pb-1">
|
<v-card-title class="">
|
||||||
{{news.title}}
|
{{news.title}}
|
||||||
</v-card-title>
|
</v-card-title>
|
||||||
<v-row class="flex-grow-0">
|
<v-row class="flex-grow-0">
|
||||||
<v-col class="d-flex flex-column ">
|
<v-col class="d-flex flex-column ">
|
||||||
<v-img
|
<v-img
|
||||||
:src="`${burl}${news.link}`"
|
:src="`${burl}${news.link}`"
|
||||||
height="175px"
|
height="170px"
|
||||||
width="92%"
|
width="92%"
|
||||||
class="mx-auto"
|
class="mx-auto"
|
||||||
cover
|
cover
|
||||||
@@ -20,7 +21,7 @@
|
|||||||
|
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
<v-divider/>
|
|
||||||
<v-row class="ma-0 flex-grow-0">
|
<v-row class="ma-0 flex-grow-0">
|
||||||
<v-col
|
<v-col
|
||||||
class="py-1 pl-4"
|
class="py-1 pl-4"
|
||||||
@@ -84,7 +85,7 @@
|
|||||||
|
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
<v-divider/>
|
<v-divider class="mx-4"/>
|
||||||
<v-row class="ma-0 overflow-auto">
|
<v-row class="ma-0 overflow-auto">
|
||||||
<v-col
|
<v-col
|
||||||
class="py-0"
|
class="py-0"
|
||||||
@@ -97,14 +98,15 @@
|
|||||||
</v-card-text>
|
</v-card-text>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
<v-divider/>
|
<v-divider class="mx-4"/>
|
||||||
<v-row class="flex-grow-0 ma-0">
|
<v-row class="flex-grow-0 ma-0">
|
||||||
<v-col class="d-flex justify-space-between">
|
<v-col class="d-flex justify-space-between">
|
||||||
<v-btn
|
<v-btn
|
||||||
color="more_details_btn"
|
color="more_details_btn"
|
||||||
variant="text"
|
|
||||||
:to='`/newsfull?id=${news.id}`'
|
:to='`/newsfull?id=${news.id}`'
|
||||||
size="small"
|
size="small"
|
||||||
|
rounded="xl"
|
||||||
append-icon="mdi-step-forward-2"
|
append-icon="mdi-step-forward-2"
|
||||||
>
|
>
|
||||||
Подробнее
|
Подробнее
|
||||||
@@ -130,7 +132,7 @@ const accountStore = useAccountStore()
|
|||||||
export default {
|
export default {
|
||||||
|
|
||||||
components: { icoUser },
|
components: { icoUser },
|
||||||
|
name:'NewsCard',
|
||||||
props: {
|
props: {
|
||||||
news: {
|
news: {
|
||||||
type: Object,
|
type: Object,
|
||||||
@@ -41,6 +41,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { declOfNum } from '@/utils/universal_functions'
|
||||||
import { computed, ref } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -66,11 +67,6 @@ export default {
|
|||||||
const hours = computed(() => minutes.value * 60);
|
const hours = computed(() => minutes.value * 60);
|
||||||
const days = computed(() => hours.value * 24);
|
const days = computed(() => hours.value * 24);
|
||||||
|
|
||||||
function declOfNum(value, titles) {
|
|
||||||
const cases = [2, 0, 1, 1, 1, 2];
|
|
||||||
return titles[(value % 100 > 4 && value % 100 < 20) ? 2 : cases[(value % 10 < 5) ? value % 10 : 5]];
|
|
||||||
}
|
|
||||||
|
|
||||||
const disabledcard = ref({
|
const disabledcard = ref({
|
||||||
text: 'окончания',
|
text: 'окончания',
|
||||||
disabled: false
|
disabled: false
|
||||||
|
|||||||
@@ -65,8 +65,8 @@
|
|||||||
<v-divider/>
|
<v-divider/>
|
||||||
<v-card-actions class="align-self-end py-0">
|
<v-card-actions class="align-self-end py-0">
|
||||||
<v-btn
|
<v-btn
|
||||||
color="modal_btn"
|
rounded="xl"
|
||||||
variant="text"
|
color="more_details_btn"
|
||||||
@click= "$emit('update:opendialog', false)"
|
@click= "$emit('update:opendialog', false)"
|
||||||
>
|
>
|
||||||
Закрыть
|
Закрыть
|
||||||
|
|||||||
@@ -121,11 +121,11 @@
|
|||||||
import { formatComa } from "@/utils/universal_functions";
|
import { formatComa } from "@/utils/universal_functions";
|
||||||
import { ref } from "vue";
|
import { ref } from "vue";
|
||||||
import { axiosApiInstance } from "@/utils/axios-api";
|
import { axiosApiInstance } from "@/utils/axios-api";
|
||||||
import CKEditor from "@ckeditor/ckeditor5-vue";
|
// import CKEditor from "@ckeditor/ckeditor5-vue";
|
||||||
import ClassicEditor from "@ckeditor/ckeditor5-build-classic";
|
// import ClassicEditor from "@ckeditor/ckeditor5-build-classic";
|
||||||
import "@ckeditor/ckeditor5-build-classic/build/translations/ru";
|
// import "@ckeditor/ckeditor5-build-classic/build/translations/ru";
|
||||||
import EventDialogEditParticipant from "./event-dialog-edit-participant.vue";
|
// import EventDialogEditParticipant from "./event-dialog-edit-participant.vue";
|
||||||
import eventDialogEdit from "@/components/calendar_of_events/event-dialog-edit.vue";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
@@ -136,8 +136,8 @@ export default {
|
|||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
// Use the <ckeditor> component in this view.
|
// Use the <ckeditor> component in this view.
|
||||||
ckeditor: CKEditor.component,
|
// ckeditor: CKEditor.component,
|
||||||
EventDialogEditParticipant,
|
// EventDialogEditParticipant,
|
||||||
},
|
},
|
||||||
|
|
||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
<v-spacer/>
|
<v-spacer/>
|
||||||
<v-btn
|
<v-btn
|
||||||
color="modal_btn"
|
color="modal_btn"
|
||||||
variant="text"
|
rounded="xl"
|
||||||
text="Закрыть"
|
text="Закрыть"
|
||||||
@click="menusCloses"
|
@click="menusCloses"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,18 +1,21 @@
|
|||||||
<template>
|
<template>
|
||||||
|
{{ interval }}
|
||||||
<v-carousel
|
<v-carousel
|
||||||
cycle
|
v-model="currentslide"
|
||||||
interval="10000"
|
:interval="interval"
|
||||||
cover
|
cover
|
||||||
|
cycle
|
||||||
height="450"
|
height="450"
|
||||||
hide-delimiters
|
hide-delimiters
|
||||||
hide-delimiter-background
|
hide-delimiter-background
|
||||||
:show-arrows="carous.length<2?false:'hover'"
|
:show-arrows="carous.length<2?false:'hover'"
|
||||||
color="white"
|
color="white"
|
||||||
|
@update:modelValue="slidechanged"
|
||||||
>
|
>
|
||||||
|
|
||||||
<v-carousel-item
|
<template v-for="(x, i) in carous" :key="i">
|
||||||
v-for="(x, i) in carous"
|
<v-carousel-item
|
||||||
:key="i"
|
v-if="!x.link.endsWith('mp4')"
|
||||||
:src="`${burl}${x.link}`"
|
:src="`${burl}${x.link}`"
|
||||||
cover
|
cover
|
||||||
eager
|
eager
|
||||||
@@ -67,19 +70,42 @@
|
|||||||
</v-card>
|
</v-card>
|
||||||
</v-container>
|
</v-container>
|
||||||
</v-carousel-item>
|
</v-carousel-item>
|
||||||
|
<v-carousel-item v-else >
|
||||||
|
|
||||||
|
<div class="d-flex justify-center">
|
||||||
|
<video
|
||||||
|
ref="videoElement"
|
||||||
|
style="height: 450px"
|
||||||
|
|
||||||
|
controls
|
||||||
|
autoplay
|
||||||
|
preload="metadata"
|
||||||
|
@ended="ended"
|
||||||
|
@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>
|
</v-carousel>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { ref } from "vue";
|
import { ref, computed } from "vue";
|
||||||
import { baseURL } from "@/utils/axios-api";
|
import { baseURL } from "@/utils/axios-api";
|
||||||
import { axiosApiInstance } from "@/utils/axios-api";
|
import { axiosApiInstance } from "@/utils/axios-api";
|
||||||
import { useAlertStore } from "@/store/useAlertStore";
|
import { useAlertStore } from "@/store/useAlertStore";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
|
const currentslide=ref(0)
|
||||||
const burl = baseURL.slice(0, -1);
|
const burl = baseURL.slice(0, -1);
|
||||||
|
const videoElement=ref(null)
|
||||||
const carous = ref([{ link: `/media/newsimage/scales.jpg`, "title": null, "text": "" }]);
|
const carous = ref([{ link: `/media/newsimage/scales.jpg`, "title": null, "text": "" }]);
|
||||||
const feedalert = useAlertStore().alert;
|
const feedalert = useAlertStore().alert;
|
||||||
|
|
||||||
@@ -92,6 +118,7 @@ export default {
|
|||||||
feedalert.ico = "mdi-alert-outline";
|
feedalert.ico = "mdi-alert-outline";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(result.data);
|
||||||
if (result.data.result.length > 0) {
|
if (result.data.result.length > 0) {
|
||||||
carous.value = result.data.result;
|
carous.value = result.data.result;
|
||||||
}
|
}
|
||||||
@@ -100,10 +127,53 @@ export default {
|
|||||||
};
|
};
|
||||||
|
|
||||||
getfromserver();
|
getfromserver();
|
||||||
|
const interval=ref(10000)
|
||||||
|
|
||||||
|
const slidechanged=()=>{
|
||||||
|
console.log(videoElement.value);
|
||||||
|
|
||||||
|
if (carous.value[currentslide.value].link.endsWith('mp4')){
|
||||||
|
videoElement.value.forEach((e)=>{
|
||||||
|
if(e.currentSrc!=burl+carous.value[currentslide.value].link){
|
||||||
|
e.pause()
|
||||||
|
|
||||||
|
}else{
|
||||||
|
console.log("sdflkhlh");
|
||||||
|
e.play()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if(carous.value[currentslide.value].link.endsWith('mp4')){
|
||||||
|
interval.value = 10000000000
|
||||||
|
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
interval.value=10000
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
const ended = (val)=>{
|
||||||
|
val.target.currentTime = 0
|
||||||
|
val.target.pause();
|
||||||
|
document.exitFullscreen()
|
||||||
|
currentslide.value=currentslide.value<carous.value.length-1?currentslide.value+1:0
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
slidechanged,
|
||||||
|
videoElement,
|
||||||
|
currentslide,
|
||||||
|
interval,
|
||||||
|
// intervalcomp,
|
||||||
burl,
|
burl,
|
||||||
carous,
|
carous,
|
||||||
|
ended
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -42,7 +42,8 @@
|
|||||||
</v-card>
|
</v-card>
|
||||||
<v-divider class="" />
|
<v-divider class="" />
|
||||||
<v-card-actions class="pb-0" style="place-content: end">
|
<v-card-actions class="pb-0" style="place-content: end">
|
||||||
<v-btn color="more_details_btn" variant="text" @click="onSubmit">
|
<v-btn
|
||||||
|
color="more_details_btn" rounded="xl" @click="onSubmit">
|
||||||
Закрыть
|
Закрыть
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-row>
|
<v-row class="py-2">
|
||||||
<v-col class="d-flex flex-column">
|
<v-col class="d-flex flex-column">
|
||||||
<v-row class=" flex-grow-1 pa-1 d-flex h-0 overflow-auto">
|
<v-row class="h-0 overflow-auto">
|
||||||
<v-col
|
<v-col
|
||||||
v-for="(x, key) in newsAll"
|
v-for="(x, key) in newsAll"
|
||||||
:key="key"
|
:key="key"
|
||||||
@@ -11,27 +11,40 @@
|
|||||||
sm=12
|
sm=12
|
||||||
xs=12
|
xs=12
|
||||||
cols=12
|
cols=12
|
||||||
class="d-flex pa-1 flex-column "
|
class="d-flex pa-0 flex-column "
|
||||||
>
|
>
|
||||||
<news-card :news="x"/>
|
<NewsCard :news="x" class="ma-1"/>
|
||||||
|
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
|
|
||||||
<v-row class="flex-grow-0 ">
|
<v-row class="flex-grow-0 ">
|
||||||
<v-col class="pa-0" >
|
<v-col class="pa-0" >
|
||||||
<v-pagination
|
<v-pagination
|
||||||
|
density="compact"
|
||||||
v-model="page"
|
v-model="page"
|
||||||
:length=visiblePage
|
:length="visiblePage"
|
||||||
:total-visible="7"
|
:total-visible="7"
|
||||||
@update:modelValue="loadNewsAll"
|
@update:modelValue="loadNewsAll"
|
||||||
/>
|
>
|
||||||
|
<template v-slot:item="item">
|
||||||
|
|
||||||
|
<v-btn icon density="compact"
|
||||||
|
:color="item.isActive?'more_details_btn':'grey-ligten-3'"
|
||||||
|
@click="pager(item.page)"
|
||||||
|
>{{ item.page }}</v-btn>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
|
||||||
|
</v-pagination>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col class="flex-grow-0 py-0">
|
<v-col class="flex-grow-0 py-0 " >
|
||||||
<v-select
|
<v-select
|
||||||
style="width:53px"
|
style="width:53px"
|
||||||
hide-details
|
hide-details
|
||||||
hide-selected
|
|
||||||
density="compact"
|
density="compact"
|
||||||
|
hide-selected
|
||||||
|
|
||||||
v-model="countpage"
|
v-model="countpage"
|
||||||
rounded
|
rounded
|
||||||
variant="underlined"
|
variant="underlined"
|
||||||
@@ -50,12 +63,12 @@
|
|||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { axiosApiInstance } from '@/utils/axios-api'
|
import { axiosApiInstance } from '@/utils/axios-api'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
import newsCard from './UI/news-card.vue'
|
import NewsCard from './UI/NewsCard.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
newsCard
|
NewsCard
|
||||||
},
|
},
|
||||||
|
|
||||||
setup(){
|
setup(){
|
||||||
@@ -68,21 +81,27 @@ export default {
|
|||||||
const visiblePage = ref(0)
|
const visiblePage = ref(0)
|
||||||
|
|
||||||
const loadNewsAll = () => {
|
const loadNewsAll = () => {
|
||||||
axiosApiInstance.get( `api/navigation/newscrossroad/?name=${route.path}&page=${page.value-1}&countpage=${countpage.value}`).then(result => {
|
|
||||||
|
axiosApiInstance.get( `api/navigation/newscrossroad/?name=${route.path.slice(1)}&page=${page.value-1}&countpage=${countpage.value}`).then(result => {
|
||||||
|
|
||||||
newsAll.value= result.data.result
|
newsAll.value= result.data.result
|
||||||
countetnews.value = result.data.countpage/countpage.value
|
countetnews.value = result.data.countpage/countpage.value
|
||||||
visiblePage.value = countetnews.value <= 1 ? 1 : countetnews.value+1
|
visiblePage.value = countetnews.value <= 1 ? 1 : Math.ceil(countetnews.value)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
loadNewsAll()
|
loadNewsAll()
|
||||||
|
const pager=(val)=>{
|
||||||
|
page.value=Number(val)
|
||||||
|
loadNewsAll()
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
newsAll,
|
newsAll,
|
||||||
|
|
||||||
countetnews,
|
pager,
|
||||||
page,
|
page,
|
||||||
countpage,
|
countpage,
|
||||||
visiblePage,
|
visiblePage,
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-row>
|
<v-row class="">
|
||||||
<v-col class="flex-column d-flex">
|
<v-col class="flex-column d-flex pa-0">
|
||||||
<v-row class="mt-0 h-0 overflow-auto ">
|
<v-row class="mt-0 mx-3 h-0 overflow-auto ">
|
||||||
<v-col
|
<v-col
|
||||||
v-for="(x, key) in newsAll"
|
v-for="(x, key) in newsAll"
|
||||||
:key="key"
|
:key="key"
|
||||||
class="pb-1 pt-0"
|
class="py-1"
|
||||||
lg=12
|
lg=12
|
||||||
md=6
|
md=6
|
||||||
sm=6
|
sm=6
|
||||||
>
|
>
|
||||||
<news-card :news="x"/>
|
<NewsCard :news="x"/>
|
||||||
|
|
||||||
|
|
||||||
<v-dialog
|
<v-dialog
|
||||||
v-model="dialogfotoOne"
|
v-model="dialogfotoOne"
|
||||||
@@ -73,12 +73,12 @@
|
|||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { axiosApiInstance } from '@/utils/axios-api'
|
import { axiosApiInstance } from '@/utils/axios-api'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
import newsCard from './UI/news-card.vue'
|
import NewsCard from './UI/NewsCard.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
newsCard
|
NewsCard
|
||||||
},
|
},
|
||||||
|
|
||||||
setup(){
|
setup(){
|
||||||
|
|||||||
@@ -0,0 +1,148 @@
|
|||||||
|
<!-- Раздел с назначенным тестированием -->
|
||||||
|
<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>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import moment from 'moment';
|
||||||
|
import { declOfNum } from '@/utils/universal_functions'
|
||||||
|
import { baseURL } from "@/utils/axios-api";
|
||||||
|
import { ref, computed } from 'vue';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
title: {
|
||||||
|
type: String,
|
||||||
|
default: 'Не забыть передать тайтл сюда!',
|
||||||
|
},
|
||||||
|
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 searchTest = computed(() => {
|
||||||
|
if (!search.value) return props.testingCard
|
||||||
|
return props.testingCard.filter(item => item.name.toLowerCase().includes(search.value.toLowerCase()))
|
||||||
|
})
|
||||||
|
|
||||||
|
const activeTabIcon = computed(() => {
|
||||||
|
let icons = [
|
||||||
|
// иконки для использования в карточках
|
||||||
|
{
|
||||||
|
icon: 'mdi-calendar-clock',
|
||||||
|
field: 'dateend',
|
||||||
|
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 momenter = (val, field)=>{
|
||||||
|
if (field == 'dateend'){
|
||||||
|
return 'до ' + moment(val).format('DD.MM.YYYY, HH:mm')
|
||||||
|
}
|
||||||
|
else if (field == 'question_count') {
|
||||||
|
return val + declOfNum(val, [' вопрос', ' вопроса', ' вопросов'])
|
||||||
|
}
|
||||||
|
else if (field == 'time') {
|
||||||
|
return val + declOfNum(val, [' минута', ' минуты', ' минут'])
|
||||||
|
}
|
||||||
|
return val
|
||||||
|
}
|
||||||
|
|
||||||
|
return { search, searchTest, momenter, activeTabIcon, baseURL }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<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>
|
||||||
@@ -62,6 +62,7 @@
|
|||||||
:disabled="result[question.id]?.length >= question.settings.multiChoice && !result[question.id]?.includes(answer.id)"
|
:disabled="result[question.id]?.length >= question.settings.multiChoice && !result[question.id]?.includes(answer.id)"
|
||||||
density="compact">
|
density="compact">
|
||||||
{{ answer.employee?.fio || answer.name }}
|
{{ answer.employee?.fio || answer.name }}
|
||||||
|
|
||||||
<template v-slot:prepend="{ isSelected }">
|
<template v-slot:prepend="{ isSelected }">
|
||||||
<v-list-item-action start>
|
<v-list-item-action start>
|
||||||
<v-checkbox-btn :model-value="isSelected"></v-checkbox-btn>
|
<v-checkbox-btn :model-value="isSelected"></v-checkbox-btn>
|
||||||
@@ -148,15 +149,11 @@ import {useAccountStore} from "@/store/AccountStore";
|
|||||||
import {checkremote} from "@/utils/universal_functions";
|
import {checkremote} from "@/utils/universal_functions";
|
||||||
import VoteAnimation from "@/components/vote/VoteAnimation.vue";
|
import VoteAnimation from "@/components/vote/VoteAnimation.vue";
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'CurrentVote',
|
name: 'CurrentVote',
|
||||||
components: {VoteAnimation},
|
components: {VoteAnimation},
|
||||||
methods: {
|
|
||||||
checkremote,
|
|
||||||
spravURL() {
|
|
||||||
return spravURL
|
|
||||||
}
|
|
||||||
},
|
|
||||||
emits: ['closer'],
|
emits: ['closer'],
|
||||||
props: {
|
props: {
|
||||||
data: {
|
data: {
|
||||||
@@ -255,6 +252,8 @@ export default {
|
|||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
spravURL,
|
||||||
|
checkremote,
|
||||||
groupedAnswers,
|
groupedAnswers,
|
||||||
activepick,
|
activepick,
|
||||||
opendialog,
|
opendialog,
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<template>
|
||||||
|
<v-container class="h-100">
|
||||||
|
<v-row justify="center" align="center" class="h-100">
|
||||||
|
<v-card-title class="text-h4 text-grey-lighten-1">{{ current }} голосований сейчас нет</v-card-title>
|
||||||
|
</v-row>
|
||||||
|
</v-container>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
current: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -100,7 +100,7 @@ import Timer from "@/components/UI/Timer.vue"
|
|||||||
import {baseURL} from "@/utils/axios-api";
|
import {baseURL} from "@/utils/axios-api";
|
||||||
import {computed, ref} from 'vue'
|
import {computed, ref} from 'vue'
|
||||||
import {useAccountStore} from "@/store/AccountStore";
|
import {useAccountStore} from "@/store/AccountStore";
|
||||||
import defaultImage from '../../assets/emblem.png'
|
import defaultImage from '@/assets/emblem.png'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {Timer},
|
components: {Timer},
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<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">
|
<template v-if="isVoteCreated">
|
||||||
<v-card class="d-flex flex-column flex-grow-1 flex-shrink-0 text-center pa-8" flat>
|
<v-card class="d-flex flex-column flex-grow-1 flex-shrink-0 text-center pa-8" flat>
|
||||||
<v-spacer></v-spacer>
|
<v-spacer></v-spacer>
|
||||||
@@ -14,10 +14,8 @@
|
|||||||
</v-card>
|
</v-card>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<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 v-model="step" editable class="d-flex flex-column fill-height">
|
|
||||||
<v-stepper-header class="flex-grow-0 flex-shrink-1">
|
<v-stepper-header class="flex-grow-0 flex-shrink-1">
|
||||||
<v-stepper-item :complete="step > 0" step="1">Основная информация
|
<v-stepper-item :complete="step > 0" step="1">Основная информация
|
||||||
|
|
||||||
@@ -30,44 +28,45 @@
|
|||||||
|
|
||||||
<v-stepper-window class="fill-height">
|
<v-stepper-window class="fill-height">
|
||||||
<!-- Основная информация -->
|
<!-- Основная информация -->
|
||||||
<v-stepper-window-item step="1" class="fill-height">
|
<v-stepper-window-item class="fill-height" step="1">
|
||||||
<v-card flat class="fill-height d-flex flex-column ">
|
<v-card class="fill-height d-flex flex-column " flat>
|
||||||
<v-card-title>Основная информация</v-card-title>
|
<v-card-title>Основная информация</v-card-title>
|
||||||
<v-card-text class="d-flex flex-column overflow-auto">
|
<v-card-text class="d-flex flex-column overflow-auto">
|
||||||
<v-text-field v-model="form.title" :rules="[rules.required]" label="Название голосования"
|
<v-text-field v-model="form.title" :rules="[rules.required]" class="flex-grow-0 flex-shrink-1"
|
||||||
class="flex-grow-0 flex-shrink-1"
|
label="Название голосования"
|
||||||
variant="underlined"></v-text-field>
|
variant="underlined"></v-text-field>
|
||||||
<div class="flex-grow-1 flex-shrink-0">
|
<div class="flex-grow-1 flex-shrink-0">
|
||||||
|
|
||||||
<v-textarea v-model="form.description" :rules="[rules.required]" label="Описание"
|
<v-textarea v-model="form.description" :rules="[rules.required]" label="Описание"
|
||||||
|
|
||||||
variant="outlined"></v-textarea>
|
variant="outlined"></v-textarea>
|
||||||
</div>
|
</div>
|
||||||
<v-divider></v-divider>
|
<v-divider></v-divider>
|
||||||
<div class="flex-grow-0 flex-shrink-1">
|
<div class="flex-grow-0 flex-shrink-1">
|
||||||
<div class="pt-2 text-overline text-grey">Дата и время:</div>
|
<div class="pt-2 text-overline text-grey">Дата и время:</div>
|
||||||
<div class="d-flex justify-space-around">
|
<div class="d-flex justify-space-around">
|
||||||
<div class="d-flex ga-3 align-center">
|
<div class="d-flex ga-3 align-center">
|
||||||
<h6 class="text-subtitle-1 pt-2">начало:</h6>
|
<h6 class="text-subtitle-1 pt-2">начало:</h6>
|
||||||
<date-select :datedefault="form.startDate" @returndate="returnstart" />
|
<date-select :datedefault="form.startDate" @returndate="returnstart"/>
|
||||||
<v-select v-model="selectedTimeStart" :items="timeOptions" density="compact" variant="plain"
|
<v-select v-model="selectedTimeStart" :items="timeOptions" density="compact" hide-details
|
||||||
hide-details>
|
variant="plain">
|
||||||
<template v-slot:prepend-inner>
|
<template v-slot:prepend-inner>
|
||||||
<v-icon icon="mdi-timer" size="xsmall" color="red"></v-icon>
|
<v-icon color="red" icon="mdi-timer" size="xsmall"></v-icon>
|
||||||
</template>
|
</template>
|
||||||
</v-select>
|
</v-select>
|
||||||
|
</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">
|
||||||
|
<template v-slot:prepend-inner>
|
||||||
|
<v-icon color="red" icon="mdi-timer" size="xsmall"></v-icon>
|
||||||
|
</template>
|
||||||
|
</v-select>
|
||||||
|
</div>
|
||||||
</div>
|
</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" outlined variant="plain"
|
|
||||||
hide-details>
|
|
||||||
<template v-slot:prepend-inner>
|
|
||||||
<v-icon icon="mdi-timer" size="xsmall" color="red"></v-icon>
|
|
||||||
</template>
|
|
||||||
</v-select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
|
|
||||||
@@ -78,184 +77,187 @@
|
|||||||
</v-stepper-window-item>
|
</v-stepper-window-item>
|
||||||
|
|
||||||
<!-- Создание опроса -->
|
<!-- Создание опроса -->
|
||||||
<v-stepper-window-item step="2" class="fill-height">
|
<v-stepper-window-item class="fill-height" step="2">
|
||||||
|
|
||||||
<v-card flat class="fill-height d-flex flex-column">
|
<v-card class="fill-height d-flex flex-column" flat>
|
||||||
<v-card-title>Создание опроса:</v-card-title>
|
<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">
|
<transition-group name="list" tag="div">
|
||||||
<div v-for="(question, index) in form.questions" :key="index" class="mb-4">
|
<div v-for="(question, index) in form.questions" :key="index" class="mb-4">
|
||||||
<div class="d-flex">
|
<div class="d-flex">
|
||||||
<v-text-field density="comfortable" v-model="question.text" :label="'Вопрос ' + (index + 1)"
|
<!-- <v-text-field v-model="question.text" :label="'Вопрос ' + (index + 1)" :rules="[rules.required]"-->
|
||||||
:rules="[rules.required]" variant="underlined">
|
<!-- density="comfortable" variant="underlined">-->
|
||||||
<template v-slot:append>
|
<v-text-field
|
||||||
<v-btn color="error" icon="mdi-delete" size="small" @click="removeQuestion(index)" />
|
v-model="question.text"
|
||||||
</template>
|
:label="'Вопрос ' + (index + 1)"
|
||||||
|
density="comfortable"
|
||||||
</v-text-field>
|
variant="underlined"
|
||||||
</div>
|
:rules="[rules.required]"
|
||||||
<v-file-input density="comfortable" v-model="question.image" accept="image/*"
|
@input="updateQuest(index)"
|
||||||
label="Картинка для вопроса" variant="outlined"></v-file-input>
|
>
|
||||||
<v-divider></v-divider>
|
<template v-slot:append>
|
||||||
<div class="py-2 text-overline text-grey">Настройки вопроса</div>
|
<v-btn color="error" icon="mdi-delete" size="small" @click="removeQuestion(index)"/>
|
||||||
<div class="v-row ">
|
|
||||||
|
|
||||||
<v-col cols="auto" class="align-self-center font-weight-bold py-0">
|
|
||||||
Тип ответа
|
|
||||||
</v-col>
|
|
||||||
<v-col cols="3" class="py-0 align-self-center ">
|
|
||||||
|
|
||||||
<v-select density="compact" v-model="question.settings.choice" :items="questionTypes"
|
|
||||||
@update:model-value="question.answers=[]"
|
|
||||||
:list-props="{density:'compact'}"
|
|
||||||
item-title="name" item-value="choice" label="" hide-details variant="outlined"></v-select>
|
|
||||||
<!-- choice -->
|
|
||||||
|
|
||||||
</v-col>
|
|
||||||
<v-spacer/>
|
|
||||||
<v-col cols="auto" class="align-self-center font-weight-bold">
|
|
||||||
Число возможных ответов
|
|
||||||
</v-col>
|
|
||||||
<v-col cols="1" class="">
|
|
||||||
<v-text-field density="compact" v-model="question.settings.multiChoice"
|
|
||||||
:rules="[rules.required && question.settings.multiChoice > 0]" hide-details type="number"
|
|
||||||
min="1" variant="outlined">
|
|
||||||
<template v-slot:prepend>
|
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
</v-text-field>
|
</v-text-field>
|
||||||
</v-col>
|
</div>
|
||||||
</div>
|
<v-file-input v-model="question.image" accept="image/*" density="comfortable"
|
||||||
<div class="v-row">
|
label="Картинка для вопроса" variant="outlined"></v-file-input>
|
||||||
</div>
|
<v-divider></v-divider>
|
||||||
|
<div class="py-2 text-overline text-grey">Настройки вопроса</div>
|
||||||
|
<div class="v-row ">
|
||||||
|
|
||||||
<v-card-text class="px-0">
|
<v-col class="align-self-center font-weight-bold py-0" cols="auto">
|
||||||
<div v-if="question.settings.choice === 'free'">
|
Тип ответа
|
||||||
<transition-group name="list" tag="div">
|
</v-col>
|
||||||
<div v-for="(answer, ind) in question.answers" :key="ind" class="d-flex align-start mb-4">
|
<v-col class="py-0 align-self-center " cols="3">
|
||||||
<v-text-field v-model="answer.text" :label="'Ответ ' + (ind + 1)" :rules="[rules.required]"
|
|
||||||
class="mr-4" variant="outlined" density="compact"></v-text-field>
|
|
||||||
<v-file-input v-model="answer.image" accept="image/*" dense hide-details label="Картинка"
|
|
||||||
variant="outlined" density="compact"></v-file-input>
|
|
||||||
<v-btn class="ms-1" color="error" icon="mdi-delete" size="small" @click="removeAnswer(index,ind)">
|
|
||||||
|
|
||||||
</v-btn>
|
<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-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-col>
|
||||||
|
</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">
|
||||||
|
<v-text-field
|
||||||
|
v-model="answer.text"
|
||||||
|
:label="'Ответ ' + (ind + 1)"
|
||||||
|
:rules="[rules.required]"
|
||||||
|
class="mr-4"
|
||||||
|
density="compact"
|
||||||
|
variant="outlined">
|
||||||
|
</v-text-field>
|
||||||
|
<v-file-input
|
||||||
|
v-model="answer.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="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>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-else>
|
||||||
|
<div class="v-row">
|
||||||
|
<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>
|
||||||
|
</template>
|
||||||
|
<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>
|
||||||
|
</v-radio>
|
||||||
|
</v-radio-group>
|
||||||
|
</div>
|
||||||
|
<v-autocomplete
|
||||||
|
v-model="question.selectedEmployees"
|
||||||
|
: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))"
|
||||||
|
>
|
||||||
|
<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>
|
||||||
|
</template>
|
||||||
|
<template #selection="{item}">
|
||||||
|
<v-chip
|
||||||
|
:prepend-avatar="checkremote(`${spravURL}${item.raw.login}.jpg`)"
|
||||||
|
>
|
||||||
|
|
||||||
</transition-group>
|
{{ 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>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<v-list-item
|
||||||
|
|
||||||
<div class="d-flex justify-start">
|
:append-avatar="checkremote(`${spravURL}${data.item.raw.login}.jpg`)"
|
||||||
<v-btn size="small" color="teal-darken-4" @click="addAnswer(index)">Добавить ответ</v-btn>
|
density="compact"
|
||||||
|
slim
|
||||||
|
@click="onEmployeesChange(data.item.raw.id, index)"
|
||||||
|
>
|
||||||
|
<template #prepend>
|
||||||
|
|
||||||
</div>
|
<v-checkbox :model-value="question.selectedEmployees.includes(data.item.raw.id)"
|
||||||
</div>
|
|
||||||
<div v-else>
|
|
||||||
|
|
||||||
<div class="v-row">
|
density="compact"
|
||||||
|
hide-details></v-checkbox>
|
||||||
<v-radio-group class="text-caption" inline v-model="question.settings.onlyDep">
|
|
||||||
<template v-slot:label>
|
|
||||||
<div class="text-body-2 font-weight-bold">Голосование по отделам:</div>
|
|
||||||
</template>
|
</template>
|
||||||
<v-radio v-for="x in onlyDepdict" :key="x.name" :value=x.value>
|
<v-list-item-title class="text-third" v-text="data.item.raw.fio"></v-list-item-title>
|
||||||
<template v-slot:label>
|
</v-list-item>
|
||||||
<div class="text-caption">{{ x.name }}</div>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
</v-radio>
|
</v-autocomplete>
|
||||||
</v-radio-group>
|
<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-col class="py-0" cols="7">
|
||||||
|
<v-chip
|
||||||
|
:prepend-avatar="checkremote(`${spravURL}${findEmployeeById(person.text)?.login}.jpg`)"
|
||||||
|
:text="findEmployeeById(person.text)?.fio ">
|
||||||
|
</v-chip>
|
||||||
|
</v-col>
|
||||||
<v-autocomplete
|
<v-col class="py-0 d-flex" cols="5">
|
||||||
class=" text-no-wrap"
|
<v-file-input v-model="person.image" accept="image/*" dense density="compact"
|
||||||
v-model="question.selectedEmployees" :items="allEmployeesgroupedbydep"
|
hide-details
|
||||||
item-title="fio" item-value="id" label="Выберите сотрудников" multiple variant="outlined"
|
label="Картинка" variant="outlined"></v-file-input>
|
||||||
density="compact"
|
<v-btn class="ms-1" color="error" icon="mdi-delete" size="small"
|
||||||
@update:model-value="(selected)=>question.answers=question.answers.filter(e=>selected.includes(e.text))"
|
@click="question.selectedEmployees.splice(ind,1); removeAnswer(index,ind)">
|
||||||
>
|
</v-btn>
|
||||||
<template #prepend-item>
|
</v-col>
|
||||||
<v-checkbox class="pa-0" :model-value="question.selectedEmployees.length==allEmployees.length" label="Все"
|
</div>
|
||||||
@update:model-value="handleSelectAll(question.selectedEmployees.length==allEmployees.length, index)"></v-checkbox>
|
</transition-group>
|
||||||
</template>
|
|
||||||
<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>
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
<v-list-item
|
|
||||||
|
|
||||||
slim
|
|
||||||
density="compact"
|
|
||||||
:append-avatar="checkremote(`${spravURL}${data.item.raw.login}.jpg`)"
|
|
||||||
@click="onEmployeesChange(data.item.raw.id, index)"
|
|
||||||
>
|
|
||||||
<template #prepend>
|
|
||||||
|
|
||||||
<v-checkbox hide-details
|
|
||||||
|
|
||||||
:model-value="question.selectedEmployees.includes(data.item.raw.id)"
|
|
||||||
density="compact"></v-checkbox>
|
|
||||||
</template>
|
|
||||||
<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">
|
|
||||||
<v-col cols="7" class="py-0" >
|
|
||||||
|
|
||||||
<v-chip :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 hide-details label="Картинка"
|
|
||||||
variant="outlined" density="compact"></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>
|
</div>
|
||||||
</transition-group>
|
</v-card-text>
|
||||||
</div>
|
</div>
|
||||||
</v-card-text>
|
</transition-group>
|
||||||
</div>
|
|
||||||
</transition-group>
|
|
||||||
<v-divider class="ma-2 pa-1"></v-divider>
|
<v-divider class="ma-2 pa-1"></v-divider>
|
||||||
<div class="d-flex justify-center">
|
<div class="d-flex justify-center">
|
||||||
|
<v-btn color="orange-darken-4" size="small" @click="addQuestion">Добавить вопрос</v-btn>
|
||||||
<v-btn size="small" color="orange-darken-4" @click="addQuestion">Добавить вопрос</v-btn>
|
|
||||||
</div>
|
</div>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
<v-card-actions>
|
<v-card-actions>
|
||||||
@@ -267,39 +269,49 @@
|
|||||||
</v-stepper-window-item>
|
</v-stepper-window-item>
|
||||||
|
|
||||||
<!-- Подтверждение -->
|
<!-- Подтверждение -->
|
||||||
<v-stepper-window-item step="3" class="fill-height">
|
<v-stepper-window-item class="fill-height" step="3">
|
||||||
|
|
||||||
<v-card flat class="fill-height d-flex flex-column">
|
<v-card class="fill-height d-flex flex-column" flat>
|
||||||
<v-card-title>Подтверждение</v-card-title>
|
<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;">
|
||||||
<v-alert v-if="errorMessage" class="mb-4 " type="error">
|
<v-alert v-if="errorMessage" class="mb-4 " type="error">
|
||||||
{{ errorMessage }}
|
{{ errorMessage }}
|
||||||
</v-alert>
|
</v-alert>
|
||||||
|
|
||||||
<p><v-icon size="xsmall" :class="form.title===null||form.title.length==0?'':'opacity-0'" color='red' icon="mdi-alert"/><strong class="px-2">Название:</strong> {{ form.title }}</p>
|
<p>
|
||||||
<p><v-icon size="xsmall" :class="form.description===null||form.description.length==0?'':'opacity-0'" color='red' icon="mdi-alert"/><strong class="px-2">Описание:</strong> {{ form.description }}</p>
|
<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"/>
|
||||||
|
<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.startDate.toLocaleDateString() }}</p>
|
||||||
<p><strong class="px-2">Дата окончания:</strong> {{ form.endDate.toLocaleDateString() }}</p>
|
<p><strong class="px-2">Дата окончания:</strong> {{ form.endDate.toLocaleDateString() }}</p>
|
||||||
<p><strong class="px-2">Вопросы:</strong></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">
|
<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">
|
<div v-if="question.settings.choice === 'free' && question.answers.length">
|
||||||
<p><strong>Варианты ответов:</strong></p>
|
<p><strong>Варианты ответов:</strong></p>
|
||||||
|
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li v-for="(answer, answerIndex) in question.answers" :key="answerIndex">
|
<li v-for="(answer, answerIndex) in question.answers" :key="answerIndex">
|
||||||
{{ answer.text }}
|
{{ answer.text }}
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="question.settings.choice === 'employee' && question.answers.length">
|
<div v-if="question.settings.choice === 'employee' && question.answers.length">
|
||||||
<div>Количество допустимых ответов: {{ question.settings.multiChoice }}</div>
|
<div>Количество допустимых ответов: {{ question.settings.multiChoice }}</div>
|
||||||
<div class="">Голосование по отделам: {{ onlyDepdict.find(e=>e.value===question.settings.onlyDep).name}}</div>
|
<div class="">Голосование по отделам:
|
||||||
|
{{ onlyDepdict.find(e => e.value === question.settings.onlyDep).name }}
|
||||||
|
</div>
|
||||||
<p><strong>Выбранные сотрудники:</strong></p>
|
<p><strong>Выбранные сотрудники:</strong></p>
|
||||||
<ul>
|
<ul>
|
||||||
<li v-for="employeeId in question.answers" :key="employeeId">
|
<li v-for="employeeId in question.answers" :key="employeeId">
|
||||||
@@ -308,12 +320,14 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</v-card>
|
</v-card>
|
||||||
|
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
<v-card-actions>
|
<v-card-actions>
|
||||||
<v-btn color="teal-darken-4" size="medium" @click="step -= 1">Назад</v-btn>
|
<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>
|
<v-btn :disabled="errorMessage!=''" color="teal-darken-4" size="medium" @click="saveVoting">
|
||||||
|
Сохранить
|
||||||
|
</v-btn>
|
||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
|
|
||||||
</v-card>
|
</v-card>
|
||||||
@@ -329,18 +343,15 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { computed, ref, watch } from "vue";
|
import {computed, ref, watch} from "vue";
|
||||||
import { spravURL } from "@/utils/axios-api";
|
import {createVote, getEmployees, spravURL} from "@/utils/axios-api";
|
||||||
import { createVote, getEmployees } from "@/utils/axios-api";
|
|
||||||
import DateSelect from "@/components/UI/date-select.vue";
|
import DateSelect from "@/components/UI/date-select.vue";
|
||||||
import { useAccountStore } from "@/store/AccountStore";
|
import {checkremote} from "@/utils/universal_functions";
|
||||||
import { checkremote } from "@/utils/universal_functions";
|
|
||||||
export default {
|
export default {
|
||||||
components: { DateSelect },
|
components: {DateSelect},
|
||||||
emits: ['updating'],
|
emits: ['updating'],
|
||||||
setup(props, { emit }) {
|
setup(props, {emit}) {
|
||||||
const accountStore = useAccountStore();
|
|
||||||
const user = accountStore.user;
|
|
||||||
const step = ref(0);
|
const step = ref(0);
|
||||||
const isVoteCreated = ref(false);
|
const isVoteCreated = ref(false);
|
||||||
const form = ref({
|
const form = ref({
|
||||||
@@ -356,7 +367,7 @@ export default {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const currentQuestionIndex = ref(0);
|
const currentQuestionIndex = ref(0);
|
||||||
const questionTypes = [{ name: "Ввести вручную", choice: 'free' }, { name: "Выбрать сотрудника", choice: 'employee' }];
|
const questionTypes = [{name: "Ввести вручную", choice: 'free'}, {name: "Выбрать сотрудника", choice: 'employee'}];
|
||||||
|
|
||||||
const groupedEmployees = ref([]);
|
const groupedEmployees = ref([]);
|
||||||
const allEmployees = computed(() => [
|
const allEmployees = computed(() => [
|
||||||
@@ -369,10 +380,10 @@ export default {
|
|||||||
const currentQuestion = computed(() =>
|
const currentQuestion = computed(() =>
|
||||||
form.value.questions[currentQuestionIndex.value] || null
|
form.value.questions[currentQuestionIndex.value] || null
|
||||||
);
|
);
|
||||||
const allEmployeesgroupedbydep = computed(()=>{
|
const allEmployeesgroupedbydep = computed(() => {
|
||||||
let groupped = []
|
let groupped = []
|
||||||
for (let x of allEmployees.value.sort((a,b)=>a.id_dict_department-b.id_dict_department)){
|
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)
|
if (!groupped.includes(x.department)) groupped.push(x.department)
|
||||||
groupped.push(x)
|
groupped.push(x)
|
||||||
}
|
}
|
||||||
return groupped
|
return groupped
|
||||||
@@ -382,7 +393,6 @@ export default {
|
|||||||
|
|
||||||
|
|
||||||
const handleSelectAll = (selected, index) => {
|
const handleSelectAll = (selected, index) => {
|
||||||
console.log(selected, index);
|
|
||||||
if (!selected) {
|
if (!selected) {
|
||||||
form.value.questions[index].answers = groupedEmployees.value.map((employee) => ({
|
form.value.questions[index].answers = groupedEmployees.value.map((employee) => ({
|
||||||
text: employee.id,
|
text: employee.id,
|
||||||
@@ -391,7 +401,7 @@ export default {
|
|||||||
form.value.questions[index].selectedEmployees = groupedEmployees.value.map(employee => employee.id);
|
form.value.questions[index].selectedEmployees = groupedEmployees.value.map(employee => employee.id);
|
||||||
} else {
|
} else {
|
||||||
form.value.questions[index].answers = [];
|
form.value.questions[index].answers = [];
|
||||||
form.value.questions[index].selectedEmployees=[]
|
form.value.questions[index].selectedEmployees = []
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -400,7 +410,7 @@ export default {
|
|||||||
const addQuestion = () => {
|
const addQuestion = () => {
|
||||||
form.value.questions.push({
|
form.value.questions.push({
|
||||||
text: "",
|
text: "",
|
||||||
settings: { choice: "free", multiChoice: 1, onlyDep: null },
|
settings: {choice: "free", multiChoice: 1, onlyDep: null},
|
||||||
image: null,
|
image: null,
|
||||||
answers: [],
|
answers: [],
|
||||||
selectedEmployees: []
|
selectedEmployees: []
|
||||||
@@ -415,36 +425,59 @@ export default {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const updateQuest = (index) => {
|
||||||
|
quests[index] = form.value.questions[index].text.length > 0;
|
||||||
|
};
|
||||||
|
|
||||||
const addAnswer = (index) => {
|
const addAnswer = (index) => {
|
||||||
if (currentQuestion.value) {
|
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) => {
|
const removeAnswer = (index, ind) => {
|
||||||
// if (currentQuestion.value) {
|
form.value.questions[index].answers.splice(ind, 1)
|
||||||
form.value.questions[index].answers.splice(ind, 1)
|
|
||||||
// currentQuestion.value.answers.splice(index, 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() === ""
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const saveVoting = async () => {
|
const saveVoting = async () => {
|
||||||
if (!form.value.title || !form.value.description || form.value.questions.length < 1) {
|
const hasEmptyQuestions = quests.value.includes(false);
|
||||||
errorMessage.value = "Все обязательные поля должны быть заполнены";
|
const hasInvalidAnswers = validateAnswers();
|
||||||
|
|
||||||
|
if (
|
||||||
|
!form.value.title ||
|
||||||
|
!form.value.description ||
|
||||||
|
form.value.questions.length < 1 ||
|
||||||
|
hasEmptyQuestions ||
|
||||||
|
hasInvalidAnswers
|
||||||
|
) {
|
||||||
|
errorMessage.value = "Все обязательные поля и ответы должны быть заполнены";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await createVote(form.value);
|
const response = await createVote(form.value);
|
||||||
console.log("Голосование успешно создано:", response);
|
console.log("Голосование успешно создано:", response);
|
||||||
isVoteCreated.value = true;
|
isVoteCreated.value = true;
|
||||||
emit('updating', 'active')
|
emit("updating", "active");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Ошибка при создании голосования:", error);
|
console.error("Ошибка при создании голосования:", error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
form.value = {
|
form.value = {
|
||||||
title: "",
|
title: "",
|
||||||
@@ -457,27 +490,49 @@ export default {
|
|||||||
isVoteCreated.value = false;
|
isVoteCreated.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const timeOptions = Array.from({ length: 48 }, (_, i) => {
|
const timeOptions = Array.from({length: 48}, (_, i) => {
|
||||||
const hours = String(Math.floor(i / 2)).padStart(2, "0");
|
const hours = String(Math.floor(i / 2)).padStart(2, "0");
|
||||||
const minutes = i % 2 === 0 ? "00" : "30";
|
const minutes = i % 2 === 0 ? "00" : "30";
|
||||||
return `${hours}:${minutes}`;
|
return `${hours}:${minutes}`;
|
||||||
});
|
});
|
||||||
|
|
||||||
const selectedTimeStart = ref(
|
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(
|
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, () => {
|
watch(form.value, () => {
|
||||||
if (!form.value.title || !form.value.description || form.value.questions < 1) {
|
if (!form.value.title || !form.value.description || form.value.questions.length < 1) {
|
||||||
errorMessage.value = "Все обязательные поля должны быть заполнены";
|
errorMessage.value = "Все обязательные поля должны быть заполнены";
|
||||||
} else {
|
} else {
|
||||||
errorMessage.value = "";
|
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.questions,
|
||||||
|
(newQuestions) => {
|
||||||
|
const hasEmptyQuestions = newQuestions.some((q) => !q.text || q.text.trim() === "");
|
||||||
|
const hasInvalidAnswers = validateAnswers();
|
||||||
|
|
||||||
|
if (hasEmptyQuestions || hasInvalidAnswers) {
|
||||||
|
errorMessage.value = "Все вопросы и ответы должны быть заполнены";
|
||||||
|
} else {
|
||||||
|
errorMessage.value = "";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ deep: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
watch(selectedTimeStart, () => {
|
watch(selectedTimeStart, () => {
|
||||||
updateStartDate()
|
updateStartDate()
|
||||||
@@ -503,23 +558,30 @@ export default {
|
|||||||
form.value.endDate = dates
|
form.value.endDate = dates
|
||||||
}
|
}
|
||||||
|
|
||||||
const selectedEmployees = ref([]);
|
|
||||||
|
|
||||||
const onEmployeesChange = (selected, index) => {
|
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){
|
if (ind > -1) {
|
||||||
form.value.questions[index].selectedEmployees.splice(ind,1)
|
form.value.questions[index].selectedEmployees.splice(ind, 1)
|
||||||
let answ =form.value.questions[index].answers.findIndex(a=>a.text==selected)
|
let answ = form.value.questions[index].answers.findIndex(a => a.text === selected)
|
||||||
form.value.questions[index].answers.splice(answ,1)
|
form.value.questions[index].answers.splice(answ, 1)
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
form.value.questions[index].selectedEmployees.push(selected)
|
form.value.questions[index].selectedEmployees.push(selected)
|
||||||
form.value.questions[index].answers.push({ text: selected, image: null });
|
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)
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
quests,
|
||||||
|
updateQuest,
|
||||||
onlyDepdict,
|
onlyDepdict,
|
||||||
allEmployeesgroupedbydep,
|
allEmployeesgroupedbydep,
|
||||||
onEmployeesChange,
|
onEmployeesChange,
|
||||||
@@ -555,10 +617,12 @@ export default {
|
|||||||
.v-input--horizontal .v-input__prepend {
|
.v-input--horizontal .v-input__prepend {
|
||||||
margin-inline-end: 4px;
|
margin-inline-end: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.list-enter-active,
|
.list-enter-active,
|
||||||
.list-leave-active {
|
.list-leave-active {
|
||||||
transition: all 0.5s ease;
|
transition: all 0.5s ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
.list-enter-from,
|
.list-enter-from,
|
||||||
.list-leave-to {
|
.list-leave-to {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-container style="height: 85vh">
|
<v-container style="height: 85vh;">
|
||||||
<div class="text-end">
|
<div class="text-end">
|
||||||
<v-btn class="" color="red-darken-1" density="compact" icon="mdi-close-thick" size="small"
|
<v-btn class="" color="red-darken-1" density="compact" icon="mdi-close-thick" size="small"
|
||||||
@click="$emit('closer')">
|
@click="$emit('closer')">
|
||||||
@@ -30,10 +30,15 @@
|
|||||||
</v-tabs>
|
</v-tabs>
|
||||||
<v-tabs-window v-model="activeTab">
|
<v-tabs-window v-model="activeTab">
|
||||||
<v-tabs-window-item v-for="(question, questionIndex) in questions" :key="questionIndex">
|
<v-tabs-window-item v-for="(question, questionIndex) in questions" :key="questionIndex">
|
||||||
|
|
||||||
<v-row v-if="question.settings.onlyDep">
|
<v-row v-if="question.settings.onlyDep">
|
||||||
<v-col v-for="(winner, department) in getWinnersByDepartment(question)" :key="department">
|
<v-col
|
||||||
<v-card>
|
v-for="(winner, department) in getWinnersByDepartment(question).winnersByDepartment"
|
||||||
|
:key="department"
|
||||||
|
>
|
||||||
|
<v-card
|
||||||
|
class="cursor-pointer"
|
||||||
|
@click="opendialogWinn(department, getWinnersByDepartment(question).groupedByDepartment[department])"
|
||||||
|
style="max-height: 50vh; overflow-y: auto;">
|
||||||
<v-card-title>
|
<v-card-title>
|
||||||
<strong class="text-teal-darken-4">{{ department }}</strong>
|
<strong class="text-teal-darken-4">{{ department }}</strong>
|
||||||
</v-card-title>
|
</v-card-title>
|
||||||
@@ -60,14 +65,15 @@
|
|||||||
</v-col>
|
</v-col>
|
||||||
<v-col cols="12">
|
<v-col cols="12">
|
||||||
<v-card class="mb-4">
|
<v-card class="mb-4">
|
||||||
<v-card-title class="text-teal-darken-3">Топ {{ getTopResults(question).length }}</v-card-title>
|
<v-card-title class="text-teal-darken-3">Распределение голосов:</v-card-title>
|
||||||
<v-card-text>
|
<v-card-text>
|
||||||
<v-list style="max-height: 45vh; overflow-y: auto;">
|
<v-list style="max-height: 45vh; overflow-y: auto;">
|
||||||
<v-list-item
|
<v-list-item
|
||||||
v-for="(answer, answerIndex) in getTopResults(question)"
|
v-for="(answer, answerIndex) in getTopResults(question).filter(el => el.count > 0)"
|
||||||
:key="answerIndex"
|
:key="answerIndex"
|
||||||
>
|
>
|
||||||
<p>
|
<p>
|
||||||
|
<strong class="mr-4">{{ answerIndex + 1 }}.</strong>
|
||||||
<v-avatar v-if="answer.file === null && answer.employee"
|
<v-avatar v-if="answer.file === null && answer.employee"
|
||||||
:image="checkremote(`${spravURL()}${answer.employee.login}.jpg`)"
|
:image="checkremote(`${spravURL()}${answer.employee.login}.jpg`)"
|
||||||
class="cursor-pointer"
|
class="cursor-pointer"
|
||||||
@@ -105,10 +111,12 @@
|
|||||||
</v-row>
|
</v-row>
|
||||||
</v-tabs-window-item>
|
</v-tabs-window-item>
|
||||||
<v-tabs-window-item>
|
<v-tabs-window-item>
|
||||||
<NonVoteSad v-if="Object.keys(groupedByDepartment).length > 0" />
|
<NonVoteSad v-if="nonVoters.length > 0"/>
|
||||||
<v-card-title v-if="Object.keys(groupedByDepartment).length > 0" class="text-red-darken-3">Не голосовали:</v-card-title>
|
<v-card-title v-if="nonVoters.length > 0" class="text-red-darken-3">Число сотрудников, которые не проголосовали
|
||||||
|
<strong>{{ nonVoters.length }}</strong>
|
||||||
|
</v-card-title>
|
||||||
<v-card-item style="max-height: 50vh; overflow-y: auto;">
|
<v-card-item style="max-height: 50vh; overflow-y: auto;">
|
||||||
<NonVoteHappy v-if="Object.keys(groupedByDepartment).length < 1"/>
|
<NonVoteHappy v-if="nonVoters.length < 1"/>
|
||||||
<template v-for="(voters, department) in groupedByDepartment" :key="department">
|
<template v-for="(voters, department) in groupedByDepartment" :key="department">
|
||||||
<v-list-item-title class="text-teal-darken-4">{{ department }}</v-list-item-title>
|
<v-list-item-title class="text-teal-darken-4">{{ department }}</v-list-item-title>
|
||||||
<v-list-item v-for="(voter, voterIndex) in voters" :key="`${department}-${voterIndex}`">
|
<v-list-item v-for="(voter, voterIndex) in voters" :key="`${department}-${voterIndex}`">
|
||||||
@@ -119,9 +127,9 @@
|
|||||||
@click="userCardIndex = `${department}-${voterIndex}`"
|
@click="userCardIndex = `${department}-${voterIndex}`"
|
||||||
/>
|
/>
|
||||||
<InfoUserCard
|
<InfoUserCard
|
||||||
|
:author="voter"
|
||||||
:opendialog="userCardIndex === `${department}-${voterIndex}`"
|
:opendialog="userCardIndex === `${department}-${voterIndex}`"
|
||||||
@update:opendialog="userCardIndex = $event ? `${department}-${voterIndex}` : null"
|
@update:opendialog="userCardIndex = $event ? `${department}-${voterIndex}` : null"
|
||||||
:author="voter"
|
|
||||||
/>
|
/>
|
||||||
<strong class="ml-4">{{ voter.fio }}</strong>
|
<strong class="ml-4">{{ voter.fio }}</strong>
|
||||||
</p>
|
</p>
|
||||||
@@ -150,6 +158,60 @@
|
|||||||
</v-card-item>
|
</v-card-item>
|
||||||
</v-card>
|
</v-card>
|
||||||
</v-dialog>
|
</v-dialog>
|
||||||
|
|
||||||
|
<v-dialog v-model="dialogWinner" max-width="800">
|
||||||
|
<v-card>
|
||||||
|
<v-card-title class="d-flex">
|
||||||
|
<strong class="text-teal-darken-4">Результаты голосования: {{ activeDepartment }}</strong>
|
||||||
|
<v-spacer></v-spacer>
|
||||||
|
<v-btn color="red-darken-1" density="compact" icon="mdi-close-thick" size="small" @click="dialogWinner=false"/>
|
||||||
|
</v-card-title>
|
||||||
|
<v-card-text>
|
||||||
|
<v-list>
|
||||||
|
<v-list-item
|
||||||
|
v-for="(answer, index) in activeDepartmentResults.filter(el => el.count > 0)"
|
||||||
|
:key="index"
|
||||||
|
>
|
||||||
|
<p>
|
||||||
|
<strong class="mr-4">{{ index + 1 }}.</strong>
|
||||||
|
<v-avatar v-if="answer.file === null && answer.employee"
|
||||||
|
:image="checkremote(`${spravURL()}${answer.employee.login}.jpg`)"
|
||||||
|
class="cursor-pointer"
|
||||||
|
@click.stop="opendialog(checkremote(`${spravURL()}${answer.employee.login}.jpg`))"/>
|
||||||
|
<v-avatar v-if="answer.file !== null" :image="baseURL.slice(0, -1) + answer.file"
|
||||||
|
class="cursor-pointer"
|
||||||
|
@click.stop="opendialog(answer)"/>
|
||||||
|
<strong class="ml-4">{{ answer.employee ? answer.employee.fio : answer.name }}</strong>:
|
||||||
|
{{ answer.count }}
|
||||||
|
{{ voteCount(answer.count) }}
|
||||||
|
<template v-if="answer.employee">
|
||||||
|
<br/>
|
||||||
|
<small>Отдел: {{ answer.employee ? answer.employee.department : '' }}</small>
|
||||||
|
<br/>
|
||||||
|
<small>Должность: {{ answer.employee ? answer.employee.post : '' }}</small>
|
||||||
|
</template>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<v-progress-linear
|
||||||
|
:model-value="getPercentage(answer.count, questions[index])"
|
||||||
|
color="teal-darken-4"
|
||||||
|
height="13"
|
||||||
|
rounded
|
||||||
|
striped
|
||||||
|
>
|
||||||
|
<template v-slot:default="{ value }">
|
||||||
|
<strong v-if="value < 50" class="text-grey-darken-3">{{ Math.ceil(value) }}%</strong>
|
||||||
|
<strong v-else class="text-grey-lighten-5">{{ Math.ceil(value) }}%</strong>
|
||||||
|
</template>
|
||||||
|
</v-progress-linear>
|
||||||
|
|
||||||
|
</v-list-item>
|
||||||
|
|
||||||
|
</v-list>
|
||||||
|
</v-card-text>
|
||||||
|
</v-card>
|
||||||
|
</v-dialog>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -190,6 +252,17 @@ export default {
|
|||||||
const description = props.data.description;
|
const description = props.data.description;
|
||||||
const nonVoters = props.data.nonvoting;
|
const nonVoters = props.data.nonvoting;
|
||||||
|
|
||||||
|
const activeDepartment = ref(null);
|
||||||
|
const activeDepartmentResults = ref([]);
|
||||||
|
const dialog = ref(false);
|
||||||
|
const dialogWinner = ref(false);
|
||||||
|
|
||||||
|
const opendialogWinn = (department, results) => {
|
||||||
|
activeDepartment.value = department;
|
||||||
|
activeDepartmentResults.value = results;
|
||||||
|
dialogWinner.value = true;
|
||||||
|
};
|
||||||
|
|
||||||
const getWinner = (question) => {
|
const getWinner = (question) => {
|
||||||
return question.answers.reduce(
|
return question.answers.reduce(
|
||||||
(max, answer) => (answer.count > max.count ? answer : max),
|
(max, answer) => (answer.count > max.count ? answer : max),
|
||||||
@@ -198,7 +271,21 @@ export default {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getTopResults = (question) => {
|
const getTopResults = (question) => {
|
||||||
return [...question.answers].sort((a, b) => b.count - a.count).slice(0, 10);
|
const sortedAnswers = [...question.answers].sort((a, b) => b.count - a.count);
|
||||||
|
|
||||||
|
// Присваиваем одинаковые индексы для одинаковых значений count
|
||||||
|
let rank = 1;
|
||||||
|
let previousCount = null;
|
||||||
|
return sortedAnswers.map((answer, index) => {
|
||||||
|
if (answer.count !== previousCount) {
|
||||||
|
rank = index + 1;
|
||||||
|
previousCount = answer.count;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
...answer,
|
||||||
|
rank
|
||||||
|
};
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const truncateText = (text, maxLength) => {
|
const truncateText = (text, maxLength) => {
|
||||||
@@ -225,7 +312,7 @@ export default {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const activepick = ref(null)
|
const activepick = ref(null)
|
||||||
const dialog = ref(false)
|
// const dialog = ref(false)
|
||||||
const opendialog = (val) => {
|
const opendialog = (val) => {
|
||||||
dialog.value = true
|
dialog.value = true
|
||||||
activepick.value = val
|
activepick.value = val
|
||||||
@@ -244,11 +331,18 @@ export default {
|
|||||||
|
|
||||||
// Сортируем департаменты по id_dict_department
|
// Сортируем департаменты по id_dict_department
|
||||||
const sortedDepartments = Object.keys(departments).sort((a, b) => {
|
const sortedDepartments = Object.keys(departments).sort((a, b) => {
|
||||||
const idA = nonVoters.find(voter => voter.department === a)?.id_dict_department;
|
const idA = nonVoters.find(voter => voter.department === a)?.id_dict_department || 0;
|
||||||
const idB = nonVoters.find(voter => voter.department === b)?.id_dict_department;
|
const idB = nonVoters.find(voter => voter.department === b)?.id_dict_department || 0;
|
||||||
return idA - idB;
|
return idA - idB;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Сортируем сотрудников внутри каждого департамента по id_dict_position
|
||||||
|
sortedDepartments.forEach(department => {
|
||||||
|
departments[department].sort((voterA, voterB) => {
|
||||||
|
return (voterA.id_dict_position || 0) - (voterB.id_dict_position || 0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Возвращаем отсортированные департаменты с пользователями
|
// Возвращаем отсортированные департаменты с пользователями
|
||||||
const sortedGroupedByDepartment = {};
|
const sortedGroupedByDepartment = {};
|
||||||
sortedDepartments.forEach(department => {
|
sortedDepartments.forEach(department => {
|
||||||
@@ -263,7 +357,7 @@ export default {
|
|||||||
const getWinnersByDepartment = (question) => {
|
const getWinnersByDepartment = (question) => {
|
||||||
// Группируем ответы по департаментам
|
// Группируем ответы по департаментам
|
||||||
const groupedByDepartment = question.answers.reduce((groups, answer) => {
|
const groupedByDepartment = question.answers.reduce((groups, answer) => {
|
||||||
const department = answer.employee?.department || 'Без отдела'; // Отдел или 'Без отдела' если нет
|
const department = answer.employee?.department;
|
||||||
if (!groups[department]) {
|
if (!groups[department]) {
|
||||||
groups[department] = [];
|
groups[department] = [];
|
||||||
}
|
}
|
||||||
@@ -282,11 +376,15 @@ export default {
|
|||||||
winnersByDepartment[department] = winner;
|
winnersByDepartment[department] = winner;
|
||||||
}
|
}
|
||||||
|
|
||||||
return winnersByDepartment;
|
return { groupedByDepartment, winnersByDepartment };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
opendialogWinn,
|
||||||
|
dialogWinner,
|
||||||
|
activeDepartmentResults,
|
||||||
|
activeDepartment,
|
||||||
getWinnersByDepartment,
|
getWinnersByDepartment,
|
||||||
userCardIndex,
|
userCardIndex,
|
||||||
activepick,
|
activepick,
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<v-list nav density="compact" class="text-blue-grey-lighten-1">
|
||||||
|
|
||||||
|
|
||||||
|
<v-list-item
|
||||||
|
v-for="x in aMenuItem"
|
||||||
|
:key="x"
|
||||||
|
:title="x.name"
|
||||||
|
:value="x.name"
|
||||||
|
:href="x.link"
|
||||||
|
:target="x.link ? '_blank' : ''"
|
||||||
|
slim
|
||||||
|
>
|
||||||
|
<template v-slot:prepend>
|
||||||
|
<v-icon :icon="x.ico" size="x_small" />
|
||||||
|
<v-tooltip v-if="rail" activator="parent" location="top">
|
||||||
|
</v-tooltip>
|
||||||
|
</template>
|
||||||
|
</v-list-item>
|
||||||
|
|
||||||
|
</v-list>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { baseURL } from "@/utils/axios-api";
|
||||||
|
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name:'AdminMenu',
|
||||||
|
props: {
|
||||||
|
rail: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
const aMenuItem = [
|
||||||
|
{
|
||||||
|
name: "Панель администратора",
|
||||||
|
ico: "mdi-wrench",
|
||||||
|
link: baseURL + "admin",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return {
|
||||||
|
aMenuItem,
|
||||||
|
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
@@ -12,7 +12,6 @@
|
|||||||
<template v-slot:append>
|
<template v-slot:append>
|
||||||
<template v-if="accountStore.cod2user">
|
<template v-if="accountStore.cod2user">
|
||||||
<vcard-user :author="accountStore.user" />
|
<vcard-user :author="accountStore.user" />
|
||||||
|
|
||||||
<v-tooltip location="bottom">
|
<v-tooltip location="bottom">
|
||||||
<template v-slot:activator="{ props }">
|
<template v-slot:activator="{ props }">
|
||||||
<v-btn color="black_and_white" v-bind="props" dark to="/faq" icon="mdi-comment-question-outline" />
|
<v-btn color="black_and_white" v-bind="props" dark to="/faq" icon="mdi-comment-question-outline" />
|
||||||
@@ -78,15 +77,15 @@
|
|||||||
<v-col class="flex-column d-flex">
|
<v-col class="flex-column d-flex">
|
||||||
<v-row><v-col>
|
<v-row><v-col>
|
||||||
<v-list nav density="compact">
|
<v-list nav density="compact">
|
||||||
<template v-for="(x, key) in navigations">
|
<template v-for="(x, key) in navigations" :key="key">
|
||||||
<!-- v-if="!('submenu' in x) || (x.path== '/portal' && accountStore.user.is_staff)" -->
|
<!-- v-if="!('submenu' in x) || (x.path== '/portal' && accountStore.user.is_staff)" -->
|
||||||
<v-list-item v-if="(x.path == '/portal'
|
<v-list-item v-if="(x.path == '/portal'? accountStore.user.is_superuser : true) && !('submenu' in x)
|
||||||
? accountStore.user.is_superuser
|
|
||||||
: true) && !('submenu' in x)
|
|
||||||
" :key="x.key" :title="x.name" :value="x.name" :href="x.link" :disabled="x.path == ''" :to="x.path"
|
" :key="x.key" :title="x.name" :value="x.name" :href="x.link" :disabled="x.path == ''" :to="x.path"
|
||||||
:target="x.link ? '_blank' : ''" color="navigation">
|
:target="x.link ? '_blank' : ''"
|
||||||
|
color="navigation"
|
||||||
<!-- Чтобы сделать неактивным раздел безопасность, не забыть прописать путь до него в disabled для показа -->
|
|
||||||
|
>
|
||||||
|
|
||||||
<template v-slot:prepend>
|
<template v-slot:prepend>
|
||||||
<v-icon :icon="x.ico" />
|
<v-icon :icon="x.ico" />
|
||||||
<v-tooltip v-if="rail" activator="parent" location="top">
|
<v-tooltip v-if="rail" activator="parent" location="top">
|
||||||
@@ -116,7 +115,7 @@
|
|||||||
</v-list>
|
</v-list>
|
||||||
|
|
||||||
<v-list nav density="compact">
|
<v-list nav density="compact">
|
||||||
<v-list-item v-for="x of mainmenuStore.portallinks" :key="x.name" :title="x.name" :value="x.name"
|
<v-list-item v-for="x of mainmenuStore.portallinks" :key="x.name" :title="x.name" :value="x.name"
|
||||||
:href="x.link" color="app_bar" :target="x.link ? '_blank' : ''">
|
:href="x.link" color="app_bar" :target="x.link ? '_blank' : ''">
|
||||||
<template v-slot:prepend>
|
<template v-slot:prepend>
|
||||||
<v-icon :icon="x.imagecode" />
|
<v-icon :icon="x.imagecode" />
|
||||||
@@ -131,17 +130,8 @@
|
|||||||
|
|
||||||
<v-row class="flex-grow-0" v-if="accountStore.user.is_staff">
|
<v-row class="flex-grow-0" v-if="accountStore.user.is_staff">
|
||||||
<v-col>
|
<v-col>
|
||||||
<default-portal-menu-list :rail="rail" />
|
<AdminMenu :rail="rail" />
|
||||||
<!-- <v-list nav density="compact" active-class="noneoutline">
|
|
||||||
<default-portal-menu-list :aMenuItem="supperuser"/>
|
|
||||||
<div v-if="getDevelopment()">
|
|
||||||
|
|
||||||
<default-portal-menu-list :aMenuItem="oRasrab"/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</v-list> -->
|
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
<v-row no-gutters class="flex-grow-0">
|
<v-row no-gutters class="flex-grow-0">
|
||||||
@@ -197,8 +187,8 @@ import { axiosApiInstance, clearAxios } from "@/utils/axios-api";
|
|||||||
import { baseURL } from "@/utils/axios-api";
|
import { baseURL } from "@/utils/axios-api";
|
||||||
import VcardUser from "@/components/UI/fiousercard/vcardUser.vue";
|
import VcardUser from "@/components/UI/fiousercard/vcardUser.vue";
|
||||||
import PageCounter from "@/components/UI/defaultportal/page-counter.vue";
|
import PageCounter from "@/components/UI/defaultportal/page-counter.vue";
|
||||||
import DefaultPortalMenuList from "@/layouts/default/DefaultPortalMenuList.vue";
|
import AdminMenu from "@/layouts/default/AdminMenu.vue";
|
||||||
import { getDevelopment } from "@/utils/universal_functions";
|
|
||||||
import { useDisplay } from "vuetify";
|
import { useDisplay } from "vuetify";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -208,7 +198,7 @@ export default {
|
|||||||
CardLike,
|
CardLike,
|
||||||
VcardUser,
|
VcardUser,
|
||||||
PageCounter,
|
PageCounter,
|
||||||
DefaultPortalMenuList,
|
AdminMenu,
|
||||||
},
|
},
|
||||||
|
|
||||||
mixins: [uf],
|
mixins: [uf],
|
||||||
@@ -258,30 +248,7 @@ export default {
|
|||||||
|
|
||||||
mainmenuStore.loadlinks();
|
mainmenuStore.loadlinks();
|
||||||
|
|
||||||
const gittlink = () => {
|
|
||||||
const link =
|
|
||||||
baseURL == "http://127.0.0.1:8000/"
|
|
||||||
? "http://sulaco.nodered.ru:5223/COD2/PORTAL_COD2/projects"
|
|
||||||
: "http://maestro.cod2.regions.tax.nalog.ru:3333/COD2/PORTAL_COD2/projects/22";
|
|
||||||
return link;
|
|
||||||
};
|
|
||||||
|
|
||||||
// 'https://materialdesignicons.com/cdn/1.6.50-dev/'
|
|
||||||
|
|
||||||
const oRasrab = [
|
|
||||||
{
|
|
||||||
name: "Gitt",
|
|
||||||
ico: "mdi-github",
|
|
||||||
link: gittlink(),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Swagger",
|
|
||||||
ico: "mdi-puzzle",
|
|
||||||
link: "http://127.0.0.1:8000/swagger/",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
// ]
|
|
||||||
|
|
||||||
const navigations = ref([
|
const navigations = ref([
|
||||||
{
|
{
|
||||||
@@ -354,11 +321,7 @@ export default {
|
|||||||
path: "/portal",
|
path: "/portal",
|
||||||
},
|
},
|
||||||
|
|
||||||
// {
|
|
||||||
// name: 'К празднику',
|
|
||||||
// ico: 'mdi-cake-variant',
|
|
||||||
// path: "/fnshol"
|
|
||||||
// }
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const imageSrc = computed(() => {
|
const imageSrc = computed(() => {
|
||||||
@@ -390,7 +353,7 @@ export default {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
getSafetyChapter();
|
// getSafetyChapter();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
theme,
|
theme,
|
||||||
@@ -402,18 +365,16 @@ export default {
|
|||||||
navigations,
|
navigations,
|
||||||
imageSrc,
|
imageSrc,
|
||||||
LikeDialog,
|
LikeDialog,
|
||||||
scrimg,
|
scrimg,
|
||||||
oRasrab,
|
|
||||||
rail,
|
rail,
|
||||||
showTooltip,
|
showTooltip,
|
||||||
menuTruncated,
|
menuTruncated,
|
||||||
// feedalert,
|
|
||||||
alert,
|
alert,
|
||||||
burl,
|
burl,
|
||||||
name,
|
name,
|
||||||
closeinfo,
|
closeinfo,
|
||||||
baseURL,
|
baseURL,
|
||||||
getDevelopment,
|
|
||||||
message,
|
message,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,89 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div>
|
|
||||||
<v-list nav density="compact" class="text-blue-grey-lighten-1">
|
|
||||||
<div v-for="(list, key) in aMenuItem" :key="key">
|
|
||||||
<div v-if="showProm(key)">
|
|
||||||
<v-list-item
|
|
||||||
v-for="x in list"
|
|
||||||
:key="x"
|
|
||||||
:title="x.name"
|
|
||||||
:value="x.name"
|
|
||||||
:href="x.link"
|
|
||||||
:target="x.link ? '_blank' : ''"
|
|
||||||
slim
|
|
||||||
>
|
|
||||||
<template v-slot:prepend>
|
|
||||||
<v-icon :icon="x.ico" size="x_small" />
|
|
||||||
<v-tooltip v-if="rail" activator="parent" location="top">
|
|
||||||
</v-tooltip>
|
|
||||||
</template>
|
|
||||||
</v-list-item>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</v-list>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import { baseURL } from "@/utils/axios-api";
|
|
||||||
import { getDevelopment } from "@/utils/universal_functions";
|
|
||||||
|
|
||||||
export default {
|
|
||||||
props: {
|
|
||||||
rail: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
setup() {
|
|
||||||
const gittlink = () => {
|
|
||||||
const link =
|
|
||||||
baseURL == "http://127.0.0.1:8000/"
|
|
||||||
? "http://sulaco.nodered.ru:5223/COD2/PORTAL_COD2/projects"
|
|
||||||
: "http://maestro.cod2.regions.tax.nalog.ru:3333/COD2/PORTAL_COD2/projects/22";
|
|
||||||
return link;
|
|
||||||
};
|
|
||||||
const aMenuItem = {
|
|
||||||
prom: [
|
|
||||||
{
|
|
||||||
name: "Панель администратора",
|
|
||||||
ico: "mdi-wrench",
|
|
||||||
link: baseURL + "admin",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
my: [
|
|
||||||
{
|
|
||||||
name: "Gitt",
|
|
||||||
ico: "mdi-github",
|
|
||||||
link: gittlink(),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Swagger",
|
|
||||||
ico: "mdi-puzzle",
|
|
||||||
link: "http://127.0.0.1:8000/swagger/",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
const showProm = (data) => {
|
|
||||||
let show = true;
|
|
||||||
|
|
||||||
if (data == "my" && getDevelopment() == false) {
|
|
||||||
show = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return show;
|
|
||||||
};
|
|
||||||
|
|
||||||
return {
|
|
||||||
aMenuItem,
|
|
||||||
getDevelopment,
|
|
||||||
showProm,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style></style>
|
|
||||||
@@ -140,7 +140,7 @@ const routes = [
|
|||||||
ico: "mdi-account",
|
ico: "mdi-account",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
path: "/vote",
|
path: "/vote",
|
||||||
name: "VoteHomePage",
|
name: "VoteHomePage",
|
||||||
@@ -177,11 +177,6 @@ const routes = [
|
|||||||
ico: "mdi-account",
|
ico: "mdi-account",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
path: '/secret',
|
path: '/secret',
|
||||||
name: 'Secret Page',
|
name: 'Secret Page',
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import axios from "axios";
|
|||||||
const spravURL = 'http://10.252.44.33/accounting6/images/photo/'
|
const spravURL = 'http://10.252.44.33/accounting6/images/photo/'
|
||||||
const spravURLBase = 'http://10.252.44.33/accounting6/'
|
const spravURLBase = 'http://10.252.44.33/accounting6/'
|
||||||
const baseURL = process.env.NODE_ENV === 'development' ? 'http://127.0.0.1:8000/' : `http://${window.location.host}/`;
|
const baseURL = process.env.NODE_ENV === 'development' ? 'http://127.0.0.1:8000/' : `http://${window.location.host}/`;
|
||||||
const baseWS = process.env.NODE_ENV == 'development' ? 'ws://127.0.0.1:8000/' : `ws://${window.location.host}/`;
|
const baseWS = process.env.NODE_ENV === 'development' ? 'ws://127.0.0.1:8000/' : `ws://${window.location.host}/`;
|
||||||
// const baseURL = process.env.NODE_ENV == 'development'? 'http://127.0.0.1:8000/': `http://10.252.44.60:9965/`;
|
// const baseURL = process.env.NODE_ENV == 'development'? 'http://127.0.0.1:8000/': `http://10.252.44.60:9965/`;
|
||||||
// const baseWS = process.env.NODE_ENV == 'development'? 'ws://127.0.0.1:8000/': `ws://10.252.44.60:9966/`;
|
// const baseWS = process.env.NODE_ENV == 'development'? 'ws://127.0.0.1:8000/': `ws://10.252.44.60:9966/`;
|
||||||
// для релизного меняем 'http://ukd/'
|
// для релизного меняем 'http://ukd/'
|
||||||
|
|||||||
@@ -6,8 +6,7 @@ import { axiosApiInstance, clearAxios } from "@/utils/axios-api";
|
|||||||
import { useRouter } from "vue-router";
|
import { useRouter } from "vue-router";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import { ref, onMounted } from "vue";
|
import { ref, onMounted } from "vue";
|
||||||
|
import defaultImage from '@/assets/FNS-logo-xs.png'
|
||||||
|
|
||||||
export function get_name(namestr) {
|
export function get_name(namestr) {
|
||||||
let arr = namestr.split("/");
|
let arr = namestr.split("/");
|
||||||
return arr[arr.length - 1];
|
return arr[arr.length - 1];
|
||||||
@@ -57,18 +56,23 @@ export function getfromserverfree(path, reactive) {
|
|||||||
|
|
||||||
export function checkremote(filecheck) {
|
export function checkremote(filecheck) {
|
||||||
return process.env.NODE_ENV == "development"
|
return process.env.NODE_ENV == "development"
|
||||||
? "https://pixelbox.ru/wp-content/uploads/2021/11/avatar-whatsapp-pixelbox.ru-36.jpg"
|
? defaultImage
|
||||||
: filecheck;
|
: filecheck;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default str;
|
export default str;
|
||||||
|
|
||||||
export function splitname(name) {
|
export function splitname(name) {
|
||||||
|
|
||||||
return name.familyname + " " + name.name[0] + "." + name.parentname[0] + ".";
|
return name.familyname + " " + name.name[0] + "." + name.parentname[0] + ".";
|
||||||
}
|
}
|
||||||
|
|
||||||
export function pagecounter() {
|
export function pagecounter() {
|
||||||
|
// Функция записи посещения страницы сотрудникам.
|
||||||
|
// В случае, если в роуте присутствует ключ мета и в нем ико - тогда производится запись
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
|
if('meta' in router.currentRoute.value && 'ico' in router.currentRoute.value.meta){
|
||||||
const accountStore = useAccountStore();
|
const accountStore = useAccountStore();
|
||||||
const appStore = useAppStore();
|
const appStore = useAppStore();
|
||||||
|
|
||||||
@@ -86,9 +90,6 @@ export function pagecounter() {
|
|||||||
appStore.countvisitor = result.data;
|
appStore.countvisitor = result.data;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getDevelopment() {
|
|
||||||
return process.env.NODE_ENV == "development" ? true : false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useICalReader(url) {
|
export function useICalReader(url) {
|
||||||
@@ -167,3 +168,9 @@ export function useICalReader(url) {
|
|||||||
|
|
||||||
// return { icsContent, fetchICalFile }
|
// return { icsContent, fetchICalFile }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
// Функция склонения числительных
|
||||||
|
export function declOfNum(value, titles) {
|
||||||
|
const cases = [2, 0, 1, 1, 1, 2];
|
||||||
|
return titles[(value % 100 > 4 && value % 100 < 20) ? 2 : cases[(value % 10 < 5) ? value % 10 : 5]];
|
||||||
|
}
|
||||||
@@ -13,8 +13,9 @@
|
|||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
<v-row style="height:250px">
|
<v-row style="height:250px">
|
||||||
<v-col class="d-flex flex-column pa-1">
|
<v-col class="d-flex flex-column flex-grow-0 pa-1">
|
||||||
<!-- <event-calendar/> -->
|
<!-- <event-calendar/> -->
|
||||||
|
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
</v-col>
|
</v-col>
|
||||||
@@ -65,6 +66,8 @@
|
|||||||
<v-slide-group
|
<v-slide-group
|
||||||
show-arrows
|
show-arrows
|
||||||
>
|
>
|
||||||
|
|
||||||
|
|
||||||
<v-slide-group-item
|
<v-slide-group-item
|
||||||
v-for="x in favorit"
|
v-for="x in favorit"
|
||||||
:key="x"
|
:key="x"
|
||||||
@@ -95,6 +98,7 @@
|
|||||||
|
|
||||||
</v-card>
|
</v-card>
|
||||||
</v-col>
|
</v-col>
|
||||||
|
|
||||||
</v-row>
|
</v-row>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
@@ -109,7 +113,7 @@
|
|||||||
|
|
||||||
import CarouselList from '@/components/carousel-list.vue'
|
import CarouselList from '@/components/carousel-list.vue'
|
||||||
import CarouselNumbers from '@/components/carousel-numbers.vue'
|
import CarouselNumbers from '@/components/carousel-numbers.vue'
|
||||||
|
|
||||||
|
|
||||||
import NewsHome from '@/components/news-home.vue'
|
import NewsHome from '@/components/news-home.vue'
|
||||||
import LoadRound from '@/components/load-round.vue'
|
import LoadRound from '@/components/load-round.vue'
|
||||||
@@ -121,7 +125,7 @@
|
|||||||
export default {
|
export default {
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
|
|
||||||
CarouselList,
|
CarouselList,
|
||||||
CarouselNumbers,
|
CarouselNumbers,
|
||||||
|
|
||||||
|
|||||||
@@ -1,23 +1,223 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-row>
|
<v-container>
|
||||||
<v-col
|
<v-tabs v-model="activeTab" class="mb-4 text-teal-darken-4">
|
||||||
class="text-h6 text-grey text-center align-self-center text--lighten-1 font-weight-light"
|
<v-tab>Назначенные ({{ scheduledTests.length }})</v-tab>
|
||||||
>
|
<v-tab>Завершенные ({{ completedTests.length }})</v-tab>
|
||||||
Тестирование
|
<v-tab>Каталог</v-tab>
|
||||||
</v-col>
|
</v-tabs>
|
||||||
</v-row>
|
|
||||||
|
<v-tabs-window v-model="activeTab">
|
||||||
|
<!-- Назначенные -->
|
||||||
|
<v-tabs-window-item>
|
||||||
|
<v-card outlined>
|
||||||
|
<v-card-title>
|
||||||
|
Назначенные
|
||||||
|
</v-card-title>
|
||||||
|
|
||||||
|
<v-text-field
|
||||||
|
v-model="search"
|
||||||
|
class="mx-4"
|
||||||
|
clearable
|
||||||
|
label="Найти тестирование по названию"
|
||||||
|
variant="outlined"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<v-data-table
|
||||||
|
:headers="headers"
|
||||||
|
:items="filteredScheduledTests"
|
||||||
|
hide-default-footer
|
||||||
|
hide-default-header
|
||||||
|
item-value="id"
|
||||||
|
>
|
||||||
|
|
||||||
|
<template #item.image="{ item }">
|
||||||
|
<v-img :src="item.image" alt="Test Image" height="100" width="100"/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #item.title="{ item }">
|
||||||
|
<TestCard :item="item"/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #item.actions="{ item }">
|
||||||
|
<v-btn v-if="item.type === 'test'" class="mr-4" color="teal-darken-4" variant="tonal">Тренироваться
|
||||||
|
</v-btn>
|
||||||
|
<v-btn color="teal-darken-4">Пройти</v-btn>
|
||||||
|
</template>
|
||||||
|
</v-data-table>
|
||||||
|
</v-card>
|
||||||
|
</v-tabs-window-item>
|
||||||
|
|
||||||
|
<!-- Завершенные -->
|
||||||
|
<v-tabs-window-item>
|
||||||
|
<v-card class="mb-6" outlined>
|
||||||
|
<v-card-title>
|
||||||
|
Завершенные
|
||||||
|
</v-card-title>
|
||||||
|
<v-data-table
|
||||||
|
:headers="headers"
|
||||||
|
:items="filteredCompletedTests"
|
||||||
|
hide-default-footer
|
||||||
|
hide-default-header
|
||||||
|
item-value="id"
|
||||||
|
>
|
||||||
|
<template #item.image="{ item }">
|
||||||
|
<v-img :src="item.image" alt="Test Image" height="100" width="100"/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #item.title="{ item }">
|
||||||
|
<TestCard :item="item"/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #item.actions="{ item }">
|
||||||
|
<v-btn color="teal-darken-4">Посмотреть результаты</v-btn>
|
||||||
|
</template>
|
||||||
|
</v-data-table>
|
||||||
|
</v-card>
|
||||||
|
</v-tabs-window-item>
|
||||||
|
|
||||||
|
<!-- Каталог -->
|
||||||
|
<v-tabs-window-item>
|
||||||
|
<v-card outlined>
|
||||||
|
<v-card-title>
|
||||||
|
Каталог
|
||||||
|
</v-card-title>
|
||||||
|
|
||||||
|
<v-text-field
|
||||||
|
v-model="search"
|
||||||
|
class="mx-4"
|
||||||
|
clearable
|
||||||
|
label="Найти тестирование по названию"
|
||||||
|
variant="outlined"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<v-data-table
|
||||||
|
:headers="headers"
|
||||||
|
:items="filteredTests"
|
||||||
|
hide-default-footer
|
||||||
|
hide-default-header
|
||||||
|
item-value="id"
|
||||||
|
>
|
||||||
|
<template #item.image="{ item }">
|
||||||
|
<v-img :src="item.image" alt="Test Image" height="100" width="100"/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #item.title="{ item }">
|
||||||
|
<TestCard :item="item"/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #item.actions="{ item }">
|
||||||
|
<v-btn v-if="item.type === 'test'" class="mr-4" color="teal-darken-4" variant="tonal">Тренироваться
|
||||||
|
</v-btn>
|
||||||
|
<v-btn color="teal-darken-4">Пройти</v-btn>
|
||||||
|
</template>
|
||||||
|
</v-data-table>
|
||||||
|
</v-card>
|
||||||
|
</v-tabs-window-item>
|
||||||
|
</v-tabs-window>
|
||||||
|
</v-container>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {pagecounter} from '@/utils/universal_functions'
|
import {computed, ref} from 'vue';
|
||||||
|
import TestCard from "@/components/tests/TestCard.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setup(){
|
components: {TestCard},
|
||||||
pagecounter()
|
setup() {
|
||||||
}
|
const activeTab = ref(0);
|
||||||
}
|
const search = ref('');
|
||||||
|
|
||||||
|
const headers = [
|
||||||
|
{text: 'Картинка', value: 'image', sortable: false},
|
||||||
|
{text: 'Название', value: 'title', align: 'start'},
|
||||||
|
{text: 'Действия', value: 'actions', sortable: false},
|
||||||
|
];
|
||||||
|
|
||||||
|
const tests = ref([
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
title: 'Комплекс тестовых вопросов на знание в области информационно-коммуникационных технологий',
|
||||||
|
type: 'test',
|
||||||
|
description: 'Краткое описание тестирования',
|
||||||
|
date: '2025-02-28',
|
||||||
|
questions: 20,
|
||||||
|
time: '15 минут',
|
||||||
|
attempts: 1,
|
||||||
|
image: 'https://icdn.lenta.ru/images/2024/03/27/12/20240327123127525/square_1280_63e6b3d7acbfce65d885ae4cf216dfe2.jpg',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
title: 'Удобство раздела тестирования',
|
||||||
|
type: 'survey',
|
||||||
|
description: 'Опрос среди сотрудников ЦОД МФ',
|
||||||
|
date: '2025-06-22',
|
||||||
|
questions: 28,
|
||||||
|
time: null,
|
||||||
|
attempts: null,
|
||||||
|
image: 'https://icdn.lenta.ru/images/2024/03/27/12/20240327123127525/square_1280_63e6b3d7acbfce65d885ae4cf216dfe2.jpg',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 3,
|
||||||
|
title: 'Законченная карточка законченного тестирования',
|
||||||
|
type: 'survey',
|
||||||
|
description: 'законченное описание законченного тестирования',
|
||||||
|
date: '2024-06-22',
|
||||||
|
questions: 1,
|
||||||
|
time: null,
|
||||||
|
attempts: null,
|
||||||
|
image: 'https://icdn.lenta.ru/images/2024/03/27/12/20240327123127525/square_1280_63e6b3d7acbfce65d885ae4cf216dfe2.jpg',
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
const currentDate = new Date();
|
||||||
|
|
||||||
|
const scheduledTests = computed(() => {
|
||||||
|
return tests.value.filter(test => new Date(test.date) > currentDate);
|
||||||
|
});
|
||||||
|
|
||||||
|
const completedTests = computed(() => {
|
||||||
|
return tests.value.filter(test => new Date(test.date) <= currentDate);
|
||||||
|
});
|
||||||
|
|
||||||
|
const filteredScheduledTests = computed(() => {
|
||||||
|
if (!search.value) return scheduledTests.value;
|
||||||
|
return scheduledTests.value.filter(test =>
|
||||||
|
test.title.toLowerCase().includes(search.value.toLowerCase())
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
const filteredCompletedTests = computed(() => {
|
||||||
|
if (!search.value) return completedTests.value;
|
||||||
|
return completedTests.value.filter(test =>
|
||||||
|
test.title.toLowerCase().includes(search.value.toLowerCase())
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
const filteredTests = computed(() => {
|
||||||
|
if (!search.value) return tests.value.filter(test => new Date(test.date) > currentDate);
|
||||||
|
return tests.value.filter(test => new Date(test.date) > currentDate)
|
||||||
|
.filter((test) =>
|
||||||
|
test.title.toLowerCase().includes(search.value.toLowerCase())
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
activeTab,
|
||||||
|
search,
|
||||||
|
headers,
|
||||||
|
tests,
|
||||||
|
filteredTests,
|
||||||
|
filteredScheduledTests,
|
||||||
|
filteredCompletedTests,
|
||||||
|
scheduledTests,
|
||||||
|
completedTests,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
.v-data-table__wrapper {
|
||||||
|
overflow-x: auto;
|
||||||
</style>
|
}
|
||||||
|
</style>
|
||||||
@@ -7,22 +7,22 @@
|
|||||||
align="center">
|
align="center">
|
||||||
<v-tab v-for="x in tabs" :key="x.value" :value="x.value">{{ x.text }}</v-tab>
|
<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-tabs>
|
||||||
|
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col class="pa-0 overflow-hidden">
|
<v-col class="pa-0 overflow-hidden">
|
||||||
|
|
||||||
<v-window v-model="currentTab" class="h-100">
|
<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-tabs-window-item v-for="x in ['active','completed']" :value="x" class="h-100 overflow-auto">
|
||||||
<v-row class="mx-2">
|
<v-row v-if="sortedVotes.length > 0" class="mx-2">
|
||||||
<v-col
|
<v-col
|
||||||
v-for="voting in sortedVotes"
|
v-for="voting in sortedVotes"
|
||||||
:key="voting.id"
|
:key="voting.id"
|
||||||
cols="12"
|
cols="12"
|
||||||
lg="3"
|
lg="3"
|
||||||
md="4"
|
md="4"
|
||||||
>
|
>
|
||||||
<VoteCardVue
|
<VoteCardVue
|
||||||
:isFinished="currentTab==='active'"
|
:isFinished="currentTab==='active'"
|
||||||
@@ -33,13 +33,14 @@
|
|||||||
/>
|
/>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
|
<NoneVote v-else :current="currentTab == 'active' ? 'Текущих' : 'Завершенных'"/>
|
||||||
</v-tabs-window-item>
|
</v-tabs-window-item>
|
||||||
<!-- Конструктор -->
|
<!-- Конструктор -->
|
||||||
<v-tabs-window-item v-if="accountStore.user.is_staff" class="h-100 overflow-auto" value="constructor">
|
<v-tabs-window-item v-if="accountStore.user.is_staff" class="h-100 overflow-auto" value="constructor">
|
||||||
<VoteConstructor @updating="updating"/>
|
<VoteConstructor @updating="updating" ref="constructor"/>
|
||||||
</v-tabs-window-item>
|
</v-tabs-window-item>
|
||||||
</v-window>
|
</v-window>
|
||||||
|
|
||||||
<!-- Модальные окна -->
|
<!-- Модальные окна -->
|
||||||
<v-dialog v-model="voteModal" @click:outside="closeModal">
|
<v-dialog v-model="voteModal" @click:outside="closeModal">
|
||||||
<CurrentVote :data="res" @closer="closeModal"/>
|
<CurrentVote :data="res" @closer="closeModal"/>
|
||||||
@@ -48,9 +49,6 @@
|
|||||||
<v-dialog v-model="resultsModal" max-width="1200px" @click:outside="closeModal">
|
<v-dialog v-model="resultsModal" max-width="1200px" @click:outside="closeModal">
|
||||||
<v-card>
|
<v-card>
|
||||||
<VoteResult :data="result" @closer="closeModal" />
|
<VoteResult :data="result" @closer="closeModal" />
|
||||||
<v-card-actions>
|
|
||||||
<v-btn @click="closeModal">Закрыть</v-btn>
|
|
||||||
</v-card-actions>
|
|
||||||
</v-card>
|
</v-card>
|
||||||
</v-dialog>
|
</v-dialog>
|
||||||
</v-col>
|
</v-col>
|
||||||
@@ -63,24 +61,25 @@ import {computed, ref, watch} from "vue";
|
|||||||
import VoteConstructor from "@/components/vote/VoteConstructor.vue";
|
import VoteConstructor from "@/components/vote/VoteConstructor.vue";
|
||||||
import CurrentVote from "@/components/vote/CurrentVote.vue";
|
import CurrentVote from "@/components/vote/CurrentVote.vue";
|
||||||
import VoteCardVue from "@/components/vote/VoteCard.vue";
|
import VoteCardVue from "@/components/vote/VoteCard.vue";
|
||||||
|
import NoneVote from "@/components/vote/NoneVote.vue"
|
||||||
import {useRoute, useRouter} from "vue-router";
|
import {useRoute, useRouter} from "vue-router";
|
||||||
import VoteResult from "@/components/vote/VoteResult.vue";
|
import VoteResult from "@/components/vote/VoteResult.vue";
|
||||||
import {deleteVote, getVoteDetail, getVoteResult, getVotes} from "@/utils/axios-api";
|
import {deleteVote, getVoteDetail, getVoteResult, getVotes} from "@/utils/axios-api";
|
||||||
import {formatDate} from "@vueuse/shared";
|
// import {formatDate} from "@vueuse/shared";
|
||||||
import { useAccountStore } from "@/store/AccountStore";
|
import { useAccountStore } from "@/store/AccountStore";
|
||||||
import {pagecounter} from '@/utils/universal_functions'
|
import {pagecounter} from '@/utils/universal_functions'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
methods: {formatDate},
|
|
||||||
|
|
||||||
components: {CurrentVote, VoteConstructor, VoteCardVue, VoteResult},
|
components: {CurrentVote, VoteConstructor, VoteCardVue, VoteResult, NoneVote},
|
||||||
setup() {
|
setup() {
|
||||||
pagecounter()
|
pagecounter()
|
||||||
const accountStore = useAccountStore();
|
const accountStore = useAccountStore();
|
||||||
const tabs = [
|
const tabs = [
|
||||||
{value: "active", text: 'Текущие голосования'},
|
{value: "active", text: 'Текущие голосования'},
|
||||||
{value: "completed", text: 'Завершенные голосования'},
|
{value: "completed", text: 'Завершенные голосования'},
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
const currentTab = ref("active");
|
const currentTab = ref("active");
|
||||||
@@ -89,6 +88,7 @@ export default {
|
|||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const res = ref(null);
|
const res = ref(null);
|
||||||
const result = ref(null);
|
const result = ref(null);
|
||||||
|
const constructor = ref(null)
|
||||||
|
|
||||||
const updating = async (param) => {
|
const updating = async (param) => {
|
||||||
const data = await getVotes(param);
|
const data = await getVotes(param);
|
||||||
@@ -112,7 +112,7 @@ export default {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Ошибка при загрузке данных голосования:", error);
|
console.error("Ошибка при загрузке данных голосования:", error);
|
||||||
// res.value = {};
|
// res.value = {};
|
||||||
|
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -163,7 +163,15 @@ export default {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
watch(currentTab, async () => await updating(currentTab.value))
|
watch(currentTab, async () => {
|
||||||
|
if (currentTab.value !== 'constructor') {
|
||||||
|
await updating(currentTab.value)
|
||||||
|
console.log(constructor.value, '!!!');
|
||||||
|
if (constructor.value !== null) {
|
||||||
|
constructor.value.resetForm()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => route,
|
() => route,
|
||||||
@@ -205,7 +213,8 @@ export default {
|
|||||||
updating,
|
updating,
|
||||||
res,
|
res,
|
||||||
tabs,
|
tabs,
|
||||||
result
|
result,
|
||||||
|
constructor
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,27 +1,97 @@
|
|||||||
<template>
|
<template>
|
||||||
<!-- <v-container>
|
<v-container :fluid="true">
|
||||||
<TimerUI :endTime="end" />
|
<v-tabs v-model="activeTab" class="mb-2 text-teal-darken-4">
|
||||||
<SmallTimer :endTime="end"/>
|
<v-tab v-for="tab in tabs" :key="tab.value" :value="tab.value"> {{ tab.title }} </v-tab>
|
||||||
</v-container> -->
|
</v-tabs>
|
||||||
<VoteCard />
|
<v-tabs-window v-model="activeTab" class="border-t-thin">
|
||||||
|
<!-- Вкладка назначенные -->
|
||||||
|
<v-tabs-window-item class="my-2 ">
|
||||||
|
<CatalogTest title="Назначенные" :activeTab="activeTab" :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>
|
||||||
|
<!-- Вкладка завершенных -->
|
||||||
|
<v-tabs-window-item>
|
||||||
|
<CatalogTest title="Завершенные" :activeTab="activeTab" :testingCard="getAllTests">
|
||||||
|
<template #results>
|
||||||
|
<div>
|
||||||
|
<v-icon icon="mdi-calendar-clock" size="large" />
|
||||||
|
<span class="ml-1">12354</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<template #buttons>
|
||||||
|
<v-btn color="#00897B1F" class="mr-2 text-teal-darken-1" elevation="0">
|
||||||
|
Результаты
|
||||||
|
</v-btn>
|
||||||
|
</template>
|
||||||
|
</CatalogTest>
|
||||||
|
</v-tabs-window-item>
|
||||||
|
<!-- Вкладка каталога -->
|
||||||
|
<v-tabs-window-item>
|
||||||
|
<CatalogTest title="Каталог" :activeTab="activeTab" :testingCard="getAllTests">
|
||||||
|
<template #buttons>
|
||||||
|
<v-btn color="#00897B1F" class="mr-2 text-teal-darken-1" elevation="0">
|
||||||
|
Тренироваться
|
||||||
|
</v-btn>
|
||||||
|
</template>
|
||||||
|
</CatalogTest>
|
||||||
|
</v-tabs-window-item>
|
||||||
|
</v-tabs-window>
|
||||||
|
{{ getAllTests }}
|
||||||
|
</v-container>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// import TimerUI from "@/components/secret/TimerUI.vue"
|
import CatalogTest from "@/components/testing/CatalogTest.vue";
|
||||||
// import SmallTimer from "@/components/secret/SmallTimer.vue"
|
import { axiosApiInstance } from "@/utils/axios-api";
|
||||||
import VoteCard from "@/components/vote/VoteCard.vue"
|
|
||||||
|
import { ref, computed, watch } from "vue"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
// TimerUI,
|
CatalogTest
|
||||||
// SmallTimer,
|
|
||||||
VoteCard
|
|
||||||
},
|
},
|
||||||
setup() {
|
setup() {
|
||||||
// const end = new Date(2025, 0, 14, 15, 58, 5)
|
const activeTab = ref(0);
|
||||||
|
const currentTest = ref('')
|
||||||
|
|
||||||
|
const getAllTests = ref([])
|
||||||
|
|
||||||
|
const getTestById = () => {
|
||||||
|
let status = activeTab.value == 0 ? '?status=active' : activeTab.value == 1 ? '?status=completed' : ''
|
||||||
|
axiosApiInstance.get(`/api/tests/gettests/${status}`).then(resp => getAllTests.value = resp.data).finally(() => {
|
||||||
|
if (activeTab.value == 0) {
|
||||||
|
currentTest.value = getAllTests.value.length
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
getTestById()
|
||||||
|
|
||||||
|
watch (() => activeTab.value,
|
||||||
|
() => {
|
||||||
|
getTestById()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
const tabs = computed(() => [
|
||||||
|
{ value: 0, title: `Назначенные (${currentTest.value})`, },
|
||||||
|
{ value: 1, title: 'Завершенные', },
|
||||||
|
{ value: 2, title: 'Каталог', },
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
// end
|
activeTab,
|
||||||
|
tabs,
|
||||||
|
getAllTests,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user