Merge branch 'develop'
This commit is contained in:
commit
12b86a9201
174 files changed
+12054
-1022
No files matched your search
@@ -5,7 +5,6 @@ from django.conf import settings
|
||||
from ckeditor.fields import RichTextField
|
||||
from ckeditor_uploader.fields import RichTextUploadingField
|
||||
from datetime import date
|
||||
from vote.models import Vote
|
||||
from django.utils.timezone import now
|
||||
|
||||
class BaseSender(models.Model):
|
||||
@@ -41,7 +40,6 @@ class News(models.Model):
|
||||
cdate =models.DateTimeField(default=datetime.now, 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='Изображение')
|
||||
vote = models.ForeignKey(Vote, on_delete=models.CASCADE, null=True, blank=True)
|
||||
|
||||
class Meta:
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ class CarouselsAPIView(ListAPIView):
|
||||
|
||||
result = CarouselsSerializer(queryset, many= True).data
|
||||
|
||||
manbrd = DictEmployee.objects.filter(birthdate__month=date.today().month, birthdate__day__gte=date.today().day).order_by('birthdate__day')
|
||||
manbrd = DictEmployee.objects.filter(birthdate__month=date.today().month, birthdate__day__gte=date.today().day, deleted=0).order_by('birthdate__day')
|
||||
dr_img = BaseSender.objects.update_or_create(name="День рождения", defaults={'name':"День рождения"})
|
||||
mess = ''
|
||||
if len(manbrd) > 0 :
|
||||
|
||||
+14
-16
@@ -50,9 +50,20 @@ class TestAnswer(models.Model):
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
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):
|
||||
return self.test.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)
|
||||
testing = models.ForeignKey(Testing, on_delete=models.CASCADE)
|
||||
score = models.FloatField(verbose_name='Результат', default=0.0)
|
||||
attempt_number = models.IntegerField(verbose_name='Номер попытки', default=1)
|
||||
completion_date = models.DateTimeField(default=datetime.datetime.now, verbose_name="Дата прохождения теста")
|
||||
@@ -71,17 +82,4 @@ class TestResult(models.Model):
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Результат"
|
||||
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):
|
||||
return self.test.name
|
||||
verbose_name_plural = "Результаты"
|
||||
@@ -31,7 +31,8 @@ class TestAnswerSerializer(serializers.ModelSerializer):
|
||||
return validated_data
|
||||
|
||||
def to_representation(self, instance):
|
||||
user_login = self.context['request'].user.username
|
||||
# user_login = self.context['request'].user.username
|
||||
user_login = '9966-00-125'
|
||||
representation = super().to_representation(instance)
|
||||
representation['right_wrong'] = self.encrypt_data(str(representation['right_wrong']), user_login)
|
||||
|
||||
@@ -86,4 +87,11 @@ class TestsSerializer(serializers.ModelSerializer):
|
||||
if user.is_authenticated:
|
||||
validated_data['author'] = user
|
||||
|
||||
return super().create(validated_data)
|
||||
return super().create(validated_data)
|
||||
|
||||
class TestInfoSerializer(serializers.Serializer):
|
||||
test = TestsSerializer(read_only=True)
|
||||
# test_answers = TestAnswerSerializer(many=True, read_only=True)
|
||||
score = serializers.IntegerField(read_only=True)
|
||||
is_passed = serializers.BooleanField(read_only=True)
|
||||
test_answers = TestAnswerSerializer(many=True, read_only=True)
|
||||
@@ -5,7 +5,7 @@ from .views import *
|
||||
urlpatterns = [
|
||||
path('testdetail/<int:id>/', TestDetail.as_view(),name='TestDetail'),
|
||||
path('gettests/', GetTests.as_view(), name="GetTests"),
|
||||
path('gettesting/', GetTesting.as_view(), name="GetTesting"),
|
||||
path('testresultcreate/', TestResultCreate.as_view(), name="TestResultCreate"),
|
||||
# path('gettesting/', GetTesting.as_view(), name="GetTesting"),
|
||||
path('testresultview/', TestResultView.as_view(), name="TestResultView"),
|
||||
]
|
||||
|
||||
+108
-66
@@ -19,17 +19,37 @@ import base64
|
||||
import hashlib
|
||||
from cryptography.fernet import Fernet
|
||||
from django.db.models import F
|
||||
from drf_yasg import openapi
|
||||
from drf_yasg.utils import swagger_auto_schema
|
||||
|
||||
class GetTests(generics.ListAPIView):
|
||||
queryset = Test.objects.all()
|
||||
serializer_class = TestsSerializer
|
||||
pagination_class = None
|
||||
|
||||
@swagger_auto_schema(
|
||||
operation_description="""Получить список тестов по статусу
|
||||
*Нужно авторизоваться!""",
|
||||
manual_parameters=[
|
||||
openapi.Parameter(
|
||||
'status',
|
||||
openapi.IN_QUERY,
|
||||
description="Статус тестов (например, 'active', 'completed'). Пустое значение вернет все тесты",
|
||||
type=openapi.TYPE_STRING,
|
||||
required=False,
|
||||
),
|
||||
],
|
||||
responses={
|
||||
200: "success",
|
||||
400: 'error',
|
||||
}
|
||||
)
|
||||
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:
|
||||
if status is not None:
|
||||
self.set_attemps_number(user, tests)
|
||||
serialized_tests = self.get_serializer(tests, many=True).data
|
||||
|
||||
@@ -55,8 +75,11 @@ class GetTests(generics.ListAPIView):
|
||||
return status_filters.get(status, Test.objects.none()).order_by('dateend')
|
||||
|
||||
def set_attemps_number(self, user, tests):
|
||||
attempt_counts = TestAttempt.objects.filter(testing__user=user, testing__test__in=tests).values('testing__test').annotate(count=Count('testing__test'))
|
||||
attempt_counts = {item['testing__test']: item['count'] for item in attempt_counts}
|
||||
|
||||
for test in tests:
|
||||
test.attemps_number = get_attempt_count(user=user, test=test)
|
||||
test.attemps_number = test.attemps_number - attempt_counts.get(test.id, 0)
|
||||
|
||||
class TestDetail(generics.RetrieveUpdateDestroyAPIView):
|
||||
queryset = Test.objects.all()
|
||||
@@ -73,92 +96,110 @@ class TestDetail(generics.RetrieveUpdateDestroyAPIView):
|
||||
|
||||
return Response(test_serialized)
|
||||
|
||||
# class TestListCreate(generics.ListCreateAPIView):
|
||||
# queryset = Test.objects.all()
|
||||
# serializer_class = TestSerializer
|
||||
|
||||
# class GetTesting(APIView):
|
||||
|
||||
# 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)
|
||||
# tests = Testing.objects.filter(user=user)
|
||||
# test_names = {test.id: test.test.name for test in tests}
|
||||
# serializer = TestingSeriaizer(tests, many=True).data
|
||||
# for test in serializer:
|
||||
# if test['id'] in test_names:
|
||||
# test['test_name'] = test_names[test['id']]
|
||||
# return Response(serializer)
|
||||
|
||||
# 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):
|
||||
user = request.user
|
||||
tests = Testing.objects.filter(user=user)
|
||||
test_names = {test.id: test.test.name for test in tests}
|
||||
serializer = TestingSeriaizer(tests, many=True).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):
|
||||
class TestResultView(generics.ListCreateAPIView):
|
||||
|
||||
queryset = TestResult.objects.all()
|
||||
serializer_class = TestResultSerializer
|
||||
pagination_class = None
|
||||
|
||||
@swagger_auto_schema(
|
||||
operation_description="""Получить результаты тестов
|
||||
*Нужно авторизоваться!""",
|
||||
manual_parameters=[
|
||||
openapi.Parameter(
|
||||
'id',
|
||||
openapi.IN_QUERY,
|
||||
description="ID теста",
|
||||
type=openapi.TYPE_INTEGER,
|
||||
required=True,
|
||||
),
|
||||
],
|
||||
responses={
|
||||
200: "success",
|
||||
400: 'error',
|
||||
}
|
||||
)
|
||||
def get(self, request, *args, **kwargs):
|
||||
user = request.user
|
||||
# user = User.objects.get(username = "9966-00-125")
|
||||
test_id = request.GET.get('id')
|
||||
last_attempt = TestAttempt.objects.filter(testing__user=user, testing__test__id=test_id).order_by('-completion_date').first()
|
||||
answer_ids = TestResult.objects.filter(attempt=last_attempt).values_list('answer__id', flat=True)
|
||||
test_info = self.get_test_info(answer_ids)
|
||||
return Response(data={'score': test_info['score'], 'answered_questions_total': test_info['answered_questions_total']})
|
||||
|
||||
@swagger_auto_schema(
|
||||
operation_description=""" Сохранить результаты тестов
|
||||
*Нужно авторизоваться!""",
|
||||
manual_parameters=[
|
||||
openapi.Parameter(
|
||||
'status',
|
||||
openapi.IN_QUERY,
|
||||
description="Статус тестов (например, 'testing'). Пустое значение - режим тренировки",
|
||||
type=openapi.TYPE_STRING,
|
||||
required=False,
|
||||
),
|
||||
],
|
||||
request_body=openapi.Schema(
|
||||
type=openapi.TYPE_ARRAY,
|
||||
items=openapi.Schema(
|
||||
type=openapi.TYPE_OBJECT,
|
||||
properties={
|
||||
'answer': openapi.Schema(type=openapi.TYPE_INTEGER, description='ID ответа')
|
||||
},
|
||||
),
|
||||
),
|
||||
responses={
|
||||
200: "success",
|
||||
400: 'error',
|
||||
}
|
||||
)
|
||||
def post(self, request, *args, **kwargs):
|
||||
user = request.user
|
||||
# user = User.objects.get(username = "9966-00-125")
|
||||
|
||||
test_info = self.get_test_info(request)
|
||||
test_attempt = self.create_test_attempt(user, test_info)
|
||||
status = request.query_params.get('status')
|
||||
answer_ids = [item['answer'] for item in request.data]
|
||||
test_info = self.get_test_info(answer_ids)
|
||||
if status == 'testing':
|
||||
test_attempt = self.create_test_attempt(user, test_info)
|
||||
|
||||
serializer = self.get_serializer(data=request.data, many=True)
|
||||
if serializer.is_valid():
|
||||
serializer.save(attempt=test_attempt)
|
||||
self.update_testing(user, test_info)
|
||||
serializer = self.get_serializer(data=request.data, many=True)
|
||||
if serializer.is_valid():
|
||||
serializer.save(attempt=test_attempt)
|
||||
self.update_testing(user, test_info)
|
||||
|
||||
return Response(test_info['is_passed'])
|
||||
return Response(data={'score': test_info['score'], 'answered_questions_total': test_info['answered_questions_total']})
|
||||
|
||||
def create_test_attempt(self, user, test_info):
|
||||
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())
|
||||
testing = Testing.objects.get(user=user, test=test)
|
||||
attempt_count = get_attempt_count(testing)+ 1
|
||||
test_attempt = TestAttempt.objects.create(testing=testing , 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})
|
||||
Testing.objects.update_or_create(user=user, test=test, defaults = {"test_passed":test_passed})
|
||||
|
||||
def get_test_info(self, request):
|
||||
def get_test_info(self, answer_ids):
|
||||
|
||||
answer_ids = [item['answer'] for item in request.data]
|
||||
test_answers = TestAnswer.objects.filter(id__in=answer_ids)
|
||||
test = test_answers[0].question.test
|
||||
answered_questions_total = test_answers.values('question').distinct().count()
|
||||
|
||||
correct_questions = sum(
|
||||
TestAnswer.objects.filter(
|
||||
@@ -175,9 +216,10 @@ class TestResultCreate(generics.ListCreateAPIView):
|
||||
result = {
|
||||
"is_passed": correct_questions >= pass_perc,
|
||||
"score": correct_questions,
|
||||
"test": test
|
||||
"test": test,
|
||||
"answered_questions_total": answered_questions_total,
|
||||
}
|
||||
return result
|
||||
|
||||
def get_attempt_count(user, test):
|
||||
return TestAttempt.objects.filter(user=user, test=test).count()
|
||||
def get_attempt_count(testing):
|
||||
return TestAttempt.objects.filter(testing=testing).count()
|
||||
@@ -2,6 +2,7 @@ from django.db import models
|
||||
from userauth.models import *
|
||||
from accounts.models import User
|
||||
import datetime
|
||||
from navigation.models import News
|
||||
# Create your models here.
|
||||
|
||||
class Vote(models.Model):
|
||||
@@ -10,10 +11,16 @@ class Vote(models.Model):
|
||||
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='Создатель голосования')
|
||||
news = models.ForeignKey(News, on_delete=models.CASCADE, null=True, blank=True, verbose_name='Новость')
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
def delete(self, *args, **kwargs):
|
||||
if self.news:
|
||||
self.news.delete()
|
||||
super().delete(*args, **kwargs)
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Голосование"
|
||||
verbose_name_plural = "Голосования"
|
||||
|
||||
+353
-126
@@ -1,232 +1,459 @@
|
||||
from rest_framework.views import APIView
|
||||
from rest_framework.response import Response
|
||||
from django.db.models import Count
|
||||
from django.db.models import Q
|
||||
from .models import *
|
||||
from userauth.models import *
|
||||
from .serializers 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 datetime import datetime, timezone
|
||||
from collections import defaultdict
|
||||
|
||||
from rest_framework.views import APIView
|
||||
from rest_framework.response import Response
|
||||
from rest_framework import generics
|
||||
|
||||
from django.db import DatabaseError
|
||||
from django.db.models import Count
|
||||
from accounts.models import User
|
||||
from navigation.models import News
|
||||
from userauth.models import DictDepartment, DictEmployee, EmployeeDepartment
|
||||
|
||||
from .models import Vote, Answer, Question, Result
|
||||
from .serializers import (
|
||||
VoteSerializer,
|
||||
VotesSerializer,
|
||||
DictEmployeeSerializer,
|
||||
ResultSerializer,
|
||||
)
|
||||
|
||||
|
||||
class GetVotes(APIView):
|
||||
"""
|
||||
Комментарий
|
||||
"""
|
||||
|
||||
def get(self, request):
|
||||
"""
|
||||
Комментарий
|
||||
"""
|
||||
user = request.user
|
||||
# user = User.objects.get(username='9966-00-125')
|
||||
now = datetime.now()
|
||||
status = request.query_params.get('status')
|
||||
|
||||
#
|
||||
|
||||
status = request.query_params.get("status")
|
||||
votes = self.get_votes_by_status(status, now)
|
||||
serialized_votes = VotesSerializer(votes, many=True).data
|
||||
questions_by_vote_id = self.get_questions_by_vote_id(votes)
|
||||
self.enrich_votes(serialized_votes, questions_by_vote_id, user)
|
||||
|
||||
return Response(serialized_votes)
|
||||
|
||||
def get_votes_by_status(self, status, now):
|
||||
"""
|
||||
Комментарий
|
||||
"""
|
||||
print(status)
|
||||
if status is None:
|
||||
return Vote.objects.all().order_by("dateend")
|
||||
|
||||
status_filters = {
|
||||
"active": Vote.objects.filter(dateend__gt=now),
|
||||
"completed": Vote.objects.filter(dateend__lt=now),
|
||||
}
|
||||
|
||||
return status_filters.get(status, Vote.objects.none()).order_by("dateend")
|
||||
|
||||
def get_questions_by_vote_id(self, votes):
|
||||
"""
|
||||
Комментарий
|
||||
"""
|
||||
questions = Question.objects.filter(vote__in=votes)
|
||||
|
||||
questions_by_vote_id = defaultdict(list)
|
||||
for question in questions:
|
||||
questions_by_vote_id[question.vote.id].append(question)
|
||||
return questions_by_vote_id
|
||||
|
||||
def enrich_votes(self, serialized_votes, questions_by_vote_id, user):
|
||||
"""
|
||||
Комментарий
|
||||
"""
|
||||
for vote in serialized_votes:
|
||||
vote['is_passed'] = self.has_participated(user, vote['id'])
|
||||
related_questions = questions_by_vote_id[vote['id']]
|
||||
vote['files'] = [question.file.url for question in related_questions if question.file]
|
||||
|
||||
return Response(serialized_votes)
|
||||
|
||||
def get_votes_by_status(self, status, now):
|
||||
print(status)
|
||||
if status is None:
|
||||
return Vote.objects.all().order_by('dateend')
|
||||
|
||||
status_filters = {
|
||||
'active': Vote.objects.filter(dateend__gt=now),
|
||||
'completed': Vote.objects.filter(dateend__lt=now),
|
||||
}
|
||||
|
||||
return status_filters.get(status, Vote.objects.none()).order_by('dateend')
|
||||
vote["is_passed"] = self.has_participated(user, vote["id"])
|
||||
related_questions = questions_by_vote_id[vote["id"]]
|
||||
vote["files"] = [
|
||||
question.file.url for question in related_questions if question.file
|
||||
]
|
||||
|
||||
def has_participated(self, employee, vote):
|
||||
return Result.objects.filter(user=employee, answer__question__vote=vote).exists()
|
||||
"""
|
||||
Комментарий
|
||||
"""
|
||||
return Result.objects.filter(
|
||||
user=employee, answer__question__vote=vote
|
||||
).exists()
|
||||
|
||||
|
||||
class VoteDetail(generics.RetrieveUpdateDestroyAPIView):
|
||||
"""
|
||||
Комментарий
|
||||
"""
|
||||
|
||||
queryset = Vote.objects.all()
|
||||
serializer_class = VoteSerializer
|
||||
lookup_url_kwarg = 'id'
|
||||
lookup_field = 'id'
|
||||
lookup_url_kwarg = "id"
|
||||
lookup_field = "id"
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
results = Result.objects.filter(answer__question__vote=kwargs['id'], user=request.user)
|
||||
if results:
|
||||
return Response({'status': 'error', 'message': 'voted'}, status=400)
|
||||
|
||||
try:
|
||||
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:
|
||||
return Response({'status': 'error', 'message': str(e)}, status=400)
|
||||
|
||||
answers_employee = Answer.objects.filter(question__vote=vote).filter(question__settings__choice="employee").values('name', 'question')
|
||||
"""
|
||||
Комментарий
|
||||
"""
|
||||
|
||||
answers_names = [item['name'] for item in answers_employee]
|
||||
question_ids = [item['question'] for item in answers_employee]
|
||||
|
||||
if answers_employee:
|
||||
employees_serializer = get_employees_serializer(answers_names)
|
||||
employee_dict = {employee['id']: employee for employee in employees_serializer}
|
||||
# if self.check_user_vote(kwargs['id'], User.objects.get(username='9966-00-125')):
|
||||
if self.check_user_vote(kwargs["id"], request.user):
|
||||
return Response({"status": "error", "message": "voted"}, status=400)
|
||||
|
||||
vote = self.get_vote(kwargs["id"])
|
||||
if isinstance(vote, Response):
|
||||
return vote
|
||||
|
||||
answers_employee = self.get_employee_answers(vote)
|
||||
answers_names = [item["name"] for item in answers_employee]
|
||||
|
||||
employee_dict = self.serialize_employees(answers_names)
|
||||
|
||||
serialized_data = self.retrieve(request, *args, **kwargs).data
|
||||
|
||||
for question in serialized_data['questions']:
|
||||
for answer in question['answers']:
|
||||
if question['id'] in question_ids:
|
||||
if answer['name'] in answers_names:
|
||||
answer['employee'] = employee_dict.get(int(answer['name']))
|
||||
self.add_employee_info(
|
||||
serialized_data, answers_employee, answers_names, employee_dict
|
||||
)
|
||||
|
||||
return Response(serialized_data)
|
||||
|
||||
def check_user_vote(self, vote_id, user):
|
||||
"""
|
||||
Комментарий
|
||||
"""
|
||||
results = Result.objects.filter(answer__question__vote=vote_id, user=user)
|
||||
return results.exists()
|
||||
|
||||
def get_vote(self, vote_id):
|
||||
"""
|
||||
Получить незавершенное голосование
|
||||
"""
|
||||
try:
|
||||
vote = Vote.objects.get(id=vote_id)
|
||||
if vote.dateend < datetime.now(timezone.utc):
|
||||
return Response(
|
||||
{"status": "error", "message": "Voting is over"}, status=400
|
||||
)
|
||||
return vote
|
||||
except Vote.DoesNotExist as e:
|
||||
return Response({"status": "error", "message": str(e)}, status=400)
|
||||
|
||||
def get_employee_answers(self, vote):
|
||||
"""
|
||||
Комментарий
|
||||
"""
|
||||
return (
|
||||
Answer.objects.filter(question__vote=vote)
|
||||
.filter(question__settings__choice="employee")
|
||||
.values("name", "question")
|
||||
)
|
||||
|
||||
def serialize_employees(self, answers_names):
|
||||
"""
|
||||
Комментарий
|
||||
"""
|
||||
|
||||
employees_serializer = get_employees_serializer(answers_names)
|
||||
return {employee["id"]: employee for employee in employees_serializer}
|
||||
|
||||
def add_employee_info(
|
||||
self, serialized_data, answers_employee, answers_names, employee_dict
|
||||
):
|
||||
"""
|
||||
Комментарий
|
||||
"""
|
||||
question_ids = [item["question"] for item in answers_employee]
|
||||
|
||||
for question in serialized_data["questions"]:
|
||||
for answer in question["answers"]:
|
||||
if question["id"] in question_ids:
|
||||
if answer["name"] in answers_names:
|
||||
answer["employee"] = employee_dict.get(int(answer["name"]))
|
||||
|
||||
|
||||
class VoteCreate(APIView):
|
||||
"""
|
||||
Комментарий
|
||||
"""
|
||||
|
||||
def post(self, request):
|
||||
"""
|
||||
Комментарий
|
||||
"""
|
||||
try:
|
||||
vote = self.create_vote(request)
|
||||
self.create_news(request, vote)
|
||||
return Response({'status': 'success', 'message': 'Vote and news created successfully.'}, status=200)
|
||||
except Exception as e:
|
||||
if request.data.get("news") == "true":
|
||||
self.create_news(request, vote)
|
||||
return Response(
|
||||
{"status": "success", "message": "Vote and news created successfully."},
|
||||
status=200,
|
||||
)
|
||||
except ValueError as e:
|
||||
|
||||
return Response({"status": "error", "message": str(e)}, status=400)
|
||||
|
||||
except DatabaseError as e:
|
||||
print(e)
|
||||
return Response({'status': 'error', 'message': str(e)}, status=400)
|
||||
return Response({"status": "error", "message": str(e)}, status=400)
|
||||
|
||||
def create_vote(self, request):
|
||||
"""
|
||||
Комментарий
|
||||
"""
|
||||
user = request.user
|
||||
|
||||
vote = Vote.objects.create(
|
||||
name=request.data['title'],
|
||||
description=request.data['description'],
|
||||
datestart=request.data['startDate'],
|
||||
dateend=request.data['endDate'],
|
||||
name=request.data["title"],
|
||||
description=request.data["description"],
|
||||
datestart=request.data["startDate"],
|
||||
dateend=request.data["endDate"],
|
||||
author=user,
|
||||
)
|
||||
|
||||
questions_files = {file.name: file for file in request.FILES.getlist('questionsfiles')}
|
||||
answers_files = {file.name: file for file in request.FILES.getlist('answersfiles')}
|
||||
questions_files = {
|
||||
file.name: file for file in request.FILES.getlist("questionsfiles")
|
||||
}
|
||||
answers_files = {
|
||||
file.name: file for file in request.FILES.getlist("answersfiles")
|
||||
}
|
||||
|
||||
questions = json.loads(request.data['questions'])
|
||||
questions = json.loads(request.data["questions"])
|
||||
for count, question_data in enumerate(questions, start=1):
|
||||
question_image = questions_files.get(question_data['image']['name']) if 'image' in question_data and question_data['image'] is not None else None
|
||||
question_image = (
|
||||
questions_files.get(question_data["image"]["name"])
|
||||
if "image" in question_data and question_data["image"] is not None
|
||||
else None
|
||||
)
|
||||
question = Question.objects.create(
|
||||
name=question_data['text'],
|
||||
name=question_data["text"],
|
||||
vote=vote,
|
||||
file=question_image,
|
||||
numb=count,
|
||||
settings=question_data.get('settings', {}),
|
||||
settings=question_data.get("settings", {}),
|
||||
)
|
||||
|
||||
for answer in question_data['answers']:
|
||||
answer_image = answers_files.get(answer['image']['name']) if 'image' in answer and answer['image'] is not None else None
|
||||
for answer in question_data["answers"]:
|
||||
answer_image = (
|
||||
answers_files.get(answer["image"]["name"])
|
||||
if "image" in answer and answer["image"] is not None
|
||||
else None
|
||||
)
|
||||
Answer.objects.create(
|
||||
name=answer['text'],
|
||||
file=answer_image,
|
||||
question=question
|
||||
name=answer["text"], file=answer_image, question=question
|
||||
)
|
||||
|
||||
return vote
|
||||
|
||||
def create_news(self, request, vote):
|
||||
"""
|
||||
Комментарий
|
||||
"""
|
||||
|
||||
formatted_date = datetime.strptime(request.data["endDate"][:-1], "%Y-%m-%dT%H:%M:%S.%f").strftime("%d.%m.%Y %H:%M")
|
||||
vote_url = make_clickable(request.data['title'], f"/vote/voting/{vote.id}")
|
||||
formatted_date = datetime.strptime(
|
||||
request.data["endDate"][:-1], "%Y-%m-%dT%H:%M:%S.%f"
|
||||
).strftime("%d.%m.%Y %H:%M")
|
||||
vote_url = make_clickable(request.data["title"], f"/vote/voting/{vote.id}")
|
||||
|
||||
news = News(
|
||||
title = 'Пройдите голосование!',
|
||||
text = f'Пройдите голосование "{vote_url}" до {formatted_date}',
|
||||
cdate = request.data['startDate'],
|
||||
author = request.user,
|
||||
link = os.path.join('defaultimg','vote.png'),
|
||||
vote = vote
|
||||
title="Пройдите голосование!",
|
||||
text=f'Пройдите голосование "{vote_url}" до {formatted_date}',
|
||||
cdate=request.data["startDate"],
|
||||
author=request.user,
|
||||
link=os.path.join("defaultimg", "vote.png"),
|
||||
)
|
||||
news.save()
|
||||
news.save()
|
||||
vote.news = news
|
||||
vote.save()
|
||||
|
||||
|
||||
def make_clickable(text, url):
|
||||
"""
|
||||
Комментарий
|
||||
"""
|
||||
text = html.escape(text)
|
||||
anchor = f'<a href="{html.escape(url)}">{text}</a>'
|
||||
return anchor
|
||||
|
||||
|
||||
class GetDictEmployee(APIView):
|
||||
"""
|
||||
Комментарий
|
||||
"""
|
||||
|
||||
def get(self, request):
|
||||
"""
|
||||
Комментарий
|
||||
"""
|
||||
employees = DictEmployee.objects.filter(deleted=0)
|
||||
set_real_departments(employees)
|
||||
employees_serializer = DictEmployeeSerializer(employees, many=True).data
|
||||
return Response(employees_serializer)
|
||||
|
||||
|
||||
|
||||
class GetResults(APIView):
|
||||
"""
|
||||
Комментарий
|
||||
"""
|
||||
|
||||
def get(self, request):
|
||||
vote_id = request.GET.get('id')
|
||||
try:
|
||||
vote = Vote.objects.get(id=vote_id)
|
||||
except Vote.DoesNotExist:
|
||||
return Response({'status': 'error', 'message': 'Vote not found'}, status=404)
|
||||
"""
|
||||
Комментарий
|
||||
"""
|
||||
vote_id = request.GET.get("id")
|
||||
vote = self.get_vote(vote_id)
|
||||
if isinstance(vote, Response):
|
||||
return vote
|
||||
|
||||
serialized_data = VoteSerializer(vote).data
|
||||
answers_employee = Answer.objects.filter(
|
||||
question__vote=vote,
|
||||
question__settings__choice="employee"
|
||||
).values('name', 'question')
|
||||
|
||||
answers_names = [item['name'] for item in answers_employee]
|
||||
question_ids = [item['question'] for item in answers_employee]
|
||||
answers_employee = self.get_employee_answers(vote)
|
||||
answers_names = [item["name"] for item in answers_employee]
|
||||
employee_dict = self.create_employee_dict(answers_names)
|
||||
result_dict = self.get_answer_counts(vote)
|
||||
info = {
|
||||
"serialized_data": serialized_data,
|
||||
"answers_employee": answers_employee,
|
||||
"answers_names": answers_names,
|
||||
"employee_dict": employee_dict,
|
||||
"result_dict": result_dict,
|
||||
}
|
||||
self.add_employee_info(info)
|
||||
|
||||
employee_dict = {}
|
||||
if answers_employee:
|
||||
employees_serializer = get_employees_serializer(answers_names)
|
||||
employee_dict = {employee['id']: employee for employee in employees_serializer}
|
||||
|
||||
results = Result.objects.filter(
|
||||
answer__question__vote=vote
|
||||
).values('answer_id').annotate(count=Count('id'))
|
||||
|
||||
result_dict = {int(result['answer_id']): result['count'] for result in results}
|
||||
|
||||
for question in serialized_data['questions']:
|
||||
for answer in question['answers']:
|
||||
answer['count'] = result_dict.get(int(answer['id']), 0)
|
||||
if question['id'] in question_ids:
|
||||
if answer['name'] in answers_names:
|
||||
answer['employee'] = employee_dict.get(int(answer['name']))
|
||||
|
||||
users = Result.objects.filter(answer__question__vote=vote).values('user_id')
|
||||
users = User.objects.filter(created_at__lt=vote.dateend).exclude(id__in=users)
|
||||
employee_ids = users.values_list('user_id', flat=True)
|
||||
serialized_data['nonvoting'] = get_employees_serializer(employee_ids)
|
||||
serialized_data["nonvoting"] = self.get_non_voting_employees(vote)
|
||||
|
||||
return Response(serialized_data)
|
||||
|
||||
|
||||
def get_vote(self, vote_id):
|
||||
"""
|
||||
Комментарий
|
||||
"""
|
||||
try:
|
||||
vote = Vote.objects.get(id=vote_id)
|
||||
return vote
|
||||
except Vote.DoesNotExist:
|
||||
return Response(
|
||||
{"status": "error", "message": "Vote not found"}, status=404
|
||||
)
|
||||
|
||||
def get_employee_answers(self, vote):
|
||||
"""
|
||||
Комментарий
|
||||
"""
|
||||
answers_employee = Answer.objects.filter(
|
||||
question__vote=vote, question__settings__choice="employee"
|
||||
).values("name", "question")
|
||||
|
||||
return answers_employee
|
||||
|
||||
def create_employee_dict(self, answers_names):
|
||||
"""
|
||||
Комментарий
|
||||
"""
|
||||
if not answers_names:
|
||||
return {}
|
||||
|
||||
employees_serializer = get_employees_serializer(answers_names)
|
||||
return {employee["id"]: employee for employee in employees_serializer}
|
||||
|
||||
def get_answer_counts(self, vote):
|
||||
"""
|
||||
Комментарий
|
||||
"""
|
||||
results = (
|
||||
Result.objects.filter(answer__question__vote=vote)
|
||||
.values("answer_id")
|
||||
.annotate(count=Count("id"))
|
||||
)
|
||||
|
||||
return {int(result["answer_id"]): result["count"] for result in results}
|
||||
|
||||
def add_employee_info(self, info):
|
||||
"""
|
||||
info ={serialized_data, answers_employee, answers_names, employee_dict, result_dict}
|
||||
Комментарий
|
||||
"""
|
||||
|
||||
serialized_data = info.get("serialized_data")
|
||||
answers_employee = info.get("answers_employee")
|
||||
answers_names = info.get("answers_names")
|
||||
employee_dict = info.get("employee_dict")
|
||||
result_dict = info.get("result_dict")
|
||||
|
||||
question_ids = [item["question"] for item in answers_employee]
|
||||
for question in serialized_data["questions"]:
|
||||
for answer in question["answers"]:
|
||||
answer["count"] = result_dict.get(int(answer["id"]), 0)
|
||||
if question["id"] in question_ids:
|
||||
if answer["name"] in answers_names:
|
||||
answer["employee"] = employee_dict.get(int(answer["name"]))
|
||||
|
||||
def get_non_voting_employees(self, vote):
|
||||
"""
|
||||
Комментарий
|
||||
"""
|
||||
users = Result.objects.filter(answer__question__vote=vote).values("user_id")
|
||||
non_voting_users = User.objects.filter(created_at__lt=vote.dateend).exclude(
|
||||
id__in=users
|
||||
)
|
||||
employee_ids = non_voting_users.values_list("user_id", flat=True)
|
||||
return get_employees_serializer(employee_ids)
|
||||
|
||||
|
||||
class VoteResultCreate(generics.ListCreateAPIView):
|
||||
"""
|
||||
Комментарий
|
||||
"""
|
||||
|
||||
queryset = Result.objects.all()
|
||||
serializer_class = ResultSerializer
|
||||
|
||||
def create(self, request, *args, **kwargs):
|
||||
"""
|
||||
Комментарий
|
||||
"""
|
||||
serializer = self.get_serializer(data=request.data, many=True)
|
||||
if serializer.is_valid():
|
||||
serializer.save()
|
||||
return Response(serializer.data)
|
||||
|
||||
|
||||
def get_employees_serializer(ids):
|
||||
"""
|
||||
Комментарий
|
||||
"""
|
||||
employees = DictEmployee.objects.filter(id__in=ids)
|
||||
set_real_departments(employees)
|
||||
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}
|
||||
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']
|
||||
employee.department = department_map[employee.id]["name"]
|
||||
employee.id_dict_department = department_map[employee.id]["id"]
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "front",
|
||||
"version": "0.0.84",
|
||||
"version": "0.0.85",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "front",
|
||||
"version": "0.0.84",
|
||||
"version": "0.0.85",
|
||||
"dependencies": {
|
||||
"@ckeditor/ckeditor5-build-classic": "^44.1.0",
|
||||
"@ckeditor/ckeditor5-dev-translations": "^43.0.1",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "front",
|
||||
"version": "0.0.84",
|
||||
"version": "0.0.85",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
|
||||
+21
-27
@@ -2,51 +2,45 @@
|
||||
<router-view />
|
||||
</template>
|
||||
|
||||
<script setup >
|
||||
import {useAccountStore} from '@/store/AccountStore'
|
||||
const accountStore = useAccountStore()
|
||||
accountStore.setUser(accountStore.getuserFromStorage())
|
||||
|
||||
<script setup>
|
||||
import { useAccountStore } from '@/store/AccountStore';
|
||||
const accountStore = useAccountStore();
|
||||
|
||||
accountStore.setUser(accountStore.getuserFromStorage());
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
|
||||
::-webkit-scrollbar {
|
||||
width: 1px;
|
||||
height: 6px;
|
||||
width: 1px;
|
||||
height: 6px;
|
||||
}
|
||||
/* Track */
|
||||
::-webkit-scrollbar-track {
|
||||
|
||||
-webkit-border-radius: 6px;
|
||||
border-radius: 6px;
|
||||
-webkit-border-radius: 6px;
|
||||
border-radius: 6px;
|
||||
}
|
||||
/* Handle */
|
||||
::-webkit-scrollbar-thumb {
|
||||
-webkit-border-radius: 6px;
|
||||
border-radius: 6px;
|
||||
background: rgb(var(--v-theme-scrollbar))
|
||||
|
||||
-webkit-border-radius: 6px;
|
||||
border-radius: 6px;
|
||||
background: rgb(var(--v-theme-scrollbar));
|
||||
}
|
||||
::-webkit-scrollbar-thumb:window-inactive {
|
||||
background: rgb(var(--v-theme-scrollbar))
|
||||
background: rgb(var(--v-theme-scrollbar));
|
||||
}
|
||||
|
||||
|
||||
|
||||
.bggrad {
|
||||
background: linear-gradient(to top right, rgba(19,84,122,.8), rgba(128,208,199,.8));
|
||||
background: linear-gradient(to top right, rgba(19, 84, 122, 0.8), rgba(128, 208, 199, 0.8));
|
||||
}
|
||||
|
||||
.bgCard {
|
||||
/* #ffffff6b #ffffff8c*/
|
||||
background: #ffffff38 ;
|
||||
/* #ffffff6b #ffffff8c*/
|
||||
background: #ffffff38;
|
||||
}
|
||||
|
||||
.bgText {
|
||||
background: #ffffffb0;
|
||||
line-height: 2.1rem!important;
|
||||
|
||||
background: #ffffffb0;
|
||||
line-height: 2.1rem !important;
|
||||
}
|
||||
|
||||
.gap {
|
||||
@@ -54,11 +48,11 @@ import {useAccountStore} from '@/store/AccountStore'
|
||||
}
|
||||
|
||||
.w100 {
|
||||
max-width: 100%!important
|
||||
max-width: 100% !important;
|
||||
}
|
||||
|
||||
.bottom-alert {
|
||||
bottom: 10px;
|
||||
left: 40%;
|
||||
left: 40%;
|
||||
}
|
||||
</style>
|
||||
@@ -51,9 +51,7 @@
|
||||
<v-col>
|
||||
<calendar-my
|
||||
:calendars="
|
||||
calendarForMy.filter(
|
||||
(e) => e.author == accountStore.user.is_idEmployee
|
||||
)
|
||||
calendarForMy.filter((e) => e.author == accountStore.user.is_idEmployee)
|
||||
"
|
||||
title="Мои календари"
|
||||
@getCalendar="getCalendar"
|
||||
@@ -61,9 +59,7 @@
|
||||
|
||||
<calendar-my
|
||||
:calendars="
|
||||
calendarForMy.filter(
|
||||
(e) => e.author != accountStore.user.is_idEmployee
|
||||
)
|
||||
calendarForMy.filter((e) => e.author != accountStore.user.is_idEmployee)
|
||||
"
|
||||
title="Подписки"
|
||||
/>
|
||||
@@ -103,18 +99,18 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ref, onMounted, watch } from "vue";
|
||||
import { useWeekendsStore } from "@/store/WeekendsStore";
|
||||
import EventCreate from "@/components/calendar_of_events/event-create.vue";
|
||||
import CalendarMy from "@/components/calendar_of_events/calendar-my.vue";
|
||||
import { axiosApiInstance } from "@/utils/axios-api";
|
||||
import { useAccountStore } from "@/store/AccountStore";
|
||||
import CalendarFull from "@/components/calendar_of_events/UI_calendar/calendarFull.vue";
|
||||
import { ref, onMounted, watch } from 'vue';
|
||||
import { useWeekendsStore } from '@/store/WeekendsStore';
|
||||
import EventCreate from '@/components/calendar_of_events/event-create.vue';
|
||||
import CalendarMy from '@/components/calendar_of_events/calendar-my.vue';
|
||||
import { axiosApiInstance } from '@/utils/axios-api';
|
||||
import { useAccountStore } from '@/store/AccountStore';
|
||||
import CalendarFull from '@/components/calendar_of_events/UI_calendar/calendarFull.vue';
|
||||
|
||||
export default {
|
||||
components: { EventCreate, CalendarMy, CalendarFull },
|
||||
|
||||
setup(props, { emit }) {
|
||||
setup() {
|
||||
const accountStore = useAccountStore();
|
||||
const showDialog = ref(false);
|
||||
const week = useWeekendsStore();
|
||||
@@ -135,36 +131,27 @@ export default {
|
||||
};
|
||||
|
||||
const getCalendar = () => {
|
||||
axiosApiInstance
|
||||
.get(`api/calendar_of_events/my_calendars/`)
|
||||
.then((res) => {
|
||||
res.data.forEach(
|
||||
(e) =>
|
||||
(e.visible = accountStore.calendar.includes(e.id) ? false : true)
|
||||
);
|
||||
calendarForMy.value = res.data;
|
||||
});
|
||||
axiosApiInstance.get(`api/calendar_of_events/my_calendars/`).then((res) => {
|
||||
res.data.forEach((e) => (e.visible = accountStore.calendar.includes(e.id) ? false : true));
|
||||
calendarForMy.value = res.data;
|
||||
});
|
||||
};
|
||||
|
||||
getCalendar();
|
||||
|
||||
const getEvents = (idEvent, clik) => {
|
||||
axiosApiInstance
|
||||
.get(
|
||||
`api/calendar_of_events/my_events/${
|
||||
idEvent === undefined ? "" : `?id=${idEvent}`
|
||||
}`
|
||||
)
|
||||
.get(`api/calendar_of_events/my_events/${idEvent === undefined ? '' : `?id=${idEvent}`}`)
|
||||
.then((res) => {
|
||||
if (idEvent === undefined) {
|
||||
res.data.event = {
|
||||
name: "",
|
||||
name: '',
|
||||
participant: [accountStore.user.is_idEmployee],
|
||||
files: [],
|
||||
date_start: new Date(),
|
||||
date_end: new Date(),
|
||||
period: null,
|
||||
description: "",
|
||||
description: '',
|
||||
calendar: null,
|
||||
};
|
||||
}
|
||||
@@ -184,28 +171,25 @@ export default {
|
||||
};
|
||||
|
||||
const weekendsData = () => {
|
||||
cal.value.$el
|
||||
.querySelectorAll(".v-date-picker-month__day")
|
||||
.forEach((e) => {
|
||||
let datas = e.getAttribute("data-v-date");
|
||||
let weeks =
|
||||
new Date(datas).getDay() === 6 || new Date(datas).getDay() === 0;
|
||||
if (weeks) {
|
||||
e.querySelectorAll("span").forEach((n) => {
|
||||
n.classList.add("text-red");
|
||||
cal.value.$el.querySelectorAll('.v-date-picker-month__day').forEach((e) => {
|
||||
let datas = e.getAttribute('data-v-date');
|
||||
let weeks = new Date(datas).getDay() === 6 || new Date(datas).getDay() === 0;
|
||||
if (weeks) {
|
||||
e.querySelectorAll('span').forEach((n) => {
|
||||
n.classList.add('text-red');
|
||||
});
|
||||
}
|
||||
if (MyMonth.value in week.week[MyYear.value]) {
|
||||
if (week.week[MyYear.value][MyMonth.value].includes(datas)) {
|
||||
e.querySelectorAll('span').forEach((n) => {
|
||||
n.classList.add('text-red');
|
||||
if (n.classList.contains('text-red') && weeks) {
|
||||
n.classList.replace('text-red', 'text-black');
|
||||
}
|
||||
});
|
||||
}
|
||||
if (MyMonth.value in week.week[MyYear.value]) {
|
||||
if (week.week[MyYear.value][MyMonth.value].includes(datas)) {
|
||||
e.querySelectorAll("span").forEach((n) => {
|
||||
n.classList.add("text-red");
|
||||
if (n.classList.contains("text-red") && weeks) {
|
||||
n.classList.replace("text-red", "text-black");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
@@ -214,11 +198,11 @@ export default {
|
||||
|
||||
watch(
|
||||
() => week.week,
|
||||
(newValue, oldValue) => {
|
||||
(newValue) => {
|
||||
if (newValue) {
|
||||
weekendsData();
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
const CheckingStore = () => {
|
||||
@@ -230,7 +214,7 @@ export default {
|
||||
};
|
||||
|
||||
const infoEvent = (i) => {
|
||||
console.log(i, "iiiiiiiiii");
|
||||
console.log(i, 'iiiiiiiiii');
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
@@ -16,11 +16,7 @@
|
||||
return-object
|
||||
>
|
||||
<template v-slot:selection="{ item }">
|
||||
<v-chip
|
||||
class="me-2"
|
||||
color="teal-darken-3"
|
||||
size="small"
|
||||
label>
|
||||
<v-chip class="me-2" color="teal-darken-3" size="small" label>
|
||||
<span> {{ item.title }}</span>
|
||||
<v-icon
|
||||
v-if="item.value != accountStore.user.is_idEmployee"
|
||||
@@ -53,12 +49,7 @@
|
||||
<template v-slot:item="{ props, item }">
|
||||
<v-list-group v-bind="props" :value="item.raw.title">
|
||||
<template v-slot:activator="{ props }">
|
||||
<v-list-item
|
||||
v-bind="props"
|
||||
@click.stop=""
|
||||
density="compact"
|
||||
class="text-body-2"
|
||||
>
|
||||
<v-list-item v-bind="props" @click.stop="" density="compact" class="text-body-2">
|
||||
<template v-slot:prepend>
|
||||
<v-checkbox-btn
|
||||
@click.stop="selectedStaff = item.raw"
|
||||
@@ -78,7 +69,7 @@
|
||||
|
||||
<v-list-item
|
||||
v-for="x in item.raw.employees.filter((e) =>
|
||||
e.title.toLowerCase().includes(filtered.toLowerCase())
|
||||
e.title.toLowerCase().includes(filtered.toLowerCase()),
|
||||
)"
|
||||
:key="x.id"
|
||||
:value="x.title"
|
||||
@@ -101,9 +92,9 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ref, computed } from "vue";
|
||||
import { splitname } from "@/utils/universal_functions";
|
||||
import { useAccountStore } from "@/store/AccountStore";
|
||||
import { ref, computed } from 'vue';
|
||||
import { splitname } from '@/utils/universal_functions';
|
||||
import { useAccountStore } from '@/store/AccountStore';
|
||||
|
||||
export default {
|
||||
props: {
|
||||
@@ -113,18 +104,18 @@ export default {
|
||||
},
|
||||
okey: {
|
||||
type: String,
|
||||
default: "selected",
|
||||
default: 'selected',
|
||||
},
|
||||
},
|
||||
|
||||
setup(props, { emit }) {
|
||||
const filtered = ref("");
|
||||
const filtered = ref('');
|
||||
const accountStore = useAccountStore();
|
||||
const back = ref([]);
|
||||
|
||||
const staffed = computed({
|
||||
get() {
|
||||
if (props.okey == "editor") {
|
||||
if (props.okey == 'editor') {
|
||||
let ns = [];
|
||||
props.staff.forEach((e) => {
|
||||
let emp = { ...e };
|
||||
@@ -147,10 +138,7 @@ export default {
|
||||
get() {
|
||||
let selected = [];
|
||||
props.staff.forEach((e) => {
|
||||
if (
|
||||
e.employees.length != 1 &&
|
||||
e.employees.every((n) => n[props.okey] == true)
|
||||
) {
|
||||
if (e.employees.length != 1 && e.employees.every((n) => n[props.okey] == true)) {
|
||||
e[props.okey] = true;
|
||||
selected.push(e);
|
||||
} else if (e.employees.length == 1) {
|
||||
@@ -176,13 +164,13 @@ export default {
|
||||
});
|
||||
|
||||
const emitUp = (part) => {
|
||||
if ("employees" in part) {
|
||||
if ('employees' in part) {
|
||||
part.employees.forEach((e) => {
|
||||
if (e.id != accountStore.user.is_idEmployee) {
|
||||
e[props.okey] = !part[props.okey];
|
||||
}
|
||||
});
|
||||
emit("returnIdParticant", {
|
||||
emit('returnIdParticant', {
|
||||
okey: props.okey,
|
||||
staff: part.employees,
|
||||
select: [],
|
||||
@@ -191,7 +179,7 @@ export default {
|
||||
if (part[0].id != accountStore.user.is_idEmployee) {
|
||||
let val = part.every((e) => e[props.okey] == true) ? false : true;
|
||||
cbstaff(part, val);
|
||||
emit("returnIdParticant", {
|
||||
emit('returnIdParticant', {
|
||||
okey: props.okey,
|
||||
staff: back.value,
|
||||
select: [],
|
||||
@@ -200,7 +188,7 @@ export default {
|
||||
}
|
||||
} else {
|
||||
part[props.okey] = !part[props.okey];
|
||||
emit("returnIdParticant", {
|
||||
emit('returnIdParticant', {
|
||||
okey: props.okey,
|
||||
staff: [part],
|
||||
select: [],
|
||||
@@ -213,10 +201,10 @@ export default {
|
||||
if (e.id != accountStore.user.is_idEmployee) {
|
||||
e[props.okey] = value;
|
||||
}
|
||||
if (!("employees" in e)) {
|
||||
if (!('employees' in e)) {
|
||||
back.value.push(e);
|
||||
}
|
||||
if ("employees" in e) {
|
||||
if ('employees' in e) {
|
||||
cbstaff(e.employees, value);
|
||||
}
|
||||
});
|
||||
@@ -226,7 +214,7 @@ export default {
|
||||
return (
|
||||
item.includes(filtered.value) ||
|
||||
itemText.raw.employees.some((e) =>
|
||||
e.title.toLowerCase().includes(filtered.value.toLowerCase())
|
||||
e.title.toLowerCase().includes(filtered.value.toLowerCase()),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -10,10 +10,7 @@
|
||||
<v-row no-gutters class="flex-column">
|
||||
<v-col class="d-flex flex-column">
|
||||
<v-row no-gutters class="align-center">
|
||||
<v-col class="text-body-2 text-text_grey pb-5" lg="2">
|
||||
|
||||
Название
|
||||
</v-col>
|
||||
<v-col class="text-body-2 text-text_grey pb-5" lg="2"> Название </v-col>
|
||||
<v-col>
|
||||
<v-textarea
|
||||
density="compact"
|
||||
@@ -37,8 +34,8 @@
|
||||
propsCalendar.cl_color === null
|
||||
? 'flat'
|
||||
: propsCalendar.cl_color === x
|
||||
? 'flat'
|
||||
: 'tonal'
|
||||
? 'flat'
|
||||
: 'tonal'
|
||||
"
|
||||
/> </v-col
|
||||
></v-row>
|
||||
@@ -80,8 +77,8 @@
|
||||
<v-icon v-bind="props" icon="mdi-help-circle-outline" />
|
||||
</template>
|
||||
<div class="custom-tooltip">
|
||||
Участники с доступом редактирования смогут изменять поля
|
||||
календаря, а также редактировать и удалять события
|
||||
Участники с доступом редактирования смогут изменять поля календаря, а также
|
||||
редактировать и удалять события
|
||||
</div>
|
||||
</v-tooltip>
|
||||
</v-col>
|
||||
@@ -92,12 +89,12 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { computed, ref } from "vue";
|
||||
import { axiosApiInstance } from "@/utils/axios-api";
|
||||
import calendarCreateSelect from "@/components/calendar_of_events/calendar-create-select.vue";
|
||||
import { useAlertStore } from "@/store/useAlertStore";
|
||||
import DialogCreate from "./UI_calendar/dialogCreate.vue";
|
||||
import { useAccountStore } from "@/store/AccountStore";
|
||||
import { computed, ref } from 'vue';
|
||||
import { axiosApiInstance } from '@/utils/axios-api';
|
||||
import calendarCreateSelect from '@/components/calendar_of_events/calendar-create-select.vue';
|
||||
import { useAlertStore } from '@/store/useAlertStore';
|
||||
import DialogCreate from './UI_calendar/dialogCreate.vue';
|
||||
import { useAccountStore } from '@/store/AccountStore';
|
||||
|
||||
export default {
|
||||
components: { calendarCreateSelect, DialogCreate },
|
||||
@@ -105,7 +102,7 @@ export default {
|
||||
props: {
|
||||
calendar: {
|
||||
type: Object,
|
||||
default: {},
|
||||
default: () => {},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -113,15 +110,10 @@ export default {
|
||||
const accountStore = useAccountStore();
|
||||
|
||||
const returnIdParticant = (idPart) => {
|
||||
|
||||
idPart.staff.forEach((e) => {
|
||||
let indx = propsCalendar.value.participant.findIndex(
|
||||
(l) => l.participant_calendar == e.id
|
||||
);
|
||||
let ind = propsCalendar.value.participant.find(
|
||||
(l) => l.participant_calendar == e.id
|
||||
);
|
||||
if (idPart.okey == "editor") {
|
||||
let indx = propsCalendar.value.participant.findIndex((l) => l.participant_calendar == e.id);
|
||||
let ind = propsCalendar.value.participant.find((l) => l.participant_calendar == e.id);
|
||||
if (idPart.okey == 'editor') {
|
||||
ind.editor = e.editor;
|
||||
} else {
|
||||
if (e.selected == true) {
|
||||
@@ -135,7 +127,7 @@ export default {
|
||||
}
|
||||
} else {
|
||||
let ind = propsCalendar.value.participant.findIndex(
|
||||
(l) => l.participant_calendar == e.id
|
||||
(l) => l.participant_calendar == e.id,
|
||||
);
|
||||
|
||||
if (ind != -1) {
|
||||
@@ -144,32 +136,29 @@ export default {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
const propsCalendar = computed({
|
||||
get: () => props.calendar,
|
||||
set: (value) => emit("update:calendar", value),
|
||||
set: (value) => emit('update:calendar', value),
|
||||
});
|
||||
|
||||
const feedalert = useAlertStore().alert;
|
||||
|
||||
const rules = {
|
||||
|
||||
cl_name: [(val) => req(val)],
|
||||
cl_descr: [(val) => req(val)],
|
||||
};
|
||||
|
||||
const titleCard = ref("");
|
||||
const titleCard = ref('');
|
||||
const newCalendar = ref(false);
|
||||
|
||||
const calendarNewOrOld = () => {
|
||||
if (propsCalendar.value.hasOwnProperty("id")) {
|
||||
titleCard.value = "Редактирование календаря";
|
||||
if (propsCalendar.value.author != accountStore.user.is_idEmployee)
|
||||
newCalendar.value = true;
|
||||
if ('id' in propsCalendar.value) {
|
||||
titleCard.value = 'Редактирование календаря';
|
||||
if (propsCalendar.value.author != accountStore.user.is_idEmployee) newCalendar.value = true;
|
||||
} else {
|
||||
titleCard.value = "Новый календарь";
|
||||
titleCard.value = 'Новый календарь';
|
||||
|
||||
newCalendar.value = true;
|
||||
}
|
||||
@@ -186,22 +175,19 @@ export default {
|
||||
.then((result) => {
|
||||
feedalert.alert = true;
|
||||
feedalert.text = result.data.mess;
|
||||
feedalert.ico = "mdi-check";
|
||||
feedalert.color = "green-darken-4";
|
||||
emit("getCalendar");
|
||||
emit("closeDialog");
|
||||
feedalert.ico = 'mdi-check';
|
||||
feedalert.color = 'green-darken-4';
|
||||
emit('getCalendar');
|
||||
emit('closeDialog');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const staff = ref([]);
|
||||
|
||||
axiosApiInstance
|
||||
|
||||
.get("api/calendar_of_events/get_employees/")
|
||||
.then((res) => {
|
||||
staff.value = res.data.filter((e) => e.employees.length > 0);
|
||||
});
|
||||
axiosApiInstance.get('api/calendar_of_events/get_employees/').then((res) => {
|
||||
staff.value = res.data.filter((e) => e.employees.length > 0);
|
||||
});
|
||||
|
||||
const newStaff = computed({
|
||||
get() {
|
||||
@@ -209,7 +195,7 @@ export default {
|
||||
if (propsCalendar.value.participant.length > 0) {
|
||||
e.employees.forEach((empl) => {
|
||||
let ab = propsCalendar.value.participant.find(
|
||||
(a) => a.participant_calendar === empl.id
|
||||
(a) => a.participant_calendar === empl.id,
|
||||
);
|
||||
if (ab) {
|
||||
empl.selected = true;
|
||||
@@ -227,21 +213,21 @@ export default {
|
||||
});
|
||||
|
||||
const color = [
|
||||
"red",
|
||||
"pink",
|
||||
"deep-orange",
|
||||
"amber",
|
||||
"yellow",
|
||||
"lime",
|
||||
"light-green",
|
||||
"green",
|
||||
"light-blue",
|
||||
"blue",
|
||||
"indigo",
|
||||
"deep-purple",
|
||||
"purple",
|
||||
"blue-grey",
|
||||
"brown",
|
||||
'red',
|
||||
'pink',
|
||||
'deep-orange',
|
||||
'amber',
|
||||
'yellow',
|
||||
'lime',
|
||||
'light-green',
|
||||
'green',
|
||||
'light-blue',
|
||||
'blue',
|
||||
'indigo',
|
||||
'deep-purple',
|
||||
'purple',
|
||||
'blue-grey',
|
||||
'brown',
|
||||
];
|
||||
|
||||
const colorPik = (col) => {
|
||||
@@ -258,16 +244,15 @@ export default {
|
||||
.then((result) => {
|
||||
feedalert.alert = true;
|
||||
feedalert.text = result.data.mess;
|
||||
feedalert.ico = "mdi-check";
|
||||
feedalert.color = "orange-accent-1";
|
||||
emit("getCalendar");
|
||||
feedalert.ico = 'mdi-check';
|
||||
feedalert.color = 'orange-accent-1';
|
||||
emit('getCalendar');
|
||||
});
|
||||
emit("closeDialog");
|
||||
emit('closeDialog');
|
||||
};
|
||||
|
||||
const req = (val) => {
|
||||
|
||||
return !!val || "Поле обязательно";
|
||||
return !!val || 'Поле обязательно';
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<template>
|
||||
|
||||
<v-carousel
|
||||
v-model="currentslide"
|
||||
:interval="interval"
|
||||
@@ -8,173 +7,135 @@
|
||||
height="450"
|
||||
hide-delimiters
|
||||
hide-delimiter-background
|
||||
:show-arrows="carous.length<2?false:'hover'"
|
||||
:show-arrows="carous.length < 2 ? false : 'hover'"
|
||||
color="white"
|
||||
@update:modelValue="slidechanged"
|
||||
>
|
||||
|
||||
<template v-for="(x, i) in carous" :key="i">
|
||||
<v-carousel-item
|
||||
v-if="!x.link.endsWith('mp4')"
|
||||
:src="`${burl}${x.link}`"
|
||||
cover
|
||||
eager
|
||||
>
|
||||
|
||||
<v-container
|
||||
fill-height
|
||||
fluid
|
||||
pa-0
|
||||
ma-0
|
||||
pb-3
|
||||
class="flex-column h-100 d-flex"
|
||||
>
|
||||
<v-card
|
||||
v-if="x.text != '' || x.title != null"
|
||||
class="bgCard h-100 d-flex flex-column"
|
||||
>
|
||||
<v-card-title
|
||||
v-if="x.title != null"
|
||||
class="text-h3 text-uppercase titles text-text_carous ma-1 mb-0"
|
||||
>
|
||||
<v-row no-gutters>
|
||||
<v-col class="align-self-center">
|
||||
{{ x.title }}
|
||||
</v-col>
|
||||
<v-col class="flex-grow-0">
|
||||
<v-img
|
||||
width="50"
|
||||
:aspect-ratio="1"
|
||||
:src="`${burl}${x.sender}`"
|
||||
cover
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-card-title>
|
||||
<v-card-text
|
||||
v-if="x.text != ''"
|
||||
class="w-50 flex-grow-0 text-h6 bgText overflow-auto ma-1 pa-0"
|
||||
>
|
||||
<v-textarea
|
||||
class="text-text_caroustext-black textareas font-weight-medium nocursor"
|
||||
:model-value="x.text"
|
||||
variant="solo"
|
||||
readonly
|
||||
auto-grow
|
||||
rows="1"
|
||||
hide-details
|
||||
flat
|
||||
bg-color="transparent"
|
||||
/>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</v-container>
|
||||
</v-carousel-item>
|
||||
<v-carousel-item v-else >
|
||||
|
||||
<div class="d-flex justify-center">
|
||||
<video
|
||||
ref="videoElement"
|
||||
style="height: 450px"
|
||||
|
||||
controls
|
||||
|
||||
preload="metadata"
|
||||
@ended="ended"
|
||||
@loadedmetadata="interval = 10000000000"
|
||||
<template v-for="(x, i) in carous" :key="i">
|
||||
<v-carousel-item v-if="!x.link.endsWith('mp4')" :src="`${burl}${x.link}`" cover eager>
|
||||
<v-container fill-height fluid pa-0 ma-0 pb-3 class="flex-column h-100 d-flex">
|
||||
<v-card v-if="x.text != '' || x.title != null" class="bgCard h-100 d-flex flex-column">
|
||||
<v-card-title
|
||||
v-if="x.title != null"
|
||||
class="text-h3 text-uppercase titles text-text_carous ma-1 mb-0"
|
||||
>
|
||||
<source :src="`${burl}${x.link}`" type="video/mp4" />
|
||||
|
||||
Текущий браузер не поддерживает воспроизведение этого видео.
|
||||
</video>
|
||||
</div>
|
||||
<!-- currentslide=currentslide<carous.length-1?currentslide+1:0 -->
|
||||
</v-carousel-item>
|
||||
</template>
|
||||
<v-row no-gutters>
|
||||
<v-col class="align-self-center">
|
||||
{{ x.title }}
|
||||
</v-col>
|
||||
<v-col class="flex-grow-0">
|
||||
<v-img width="50" :aspect-ratio="1" :src="`${burl}${x.sender}`" cover />
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-card-title>
|
||||
<v-card-text
|
||||
v-if="x.text != ''"
|
||||
class="w-50 flex-grow-0 text-h6 bgText overflow-auto ma-1 pa-0"
|
||||
>
|
||||
<v-textarea
|
||||
class="text-text_caroustext-black textareas font-weight-medium nocursor"
|
||||
:model-value="x.text"
|
||||
variant="solo"
|
||||
readonly
|
||||
auto-grow
|
||||
rows="1"
|
||||
hide-details
|
||||
flat
|
||||
bg-color="transparent"
|
||||
/>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</v-container>
|
||||
</v-carousel-item>
|
||||
<v-carousel-item v-else>
|
||||
<div class="d-flex justify-center">
|
||||
<video
|
||||
ref="videoElement"
|
||||
style="height: 450px"
|
||||
controls
|
||||
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>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ref, computed } from "vue";
|
||||
import { baseURL } from "@/utils/axios-api";
|
||||
import { axiosApiInstance } from "@/utils/axios-api";
|
||||
import { useAlertStore } from "@/store/useAlertStore";
|
||||
import { ref } from 'vue';
|
||||
import { baseURL } from '@/utils/axios-api';
|
||||
import { axiosApiInstance } from '@/utils/axios-api';
|
||||
import { useAlertStore } from '@/store/useAlertStore';
|
||||
|
||||
export default {
|
||||
|
||||
setup() {
|
||||
const currentslide=ref(0)
|
||||
const currentslide = ref(0);
|
||||
const burl = baseURL.slice(0, -1);
|
||||
const videoElement=ref(null)
|
||||
const carous = ref([{ link: `/media/newsimage/scales.jpg`, "title": null, "text": "" }]);
|
||||
const videoElement = ref(null);
|
||||
const carous = ref([{ link: `/media/newsimage/scales.jpg`, title: null, text: '' }]);
|
||||
const feedalert = useAlertStore().alert;
|
||||
|
||||
const getfromserver = () => {
|
||||
axiosApiInstance.get("api/navigation/carousels/").then((result) => {
|
||||
if (result.data.mess != "") {
|
||||
axiosApiInstance.get('api/navigation/carousels/').then((result) => {
|
||||
if (result.data.mess != '') {
|
||||
feedalert.alert = true;
|
||||
feedalert.text = result.data.mess;
|
||||
feedalert.color = "red-darken-2";
|
||||
feedalert.ico = "mdi-alert-outline";
|
||||
feedalert.color = 'red-darken-2';
|
||||
feedalert.ico = 'mdi-alert-outline';
|
||||
}
|
||||
|
||||
console.log(result.data);
|
||||
if (result.data.result.length > 0) {
|
||||
carous.value = result.data.result;
|
||||
}
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
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()
|
||||
|
||||
const interval = ref(10000);
|
||||
|
||||
const slidechanged = () => {
|
||||
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
|
||||
if (carous.value[currentslide.value].link.endsWith('mp4')) {
|
||||
interval.value = 10000000000;
|
||||
} else {
|
||||
interval.value = 10000;
|
||||
}
|
||||
|
||||
}
|
||||
const ended = (val)=>{
|
||||
val.target.currentTime = 0
|
||||
};
|
||||
const ended = (val) => {
|
||||
val.target.currentTime = 0;
|
||||
val.target.pause();
|
||||
document.exitFullscreen()
|
||||
currentslide.value=currentslide.value<carous.value.length-1?currentslide.value+1:0
|
||||
}
|
||||
document.exitFullscreen();
|
||||
currentslide.value =
|
||||
currentslide.value < carous.value.length - 1 ? currentslide.value + 1 : 0;
|
||||
};
|
||||
|
||||
return {
|
||||
slidechanged,
|
||||
videoElement,
|
||||
currentslide,
|
||||
interval,
|
||||
// intervalcomp,
|
||||
|
||||
burl,
|
||||
carous,
|
||||
ended
|
||||
ended,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
Whitespace-only changes.
@@ -1,6 +1,5 @@
|
||||
<template>
|
||||
<div class="px-4">
|
||||
{{ displayDays + declOfNum(displayDays, [' день', ' дня', ' дней']) }}
|
||||
{{ displayHours + declOfNum(displayHours, [' час', ' часа', ' часов']) }}
|
||||
{{ displayMinutes + declOfNum(displayMinutes, [' минута', ' минуты', ' минут']) }}
|
||||
{{ displaySeconds + declOfNum(displaySeconds, [' секунда', ' секунды', ' секунд']) }}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<template>
|
||||
<v-container>
|
||||
<HeaderDetailTesting />
|
||||
|
||||
</v-container>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import HeaderDetailTesting from './HeaderDetailTesting.vue';
|
||||
|
||||
|
||||
export default {
|
||||
components: {
|
||||
HeaderDetailTesting,
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
@@ -0,0 +1,43 @@
|
||||
<template>
|
||||
<v-row class="ma-0 border-b-thin">
|
||||
<v-col cols="auto" class="flex-grow-1">
|
||||
<div class="text-subtitle-1 text-grey-lighten-1">Тест</div>
|
||||
<div class="text-h5">{{ title }}</div>
|
||||
</v-col>
|
||||
<v-col cols="auto" class="d-flex flex-column">
|
||||
<div class="align-self-end text-grey-lighten-1">!!!</div>
|
||||
<div class="text-h4 text-grey-lighten-1">{{ time }}Таймер сюдаааа!!!</div>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row class="ma-0 border-b-thin">
|
||||
<v-col cols="auto" class="flex-grow-1">
|
||||
<v-container class="d-flex align-center max-width">
|
||||
<v-btn elevation="1" color="teal-darken-1" size="x-small" rounded icon="mdi-information-outline" />
|
||||
<v-pagination :length="25" :total-visible="20" next-icon="mdi-menu-right" prev-icon="mdi-menu-left">
|
||||
<template #item="item">
|
||||
{{ item }}
|
||||
</template>
|
||||
</v-pagination>
|
||||
</v-container>
|
||||
</v-col>
|
||||
<v-col cols="auto" class="align-self-center">
|
||||
<v-btn elevation="0" color="#0000001F" rounded="1">Выйти</v-btn>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
export default {
|
||||
props: {
|
||||
title: {
|
||||
type: String,
|
||||
default: 'Название теста здесь',
|
||||
},
|
||||
time: {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
@@ -43,6 +43,14 @@
|
||||
</div>
|
||||
<v-divider></v-divider>
|
||||
<div class="flex-grow-0 flex-shrink-1">
|
||||
<div class="pt-2 d-flex align-center"><span class="text-overline text-grey text-center">Публикация новости: </span>
|
||||
<v-switch v-model="form.createnews"
|
||||
class="px-2"
|
||||
density="comfortable"
|
||||
hide-details
|
||||
color="primary"
|
||||
:label="form.createnews?'да':'нет'"
|
||||
></v-switch></div>
|
||||
<div class="pt-2 text-overline text-grey">Дата и время:</div>
|
||||
<div class="d-flex justify-space-around">
|
||||
<div class="d-flex ga-3 align-center">
|
||||
@@ -360,6 +368,7 @@ export default {
|
||||
startDate: new Date(),
|
||||
endDate: new Date(new Date().setDate(new Date().getDate() + 14)),
|
||||
questions: [],
|
||||
createnews:false
|
||||
});
|
||||
|
||||
const rules = {
|
||||
|
||||
@@ -177,6 +177,12 @@ const routes = [
|
||||
ico: "mdi-account",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "/test/testdetail/:id",
|
||||
name: "TestDetail",
|
||||
component: () =>
|
||||
import("@/components/testing/DetailCardTest.vue")
|
||||
},
|
||||
{
|
||||
path: '/secret',
|
||||
name: 'Secret Page',
|
||||
|
||||
@@ -1,32 +1,39 @@
|
||||
import {useAccountStore} from '@/store/AccountStore'
|
||||
import axios from "axios";
|
||||
import { useAccountStore } from '@/store/AccountStore';
|
||||
import axios from 'axios';
|
||||
|
||||
const spravURL = 'http://10.252.44.33/accounting6/images/photo/'
|
||||
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 baseWS = process.env.NODE_ENV === 'development' ? 'ws://127.0.0.1:8000/' : `ws://${window.location.host}/`;
|
||||
const spravURL = 'http://10.252.44.33/accounting6/images/photo/';
|
||||
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 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 baseWS = process.env.NODE_ENV == 'development'? 'ws://127.0.0.1:8000/': `ws://10.252.44.60:9966/`;
|
||||
// для релизного меняем 'http://ukd/'
|
||||
// const baseURL = 'http://127.0.0.1:8000/';
|
||||
|
||||
async function refreshToken() {
|
||||
|
||||
const refresh = localStorage.getItem('refresh');
|
||||
|
||||
try {
|
||||
const result = await axios.post('/api/accounts/token/refresh/', {refresh}, {
|
||||
baseURL
|
||||
})
|
||||
const result = await axios.post(
|
||||
'/api/accounts/token/refresh/',
|
||||
{ refresh },
|
||||
{
|
||||
baseURL,
|
||||
},
|
||||
);
|
||||
|
||||
if (result.config.data) localStorage.setItem('refresh', JSON.parse(result.config.data).refresh);
|
||||
localStorage.setItem('access', result.data.access)
|
||||
localStorage.setItem('access', result.data.access);
|
||||
|
||||
return result.data.access;
|
||||
} catch (e) {
|
||||
const accountStore = useAccountStore()
|
||||
accountStore.logout()
|
||||
accountStore.cod2user.value = false
|
||||
const accountStore = useAccountStore();
|
||||
accountStore.logout();
|
||||
accountStore.cod2user.value = false;
|
||||
|
||||
return Promise.reject(e);
|
||||
}
|
||||
@@ -40,32 +47,36 @@ const clearAxios = axios.create({
|
||||
baseURL,
|
||||
});
|
||||
|
||||
axiosApiInstance.defaults.headers.common['Authorization'] = `Bearer ${localStorage.getItem('access')}`
|
||||
axiosApiInstance.defaults.headers.common['Authorization'] =
|
||||
`Bearer ${localStorage.getItem('access')}`;
|
||||
|
||||
axiosApiInstance.interceptors.request.use(config => {
|
||||
const access = localStorage.getItem('access');
|
||||
if (access) {
|
||||
config.headers = {
|
||||
'Authorization': `Bearer ${access}`,
|
||||
axiosApiInstance.interceptors.request.use(
|
||||
(config) => {
|
||||
const access = localStorage.getItem('access');
|
||||
if (access) {
|
||||
config.headers = {
|
||||
Authorization: `Bearer ${access}`,
|
||||
};
|
||||
}
|
||||
}
|
||||
return config;
|
||||
}, error => {
|
||||
return Promise.reject(error);
|
||||
})
|
||||
return config;
|
||||
},
|
||||
(error) => {
|
||||
return Promise.reject(error);
|
||||
},
|
||||
);
|
||||
|
||||
axiosApiInstance.interceptors.response.use(
|
||||
response => {
|
||||
(response) => {
|
||||
return response;
|
||||
},
|
||||
async error => {
|
||||
|
||||
async (error) => {
|
||||
const originalRequest = error.config;
|
||||
if ((error.response.status === 401 || error.response.status === 403) && !originalRequest._retry) {
|
||||
|
||||
if (
|
||||
(error.response.status === 401 || error.response.status === 403) &&
|
||||
!originalRequest._retry
|
||||
) {
|
||||
originalRequest._retry = true;
|
||||
try {
|
||||
|
||||
const token = await refreshToken();
|
||||
|
||||
axiosApiInstance.defaults.headers.common['Authorization'] = `Bearer ${token}`;
|
||||
@@ -75,64 +86,54 @@ axiosApiInstance.interceptors.response.use(
|
||||
}
|
||||
|
||||
return axiosApiInstance(originalRequest);
|
||||
|
||||
} catch (e) {
|
||||
return Promise.reject(error);
|
||||
return Promise.reject(error) ?? e;
|
||||
}
|
||||
}
|
||||
return Promise.reject(error);
|
||||
})
|
||||
},
|
||||
);
|
||||
|
||||
async function getVotes(status) {
|
||||
try {
|
||||
const response = await axiosApiInstance.get(`/api/vote/getvotes?status=${status}`);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка запроса голосования:', error);
|
||||
throw error;
|
||||
throw new Error('Ошибка запроса голосования:', error);
|
||||
}
|
||||
}
|
||||
|
||||
async function createVote(voteData) {
|
||||
|
||||
try {
|
||||
|
||||
const formData = new FormData();
|
||||
voteData.questions.forEach(question => {
|
||||
formData.append('questionsfiles', question.image)
|
||||
if(!!question.image){
|
||||
const {name,size,lastModified}=question.image
|
||||
question.image={name,size,lastModified}
|
||||
voteData.questions.forEach((question) => {
|
||||
formData.append('questionsfiles', question.image);
|
||||
if (question.image) {
|
||||
const { name, size, lastModified } = question.image;
|
||||
question.image = { name, size, lastModified };
|
||||
}
|
||||
|
||||
question.answers.forEach((answer) => {
|
||||
formData.append('answersfiles', answer.image);
|
||||
if (answer.image) {
|
||||
const { name, size, lastModified } = answer.image;
|
||||
answer.image = { name, size, lastModified };
|
||||
}
|
||||
|
||||
question.answers.forEach(answer=>{
|
||||
|
||||
formData.append('answersfiles', answer.image)
|
||||
if(!!answer.image){
|
||||
const {name,size,lastModified}=answer.image
|
||||
answer.image={name,size,lastModified}
|
||||
}
|
||||
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
formData.append('news', voteData.createnews);
|
||||
formData.append('title', voteData.title);
|
||||
formData.append('description', voteData.description);
|
||||
formData.append('startDate', new Date(voteData.startDate).toISOString());
|
||||
formData.append('endDate', new Date(voteData.endDate).toISOString());
|
||||
formData.append('questions', JSON.stringify(voteData.questions));
|
||||
|
||||
|
||||
const response = await axiosApiInstance.post('/api/vote/votecreate/', formData, {
|
||||
headers: {'Content-Type': 'multipart/form-data'},
|
||||
await axiosApiInstance.post('/api/vote/votecreate/', formData, {
|
||||
headers: { 'Content-Type': 'multipart/form-data' },
|
||||
});
|
||||
|
||||
// return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка создания голосования:', error);
|
||||
throw error;
|
||||
throw new Error(error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,8 +142,7 @@ async function getVoteDetail(id) {
|
||||
const response = await axiosApiInstance.get(`/api/vote/votedetail/${id}/`);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error("Ошибка получения деталей голосования:", error);
|
||||
throw error;
|
||||
throw new Error(error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,10 +169,8 @@ async function getVoteDetail(id) {
|
||||
async function deleteVote(id) {
|
||||
try {
|
||||
await axiosApiInstance.delete(`/api/vote/votedetail/${id}/`);
|
||||
console.log("Голосование успешно удалено");
|
||||
} catch (error) {
|
||||
console.error("Ошибка удаления голосования:", error);
|
||||
throw error;
|
||||
throw new Error(error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,8 +179,7 @@ async function getEmployees() {
|
||||
const response = await axiosApiInstance.get(`api/vote/getdictemployee/`);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error("Ошибка получения всех сотрудников:", error);
|
||||
throw error;
|
||||
throw new Error(error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,12 +188,10 @@ async function getVoteResult(id) {
|
||||
const response = await axiosApiInstance.get(`/api/vote/getresults/?id=${id}`);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error("Ошибка получения результата голосования:", error);
|
||||
throw error;
|
||||
throw new Error(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export {
|
||||
axiosApiInstance,
|
||||
clearAxios,
|
||||
@@ -212,4 +207,4 @@ export {
|
||||
deleteVote,
|
||||
getEmployees,
|
||||
getVoteResult,
|
||||
}
|
||||
};
|
||||
@@ -1,26 +1,21 @@
|
||||
<template>
|
||||
|
||||
<v-row>
|
||||
|
||||
<v-col
|
||||
class="text-h6 text-grey text-center align-self-center text--lighten-1 font-weight-light"
|
||||
>
|
||||
F.A.Q.
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
<v-row>
|
||||
<v-col
|
||||
class="text-h6 text-grey text-center align-self-center text--lighten-1 font-weight-light"
|
||||
>
|
||||
F.A.Q.
|
||||
</v-col>
|
||||
</v-row>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {pagecounter} from '@/utils/universal_functions'
|
||||
import { pagecounter } from '@/utils/universal_functions';
|
||||
|
||||
export default {
|
||||
setup(){
|
||||
pagecounter()
|
||||
}
|
||||
}
|
||||
setup() {
|
||||
pagecounter();
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
|
||||
</style>
|
||||
<style></style>
|
||||
+88
-150
@@ -1,160 +1,98 @@
|
||||
<template>
|
||||
<v-carousel
|
||||
cover
|
||||
:height="carushi"
|
||||
hide-delimiters
|
||||
hide-delimiter-background
|
||||
show-arrows="hover"
|
||||
color="white"
|
||||
>
|
||||
<v-carousel-item v-for="(x, i) in carous" :key="i" :src="`${burl}${x.link}`" cover eager>
|
||||
<v-container fill-height fluid pa-0 ma-0 pb-3 class="flex-column h-100 d-flex">
|
||||
<v-card class="bgCard h-100 d-flex flex-column">
|
||||
<v-card-title class="ma-2 text-h3 text-uppercase titles py-5 flex-column">
|
||||
<v-row>
|
||||
<v-col class="pa-0 pl-1 align-self-center">{{ x.title }} </v-col>
|
||||
|
||||
<v-carousel
|
||||
|
||||
cover
|
||||
:height="carushi"
|
||||
hide-delimiters
|
||||
hide-delimiter-background
|
||||
show-arrows="hover"
|
||||
color="white"
|
||||
|
||||
|
||||
|
||||
|
||||
>
|
||||
|
||||
|
||||
<v-carousel-item
|
||||
v-for="(x, i) in carous" :key="i"
|
||||
:src="`${burl}${x.link}`"
|
||||
cover
|
||||
eager
|
||||
>
|
||||
<v-col class="flex-grow-0 pa-0 pr-1">
|
||||
<v-img width="50" :aspect-ratio="1" :src="`${burl}${x.sender}`" cover />
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-card-title>
|
||||
<v-card-text
|
||||
v-if="'text' in x && x.text.length > 0"
|
||||
class="ml-2 mb-0 mb-2 flex-grow-0 pb-3 text-h6 h-100 pl-3 py-3 mr-1"
|
||||
>
|
||||
<v-row>
|
||||
<v-col cols="6" class="bgText">
|
||||
<v-textarea
|
||||
class="mt-n3 text-black textareas pt-2 font-weight-medium"
|
||||
:model-value="x.text"
|
||||
variant="plain"
|
||||
readonly
|
||||
auto-grow
|
||||
rows="1"
|
||||
hide-details
|
||||
/>
|
||||
</v-col>
|
||||
|
||||
<v-container
|
||||
fill-height
|
||||
fluid
|
||||
pa-0 ma-0 pb-3
|
||||
class="flex-column h-100 d-flex"
|
||||
>
|
||||
|
||||
<v-card class="bgCard h-100 d-flex flex-column">
|
||||
<v-card-title class="ma-2 text-h3 text-uppercase titles py-5 flex-column">
|
||||
<v-row>
|
||||
<v-col class="pa-0 pl-1 align-self-center">{{x.title}}
|
||||
</v-col>
|
||||
|
||||
<v-col class="flex-grow-0 pa-0 pr-1">
|
||||
<v-img
|
||||
|
||||
width="50"
|
||||
:aspect-ratio="1"
|
||||
:src="`${burl}${x.sender}`"
|
||||
cover
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
|
||||
</v-card-title>
|
||||
<v-card-text v-if="'text' in x && x.text.length>0" class="ml-2 mb-0 mb-2 flex-grow-0 pb-3 text-h6 h-100 pl-3 py-3 mr-1 ">
|
||||
<v-row>
|
||||
<v-col cols="6" class="bgText">
|
||||
<v-img :aspect-ratio="1" :src="`${burl}${x.link2}`" />
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</v-container>
|
||||
</v-carousel-item>
|
||||
</v-carousel>
|
||||
</template>
|
||||
|
||||
|
||||
<v-col cols=6 class=" bgText">
|
||||
<v-textarea
|
||||
class="mt-n3 text-black textareas pt-2 font-weight-medium"
|
||||
:model-value=x.text
|
||||
variant='plain'
|
||||
readonly
|
||||
auto-grow
|
||||
rows="1"
|
||||
|
||||
hide-details
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
import { ref, computed } from 'vue';
|
||||
|
||||
/>
|
||||
|
||||
</v-col>
|
||||
|
||||
import { baseURL } from '@/utils/axios-api';
|
||||
import { axiosApiInstance } from '@/utils/axios-api';
|
||||
|
||||
<v-col cols=6 class=" bgText">
|
||||
<v-img
|
||||
|
||||
|
||||
:aspect-ratio="1"
|
||||
:src="`${burl}${x.link2}`"
|
||||
|
||||
/>
|
||||
|
||||
</v-col>
|
||||
|
||||
|
||||
</v-row>
|
||||
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
|
||||
|
||||
</v-container>
|
||||
|
||||
</v-carousel-item>
|
||||
|
||||
</v-carousel>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ref, computed } from 'vue'
|
||||
import {getfromserver} from '@/utils/universal_functions'
|
||||
import { baseURL } from '@/utils/axios-api'
|
||||
import { axiosApiInstance } from '@/utils/axios-api'
|
||||
|
||||
|
||||
|
||||
export default {
|
||||
|
||||
setup() {
|
||||
const burl = baseURL.slice(0,-1)
|
||||
const carous=ref([{link: ""}])
|
||||
|
||||
axiosApiInstance.get(`api/fns/links/`).then(data => {
|
||||
carous.value= data.data
|
||||
|
||||
// t_dailyRound.value = data.data
|
||||
export default {
|
||||
setup() {
|
||||
const burl = baseURL.slice(0, -1);
|
||||
const carous = ref([{ link: '' }]);
|
||||
|
||||
// result.value=JSON.parse(JSON.stringify(data.data.daily))
|
||||
axiosApiInstance.get(`api/fns/links/`).then((data) => {
|
||||
carous.value = data.data;
|
||||
|
||||
})
|
||||
// getfromserver("api/fns/links/", carous)
|
||||
|
||||
const carushi = computed(()=> {
|
||||
|
||||
return window.innerHeight-50
|
||||
|
||||
})
|
||||
|
||||
return { burl, carous, carushi}
|
||||
}
|
||||
// t_dailyRound.value = data.data
|
||||
|
||||
|
||||
// result.value=JSON.parse(JSON.stringify(data.data.daily))
|
||||
});
|
||||
// getfromserver("api/fns/links/", carous)
|
||||
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.bgCard {
|
||||
/* #ffffff6b #ffffff8c*/
|
||||
background: #ffffff38 ;
|
||||
}
|
||||
|
||||
.bgText {
|
||||
background: #ffffffb0;
|
||||
line-height: 3.1rem!important;
|
||||
|
||||
}
|
||||
|
||||
.titles {
|
||||
/* font-family: cursive !important; */
|
||||
background: #ffffff8c;
|
||||
}
|
||||
|
||||
.textareas .v-field__input {
|
||||
|
||||
font-size: 2.5em!important;
|
||||
}
|
||||
</style>
|
||||
const carushi = computed(() => {
|
||||
return window.innerHeight - 50;
|
||||
});
|
||||
|
||||
return { burl, carous, carushi };
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.bgCard {
|
||||
/* #ffffff6b #ffffff8c*/
|
||||
background: #ffffff38;
|
||||
}
|
||||
|
||||
.bgText {
|
||||
background: #ffffffb0;
|
||||
line-height: 3.1rem !important;
|
||||
}
|
||||
|
||||
.titles {
|
||||
/* font-family: cursive !important; */
|
||||
background: #ffffff8c;
|
||||
}
|
||||
|
||||
.textareas .v-field__input {
|
||||
font-size: 2.5em !important;
|
||||
}
|
||||
</style>
|
||||
@@ -1,223 +1,100 @@
|
||||
<template>
|
||||
<v-container>
|
||||
<v-tabs v-model="activeTab" class="mb-4 text-teal-darken-4">
|
||||
<v-tab>Назначенные ({{ scheduledTests.length }})</v-tab>
|
||||
<v-tab>Завершенные ({{ completedTests.length }})</v-tab>
|
||||
<v-tab>Каталог</v-tab>
|
||||
<v-container :fluid="true">
|
||||
<v-tabs v-model="activeTab" class="mb-2 text-teal-darken-4">
|
||||
<v-tab v-for="tab in tabs" :key="tab.value" :value="tab.value"> {{ tab.title }} </v-tab>
|
||||
</v-tabs>
|
||||
|
||||
<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 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>
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
<CatalogTest title="Каталог" :activeTab="activeTab" :testingCard="getAllTests">
|
||||
<template #buttons>
|
||||
<v-btn color="#00897B1F" class="mr-2 text-teal-darken-1" elevation="0">
|
||||
Тренироваться
|
||||
</v-btn>
|
||||
</template>
|
||||
</CatalogTest>
|
||||
</v-tabs-window-item>
|
||||
</v-tabs-window>
|
||||
</v-container>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {computed, ref} from 'vue';
|
||||
import TestCard from "@/components/tests/TestCard.vue";
|
||||
import CatalogTest from '@/components/testing/CatalogTest.vue';
|
||||
import { axiosApiInstance } from '@/utils/axios-api';
|
||||
|
||||
import { ref, computed, watch } from 'vue';
|
||||
|
||||
export default {
|
||||
components: {TestCard},
|
||||
components: {
|
||||
CatalogTest,
|
||||
},
|
||||
setup() {
|
||||
const activeTab = ref(0);
|
||||
const search = ref('');
|
||||
const currentTest = ref('');
|
||||
|
||||
const headers = [
|
||||
{text: 'Картинка', value: 'image', sortable: false},
|
||||
{text: 'Название', value: 'title', align: 'start'},
|
||||
{text: 'Действия', value: 'actions', sortable: false},
|
||||
];
|
||||
const getAllTests = ref([]);
|
||||
|
||||
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 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: 'Каталог' },
|
||||
]);
|
||||
|
||||
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,
|
||||
tabs,
|
||||
getAllTests,
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.v-data-table__wrapper {
|
||||
overflow-x: auto;
|
||||
}
|
||||
</style>
|
||||
@@ -19,6 +19,8 @@
|
||||
<div>
|
||||
<v-card class="vote-card-information" variant="flat">
|
||||
|
||||
|
||||
|
||||
<v-card-text class="justify-center align-center vote-card-information-title">
|
||||
<p>ВЫ УЖЕ ПРОГОЛОСОВАЛИ.</p>
|
||||
<p>СПАСИБО!</p>
|
||||
|
||||
@@ -20,11 +20,12 @@
|
||||
<!-- Вкладка завершенных -->
|
||||
<v-tabs-window-item>
|
||||
<CatalogTest title="Завершенные" :activeTab="activeTab" :testingCard="getAllTests">
|
||||
<!-- Здесь отобразить результат теста после того как будет готов БЭК и УМТ -->
|
||||
<template #results>
|
||||
<div>
|
||||
<!-- <div>
|
||||
<v-icon icon="mdi-calendar-clock" size="large" />
|
||||
<span class="ml-1">12354</span>
|
||||
</div>
|
||||
</div> -->
|
||||
</template>
|
||||
<template #buttons>
|
||||
<v-btn color="#00897B1F" class="mr-2 text-teal-darken-1" elevation="0">
|
||||
@@ -44,7 +45,6 @@
|
||||
</CatalogTest>
|
||||
</v-tabs-window-item>
|
||||
</v-tabs-window>
|
||||
{{ getAllTests }}
|
||||
</v-container>
|
||||
</template>
|
||||
|
||||
|
||||
Reference in new issue
Block a user