Merge branch 'develop'
This commit is contained in:
commit
901275658e
64 files changed
+7162
-22111
No files matched your search
+3
-1
@@ -1,6 +1,8 @@
|
||||
env/
|
||||
|
||||
/src/__pycache__/
|
||||
/src/*/__pycache__/
|
||||
/src/*/migrations/
|
||||
/src/front/public/Tiles/
|
||||
/src/front/node_modules/
|
||||
/src/front/node_modules/
|
||||
.vscode/
|
||||
+2
-2
@@ -2,8 +2,8 @@ env/
|
||||
/__pycache__/
|
||||
/*/__pycache__/
|
||||
/*/migrations/
|
||||
portal/ds.py
|
||||
/front/node_modules/
|
||||
*.sqlite3
|
||||
/media/
|
||||
/static/
|
||||
/static/
|
||||
*.env
|
||||
@@ -129,7 +129,8 @@ class OrderResponsibility(models.Model):
|
||||
return f'{self.number} - {self.name}'
|
||||
|
||||
class OrderResponsibilityEmployee(models.Model):
|
||||
id_order_responsibility = models.ForeignKey(OrderResponsibility, models.DO_NOTHING, db_column='id_order_responsibility', primary_key=True, 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 = 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.
|
||||
employee = models.ForeignKey('userauth.DictEmployee', models.DO_NOTHING, db_column='id_dict_employee', db_comment='╚─ ёюЄЁєфэшър, ъюЄюЁ√щ эрчэрўхэ юЄтхЄёЄтхээ√ь яю фрээюьє яЁшърчє', related_name="user_respons")
|
||||
|
||||
class Meta:
|
||||
@@ -140,6 +141,7 @@ class OrderResponsibilityEmployee(models.Model):
|
||||
verbose_name_plural = 'Ответственные сотрудники'
|
||||
def __str__(self):
|
||||
return str(self.employee)
|
||||
|
||||
class OrderResponsibilityFiles(models.Model):
|
||||
id = models.PositiveIntegerField(primary_key=True, db_comment='╥рсхы№э√щ эюьхЁ')
|
||||
id_order_responsibility = models.ForeignKey(OrderResponsibility, models.DO_NOTHING, db_column='id_order_responsibility', db_comment='╚─ яЁшърчр юс юЄтхЄёЄтхээ√ї ёюЄЁєфэшърї', related_name="get_resp_files")
|
||||
|
||||
@@ -5,6 +5,8 @@ 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):
|
||||
name = models.CharField(verbose_name='Название', max_length=150, blank=True, db_index=True)
|
||||
@@ -39,7 +41,8 @@ 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:
|
||||
|
||||
verbose_name = "Новости"
|
||||
@@ -125,14 +128,17 @@ class CommentNews(models.Model):
|
||||
|
||||
names.short_description="ФИО"
|
||||
|
||||
def default_end_date():
|
||||
return now().replace(hour=23, minute=0) + timedelta(days=7)
|
||||
|
||||
class Carousels(models.Model):
|
||||
title=models.CharField(max_length=255, blank=True, null=True, verbose_name='Заголовок')
|
||||
text= models.TextField(max_length=260, blank=True, null=True, verbose_name='Сообщение')
|
||||
cdate =models.DateTimeField(default=datetime.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='Автор новости')
|
||||
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='Опубликован')
|
||||
enddate = models.DateTimeField(default=datetime.now().replace(hour=23,minute=0,second=0,microsecond=0) + timedelta(days=7), 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='Тематика')
|
||||
order = models.IntegerField(verbose_name='Порядок сортировки', null=True, blank=True)
|
||||
|
||||
@@ -166,11 +172,13 @@ class BirthdayText(models.Model):
|
||||
def __str__(self):
|
||||
return str(self.pk)
|
||||
|
||||
def default_date():
|
||||
return date.today().replace(year=1992)
|
||||
|
||||
class Screensaver(models.Model):
|
||||
img = models.ImageField(upload_to='screengallery/%Y/%m/%d', null=True, verbose_name='Изображение')
|
||||
cdate =models.DateField(default=date.today().replace(year=1992), null=True, verbose_name='Дата начала периода')
|
||||
enddate = models.DateField(default= date.today().replace(year=1992), verbose_name='Дата окончания периода', null=True)
|
||||
cdate =models.DateField(default=default_date, null=True, verbose_name='Дата начала периода')
|
||||
enddate = models.DateField(default= default_date, verbose_name='Дата окончания периода', null=True)
|
||||
|
||||
class Meta:
|
||||
|
||||
|
||||
@@ -209,16 +209,16 @@ class ScreensaverAPIView(ListAPIView):
|
||||
# print(result, "--------------------------no foto screensaver")
|
||||
# try:
|
||||
# queryset = Screensaver.objects.all()
|
||||
# queryset = Screensaver.objects.filter(cdate__month__lte = date.today().month, cdate__day__lte = date.today().day,
|
||||
# enddate__month__gte=date.today().month, enddate__day__gte=date.today().day).order_by('-cdate')
|
||||
queryset = Screensaver.objects.filter(cdate__month__lte = 6, cdate__day__lte = 3,
|
||||
enddate__month__gte=6, enddate__day__gte=3).order_by('-cdate')
|
||||
b = Screensaver.objects.values('cdate__month', 'cdate__day', 'enddate__month', 'enddate__day')
|
||||
queryset = Screensaver.objects.filter(cdate__month__lte = date.today().month, cdate__day__lte = date.today().day,
|
||||
enddate__month__gte=date.today().month, enddate__day__gte=date.today().day).order_by('-cdate')
|
||||
# queryset = Screensaver.objects.filter(cdate__month__lte = 6, cdate__day__lte = 3,
|
||||
# enddate__month__gte=6, enddate__day__gte=3).order_by('-cdate')
|
||||
# b = Screensaver.objects.values('cdate__month', 'cdate__day', 'enddate__month', 'enddate__day')
|
||||
# result = ScreensaverSerializer(queryset, many= True).data
|
||||
print(queryset,"--------------------------no foto screensaver")
|
||||
# queryset = queryset.filter(cdate=queryset[0].cdate).order_by("?")[:1]
|
||||
queryset = queryset.filter(cdate=queryset[0].cdate).order_by("?")[:1]
|
||||
|
||||
# result = ScreensaverSerializer(queryset, many= True).data
|
||||
result = ScreensaverSerializer(queryset[0]).data
|
||||
|
||||
|
||||
# except Exception as e:
|
||||
# print("no foto screensaver")
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
ENGINE=django.db.backends.mysql
|
||||
DBNAME = accounting
|
||||
USER =
|
||||
PASSWORD=
|
||||
HOST=127.0.0.1
|
||||
PORT=3306
|
||||
+12
-6
@@ -1,19 +1,25 @@
|
||||
from datetime import timedelta
|
||||
from dotenv import load_dotenv
|
||||
import os
|
||||
dotenv_path = os.path.join(os.path.dirname(__file__), '.env')
|
||||
load_dotenv(dotenv_path)
|
||||
class Settings():
|
||||
def __init__(self) -> None:
|
||||
|
||||
self.secret_key='V7bvDZMztr3EU8S9g1Dipw'
|
||||
self.redis_hosts = [("127.0.0.1", 6379)]
|
||||
self.access_token_lifetime = timedelta(minutes=480)
|
||||
self.refresh_token_lifetime = timedelta(days=1)
|
||||
self.db = {
|
||||
'default':{
|
||||
'ENGINE': 'django.db.backends.mysql',
|
||||
'NAME': 'accounting',
|
||||
'USER': 'root',
|
||||
'PASSWORD': 'ADMIN',
|
||||
'HOST': '127.0.0.1',
|
||||
'PORT': '3306',
|
||||
'ENGINE': str(os.getenv('ENGINE')),
|
||||
'NAME': str(os.getenv('DBNAME')),
|
||||
'USER': str(os.getenv('USER')),
|
||||
'PASSWORD': str(os.getenv('PASSWORD')),
|
||||
'HOST': str(os.getenv('HOST')),
|
||||
'PORT': str(os.getenv('PORT')),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
pass
|
||||
@@ -1,8 +0,0 @@
|
||||
class Settings():
|
||||
def __init__(self) -> None:
|
||||
self.secret_key=''
|
||||
self.redis_hosts = []
|
||||
self.db = {
|
||||
}
|
||||
|
||||
pass
|
||||
@@ -24,6 +24,7 @@ SECRET_KEY=stngs.secret_key
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
myDEBUG=True
|
||||
|
||||
SWAGGER_SETTINGS = {
|
||||
'DEFAULT_INFO': 'import.path.to.urls.api_info',
|
||||
'SECURITY_DEFINITIONS': {
|
||||
@@ -37,7 +38,7 @@ SWAGGER_SETTINGS = {
|
||||
}
|
||||
}
|
||||
}
|
||||
ALLOWED_HOSTS = []
|
||||
ALLOWED_HOSTS = ["*","portal-t",'portal9966']
|
||||
CHANNEL_LAYERS = {
|
||||
"default": {
|
||||
"BACKEND": "channels_redis.core.RedisChannelLayer",
|
||||
@@ -64,10 +65,10 @@ INSTALLED_APPS = [
|
||||
'navigation.apps.NavigationConfig',
|
||||
'drf_yasg',
|
||||
'accounts',
|
||||
'safety',
|
||||
|
||||
'vote.apps.VoteConfig',
|
||||
'commeteresp',
|
||||
'safety',
|
||||
'vote.apps.VoteConfig',
|
||||
|
||||
# 'orgmanagment',
|
||||
'corsheaders',
|
||||
'watcher.apps.WatcherConfig',
|
||||
@@ -77,7 +78,7 @@ INSTALLED_APPS = [
|
||||
'about_inspection.apps.AboutInspectionConfig',
|
||||
'calendar_of_events.apps.CalendarOfEventsConfig',
|
||||
'tests.apps.TestsConfig',
|
||||
'ckeditor'
|
||||
'django_ckeditor_5',
|
||||
|
||||
]
|
||||
|
||||
@@ -175,10 +176,10 @@ USE_TZ = True
|
||||
|
||||
|
||||
STATIC_URL = '/static/'
|
||||
STATICFILES_DIRS = (
|
||||
BASE_DIR.joinpath('static'),
|
||||
)
|
||||
# STATIC_ROOT = BASE_DIR.joinpath('static')
|
||||
# STATICFILES_DIRS = (
|
||||
# BASE_DIR.joinpath('static'),
|
||||
# )
|
||||
STATIC_ROOT = BASE_DIR.joinpath('static')
|
||||
CKEDITOR_UPLOAD_PATH = "uploads/"
|
||||
# Media
|
||||
MEDIA_URL = '/media/'
|
||||
|
||||
Binary file not shown.
@@ -20,21 +20,4 @@ class SafetyAPIView(APIView):
|
||||
chapters = self.request.query_params.get('chapter', "fire")
|
||||
safety_group = SafetyType.objects.get(path=chapters)
|
||||
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 .models import *
|
||||
|
||||
|
||||
|
||||
class InlineAppointment(admin.StackedInline):
|
||||
|
||||
fields = ('link_on_user',)
|
||||
model = SavedResultTest
|
||||
class TestAnswerInline(admin.StackedInline):
|
||||
model = TestAnswer
|
||||
extra = 0
|
||||
|
||||
class TestQuestionAdmin(admin.ModelAdmin):
|
||||
inlines = [TestAnswerInline]
|
||||
|
||||
class AppointmentAdmin(admin.ModelAdmin):
|
||||
inlines = [InlineAppointment]
|
||||
|
||||
|
||||
|
||||
class InlineQuestion(admin.StackedInline):
|
||||
fields = ('question_name', 'name_of_test', 'description', 'question_image',)
|
||||
model = Question
|
||||
class TestQuestionInline(admin.StackedInline):
|
||||
model = TestQuestion
|
||||
extra = 0
|
||||
|
||||
|
||||
class InlineAnswer(admin.StackedInline):
|
||||
fields = ('answer_variant', 'right_wrong', 'name_of_question'),
|
||||
model = Answer
|
||||
extra = 0
|
||||
|
||||
|
||||
class TestAdmin(admin.ModelAdmin):
|
||||
inlines = [InlineQuestion, InlineAnswer]
|
||||
|
||||
# Dunmmy добавлен временно пока не будет придумано как надо.
|
||||
admin.site.register(Dummy)
|
||||
inlines = [TestQuestionInline]
|
||||
|
||||
|
||||
admin.site.register(AppointmentTest, AppointmentAdmin)
|
||||
admin.site.register(Test, TestAdmin)
|
||||
admin.site.register(Question)
|
||||
admin.site.register(Answer)
|
||||
admin.site.register(SavedResultTest)
|
||||
admin.site.register(TestQuestion, TestQuestionAdmin)
|
||||
admin.site.register(TestAnswer)
|
||||
+63
-57
@@ -1,81 +1,87 @@
|
||||
from django.db import models
|
||||
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 Dummy(models.Model):
|
||||
dummy = models.CharField(max_length=255, verbose_name="Заглушка")
|
||||
class Test(models.Model):
|
||||
file = models.ImageField(upload_to='tests/files/', null=True, blank=True, 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):
|
||||
return self.dummy
|
||||
|
||||
|
||||
|
||||
# Модель тестов
|
||||
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="Количество попыток")
|
||||
|
||||
return self.name
|
||||
class Meta:
|
||||
verbose_name = "Тест"
|
||||
verbose_name_plural = "Тест"
|
||||
def __str__(self):
|
||||
return self.name_test
|
||||
verbose_name_plural = "Тесты"
|
||||
|
||||
# Модель вопросов
|
||||
class Question(models.Model):
|
||||
question_name = models.CharField(max_length=255, blank=False, verbose_name="Название вопроса")
|
||||
name_of_test = models.ForeignKey(Test,on_delete=models.PROTECT, verbose_name="Тест")
|
||||
description = models.CharField(max_length=255, blank=False, verbose_name="Описание")
|
||||
question_image = models.ImageField()
|
||||
class TestQuestion(models.Model):
|
||||
name = models.CharField(max_length=255, blank=False, verbose_name="Вопрос")
|
||||
test = models.ForeignKey(Test, related_name='questions', on_delete=models.CASCADE, verbose_name="Тест")
|
||||
file = models.ImageField(upload_to='tests/question_images/', null=True, blank=True, verbose_name='Картинка')
|
||||
numb = models.PositiveIntegerField(verbose_name="Порядковый номер вопроса")
|
||||
settings = models.JSONField(default=dict, verbose_name='Json настроек тестирования')
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Вопрос"
|
||||
verbose_name_plural = "Вопрос"
|
||||
verbose_name_plural = "Вопросы"
|
||||
|
||||
def __str__(self):
|
||||
return self.question_name
|
||||
return self.name
|
||||
|
||||
# Модель ответов
|
||||
class Answer(models.Model):
|
||||
answer_variant = models.CharField(max_length=255, blank=False, verbose_name="Вариант ответа")
|
||||
class TestAnswer(models.Model):
|
||||
name = 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="Правильно/Неправильно")
|
||||
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:
|
||||
verbose_name = "Ответ"
|
||||
verbose_name_plural = "Ответ"
|
||||
verbose_name_plural = "Ответы"
|
||||
|
||||
def __str__(self):
|
||||
return self.answer_variant
|
||||
|
||||
|
||||
|
||||
# Модель назначения тестов
|
||||
class AppointmentTest(models.Model):
|
||||
dedline_date = models.DateField(blank=True, null=True, verbose_name="Дата окончания тестирования" )
|
||||
tests = models.ForeignKey(Test, on_delete=models.PROTECT, blank=False, verbose_name="Тест")
|
||||
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)
|
||||
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="Дата прохождения теста")
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Назначение теста"
|
||||
verbose_name_plural = "Назначение теста"
|
||||
verbose_name = 'Попытка прохождения теста'
|
||||
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):
|
||||
return self.tests.name_test
|
||||
|
||||
|
||||
# Модель Сохраненных результатов
|
||||
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="Тест")
|
||||
return self.answer.name
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Результаты тестирования"
|
||||
verbose_name_plural = "Результаты тестирования"
|
||||
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.link_on_user.fio
|
||||
return self.test.name
|
||||
@@ -1,42 +1,89 @@
|
||||
from rest_framework import serializers
|
||||
from .models import *
|
||||
from userauth.models import *
|
||||
import base64
|
||||
import hashlib
|
||||
from cryptography.fernet import Fernet
|
||||
|
||||
# Dummy временно
|
||||
class DummySerializer(serializers.ModelSerializer):
|
||||
|
||||
class Meat:
|
||||
model = Dummy
|
||||
class TestAnswerSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = TestAnswer
|
||||
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:
|
||||
model = Question
|
||||
fields = ['question_name','name_of_test','description']
|
||||
|
||||
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 create(self, 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 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:
|
||||
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 = [
|
||||
path('alltests/', GetAllTests.as_view(), name="getalltests"),
|
||||
path('appointmentusers/', GetAppointmentsUsers.as_view(), name="getappointmentusers"),
|
||||
path('accomplished/', GetAccompishedTests.as_view(), name="getaccomplished"),
|
||||
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"),
|
||||
]
|
||||
|
||||
+171
-27
@@ -1,39 +1,183 @@
|
||||
from django.views.decorators.http import require_GET
|
||||
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 .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):
|
||||
queryset = Test.objects.all()
|
||||
paginator = AllTestsPagination()
|
||||
paginated_queryset = paginator.paginate_queryset(queryset,request)
|
||||
serializer = TestSerializer(paginated_queryset, many=True)
|
||||
return paginator.get_paginated_response(serializer.data)
|
||||
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):
|
||||
|
||||
queryset = TestResult.objects.all()
|
||||
serializer_class = TestResultSerializer
|
||||
|
||||
# Количество страниц передавать с фронта
|
||||
class GetAppointmentsUsers(APIView):
|
||||
def get(self, request):
|
||||
id_user = request.GET.get('id')
|
||||
queryset = SavedResultTest.objects.filter(link_on_user=id_user)
|
||||
paginator = AppointmentUserPagination()
|
||||
paginated_queryset = paginator.paginate_queryset(queryset, request)
|
||||
serializer = SavedResultTestSerializer(paginated_queryset, many=True)
|
||||
return paginator.get_paginated_response(serializer.data)
|
||||
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)
|
||||
|
||||
# Количество страниц передавать с фронта
|
||||
class GetAccompishedTests(APIView):
|
||||
def get(self, request):
|
||||
id_user = request.GET.get('id')
|
||||
queryset = SavedResultTest.objects.filter(link_on_user=id_user,accomp_wrong=True)
|
||||
paginator = AccomplishedPagination()
|
||||
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)
|
||||
if serializer.is_valid():
|
||||
serializer.save(attempt=test_attempt)
|
||||
self.update_testing(user, test_info)
|
||||
|
||||
return Response(test_info['is_passed'])
|
||||
|
||||
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())
|
||||
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:
|
||||
managed = False
|
||||
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 = "Сотрудники и их реальные отделы"
|
||||
+3
-12
@@ -1,15 +1,6 @@
|
||||
from django.contrib import admin
|
||||
from .models import *
|
||||
|
||||
# Register your models here.
|
||||
admin.site.register(ThanksVote)
|
||||
admin.site.register(BestVote)
|
||||
|
||||
|
||||
|
||||
class DictEmplyeeRAdmin(admin.ModelAdmin):
|
||||
list_display=('id_dict_employee', 'id_dict_department',)
|
||||
list_editable=('id_dict_department', )
|
||||
|
||||
|
||||
admin.site.register(DictEmplyeeR, DictEmplyeeRAdmin)
|
||||
admin.site.register(Vote)
|
||||
admin.site.register(Question)
|
||||
admin.site.register(Answer)
|
||||
@@ -4,4 +4,5 @@ from django.apps import AppConfig
|
||||
class VoteConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'vote'
|
||||
verbose_name = 'Голосование'
|
||||
|
||||
+46
-32
@@ -1,43 +1,57 @@
|
||||
from django.db import models
|
||||
from userauth.models import *
|
||||
from accounts.models import User
|
||||
import datetime
|
||||
# Create your models here.
|
||||
|
||||
|
||||
class ThanksVote(models.Model):
|
||||
voted_user = models.CharField(blank=False, max_length=255)
|
||||
department_user = models.CharField(
|
||||
blank=False, default=None, max_length=255)
|
||||
cand_name = models.CharField(blank=False, default=None, max_length=255)
|
||||
vote_thanks_date = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Голосование, хочу сказать спасибо!"
|
||||
verbose_name_plural = "Голосование, хочу сказать спасибо!"
|
||||
class Vote(models.Model):
|
||||
name = models.CharField(max_length=255,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='Создатель голосования')
|
||||
|
||||
def __str__(self):
|
||||
return self.cand_name
|
||||
|
||||
|
||||
class BestVote(models.Model):
|
||||
voted_user = models.CharField(blank=False, max_length=255)
|
||||
department_user = models.CharField(
|
||||
blank=False, default=None, max_length=255)
|
||||
cand_name = models.CharField(blank=False, default=None, max_length=255)
|
||||
vote_best_date = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
return self.name
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Голосование, мой коллега самый лучший"
|
||||
verbose_name_plural = "Голосование, мой коллега самый лучший"
|
||||
verbose_name = "Голосование"
|
||||
verbose_name_plural = "Голосования"
|
||||
|
||||
class Question(models.Model):
|
||||
name = models.CharField(max_length=255)
|
||||
vote = models.ForeignKey(Vote, related_name='questions', on_delete=models.CASCADE)
|
||||
file = models.ImageField(upload_to='vote/question_images/', null=True, blank=True)
|
||||
numb = models.PositiveIntegerField()
|
||||
settings = models.JSONField(default=dict, verbose_name='Json настроек голосования')
|
||||
|
||||
def __str__(self):
|
||||
return self.cand_name
|
||||
|
||||
class DictEmplyeeR(models.Model):
|
||||
# id = models.IntegerField(primary_key=True)
|
||||
id_dict_employee = models.ForeignKey(DictEmployee, models.DO_NOTHING)
|
||||
id_dict_department = models.ForeignKey(DictDepartment, models.DO_NOTHING)
|
||||
return self.name
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Сотрудники(реальные отделы)"
|
||||
verbose_name_plural = "Сотрудники(реальные отделы)"
|
||||
verbose_name = "Вопрос"
|
||||
verbose_name_plural = "Вопросы"
|
||||
|
||||
class Answer(models.Model):
|
||||
name = models.CharField(max_length=255)
|
||||
file = models.FileField(upload_to='vote/answer_files/', null=True, blank=True)
|
||||
question = models.ForeignKey(Question, related_name='answers', on_delete=models.CASCADE)
|
||||
|
||||
def __str__(self):
|
||||
return str(self.id_dict_employee)
|
||||
return self.name
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Ответ"
|
||||
verbose_name_plural = "Ответы"
|
||||
|
||||
class Result(models.Model):
|
||||
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
||||
answer = models.ForeignKey(Answer, on_delete=models.CASCADE)
|
||||
comment = models.TextField(null=True, blank=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.answer.name
|
||||
|
||||
class Meta:
|
||||
verbose_name = "Результат"
|
||||
verbose_name_plural = "Результаты"
|
||||
@@ -2,34 +2,58 @@ from rest_framework import serializers
|
||||
from .models import *
|
||||
from userauth.models import *
|
||||
|
||||
class VotesSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Vote
|
||||
fields = '__all__'
|
||||
|
||||
class GetEmpSerializer(serializers.ModelSerializer):
|
||||
def create(self, validated_data):
|
||||
user = self.context['request'].user
|
||||
if user.is_authenticated:
|
||||
validated_data['author'] = user
|
||||
|
||||
return super().create(validated_data)
|
||||
|
||||
class AnswerSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Answer
|
||||
fields = '__all__'
|
||||
|
||||
class QuestionSerializer(serializers.ModelSerializer):
|
||||
answers = AnswerSerializer(many=True, read_only=True)
|
||||
class Meta:
|
||||
model = Question
|
||||
fields = '__all__'
|
||||
|
||||
class VoteSerializer(serializers.ModelSerializer):
|
||||
questions = QuestionSerializer(many=True, read_only=True)
|
||||
class Meta:
|
||||
model = Vote
|
||||
fields = '__all__'
|
||||
# fields = ['id', 'name', 'description', 'datestart', 'dateend', 'settings', 'author']
|
||||
|
||||
def create(self, validated_data):
|
||||
user = self.context['request'].user
|
||||
if user.is_authenticated:
|
||||
validated_data['author'] = user
|
||||
|
||||
return super().create(validated_data)
|
||||
|
||||
class ResultSerializer(serializers.ModelSerializer):
|
||||
answer=serializers.PrimaryKeyRelatedField( queryset=Answer.objects.all(),many=False)
|
||||
user=serializers.PrimaryKeyRelatedField( queryset=User.objects.all(),many=False)
|
||||
comment = serializers.CharField(allow_null=True)
|
||||
class Meta:
|
||||
model = Result
|
||||
fields = '__all__'
|
||||
|
||||
class DictEmployeeSerializer(serializers.ModelSerializer):
|
||||
order_position = serializers.IntegerField(source = 'id_dict_position.order_position', read_only=True)
|
||||
class Meta:
|
||||
model = DictEmployee
|
||||
fields = ['id', 'id_dict_department',
|
||||
'fio', 'post', 'department']
|
||||
fields = '__all__'
|
||||
|
||||
class GetEmpSerializerR(serializers.ModelSerializer):
|
||||
id = serializers.IntegerField(source="id_dict_employee.id")
|
||||
fio = serializers.CharField(source="id_dict_employee.fio")
|
||||
id_dict_department = serializers.IntegerField(source="id_dict_department.id")
|
||||
post = serializers.CharField(source="id_dict_employee.post")
|
||||
department = serializers.CharField(source="id_dict_department.name")
|
||||
login=serializers.CharField(source='id_dict_employee.login')
|
||||
|
||||
class Meta:
|
||||
model = DictEmplyeeR
|
||||
fields = ['id', 'id_dict_department',
|
||||
'fio', 'post', 'department','login']
|
||||
|
||||
|
||||
class ThanksVoteSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = ThanksVote
|
||||
fields = ('id', 'voted_user', 'cand_name', 'vote_thanks_date','department_user')
|
||||
|
||||
|
||||
class BestVoteSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = BestVote
|
||||
fields = ('id', 'voted_user', 'cand_name', 'vote_best_date', 'department_user')
|
||||
class VoteResultSerializer(serializers.Serializer):
|
||||
answer = serializers.CharField(source='answer__answer')
|
||||
count = serializers.IntegerField()
|
||||
employee = DictEmployeeSerializer(required=False)
|
||||
+6
-14
@@ -4,18 +4,10 @@ from .views import *
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
path('get_for_thn/', GetForThn.as_view(),),
|
||||
path('get_for_bst/', GetForBst.as_view(),),
|
||||
path('setthanks/', SetThanks.as_view(), name=''),
|
||||
path('getthanks/', GetThanks.as_view(), name=''),
|
||||
path('setbest/', SetBest.as_view(), name=''),
|
||||
path('getbest/', GetBest.as_view(), name=''),
|
||||
path('getnotvotethn/', GetNotVoteThn.as_view()),
|
||||
path('getnotvotebst/', GetNotVoteBst.as_view()),
|
||||
|
||||
|
||||
path('getvoteinfo/', GetVoteInfo.as_view()),
|
||||
|
||||
|
||||
|
||||
path('getvotes/', GetVotes.as_view(),name='GetVotes'),
|
||||
path('votedetail/<int:id>/', VoteDetail.as_view(),name='VoteDetail'),
|
||||
path('votecreate/', VoteCreate.as_view(),name='VoteCreate'),
|
||||
path('getdictemployee/', GetDictEmployee.as_view(),name='GetDictEmployee'),
|
||||
path('getresults/', GetResults.as_view(),name='GetResults'),
|
||||
path('voteresultcreate/', VoteResultCreate.as_view(),name='VoteResultCreate'),
|
||||
]
|
||||
+218
-88
@@ -5,98 +5,228 @@ 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
|
||||
|
||||
# Create your views here.
|
||||
class GetVotes(APIView):
|
||||
|
||||
|
||||
class GetForThn(APIView):
|
||||
def get(self, request):
|
||||
user_login = request.GET.get('login')
|
||||
all_emps = DictEmplyeeR.objects.exclude(id_dict_employee__login=user_login).exclude(id_dict_department__name='Руководство').exclude(id_dict_employee__deleted=1).order_by('id_dict_employee__fio')
|
||||
return Response(GetEmpSerializerR(all_emps, many=True).data)
|
||||
user = request.user
|
||||
# user = User.objects.get(username='9966-00-125')
|
||||
now = datetime.now()
|
||||
status = request.query_params.get('status')
|
||||
votes = self.get_votes_by_status(status, now)
|
||||
serialized_votes = VotesSerializer(votes, many=True).data
|
||||
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)
|
||||
|
||||
class GetForBst(APIView):
|
||||
def get(self, request):
|
||||
user_login = request.GET.get('login')
|
||||
dep_id = DictEmplyeeR.objects.get(id_dict_employee__login=user_login)
|
||||
emp_user = DictEmplyeeR.objects.filter(Q(id_dict_department=dep_id.id_dict_department), ~Q(id_dict_employee__login=user_login)).exclude(id_dict_employee__deleted=1).order_by('id_dict_employee__fio')
|
||||
return Response(GetEmpSerializerR(emp_user, many=True).data)
|
||||
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]
|
||||
|
||||
|
||||
class SetThanks(APIView):
|
||||
def post(self, request):
|
||||
# department_user = request.data['department_user']
|
||||
cand_name = request.data['cand_name_id']
|
||||
depuser = DictEmplyeeR.objects.get(id_dict_employee__fio=cand_name)
|
||||
ThanksVote.objects.create(
|
||||
voted_user=request.user,
|
||||
department_user=depuser.id_dict_department.name,
|
||||
cand_name=cand_name
|
||||
)
|
||||
return Response("Ваш голос добавлен!")
|
||||
|
||||
|
||||
class GetThanks(APIView):
|
||||
def get(self, request):
|
||||
# Группировка кандидатов по имени и подсчет каждого
|
||||
count_thanks = ThanksVote.objects.values('voted_user',
|
||||
'cand_name').annotate(total=Count('id')).order_by('cand_name')
|
||||
return Response(count_thanks)
|
||||
|
||||
|
||||
class SetBest(APIView):
|
||||
def post(self, request):
|
||||
voted_user = request.user
|
||||
# department_user = request.data['department_user']
|
||||
cand_name = request.data['cand_name_id']
|
||||
depuser = DictEmplyeeR.objects.get(id_dict_employee__fio=cand_name)
|
||||
BestVote.objects.create(
|
||||
voted_user=voted_user,
|
||||
department_user=depuser.id_dict_department.name,
|
||||
cand_name=cand_name
|
||||
)
|
||||
return Response("Ваш голос добавлен!")
|
||||
|
||||
|
||||
|
||||
class GetBest(APIView):
|
||||
def get(self, request):
|
||||
# Группировка кандидатов по имени и подсчет каждого
|
||||
count_bests = BestVote.objects.values('voted_user','department_user', 'cand_name').annotate(total=Count('id')).order_by('cand_name')
|
||||
return Response(count_bests)
|
||||
|
||||
|
||||
class GetNotVoteThn(APIView):
|
||||
def get(self, request):
|
||||
list_thn_users = ThanksVote.objects.values('voted_user')
|
||||
list_emp = DictEmplyeeR.objects.filter(
|
||||
id_dict_employee__deleted=0).exclude(id_dict_employee__login__in=list_thn_users).exclude(id_dict_employee__department='Руководство').order_by('id_dict_employee__fio')
|
||||
return Response(GetEmpSerializerR(list_emp, many=True).data)
|
||||
|
||||
|
||||
class GetNotVoteBst(APIView):
|
||||
def get(self, request):
|
||||
list_bst_users = BestVote.objects.values('voted_user')
|
||||
list_emp_bst = DictEmplyeeR.objects.filter(
|
||||
id_dict_employee__deleted=0).exclude(id_dict_employee__login__in=list_bst_users).exclude(id_dict_employee__department='Руководство').order_by('id_dict_employee__fio')
|
||||
return Response(GetEmpSerializerR(list_emp_bst, many=True).data)
|
||||
|
||||
class GetVoteInfo(APIView):
|
||||
def get(self, request):
|
||||
print(request.user)
|
||||
allcod = DictEmplyeeR.objects.filter( id_dict_employee__deleted=0)
|
||||
|
||||
# try:
|
||||
realdep = allcod.get(id_dict_employee__login=request.user)
|
||||
|
||||
usersvotedbest=BestVote.objects.filter()
|
||||
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),
|
||||
}
|
||||
|
||||
uservotedthanks=ThanksVote.objects.all()
|
||||
|
||||
return Response({'allcod':GetEmpSerializerR(allcod, many=True).data,
|
||||
'voteresults':{'uservotedthanks': ThanksVoteSerializer(uservotedthanks,many=True).data,
|
||||
'usersvotedbest':BestVoteSerializer(usersvotedbest, many=True).data,
|
||||
}
|
||||
}
|
||||
)
|
||||
return status_filters.get(status, Vote.objects.none()).order_by('dateend')
|
||||
|
||||
def has_participated(self, employee, vote):
|
||||
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'
|
||||
|
||||
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}
|
||||
|
||||
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']))
|
||||
|
||||
return Response(serialized_data)
|
||||
|
||||
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:
|
||||
print(e)
|
||||
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'],
|
||||
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 = 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 = Question.objects.create(
|
||||
name=question_data['text'],
|
||||
vote=vote,
|
||||
file=question_image,
|
||||
numb=count,
|
||||
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
|
||||
Answer.objects.create(
|
||||
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}")
|
||||
|
||||
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
|
||||
)
|
||||
news.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)
|
||||
|
||||
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]
|
||||
|
||||
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)
|
||||
|
||||
return Response(serialized_data)
|
||||
|
||||
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)
|
||||
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
+3017
-21121
File diff suppressed because it is too large.
Load diff
+25
-47
@@ -6,67 +6,45 @@
|
||||
"build": "vite build",
|
||||
"preview": "vite preview",
|
||||
"lint": "eslint . --fix --ignore-path .gitignore",
|
||||
"storybook": "storybook dev -p 6006",
|
||||
"build-storybook": "storybook build"
|
||||
"docs": "vuepress build docs"
|
||||
},
|
||||
"dependencies": {
|
||||
"-": "^0.0.1",
|
||||
"@ckeditor/ckeditor5-build-classic": "^41.4.2",
|
||||
"@ckeditor/ckeditor5-dev-translations": "^40.0.0",
|
||||
"@ckeditor/ckeditor5-vue": "^5.1.0",
|
||||
"@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",
|
||||
"@ckeditor/ckeditor5-build-classic": "^44.1.0",
|
||||
"@ckeditor/ckeditor5-dev-translations": "^43.0.1",
|
||||
"@ckeditor/ckeditor5-vue": "^7.3.0",
|
||||
"@mdi/font": "7.4.47",
|
||||
"@vuelidate/core": "^2.0.3",
|
||||
"@vuelidate/validators": "^2.0.3",
|
||||
"@vuelidate/validators": "^2.0.4",
|
||||
"adapter": "^1.0.0-beta.10",
|
||||
"axios": "^1.4.0",
|
||||
"chart.js": "^4.4.1",
|
||||
"chartjs": "^0.3.24",
|
||||
"axios": "^1.7.9",
|
||||
"chart.js": "^4.4.7",
|
||||
"chartjs-adapter-moment": "^1.0.1",
|
||||
"chartjs-plugin-datalabels": "^2.2.0",
|
||||
"date-fns": "^2.30.0",
|
||||
"express-vue": "^5.12.0",
|
||||
"date-fns": "^4.1.0",
|
||||
"file-saver": "^2.0.5",
|
||||
"ical.js": "^2.0.0",
|
||||
"ical.js": "^2.1.0",
|
||||
"moment": "^2.30.1",
|
||||
"pinia": "^2.0.23",
|
||||
"roboto-fontface": "*",
|
||||
"pinia": "^2.3.1",
|
||||
"rrule": "^2.8.1",
|
||||
"v-tooltip": "^2.1.3",
|
||||
"vee-validate": "^4.12.8",
|
||||
"vue": "^3.2.0",
|
||||
"vue-cal": "^4.8.1",
|
||||
"vue-chartjs": "^5.3.0",
|
||||
"vue": "^3.5.13",
|
||||
"vue-cal": "^4.10.2",
|
||||
"vue-chartjs": "^5.3.2",
|
||||
"vue-jwt-decode": "^0.1.0",
|
||||
"vue-pdf-embed": "^2.0.3",
|
||||
"vue-router": "^4.0.0",
|
||||
"vue3-autocounter": "^1.0.6",
|
||||
"vue-pdf-embed": "^2.1.2",
|
||||
"vue-router": "^4.5.0",
|
||||
"vue3-autocounter": "^1.0.8",
|
||||
"vuelidate": "^0.7.7",
|
||||
"vuetify": "^3.6.11",
|
||||
"webfontloader": "^1.0.0",
|
||||
"yup": "^1.4.0"
|
||||
"vuetify": "^3.7.8",
|
||||
"webfontloader": "^1.6.28"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@storybook/addon-essentials": "^7.4.6",
|
||||
"@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",
|
||||
"@vitejs/plugin-vue": "^5.2.1",
|
||||
"@vue-leaflet/vue-leaflet": "^0.10.1",
|
||||
"eslint": "^8.22.0",
|
||||
"eslint-plugin-storybook": "^0.6.14",
|
||||
"eslint-plugin-vue": "^9.3.0",
|
||||
"eslint": "^9.19.0",
|
||||
"eslint-plugin-vue": "^9.32.0",
|
||||
"leaflet": "^1.9.4",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"vite": "^4.2.0",
|
||||
"vite-plugin-vuetify": "^1.0.0"
|
||||
"sass-embedded": "^1.83.4",
|
||||
"vite": "^6.0.11",
|
||||
"vite-plugin-vuetify": "^2.0.4"
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 16 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.2 MiB |
@@ -88,7 +88,7 @@
|
||||
type="error"
|
||||
density="compact"
|
||||
title="Ошибка авторизации"
|
||||
:text="info"
|
||||
|
||||
v-model="alert"
|
||||
|
||||
|
||||
|
||||
+12
-10
@@ -1,17 +1,18 @@
|
||||
<template>
|
||||
<v-card
|
||||
class="rounded-0 h-100 flex-column d-flex"
|
||||
min-height="410"
|
||||
max-height="410"
|
||||
min-height="400"
|
||||
max-height="400"
|
||||
|
||||
>
|
||||
<v-card-title class="pb-1">
|
||||
<v-card-title class="">
|
||||
{{news.title}}
|
||||
</v-card-title>
|
||||
<v-row class="flex-grow-0">
|
||||
<v-col class="d-flex flex-column ">
|
||||
<v-img
|
||||
:src="`${burl}${news.link}`"
|
||||
height="175px"
|
||||
height="170px"
|
||||
width="92%"
|
||||
class="mx-auto"
|
||||
cover
|
||||
@@ -20,7 +21,7 @@
|
||||
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-divider/>
|
||||
|
||||
<v-row class="ma-0 flex-grow-0">
|
||||
<v-col
|
||||
class="py-1 pl-4"
|
||||
@@ -84,7 +85,7 @@
|
||||
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-divider/>
|
||||
<v-divider class="mx-4"/>
|
||||
<v-row class="ma-0 overflow-auto">
|
||||
<v-col
|
||||
class="py-0"
|
||||
@@ -97,14 +98,15 @@
|
||||
</v-card-text>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-divider/>
|
||||
<v-divider class="mx-4"/>
|
||||
<v-row class="flex-grow-0 ma-0">
|
||||
<v-col class="d-flex justify-space-between">
|
||||
<v-btn
|
||||
color="more_details_btn"
|
||||
variant="text"
|
||||
|
||||
:to='`/newsfull?id=${news.id}`'
|
||||
size="small"
|
||||
size="small"
|
||||
rounded="xl"
|
||||
append-icon="mdi-step-forward-2"
|
||||
>
|
||||
Подробнее
|
||||
@@ -130,7 +132,7 @@ const accountStore = useAccountStore()
|
||||
export default {
|
||||
|
||||
components: { icoUser },
|
||||
|
||||
name:'NewsCard',
|
||||
props: {
|
||||
news: {
|
||||
type: Object,
|
||||
@@ -0,0 +1,133 @@
|
||||
<template>
|
||||
<v-row class="px-2">
|
||||
<v-card variant="text"
|
||||
:disabled="disabledcard.disabled"
|
||||
class="py-2 mx-auto">
|
||||
<v-card-title class="text-body-1">
|
||||
До {{ disabledcard.text }} голосования осталось:
|
||||
|
||||
</v-card-title>
|
||||
<v-row no-gutters class="align-baseline">
|
||||
<v-col class="text-center">
|
||||
<v-card class="bg-yellow-darken-4">
|
||||
<div>{{ displayDays }}</div>
|
||||
</v-card>
|
||||
<span class="text-caption">{{ declOfNum(displayDays, [' день', ' дня', ' дней']) }}</span>
|
||||
</v-col>
|
||||
<v-col cols="auto" class="px-1">:</v-col>
|
||||
<v-col class="text-center">
|
||||
<v-card class="bg-yellow-darken-4">
|
||||
<div>{{ displayHours }}</div>
|
||||
</v-card>
|
||||
<span class="text-caption">{{ declOfNum(displayHours, [' час', ' часа', ' часов']) }}</span>
|
||||
</v-col>
|
||||
<v-col cols="auto" class="px-1">:</v-col>
|
||||
<v-col class="text-center">
|
||||
<v-card class="bg-yellow-darken-4">
|
||||
<div>{{ displayMinutes }}</div>
|
||||
</v-card>
|
||||
<span class="text-caption">{{ declOfNum(displayMinutes, [' минута', ' минуты', ' минут']) }}</span>
|
||||
</v-col>
|
||||
<v-col cols="auto" class="px-1">:</v-col>
|
||||
<v-col class="text-center">
|
||||
<v-card class="bg-yellow-darken-4">
|
||||
<div>{{ displaySeconds }}</div>
|
||||
</v-card>
|
||||
<span class="text-caption">{{ declOfNum(displaySeconds, [' секунда', ' секунды', ' секунд']) }}</span>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-card>
|
||||
</v-row>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { declOfNum } from '@/utils/universal_functions'
|
||||
import { computed, ref } from 'vue'
|
||||
|
||||
export default {
|
||||
props: {
|
||||
voteTime: {
|
||||
type: Object,
|
||||
default: () => { return {
|
||||
dateend: new Date().setFullYear(),
|
||||
datestart: new Date().setFullYear()
|
||||
}}
|
||||
}
|
||||
},
|
||||
setup(props, {emit}) {
|
||||
const seconds = 1000
|
||||
const displayMinutes = ref(0);
|
||||
const displayHours = ref(0);
|
||||
const displayDays = ref(0);
|
||||
const displaySeconds = ref(0);
|
||||
const isFinished = ref(false);
|
||||
|
||||
|
||||
const minutes = computed(() => seconds * 60);
|
||||
const hours = computed(() => minutes.value * 60);
|
||||
const days = computed(() => hours.value * 24);
|
||||
|
||||
const disabledcard = ref({
|
||||
text: 'окончания',
|
||||
disabled: false
|
||||
});
|
||||
|
||||
const dateendorStart = () => {
|
||||
let param = 'dateend';
|
||||
|
||||
if (new Date().getTime() < new Date(props.voteTime.datestart).getTime()) {
|
||||
param = 'datestart';
|
||||
disabledcard.value = {
|
||||
text: 'начала',
|
||||
disabled: true,
|
||||
};
|
||||
emit('changeBtn', true);
|
||||
} else {
|
||||
disabledcard.value = {
|
||||
text: 'окончания',
|
||||
disabled: false,
|
||||
};
|
||||
emit('changeBtn', false);
|
||||
}
|
||||
return param;
|
||||
};
|
||||
|
||||
function countDown() {
|
||||
const timer = setInterval(() => {
|
||||
const date = new Date()
|
||||
const distance = new Date(props.voteTime[dateendorStart()]).getTime() - date.getTime()
|
||||
|
||||
if (distance <= 1) {
|
||||
clearInterval(timer)
|
||||
setTimeout(()=>countDown(),1000)
|
||||
return
|
||||
}
|
||||
|
||||
const daysOf = Math.floor(distance / days.value)
|
||||
const hoursOf = Math.floor((distance % days.value) / hours.value)
|
||||
const minutesOf = Math.floor((distance % hours.value) / minutes.value)
|
||||
const secondsOf = Math.floor((distance % minutes.value) / seconds)
|
||||
|
||||
displayDays.value = daysOf < 10 ? "0" + daysOf : daysOf
|
||||
displayHours.value = hoursOf < 10 ? "0" + hoursOf : hoursOf
|
||||
displayMinutes.value = minutesOf < 10 ? "0" + minutesOf : minutesOf
|
||||
displaySeconds.value = secondsOf < 10 ? "0" + secondsOf : secondsOf
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
countDown()
|
||||
|
||||
return {
|
||||
displayMinutes,
|
||||
displayHours,
|
||||
displayDays,
|
||||
displaySeconds,
|
||||
declOfNum,
|
||||
dateendorStart,
|
||||
disabledcard,
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -19,14 +19,14 @@
|
||||
density="compact"
|
||||
v-bind="props"
|
||||
>
|
||||
<template v-slot:prepend-inner>
|
||||
<template v-slot:prepend-inner>
|
||||
<v-icon
|
||||
v-bind="props"
|
||||
v-bind="props"
|
||||
icon='mdi-calendar-today'
|
||||
color="cyan-darken-3"
|
||||
size="x-small"
|
||||
|
||||
/>
|
||||
|
||||
/>
|
||||
</template>
|
||||
</v-textarea>
|
||||
</template>
|
||||
@@ -37,8 +37,6 @@
|
||||
hide-header
|
||||
@update:modelValue="dateStart"
|
||||
border
|
||||
:max="formatDash(new Date())"
|
||||
:min="formatDash(appStore.countvisitor.visitdate)"
|
||||
/>
|
||||
|
||||
</v-locale-provider>
|
||||
@@ -59,14 +57,14 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
setup(props, {emit}) {
|
||||
const appStore = useAppStore()
|
||||
const maxdate = formatDash(new Date())
|
||||
const menudate = ref(false)
|
||||
const selectedDate = ref(null)
|
||||
|
||||
|
||||
const dateStart = () => {
|
||||
emit('returndate', selectedDate.value)
|
||||
menudate.value=false
|
||||
@@ -102,4 +100,4 @@ export default {
|
||||
.v-field__prepend-inner {
|
||||
align-items: center!important;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
@@ -4,7 +4,7 @@
|
||||
persistent
|
||||
width="600"
|
||||
class="mx-auto"
|
||||
>
|
||||
>
|
||||
<v-card height="500">
|
||||
<v-card-title class="pl-6">
|
||||
Информация
|
||||
@@ -22,7 +22,7 @@
|
||||
max-height="222px"
|
||||
:src="checkremote(`${spravURL}${author.login}.jpg`)"
|
||||
/>
|
||||
|
||||
|
||||
</v-col>
|
||||
<v-col class="d-flex flex-column">
|
||||
<v-row
|
||||
@@ -65,9 +65,9 @@
|
||||
<v-divider/>
|
||||
<v-card-actions class="align-self-end py-0">
|
||||
<v-btn
|
||||
color="modal_btn"
|
||||
variant="text"
|
||||
@click= "$emit('update:opendialog', value)"
|
||||
rounded="xl"
|
||||
color="more_details_btn"
|
||||
@click= "$emit('update:opendialog', false)"
|
||||
>
|
||||
Закрыть
|
||||
</v-btn>
|
||||
@@ -101,9 +101,9 @@ export default {
|
||||
setup (props, {emit}) {
|
||||
|
||||
const mydialog = computed({
|
||||
get: () => props.opendialog,
|
||||
set: (value) => emit('update:opendialog', value)
|
||||
})
|
||||
get: () => props.opendialog,
|
||||
set: (value) => emit('update:opendialog', value)
|
||||
})
|
||||
|
||||
const basicInformation = () => [
|
||||
{title: 'Отдел:', info: props.author.department},
|
||||
@@ -131,4 +131,4 @@ export default {
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
</style>
|
||||
@@ -156,7 +156,7 @@
|
||||
<br />
|
||||
<span class="text-h5 text-grey"
|
||||
>Сейчас вакансий нет, <br />
|
||||
загляните позжет</span
|
||||
загляните позже</span
|
||||
>
|
||||
</v-card-subtitle>
|
||||
</v-card>
|
||||
|
||||
@@ -121,11 +121,11 @@
|
||||
import { formatComa } from "@/utils/universal_functions";
|
||||
import { ref } from "vue";
|
||||
import { axiosApiInstance } from "@/utils/axios-api";
|
||||
import CKEditor from "@ckeditor/ckeditor5-vue";
|
||||
import ClassicEditor from "@ckeditor/ckeditor5-build-classic";
|
||||
import "@ckeditor/ckeditor5-build-classic/build/translations/ru";
|
||||
import EventDialogEditParticipant from "./event-dialog-edit-participant.vue";
|
||||
import eventDialogEdit from "@/components/calendar_of_events/event-dialog-edit.vue";
|
||||
// import CKEditor from "@ckeditor/ckeditor5-vue";
|
||||
// import ClassicEditor from "@ckeditor/ckeditor5-build-classic";
|
||||
// import "@ckeditor/ckeditor5-build-classic/build/translations/ru";
|
||||
// import EventDialogEditParticipant from "./event-dialog-edit-participant.vue";
|
||||
|
||||
|
||||
export default {
|
||||
props: {
|
||||
@@ -136,8 +136,8 @@ export default {
|
||||
},
|
||||
components: {
|
||||
// Use the <ckeditor> component in this view.
|
||||
ckeditor: CKEditor.component,
|
||||
EventDialogEditParticipant,
|
||||
// ckeditor: CKEditor.component,
|
||||
// EventDialogEditParticipant,
|
||||
},
|
||||
|
||||
setup(props, { emit }) {
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
<v-spacer/>
|
||||
<v-btn
|
||||
color="modal_btn"
|
||||
variant="text"
|
||||
rounded="xl"
|
||||
text="Закрыть"
|
||||
@click="menusCloses"
|
||||
/>
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
<template>
|
||||
|
||||
<v-carousel
|
||||
cycle
|
||||
interval="10000"
|
||||
v-model="currentslide"
|
||||
:interval="interval"
|
||||
cover
|
||||
cycle
|
||||
height="450"
|
||||
hide-delimiters
|
||||
hide-delimiter-background
|
||||
:show-arrows="carous.length<2?false:'hover'"
|
||||
color="white"
|
||||
@update:modelValue="slidechanged"
|
||||
>
|
||||
|
||||
<v-carousel-item
|
||||
v-for="(x, i) in carous"
|
||||
:key="i"
|
||||
|
||||
<template v-for="(x, i) in carous" :key="i">
|
||||
<v-carousel-item
|
||||
v-if="!x.link.endsWith('mp4')"
|
||||
:src="`${burl}${x.link}`"
|
||||
cover
|
||||
eager
|
||||
@@ -67,19 +70,42 @@
|
||||
</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
|
||||
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>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { ref } from "vue";
|
||||
import { ref, computed } 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 burl = baseURL.slice(0, -1);
|
||||
|
||||
const videoElement=ref(null)
|
||||
const carous = ref([{ link: `/media/newsimage/scales.jpg`, "title": null, "text": "" }]);
|
||||
const feedalert = useAlertStore().alert;
|
||||
|
||||
@@ -92,6 +118,7 @@ export default {
|
||||
feedalert.ico = "mdi-alert-outline";
|
||||
}
|
||||
|
||||
console.log(result.data);
|
||||
if (result.data.result.length > 0) {
|
||||
carous.value = result.data.result;
|
||||
}
|
||||
@@ -100,10 +127,53 @@ export default {
|
||||
};
|
||||
|
||||
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 {
|
||||
slidechanged,
|
||||
videoElement,
|
||||
currentslide,
|
||||
interval,
|
||||
// intervalcomp,
|
||||
burl,
|
||||
carous,
|
||||
ended
|
||||
};
|
||||
},
|
||||
};
|
||||
|
||||
@@ -42,7 +42,8 @@
|
||||
</v-card>
|
||||
<v-divider class="" />
|
||||
<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-card-actions>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<v-row>
|
||||
<v-row class="py-2">
|
||||
<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-for="(x, key) in newsAll"
|
||||
:key="key"
|
||||
@@ -11,27 +11,40 @@
|
||||
sm=12
|
||||
xs=12
|
||||
cols=12
|
||||
class="d-flex pa-1 flex-column "
|
||||
class="d-flex pa-0 flex-column "
|
||||
>
|
||||
<news-card :news="x"/>
|
||||
{{aNewsAll}}
|
||||
<NewsCard :news="x" class="ma-1"/>
|
||||
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
<v-row class="flex-grow-0 ">
|
||||
<v-col class="pa-0" >
|
||||
<v-pagination
|
||||
density="compact"
|
||||
v-model="page"
|
||||
:length=visiblePage
|
||||
:length="visiblePage"
|
||||
:total-visible="7"
|
||||
@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 class="flex-grow-0 py-0">
|
||||
<v-col class="flex-grow-0 py-0 " >
|
||||
<v-select
|
||||
style="width:53px"
|
||||
hide-details
|
||||
hide-selected
|
||||
density="compact"
|
||||
hide-selected
|
||||
|
||||
v-model="countpage"
|
||||
rounded
|
||||
variant="underlined"
|
||||
@@ -50,12 +63,12 @@
|
||||
import { ref } from 'vue'
|
||||
import { axiosApiInstance } from '@/utils/axios-api'
|
||||
import { useRoute } from 'vue-router'
|
||||
import newsCard from './UI/news-card.vue'
|
||||
import NewsCard from './UI/NewsCard.vue'
|
||||
|
||||
export default {
|
||||
|
||||
components: {
|
||||
newsCard
|
||||
NewsCard
|
||||
},
|
||||
|
||||
setup(){
|
||||
@@ -68,21 +81,27 @@ export default {
|
||||
const visiblePage = ref(0)
|
||||
|
||||
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
|
||||
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()
|
||||
const pager=(val)=>{
|
||||
page.value=Number(val)
|
||||
loadNewsAll()
|
||||
}
|
||||
|
||||
return {
|
||||
newsAll,
|
||||
|
||||
countetnews,
|
||||
pager,
|
||||
page,
|
||||
countpage,
|
||||
visiblePage,
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
<template>
|
||||
<v-row>
|
||||
<v-col class="flex-column d-flex">
|
||||
<v-row class="mt-0 h-0 overflow-auto ">
|
||||
<v-row class="">
|
||||
<v-col class="flex-column d-flex pa-0">
|
||||
<v-row class="mt-0 mx-3 h-0 overflow-auto ">
|
||||
<v-col
|
||||
v-for="(x, key) in newsAll"
|
||||
:key="key"
|
||||
class="pb-1 pt-0"
|
||||
class="py-1"
|
||||
lg=12
|
||||
md=6
|
||||
sm=6
|
||||
>
|
||||
<news-card :news="x"/>
|
||||
|
||||
<NewsCard :news="x"/>
|
||||
|
||||
|
||||
<v-dialog
|
||||
v-model="dialogfotoOne"
|
||||
@@ -73,12 +73,12 @@
|
||||
import { ref } from 'vue'
|
||||
import { axiosApiInstance } from '@/utils/axios-api'
|
||||
import { useRoute } from 'vue-router'
|
||||
import newsCard from './UI/news-card.vue'
|
||||
import NewsCard from './UI/NewsCard.vue'
|
||||
|
||||
export default {
|
||||
|
||||
components: {
|
||||
newsCard
|
||||
NewsCard
|
||||
},
|
||||
|
||||
setup(){
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
<template>
|
||||
<div class="px-4">
|
||||
{{ displayDays + declOfNum(displayDays, [' день', ' дня', ' дней']) }}
|
||||
{{ displayHours + declOfNum(displayHours, [' час', ' часа', ' часов']) }}
|
||||
{{ displayMinutes + declOfNum(displayMinutes, [' минута', ' минуты', ' минут']) }}
|
||||
{{ displaySeconds + declOfNum(displaySeconds, [' секунда', ' секунды', ' секунд']) }}
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
|
||||
import { computed, ref } from 'vue'
|
||||
|
||||
export default {
|
||||
props: {
|
||||
endTime: {
|
||||
type: Date,
|
||||
default: () => { return new Date.setFullYear() }
|
||||
}
|
||||
},
|
||||
|
||||
setup(props) {
|
||||
|
||||
const seconds = 1000
|
||||
const displayMinutes = ref(0);
|
||||
const displayHours = ref(0);
|
||||
const displayDays = ref(0);
|
||||
const displaySeconds = ref(0)
|
||||
|
||||
const minutes = computed(() => {
|
||||
return seconds * 60
|
||||
})
|
||||
|
||||
const hours = computed(() => {
|
||||
return minutes.value * 60
|
||||
})
|
||||
|
||||
const days = computed(() => {
|
||||
return 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]]
|
||||
}
|
||||
|
||||
function countDown() {
|
||||
const timer = setInterval(() => {
|
||||
const date = new Date()
|
||||
const distance = props.endTime.getTime() - date.getTime()
|
||||
|
||||
if (distance < 0) {
|
||||
clearInterval(timer)
|
||||
return
|
||||
}
|
||||
|
||||
displayDays.value = Math.floor(distance / days.value)
|
||||
displayHours.value = Math.floor((distance % days.value) / hours.value)
|
||||
displayMinutes.value = Math.floor((distance % hours.value) / minutes.value)
|
||||
displaySeconds.value = Math.floor((distance % minutes.value) / seconds)
|
||||
|
||||
|
||||
}, 1000)
|
||||
}
|
||||
|
||||
countDown()
|
||||
|
||||
return {
|
||||
displayMinutes,
|
||||
displayHours,
|
||||
displayDays,
|
||||
displaySeconds,
|
||||
declOfNum,
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -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>
|
||||
@@ -0,0 +1,280 @@
|
||||
<template>
|
||||
<template v-if="!isVoteSubmitted">
|
||||
<v-card style="height: 85vh;">
|
||||
<div class="d-flex flex-column flex-fill px-2 ">
|
||||
<v-col cols="auto">
|
||||
<v-row class="d-flex flex-column">
|
||||
<v-col class="d-flex flex-row pa-0" cols="12">
|
||||
<v-col>
|
||||
<v-card-title>{{ data.name }}</v-card-title>
|
||||
<v-card-subtitle>{{ data.description }}</v-card-subtitle>
|
||||
</v-col>
|
||||
<v-col cols="auto">
|
||||
<v-btn color="red-darken-1" density="compact" icon="mdi-close-thick" size="small"
|
||||
@click="$emit('closer')">
|
||||
</v-btn>
|
||||
</v-col>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-col>
|
||||
<div class="d-flex flex-column flex-fill ">
|
||||
<v-stepper v-model="activeStep" class="d-flex flex-column flex-fill">
|
||||
<!-- Шаги голосования -->
|
||||
<v-stepper-header class="py-0">
|
||||
<template v-for="question in data.questions" :key="question.numb">
|
||||
<v-stepper-item
|
||||
:color="question.numb < activeStep+1?'success':'warning'"
|
||||
:complete="question.numb < activeStep+1"
|
||||
:step="question.numb" edit-icon="mdi-help">
|
||||
Вопрос {{ question.numb }}
|
||||
</v-stepper-item>
|
||||
</template>
|
||||
</v-stepper-header>
|
||||
<v-stepper-window class="d-flex flex-column flex-fill">
|
||||
<v-stepper-window-item
|
||||
v-for="(question, index) in data.questions"
|
||||
:key="question.numb"
|
||||
:step="question.numb">
|
||||
<div>
|
||||
<h3 class="text-center">
|
||||
{{ question.name }}
|
||||
<span class="text-subtitle-1">(вариантов ответа: {{ question.settings.multiChoice }})</span>
|
||||
</h3>
|
||||
<v-row>
|
||||
<div class="v-col align-self-start">
|
||||
<VoteAnimation v-if="!question.file" />
|
||||
<v-img
|
||||
:src="question.file"
|
||||
class="cursor-pointer"
|
||||
style="max-height:45vh"
|
||||
@click.stop="opendialog({ answer: question.question, file: question.file })"/>
|
||||
</div>
|
||||
<div class="v-col-6" style="max-height:50vh">
|
||||
<v-list v-model:selected="result[question.id]" density="compact" select-strategy="leaf" slim style="max-height: 100%; overflow-y: auto;">
|
||||
<template v-for="(answers, department) in groupedAnswers(question)" :key="department">
|
||||
<v-list-item-subtitle v-if="department">
|
||||
{{ department }}
|
||||
</v-list-item-subtitle>
|
||||
<v-list-item
|
||||
v-for="answer in answers"
|
||||
:key="answer.id"
|
||||
:value="answer.id"
|
||||
:disabled="result[question.id]?.length >= question.settings.multiChoice && !result[question.id]?.includes(answer.id)"
|
||||
density="compact">
|
||||
{{ answer.employee?.fio || answer.name }}
|
||||
|
||||
<template v-slot:prepend="{ isSelected }">
|
||||
<v-list-item-action start>
|
||||
<v-checkbox-btn :model-value="isSelected"></v-checkbox-btn>
|
||||
</v-list-item-action>
|
||||
</template>
|
||||
<template v-slot:append>
|
||||
<v-avatar
|
||||
v-if="answer.file === null && answer.employee"
|
||||
:image="checkremote(`${spravURL}${answer.employee.login}.jpg`)"
|
||||
@click.stop="opendialog(checkremote(`${spravURL}${answer.employee.login}.jpg`))" />
|
||||
<v-avatar
|
||||
v-if="answer.file !== null"
|
||||
:image="answer.file"
|
||||
@click.stop="opendialog(answer)">
|
||||
</v-avatar>
|
||||
</template>
|
||||
</v-list-item>
|
||||
</template>
|
||||
</v-list>
|
||||
</div>
|
||||
</v-row>
|
||||
</div>
|
||||
</v-stepper-window-item>
|
||||
|
||||
</v-stepper-window>
|
||||
<v-stepper-actions>
|
||||
<template v-slot:prev>
|
||||
|
||||
<v-btn outlined @click="prevStep">Назад</v-btn>
|
||||
</template>
|
||||
<template v-slot:next>
|
||||
|
||||
<v-btn v-if="activeStep < data.questions.length - 1" :disabled="!isCurrentQuestionAnswered"
|
||||
color="teal-darken-4"
|
||||
@click="nextStep">
|
||||
Далее
|
||||
</v-btn>
|
||||
<v-btn v-else :disabled="!isCurrentQuestionAnswered" color="teal-darken-4" @click="submitVote">
|
||||
Отправить
|
||||
</v-btn>
|
||||
</template>
|
||||
</v-stepper-actions>
|
||||
</v-stepper>
|
||||
</div>
|
||||
</div>
|
||||
</v-card>
|
||||
<v-dialog v-model="dialog" max-width="100vh">
|
||||
<v-card max-height="800">
|
||||
<v-card-title class="v-row">
|
||||
<div class="v-col-auto">
|
||||
{{ activepick.answer }}
|
||||
</div>
|
||||
<v-spacer></v-spacer>
|
||||
<div>
|
||||
<v-btn color="red-darken-1" density="compact" icon="mdi-close-thick" size="small" @click="dialog=false"/>
|
||||
</div>
|
||||
|
||||
</v-card-title>
|
||||
<v-card-item>
|
||||
<v-img :src="activepick.file ?? activepick" max-height="600"></v-img>
|
||||
</v-card-item>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</template>
|
||||
|
||||
<!-- Спасибо за голос -->
|
||||
<template v-else>
|
||||
<v-card class="mx-auto" width="400">
|
||||
<v-row align="center" class="pa-3" justify="center">
|
||||
<v-col class="text-center">
|
||||
<v-icon :color="messeger[messeger.key].color" :icon="messeger[messeger.key].icon" size="64"/>
|
||||
<h2>{{ messeger[messeger.key].text }}</h2>
|
||||
<v-btn class="ma-3 " @click="$emit('closer')">Закрыть</v-btn>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-card>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {axiosApiInstance, spravURL} from "@/utils/axios-api";
|
||||
import {computed, ref} from "vue";
|
||||
import {useAccountStore} from "@/store/AccountStore";
|
||||
import {checkremote} from "@/utils/universal_functions";
|
||||
import VoteAnimation from "@/components/vote/VoteAnimation.vue";
|
||||
|
||||
|
||||
export default {
|
||||
name: 'CurrentVote',
|
||||
components: {VoteAnimation},
|
||||
|
||||
emits: ['closer'],
|
||||
props: {
|
||||
data: {
|
||||
type: Object,
|
||||
required: true,
|
||||
default: () => ({}),
|
||||
},
|
||||
},
|
||||
setup(props, {emit}) {
|
||||
const accountStore = useAccountStore();
|
||||
const messeger = ref({
|
||||
good: {icon: 'mdi-check-circle', text: 'Спасибо за Ваш голос!', color: "green"},
|
||||
bad: {icon: 'mdi-alert', text: 'Произошла ошибка!', color: "red"},
|
||||
key: 'good'
|
||||
})
|
||||
const activeStep = ref(0);
|
||||
const answers = ref(props.data.questions.map(() => null));
|
||||
const isVoteSubmitted = ref(false);
|
||||
|
||||
const isCurrentQuestionAnswered = computed(() => {
|
||||
let q = props.data.questions.find(e => e.numb === activeStep.value + 1)
|
||||
return q !== undefined ? result.value[q.id].length > 0 : false;
|
||||
});
|
||||
|
||||
const getres = () => {
|
||||
return props.data.questions.reduce((acc, item) => {
|
||||
acc[item.id] = []
|
||||
return acc
|
||||
}, {})
|
||||
}
|
||||
const result = ref(getres())
|
||||
const nextStep = () => {
|
||||
if (activeStep.value < props.data.questions.length - 1) {
|
||||
activeStep.value++;
|
||||
}
|
||||
};
|
||||
|
||||
const prevStep = () => {
|
||||
if (activeStep.value > 0) {
|
||||
activeStep.value--;
|
||||
}
|
||||
};
|
||||
|
||||
const submitVote = () => {
|
||||
let voteData = []
|
||||
for (let val of Object.values(result.value)) {
|
||||
val.forEach(e => voteData.push({answer: e, comment: null, user: accountStore.user.id}))
|
||||
}
|
||||
|
||||
axiosApiInstance.post('api/vote/voteresultcreate/', voteData).then(res => {
|
||||
messeger.value.key = 'good'
|
||||
|
||||
}).catch(e => {
|
||||
console.log(e);
|
||||
messeger.value.key = 'bad'
|
||||
}
|
||||
).finally(() => isVoteSubmitted.value = true)
|
||||
|
||||
};
|
||||
|
||||
const activepick = ref(null)
|
||||
const dialog = ref(false)
|
||||
const opendialog = (val) => {
|
||||
dialog.value = true
|
||||
activepick.value = val
|
||||
}
|
||||
|
||||
const groupedAnswers = (question) => {
|
||||
const filtered = question.answers.filter(answer => answer.employee?.id !== accountStore.user.is_idEmployee);
|
||||
|
||||
if (question.settings.onlyDep === null) {
|
||||
return groupByDepartment(filtered);
|
||||
} else if (question.settings.onlyDep) {
|
||||
const byDepartment = filtered.filter(
|
||||
(answer) => answer.employee?.department === accountStore.user.department
|
||||
);
|
||||
return groupByDepartment(byDepartment);
|
||||
} else {
|
||||
const notByDepartment = filtered.filter(
|
||||
(answer) => answer.employee?.department !== accountStore.user.department
|
||||
);
|
||||
return groupByDepartment(notByDepartment);
|
||||
}
|
||||
};
|
||||
|
||||
const groupByDepartment = (answers) => {
|
||||
return answers.reduce((groups, answer) => {
|
||||
const department = answer.employee?.department || "";
|
||||
if (!groups[department]) {
|
||||
groups[department] = [];
|
||||
}
|
||||
groups[department].push(answer);
|
||||
return groups;
|
||||
}, {});
|
||||
};
|
||||
|
||||
|
||||
return {
|
||||
spravURL,
|
||||
checkremote,
|
||||
groupedAnswers,
|
||||
activepick,
|
||||
opendialog,
|
||||
dialog,
|
||||
messeger,
|
||||
activeStep,
|
||||
answers,
|
||||
isCurrentQuestionAnswered,
|
||||
nextStep,
|
||||
prevStep,
|
||||
submitVote,
|
||||
isVoteSubmitted,
|
||||
result
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.v-label {
|
||||
color: #000 !important;
|
||||
opacity: 1 !important;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,143 @@
|
||||
<template>
|
||||
<v-container class="d-flex flex-column align-center">
|
||||
<div id="container">
|
||||
<div id="success-box">
|
||||
<div class="face">
|
||||
<div class="eye"></div>
|
||||
<div class="eye right"></div>
|
||||
<div class="mouth happy"></div>
|
||||
</div>
|
||||
<div class="shadow scale"></div>
|
||||
<div class="message"><h1 class="alert">Все проголосовали!</h1><p>тех, кто не голосовал нет</p></div>
|
||||
</div>
|
||||
</div>
|
||||
</v-container>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
setup() {
|
||||
return {};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
$white: #80CBC4;
|
||||
$gray: #CBCDD3;
|
||||
$dark: #000000;
|
||||
|
||||
@import url('https://fonts.googleapis.com/css?family=Lato:400,700');
|
||||
|
||||
$font: 'Lato', sans-serif;
|
||||
|
||||
#container {
|
||||
position: relative;
|
||||
margin: auto;
|
||||
overflow: hidden;
|
||||
width: 50vw;
|
||||
height: 40vh;
|
||||
}
|
||||
|
||||
#success-box {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 80vh;
|
||||
top: -50px;
|
||||
}
|
||||
|
||||
.message {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
height: 40%;
|
||||
top: 47%;
|
||||
color: #004D40;
|
||||
}
|
||||
|
||||
.face {
|
||||
position: absolute;
|
||||
width: 22%;
|
||||
height: 22%;
|
||||
background: $white;
|
||||
border-radius: 50%;
|
||||
border: 1px solid $dark;
|
||||
top: 21%;
|
||||
left: 37.5%;
|
||||
z-index: 2;
|
||||
animation: bounce 1s ease-in infinite;
|
||||
}
|
||||
|
||||
.eye {
|
||||
position: absolute;
|
||||
width: 5px;
|
||||
height: 5px;
|
||||
background: $dark;
|
||||
border-radius: 50%;
|
||||
top: 40%;
|
||||
left: 20%;
|
||||
}
|
||||
|
||||
.right {
|
||||
left: 68%;
|
||||
}
|
||||
|
||||
.mouth {
|
||||
position:absolute;
|
||||
top: 43%;
|
||||
left: 41%;
|
||||
width: 7px;
|
||||
height: 7px;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.happy {
|
||||
border: 2px solid;
|
||||
border-color: transparent $dark $dark transparent;
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
|
||||
.shadow {
|
||||
position: absolute;
|
||||
width: 21%;
|
||||
height: 3%;
|
||||
opacity: .5;
|
||||
background: $dark;
|
||||
left: 40%;
|
||||
top: 43%;
|
||||
border-radius: 50%;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.scale {
|
||||
animation: scale 1s ease-in infinite;
|
||||
}
|
||||
.move {
|
||||
animation: move 3s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes bounce {
|
||||
50% {
|
||||
transform: translateY(-10px);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes scale {
|
||||
50% {
|
||||
transform: scale(0.9);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes move {
|
||||
0% {
|
||||
left: 25%;
|
||||
}
|
||||
50% {
|
||||
left: 60%;
|
||||
}
|
||||
100% {
|
||||
left: 25%;
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,127 @@
|
||||
<template>
|
||||
<div id="container">
|
||||
<div id="error-box">
|
||||
<div class="face2">
|
||||
<div class="eye"></div>
|
||||
<div class="eye right"></div>
|
||||
<div class="mouth sad"></div>
|
||||
</div>
|
||||
<div class="shadow move"></div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
$white: #EF5350;
|
||||
$gray: #CBCDD3;
|
||||
$dark: #000000;
|
||||
|
||||
#container {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
width: 200px;
|
||||
height: 110px;
|
||||
}
|
||||
|
||||
#error-box {
|
||||
position: absolute;
|
||||
width: 350px;
|
||||
height: 350px;
|
||||
right: -32%;
|
||||
}
|
||||
|
||||
.face2 {
|
||||
position: absolute;
|
||||
width: 22%;
|
||||
height: 22%;
|
||||
background: $white;
|
||||
border-radius: 50%;
|
||||
border: 1px solid $dark;
|
||||
top: 7%;
|
||||
left: 37.5%;
|
||||
z-index: 2;
|
||||
animation: roll 3s ease-in-out infinite;
|
||||
}
|
||||
|
||||
.eye {
|
||||
position: absolute;
|
||||
width: 5px;
|
||||
height: 5px;
|
||||
background: $dark;
|
||||
border-radius: 50%;
|
||||
top: 40%;
|
||||
left: 20%;
|
||||
}
|
||||
|
||||
.right {
|
||||
left: 68%;
|
||||
}
|
||||
|
||||
.mouth {
|
||||
position:absolute;
|
||||
top: 43%;
|
||||
left: 41%;
|
||||
width: 7px;
|
||||
height: 7px;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.sad {
|
||||
top: 49%;
|
||||
border: 2px solid;
|
||||
border-color: $dark transparent transparent $dark;
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
|
||||
.shadow {
|
||||
position: absolute;
|
||||
width: 21%;
|
||||
height: 3%;
|
||||
opacity: .5;
|
||||
background: $dark;
|
||||
left: 40%;
|
||||
top: 28%;
|
||||
border-radius: 50%;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.scale {
|
||||
animation: scale 1s ease-in infinite;
|
||||
}
|
||||
.move {
|
||||
animation: move 3s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes scale {
|
||||
50% {
|
||||
transform: scale(0.9);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes roll {
|
||||
0% {
|
||||
transform: rotate(0deg);
|
||||
left: 25%;
|
||||
}
|
||||
50% {
|
||||
left: 60%;
|
||||
transform: rotate(168deg);
|
||||
}
|
||||
100% {
|
||||
transform: rotate(0deg);
|
||||
left: 25%;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes move {
|
||||
0% {
|
||||
left: 25%;
|
||||
}
|
||||
50% {
|
||||
left: 60%;
|
||||
}
|
||||
100% {
|
||||
left: 25%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -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>
|
||||
@@ -0,0 +1,92 @@
|
||||
<template>
|
||||
<v-container class="d-flex flex-column align-center">
|
||||
<div class="animation-container">
|
||||
<div class="ballot">
|
||||
<span class="ballot-text">Голос</span>
|
||||
</div>
|
||||
<div class="urn">
|
||||
<div class="slot"></div>
|
||||
</div>
|
||||
</div>
|
||||
</v-container>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
setup() {
|
||||
return {};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.animation-container {
|
||||
position: relative;
|
||||
width: 200px;
|
||||
height: 300px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: flex-end;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.ballot {
|
||||
position: absolute;
|
||||
width: 60px;
|
||||
height: 40px;
|
||||
background-color: #004D40;
|
||||
border-radius: 4px;
|
||||
color: #fff;
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
line-height: 40px;
|
||||
animation: dropBallot 3s cubic-bezier(0.4, 0, 0.2, 1) infinite;
|
||||
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
.ballot-text {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.urn {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
width: 120px;
|
||||
height: 80px;
|
||||
background-color: #546E7A;
|
||||
border-top-left-radius: 10px;
|
||||
border-top-right-radius: 10px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.slot {
|
||||
width: 60px;
|
||||
height: 10px;
|
||||
background-color: #455A64;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
@keyframes dropBallot {
|
||||
0% {
|
||||
top: -50px;
|
||||
transform: rotate(0deg);
|
||||
opacity: 1;
|
||||
}
|
||||
40% {
|
||||
transform: rotate(15deg);
|
||||
}
|
||||
60% {
|
||||
top: 220px;
|
||||
transform: rotate(-10deg);
|
||||
opacity: 1;
|
||||
}
|
||||
100% {
|
||||
transform: rotate(0deg);
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,151 @@
|
||||
<template>
|
||||
<v-card>
|
||||
<v-card-text class="d-flex justify-space-between ga-3 text-h6">
|
||||
<v-tooltip bottom>
|
||||
<template v-slot:activator="{ props }">
|
||||
<span
|
||||
style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"
|
||||
v-bind="props">
|
||||
{{ voteCard.name }}
|
||||
</span>
|
||||
</template>
|
||||
<span>{{ voteCard.name }}</span>
|
||||
</v-tooltip>
|
||||
</v-card-text>
|
||||
<v-row>
|
||||
<v-col>
|
||||
<v-carousel
|
||||
cycle
|
||||
height="200" hide-delimiters
|
||||
show-arrows="hover">
|
||||
<v-carousel-item
|
||||
v-for="(picture, index) in images"
|
||||
:key="index"
|
||||
:src="images[index].length < 1 ? defaultImage : `${baseURL.slice(0, -1)}${picture}`">
|
||||
</v-carousel-item>
|
||||
</v-carousel>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-card-text class="">
|
||||
<v-tooltip bottom>
|
||||
<template v-slot:activator="{ props }">
|
||||
<span
|
||||
style="white-space: nowrap; overflow: hidden; text-overflow: ellipsis;"
|
||||
v-bind="props">
|
||||
{{ voteCard.description }}
|
||||
</span>
|
||||
</template>
|
||||
<span>{{ voteCard.description }}</span>
|
||||
</v-tooltip>
|
||||
</v-card-text>
|
||||
<div class="px-2">
|
||||
<Timer v-if="!isFinished" :voteTime="{ dateend: voteCard.dateend, datestart: voteCard.datestart }"
|
||||
@changeBtn="(time) => timeChange = time"/>
|
||||
|
||||
<div v-else class="font-weight-bold text-center"> Завершено: {{
|
||||
new Date(voteCard.dateend).toLocaleDateString()
|
||||
}}
|
||||
</div>
|
||||
</div>
|
||||
<v-card-actions class="justify-space-between mt-4 pb-2">
|
||||
<template v-if="!isFinished">
|
||||
<v-btn :disabled="voteCard.is_passed || timeChange" color="teal-darken-4" prepend-icon="mdi-vote-outline"
|
||||
rounded="xl" size="small" variant="outlined" @click="$emit('openVoteModal', voteCard)">
|
||||
{{ !voteCard.is_passed ? "Проголосовать" : "Уже проголосовали" }}
|
||||
</v-btn>
|
||||
</template>
|
||||
<template v-else>
|
||||
<v-btn color="teal-darken-4" prepend-icon="mdi-trophy-outline"
|
||||
rounded="xl" size="small" variant="outlined" @click="$emit('openResultModal', voteCard)">
|
||||
Результаты
|
||||
</v-btn>
|
||||
</template>
|
||||
<v-btn v-if="user.id === voteCard.author || user.is_superuser" color="error" size="medium" @click="youSure=true">
|
||||
<v-icon>mdi-delete</v-icon>
|
||||
<v-dialog v-model="youSure" width="500">
|
||||
<v-card class="flex" max-width="450">
|
||||
<v-btn
|
||||
class="align-self-end ma-2 text-red"
|
||||
icon="mdi-close"
|
||||
size="medium"
|
||||
variant="text"
|
||||
@click="youSure = false"
|
||||
/>
|
||||
<div class="ml-5 text-h6">
|
||||
Вы действительно хотите удалить голосование?
|
||||
</div>
|
||||
<template v-slot:actions>
|
||||
<v-btn-group>
|
||||
<v-btn
|
||||
class="text-red"
|
||||
@click="$emit('deleteVoting', voteCard.id), youSure = false">
|
||||
Да
|
||||
</v-btn>
|
||||
<v-btn
|
||||
class="text-green"
|
||||
@click="youSure = false">
|
||||
Нет
|
||||
</v-btn>
|
||||
</v-btn-group>
|
||||
</template>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Timer from "@/components/UI/Timer.vue"
|
||||
import {baseURL} from "@/utils/axios-api";
|
||||
import {computed, ref} from 'vue'
|
||||
import {useAccountStore} from "@/store/AccountStore";
|
||||
import defaultImage from '@/assets/emblem.png'
|
||||
|
||||
export default {
|
||||
components: {Timer},
|
||||
emits: ['openVoteModal', 'openEditVoteModal', 'deleteVoting', 'openResultModal'],
|
||||
props: {
|
||||
isFinished: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
voteCard: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
return {
|
||||
id: 0,
|
||||
name: "",
|
||||
description: "",
|
||||
files: [],
|
||||
dateend: new Date(new Date().getTime() + 600000),
|
||||
is_passed: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
setup(props) {
|
||||
const timeChange = ref(false)
|
||||
const youSure = ref(false)
|
||||
const isFinished = ref(false);
|
||||
const accountStore = useAccountStore();
|
||||
const user = accountStore.user;
|
||||
|
||||
const images = computed(() => {
|
||||
return props.voteCard.files.length > 0 ? props.voteCard.files : ['']
|
||||
})
|
||||
|
||||
const date = new Date();
|
||||
const endDate = new Date(props.voteCard.dateend);
|
||||
const distance = endDate.getTime() - date.getTime();
|
||||
|
||||
if (distance <= 0) {
|
||||
isFinished.value = true;
|
||||
}
|
||||
|
||||
return {timeChange, baseURL, images, youSure, isFinished, user, defaultImage}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
@@ -0,0 +1,632 @@
|
||||
<template>
|
||||
|
||||
<v-row class="pt-2 mx-1 flex-column fill-height flex-grow-0 ">
|
||||
<template v-if="isVoteCreated">
|
||||
<v-card class="d-flex flex-column flex-grow-1 flex-shrink-0 text-center pa-8" flat>
|
||||
<v-spacer></v-spacer>
|
||||
<div class>
|
||||
<v-icon color="success" size="48">mdi-check-circle</v-icon>
|
||||
<h2 class="mt-4">Голосование создано!</h2>
|
||||
<v-btn class="mt-4" color="teal-darken-4" @click="resetForm">Создать ещё</v-btn>
|
||||
|
||||
</div>
|
||||
<v-spacer></v-spacer>
|
||||
</v-card>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div class="v-col flex-grow-1 flex-shrink-0 ">
|
||||
<v-stepper v-model="step" class="d-flex flex-column fill-height" editable>
|
||||
<v-stepper-header class="flex-grow-0 flex-shrink-1">
|
||||
<v-stepper-item :complete="step > 0" step="1">Основная информация
|
||||
|
||||
</v-stepper-item>
|
||||
<v-divider></v-divider>
|
||||
<v-stepper-item :complete="step > 1" step="2">Создание опроса</v-stepper-item>
|
||||
<v-divider></v-divider>
|
||||
<v-stepper-item :complete="step > 2" step="3">Подтверждение</v-stepper-item>
|
||||
</v-stepper-header>
|
||||
|
||||
<v-stepper-window class="fill-height">
|
||||
<!-- Основная информация -->
|
||||
<v-stepper-window-item class="fill-height" step="1">
|
||||
<v-card class="fill-height d-flex flex-column " flat>
|
||||
<v-card-title>Основная информация</v-card-title>
|
||||
<v-card-text class="d-flex flex-column overflow-auto">
|
||||
<v-text-field v-model="form.title" :rules="[rules.required]" class="flex-grow-0 flex-shrink-1"
|
||||
label="Название голосования"
|
||||
variant="underlined"></v-text-field>
|
||||
<div class="flex-grow-1 flex-shrink-0">
|
||||
|
||||
<v-textarea v-model="form.description" :rules="[rules.required]" label="Описание"
|
||||
|
||||
variant="outlined"></v-textarea>
|
||||
</div>
|
||||
<v-divider></v-divider>
|
||||
<div class="flex-grow-0 flex-shrink-1">
|
||||
<div class="pt-2 text-overline text-grey">Дата и время:</div>
|
||||
<div class="d-flex justify-space-around">
|
||||
<div class="d-flex ga-3 align-center">
|
||||
<h6 class="text-subtitle-1 pt-2">начало:</h6>
|
||||
<date-select :datedefault="form.startDate" @returndate="returnstart"/>
|
||||
<v-select v-model="selectedTimeStart" :items="timeOptions" density="compact" hide-details
|
||||
variant="plain">
|
||||
<template v-slot:prepend-inner>
|
||||
<v-icon color="red" icon="mdi-timer" size="xsmall"></v-icon>
|
||||
</template>
|
||||
</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>
|
||||
</v-card-text>
|
||||
|
||||
<v-card-actions>
|
||||
<v-btn color="teal-darken-4" size="medium" @click="step = 1">Далее</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-stepper-window-item>
|
||||
|
||||
<!-- Создание опроса -->
|
||||
<v-stepper-window-item class="fill-height" step="2">
|
||||
|
||||
<v-card class="fill-height d-flex flex-column" flat>
|
||||
<v-card-title>Создание опроса:</v-card-title>
|
||||
<v-card-text style="max-height: 62vh; overflow-y: auto;">
|
||||
<transition-group name="list" tag="div">
|
||||
<div v-for="(question, index) in form.questions" :key="index" class="mb-4">
|
||||
<div class="d-flex">
|
||||
<!-- <v-text-field v-model="question.text" :label="'Вопрос ' + (index + 1)" :rules="[rules.required]"-->
|
||||
<!-- density="comfortable" variant="underlined">-->
|
||||
<v-text-field
|
||||
v-model="question.text"
|
||||
:label="'Вопрос ' + (index + 1)"
|
||||
density="comfortable"
|
||||
variant="underlined"
|
||||
:rules="[rules.required]"
|
||||
@input="updateQuest(index)"
|
||||
>
|
||||
<template v-slot:append>
|
||||
<v-btn color="error" icon="mdi-delete" size="small" @click="removeQuestion(index)"/>
|
||||
</template>
|
||||
|
||||
</v-text-field>
|
||||
</div>
|
||||
<v-file-input v-model="question.image" accept="image/*" density="comfortable"
|
||||
label="Картинка для вопроса" variant="outlined"></v-file-input>
|
||||
<v-divider></v-divider>
|
||||
<div class="py-2 text-overline text-grey">Настройки вопроса</div>
|
||||
<div class="v-row ">
|
||||
|
||||
<v-col class="align-self-center font-weight-bold py-0" cols="auto">
|
||||
Тип ответа
|
||||
</v-col>
|
||||
<v-col class="py-0 align-self-center " cols="3">
|
||||
|
||||
<v-select v-model="question.settings.choice" :items="questionTypes" :list-props="{density:'compact'}"
|
||||
density="compact"
|
||||
hide-details
|
||||
item-title="name" item-value="choice" label="" variant="outlined"
|
||||
@update:model-value="question.answers=[]"></v-select>
|
||||
<!-- 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 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`)"
|
||||
>
|
||||
|
||||
{{ 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
|
||||
|
||||
:append-avatar="checkremote(`${spravURL}${data.item.raw.login}.jpg`)"
|
||||
density="compact"
|
||||
slim
|
||||
@click="onEmployeesChange(data.item.raw.id, index)"
|
||||
>
|
||||
<template #prepend>
|
||||
|
||||
<v-checkbox :model-value="question.selectedEmployees.includes(data.item.raw.id)"
|
||||
|
||||
density="compact"
|
||||
hide-details></v-checkbox>
|
||||
</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 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-col class="py-0 d-flex" cols="5">
|
||||
<v-file-input v-model="person.image" accept="image/*" dense density="compact"
|
||||
hide-details
|
||||
label="Картинка" variant="outlined"></v-file-input>
|
||||
<v-btn class="ms-1" color="error" icon="mdi-delete" size="small"
|
||||
@click="question.selectedEmployees.splice(ind,1); removeAnswer(index,ind)">
|
||||
</v-btn>
|
||||
</v-col>
|
||||
</div>
|
||||
</transition-group>
|
||||
</div>
|
||||
</v-card-text>
|
||||
</div>
|
||||
</transition-group>
|
||||
<v-divider class="ma-2 pa-1"></v-divider>
|
||||
<div class="d-flex justify-center">
|
||||
<v-btn color="orange-darken-4" size="small" @click="addQuestion">Добавить вопрос</v-btn>
|
||||
</div>
|
||||
</v-card-text>
|
||||
<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 = 2">Далее</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
|
||||
</v-stepper-window-item>
|
||||
|
||||
<!-- Подтверждение -->
|
||||
<v-stepper-window-item class="fill-height" step="3">
|
||||
|
||||
<v-card class="fill-height d-flex flex-column" flat>
|
||||
<v-card-title>Подтверждение</v-card-title>
|
||||
<v-card-text style="max-height: 62vh; overflow-y: auto;">
|
||||
<v-alert v-if="errorMessage" class="mb-4 " type="error">
|
||||
{{ errorMessage }}
|
||||
</v-alert>
|
||||
|
||||
<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.endDate.toLocaleDateString() }}</p>
|
||||
<p><strong class="px-2">Вопросы:</strong></p>
|
||||
|
||||
<v-card v-for="(question, index) in form.questions" :key="index" class="mb-4 pa-3">
|
||||
<div class="pa-2">
|
||||
|
||||
<p><strong>Вопрос {{ index + 1 }}:</strong> {{ question.text }} ({{ question.type }})</p>
|
||||
|
||||
<div v-if="question.settings.choice === 'free' && question.answers.length">
|
||||
<p><strong>Варианты ответов:</strong></p>
|
||||
|
||||
|
||||
<ul>
|
||||
<li v-for="(answer, answerIndex) in question.answers" :key="answerIndex">
|
||||
{{ answer.text }}
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div v-if="question.settings.choice === 'employee' && question.answers.length">
|
||||
<div>Количество допустимых ответов: {{ question.settings.multiChoice }}</div>
|
||||
<div class="">Голосование по отделам:
|
||||
{{ onlyDepdict.find(e => e.value === question.settings.onlyDep).name }}
|
||||
</div>
|
||||
<p><strong>Выбранные сотрудники:</strong></p>
|
||||
<ul>
|
||||
<li v-for="employeeId in question.answers" :key="employeeId">
|
||||
{{ findEmployeeById(employeeId.text).fio }}
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</v-card>
|
||||
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-btn color="teal-darken-4" size="medium" @click="step -= 1">Назад</v-btn>
|
||||
<v-btn :disabled="errorMessage!=''" color="teal-darken-4" size="medium" @click="saveVoting">
|
||||
Сохранить
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
|
||||
</v-card>
|
||||
</v-stepper-window-item>
|
||||
|
||||
</v-stepper-window>
|
||||
</v-stepper>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
</v-row>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {computed, ref, watch} from "vue";
|
||||
import {createVote, getEmployees, spravURL} from "@/utils/axios-api";
|
||||
import DateSelect from "@/components/UI/date-select.vue";
|
||||
import {checkremote} from "@/utils/universal_functions";
|
||||
|
||||
export default {
|
||||
components: {DateSelect},
|
||||
emits: ['updating'],
|
||||
setup(props, {emit}) {
|
||||
const step = ref(0);
|
||||
const isVoteCreated = ref(false);
|
||||
const form = ref({
|
||||
title: "",
|
||||
description: "",
|
||||
startDate: new Date(),
|
||||
endDate: new Date(new Date().setDate(new Date().getDate() + 14)),
|
||||
questions: [],
|
||||
});
|
||||
|
||||
const rules = {
|
||||
required: (value) => !!value || "Это поле обязательно для заполнения",
|
||||
};
|
||||
|
||||
const currentQuestionIndex = ref(0);
|
||||
const questionTypes = [{name: "Ввести вручную", choice: 'free'}, {name: "Выбрать сотрудника", choice: 'employee'}];
|
||||
|
||||
const groupedEmployees = ref([]);
|
||||
const allEmployees = computed(() => [
|
||||
...groupedEmployees.value,
|
||||
]);
|
||||
|
||||
getEmployees()
|
||||
.then(r => groupedEmployees.value = r)
|
||||
|
||||
const currentQuestion = computed(() =>
|
||||
form.value.questions[currentQuestionIndex.value] || null
|
||||
);
|
||||
const allEmployeesgroupedbydep = computed(() => {
|
||||
let groupped = []
|
||||
for (let x of allEmployees.value.sort((a, b) => a.id_dict_department - b.id_dict_department)) {
|
||||
if (!groupped.includes(x.department)) groupped.push(x.department)
|
||||
groupped.push(x)
|
||||
}
|
||||
return groupped
|
||||
})
|
||||
const findEmployeeById = (id) =>
|
||||
groupedEmployees.value.find((employee) => employee.id === id) || {};
|
||||
|
||||
|
||||
const handleSelectAll = (selected, index) => {
|
||||
if (!selected) {
|
||||
form.value.questions[index].answers = groupedEmployees.value.map((employee) => ({
|
||||
text: employee.id,
|
||||
image: null,
|
||||
}));
|
||||
form.value.questions[index].selectedEmployees = groupedEmployees.value.map(employee => employee.id);
|
||||
} else {
|
||||
form.value.questions[index].answers = [];
|
||||
form.value.questions[index].selectedEmployees = []
|
||||
}
|
||||
};
|
||||
|
||||
const isAllSelected = computed(() => currentQuestion.value.answers.length === groupedEmployees.value.length);
|
||||
|
||||
const addQuestion = () => {
|
||||
form.value.questions.push({
|
||||
text: "",
|
||||
settings: {choice: "free", multiChoice: 1, onlyDep: null},
|
||||
image: null,
|
||||
answers: [],
|
||||
selectedEmployees: []
|
||||
});
|
||||
currentQuestionIndex.value = form.value.questions.length - 1;
|
||||
};
|
||||
|
||||
const removeQuestion = (index) => {
|
||||
form.value.questions.splice(index, 1);
|
||||
if (currentQuestionIndex.value >= form.value.questions.length) {
|
||||
currentQuestionIndex.value = form.value.questions.length - 1;
|
||||
}
|
||||
};
|
||||
|
||||
const updateQuest = (index) => {
|
||||
quests[index] = form.value.questions[index].text.length > 0;
|
||||
};
|
||||
|
||||
const addAnswer = (index) => {
|
||||
if (currentQuestion.value) {
|
||||
form.value.questions[index].answers.push({text: "", image: null});
|
||||
}
|
||||
};
|
||||
|
||||
const removeAnswer = (index, ind) => {
|
||||
form.value.questions[index].answers.splice(ind, 1)
|
||||
};
|
||||
|
||||
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 hasEmptyQuestions = quests.value.includes(false);
|
||||
const hasInvalidAnswers = validateAnswers();
|
||||
|
||||
if (
|
||||
!form.value.title ||
|
||||
!form.value.description ||
|
||||
form.value.questions.length < 1 ||
|
||||
hasEmptyQuestions ||
|
||||
hasInvalidAnswers
|
||||
) {
|
||||
errorMessage.value = "Все обязательные поля и ответы должны быть заполнены";
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await createVote(form.value);
|
||||
console.log("Голосование успешно создано:", response);
|
||||
isVoteCreated.value = true;
|
||||
emit("updating", "active");
|
||||
} catch (error) {
|
||||
console.error("Ошибка при создании голосования:", error);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const resetForm = () => {
|
||||
form.value = {
|
||||
title: "",
|
||||
description: "",
|
||||
startDate: new Date(),
|
||||
endDate: new Date(new Date().setDate(new Date().getDate() + 14)),
|
||||
questions: [],
|
||||
};
|
||||
step.value = 0;
|
||||
isVoteCreated.value = false;
|
||||
};
|
||||
|
||||
const timeOptions = Array.from({length: 48}, (_, i) => {
|
||||
const hours = String(Math.floor(i / 2)).padStart(2, "0");
|
||||
const minutes = i % 2 === 0 ? "00" : "30";
|
||||
return `${hours}:${minutes}`;
|
||||
});
|
||||
|
||||
const selectedTimeStart = ref(
|
||||
`${(form.value.startDate.getHours() + 1).toString().padStart(2, "0")}:00`
|
||||
);
|
||||
|
||||
const selectedTimeEnd = ref(
|
||||
`${(form.value.endDate.getHours() + 1).toString().padStart(2, "0")}:00`
|
||||
);
|
||||
|
||||
watch(form.value, () => {
|
||||
if (!form.value.title || !form.value.description || form.value.questions.length < 1) {
|
||||
errorMessage.value = "Все обязательные поля должны быть заполнены";
|
||||
} else {
|
||||
errorMessage.value = "";
|
||||
}
|
||||
}, { deep: true });
|
||||
|
||||
const updateQuests = () => {
|
||||
quests.value = form.value.questions.map((q) => !!q.text.trim());
|
||||
};
|
||||
|
||||
watch(() => form.value.questions, updateQuests, { deep: true });
|
||||
|
||||
watch(
|
||||
() => form.value.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, () => {
|
||||
updateStartDate()
|
||||
})
|
||||
watch(selectedTimeEnd, () => {
|
||||
updateEndDate()
|
||||
})
|
||||
|
||||
const updateStartDate = () => {
|
||||
const [hours, minutes] = selectedTimeStart.value.split(":").map(Number);
|
||||
form.value.startDate.setHours(hours, minutes);
|
||||
};
|
||||
const updateEndDate = () => {
|
||||
const [hours, minutes] = selectedTimeEnd.value.split(":").map(Number);
|
||||
form.value.endDate.setHours(hours, minutes);
|
||||
};
|
||||
|
||||
const returnstart = (dates) => {
|
||||
form.value.startDate = dates
|
||||
}
|
||||
|
||||
const returnend = (dates) => {
|
||||
form.value.endDate = dates
|
||||
}
|
||||
|
||||
const onEmployeesChange = (selected, index) => {
|
||||
let ind = form.value.questions[index].selectedEmployees.findIndex(e => e === selected)
|
||||
if (ind > -1) {
|
||||
form.value.questions[index].selectedEmployees.splice(ind, 1)
|
||||
let answ = form.value.questions[index].answers.findIndex(a => a.text === selected)
|
||||
form.value.questions[index].answers.splice(answ, 1)
|
||||
} else {
|
||||
form.value.questions[index].selectedEmployees.push(selected)
|
||||
form.value.questions[index].answers.push({text: selected, image: null});
|
||||
}
|
||||
};
|
||||
|
||||
const onlyDepdict = [{name: 'За любого сотрудника', value: null}, {
|
||||
name: "Кроме своего отдела",
|
||||
value: false
|
||||
}, {name: "Только за свой отдел", value: true}]
|
||||
|
||||
const quests = computed(() =>
|
||||
form.value.questions.map((question) => question.text.length > 0)
|
||||
);
|
||||
|
||||
return {
|
||||
quests,
|
||||
updateQuest,
|
||||
onlyDepdict,
|
||||
allEmployeesgroupedbydep,
|
||||
onEmployeesChange,
|
||||
returnend,
|
||||
returnstart,
|
||||
step,
|
||||
form,
|
||||
questionTypes,
|
||||
addQuestion,
|
||||
removeQuestion,
|
||||
addAnswer,
|
||||
removeAnswer,
|
||||
findEmployeeById,
|
||||
saveVoting,
|
||||
isVoteCreated,
|
||||
resetForm,
|
||||
rules,
|
||||
errorMessage,
|
||||
timeOptions,
|
||||
selectedTimeStart,
|
||||
selectedTimeEnd,
|
||||
allEmployees,
|
||||
handleSelectAll,
|
||||
isAllSelected,
|
||||
checkremote,
|
||||
spravURL
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.v-input--horizontal .v-input__prepend {
|
||||
margin-inline-end: 4px;
|
||||
}
|
||||
|
||||
.list-enter-active,
|
||||
.list-leave-active {
|
||||
transition: all 0.5s ease;
|
||||
}
|
||||
|
||||
.list-enter-from,
|
||||
.list-leave-to {
|
||||
opacity: 0;
|
||||
transform: translateX(50px);
|
||||
}
|
||||
|
||||
</style>
|
||||
@@ -1,148 +1,147 @@
|
||||
<template>
|
||||
|
||||
<v-form @submit="voteSend" ref="vot" >
|
||||
<v-card id="scroll-window-chekbox" :height="heightel" elevation="0">
|
||||
<!-- Форма голосования -->
|
||||
|
||||
<v-virtual-scroll :items="persons">
|
||||
<template v-slot:default="{ item }">
|
||||
<v-checkbox hide-details="true" v-model="vote" :id="item.fio" :value="item.fio" :label="item.fio" required />
|
||||
</template>
|
||||
</v-virtual-scroll>
|
||||
<v-form ref="vot" @submit="voteSend">
|
||||
<v-card id="scroll-window-chekbox" :height="heightel" elevation="0">
|
||||
<!-- Форма голосования -->
|
||||
|
||||
<v-virtual-scroll :items="persons">
|
||||
<template v-slot:default="{ item }">
|
||||
<v-checkbox :id="item.fio" v-model="vote" :label="item.fio" :value="item.fio" hide-details="true" required/>
|
||||
</template>
|
||||
</v-virtual-scroll>
|
||||
</v-card>
|
||||
|
||||
<v-dialog v-model="dialog" max-width="500">
|
||||
<!-- <template v-slot:activator>
|
||||
</template> -->
|
||||
<template v-slot:default>
|
||||
<v-card class="justify-center align-center">
|
||||
<v-card-title>Вы подтверждаете выбор?</v-card-title>
|
||||
<v-card-text>После подтверждения внесение измений станет невозможным.</v-card-text>
|
||||
<p>Выбранный кандидат</p>
|
||||
<v-card-title v-if="approve_name">{{ approve_name }}</v-card-title>
|
||||
<v-card-title v-else>Кандидат не выбран повторите голосование</v-card-title>
|
||||
<v-col class="d-flex flex-rows justify-center align-center" cols="12">
|
||||
<v-col cols="2">
|
||||
<v-btn v-if="approve_name" color="green-darken-1" variant="elevated"
|
||||
@click="voteSend">ДА
|
||||
</v-btn>
|
||||
<v-btn v-else color="green-darken-1" disabled variant="elevated"
|
||||
@click="voteSend">ДА
|
||||
</v-btn>
|
||||
</v-col>
|
||||
<v-col cols="2">
|
||||
<v-btn color="red-darken-1" variant="elevated"
|
||||
@click="dialog = false">НЕТ
|
||||
</v-btn>
|
||||
</v-col>
|
||||
</v-col>
|
||||
</v-card>
|
||||
|
||||
<v-dialog max-width="500" v-model="dialog">
|
||||
<!-- <template v-slot:activator>
|
||||
|
||||
</template> -->
|
||||
<template v-slot:default>
|
||||
<v-card class="justify-center align-center">
|
||||
<v-card-title>Вы подтверждаете выбор?</v-card-title>
|
||||
<v-card-text>После подтверждения внесение измений станет невозможным.</v-card-text>
|
||||
<p>Выбранный кандидат</p>
|
||||
<v-card-title v-if="approve_name">{{ approve_name }}</v-card-title>
|
||||
<v-card-title v-else>Кандидат не выбран повторите голосование</v-card-title>
|
||||
<v-col class="d-flex flex-rows justify-center align-center" cols="12">
|
||||
<v-col cols="2">
|
||||
<v-btn v-if="approve_name" variant="elevated" color="green-darken-1"
|
||||
@click="voteSend">ДА</v-btn>
|
||||
<v-btn v-else variant="elevated" color="green-darken-1" @click="voteSend"
|
||||
disabled>ДА</v-btn>
|
||||
</v-col>
|
||||
<v-col cols="2">
|
||||
<v-btn variant="elevated" color="red-darken-1"
|
||||
@click="dialog = false">НЕТ</v-btn>
|
||||
</v-col>
|
||||
</v-col>
|
||||
</v-card>
|
||||
</template>
|
||||
</v-dialog>
|
||||
</v-form>
|
||||
|
||||
|
||||
</template>
|
||||
</v-dialog>
|
||||
</v-form>
|
||||
|
||||
|
||||
</template>
|
||||
<script scope>
|
||||
import { ref, computed } from "vue";
|
||||
import { clearAxios, axiosApiInstance } from "@/utils/axios-api";
|
||||
import { useAccountStore } from '@/store/AccountStore';
|
||||
import Vote from "@/views/Vote.vue";
|
||||
import {computed, ref} from "vue";
|
||||
import {axiosApiInstance} from "@/utils/axios-api";
|
||||
import {useAccountStore} from '@/store/AccountStore';
|
||||
|
||||
export default {
|
||||
|
||||
props: {type_fetch:{type:String, default:'best'},
|
||||
persons:{
|
||||
type:Array,
|
||||
default:()=>[]
|
||||
},
|
||||
myrealdep:{
|
||||
type:Object,
|
||||
default:()=>{}
|
||||
}
|
||||
},
|
||||
setup(props, {emit}) {
|
||||
let account_login = useAccountStore();
|
||||
// let department_id = useAccountStore().user.id_dict_department;
|
||||
// let department_name = useAccountStore().user.department
|
||||
// let type_fetch = props.type_fetch;
|
||||
const dialog=ref(false)
|
||||
let vote = ref();
|
||||
// let get_address = ref();
|
||||
let send_address = ref();
|
||||
// let vote_data = ref([]);
|
||||
let approve_name = ref();
|
||||
let aproveFalseMessage = ref();
|
||||
|
||||
if (props.type_fetch == "thanks") {
|
||||
|
||||
send_address = `api/vote/setthanks/`;
|
||||
} else if (props.type_fetch == "best") {
|
||||
|
||||
send_address = `api/vote/setbest/`;
|
||||
}
|
||||
|
||||
// const getVotesData = () => {
|
||||
// clearAxios.get(get_address).then((data) => {
|
||||
// vote_data.value = data.data;
|
||||
// });
|
||||
// };
|
||||
|
||||
|
||||
|
||||
const approveCandidate = () => {
|
||||
if (vote.value === 'False' || vote.value === '') {
|
||||
approve_name.value = false;
|
||||
|
||||
} else {
|
||||
approve_name.value = vote.value;
|
||||
|
||||
}
|
||||
|
||||
dialog.value=true
|
||||
}
|
||||
|
||||
const voteSend = () => {
|
||||
console.log(vote.value);
|
||||
axiosApiInstance.post(send_address, {
|
||||
cand_name_id: vote.value,
|
||||
// department_user: props.myrealdep.department,
|
||||
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}
|
||||
).then(res=>
|
||||
{
|
||||
dialog.value=false
|
||||
window.location.reload()
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
// getVotesData();
|
||||
const vot = ref(null)
|
||||
const heightel = computed(()=>!!vot.value?vot.value.clientHeight:300)
|
||||
return {
|
||||
vot,
|
||||
heightel,
|
||||
approveCandidate,
|
||||
voteSend,
|
||||
// vote_data,
|
||||
vote,
|
||||
approve_name,
|
||||
aproveFalseMessage,
|
||||
dialog
|
||||
}
|
||||
props: {
|
||||
type_fetch: {type: String, default: 'best'},
|
||||
persons: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
myrealdep: {
|
||||
type: Object,
|
||||
default: () => {
|
||||
}
|
||||
}
|
||||
},
|
||||
setup(props, {emit}) {
|
||||
let account_login = useAccountStore();
|
||||
// let department_id = useAccountStore().user.id_dict_department;
|
||||
// let department_name = useAccountStore().user.department
|
||||
// let type_fetch = props.type_fetch;
|
||||
const dialog = ref(false)
|
||||
let vote = ref();
|
||||
// let get_address = ref();
|
||||
let send_address = ref();
|
||||
// let vote_data = ref([]);
|
||||
let approve_name = ref();
|
||||
let aproveFalseMessage = ref();
|
||||
|
||||
if (props.type_fetch == "thanks") {
|
||||
|
||||
send_address = `api/vote/setthanks/`;
|
||||
} else if (props.type_fetch == "best") {
|
||||
|
||||
send_address = `api/vote/setbest/`;
|
||||
}
|
||||
|
||||
// const getVotesData = () => {
|
||||
// clearAxios.get(get_address).then((data) => {
|
||||
// vote_data.value = data.data;
|
||||
// });
|
||||
// };
|
||||
|
||||
|
||||
const approveCandidate = () => {
|
||||
if (vote.value === 'False' || vote.value === '') {
|
||||
approve_name.value = false;
|
||||
|
||||
} else {
|
||||
approve_name.value = vote.value;
|
||||
|
||||
}
|
||||
|
||||
dialog.value = true
|
||||
}
|
||||
|
||||
const voteSend = () => {
|
||||
console.log(vote.value);
|
||||
axiosApiInstance.post(send_address, {
|
||||
cand_name_id: vote.value,
|
||||
// department_user: props.myrealdep.department,
|
||||
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}
|
||||
).then(res => {
|
||||
dialog.value = false
|
||||
window.location.reload()
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
// getVotesData();
|
||||
const vot = ref(null)
|
||||
const heightel = computed(() => !!vot.value ? vot.value.clientHeight : 300)
|
||||
return {
|
||||
vot,
|
||||
heightel,
|
||||
approveCandidate,
|
||||
voteSend,
|
||||
// vote_data,
|
||||
vote,
|
||||
approve_name,
|
||||
aproveFalseMessage,
|
||||
dialog
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
#scroll-window-chekbox {
|
||||
overflow-y: scroll !important;
|
||||
overflow-y: scroll !important;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
@@ -0,0 +1,408 @@
|
||||
<template>
|
||||
<v-container style="height: 85vh;">
|
||||
<div class="text-end">
|
||||
<v-btn class="" color="red-darken-1" density="compact" icon="mdi-close-thick" size="small"
|
||||
@click="$emit('closer')">
|
||||
</v-btn>
|
||||
</div>
|
||||
<v-card-title class="text-subtitle-1">Результат голосования: {{ title }}</v-card-title>
|
||||
<v-card-subtitle class="text-subtitle-2">{{ description }}</v-card-subtitle>
|
||||
<v-tabs v-model="activeTab" class="mb-4">
|
||||
<v-tab
|
||||
v-for="(question, questionIndex) in questions"
|
||||
:key="questionIndex"
|
||||
>
|
||||
<template v-if="shouldShowTooltip(question.name || 'Без названия', 10)">
|
||||
<v-tooltip bottom>
|
||||
<template v-slot:activator="{ props }">
|
||||
<span v-bind="props">
|
||||
{{ truncateText(question.name || 'Без названия', 10) }}
|
||||
</span>
|
||||
</template>
|
||||
<span>{{ question.name || 'Без названия' }}</span>
|
||||
</v-tooltip>
|
||||
</template>
|
||||
<template v-else>
|
||||
<span>{{ truncateText(question.name || 'Без названия', 10) }}</span>
|
||||
</template>
|
||||
</v-tab>
|
||||
<v-tab>Не голосовали</v-tab>
|
||||
</v-tabs>
|
||||
<v-tabs-window v-model="activeTab">
|
||||
<v-tabs-window-item v-for="(question, questionIndex) in questions" :key="questionIndex">
|
||||
<v-row v-if="question.settings.onlyDep">
|
||||
<v-col
|
||||
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>
|
||||
<strong class="text-teal-darken-4">{{ department }}</strong>
|
||||
</v-card-title>
|
||||
<v-card-subtitle>
|
||||
Победитель: {{ winner.employee.fio || winner.name }} 🏆
|
||||
</v-card-subtitle>
|
||||
<v-card-text>
|
||||
Количество голосов: {{ winner.count }}
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</v-col>
|
||||
</v-row>
|
||||
|
||||
<v-row v-else>
|
||||
<v-col cols="12">
|
||||
<h3 class="text-center">{{ question.name }}</h3>
|
||||
<v-card-title class="d-flex ga-2 align-center">
|
||||
<h4 class="text-teal-darken-4">Победитель:</h4>
|
||||
<h3>{{ getWinner(question).employee?.fio || getWinner(question).name }} 🏆</h3>
|
||||
</v-card-title>
|
||||
<v-card-subtitle>
|
||||
Количество голосов: {{ getWinner(question)?.count || 0 }}
|
||||
</v-card-subtitle>
|
||||
</v-col>
|
||||
<v-col cols="12">
|
||||
<v-card class="mb-4">
|
||||
<v-card-title class="text-teal-darken-3">Распределение голосов:</v-card-title>
|
||||
<v-card-text>
|
||||
<v-list style="max-height: 45vh; overflow-y: auto;">
|
||||
<v-list-item
|
||||
v-for="(answer, answerIndex) in getTopResults(question).filter(el => el.count > 0)"
|
||||
:key="answerIndex"
|
||||
>
|
||||
<p>
|
||||
<strong class="mr-4">{{ answerIndex + 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, question)"
|
||||
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-col>
|
||||
</v-row>
|
||||
</v-tabs-window-item>
|
||||
<v-tabs-window-item>
|
||||
<NonVoteSad v-if="nonVoters.length > 0"/>
|
||||
<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;">
|
||||
<NonVoteHappy v-if="nonVoters.length < 1"/>
|
||||
<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 v-for="(voter, voterIndex) in voters" :key="`${department}-${voterIndex}`">
|
||||
<p>
|
||||
<v-avatar
|
||||
:image="checkremote(`${spravURL()}${voter.login}.jpg`)"
|
||||
class="cursor-pointer"
|
||||
@click="userCardIndex = `${department}-${voterIndex}`"
|
||||
/>
|
||||
<InfoUserCard
|
||||
:author="voter"
|
||||
:opendialog="userCardIndex === `${department}-${voterIndex}`"
|
||||
@update:opendialog="userCardIndex = $event ? `${department}-${voterIndex}` : null"
|
||||
/>
|
||||
<strong class="ml-4">{{ voter.fio }}</strong>
|
||||
</p>
|
||||
</v-list-item>
|
||||
</template>
|
||||
</v-card-item>
|
||||
</v-tabs-window-item>
|
||||
</v-tabs-window>
|
||||
</v-container>
|
||||
|
||||
<v-dialog v-model="dialog" max-width="100vh">
|
||||
<v-card max-height="800">
|
||||
<v-card-title class="v-row">
|
||||
<div class="v-col-auto">
|
||||
{{ activepick.answer }}
|
||||
</div>
|
||||
<v-spacer></v-spacer>
|
||||
<div>
|
||||
<v-btn color="red-darken-1" density="compact" icon="mdi-close-thick" size="small" @click="dialog=false"/>
|
||||
</div>
|
||||
|
||||
</v-card-title>
|
||||
<v-card-item>
|
||||
<v-img :src="activepick.file !== undefined ? baseURL.slice(0, -1) + activepick.file : activepick"
|
||||
max-height="600"></v-img>
|
||||
</v-card-item>
|
||||
</v-card>
|
||||
</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>
|
||||
|
||||
<script>
|
||||
import {computed, ref} from 'vue';
|
||||
import {baseURL, spravURL} from "@/utils/axios-api";
|
||||
import {checkremote} from "@/utils/universal_functions";
|
||||
import NonVoteHappy from "@/components/vote/NonVoteHappy.vue";
|
||||
import NonVoteSad from "@/components/vote/NonVoteSad.vue";
|
||||
import InfoUserCard from "@/components/UI/fiousercard/infoUserCard.vue";
|
||||
|
||||
export default {
|
||||
name: 'VoteResult',
|
||||
components: {InfoUserCard, NonVoteSad, NonVoteHappy},
|
||||
methods: {
|
||||
checkremote,
|
||||
spravURL() {
|
||||
return spravURL
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
baseURL() {
|
||||
return baseURL
|
||||
}
|
||||
},
|
||||
emits: ['closer'],
|
||||
props: {
|
||||
data: {
|
||||
type: Object,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
setup(props) {
|
||||
const activeTab = ref(0);
|
||||
const questions = computed(() => props.data.questions || []);
|
||||
const userCardIndex = ref(null);
|
||||
|
||||
const title = props.data.name;
|
||||
const description = props.data.description;
|
||||
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) => {
|
||||
return question.answers.reduce(
|
||||
(max, answer) => (answer.count > max.count ? answer : max),
|
||||
{count: 0, employee: {fio: '', department: '', post: ''}, name: ''}
|
||||
);
|
||||
};
|
||||
|
||||
const getTopResults = (question) => {
|
||||
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) => {
|
||||
if (!text) return '';
|
||||
return text.length > maxLength ? text.slice(0, maxLength) + '…' : text;
|
||||
};
|
||||
|
||||
const shouldShowTooltip = (text, maxLength) => {
|
||||
return text && text.length > maxLength;
|
||||
};
|
||||
|
||||
const voteCount = (count) => {
|
||||
let currentVote = '';
|
||||
const lastDigit = count % 10;
|
||||
if (lastDigit === 1) currentVote = 'голос'
|
||||
if (lastDigit > 1) currentVote = 'голоса'
|
||||
if (lastDigit > 4 || count === 0 || count === 11 || count === 12 || count === 13 || count === 14) currentVote = 'голосов'
|
||||
return currentVote
|
||||
}
|
||||
|
||||
const getPercentage = (count, question) => {
|
||||
const totalVotes = question.answers.reduce((sum, answer) => sum + answer.count, 0);
|
||||
return totalVotes > 0 ? (count / totalVotes) * 100 : 0;
|
||||
};
|
||||
|
||||
const activepick = ref(null)
|
||||
// const dialog = ref(false)
|
||||
const opendialog = (val) => {
|
||||
dialog.value = true
|
||||
activepick.value = val
|
||||
}
|
||||
|
||||
const groupedByDepartment = computed(() => {
|
||||
// Группируем пользователей по департаментам
|
||||
const departments = nonVoters.reduce((groups, voter) => {
|
||||
const department = voter.department || '';
|
||||
if (!groups[department]) {
|
||||
groups[department] = [];
|
||||
}
|
||||
groups[department].push(voter);
|
||||
return groups;
|
||||
}, {});
|
||||
|
||||
// Сортируем департаменты по id_dict_department
|
||||
const sortedDepartments = Object.keys(departments).sort((a, b) => {
|
||||
const idA = nonVoters.find(voter => voter.department === a)?.id_dict_department || 0;
|
||||
const idB = nonVoters.find(voter => voter.department === b)?.id_dict_department || 0;
|
||||
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 = {};
|
||||
sortedDepartments.forEach(department => {
|
||||
sortedGroupedByDepartment[department] = departments[department];
|
||||
});
|
||||
|
||||
return sortedGroupedByDepartment;
|
||||
});
|
||||
|
||||
// const groupedByDepartment = {};
|
||||
|
||||
const getWinnersByDepartment = (question) => {
|
||||
// Группируем ответы по департаментам
|
||||
const groupedByDepartment = question.answers.reduce((groups, answer) => {
|
||||
const department = answer.employee?.department;
|
||||
if (!groups[department]) {
|
||||
groups[department] = [];
|
||||
}
|
||||
groups[department].push(answer);
|
||||
return groups;
|
||||
}, {});
|
||||
|
||||
// Для каждого департамента находим победителя
|
||||
const winnersByDepartment = {};
|
||||
for (const department in groupedByDepartment) {
|
||||
const answers = groupedByDepartment[department];
|
||||
const winner = answers.reduce(
|
||||
(max, answer) => (answer.count > max.count ? answer : max),
|
||||
{count: 0, employee: {fio: '', department: '', post: ''}, name: ''}
|
||||
);
|
||||
winnersByDepartment[department] = winner;
|
||||
}
|
||||
|
||||
return { groupedByDepartment, winnersByDepartment };
|
||||
};
|
||||
|
||||
|
||||
return {
|
||||
opendialogWinn,
|
||||
dialogWinner,
|
||||
activeDepartmentResults,
|
||||
activeDepartment,
|
||||
getWinnersByDepartment,
|
||||
userCardIndex,
|
||||
activepick,
|
||||
opendialog,
|
||||
dialog,
|
||||
activeTab,
|
||||
questions,
|
||||
getWinner,
|
||||
getTopResults,
|
||||
truncateText,
|
||||
shouldShowTooltip,
|
||||
voteCount,
|
||||
title,
|
||||
description,
|
||||
getPercentage,
|
||||
nonVoters,
|
||||
groupedByDepartment
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
@@ -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-if="accountStore.cod2user">
|
||||
<vcard-user :author="accountStore.user" />
|
||||
|
||||
<v-tooltip location="bottom">
|
||||
<template v-slot:activator="{ props }">
|
||||
<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-row><v-col>
|
||||
<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-list-item v-if="(x.path == '/portal'
|
||||
? accountStore.user.is_superuser
|
||||
: true) && !('submenu' in x)
|
||||
<v-list-item v-if="(x.path == '/portal'? 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"
|
||||
:target="x.link ? '_blank' : ''" color="navigation">
|
||||
|
||||
<!-- Чтобы сделать неактивным раздел безопасность, не забыть прописать путь до него в disabled для показа -->
|
||||
:target="x.link ? '_blank' : ''"
|
||||
color="navigation"
|
||||
|
||||
>
|
||||
|
||||
<template v-slot:prepend>
|
||||
<v-icon :icon="x.ico" />
|
||||
<v-tooltip v-if="rail" activator="parent" location="top">
|
||||
@@ -116,7 +115,7 @@
|
||||
</v-list>
|
||||
|
||||
<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' : ''">
|
||||
<template v-slot:prepend>
|
||||
<v-icon :icon="x.imagecode" />
|
||||
@@ -131,17 +130,8 @@
|
||||
|
||||
<v-row class="flex-grow-0" v-if="accountStore.user.is_staff">
|
||||
<v-col>
|
||||
<default-portal-menu-list :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> -->
|
||||
<AdminMenu :rail="rail" />
|
||||
|
||||
</v-col>
|
||||
</v-row>
|
||||
<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 VcardUser from "@/components/UI/fiousercard/vcardUser.vue";
|
||||
import PageCounter from "@/components/UI/defaultportal/page-counter.vue";
|
||||
import DefaultPortalMenuList from "@/layouts/default/DefaultPortalMenuList.vue";
|
||||
import { getDevelopment } from "@/utils/universal_functions";
|
||||
import AdminMenu from "@/layouts/default/AdminMenu.vue";
|
||||
|
||||
import { useDisplay } from "vuetify";
|
||||
|
||||
export default {
|
||||
@@ -208,7 +198,7 @@ export default {
|
||||
CardLike,
|
||||
VcardUser,
|
||||
PageCounter,
|
||||
DefaultPortalMenuList,
|
||||
AdminMenu,
|
||||
},
|
||||
|
||||
mixins: [uf],
|
||||
@@ -238,8 +228,8 @@ export default {
|
||||
if (!accountStore.cod2user) {
|
||||
|
||||
clearAxios.get(`api/navigation/screensaver/`).then((data) => {
|
||||
console.log(data, 'saver--')
|
||||
// scrimg.value = data.data[0].img;
|
||||
// console.log(data, 'saver--')
|
||||
scrimg.value = data.data.img;
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -258,30 +248,7 @@ export default {
|
||||
|
||||
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([
|
||||
{
|
||||
@@ -336,6 +303,11 @@ export default {
|
||||
ico: "mdi-vote",
|
||||
path: "/vote",
|
||||
},
|
||||
{
|
||||
name: "Тестирование",
|
||||
ico: "mdi-book-open-blank-variant",
|
||||
path: "/test",
|
||||
},
|
||||
|
||||
{
|
||||
name: "Об инспекции",
|
||||
@@ -349,11 +321,7 @@ export default {
|
||||
path: "/portal",
|
||||
},
|
||||
|
||||
// {
|
||||
// name: 'К празднику',
|
||||
// ico: 'mdi-cake-variant',
|
||||
// path: "/fnshol"
|
||||
// }
|
||||
|
||||
]);
|
||||
|
||||
const imageSrc = computed(() => {
|
||||
@@ -385,7 +353,7 @@ export default {
|
||||
});
|
||||
};
|
||||
|
||||
getSafetyChapter();
|
||||
// getSafetyChapter();
|
||||
|
||||
return {
|
||||
theme,
|
||||
@@ -397,18 +365,16 @@ export default {
|
||||
navigations,
|
||||
imageSrc,
|
||||
LikeDialog,
|
||||
scrimg,
|
||||
oRasrab,
|
||||
scrimg,
|
||||
rail,
|
||||
showTooltip,
|
||||
menuTruncated,
|
||||
// feedalert,
|
||||
alert,
|
||||
burl,
|
||||
name,
|
||||
closeinfo,
|
||||
baseURL,
|
||||
getDevelopment,
|
||||
|
||||
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,13 +140,49 @@ const routes = [
|
||||
ico: "mdi-account",
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
|
||||
path: "/vote",
|
||||
name: "Vote",
|
||||
name: "VoteHomePage",
|
||||
component: () =>
|
||||
import("@/views/Vote.vue")
|
||||
import("@/views/VoteHomePage.vue"),
|
||||
meta: {
|
||||
title: "Голосование",
|
||||
ico: "mdi-account",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "/vote/voting/:id",
|
||||
name: "Voting",
|
||||
component: () =>
|
||||
import("@/views/VoteHomePage.vue"),
|
||||
meta: {
|
||||
title: "Голосование",
|
||||
ico: "mdi-account",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "/vote/vote-results/:id",
|
||||
name: "VoteResults",
|
||||
component: () =>
|
||||
import("@/views/VoteHomePage.vue")
|
||||
},
|
||||
{
|
||||
path: "/test",
|
||||
name: "TestPage",
|
||||
component: () =>
|
||||
import("@/views/TestHomePage.vue"),
|
||||
meta: {
|
||||
title: "Тестирование",
|
||||
ico: "mdi-account",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: '/secret',
|
||||
name: 'Secret Page',
|
||||
component: () =>
|
||||
import("@/views/secret/SecretPage.vue")
|
||||
}
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
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 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/'
|
||||
@@ -11,82 +12,204 @@ const baseWS = process.env.NODE_ENV == 'development'? 'ws://127.0.0.1:8000/': `w
|
||||
|
||||
async function refreshToken() {
|
||||
|
||||
const refresh = localStorage.getItem('refresh');
|
||||
const refresh = localStorage.getItem('refresh');
|
||||
|
||||
try {
|
||||
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)
|
||||
try {
|
||||
const result = await axios.post('/api/accounts/token/refresh/', {refresh}, {
|
||||
baseURL
|
||||
})
|
||||
|
||||
return result.data.access;
|
||||
}
|
||||
|
||||
catch(e) {
|
||||
const accountStore = useAccountStore()
|
||||
accountStore.logout()
|
||||
accountStore.cod2user.value=false
|
||||
|
||||
return Promise.reject(e);
|
||||
}
|
||||
if (result.config.data) localStorage.setItem('refresh', JSON.parse(result.config.data).refresh);
|
||||
localStorage.setItem('access', result.data.access)
|
||||
|
||||
return result.data.access;
|
||||
} catch (e) {
|
||||
const accountStore = useAccountStore()
|
||||
accountStore.logout()
|
||||
accountStore.cod2user.value = false
|
||||
|
||||
return Promise.reject(e);
|
||||
}
|
||||
}
|
||||
|
||||
const axiosApiInstance = axios.create({
|
||||
baseURL,
|
||||
baseURL,
|
||||
});
|
||||
|
||||
const clearAxios = axios.create({
|
||||
baseURL,
|
||||
baseURL,
|
||||
});
|
||||
|
||||
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}`,
|
||||
}
|
||||
const access = localStorage.getItem('access');
|
||||
if (access) {
|
||||
config.headers = {
|
||||
'Authorization': `Bearer ${access}`,
|
||||
}
|
||||
return config;
|
||||
}
|
||||
return config;
|
||||
}, error => {
|
||||
return Promise.reject(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) {
|
||||
|
||||
originalRequest._retry = true;
|
||||
try {
|
||||
|
||||
const token = await refreshToken();
|
||||
|
||||
axiosApiInstance.defaults.headers.common['Authorization'] = `Bearer ${token}`;
|
||||
|
||||
if (originalRequest.data){
|
||||
originalRequest.data = JSON.parse(originalRequest.data); }
|
||||
|
||||
return axiosApiInstance(originalRequest);
|
||||
originalRequest._retry = true;
|
||||
try {
|
||||
|
||||
} catch(e) {
|
||||
|
||||
//
|
||||
// if (window.location.pathname!='/auth') window.location.reload()
|
||||
// window.location.reload()
|
||||
|
||||
return Promise.reject(error);
|
||||
const token = await refreshToken();
|
||||
|
||||
axiosApiInstance.defaults.headers.common['Authorization'] = `Bearer ${token}`;
|
||||
|
||||
if (originalRequest.data) {
|
||||
originalRequest.data = JSON.parse(originalRequest.data);
|
||||
}
|
||||
|
||||
return axiosApiInstance(originalRequest);
|
||||
|
||||
} catch (e) {
|
||||
return Promise.reject(error);
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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}
|
||||
}
|
||||
|
||||
question.answers.forEach(answer=>{
|
||||
|
||||
formData.append('answersfiles', answer.image)
|
||||
if(!!answer.image){
|
||||
const {name,size,lastModified}=answer.image
|
||||
answer.image={name,size,lastModified}
|
||||
}
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
export { axiosApiInstance, clearAxios, baseURL,spravURL, spravURLBase, baseWS }
|
||||
|
||||
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'},
|
||||
});
|
||||
|
||||
// return response.data;
|
||||
} catch (error) {
|
||||
console.error('Ошибка создания голосования:', error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async function getVoteDetail(id) {
|
||||
try {
|
||||
const response = await axiosApiInstance.get(`/api/vote/votedetail/${id}/`);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error("Ошибка получения деталей голосования:", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
// async function updateVote(id, updatedData) {
|
||||
// try {
|
||||
// const response = await axiosApiInstance.put(`/api/vote/votedetail/${id}/`, updatedData);
|
||||
// return response.data;
|
||||
// } catch (error) {
|
||||
// console.error("Ошибка обновления голосования:", error);
|
||||
// throw error;
|
||||
// }
|
||||
// }
|
||||
|
||||
// async function patchVote(id, partialData) {
|
||||
// try {
|
||||
// const response = await axiosApiInstance.patch(`/api/vote/votedetail/${id}/`, partialData);
|
||||
// return response.data;
|
||||
// } catch (error) {
|
||||
// console.error("Ошибка частичного обновления голосования:", error);
|
||||
// throw error;
|
||||
// }
|
||||
// }
|
||||
|
||||
async function deleteVote(id) {
|
||||
try {
|
||||
await axiosApiInstance.delete(`/api/vote/votedetail/${id}/`);
|
||||
console.log("Голосование успешно удалено");
|
||||
} catch (error) {
|
||||
console.error("Ошибка удаления голосования:", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async function getEmployees() {
|
||||
try {
|
||||
const response = await axiosApiInstance.get(`api/vote/getdictemployee/`);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error("Ошибка получения всех сотрудников:", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
async function getVoteResult(id) {
|
||||
try {
|
||||
const response = await axiosApiInstance.get(`/api/vote/getresults/?id=${id}`);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error("Ошибка получения результата голосования:", error);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export {
|
||||
axiosApiInstance,
|
||||
clearAxios,
|
||||
baseURL,
|
||||
spravURL,
|
||||
spravURLBase,
|
||||
baseWS,
|
||||
getVotes,
|
||||
createVote,
|
||||
getVoteDetail,
|
||||
// updateVote,
|
||||
// patchVote,
|
||||
deleteVote,
|
||||
getEmployees,
|
||||
getVoteResult,
|
||||
}
|
||||
@@ -6,8 +6,7 @@ import { axiosApiInstance, clearAxios } from "@/utils/axios-api";
|
||||
import { useRouter } from "vue-router";
|
||||
import moment from "moment";
|
||||
import { ref, onMounted } from "vue";
|
||||
|
||||
|
||||
import defaultImage from '@/assets/FNS-logo-xs.png'
|
||||
export function get_name(namestr) {
|
||||
let arr = namestr.split("/");
|
||||
return arr[arr.length - 1];
|
||||
@@ -57,18 +56,23 @@ export function getfromserverfree(path, reactive) {
|
||||
|
||||
export function checkremote(filecheck) {
|
||||
return process.env.NODE_ENV == "development"
|
||||
? "https://pixelbox.ru/wp-content/uploads/2021/11/avatar-whatsapp-pixelbox.ru-36.jpg"
|
||||
? defaultImage
|
||||
: filecheck;
|
||||
}
|
||||
|
||||
export default str;
|
||||
|
||||
export function splitname(name) {
|
||||
|
||||
return name.familyname + " " + name.name[0] + "." + name.parentname[0] + ".";
|
||||
}
|
||||
|
||||
export function pagecounter() {
|
||||
// Функция записи посещения страницы сотрудникам.
|
||||
// В случае, если в роуте присутствует ключ мета и в нем ико - тогда производится запись
|
||||
const router = useRouter();
|
||||
|
||||
if('meta' in router.currentRoute.value && 'ico' in router.currentRoute.value.meta){
|
||||
const accountStore = useAccountStore();
|
||||
const appStore = useAppStore();
|
||||
|
||||
@@ -86,9 +90,6 @@ export function pagecounter() {
|
||||
appStore.countvisitor = result.data;
|
||||
});
|
||||
}
|
||||
|
||||
export function getDevelopment() {
|
||||
return process.env.NODE_ENV == "development" ? true : false;
|
||||
}
|
||||
|
||||
export function useICalReader(url) {
|
||||
@@ -167,3 +168,9 @@ export function useICalReader(url) {
|
||||
|
||||
// return { icsContent, fetchICalFile }
|
||||
// }
|
||||
|
||||
// Функция склонения числительных
|
||||
export function declOfNum(value, titles) {
|
||||
const cases = [2, 0, 1, 1, 1, 2];
|
||||
return titles[(value % 100 > 4 && value % 100 < 20) ? 2 : cases[(value % 10 < 5) ? value % 10 : 5]];
|
||||
}
|
||||
@@ -13,8 +13,9 @@
|
||||
</v-col>
|
||||
</v-row>
|
||||
<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/> -->
|
||||
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-col>
|
||||
@@ -65,6 +66,8 @@
|
||||
<v-slide-group
|
||||
show-arrows
|
||||
>
|
||||
|
||||
|
||||
<v-slide-group-item
|
||||
v-for="x in favorit"
|
||||
:key="x"
|
||||
@@ -95,6 +98,7 @@
|
||||
|
||||
</v-card>
|
||||
</v-col>
|
||||
|
||||
</v-row>
|
||||
</v-col>
|
||||
</v-row>
|
||||
@@ -109,7 +113,7 @@
|
||||
|
||||
import CarouselList from '@/components/carousel-list.vue'
|
||||
import CarouselNumbers from '@/components/carousel-numbers.vue'
|
||||
|
||||
|
||||
|
||||
import NewsHome from '@/components/news-home.vue'
|
||||
import LoadRound from '@/components/load-round.vue'
|
||||
@@ -121,7 +125,7 @@
|
||||
export default {
|
||||
|
||||
components: {
|
||||
|
||||
|
||||
CarouselList,
|
||||
CarouselNumbers,
|
||||
|
||||
|
||||
@@ -0,0 +1,223 @@
|
||||
<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-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-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>
|
||||
|
||||
<script>
|
||||
import {computed, ref} from 'vue';
|
||||
import TestCard from "@/components/tests/TestCard.vue";
|
||||
|
||||
export default {
|
||||
components: {TestCard},
|
||||
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>
|
||||
|
||||
<style>
|
||||
.v-data-table__wrapper {
|
||||
overflow-x: auto;
|
||||
}
|
||||
</style>
|
||||
@@ -31,7 +31,6 @@
|
||||
:class="{ 'cursor-pointer': admin_panel }">
|
||||
{{
|
||||
Math.round((voteresults.uservotedthanks.length * 100 / (allsorted.length + 1)).toFixed(2)) }}%</span>
|
||||
|
||||
</template>
|
||||
<template v-slot:default="{ isActive }">
|
||||
<v-row justify="center" class="h-100 admin-vote">
|
||||
@@ -58,18 +57,17 @@
|
||||
</div>
|
||||
<div v-else class="flip-card-front" @click="toggleFlip2">
|
||||
<!-- Передняя сторона карточки -->
|
||||
<v-card
|
||||
|
||||
|
||||
<v-card
|
||||
|
||||
|
||||
class="elevation-24 d-flex align-сenter justify-space-between flex-column" width="500" height="510" variant="elevated" >
|
||||
|
||||
|
||||
<div class="">
|
||||
<div class="text-h5 my-2">ЛУЧШИЙ НОВОГОДНИЙ КОСТЮМ</div>
|
||||
<div class="mt-4 ">
|
||||
<div class=" align-center font-weight-bold">
|
||||
Выберите сотрудника,
|
||||
костюм которого вам больше всего понравился
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -117,7 +115,7 @@
|
||||
<v-card class="d-flex align-сenter justify-space-between elevated-24 flex-column" width="500" height="510" variant="elevated">
|
||||
<div class="text-h5 my-2">ЛУЧШИЙ НОВОГОДНИЙ КОСТЮМ</div>
|
||||
<!-- <v-card-text class=""> -->
|
||||
|
||||
|
||||
<vote-form class="flex-grow-1 " ref="voteform" :type_fetch="'thanks'"
|
||||
:persons="allsorted"
|
||||
:myrealdep="myrealdep" @voted="toggleFlip2" />
|
||||
@@ -137,53 +135,6 @@
|
||||
</div>
|
||||
</v-col>
|
||||
</v-col>
|
||||
<!-- <v-col cols="12" class="d-flex justify-center align-end ">
|
||||
<h1>ПРИНЯЛИ УЧАСТИЕ В ГОЛОСОВАНИИ</h1>
|
||||
</v-col> -->
|
||||
<!-- <v-col cols="12" class="d-flex justify-center align-end pa-0">
|
||||
|
||||
<v-col v-if="admin_panel" justify="center" align="center" cols="6" class=" pa-0">
|
||||
|
||||
<v-dialog> -->
|
||||
<!-- <template v-slot:activator="{ props: activatorProps }">
|
||||
<v-btn v-bind="activatorProps " variant='plain'
|
||||
class="procent_card_font pa-0">
|
||||
{{ Math.round((voteresults.usersvotedbest.filter(e=>e.department_user==mydepartment[0].department).length*100/(mydepartment.length+1)).toFixed(2))}}%
|
||||
</v-btn>
|
||||
</template> -->
|
||||
<!-- <template v-slot:default="{ isActive }">
|
||||
<v-row justify="center" class="h-100 admin-vote">
|
||||
<v-card width="1500" height="900">
|
||||
|
||||
<vote-admin :usersvotedbest="voteresults.usersvotedbest" :uservotedthanks="voteresults.uservotedthanks" :all_cod="allsorted"/>
|
||||
<v-row justify="center" align="center">
|
||||
|
||||
<v-btn color="teal-darken-1"
|
||||
@click="isActive.value = false">ЗАКРЫТЬ</v-btn>
|
||||
|
||||
</v-row>
|
||||
</v-card>
|
||||
</v-row>
|
||||
</template>
|
||||
</v-dialog>
|
||||
</v-col> -->
|
||||
<!-- <v-col v-else justify="center" align="center" cols="6" class="procent_card_font pa-0">
|
||||
|
||||
<span>{{ (Math.round(((voteresults.usersvotedbest.filter(e=>e.department_user==mydepartment[0].department).length )*100/(mydepartment.length+1)).toFixed(2)))}}%</span>
|
||||
|
||||
</v-col> -->
|
||||
|
||||
<!-- <v-col v-else justify="center" align="center" cols="6" class="procent_card_font pa-0">
|
||||
<span>{{ Math.round((voteresults.uservotedthanks.length*100/(allsorted.length+1)).toFixed(2))}}%</span>
|
||||
</v-col> -->
|
||||
<!-- </v-col> -->
|
||||
<!-- <v-col cols="12" class="d-flex justify-center align-start pa-0">
|
||||
<v-col justify="center" align="center" cols="6" class="vote-cards_cell ">
|
||||
|
||||
</v-col>
|
||||
</v-col> -->
|
||||
|
||||
<!-- Голосование Спасибо КОНЕЦ-->
|
||||
</v-row>
|
||||
</template>
|
||||
<script>
|
||||
@@ -209,7 +160,7 @@ export default {
|
||||
},
|
||||
|
||||
setup() {
|
||||
|
||||
|
||||
const voteform=ref(null)
|
||||
const voted_best = ref([])
|
||||
const full_list_pers = ref([])
|
||||
@@ -224,41 +175,16 @@ export default {
|
||||
const isFlipped2 = ref(false);
|
||||
const voteresults = ref({ usersvotedbest: [], uservotedthanks: [] })
|
||||
|
||||
// const isVoted = () => {
|
||||
// clearAxios.get(`/api/vote/getthanks/`).then((data) => {
|
||||
// votedListThn = data.data;
|
||||
// let finded_thn = votedListThn.find(({ voted_user }) => voted_user === account_login)
|
||||
// if (finded_thn.voted_user === account_login) {
|
||||
// voted_thn.value = true;
|
||||
|
||||
// }
|
||||
// });
|
||||
// clearAxios.get(`/api/vote/getbest/`).then((data) => {
|
||||
// votedListBst = data.data;
|
||||
// let finded_bst = votedListBst.find(({ voted_user }) => voted_user === account_login)
|
||||
// if (finded_bst.voted_user === account_login) {
|
||||
// voted_bst.value = true;
|
||||
// }
|
||||
|
||||
// });
|
||||
// }
|
||||
|
||||
axiosApiInstance.get('/api/vote/getvoteinfo/').then((res) => {
|
||||
allcod.value = res.data.allcod
|
||||
// console.log(account_login.user);
|
||||
myrealdep.value = allcod.value.find(e => e.login === account_login.user.login)
|
||||
console.log(myrealdep.value);
|
||||
// uservoted.value = res.data.uservoted
|
||||
voteresults.value = res.data.voteresults
|
||||
console.log(res.data.voteresults);
|
||||
})
|
||||
|
||||
|
||||
const toggleFlip1 = () => {
|
||||
|
||||
isFlipped1.value = !isFlipped1.value;
|
||||
|
||||
|
||||
};
|
||||
const toggleFlip2 = () => {
|
||||
isFlipped2.value = !isFlipped2.value;
|
||||
@@ -266,11 +192,10 @@ export default {
|
||||
|
||||
if (['9966-00-134', '9966-00-141', '9966-00-011', '9966-00-125'].includes(account_login.user.login)) {
|
||||
admin_panel.value = true;
|
||||
|
||||
}
|
||||
const allsorted = computed({
|
||||
get() {
|
||||
let all = allcod.value.filter(e => e.id != myrealdep.value.id)
|
||||
let all = allcod.value.filter(e => e.id !== myrealdep.value.id)
|
||||
return all.sort((a, b) => {
|
||||
if (b.fio > a.fio) return -1
|
||||
else if (b.fio < a.fio) return 1
|
||||
@@ -278,14 +203,10 @@ export default {
|
||||
})
|
||||
}
|
||||
})
|
||||
// isVoted();
|
||||
|
||||
|
||||
const uservotedthanks = computed({
|
||||
get() {
|
||||
|
||||
let ind = voteresults.value.uservotedthanks.findIndex(e => e.voted_user === account_login.user.login)
|
||||
|
||||
if (ind > -1) return false
|
||||
return true
|
||||
}
|
||||
@@ -293,7 +214,6 @@ export default {
|
||||
|
||||
const uservotedbest = computed({
|
||||
get() {
|
||||
|
||||
let ind = voteresults.value.usersvotedbest.findIndex(e => e.voted_user === account_login.user.login)
|
||||
if (ind > -1) return false
|
||||
return true
|
||||
@@ -301,7 +221,6 @@ export default {
|
||||
})
|
||||
const mydepartment = computed({
|
||||
get() {
|
||||
console.log(allcod.value);
|
||||
let ac = allcod.value.filter(e => e.id_dict_department === myrealdep.value.id_dict_department && e.id != myrealdep.value.id)
|
||||
return ac.sort((a, b) => {
|
||||
if (b.fio > a.fio) return -1
|
||||
@@ -341,8 +260,6 @@ export default {
|
||||
height: 600px !important;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.flip-card-inner {
|
||||
|
||||
display: flex;
|
||||
@@ -366,56 +283,14 @@ export default {
|
||||
transform: rotateY(-180deg);
|
||||
}
|
||||
|
||||
.vote-card-title {
|
||||
background-color: rgba(255, 255, 255, 0.1);
|
||||
color: white;
|
||||
font-size: 1.7em;
|
||||
}
|
||||
|
||||
.vote-button {
|
||||
margin-top: 57px;
|
||||
}
|
||||
|
||||
.vote-cards_cell {
|
||||
height: 2% !important;
|
||||
}
|
||||
|
||||
|
||||
.procent_card_font {
|
||||
font-size: 5em;
|
||||
color: #008000;
|
||||
}
|
||||
|
||||
.card-count {
|
||||
font-size: 3em;
|
||||
}
|
||||
|
||||
.you-voted {
|
||||
background-color: rgba(182, 182, 182, 0.4);
|
||||
color: #ffff;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.vote-card-information {
|
||||
background-color: rgba(255, 255, 255, 0.7);
|
||||
margin-top: 20%;
|
||||
width: 460px;
|
||||
height: 200px;
|
||||
|
||||
}
|
||||
|
||||
.vote-card-information-title {
|
||||
font-size: 1.2em;
|
||||
|
||||
}
|
||||
|
||||
.vote-title {
|
||||
font-size: 1.8em;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.vote-main-title {
|
||||
font-size: 2.3em;
|
||||
font-weight: 400;
|
||||
|
||||
}</style>
|
||||
</style>
|
||||
@@ -0,0 +1,227 @@
|
||||
<template>
|
||||
<v-container class="pt-2 d-flex flex-column" fluid>
|
||||
<v-row class="flex-column">
|
||||
<v-col cols="auto">
|
||||
<v-tabs
|
||||
v-model="currentTab"
|
||||
align="center">
|
||||
<v-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-tabs>
|
||||
|
||||
</v-col>
|
||||
<v-col class="pa-0 overflow-hidden">
|
||||
|
||||
<v-window v-model="currentTab" class="h-100">
|
||||
<!-- Текущие голосования -->
|
||||
<v-tabs-window-item v-for="x in ['active','completed']" :value="x" class="h-100 overflow-auto">
|
||||
<v-row v-if="sortedVotes.length > 0" class="mx-2">
|
||||
<v-col
|
||||
v-for="voting in sortedVotes"
|
||||
:key="voting.id"
|
||||
cols="12"
|
||||
lg="3"
|
||||
md="4"
|
||||
>
|
||||
<VoteCardVue
|
||||
:isFinished="currentTab==='active'"
|
||||
:voteCard="voting"
|
||||
@deleteVoting="deleteVoting"
|
||||
@openResultModal="(voting) => openModal('results', voting)"
|
||||
@openVoteModal="(voting) => openModal('vote', voting)"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<NoneVote v-else :current="currentTab == 'active' ? 'Текущих' : 'Завершенных'"/>
|
||||
</v-tabs-window-item>
|
||||
<!-- Конструктор -->
|
||||
<v-tabs-window-item v-if="accountStore.user.is_staff" class="h-100 overflow-auto" value="constructor">
|
||||
<VoteConstructor @updating="updating" ref="constructor"/>
|
||||
</v-tabs-window-item>
|
||||
</v-window>
|
||||
|
||||
<!-- Модальные окна -->
|
||||
<v-dialog v-model="voteModal" @click:outside="closeModal">
|
||||
<CurrentVote :data="res" @closer="closeModal"/>
|
||||
</v-dialog>
|
||||
|
||||
<v-dialog v-model="resultsModal" max-width="1200px" @click:outside="closeModal">
|
||||
<v-card>
|
||||
<VoteResult :data="result" @closer="closeModal" />
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-container>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {computed, ref, watch} from "vue";
|
||||
import VoteConstructor from "@/components/vote/VoteConstructor.vue";
|
||||
import CurrentVote from "@/components/vote/CurrentVote.vue";
|
||||
import VoteCardVue from "@/components/vote/VoteCard.vue";
|
||||
import NoneVote from "@/components/vote/NoneVote.vue"
|
||||
import {useRoute, useRouter} from "vue-router";
|
||||
import VoteResult from "@/components/vote/VoteResult.vue";
|
||||
import {deleteVote, getVoteDetail, getVoteResult, getVotes} from "@/utils/axios-api";
|
||||
// import {formatDate} from "@vueuse/shared";
|
||||
import { useAccountStore } from "@/store/AccountStore";
|
||||
import {pagecounter} from '@/utils/universal_functions'
|
||||
|
||||
export default {
|
||||
|
||||
|
||||
components: {CurrentVote, VoteConstructor, VoteCardVue, VoteResult, NoneVote},
|
||||
setup() {
|
||||
pagecounter()
|
||||
const accountStore = useAccountStore();
|
||||
const tabs = [
|
||||
{value: "active", text: 'Текущие голосования'},
|
||||
{value: "completed", text: 'Завершенные голосования'},
|
||||
|
||||
]
|
||||
|
||||
const currentTab = ref("active");
|
||||
const votes = ref([]);
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
const res = ref(null);
|
||||
const result = ref(null);
|
||||
const constructor = ref(null)
|
||||
|
||||
const updating = async (param) => {
|
||||
const data = await getVotes(param);
|
||||
votes.value = data;
|
||||
};
|
||||
|
||||
updating("active");
|
||||
|
||||
const voteModal = ref(false);
|
||||
const resultsModal = ref(false);
|
||||
const selectedVoting = ref(null);
|
||||
|
||||
const sortedVotes = computed(() => currentTab.value === 'active' ? votes.value.sort((a, b) =>
|
||||
new Date(a.dateend) - new Date(b.dateend)) :
|
||||
votes.value.sort((a, b) => new Date(b.dateend) - new Date(a.dateend)));
|
||||
|
||||
const loadVoteDetails = async (id) => {
|
||||
try {
|
||||
const data = await getVoteDetail(id);
|
||||
res.value = data;
|
||||
} catch (error) {
|
||||
console.error("Ошибка при загрузке данных голосования:", error);
|
||||
// res.value = {};
|
||||
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
const loadVoteResult = async (id) => {
|
||||
try {
|
||||
const data = await getVoteResult(id);
|
||||
result.value = data;
|
||||
} catch (error) {
|
||||
console.error("Ошибка при загрузке данных голосования:", error);
|
||||
res.value = {};
|
||||
}
|
||||
};
|
||||
|
||||
const closeModal = () => {
|
||||
voteModal.value = false;
|
||||
resultsModal.value = false;
|
||||
selectedVoting.value = null;
|
||||
router.push({name: "VoteHomePage"});
|
||||
if (route.name === "Voting") updating('active')
|
||||
if (route.name === "VoteResults") updating('completed')
|
||||
};
|
||||
|
||||
const openModal = async (type, voting) => {
|
||||
selectedVoting.value = voting;
|
||||
if (type === "vote") {
|
||||
try{
|
||||
await loadVoteDetails(voting.id);
|
||||
console.log("sd;lkjs;ljlmnjlk");
|
||||
voteModal.value = true;
|
||||
router.push({name: "Voting", params: {id: voting.id}});
|
||||
}catch(e){
|
||||
router.push({ name: "VoteHomePage" })
|
||||
}
|
||||
} else if (type === "results") {
|
||||
await loadVoteResult(voting.id);
|
||||
resultsModal.value = true;
|
||||
router.push({name: "VoteResults", params: {id: voting.id}});
|
||||
}
|
||||
};
|
||||
|
||||
const deleteVoting = async (id) => {
|
||||
try {
|
||||
await deleteVote(id);
|
||||
votes.value = votes.value.filter((v) => v.id !== id);
|
||||
} catch (error) {
|
||||
console.error("Ошибка при удалении голосования:", error);
|
||||
}
|
||||
};
|
||||
|
||||
watch(currentTab, async () => {
|
||||
if (currentTab.value !== 'constructor') {
|
||||
await updating(currentTab.value)
|
||||
console.log(constructor.value, '!!!');
|
||||
if (constructor.value !== null) {
|
||||
constructor.value.resetForm()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
watch(
|
||||
() => route,
|
||||
async () => {
|
||||
if (!voteModal.value && !resultsModal.value) {
|
||||
const voting = votes.value.find((v) => v.id === route.params.id);
|
||||
if (route.name === "Voting") {
|
||||
try{
|
||||
await loadVoteDetails(route.params.id);
|
||||
voteModal.value = true;}
|
||||
catch(e){
|
||||
router.push({ name: "VoteHomePage" })
|
||||
}
|
||||
}
|
||||
// if (route.name === "EditVote") editVoteModal.value = true;
|
||||
if (route.name === "VoteResults") {
|
||||
await loadVoteResult(route.params.id)
|
||||
resultsModal.value = true;
|
||||
}
|
||||
selectedVoting.value = voting || null;
|
||||
}
|
||||
},
|
||||
{immediate: true}
|
||||
);
|
||||
|
||||
updating("active");
|
||||
|
||||
return {
|
||||
accountStore,
|
||||
currentTab,
|
||||
votes,
|
||||
sortedVotes,
|
||||
voteModal,
|
||||
resultsModal,
|
||||
selectedVoting,
|
||||
openModal,
|
||||
closeModal,
|
||||
deleteVoting,
|
||||
updating,
|
||||
res,
|
||||
tabs,
|
||||
result,
|
||||
constructor
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.voted-card {
|
||||
opacity: 0.6;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,98 @@
|
||||
<template>
|
||||
<v-container :fluid="true">
|
||||
<v-tabs v-model="activeTab" class="mb-2 text-teal-darken-4">
|
||||
<v-tab v-for="tab in tabs" :key="tab.value" :value="tab.value"> {{ tab.title }} </v-tab>
|
||||
</v-tabs>
|
||||
<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>
|
||||
|
||||
<script>
|
||||
import CatalogTest from "@/components/testing/CatalogTest.vue";
|
||||
import { axiosApiInstance } from "@/utils/axios-api";
|
||||
|
||||
import { ref, computed, watch } from "vue"
|
||||
|
||||
export default {
|
||||
components: {
|
||||
CatalogTest
|
||||
},
|
||||
setup() {
|
||||
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 {
|
||||
activeTab,
|
||||
tabs,
|
||||
getAllTests,
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in new issue
Block a user