Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
88c9403fa4 | ||
|
|
f27037ebe5 | ||
|
|
a839273951 | ||
|
|
2c609e2fd9 | ||
|
|
5edadc5ef7 | ||
|
|
b29e7eb535 | ||
|
|
1e1311bb22 | ||
|
|
37b1f18c4c | ||
|
|
76a6d0ae20 | ||
|
|
45f365f734 | ||
|
|
76fb9316cd | ||
|
|
22f9220a57 | ||
|
|
77d6679f39 | ||
|
|
f189636791 | ||
|
|
1f898f9281 | ||
|
|
21ed19749e | ||
|
|
e8dbb47479 | ||
|
|
65f76c65b7 | ||
|
|
5a746ff4b0 | ||
|
|
dbb5799d7c | ||
|
|
0e2440d94e | ||
|
|
d003ab12e7 | ||
|
|
ac9bb6dba1 | ||
|
|
d77c9ec49b | ||
|
|
8d88716cb0 | ||
|
|
c7e554fce1 | ||
|
|
d725eba050 | ||
|
|
d96a7a93dd | ||
|
|
fba4289f5f | ||
|
|
23d02f1f28 | ||
|
|
61798ba15e | ||
|
|
00eef5b31c | ||
|
|
526b72f2cf | ||
|
|
d7f4997d18 | ||
|
|
b7943efaab | ||
|
|
0af6453105 | ||
|
|
9bd778fc5e | ||
|
|
a9fe60b789 | ||
|
|
e72cafe5b1 | ||
|
|
c58a0f4f07 | ||
|
|
0cf8b8eb4f | ||
|
|
83cf60f291 | ||
|
|
fb831194e4 | ||
|
|
b79de52053 | ||
|
|
449fa9a611 | ||
|
|
abdb89e1cf | ||
|
|
98453a7752 | ||
|
|
20cde7a498 | ||
|
|
0207b624b3 | ||
|
|
ecfa04b702 | ||
|
|
eab31be04a | ||
|
|
d6086c15e2 | ||
|
|
6bca44a036 | ||
|
|
db2bbaf2c5 | ||
|
|
be58b5aa9b | ||
|
|
89987acc52 | ||
|
|
3a1c7b0a7f | ||
|
|
a72e481058 | ||
|
|
9cebd17801 | ||
|
|
ac7a6fe59e | ||
|
|
5da883dbb3 | ||
|
|
075bb5fa9e | ||
|
|
567592d794 | ||
|
|
45d77b7bca | ||
|
|
0c4222ccdc | ||
|
|
d92692449c | ||
|
|
336acda8bc | ||
|
|
65f62a0164 | ||
|
|
3834c7893e | ||
|
|
fbc97ef9ef | ||
|
|
f1e268b894 | ||
|
|
01378bae2c | ||
|
|
7fdd119a60 | ||
|
|
6f308faa87 | ||
|
|
612f673726 | ||
|
|
f9dc3e3255 | ||
|
|
ba97dca24b | ||
|
|
eacd20b603 | ||
|
|
8800f648b9 | ||
|
|
d51fbd5107 | ||
|
|
687eef521c | ||
|
|
60665aeeed | ||
|
|
9408fe1305 | ||
|
|
88d79e4e8b | ||
|
|
a2293ef53d | ||
|
|
34765c4f3d | ||
|
|
5c956216ce | ||
|
|
b6ef111722 | ||
|
|
e464e88698 | ||
|
|
78e52ad97e | ||
|
|
462f1c5fed | ||
|
|
3c4256d4f8 | ||
|
|
0c5a17eb5a | ||
|
|
913084c3f4 | ||
|
|
b964bd57b5 | ||
|
|
6789049780 | ||
|
|
99e4be1ded | ||
|
|
1285689037 | ||
|
|
bd158a8e62 | ||
|
|
75463c0b7c | ||
|
|
e8f84b4ba2 | ||
|
|
53095cea11 | ||
|
|
681ec27917 | ||
|
|
8e446a9e72 | ||
|
|
2634fc303f | ||
|
|
e6e42cbe5b | ||
|
|
3d2e35f873 | ||
|
|
8e7316ff1a | ||
|
|
6adb7e6b29 | ||
|
|
da58a80c8a | ||
|
|
0bd0e42d86 | ||
|
|
73b4f1edd2 | ||
|
|
0d4ee19b7c | ||
|
|
0279a34d0e | ||
|
|
3fbc1b0729 | ||
|
|
f9909cacd8 | ||
|
|
5cc6606e33 | ||
|
|
92c6df39b9 | ||
|
|
b30a089207 | ||
|
|
df2e9cb513 | ||
|
|
316ea215c6 | ||
|
|
a6fbd37c58 | ||
|
|
88935c2fb8 | ||
|
|
0d9c294998 | ||
|
|
3f315ed297 | ||
|
|
5bbe0826f3 | ||
|
|
7f8319443f | ||
|
|
2a449b123a | ||
|
|
b6f51f663f | ||
|
|
f76b6d1a70 | ||
|
|
36127df048 | ||
|
|
21ae8bdbe3 | ||
|
|
53e10577eb | ||
|
|
c945a11f17 | ||
|
|
12cfb5166b | ||
|
|
d3eb0c10a1 | ||
|
|
e8ff3f0779 | ||
|
|
09689b05b5 | ||
|
|
b00fafef84 | ||
|
|
e18a6e8e5c | ||
|
|
64ea67025b | ||
|
|
9e0a3b0ad6 | ||
|
|
46dd29d2c3 | ||
|
|
4ca880653c | ||
|
|
55dc560c76 | ||
|
|
f1d62b7b95 | ||
|
|
f25f0c3d9e | ||
|
|
e530c1f76a | ||
|
|
f21ee65d73 | ||
|
|
ba58b087e1 | ||
|
|
74f55128f1 | ||
|
|
593caac694 | ||
|
|
689d5d6268 | ||
|
|
0dd6b6295c | ||
|
|
1f92c87fb7 | ||
|
|
61fd8182d4 | ||
|
|
448157564a | ||
|
|
d912c75671 | ||
|
|
f303732efb | ||
|
|
dd311a03ac | ||
|
|
29ba4676a9 | ||
|
|
21ff63eff1 | ||
|
|
875b389aaa | ||
|
|
63da2079a3 | ||
|
|
05bf218246 | ||
|
|
78445ef51f | ||
|
|
e2a937bfe5 | ||
|
|
33e321c52b | ||
|
|
2b4ba0e2ed | ||
|
|
8c1881e592 | ||
|
|
5336707bd4 | ||
|
|
4fc72c679b | ||
|
|
69d9470002 | ||
|
|
51b2e49ee4 | ||
|
|
84dc5e9e72 | ||
|
|
fb9460e4d5 | ||
|
|
223a5f127f | ||
|
|
ce78c17b50 | ||
|
|
2a1d6e2692 | ||
|
|
fdff22fe85 | ||
|
|
d532af85d5 | ||
|
|
b9968fc8ed | ||
|
|
5fea889d9f | ||
|
|
6844ebd0fc | ||
|
|
674cad2985 | ||
|
|
1dcce092a3 | ||
|
|
2599536aa5 | ||
|
|
34226a3736 | ||
|
|
6e7b0e28bb | ||
|
|
cb0fb68dcc | ||
|
|
2b5d1ef079 | ||
|
|
2f6bf2492c | ||
|
|
0d84e30bd1 | ||
|
|
6ffe0530d6 | ||
|
|
3008181c12 | ||
|
|
61a7354ee8 | ||
|
|
73cb9b6fb5 | ||
|
|
19b5753aba | ||
|
|
28366b624a | ||
|
|
befc434190 | ||
|
|
941e2f4d7e | ||
|
|
42c7af4489 | ||
|
|
e50ea0a16f | ||
|
|
1f302acba7 | ||
|
|
152f3a6580 | ||
|
|
02df365098 | ||
|
|
7b8571bfcc | ||
|
|
d06eafa229 | ||
|
|
7d60be63e9 | ||
|
|
dafd40cf7e | ||
|
|
a1c7dcb000 | ||
|
|
57c2bced00 | ||
|
|
c7b44e4696 | ||
|
|
71089be8ae | ||
|
|
18cb9186b1 | ||
|
|
3263597767 | ||
|
|
63faa67b81 | ||
|
|
26d6fe6ade | ||
|
|
38017d4ad8 | ||
|
|
4db23b5e40 | ||
|
|
c0e93ea7c3 | ||
|
|
7430a61402 | ||
|
|
428db496ea | ||
|
|
aabd1b84b7 | ||
|
|
152f98aa28 | ||
|
|
0cdbf70706 | ||
|
|
2ef850a8d7 | ||
|
|
bb9366c417 | ||
|
|
35d1c01695 | ||
|
|
89877a7850 | ||
|
|
0de452ea96 | ||
|
|
e17459a1c6 | ||
|
|
84cb061b20 | ||
|
|
bb434caaf8 | ||
|
|
bd1e66dd1e | ||
|
|
4b95af9a18 | ||
|
|
fd5aa80d96 | ||
|
|
8b7e539227 | ||
|
|
5b514551fe | ||
|
|
915f2ba2a7 | ||
|
|
8abaec7c53 | ||
|
|
1e7bfcc7aa | ||
|
|
73a7a04d3b | ||
|
|
1cad19e2de | ||
|
|
792b8818fb | ||
|
|
e115815309 | ||
|
|
75ae9abee1 | ||
|
|
26f49a6936 | ||
|
|
068b93390d | ||
|
|
83a74d088b | ||
|
|
6d1009807d | ||
|
|
9436e96216 | ||
|
|
5c8b40e740 | ||
|
|
bf3d876f45 | ||
|
|
8d08071b29 | ||
|
|
c87fdd63ba | ||
|
|
8b8783517a | ||
|
|
c7a2491021 | ||
|
|
67f417a778 | ||
|
|
19f261318b | ||
|
|
0c012e6ff0 | ||
|
|
6ea5a8c61f | ||
|
|
59bada6ad8 | ||
|
|
ca4fb7164a | ||
|
|
0c1ead0c3f | ||
|
|
3ec552a2c3 | ||
|
|
452f8a1021 | ||
|
|
f1338c7e61 | ||
|
|
443f320e85 | ||
|
|
1874033109 | ||
|
|
2e08c7187b | ||
|
|
6c5acda5f2 | ||
|
|
44ada2713a | ||
|
|
ed281dae01 | ||
|
|
725e0da847 | ||
|
|
7956d08e2f | ||
|
|
556ec298db | ||
|
|
6ef4c18bb2 | ||
|
|
9e2fc5a521 | ||
|
|
20b0daea14 |
No files matched your search
@@ -31,15 +31,15 @@ DB_NAME=""
|
|||||||
DB_USER=""
|
DB_USER=""
|
||||||
DB_PASSWORD=""
|
DB_PASSWORD=""
|
||||||
DB_HOST=""
|
DB_HOST=""
|
||||||
DB_EXTERNAL_PORT=3306
|
DB_PORT=3306
|
||||||
DB_INTERNAL_PORT=3306
|
|
||||||
|
|
||||||
REDIS="redis://redis"
|
REDIS="redis://redis"
|
||||||
REDISBROKER="redis://redis"
|
REDISBROKER="redis://redis"
|
||||||
REDIS_PORT=6379
|
REDIS_PORT=6379
|
||||||
REDIS_BASE=0
|
REDIS_BASE=0
|
||||||
|
|
||||||
AUTO_BACKEND=True
|
AUTO_BACKEND="True"
|
||||||
|
|
||||||
FRONTEND_EXTERNAL_PORT=3000
|
FRONTEND_EXTERNAL_PORT=3000
|
||||||
FRONTEND_INTERNAL_PORT=3000
|
FRONTEND_INTERNAL_PORT=3000
|
||||||
@@ -47,7 +47,7 @@ FRONTEND_INTERNAL_PORT=3000
|
|||||||
BACKEND_EXTERNAL_PORT=8000
|
BACKEND_EXTERNAL_PORT=8000
|
||||||
BACKEND_INTERNAL_PORT=8000
|
BACKEND_INTERNAL_PORT=8000
|
||||||
|
|
||||||
|
DOCKER_RESTART="unless-stopped"
|
||||||
|
|
||||||
DOCS_EXTERNAL_PORT=5173
|
DOCS_EXTERNAL_PORT=5173
|
||||||
DOCS_INTERNAL_PORT=5173
|
DOCS_INTERNAL_PORT=5173
|
||||||
@@ -55,4 +55,8 @@ NGINX_EXTERNAL_PORT=80
|
|||||||
NGINX_INTERNAL_PORT=80
|
NGINX_INTERNAL_PORT=80
|
||||||
|
|
||||||
RUN_WITH_DOCS=False
|
RUN_WITH_DOCS=False
|
||||||
PRODUCTION=False
|
PRODUCTION=True
|
||||||
|
|
||||||
|
MYDEBUG=False
|
||||||
|
DJANGO_CSRF_TRUSTED_ORIGINS="http://localhost, http://portal-t, http://127.0.0.1, http://portal9966/"
|
||||||
|
DJANGO_ALLOWED_HOSTS="*, portal-t, portal9966, localhost, 0.0.0.0"
|
||||||
+2
-3
@@ -4,7 +4,6 @@ AUTO_BACKEND=False
|
|||||||
|
|
||||||
DB_NAME="accounting"
|
DB_NAME="accounting"
|
||||||
DB_USER="root"
|
DB_USER="root"
|
||||||
DB_PASSWORD="P@ssw0rd"
|
DB_PASSWORD="yourpassword"
|
||||||
DB_HOST="db"
|
DB_HOST="db"
|
||||||
DB_EXTERNAL_PORT=3306
|
DB_PORT=3306
|
||||||
DB_INTERNAL_PORT=3306
|
|
||||||
Regular → Executable
File mode changed.
Regular → Executable
+6
-6
@@ -10,10 +10,10 @@ if [ -n "$filesjs" ]; then
|
|||||||
filesjs_modified=$(echo "$filesjs" | sed 's|^src/front/src/|src/|'| tr '\n' ' ')
|
filesjs_modified=$(echo "$filesjs" | sed 's|^src/front/src/|src/|'| tr '\n' ' ')
|
||||||
# Запускаем команду formatter в контейнере
|
# Запускаем команду formatter в контейнере
|
||||||
echo $filesjs_modified
|
echo $filesjs_modified
|
||||||
if [ "$(docker-compose -f docker-compose.yml ps -q frontend)" ]; then
|
if [ "$(docker compose -f docker-compose.yml ps -q frontend)" ]; then
|
||||||
docker-compose -f docker-compose.yml exec frontend sh -c "npm run formatter $filesjs_modified && npm run linter $filesjs_modified"
|
docker compose -f docker-compose.yml exec frontend sh -c "npm run formatter $filesjs_modified && npm run linter $filesjs_modified"
|
||||||
else
|
else
|
||||||
docker-compose -f docker-compose.yml run --rm frontend sh -c "npm run formatter $filesjs_modified && npm run linter $filesjs_modified"
|
docker compose -f docker-compose.yml run --rm frontend sh -c "npm run formatter $filesjs_modified && npm run linter $filesjs_modified"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -32,11 +32,11 @@ pyfiles=$(git diff --cached --name-only --diff-filter=ACM | grep '\.py$')
|
|||||||
|
|
||||||
if [ -n "$pyfiles" ]; then
|
if [ -n "$pyfiles" ]; then
|
||||||
pyfiles_mod=$(echo "$pyfiles" | sed 's|^src/back/||'| tr '\n' ' ')
|
pyfiles_mod=$(echo "$pyfiles" | sed 's|^src/back/||'| tr '\n' ' ')
|
||||||
if [ "$(docker-compose -f docker-compose.yml ps -q backend)" ]; then
|
if [ "$(docker compose -f docker-compose.yml ps -q backend)" ]; then
|
||||||
echo $pyfiles_mod
|
echo $pyfiles_mod
|
||||||
docker-compose -f docker-compose.yml exec backend sh -c "poetry run isort $pyfiles_mod && poetry run black $pyfiles_mod && poetry run pylint $pyfiles_mod"
|
docker compose -f docker-compose.yml exec backend sh -c "poetry run isort $pyfiles_mod && poetry run black $pyfiles_mod && poetry run pylint $pyfiles_mod"
|
||||||
else
|
else
|
||||||
docker-compose -f docker-compose.yml run --rm --entrypoint sh backend -c "poetry run isort $pyfiles_mod && poetry run black $pyfiles_mod && poetry run pylint $pyfiles_mod"
|
docker compose -f docker-compose.yml run --rm --entrypoint sh backend -c "poetry run isort $pyfiles_mod && poetry run black $pyfiles_mod && poetry run pylint $pyfiles_mod"
|
||||||
fi
|
fi
|
||||||
# # Запуск pylint для всех подготовленных Python-файлов
|
# # Запуск pylint для всех подготовленных Python-файлов
|
||||||
# # echo 1
|
# # echo 1
|
||||||
@@ -14,4 +14,6 @@ easynpm
|
|||||||
easydump
|
easydump
|
||||||
easyrestore
|
easyrestore
|
||||||
easymanage
|
easymanage
|
||||||
|
easydockersave
|
||||||
|
easyserver
|
||||||
#
|
#
|
||||||
+69
-62
@@ -1,10 +1,20 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
clear_directory() {
|
||||||
|
local dir=$1
|
||||||
|
if [ -d "$dir" ]; then
|
||||||
|
echo "Очистка папки: $dir"
|
||||||
|
rm -rf "$dir"/*
|
||||||
|
else
|
||||||
|
echo "Папка не существует: $dir"
|
||||||
|
fi
|
||||||
|
}
|
||||||
# Функция для вывода переменных, определенных во время исполнения скрипта
|
# Функция для вывода переменных, определенных во время исполнения скрипта
|
||||||
print_script_variables() {
|
print_script_variables() {
|
||||||
set | sort | comm -13 .env.tmp -
|
set | sort | comm -13 .env.tmp -
|
||||||
}
|
}
|
||||||
|
# Мина разработчикам с правилами гит-хуков
|
||||||
git config core.hooksPath .git-hooks
|
git config core.hooksPath .git-hooks
|
||||||
|
chmod -R +x .git-hooks/
|
||||||
# Записываем переменные окружения и функции оболочки во временный файл
|
# Записываем переменные окружения и функции оболочки во временный файл
|
||||||
set | sort > .env.tmp
|
set | sort > .env.tmp
|
||||||
|
|
||||||
@@ -13,7 +23,7 @@ source ".env.base"
|
|||||||
|
|
||||||
# Создаем локальные файлы из их шаблонов, если они еще не созданы
|
# Создаем локальные файлы из их шаблонов, если они еще не созданы
|
||||||
cp -n ${PROJECT_DIR}/.env.local.sample ${PROJECT_DIR}/.env.local
|
cp -n ${PROJECT_DIR}/.env.local.sample ${PROJECT_DIR}/.env.local
|
||||||
# cp -n ${SOURCE_DIR}/settings/local_settings.sample.py ${SOURCE_DIR}/settings/local_settings.py
|
|
||||||
|
|
||||||
# Импортируем локальные переменные окружения
|
# Импортируем локальные переменные окружения
|
||||||
if [[ -f .env.local ]]; then
|
if [[ -f .env.local ]]; then
|
||||||
@@ -28,12 +38,13 @@ ln -sf "${CONFS_DIR}/scripts/easypip.sh" "${PROJECT_DIR}/easypip"
|
|||||||
ln -sf "${CONFS_DIR}/scripts/easynpm.sh" "${PROJECT_DIR}/easynpm"
|
ln -sf "${CONFS_DIR}/scripts/easynpm.sh" "${PROJECT_DIR}/easynpm"
|
||||||
ln -sf "${CONFS_DIR}/scripts/easydump.sh" "${PROJECT_DIR}/easydump"
|
ln -sf "${CONFS_DIR}/scripts/easydump.sh" "${PROJECT_DIR}/easydump"
|
||||||
ln -sf "${CONFS_DIR}/scripts/easyrestore.sh" "${PROJECT_DIR}/easyrestore"
|
ln -sf "${CONFS_DIR}/scripts/easyrestore.sh" "${PROJECT_DIR}/easyrestore"
|
||||||
ln -sf "${CONFS_DIR}/scripts/easymanage.sh" "${PROJECT_DIR}/easymanage"
|
ln -sf "${CONFS_DIR}/scripts/easydockersave.sh" "${PROJECT_DIR}/easydockersave"
|
||||||
# ln -sf "${PROJECT_DIR}/scripts/bash.sh" "${PROJECT_DIR}/bash"
|
ln -sf "${CONFS_DIR}/scripts/easyserver.sh" "${PROJECT_DIR}/easyserver"
|
||||||
# ln -sf "${PROJECT_DIR}/scripts/dbshell.sh" "${PROJECT_DIR}/dbshell"
|
|
||||||
# ln -sf "${PROJECT_DIR}/scripts/manage.sh" "${PROJECT_DIR}/manage"
|
|
||||||
# ln -sf "${PROJECT_DIR}/scripts/shell.sh" "${PROJECT_DIR}/shell"
|
mkdir -p "${LOCAL_FILES_DIR}/builds"
|
||||||
# ln -sf "${PROJECT_DIR}/scripts/init.sh" "${PROJECT_DIR}/init"
|
mkdir -p "${LOCAL_FILES_DIR}/builds/images"
|
||||||
|
mkdir -p "${LOCAL_FILES_DIR}/builds/volumes"
|
||||||
|
|
||||||
# # Создание локальных файлов для postgres:
|
# # Создание локальных файлов для postgres:
|
||||||
mkdir -p "${LOCAL_FILES_DIR}/mysql"
|
mkdir -p "${LOCAL_FILES_DIR}/mysql"
|
||||||
@@ -53,36 +64,32 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# # Создание локальных файлов для redis:
|
# # Создание локальных файлов для redis:
|
||||||
mkdir -p "${LOCAL_FILES_DIR}/redis"
|
mkdir -p "${LOCAL_FILES_DIR}/redis"
|
||||||
mkdir -p "${LOCAL_FILES_DIR}/redis/log"
|
mkdir -p "${LOCAL_FILES_DIR}/redis/log"
|
||||||
mkdir -p "${LOCAL_FILES_DIR}/redis/data"
|
mkdir -p "${LOCAL_FILES_DIR}/redis/data"
|
||||||
# # Создание локальных файлов для asgi:
|
|
||||||
# mkdir -p "${LOCAL_FILES_DIR}/asgi"
|
|
||||||
# mkdir -p "${LOCAL_FILES_DIR}/asgi/log"
|
|
||||||
# mkdir -p "${LOCAL_FILES_DIR}/asgi/tmp"
|
|
||||||
# mkdir -p "${LOCAL_FILES_DIR}/asgi/media"
|
|
||||||
# # Создание локальных файлов для centry:
|
|
||||||
# mkdir -p "${LOCAL_FILES_DIR}/celery"
|
|
||||||
# mkdir -p "${LOCAL_FILES_DIR}/celery/log"
|
|
||||||
# # Создание локальных файлов для nginx:
|
# # Создание локальных файлов для nginx:
|
||||||
mkdir -p "${LOCAL_FILES_DIR}/nginx"
|
mkdir -p "${LOCAL_FILES_DIR}/nginx"
|
||||||
mkdir -p "${LOCAL_FILES_DIR}/nginx/conf"
|
mkdir -p "${LOCAL_FILES_DIR}/nginx/conf"
|
||||||
# mkdir -p "${LOCAL_FILES_DIR}/nginx/log"
|
|
||||||
# mkdir -p "${LOCAL_FILES_DIR}/nginx/certs"
|
|
||||||
|
|
||||||
# Создания docker-compose.override.yml (под gitignore)
|
|
||||||
# touch "${DOCKER_COMPOSES_DIR}/docker-compose.override.yml"
|
# # Создание локальных файлов медиа джанги:
|
||||||
|
|
||||||
|
mkdir -p "${LOCAL_FILES_DIR}/django"
|
||||||
|
mkdir -p "${LOCAL_FILES_DIR}/django/media"
|
||||||
|
mkdir -p "${LOCAL_FILES_DIR}/django/media/tmp"
|
||||||
|
mkdir -p "${LOCAL_FILES_DIR}/django/static"
|
||||||
|
clear_directory "${LOCAL_FILES_DIR}/front/"
|
||||||
|
|
||||||
|
mkdir -p "${LOCAL_FILES_DIR}/front/"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Создание конфигов nginx из их шаблонов
|
# Создание конфигов nginx из их шаблонов
|
||||||
export NGINX_EXTERNAL_PORT=${NGINX_EXTERNAL_PORT}
|
export NGINX_EXTERNAL_PORT=${NGINX_EXTERNAL_PORT}
|
||||||
@@ -90,10 +97,21 @@ export BACKEND_EXTERNAL_PORT=${BACKEND_EXTERNAL_PORT}
|
|||||||
export FRONTEND_EXTERNAL_PORT=${FRONTEND_EXTERNAL_PORT}
|
export FRONTEND_EXTERNAL_PORT=${FRONTEND_EXTERNAL_PORT}
|
||||||
export DOCS_EXTERNAL_PORT=${DOCS_EXTERNAL_PORT}
|
export DOCS_EXTERNAL_PORT=${DOCS_EXTERNAL_PORT}
|
||||||
export HOST_NAME=${HOST_NAME}
|
export HOST_NAME=${HOST_NAME}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# if [[ "${PRODUCTION}" != "False" ]]; then
|
||||||
|
# echo "Сборка версии для сервера!"
|
||||||
|
envsubst '${NGINX_EXTERNAL_PORT},${BACKEND_EXTERNAL_PORT},${DOCS_EXTERNAL_PORT},${FRONTEND_EXTERNAL_PORT},${HOST_NAME}' \
|
||||||
|
< "${CONFS_DIR}/nginx/nginx.prod.conf" > \
|
||||||
|
"${LOCAL_FILES_DIR}/nginx/conf/nginx.prod.conf"
|
||||||
# # Следующие команды заполняют шаблон значениями переменных окружения
|
# # Следующие команды заполняют шаблон значениями переменных окружения
|
||||||
|
# else
|
||||||
|
# echo "Сборка версии для РАЗРАБОТКИ!"
|
||||||
envsubst '${NGINX_EXTERNAL_PORT},${BACKEND_EXTERNAL_PORT},${DOCS_EXTERNAL_PORT},${FRONTEND_EXTERNAL_PORT},${HOST_NAME}' \
|
envsubst '${NGINX_EXTERNAL_PORT},${BACKEND_EXTERNAL_PORT},${DOCS_EXTERNAL_PORT},${FRONTEND_EXTERNAL_PORT},${HOST_NAME}' \
|
||||||
< "${CONFS_DIR}/nginx/nginx.dev.conf" > \
|
< "${CONFS_DIR}/nginx/nginx.dev.conf" > \
|
||||||
"${LOCAL_FILES_DIR}/nginx/conf/nginx.dev.conf"
|
"${LOCAL_FILES_DIR}/nginx/conf/nginx.dev.conf"
|
||||||
|
# fi
|
||||||
# envsubst '${NGINX_PORT_INTERNAL},${ASGI_PORT_INTERNAL},${DOCS_PORT_INTERNAL},${HOST_NAME}' \
|
# envsubst '${NGINX_PORT_INTERNAL},${ASGI_PORT_INTERNAL},${DOCS_PORT_INTERNAL},${HOST_NAME}' \
|
||||||
# < "${CONFS_DIR}/nginx.prod.conf" > \
|
# < "${CONFS_DIR}/nginx.prod.conf" > \
|
||||||
# "${LOCAL_FILES_DIR}/nginx/conf/nginx.prod.conf"
|
# "${LOCAL_FILES_DIR}/nginx/conf/nginx.prod.conf"
|
||||||
@@ -102,42 +120,31 @@ envsubst '${NGINX_EXTERNAL_PORT},${BACKEND_EXTERNAL_PORT},${DOCS_EXTERNAL_PORT},
|
|||||||
|
|
||||||
|
|
||||||
# Дополнение docker-compose.yaml в зависимости от значений переменных окружения
|
# Дополнение docker-compose.yaml в зависимости от значений переменных окружения
|
||||||
# if [[ "${RUN_WITH_REDIS}" = "True" ]]; then
|
|
||||||
# COMPOSE_FILE="${COMPOSE_FILE}:${DOCKER_COMPOSES_DIR}/docker-compose.redis.yml"
|
|
||||||
# fi
|
|
||||||
# if [[ "${RUN_WITH_POSTGRES}" = "True" ]]; then
|
|
||||||
# COMPOSE_FILE="${COMPOSE_FILE}:${DOCKER_COMPOSES_DIR}/docker-compose.postgres.yml"
|
|
||||||
# fi
|
|
||||||
# if [[ "${RUN_WITH_OVERRIDE_DOCKER_COMPOSE}" = "True" ]]; then
|
|
||||||
# COMPOSE_FILE="${COMPOSE_FILE}:${DOCKER_COMPOSES_DIR}/docker-compose.override.yml"
|
|
||||||
# fi
|
|
||||||
if [[ "${RUN_WITH_DOCS}" = "True" ]]; then
|
if [[ "${RUN_WITH_DOCS}" = "True" ]]; then
|
||||||
echo $DOCKER_COMPOSES_DIR
|
echo $DOCKER_COMPOSES_DIR
|
||||||
COMPOSE_FILE="${COMPOSE_FILE} -f ${DOCKER_COMPOSES_DIR}/docker-compose.docs.yml"
|
COMPOSE_FILE="${COMPOSE_FILE} -f ${DOCKER_COMPOSES_DIR}/docker-compose.docs.yml"
|
||||||
fi
|
fi
|
||||||
# if [[ "${RUN_WITH_BUILD_LOCALLY}" = "True" ]]; then
|
|
||||||
# COMPOSE_FILE="${COMPOSE_FILE}:${DOCKER_COMPOSES_DIR}/docker-compose.build-asgi-locally.yml"
|
|
||||||
# if [[ "${RUN_WITH_DOCS}" = "True" ]]; then
|
if [[ "${PRODUCTION}" != "False" ]]; then
|
||||||
# COMPOSE_FILE="${COMPOSE_FILE}:${DOCKER_COMPOSES_DIR}/docker-compose.build-docs-locally.yml"
|
echo "Сборка версии для сервера!"
|
||||||
# fi
|
# COMPOSE_FILE="${COMPOSE_FILE}:${DOCKER_COMPOSES_DIR}/docker-compose.build-locally.yml"
|
||||||
# fi
|
# if [[ "${RUN_WITH_DOCS}" = "True" ]]; then
|
||||||
# ARG_FOUND=false
|
# COMPOSE_FILE="${COMPOSE_FILE}:${DOCKER_COMPOSES_DIR}/docker-compose.build-docs-locally.yml"
|
||||||
# TARGET_ARG="--lint"
|
# fi
|
||||||
# for arg in "$@"; do
|
COMPOSE_FILE="${COMPOSE_FILE} -f ${DOCKER_COMPOSES_DIR}/docker-compose.prod.yml"
|
||||||
# if [ "$arg" == "$TARGET_ARG" ]; then
|
else
|
||||||
# ARG_FOUND=true
|
echo "Сборка версии для РАЗРАБОТКИ!"
|
||||||
# break
|
COMPOSE_FILE="${COMPOSE_FILE} -f ${DOCKER_COMPOSES_DIR}/docker-compose.dev.yml"
|
||||||
# fi
|
|
||||||
# done
|
fi
|
||||||
# if [ "$ARG_FOUND" = true ]; then
|
|
||||||
# COMPOSE_FILE="${COMPOSE_FILE}:${DOCKER_COMPOSES_DIR}/docker-compose.frontlint.yml"
|
|
||||||
# else
|
|
||||||
# if [[ "${PRODUCTION}" = "False" ]]; then
|
|
||||||
# COMPOSE_FILE="${COMPOSE_FILE}:${DOCKER_COMPOSES_DIR}/docker-compose.dev.yml"
|
|
||||||
# else
|
|
||||||
# COMPOSE_FILE="${COMPOSE_FILE}:${DOCKER_COMPOSES_DIR}/docker-compose.prod.yml"
|
|
||||||
# fi
|
|
||||||
# fi
|
|
||||||
# Записываем в файл переменные окружения, объявленные в процессе выполнения текущего скрипта
|
# Записываем в файл переменные окружения, объявленные в процессе выполнения текущего скрипта
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -25,4 +25,8 @@ while [ $1 ]
|
|||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
echo $COMPOSE_FILE
|
echo $COMPOSE_FILE
|
||||||
docker compose -f ${COMPOSE_FILE} ${ARGS_STRING}
|
if command -v docker compose version &> /dev/null; then
|
||||||
|
docker compose -f ${COMPOSE_FILE} ${ARGS_STRING}
|
||||||
|
else
|
||||||
|
docker-compose -f ${COMPOSE_FILE} ${ARGS_STRING}
|
||||||
|
fi
|
||||||
+41
-67
@@ -1,88 +1,63 @@
|
|||||||
|
|
||||||
networks:
|
networks:
|
||||||
dev:
|
dev:
|
||||||
|
name: ${COMPOSE_PROJECT_NAME}
|
||||||
driver: bridge
|
driver: bridge
|
||||||
|
|
||||||
services:
|
|
||||||
|
|
||||||
frontend:
|
x-all-base: &all-base
|
||||||
|
|
||||||
restart:
|
restart:
|
||||||
always
|
${DOCKER_RESTART}
|
||||||
env_file:
|
env_file:
|
||||||
- .env
|
- .env
|
||||||
build:
|
# Все наши сервисы для удобства будут в одной сети
|
||||||
context: .
|
networks:
|
||||||
dockerfile: docker/dockerfiles/dev
|
- dev
|
||||||
args:
|
|
||||||
SOURCE_DIR: ./src/front
|
|
||||||
volumes:
|
|
||||||
|
|
||||||
- ./src/front/:/app
|
x-backend-base: &backend-base
|
||||||
- /app/node_modules
|
build:
|
||||||
|
|
||||||
ports:
|
|
||||||
- "${FRONTEND_EXTERNAL_PORT}:${FRONTEND_INTERNAL_PORT}"
|
|
||||||
environment:
|
|
||||||
- CHOKIDAR_USEPOLLING=true
|
|
||||||
|
|
||||||
|
|
||||||
networks:
|
|
||||||
- dev
|
|
||||||
|
|
||||||
|
|
||||||
redis:
|
|
||||||
env_file:
|
|
||||||
- .env
|
|
||||||
image: redis:alpine # Используем легковесный образ Redis
|
|
||||||
ports:
|
|
||||||
- "${REDIS_PORT}:${REDIS_PORT}" # Открываем порт Redis для внешнего доступа (по желанию)
|
|
||||||
networks:
|
|
||||||
- dev
|
|
||||||
|
|
||||||
db:
|
|
||||||
env_file:
|
|
||||||
- .env
|
|
||||||
image: mysql:latest
|
|
||||||
ports:
|
|
||||||
- "${DB_EXTERNAL_PORT}:${DB_INTERNAL_PORT}" # Открываем порт MySQL для внешнего доступа
|
|
||||||
environment:
|
|
||||||
- MYSQL_DATABASE=${DB_NAME}
|
|
||||||
- MYSQL_PASSWORD=${DB_PASSWORD}
|
|
||||||
- MYSQL_ROOT_PASSWORD=${DB_PASSWORD}
|
|
||||||
volumes:
|
|
||||||
- ${CONFS_DIR}/database/init.sql:/docker-entrypoint-initdb.d/init.sql
|
|
||||||
- ${LOCAL_FILES_DIR}/mysql/data/:/var/lib/mysql
|
|
||||||
- ${LOCAL_FILES_DIR}/mysql/backup/:/backup/
|
|
||||||
networks:
|
|
||||||
- dev
|
|
||||||
|
|
||||||
backend:
|
|
||||||
entrypoint: /script/backend-entrypoint.sh
|
|
||||||
restart:
|
|
||||||
always
|
|
||||||
build:
|
|
||||||
context: .
|
context: .
|
||||||
dockerfile: docker/dockerfiles/back
|
|
||||||
args:
|
args:
|
||||||
SOURCE_DIR: ./src/back
|
SOURCE_DIR: ./src/back
|
||||||
PROJECT_DIR: .
|
PROJECT_DIR: .
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
services:
|
||||||
|
|
||||||
|
|
||||||
|
redis:
|
||||||
|
container_name: ${COMPOSE_PROJECT_NAME}-redis
|
||||||
|
image: redis:alpine # Используем легковесный образ Redis
|
||||||
|
<<: *all-base
|
||||||
|
|
||||||
|
|
||||||
|
backend:
|
||||||
|
entrypoint: /script/backend-entrypoint.sh
|
||||||
|
container_name: ${COMPOSE_PROJECT_NAME}-backend
|
||||||
|
<<: [*all-base,*backend-base]
|
||||||
|
|
||||||
|
|
||||||
ports:
|
ports:
|
||||||
- "${BACKEND_EXTERNAL_PORT}:${BACKEND_INTERNAL_PORT}"
|
- "${BACKEND_EXTERNAL_PORT}:${BACKEND_INTERNAL_PORT}"
|
||||||
|
|
||||||
env_file:
|
|
||||||
- .env
|
|
||||||
networks:
|
|
||||||
- dev
|
|
||||||
depends_on:
|
|
||||||
- db
|
|
||||||
- redis
|
|
||||||
volumes:
|
volumes:
|
||||||
- /back/.venv/
|
|
||||||
- ./src/back:/back
|
- ./src/back:/back
|
||||||
|
- /back/.venv
|
||||||
|
- ${LOCAL_FILES_DIR}/django/media:/back/media/
|
||||||
|
- ${LOCAL_FILES_DIR}/django/static:/back/static/
|
||||||
|
- ${LOCAL_FILES_DIR}/front:/app/front/build
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# command: ["tail", "-f", "/dev/null"]
|
# command: ["tail", "-f", "/dev/null"]
|
||||||
nginx:
|
nginx:
|
||||||
|
container_name: ${COMPOSE_PROJECT_NAME}-nginx
|
||||||
image: nginx:latest
|
image: nginx:latest
|
||||||
|
<<: *all-base
|
||||||
ports:
|
ports:
|
||||||
- "${NGINX_EXTERNAL_PORT}:${NGINX_INTERNAL_PORT}" # Открываем порт 80 для внешнего доступа
|
- "${NGINX_EXTERNAL_PORT}:${NGINX_INTERNAL_PORT}" # Открываем порт 80 для внешнего доступа
|
||||||
volumes:
|
volumes:
|
||||||
@@ -90,8 +65,7 @@ services:
|
|||||||
- ${LOCAL_FILES_DIR}/nginx/conf/nginx.dev.conf:/etc/nginx/nginx.conf # Подключаем конфигурацию Nginx
|
- ${LOCAL_FILES_DIR}/nginx/conf/nginx.dev.conf:/etc/nginx/nginx.conf # Подключаем конфигурацию Nginx
|
||||||
depends_on:
|
depends_on:
|
||||||
- backend
|
- backend
|
||||||
networks:
|
|
||||||
- dev
|
|
||||||
volumes:
|
volumes:
|
||||||
mysql_data:
|
mysql_data:
|
||||||
|
|
||||||
@@ -0,0 +1,80 @@
|
|||||||
|
services:
|
||||||
|
db:
|
||||||
|
image: mysql:latest
|
||||||
|
|
||||||
|
environment:
|
||||||
|
- MYSQL_DATABASE=${DB_NAME}
|
||||||
|
- MYSQL_PASSWORD=${DB_PASSWORD}
|
||||||
|
- MYSQL_ROOT_PASSWORD=${DB_PASSWORD}
|
||||||
|
volumes:
|
||||||
|
- ${CONFS_DIR}/database/init.sql:/docker-entrypoint-initdb.d/init.sql
|
||||||
|
- ${LOCAL_FILES_DIR}/mysql/data/:/var/lib/mysql
|
||||||
|
- ${LOCAL_FILES_DIR}/mysql/backup/:/backup/
|
||||||
|
restart:
|
||||||
|
${DOCKER_RESTART}
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
# Все наши сервисы для удобства будут в одной сети
|
||||||
|
networks:
|
||||||
|
- dev
|
||||||
|
ports:
|
||||||
|
- "${DB_PORT}:${DB_PORT}"
|
||||||
|
|
||||||
|
backend:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: docker/dockerfiles/back_dev
|
||||||
|
args:
|
||||||
|
SOURCE_DIR: ./src/back
|
||||||
|
PROJECT_DIR: .
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
|
- redis
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ports:
|
||||||
|
- "${BACKEND_EXTERNAL_PORT}:${BACKEND_INTERNAL_PORT}"
|
||||||
|
frontend:
|
||||||
|
|
||||||
|
|
||||||
|
restart:
|
||||||
|
${DOCKER_RESTART}
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
# Все наши сервисы для удобства будут в одной сети
|
||||||
|
networks:
|
||||||
|
- dev
|
||||||
|
|
||||||
|
build:
|
||||||
|
args:
|
||||||
|
SOURCE_DIR: ./src/front
|
||||||
|
context: .
|
||||||
|
dockerfile: docker/dockerfiles/front_dev
|
||||||
|
volumes:
|
||||||
|
|
||||||
|
- ./src/front/:/app
|
||||||
|
- /app/node_modules
|
||||||
|
ports:
|
||||||
|
- "${FRONTEND_EXTERNAL_PORT}:${FRONTEND_INTERNAL_PORT}"
|
||||||
|
environment:
|
||||||
|
|
||||||
|
- CHOKIDAR_USEPOLLING=true
|
||||||
|
|
||||||
|
|
||||||
|
redis:
|
||||||
|
ports:
|
||||||
|
- "${REDIS_PORT}:${REDIS_PORT}" # Открываем порт Redis для внешнего доступа (по желанию)
|
||||||
|
|
||||||
|
nginx:
|
||||||
|
volumes:
|
||||||
|
- ${LOCAL_FILES_DIR}/nginx/conf/nginx.dev.conf:/etc/nginx/nginx.conf
|
||||||
|
- ${LOCAL_FILES_DIR}/nginx/log/:/var/log/nginx/
|
||||||
|
# - ${LOCAL_FILES_DIR}/django/media:/mnt/resource/media
|
||||||
|
# - ${LOCAL_FILES_DIR}/asgi/tmp/:/tmp/
|
||||||
|
# Важно не забыть прокинуть статику и медиафайлы основного приложения
|
||||||
|
# - ${LOCAL_FILES_DIR}/asgi/static:/mnt/resource/static
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
services:
|
||||||
|
backend:
|
||||||
|
image: ${COMPOSE_PROJECT_NAME}-all
|
||||||
|
build:
|
||||||
|
args:
|
||||||
|
|
||||||
|
SOURCE_DIRFRONT: ./src/front
|
||||||
|
dockerfile: docker/dockerfiles/back_front_prod
|
||||||
|
|
||||||
|
nginx:
|
||||||
|
volumes:
|
||||||
|
- ${LOCAL_FILES_DIR}/nginx/conf/nginx.prod.conf:/etc/nginx/nginx.conf
|
||||||
|
- ${LOCAL_FILES_DIR}/nginx/log/:/var/log/nginx/
|
||||||
|
- ${LOCAL_FILES_DIR}/django/media:/mnt/resource/media
|
||||||
|
# - ${LOCAL_FILES_DIR}/django/tmp/:/tmp/
|
||||||
|
# Важно не забыть прокинуть статику и медиафайлы основного приложения
|
||||||
|
- ${LOCAL_FILES_DIR}/django/static:/mnt/resource/static
|
||||||
|
- ${LOCAL_FILES_DIR}/front/:/mnt/resource/front/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -8,7 +8,6 @@ ENV SOURCE_DIR=${SOURCE_DIR}
|
|||||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
libmariadb-dev-compat \
|
libmariadb-dev-compat \
|
||||||
build-essential \
|
build-essential \
|
||||||
dos2unix \
|
|
||||||
pkg-config && \
|
pkg-config && \
|
||||||
apt-get clean && \
|
apt-get clean && \
|
||||||
rm -rf /var/lib/apt/lists/*
|
rm -rf /var/lib/apt/lists/*
|
||||||
@@ -18,11 +17,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|||||||
COPY ${SOURCE_DIR}/pyproject.toml ${SOURCE_DIR}/README.md ./
|
COPY ${SOURCE_DIR}/pyproject.toml ${SOURCE_DIR}/README.md ./
|
||||||
COPY docker/entries/backend-entrypoint.sh /script/backend-entrypoint.sh
|
COPY docker/entries/backend-entrypoint.sh /script/backend-entrypoint.sh
|
||||||
|
|
||||||
RUN dos2unix /script/backend-entrypoint.sh && chmod 777 /script/backend-entrypoint.sh && \
|
RUN chmod 777 /script/backend-entrypoint.sh && \
|
||||||
python -m pip install --no-cache-dir poetry \
|
python -m pip install --no-cache-dir poetry \
|
||||||
&& poetry config virtualenvs.in-project true \
|
&& poetry config virtualenvs.in-project true \
|
||||||
&& poetry install --no-interaction --no-ansi
|
&& poetry install --no-interaction --no-ansi
|
||||||
# --without dev,test
|
|
||||||
# Устанавливаем зависимости
|
# Устанавливаем зависимости
|
||||||
# RUN python -m venv env
|
# RUN python -m venv env
|
||||||
# RUN pip install --no-cache-dir -r r.txt
|
# RUN pip install --no-cache-dir -r r.txt
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
FROM node:lts-alpine as bstage
|
||||||
|
|
||||||
|
ARG SOURCE_DIRFRONT
|
||||||
|
ENV SOURCE_DIR=${SOURCE_DIRFRONT}
|
||||||
|
# Устанавливаем рабочую директорию
|
||||||
|
|
||||||
|
# Копируем package.json и package-lock.json
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY ${SOURCE_DIRFRONT}/*.json ./
|
||||||
|
COPY ${SOURCE_DIRFRONT}/*.cjs ./
|
||||||
|
COPY ${SOURCE_DIRFRONT}/.* ./
|
||||||
|
|
||||||
|
COPY ${SOURCE_DIR}/*.js ./
|
||||||
|
RUN npm cache clean --force && npm install
|
||||||
|
|
||||||
|
COPY ${SOURCE_DIRFRONT} ./
|
||||||
|
|
||||||
|
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
|
||||||
|
FROM python:3.10.13-slim AS builderstage
|
||||||
|
|
||||||
|
WORKDIR /back
|
||||||
|
|
||||||
|
ARG SOURCE_DIR
|
||||||
|
ENV SOURCE_DIR=${SOURCE_DIR}
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends rsync \
|
||||||
|
libmariadb-dev-compat \
|
||||||
|
build-essential \
|
||||||
|
pkg-config && \
|
||||||
|
apt-get clean && \
|
||||||
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
COPY --from=bstage /app/dist /app/dist
|
||||||
|
# Копируем файлы зависимостей в контейнер
|
||||||
|
COPY ${SOURCE_DIR}/pyproject.toml ${SOURCE_DIR}/README.md ./
|
||||||
|
COPY docker/entries/backend-entrypoint.sh /script/backend-entrypoint.sh
|
||||||
|
|
||||||
|
RUN chmod 777 /script/backend-entrypoint.sh && \
|
||||||
|
python -m pip install --no-cache-dir poetry \
|
||||||
|
&& poetry config virtualenvs.in-project true \
|
||||||
|
&& poetry install --no-interaction --no-ansi
|
||||||
|
##--without dev,test
|
||||||
|
|
||||||
|
EXPOSE 8000
|
||||||
File renamed without changes.
@@ -5,17 +5,17 @@ do
|
|||||||
echo "Жду запуска сервера..."
|
echo "Жду запуска сервера..."
|
||||||
done
|
done
|
||||||
|
|
||||||
until poetry run python manage.py makemigrations
|
# until poetry run python manage.py makemigrations
|
||||||
do
|
# do
|
||||||
echo "Создаю миграции..."
|
# echo "Создаю миграции..."
|
||||||
done
|
# done
|
||||||
|
|
||||||
|
|
||||||
until poetry run python manage.py migrate
|
# until poetry run python manage.py migrate
|
||||||
do
|
# do
|
||||||
echo "Применяю при необходимости..."
|
# echo "Применяю при необходимости..."
|
||||||
sleep 2
|
# sleep 2
|
||||||
done
|
# done
|
||||||
poetry run python manage.py collectstatic --noinput
|
poetry run python manage.py collectstatic --noinput
|
||||||
if [ "$PRODUCTION" == "False" ]; then
|
if [ "$PRODUCTION" == "False" ]; then
|
||||||
if [ "$AUTO_BACKEND" == "True" ]; then
|
if [ "$AUTO_BACKEND" == "True" ]; then
|
||||||
@@ -29,7 +29,7 @@ else
|
|||||||
# Фронт и бэк в одном
|
# Фронт и бэк в одном
|
||||||
|
|
||||||
|
|
||||||
mkdir -p /app/front/ && rsync -av --delete /app/dist/ /app/front/
|
mkdir -p /app/front/build && rsync -av --delete /app/dist/ /app/front/build
|
||||||
poetry run daphne -p 8000 -b 0.0.0.0 portal.asgi:application
|
poetry run daphne -p 8000 -b 0.0.0.0 portal.asgi:application
|
||||||
# python -m uvicorn config.asgi:application --bind 0.0.0.0:8000 --worker-class uvicorn.workers.UvicornWorker --timeout 180 --workers $WORKERS_COUNT --log-level debug --access-logfile - --error-logfile - --pid /tmp/gunicorn.pid'
|
# python -m uvicorn config.asgi:application --bind 0.0.0.0:8000 --worker-class uvicorn.workers.UvicornWorker --timeout 180 --workers $WORKERS_COUNT --log-level debug --access-logfile - --error-logfile - --pid /tmp/gunicorn.pid'
|
||||||
# celery --app speaker worker --loglevel=$CELERY_LOGLEVEL --concurrency 1 -E &
|
# celery --app speaker worker --loglevel=$CELERY_LOGLEVEL --concurrency 1 -E &
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
env/
|
env/
|
||||||
/__pycache__/
|
/__pycache__/
|
||||||
/*/__pycache__/
|
/**/__pycache__/
|
||||||
/*/migrations/
|
|
||||||
/front/node_modules/
|
/front/node_modules/
|
||||||
*.sqlite3
|
*.sqlite3
|
||||||
/media/
|
/media/
|
||||||
|
|||||||
@@ -0,0 +1,86 @@
|
|||||||
|
# Generated by Django 4.2.3 on 2025-01-31 09:42
|
||||||
|
|
||||||
|
import ckeditor_uploader.fields
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('userauth', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='FactSize',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('factsize', models.IntegerField(verbose_name='Фактическая численность')),
|
||||||
|
('date_created', models.DateField(verbose_name='Дата создания')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Фактическая численность',
|
||||||
|
'verbose_name_plural': 'Фактическая численность',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='StateSize',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('statesize', models.IntegerField(verbose_name='Штатная численность')),
|
||||||
|
('date_created', models.DateField(verbose_name='Дата создания')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Штатная численность',
|
||||||
|
'verbose_name_plural': 'Штатная численность',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Vacancies',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('name', models.TextField(verbose_name='Наименование')),
|
||||||
|
('functional', ckeditor_uploader.fields.RichTextUploadingField(blank=True, null=True, verbose_name='Функционал и должностные обязанности')),
|
||||||
|
('requirements', ckeditor_uploader.fields.RichTextUploadingField(blank=True, null=True, verbose_name='Базовые требования к соискателю')),
|
||||||
|
('published', models.BooleanField(default=False, verbose_name='Опубликована')),
|
||||||
|
('department', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='userauth.dictdepartment', verbose_name='Отдел')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Вакансия ',
|
||||||
|
'verbose_name_plural': 'Вакансии',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='ResponseVacancy',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('fio', models.CharField(max_length=300, verbose_name='ФИО')),
|
||||||
|
('cdate', models.DateTimeField(auto_now_add=True, verbose_name='Дата создания')),
|
||||||
|
('text', models.TextField(null=True, verbose_name='Сообщение')),
|
||||||
|
('email', models.CharField(max_length=300, null=True, verbose_name='Почта')),
|
||||||
|
('tel', models.CharField(max_length=300, null=True, verbose_name='Номер телефона')),
|
||||||
|
('file', models.FileField(null=True, upload_to='response/%Y/%m/%d', verbose_name='Файл резюме')),
|
||||||
|
('vacancy', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='get_vacancies', to='about_inspection.vacancies', verbose_name='Вакансия')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Отклик на вакансию',
|
||||||
|
'verbose_name_plural': 'Отклики на вакансию',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='InspectionDirections',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('direction_title', models.CharField(max_length=255, verbose_name='Направление деятельности')),
|
||||||
|
('icon_name', models.CharField(blank=True, default='mdi-sign-direction', max_length=100, verbose_name='Название иконки')),
|
||||||
|
('department', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='department_directions', to='userauth.dictdepartment', verbose_name='Отдел')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Направление деятельности ',
|
||||||
|
'verbose_name_plural': 'Направления деятельности',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
||||||
Whitespace-only changes.
@@ -54,7 +54,7 @@ class CustomAuth(ModelBackend):
|
|||||||
status_code=0
|
status_code=0
|
||||||
|
|
||||||
# !ТУт стучим в AD, потом к Алексею
|
# !ТУт стучим в AD, потом к Алексею
|
||||||
if myDEBUG!=True:
|
if myDEBUG!="True":
|
||||||
|
|
||||||
resp= requests.post('http://10.252.44.13:8005/getAD', json.dumps({'user': username, 'password':password, 'usercheck': username}))
|
resp= requests.post('http://10.252.44.13:8005/getAD', json.dumps({'user': username, 'password':password, 'usercheck': username}))
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
# Generated by Django 4.2.3 on 2025-01-31 09:40
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('auth', '0012_alter_user_first_name_max_length'),
|
||||||
|
('userauth', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='User',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')),
|
||||||
|
('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')),
|
||||||
|
('password', models.CharField(blank=True, max_length=128, null=True, verbose_name='Пароль')),
|
||||||
|
('username', models.CharField(db_index=True, max_length=255, unique=True, verbose_name='Логин')),
|
||||||
|
('is_active', models.BooleanField(default=True, verbose_name='Активность')),
|
||||||
|
('is_staff', models.BooleanField(default=False, verbose_name='Доступ в Админку')),
|
||||||
|
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||||
|
('updated_at', models.DateTimeField(auto_now=True)),
|
||||||
|
('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.group', verbose_name='groups')),
|
||||||
|
('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='userauth.dictemployee', verbose_name='Сотрудник')),
|
||||||
|
('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.permission', verbose_name='user permissions')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Зарегистрированный участник',
|
||||||
|
'verbose_name_plural': 'Зарегистрированные участники',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
||||||
Whitespace-only changes.
@@ -0,0 +1,97 @@
|
|||||||
|
# Generated by Django 4.2.3 on 2025-01-31 09:42
|
||||||
|
|
||||||
|
import ckeditor_uploader.fields
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('userauth', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Calendar',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('cl_name', models.CharField(max_length=300, verbose_name='Название')),
|
||||||
|
('cl_color', models.CharField(max_length=300, null=True, verbose_name='Цвет')),
|
||||||
|
('cl_descr', models.CharField(max_length=300, verbose_name='Описание')),
|
||||||
|
('author', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='userauth.dictemployee', verbose_name='Автор календаря')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Календарь',
|
||||||
|
'verbose_name_plural': 'Календари',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Event',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('name', models.CharField(blank=True, max_length=300, null=True, verbose_name='Название')),
|
||||||
|
('date_start', models.DateTimeField(blank=True, null=True, verbose_name='Дата начала события')),
|
||||||
|
('date_end', models.DateTimeField(blank=True, null=True, verbose_name='Дата окончания события')),
|
||||||
|
('period', models.JSONField(blank=True, null=True, verbose_name='Периодичность события')),
|
||||||
|
('description', ckeditor_uploader.fields.RichTextUploadingField(blank=True, null=True, verbose_name='Описание события')),
|
||||||
|
('allday', models.BooleanField(default=False, verbose_name='Событие на целый день')),
|
||||||
|
('calendar', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='get_calendar_event', to='calendar_of_events.calendar', verbose_name='Календарь')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Событие календаря',
|
||||||
|
'verbose_name_plural': 'События календаря',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='ExclusionDates',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('exclusiondate', models.DateField(blank=True, null=True, verbose_name='Дата-исключение')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Дата-исключение',
|
||||||
|
'verbose_name_plural': 'Даты-исключение',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='EventParticipant',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('event', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='get_event_participant', to='calendar_of_events.event', verbose_name='Календарь')),
|
||||||
|
('participant', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='get_user_event', to='userauth.dictemployee', verbose_name='Участник')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Участники события',
|
||||||
|
'verbose_name_plural': 'Участники событий',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='EventFiles',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('file', models.FileField(upload_to='calendar/%Y/%m/%d')),
|
||||||
|
('event', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='get_calendar_event_files', to='calendar_of_events.event', verbose_name='Событие')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Файлы календаря',
|
||||||
|
'verbose_name_plural': 'Файлы календаря',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='CalendarParticipants',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('editor', models.BooleanField(default=False, verbose_name='Редактирование')),
|
||||||
|
('calendar', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='get_participants', to='calendar_of_events.calendar', verbose_name='Календарь')),
|
||||||
|
('participant_calendar', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='userauth.dictemployee', verbose_name='Участник')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Участники календаря',
|
||||||
|
'verbose_name_plural': 'Участники календаря',
|
||||||
|
'unique_together': {('participant_calendar', 'calendar')},
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
# Generated by Django 5.2.1 on 2025-05-19 05:20
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("calendar_of_events", "0001_initial"),
|
||||||
|
("userauth", "0001_initial"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="calendar",
|
||||||
|
name="author",
|
||||||
|
field=models.ForeignKey(
|
||||||
|
null=True,
|
||||||
|
on_delete=django.db.models.deletion.PROTECT,
|
||||||
|
to="userauth.dictemployee",
|
||||||
|
verbose_name="Автор календаря",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
||||||
Whitespace-only changes.
@@ -94,7 +94,8 @@ class Event(models.Model):
|
|||||||
return str(self.name)
|
return str(self.name)
|
||||||
|
|
||||||
class EventFiles(models.Model):
|
class EventFiles(models.Model):
|
||||||
event = models.ForeignKey(Event, on_delete=models.PROTECT, related_name='get_calendar_event_files',blank=True,null=True, verbose_name='Событие')
|
# event = models.ForeignKey(Event, on_delete=models.PROTECT, related_name='get_calendar_event_files',blank=True,null=True, verbose_name='Событие')
|
||||||
|
event = models.ForeignKey(Event, on_delete=models.CASCADE, related_name='get_calendar_event_files',blank=True,null=True, verbose_name='Событие')
|
||||||
file = models.FileField(upload_to='calendar/%Y/%m/%d')
|
file = models.FileField(upload_to='calendar/%Y/%m/%d')
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|||||||
@@ -20,11 +20,10 @@ class ExclusionDatesAPIView(APIView):
|
|||||||
year = self.request.query_params.get('year', datetime.now().year)
|
year = self.request.query_params.get('year', datetime.now().year)
|
||||||
exclude = ExclusionDates.objects.filter(exclusiondate__year=year)
|
exclude = ExclusionDates.objects.filter(exclusiondate__year=year)
|
||||||
months = {}
|
months = {}
|
||||||
for i in range(1,12):
|
for i in range(1,13):
|
||||||
months[i] = exclude.filter(exclusiondate__month=i).values_list("exclusiondate", flat=True)
|
months[i] = exclude.filter(exclusiondate__month=i).values_list("exclusiondate", flat=True)
|
||||||
return Response({year:months})
|
return Response({year:months})
|
||||||
|
|
||||||
|
|
||||||
class MyCalendars(APIView):
|
class MyCalendars(APIView):
|
||||||
|
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
@@ -105,6 +104,8 @@ class MyEvents(APIView):
|
|||||||
if request.query_params.get("id") is not None:
|
if request.query_params.get("id") is not None:
|
||||||
event = Event.objects.get(id = request.query_params.get("id"))
|
event = Event.objects.get(id = request.query_params.get("id"))
|
||||||
resp['event']=EventSerializerIdRequest(event).data
|
resp['event']=EventSerializerIdRequest(event).data
|
||||||
|
# events = Event.objects.filter(calendar__id = request.query_params.get("id"))
|
||||||
|
# resp['events'] = EventSerializerIdRequest(events, many=True).data
|
||||||
return Response(resp)
|
return Response(resp)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,157 @@
|
|||||||
|
# Generated by Django 4.2.3 on 2025-01-31 09:42
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Committee1',
|
||||||
|
fields=[
|
||||||
|
('id', models.PositiveIntegerField(primary_key=True, serialize=False)),
|
||||||
|
('name', models.CharField(blank=True, db_comment='═ршьхэютрэшх ъюьшёёшш', max_length=1000, null=True, verbose_name='Название')),
|
||||||
|
('num_start', models.CharField(blank=True, db_comment='═юьхЁ яЁшърчр ю ёючфрэшш ъюьшёёшш', max_length=100, null=True)),
|
||||||
|
('date_start', models.DateField(blank=True, db_comment='─рЄр яЁшърчр ю ёючфрэшш ъюьшёёшш', null=True)),
|
||||||
|
('num_finish', models.CharField(blank=True, db_comment='═юьхЁ яЁшърчр юс єяЁрчфэхэшш ъюьшёёшш', max_length=100, null=True)),
|
||||||
|
('date_finish', models.DateField(blank=True, db_comment='─рЄр єяЁрчфэхэш\xa0 ъюьшёёшш', null=True)),
|
||||||
|
('comment', models.CharField(blank=True, db_comment='╧Ёшьхўрэшх', max_length=4000, null=True)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Комиссия',
|
||||||
|
'verbose_name_plural': 'Комиссии',
|
||||||
|
'db_table': 'committee1',
|
||||||
|
'db_table_comment': '╤яшёюъ ъюьшёёшщ',
|
||||||
|
'managed': False,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Committee1Files',
|
||||||
|
fields=[
|
||||||
|
('id', models.PositiveIntegerField(primary_key=True, serialize=False)),
|
||||||
|
('file_name', models.FileField(blank=True, null=True, upload_to='comitee_files')),
|
||||||
|
('is_actual', models.IntegerField(db_comment='╧Ёшчэръ ръЄєры№эюёЄш Їрщыр', verbose_name='Актуальность')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Файл',
|
||||||
|
'verbose_name_plural': 'Файлы',
|
||||||
|
'db_table': 'committee1_files',
|
||||||
|
'managed': False,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Committee2',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Участник',
|
||||||
|
'verbose_name_plural': 'Участники',
|
||||||
|
'db_table': 'committee2',
|
||||||
|
'db_table_comment': '╤юёЄрт ъюьшёёшщ',
|
||||||
|
'managed': False,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='DictCommitteeExpert',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('fio', models.CharField(blank=True, db_comment='╘╚╬ ¤ъёяхЁЄр', max_length=250, null=True)),
|
||||||
|
('tel', models.CharField(blank=True, db_comment='╥хыхЇюэ', max_length=100, null=True)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'db_table': 'dict_committee_expert',
|
||||||
|
'db_table_comment': '╤яЁртюўэшъ эхчртшёшь√ї ¤ъёяхЁЄют',
|
||||||
|
'managed': False,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='DictCommitteeOrderAddon',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('number', models.CharField(db_comment='═юьхЁ шчьхэхэшщ ъ яЁшърчє ю ъюьшёёшш', max_length=100)),
|
||||||
|
('date', models.DateField(db_comment='─рЄр шчьхэхэшщ т яЁшърч ю ъюьшёёшш')),
|
||||||
|
('name', models.CharField(blank=True, db_comment='═ршьхэютрэшх шчьхэхэшщ ъ яЁшърчє ю ъюьшёёшш', max_length=1024, null=True)),
|
||||||
|
('text', models.TextField(blank=True, db_comment='╥хъёЄ шчьхэхэшщ т яЁшърч ю ъюьшёёшш', null=True)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'db_table': 'dict_committee_order_addon',
|
||||||
|
'db_table_comment': '╥рсышЎр фюяюыэхэшщ ъ яЁшърчє ю ъюьшёёшш',
|
||||||
|
'managed': False,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='DictCommitteePosition',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('name', models.CharField(blank=True, db_comment='эршьхэютрэшх фюцэюёЄш т ъюьшёёшш', max_length=100, null=True)),
|
||||||
|
('name_short', models.CharField(blank=True, db_comment='ъЁрЄъюх эршьхэютрэшх фюцэюёЄш т ъюьшёёшш', max_length=100, null=True)),
|
||||||
|
('ord', models.IntegerField(blank=True, db_comment='╧юЁ\xa0фюъ ёюЁЄшЁютъш', null=True)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'db_table': 'dict_committee_position',
|
||||||
|
'db_table_comment': '╤яЁртюўэшъ фюыцэюёЄхщ ъюьшёёшщ',
|
||||||
|
'managed': False,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='DictCommitteeType',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('name', models.CharField(blank=True, db_comment='═ршьхэютрэшх тшфр ъюьшёёшш', max_length=100, null=True)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'db_table': 'dict_committee_type',
|
||||||
|
'db_table_comment': '╤яЁртюўэшъ тшфют ъюьшёёшщ',
|
||||||
|
'managed': False,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='OrderResponsibility',
|
||||||
|
fields=[
|
||||||
|
('id', models.PositiveIntegerField(db_comment='╥рсхы№э√щ эюьхЁ', primary_key=True, serialize=False)),
|
||||||
|
('number', models.CharField(db_comment='═юьхЁ яЁшърчр', max_length=50)),
|
||||||
|
('date', models.DateField(db_comment='─рЄр яЁшърчр')),
|
||||||
|
('name', models.CharField(db_comment='═рчтрэшх яЁшърчр', max_length=1024)),
|
||||||
|
('sphere_of_responsibility', models.CharField(db_comment='╤ЇхЁр юЄтхЄёЄтхээюёЄш ёюЄЁєфэшъют, эрчэрўрхьр\xa0 фрээ√ь яЁшърчюь', max_length=1024)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Cфера ответственности',
|
||||||
|
'verbose_name_plural': 'Сферы ответстсвенности',
|
||||||
|
'db_table': 'order_responsibility',
|
||||||
|
'db_table_comment': '╥рсышЎр яЁшърчют ю эрчэрўхэшш юЄтхЄёЄтхээ√ї ёюЄЁєфэшъют',
|
||||||
|
'managed': False,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='OrderResponsibilityEmployee',
|
||||||
|
fields=[
|
||||||
|
('id', models.PositiveIntegerField(db_comment='╥рсхы№э√щ эюьхЁ', primary_key=True, serialize=False)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Ответственный сотрудник',
|
||||||
|
'verbose_name_plural': 'Ответственные сотрудники',
|
||||||
|
'db_table': 'order_responsibility_employee',
|
||||||
|
'managed': False,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='OrderResponsibilityFiles',
|
||||||
|
fields=[
|
||||||
|
('id', models.PositiveIntegerField(db_comment='╥рсхы№э√щ эюьхЁ', primary_key=True, serialize=False)),
|
||||||
|
('file_name', models.FileField(blank=True, null=True, upload_to='resp_files')),
|
||||||
|
('is_actual', models.IntegerField(db_comment='╧Ёшчэръ ръЄєры№эюёЄш Їрщыр')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Файл сферы ответственности',
|
||||||
|
'verbose_name_plural': 'Файлы сферы ответственности',
|
||||||
|
'db_table': 'order_responsibility_files',
|
||||||
|
'managed': False,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
||||||
Whitespace-only changes.
@@ -0,0 +1,69 @@
|
|||||||
|
# Generated by Django 4.2.3 on 2025-01-31 09:42
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='BasePosition',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('name', models.CharField(blank=True, db_index=True, max_length=150, verbose_name='Название')),
|
||||||
|
('order', models.IntegerField(blank=True, null=True, verbose_name='Сортировка')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Справочник - Статус сотрудников',
|
||||||
|
'verbose_name_plural': 'Справочник - Статус сотрудников',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='GeneralVacation',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('login', models.CharField(blank=True, max_length=100, null=True, verbose_name='Логин')),
|
||||||
|
('planned_date', models.DateField(verbose_name='Запланированная дата')),
|
||||||
|
('count_days', models.IntegerField(blank=True, default=0, verbose_name='Кол-во дней')),
|
||||||
|
('type_of_vacation', models.CharField(choices=[('os', 'Осн'), ('nd', 'Доп н/д'), ('vl', 'Доп в/л')], max_length=300, verbose_name='Тип отпуска')),
|
||||||
|
('start_work_period', models.DateField(verbose_name='Начало рабочего периода')),
|
||||||
|
('end_work_period', models.DateField(blank=True, null=True, verbose_name='Конец рабочего периода')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'График отпусков',
|
||||||
|
'verbose_name_plural': 'График отпусков',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='PlanCalendar',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('name', models.CharField(blank=True, db_index=True, max_length=500, verbose_name='Название')),
|
||||||
|
('start_work_period', models.DateField(verbose_name='Начало рабочего периода')),
|
||||||
|
('end_work_period', models.DateField(blank=True, null=True, verbose_name='Конец рабочего периода')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'План-график',
|
||||||
|
'verbose_name_plural': 'План-график',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='DailyRoundUp',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('todaysDate', models.DateField(verbose_name='Начало рабочего периода')),
|
||||||
|
('user', models.CharField(max_length=100, verbose_name='Логин')),
|
||||||
|
('position', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='get_position', to='general_vacation.baseposition', verbose_name='Позиция')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Ежедневный обход',
|
||||||
|
'verbose_name_plural': 'Ежедневный обход',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
||||||
Whitespace-only changes.
@@ -0,0 +1,178 @@
|
|||||||
|
# Generated by Django 4.2.3 on 2025-01-31 09:42
|
||||||
|
|
||||||
|
import ckeditor_uploader.fields
|
||||||
|
import datetime
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
import django.utils.timezone
|
||||||
|
import navigation.models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('vote', '0001_initial'),
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='BaseSender',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('name', models.CharField(blank=True, db_index=True, max_length=150, verbose_name='Название')),
|
||||||
|
('img', models.ImageField(blank=True, null=True, upload_to='senderimage', verbose_name='Картинка')),
|
||||||
|
('order', models.IntegerField(blank=True, null=True, verbose_name='Порядок сортировки')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Карусель. Справочник - Статус новости',
|
||||||
|
'verbose_name_plural': 'Карусель. Справочник - Статусы новостей',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='BirthdayImage',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('img', models.ImageField(blank=True, null=True, upload_to='birthdayimage', verbose_name='Картинка')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Открытка. Изображение',
|
||||||
|
'verbose_name_plural': 'Открытки. Изображения',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='BirthdayText',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('text', models.TextField(max_length=260, null=True, verbose_name='Текст поздравления')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Открытка. Текст поздравления',
|
||||||
|
'verbose_name_plural': 'Открытки. Тексты поздравлений',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Gallery',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('img', models.ImageField(null=True, upload_to='newsgallery/%Y/%m/%d', verbose_name='Изображение')),
|
||||||
|
('cdate', models.DateTimeField(auto_now_add=True, null=True, verbose_name='Дата создания')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Новости. Изображения',
|
||||||
|
'verbose_name_plural': 'Новости. Изображения',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Links',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('name', models.CharField(db_index=True, max_length=255, verbose_name='Заголовок')),
|
||||||
|
('link', models.CharField(db_index=True, max_length=255, verbose_name='Ссылка')),
|
||||||
|
('imagecode', models.CharField(db_index=True, max_length=25, verbose_name='Иконка')),
|
||||||
|
('order', models.IntegerField(verbose_name='Порядок сортировки')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Ссылка. Внешний ресурс',
|
||||||
|
'verbose_name_plural': 'Ссылки. Внешние ресурсы',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='News',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('title', models.CharField(max_length=255, verbose_name='Заголовок')),
|
||||||
|
('text', ckeditor_uploader.fields.RichTextUploadingField(blank=True, null=True, verbose_name='Текст новости')),
|
||||||
|
('cdate', models.DateTimeField(default=datetime.datetime.now, verbose_name='Дата создания')),
|
||||||
|
('link', models.ImageField(default='newsimage/default.jpg', null=True, upload_to='newsimage/%Y/%m/%d', verbose_name='Изображение')),
|
||||||
|
('author', models.ForeignKey(editable=False, on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL, verbose_name='Автор')),
|
||||||
|
# ('vote', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='vote.vote')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Новости',
|
||||||
|
'verbose_name_plural': 'Новости',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Screensaver',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('img', models.ImageField(null=True, upload_to='screengallery/%Y/%m/%d', verbose_name='Изображение')),
|
||||||
|
('cdate', models.DateField(default=navigation.models.default_date, null=True, verbose_name='Дата начала периода')),
|
||||||
|
('enddate', models.DateField(default=navigation.models.default_date, null=True, verbose_name='Дата окончания периода')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Вход. Изображение',
|
||||||
|
'verbose_name_plural': 'Вход. Изображения',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='ScoreNews',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('score', models.BooleanField(default=None, null=True, verbose_name='Оценка лайк/дизлайк')),
|
||||||
|
('cdate', models.DateTimeField(auto_now_add=True, verbose_name='Дата создания')),
|
||||||
|
('author', models.ForeignKey(editable=False, on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL, verbose_name='Автор')),
|
||||||
|
('news', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='get_news', to='navigation.news', verbose_name='Новость')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Новости. Лайк',
|
||||||
|
'verbose_name_plural': 'Новости. Лайки',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='ScoreGallery',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('like', models.IntegerField(blank=True, default=0, verbose_name='Лайк')),
|
||||||
|
('cdate', models.DateTimeField(auto_now_add=True, verbose_name='Дата создания')),
|
||||||
|
('author', models.ForeignKey(editable=False, on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL, verbose_name='Автор')),
|
||||||
|
('gallery', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='get_gallery', to='navigation.gallery', verbose_name='Новость')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Галерея. Лайк',
|
||||||
|
'verbose_name_plural': 'Галерея. Лайки',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='gallery',
|
||||||
|
name='news',
|
||||||
|
field=models.ForeignKey(editable=False, on_delete=django.db.models.deletion.PROTECT, related_name='get_gallery_news', to='navigation.news', verbose_name='Новость'),
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='CommentNews',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('text', models.TextField(null=True, verbose_name='Сообщение')),
|
||||||
|
('cdate', models.DateTimeField(auto_now_add=True, verbose_name='Дата создания')),
|
||||||
|
('author', models.ForeignKey(editable=False, on_delete=django.db.models.deletion.PROTECT, related_name='get_user', to=settings.AUTH_USER_MODEL, verbose_name='Автор')),
|
||||||
|
('news', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='get_comment_news', to='navigation.news', verbose_name='Новость')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Новости. Комментарий пользователя',
|
||||||
|
'verbose_name_plural': 'Новости. Комментарии пользователей',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Carousels',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('title', models.CharField(blank=True, max_length=255, null=True, verbose_name='Заголовок')),
|
||||||
|
('text', models.TextField(blank=True, max_length=260, null=True, verbose_name='Сообщение')),
|
||||||
|
('cdate', models.DateTimeField(default=django.utils.timezone.now, verbose_name='Дата создания')),
|
||||||
|
('link', models.FileField(default='newsimage/default.jpg', null=True, upload_to='newsimage/%Y/%m/%d', verbose_name='Картинка')),
|
||||||
|
('published', models.BooleanField(default=True, verbose_name='Опубликован')),
|
||||||
|
('enddate', models.DateTimeField(default=navigation.models.default_end_date, verbose_name='Дата снятия с публикации')),
|
||||||
|
('order', models.IntegerField(blank=True, null=True, verbose_name='Порядок сортировки')),
|
||||||
|
('author', models.ForeignKey(editable=False, on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL, verbose_name='Автор новости')),
|
||||||
|
('sender', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='get_base_sender', to='navigation.basesender', verbose_name='Тематика')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Карусель',
|
||||||
|
'verbose_name_plural': 'Карусель',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
# Generated by Django 4.2.3 on 2025-01-31 09:48
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('vote', '0001_initial'),
|
||||||
|
('navigation', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
|
||||||
|
]
|
||||||
Whitespace-only changes.
Generated
+35
-4
@@ -1,4 +1,4 @@
|
|||||||
# This file is automatically @generated by Poetry 2.1.1 and should not be changed by hand.
|
# This file is automatically @generated by Poetry 2.1.3 and should not be changed by hand.
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anyio"
|
name = "anyio"
|
||||||
@@ -782,6 +782,25 @@ django = ">=4.2"
|
|||||||
[package.extras]
|
[package.extras]
|
||||||
tests = ["coverage"]
|
tests = ["coverage"]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "django-nested-admin"
|
||||||
|
version = "4.1.1"
|
||||||
|
description = "Django admin classes that allow for nested inlines"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.6"
|
||||||
|
groups = ["main"]
|
||||||
|
files = [
|
||||||
|
{file = "django-nested-admin-4.1.1.tar.gz", hash = "sha256:645d63b38d579b034a65e0983f1f8cbb8824c75b4232f8d62a1583fa7a9f568f"},
|
||||||
|
{file = "django_nested_admin-4.1.1-py3-none-any.whl", hash = "sha256:7e72ab7a8ae4c91074f6f709ce38fdf54f9c5f78d19e68772e0f05b83090ec9f"},
|
||||||
|
]
|
||||||
|
|
||||||
|
[package.dependencies]
|
||||||
|
python-monkey-business = ">=1.0.0"
|
||||||
|
|
||||||
|
[package.extras]
|
||||||
|
dev = ["Pillow", "black", "dj-database-url", "django-selenosis", "flake8", "pytest", "pytest-cov", "pytest-django", "pytest-xdist", "selenium"]
|
||||||
|
test = ["Pillow", "dj-database-url", "django-selenosis", "pytest", "pytest-cov", "pytest-django", "pytest-xdist", "selenium"]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "django-templated-mail"
|
name = "django-templated-mail"
|
||||||
version = "1.1.1"
|
version = "1.1.1"
|
||||||
@@ -1953,6 +1972,18 @@ files = [
|
|||||||
[package.dependencies]
|
[package.dependencies]
|
||||||
six = ">=1.5"
|
six = ">=1.5"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "python-monkey-business"
|
||||||
|
version = "1.1.0"
|
||||||
|
description = "Utility functions for monkey-patching python code"
|
||||||
|
optional = false
|
||||||
|
python-versions = "*"
|
||||||
|
groups = ["main"]
|
||||||
|
files = [
|
||||||
|
{file = "python-monkey-business-1.1.0.tar.gz", hash = "sha256:8393839cc741415ed5ddc2bd58e2d4ce07f966a7d26b7aebff19dcec64818edc"},
|
||||||
|
{file = "python_monkey_business-1.1.0-py2.py3-none-any.whl", hash = "sha256:15b4f603c749ba9a7b4f1acd36af023a6c5ba0f7e591c945f8253f0ef44bf389"},
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "python3-openid"
|
name = "python3-openid"
|
||||||
version = "3.2.0"
|
version = "3.2.0"
|
||||||
@@ -2440,7 +2471,7 @@ files = [
|
|||||||
{file = "tomli-2.2.1-py3-none-any.whl", hash = "sha256:cb55c73c5f4408779d0cf3eef9f762b9c9f147a77de7b258bef0a5628adc85cc"},
|
{file = "tomli-2.2.1-py3-none-any.whl", hash = "sha256:cb55c73c5f4408779d0cf3eef9f762b9c9f147a77de7b258bef0a5628adc85cc"},
|
||||||
{file = "tomli-2.2.1.tar.gz", hash = "sha256:cd45e1dc79c835ce60f7404ec8119f2eb06d38b1deba146f07ced3bbc44505ff"},
|
{file = "tomli-2.2.1.tar.gz", hash = "sha256:cd45e1dc79c835ce60f7404ec8119f2eb06d38b1deba146f07ced3bbc44505ff"},
|
||||||
]
|
]
|
||||||
markers = {dev = "python_version < \"3.11\""}
|
markers = {dev = "python_version == \"3.10\""}
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tomlkit"
|
name = "tomlkit"
|
||||||
@@ -2533,7 +2564,7 @@ files = [
|
|||||||
{file = "typing_extensions-4.12.2-py3-none-any.whl", hash = "sha256:04e5ca0351e0f3f85c6853954072df659d0d13fac324d0072316b67d7794700d"},
|
{file = "typing_extensions-4.12.2-py3-none-any.whl", hash = "sha256:04e5ca0351e0f3f85c6853954072df659d0d13fac324d0072316b67d7794700d"},
|
||||||
{file = "typing_extensions-4.12.2.tar.gz", hash = "sha256:1a7ead55c7e559dd4dee8856e3a88b41225abfe1ce8df57b7c13915fe121ffb8"},
|
{file = "typing_extensions-4.12.2.tar.gz", hash = "sha256:1a7ead55c7e559dd4dee8856e3a88b41225abfe1ce8df57b7c13915fe121ffb8"},
|
||||||
]
|
]
|
||||||
markers = {dev = "python_version < \"3.11\""}
|
markers = {dev = "python_version == \"3.10\""}
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tzdata"
|
name = "tzdata"
|
||||||
@@ -2801,4 +2832,4 @@ cffi = ["cffi (>=1.11)"]
|
|||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "2.1"
|
lock-version = "2.1"
|
||||||
python-versions = ">=3.10,<4.0"
|
python-versions = ">=3.10,<4.0"
|
||||||
content-hash = "65ef1545146f8d3206ce3cc82678439adc693e29cc301e57ee058ef6c8db1c76"
|
content-hash = "ff5370663207ae83e479d05b7d081e68844cb3a78487dd822912e8d32acc07e6"
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
ENGINE=django.db.backends.mysql
|
|
||||||
DBNAME = accounting
|
|
||||||
USER =
|
|
||||||
PASSWORD=
|
|
||||||
HOST=127.0.0.1
|
|
||||||
PORT=3306
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
from datetime import timedelta
|
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
|
|
||||||
class Settings:
|
|
||||||
"""
|
|
||||||
Настройки подключений - потом перенести
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self) -> None:
|
|
||||||
"""
|
|
||||||
Настройки подключений - потом перенести
|
|
||||||
"""
|
|
||||||
self.secret_key = "V7bvDZMztr3EU8S9g1Dipw"
|
|
||||||
self.redis_hosts = [f"{str(os.getenv('REDIS'))}:{str(os.getenv('REDIS_PORT'))}"]
|
|
||||||
self.access_token_lifetime = timedelta(minutes=480)
|
|
||||||
|
|
||||||
self.refresh_token_lifetime = timedelta(days=1)
|
|
||||||
|
|
||||||
self.db = {
|
|
||||||
"default": {
|
|
||||||
"ENGINE": "django.db.backends.mysql",
|
|
||||||
"NAME": os.getenv("DB_NAME"), # Имя базы данных
|
|
||||||
"USER": os.getenv("DB_USER"), # Имя пользователя
|
|
||||||
"PASSWORD": os.getenv("DB_PASSWORD"), # Пароль
|
|
||||||
"HOST": os.getenv("DB_HOST"), # Хост
|
|
||||||
"PORT": os.getenv("DB_INTERNAL_PORT"), # Порт
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
def foo1(self) -> None:
|
|
||||||
"""
|
|
||||||
Настройки - потом перенести
|
|
||||||
"""
|
|
||||||
return None
|
|
||||||
|
|
||||||
def foo2(self) -> None:
|
|
||||||
"""
|
|
||||||
Настройки подключений - потом перенести
|
|
||||||
"""
|
|
||||||
return None
|
|
||||||
+23
-15
@@ -12,18 +12,17 @@ https://docs.djangoproject.com/en/4.2/ref/settings/
|
|||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import os
|
import os
|
||||||
from .ds import Settings
|
|
||||||
stngs = Settings()
|
|
||||||
CORS_ORIGIN_ALLOW_ALL=True
|
CORS_ORIGIN_ALLOW_ALL=True
|
||||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||||
|
|
||||||
LIST_PER_PAGE=25
|
LIST_PER_PAGE=25
|
||||||
SECRET_KEY=stngs.secret_key
|
SECRET_KEY="V7bvDZMztr3EU8S9g1Dipw"
|
||||||
|
|
||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
DEBUG = True
|
DEBUG = True
|
||||||
myDEBUG=True
|
myDEBUG=os.getenv("MYDEBUG")
|
||||||
|
|
||||||
SWAGGER_SETTINGS = {
|
SWAGGER_SETTINGS = {
|
||||||
'DEFAULT_INFO': 'import.path.to.urls.api_info',
|
'DEFAULT_INFO': 'import.path.to.urls.api_info',
|
||||||
@@ -38,17 +37,15 @@ SWAGGER_SETTINGS = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CSRF_TRUSTED_ORIGINS = [
|
|
||||||
'http://localhost',
|
|
||||||
'http://127.0.0.1',
|
ALLOWED_HOSTS = str(os.getenv('DJANGO_ALLOWED_HOSTS')).split(', ')
|
||||||
'http://yourdomain.com', # Add your production domain here
|
CSRF_TRUSTED_ORIGINS = str(os.getenv('DJANGO_CSRF_TRUSTED_ORIGINS')).split(', ')
|
||||||
]
|
|
||||||
ALLOWED_HOSTS = ["*","portal-t",'portal9966','localhost','0.0.0.0']
|
|
||||||
CHANNEL_LAYERS = {
|
CHANNEL_LAYERS = {
|
||||||
"default": {
|
"default": {
|
||||||
"BACKEND": "channels_redis.core.RedisChannelLayer",
|
"BACKEND": "channels_redis.core.RedisChannelLayer",
|
||||||
"CONFIG": {
|
"CONFIG": {
|
||||||
"hosts":stngs.redis_hosts,
|
"hosts":[f"{str(os.getenv('REDIS'))}:{str(os.getenv('REDIS_PORT'))}"]
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -58,6 +55,7 @@ CHANNEL_LAYERS = {
|
|||||||
|
|
||||||
INSTALLED_APPS = [
|
INSTALLED_APPS = [
|
||||||
'daphne',
|
'daphne',
|
||||||
|
'ckeditor',
|
||||||
'django.contrib.admin',
|
'django.contrib.admin',
|
||||||
'django.contrib.auth',
|
'django.contrib.auth',
|
||||||
'django.contrib.contenttypes',
|
'django.contrib.contenttypes',
|
||||||
@@ -73,7 +71,7 @@ INSTALLED_APPS = [
|
|||||||
'commeteresp',
|
'commeteresp',
|
||||||
'safety',
|
'safety',
|
||||||
'vote.apps.VoteConfig',
|
'vote.apps.VoteConfig',
|
||||||
|
'nested_admin',
|
||||||
# 'orgmanagment',
|
# 'orgmanagment',
|
||||||
'corsheaders',
|
'corsheaders',
|
||||||
'watcher.apps.WatcherConfig',
|
'watcher.apps.WatcherConfig',
|
||||||
@@ -141,7 +139,17 @@ ASGI_APPLICATION = "portal.asgi.application"
|
|||||||
# Database
|
# Database
|
||||||
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
|
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
|
||||||
|
|
||||||
DATABASES = stngs.db
|
DATABASES = {
|
||||||
|
"default": {
|
||||||
|
"ENGINE": "django.db.backends.mysql",
|
||||||
|
"NAME": os.getenv("DB_NAME"), # Имя базы данных
|
||||||
|
"USER": os.getenv("DB_USER"), # Имя пользователя
|
||||||
|
"PASSWORD": os.getenv("DB_PASSWORD"), # Пароль
|
||||||
|
"HOST": os.getenv("DB_HOST"), # Хост
|
||||||
|
"PORT": os.getenv("DB_INTERNAL_PORT"), # Порт
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Password validation
|
# Password validation
|
||||||
@@ -198,8 +206,8 @@ from datetime import timedelta
|
|||||||
|
|
||||||
|
|
||||||
SIMPLE_JWT = {
|
SIMPLE_JWT = {
|
||||||
"ACCESS_TOKEN_LIFETIME": stngs.access_token_lifetime,
|
"ACCESS_TOKEN_LIFETIME": timedelta(hours=4),
|
||||||
"REFRESH_TOKEN_LIFETIME": stngs.refresh_token_lifetime,
|
"REFRESH_TOKEN_LIFETIME": timedelta(days=1),
|
||||||
"ROTATE_REFRESH_TOKENS": False,
|
"ROTATE_REFRESH_TOKENS": False,
|
||||||
"BLACKLIST_AFTER_ROTATION": False,
|
"BLACKLIST_AFTER_ROTATION": False,
|
||||||
"UPDATE_LAST_LOGIN": False,
|
"UPDATE_LAST_LOGIN": False,
|
||||||
|
|||||||
@@ -109,7 +109,8 @@ dependencies = [
|
|||||||
"xlsxwriter (>=3.2.2,<4.0.0)",
|
"xlsxwriter (>=3.2.2,<4.0.0)",
|
||||||
"zipp (>=3.21.0,<4.0.0)",
|
"zipp (>=3.21.0,<4.0.0)",
|
||||||
"zope-interface (>=7.2,<8.0)",
|
"zope-interface (>=7.2,<8.0)",
|
||||||
"zstandard (>=0.23.0,<0.24.0)"
|
"zstandard (>=0.23.0,<0.24.0)",
|
||||||
|
"django-nested-admin (>=4.1.1,<5.0.0)"
|
||||||
]
|
]
|
||||||
|
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
|
|||||||
-102
@@ -1,102 +0,0 @@
|
|||||||
anyio
|
|
||||||
asgiref
|
|
||||||
async-timeout
|
|
||||||
attrs
|
|
||||||
autobahn
|
|
||||||
Automat
|
|
||||||
backports.tarfile
|
|
||||||
build==1.2.2.post1
|
|
||||||
CacheControl
|
|
||||||
certifi
|
|
||||||
cffi
|
|
||||||
channels
|
|
||||||
channels-redis
|
|
||||||
charset-normalizer
|
|
||||||
cleo
|
|
||||||
constantly
|
|
||||||
crashtest
|
|
||||||
cryptography
|
|
||||||
daphne
|
|
||||||
defusedxml
|
|
||||||
distlib
|
|
||||||
Django
|
|
||||||
django-ckeditor
|
|
||||||
django-ckeditor-5
|
|
||||||
django-cors-headers
|
|
||||||
django-filter
|
|
||||||
django-grappelli
|
|
||||||
django-js-asset
|
|
||||||
django-templated-mail
|
|
||||||
djangorestframework
|
|
||||||
djangorestframework-simplejwt
|
|
||||||
djoser
|
|
||||||
drf-yasg
|
|
||||||
dulwich
|
|
||||||
et-xmlfile
|
|
||||||
exceptiongroup
|
|
||||||
fastjsonschema
|
|
||||||
filelock
|
|
||||||
findpython
|
|
||||||
h11
|
|
||||||
httpcore
|
|
||||||
httpx
|
|
||||||
hyperlink
|
|
||||||
idna
|
|
||||||
importlib_metadata
|
|
||||||
incremental
|
|
||||||
inflection
|
|
||||||
installer
|
|
||||||
jaraco.classes
|
|
||||||
jaraco.context
|
|
||||||
jaraco.functools
|
|
||||||
jeepney
|
|
||||||
keyring
|
|
||||||
Markdown
|
|
||||||
more-itertools
|
|
||||||
msgpack
|
|
||||||
mysqlclient
|
|
||||||
numpy
|
|
||||||
oauthlib
|
|
||||||
openpyxl
|
|
||||||
packaging
|
|
||||||
pandas
|
|
||||||
pbs-installer
|
|
||||||
Pillow
|
|
||||||
pkginfo
|
|
||||||
platformdirs
|
|
||||||
pyasn1
|
|
||||||
pyasn1-modules
|
|
||||||
pycparser
|
|
||||||
pyOpenSSL
|
|
||||||
pyproject_hooks
|
|
||||||
python-dateutil
|
|
||||||
python3-openid
|
|
||||||
pytz
|
|
||||||
PyYAML
|
|
||||||
RapidFuzz
|
|
||||||
redis
|
|
||||||
requests
|
|
||||||
requests-oauthlib
|
|
||||||
requests-toolbelt
|
|
||||||
SecretStorage
|
|
||||||
service-identity
|
|
||||||
shellingham
|
|
||||||
six
|
|
||||||
sniffio
|
|
||||||
social-auth-app-django
|
|
||||||
social-auth-core
|
|
||||||
sqlparse
|
|
||||||
tomli
|
|
||||||
tomlkit
|
|
||||||
trove-classifiers
|
|
||||||
Twisted
|
|
||||||
txaio
|
|
||||||
typing_extensions
|
|
||||||
tzdata
|
|
||||||
uritemplate
|
|
||||||
urllib3
|
|
||||||
virtualenv
|
|
||||||
XlsxWriter
|
|
||||||
zipp
|
|
||||||
zope.interface
|
|
||||||
zstandard
|
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
# Generated by Django 4.2.3 on 2025-01-31 09:42
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('commeteresp', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='SafetyType',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('name', models.CharField(max_length=255, verbose_name='Название подраздела')),
|
||||||
|
('path', models.CharField(max_length=255, null=True, verbose_name='Путь')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Подраздел',
|
||||||
|
'verbose_name_plural': 'Подразделы',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='SafetyFile',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('name', models.CharField(max_length=255, verbose_name='Имя документа')),
|
||||||
|
('url', models.FileField(upload_to='safety', verbose_name='Путь до файла')),
|
||||||
|
('chapter', models.ForeignKey(null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='mainpage_file', to='safety.safetytype', verbose_name='Раздел')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Документ для главной',
|
||||||
|
'verbose_name_plural': 'Документы для главной',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Safety_Responsib',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('resp', models.ForeignKey(null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='resp_group', to='commeteresp.orderresponsibility', verbose_name='Раздел')),
|
||||||
|
('type', models.ForeignKey(null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='type_resp', to='safety.safetytype', verbose_name='Раздел')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Ответственность',
|
||||||
|
'verbose_name_plural': 'Ответственности',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Safety_Commitee',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('comm', models.ForeignKey(null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='comm_group', to='commeteresp.committee1', verbose_name='Раздел')),
|
||||||
|
('type', models.ForeignKey(null=True, on_delete=django.db.models.deletion.DO_NOTHING, related_name='type_comm', to='safety.safetytype', verbose_name='Раздел')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Комиссия',
|
||||||
|
'verbose_name_plural': 'Комиссии',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
||||||
Whitespace-only changes.
+39
-26
@@ -1,39 +1,52 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from .models import Test, TestAnswer, TestQuestion
|
from .models import Test, TestAnswer, TestQuestion, TestAttempt, DictEmployee, Testing, TestFile
|
||||||
|
import nested_admin
|
||||||
|
|
||||||
class TestAnswerInline(admin.StackedInline):
|
|
||||||
"""
|
|
||||||
Инлайн ответов
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
class TestAnswerInline(nested_admin.NestedStackedInline):
|
||||||
model = TestAnswer
|
model = TestAnswer
|
||||||
extra = 0
|
extra = 0
|
||||||
|
fields = ('name', 'file', 'right_wrong')
|
||||||
|
|
||||||
|
class TestQuestionInline(nested_admin.NestedStackedInline):
|
||||||
class TestQuestionAdmin(admin.ModelAdmin):
|
|
||||||
"""
|
|
||||||
Админка вопросов к тесту
|
|
||||||
"""
|
|
||||||
|
|
||||||
inlines = [TestAnswerInline]
|
|
||||||
|
|
||||||
|
|
||||||
class TestQuestionInline(admin.StackedInline):
|
|
||||||
"""
|
|
||||||
Инлайн вопросов
|
|
||||||
"""
|
|
||||||
|
|
||||||
model = TestQuestion
|
model = TestQuestion
|
||||||
extra = 0
|
extra = 0
|
||||||
|
inlines = [TestAnswerInline]
|
||||||
|
fields = ('name', 'file')
|
||||||
|
|
||||||
|
class TestFileInline(nested_admin.NestedStackedInline):
|
||||||
|
model = TestFile
|
||||||
|
extra = 0
|
||||||
|
|
||||||
class TestAdmin(admin.ModelAdmin):
|
fields = ('file',)
|
||||||
"Админка тестов"
|
class TestAdmin(nested_admin.NestedModelAdmin):
|
||||||
|
inlines = [TestFileInline, TestQuestionInline]
|
||||||
|
|
||||||
inlines = [TestQuestionInline]
|
class TestAttemptInline(admin.TabularInline):
|
||||||
|
model = TestAttempt
|
||||||
|
extra = 0 # не показывать пустые формы
|
||||||
|
fields = ('score', 'attempt_number', 'completion_date')
|
||||||
|
readonly_fields = ('score', 'attempt_number', 'completion_date')
|
||||||
|
can_delete = False
|
||||||
|
|
||||||
|
@admin.register(Testing)
|
||||||
|
class TestingAdmin(admin.ModelAdmin):
|
||||||
|
# list_display = ('testing_user', 'testing_test', 'score', 'completion_date')
|
||||||
|
list_display = ('get_user_fio', 'test', 'get_score', 'test_passed', 'completion_date')
|
||||||
|
fields = ('user','test', 'test_passed', 'completion_date')
|
||||||
|
inlines = [TestAttemptInline]
|
||||||
|
|
||||||
|
def get_user_fio(self, obj):
|
||||||
|
return obj.user.user.fio
|
||||||
|
|
||||||
|
def get_score(self, obj):
|
||||||
|
last_attempt = TestAttempt.objects.filter(testing=obj).order_by('-attempt_number').first()
|
||||||
|
if last_attempt:
|
||||||
|
return last_attempt.score
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
get_user_fio.admin_order_field = 'user__user__fio'
|
||||||
|
get_user_fio.short_description = 'Пользователь'
|
||||||
|
get_score.short_description = 'Результат'
|
||||||
|
|
||||||
admin.site.register(Test, TestAdmin)
|
admin.site.register(Test, TestAdmin)
|
||||||
admin.site.register(TestQuestion, TestQuestionAdmin)
|
|
||||||
admin.site.register(TestAnswer)
|
|
||||||
@@ -0,0 +1,222 @@
|
|||||||
|
# Generated by Django 5.1.6 on 2025-05-28 08:45
|
||||||
|
|
||||||
|
import datetime
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name="Test",
|
||||||
|
fields=[
|
||||||
|
(
|
||||||
|
"id",
|
||||||
|
models.BigAutoField(
|
||||||
|
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"file",
|
||||||
|
models.ImageField(
|
||||||
|
blank=True, null=True, upload_to="tests/files/", verbose_name="Лого Теста"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
("name", models.CharField(max_length=255, verbose_name="Название теста")),
|
||||||
|
("description", models.TextField(verbose_name="Описание")),
|
||||||
|
("pass_perc", models.FloatField(verbose_name="Мин. кол-во правильных ответов")),
|
||||||
|
("time", models.FloatField(verbose_name="Время прохождения теста")),
|
||||||
|
("question_count", models.PositiveIntegerField(verbose_name="Количество вопросов")),
|
||||||
|
("attemps_number", models.PositiveIntegerField(verbose_name="Количество попыток")),
|
||||||
|
(
|
||||||
|
"author",
|
||||||
|
models.ForeignKey(
|
||||||
|
on_delete=django.db.models.deletion.CASCADE,
|
||||||
|
to=settings.AUTH_USER_MODEL,
|
||||||
|
verbose_name="Создатель тестирования",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
"verbose_name": "Тест",
|
||||||
|
"verbose_name_plural": "Тесты",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name="Testing",
|
||||||
|
fields=[
|
||||||
|
(
|
||||||
|
"id",
|
||||||
|
models.BigAutoField(
|
||||||
|
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"completion_date",
|
||||||
|
models.DateTimeField(
|
||||||
|
blank=True, null=True, verbose_name="Дата завершения тестирования"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
("test_passed", models.BooleanField(verbose_name="Тест пройден")),
|
||||||
|
(
|
||||||
|
"test",
|
||||||
|
models.ForeignKey(
|
||||||
|
on_delete=django.db.models.deletion.PROTECT,
|
||||||
|
to="tests.test",
|
||||||
|
verbose_name="Тест",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"user",
|
||||||
|
models.ForeignKey(
|
||||||
|
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
"verbose_name": "Тестирование",
|
||||||
|
"verbose_name_plural": "Тестирования",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name="TestAttempt",
|
||||||
|
fields=[
|
||||||
|
(
|
||||||
|
"id",
|
||||||
|
models.BigAutoField(
|
||||||
|
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
("score", models.FloatField(default=0.0, verbose_name="Результат")),
|
||||||
|
("attempt_number", models.IntegerField(default=1, verbose_name="Номер попытки")),
|
||||||
|
(
|
||||||
|
"completion_date",
|
||||||
|
models.DateTimeField(
|
||||||
|
default=datetime.datetime.now, verbose_name="Дата прохождения теста"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"testing",
|
||||||
|
models.ForeignKey(
|
||||||
|
on_delete=django.db.models.deletion.CASCADE, to="tests.testing"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
"verbose_name": "Попытка прохождения теста",
|
||||||
|
"verbose_name_plural": "Попытки прохождения тестов",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name="TestQuestion",
|
||||||
|
fields=[
|
||||||
|
(
|
||||||
|
"id",
|
||||||
|
models.BigAutoField(
|
||||||
|
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
("name", models.CharField(max_length=255, verbose_name="Вопрос")),
|
||||||
|
(
|
||||||
|
"file",
|
||||||
|
models.ImageField(
|
||||||
|
blank=True,
|
||||||
|
null=True,
|
||||||
|
upload_to="tests/question_images/",
|
||||||
|
verbose_name="Картинка",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
("numb", models.PositiveIntegerField(verbose_name="Порядковый номер вопроса")),
|
||||||
|
(
|
||||||
|
"settings",
|
||||||
|
models.JSONField(default=dict, verbose_name="Json настроек тестирования"),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"test",
|
||||||
|
models.ForeignKey(
|
||||||
|
on_delete=django.db.models.deletion.CASCADE,
|
||||||
|
related_name="questions",
|
||||||
|
to="tests.test",
|
||||||
|
verbose_name="Тест",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
"verbose_name": "Вопрос",
|
||||||
|
"verbose_name_plural": "Вопросы",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name="TestAnswer",
|
||||||
|
fields=[
|
||||||
|
(
|
||||||
|
"id",
|
||||||
|
models.BigAutoField(
|
||||||
|
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
("name", models.CharField(max_length=255, verbose_name="Ответ")),
|
||||||
|
(
|
||||||
|
"file",
|
||||||
|
models.FileField(
|
||||||
|
blank=True,
|
||||||
|
null=True,
|
||||||
|
upload_to="tests/answer_files/",
|
||||||
|
verbose_name="Картинка",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
("right_wrong", models.BooleanField(verbose_name="Правильно/Неправильно")),
|
||||||
|
(
|
||||||
|
"question",
|
||||||
|
models.ForeignKey(
|
||||||
|
on_delete=django.db.models.deletion.CASCADE,
|
||||||
|
related_name="answers",
|
||||||
|
to="tests.testquestion",
|
||||||
|
verbose_name="Вопрос",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
"verbose_name": "Ответ",
|
||||||
|
"verbose_name_plural": "Ответы",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name="TestResult",
|
||||||
|
fields=[
|
||||||
|
(
|
||||||
|
"id",
|
||||||
|
models.BigAutoField(
|
||||||
|
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
("comment", models.TextField(blank=True, null=True)),
|
||||||
|
(
|
||||||
|
"answer",
|
||||||
|
models.ForeignKey(
|
||||||
|
on_delete=django.db.models.deletion.CASCADE, to="tests.testanswer"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"attempt",
|
||||||
|
models.ForeignKey(
|
||||||
|
on_delete=django.db.models.deletion.CASCADE,
|
||||||
|
related_name="test_results",
|
||||||
|
to="tests.testattempt",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
"verbose_name": "Результат",
|
||||||
|
"verbose_name_plural": "Результаты",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
# Generated by Django 5.1.6 on 2025-05-28 08:55
|
||||||
|
|
||||||
|
import datetime
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("tests", "0001_initial"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
# migrations.AddField(
|
||||||
|
# model_name="test",
|
||||||
|
# name="dateend",
|
||||||
|
# field=models.DateTimeField(
|
||||||
|
# default=datetime.datetime.now, verbose_name="Дата и время окончания периода"
|
||||||
|
# ),
|
||||||
|
# ),
|
||||||
|
# migrations.AddField(
|
||||||
|
# model_name="test",
|
||||||
|
# name="datestart",
|
||||||
|
# field=models.DateTimeField(
|
||||||
|
# default=datetime.datetime.now, verbose_name="Дата и время начала периода"
|
||||||
|
# ),
|
||||||
|
# ),
|
||||||
|
]
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.1.6 on 2025-05-29 08:38
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("tests", "0002_test_dateend_test_datestart"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="testing",
|
||||||
|
name="is_active",
|
||||||
|
field=models.BooleanField(default=True, verbose_name="Тестирование активно"),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.1.6 on 2025-05-29 14:19
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("tests", "0003_testing_is_active"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="test",
|
||||||
|
name="is_available",
|
||||||
|
field=models.BooleanField(default=True, verbose_name="Тест доступен"),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
# Generated by Django 5.1.6 on 2025-06-02 06:58
|
||||||
|
|
||||||
|
import datetime
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
|
||||||
|
("tests", "0004_test_is_available"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="testing",
|
||||||
|
name="datestart",
|
||||||
|
field=models.DateTimeField(
|
||||||
|
default=datetime.datetime.now, verbose_name="Дата и время начала тестирования"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="testing",
|
||||||
|
name="news",
|
||||||
|
field=models.ForeignKey(
|
||||||
|
blank=True,
|
||||||
|
null=True,
|
||||||
|
on_delete=django.db.models.deletion.CASCADE,
|
||||||
|
to="navigation.news",
|
||||||
|
verbose_name="Новость",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
# Generated by Django 5.1.6 on 2025-06-03 09:36
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("tests", "0005_testing_datestart_testing_news"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="testresult",
|
||||||
|
name="question",
|
||||||
|
field=models.ForeignKey(
|
||||||
|
blank=True,
|
||||||
|
null=True,
|
||||||
|
on_delete=django.db.models.deletion.CASCADE,
|
||||||
|
to="tests.testquestion",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="testresult",
|
||||||
|
name="answer",
|
||||||
|
field=models.ForeignKey(
|
||||||
|
null=True, on_delete=django.db.models.deletion.CASCADE, to="tests.testanswer"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
# Generated by Django 5.1.6 on 2025-06-04 05:55
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("tests", "0006_testresult_question_alter_testresult_answer"),
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="testattempt",
|
||||||
|
name="testing",
|
||||||
|
field=models.ForeignKey(
|
||||||
|
on_delete=django.db.models.deletion.CASCADE, to="tests.testing", verbose_name="Тест"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="testing",
|
||||||
|
name="user",
|
||||||
|
field=models.ForeignKey(
|
||||||
|
on_delete=django.db.models.deletion.CASCADE,
|
||||||
|
to=settings.AUTH_USER_MODEL,
|
||||||
|
verbose_name="Пользователь",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
# Generated by Django 5.1.6 on 2025-06-24 08:23
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("tests", "0007_alter_testattempt_testing_alter_testing_user"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="test",
|
||||||
|
name="pass_perc",
|
||||||
|
field=models.FloatField(verbose_name="Мин. % правильных ответов"),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="testanswer",
|
||||||
|
name="right_wrong",
|
||||||
|
field=models.BooleanField(verbose_name="Правильно"),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.2.4 on 2025-07-22 07:00
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("tests", "0008_alter_test_pass_perc_alter_testanswer_right_wrong"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="testquestion",
|
||||||
|
name="name",
|
||||||
|
field=models.TextField(verbose_name="Вопрос"),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
# Generated by Django 5.2.4 on 2025-08-01 10:46
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("tests", "0009_alter_testquestion_name"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="test",
|
||||||
|
name="name",
|
||||||
|
field=models.CharField(max_length=500, verbose_name="Название теста"),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="testanswer",
|
||||||
|
name="name",
|
||||||
|
field=models.TextField(verbose_name="Ответ"),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
# Generated by Django 5.2.4 on 2025-08-07 10:02
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("tests", "0010_alter_test_name_alter_testanswer_name"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name="TestFile",
|
||||||
|
fields=[
|
||||||
|
(
|
||||||
|
"id",
|
||||||
|
models.BigAutoField(
|
||||||
|
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"file",
|
||||||
|
models.FileField(upload_to="tests/test_files/", verbose_name="Приложение"),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"test",
|
||||||
|
models.ForeignKey(
|
||||||
|
on_delete=django.db.models.deletion.CASCADE,
|
||||||
|
related_name="test_files",
|
||||||
|
to="tests.test",
|
||||||
|
verbose_name="Тест",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
"verbose_name": "Файл теста",
|
||||||
|
"verbose_name_plural": "Файлы Теста",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
# Generated by Django 5.2.4 on 2025-08-07 10:45
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("tests", "0011_testfile"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="testfile",
|
||||||
|
name="file",
|
||||||
|
field=models.FileField(
|
||||||
|
upload_to="tests/files/help/%(test_id)s/", verbose_name="Приложение"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
# Generated by Django 5.2.4 on 2025-08-07 11:01
|
||||||
|
|
||||||
|
import tests.models
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("tests", "0012_alter_testfile_file"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="testfile",
|
||||||
|
name="file",
|
||||||
|
field=models.FileField(upload_to=tests.models.id_path, verbose_name="Приложение"),
|
||||||
|
),
|
||||||
|
]
|
||||||
Whitespace-only changes.
+74
-20
@@ -4,18 +4,23 @@ from django.db import models
|
|||||||
from userauth.models import *
|
from userauth.models import *
|
||||||
from accounts.models import User
|
from accounts.models import User
|
||||||
import datetime
|
import datetime
|
||||||
|
from navigation.models import News
|
||||||
|
|
||||||
class Test(models.Model):
|
class Test(models.Model):
|
||||||
file = models.ImageField(upload_to='tests/files/', null=True, blank=True, verbose_name='Лого Теста')
|
"""describes the test"""
|
||||||
name = models.CharField(max_length=255, blank=False, verbose_name="Название теста")
|
file = models.ImageField(upload_to='tests/files/',
|
||||||
|
null=True,
|
||||||
|
blank=True,
|
||||||
|
verbose_name='Лого Теста')
|
||||||
|
name = models.CharField(max_length=500, blank=False, verbose_name="Название теста")
|
||||||
description = models.TextField(verbose_name='Описание')
|
description = models.TextField(verbose_name='Описание')
|
||||||
datestart = models.DateTimeField(default=datetime.datetime.now, verbose_name='Дата и время начала периода')
|
author = models.ForeignKey(User, on_delete=models.CASCADE,
|
||||||
dateend = models.DateTimeField(default=datetime.datetime.now, verbose_name='Дата и время окончания периода')
|
verbose_name='Создатель тестирования')
|
||||||
author = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name='Создатель тестирования')
|
pass_perc = models.FloatField(blank=False, verbose_name="Мин. % правильных ответов")
|
||||||
pass_perc = models.FloatField(blank=False, verbose_name="Мин. кол-во правильных ответов")
|
|
||||||
time = models.FloatField(blank=False, verbose_name="Время прохождения теста")
|
time = models.FloatField(blank=False, verbose_name="Время прохождения теста")
|
||||||
question_count = models.PositiveIntegerField(blank=False, verbose_name="Количество вопросов")
|
question_count = models.PositiveIntegerField(blank=False, verbose_name="Количество вопросов")
|
||||||
attemps_number = models.PositiveIntegerField(blank=False, verbose_name="Количество попыток")
|
attemps_number = models.PositiveIntegerField(blank=False, verbose_name="Количество попыток")
|
||||||
|
is_available = models.BooleanField(default=True, verbose_name="Тест доступен")
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
@@ -23,10 +28,37 @@ class Test(models.Model):
|
|||||||
verbose_name = "Тест"
|
verbose_name = "Тест"
|
||||||
verbose_name_plural = "Тесты"
|
verbose_name_plural = "Тесты"
|
||||||
|
|
||||||
|
def id_path(instance,filename):
|
||||||
|
return f'tests/files/help/{instance.test.id}/{filename}'
|
||||||
|
|
||||||
|
class TestFile(models.Model):
|
||||||
|
test = models.ForeignKey(Test, related_name="test_files",on_delete=models.CASCADE, verbose_name="Тест")
|
||||||
|
file = models.FileField(upload_to=id_path,
|
||||||
|
verbose_name='Приложение')
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
verbose_name = "Файл теста"
|
||||||
|
verbose_name_plural = "Файлы Теста"
|
||||||
|
|
||||||
|
def delete(self, *args, **kwargs):
|
||||||
|
|
||||||
|
if self.file:
|
||||||
|
storage, path = self.file.storage, self.file.path
|
||||||
|
storage.delete(path)
|
||||||
|
|
||||||
|
super().delete(*args, **kwargs)
|
||||||
|
|
||||||
class TestQuestion(models.Model):
|
class TestQuestion(models.Model):
|
||||||
name = models.CharField(max_length=255, blank=False, verbose_name="Вопрос")
|
"""test questions"""
|
||||||
test = models.ForeignKey(Test, related_name='questions', on_delete=models.CASCADE, verbose_name="Тест")
|
name = models.TextField(blank=False, verbose_name="Вопрос")
|
||||||
file = models.ImageField(upload_to='tests/question_images/', null=True, blank=True, 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="Порядковый номер вопроса")
|
numb = models.PositiveIntegerField(verbose_name="Порядковый номер вопроса")
|
||||||
settings = models.JSONField(default=dict, verbose_name='Json настроек тестирования')
|
settings = models.JSONField(default=dict, verbose_name='Json настроек тестирования')
|
||||||
|
|
||||||
@@ -38,10 +70,17 @@ class TestQuestion(models.Model):
|
|||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
class TestAnswer(models.Model):
|
class TestAnswer(models.Model):
|
||||||
name = models.CharField(max_length=255, blank=False, verbose_name="Ответ")
|
"""answer options for the question"""
|
||||||
file = models.FileField(upload_to='tests/answer_files/', null=True, blank=True, verbose_name='Картинка')
|
name = models.TextField(blank=False, verbose_name="Ответ")
|
||||||
question = models.ForeignKey(TestQuestion, related_name='answers', on_delete=models.CASCADE, verbose_name="Вопрос")
|
file = models.FileField(upload_to='tests/answer_files/',
|
||||||
right_wrong = models.BooleanField(blank=False, verbose_name="Правильно/Неправильно")
|
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="Правильно")
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = "Ответ"
|
verbose_name = "Ответ"
|
||||||
@@ -51,30 +90,45 @@ class TestAnswer(models.Model):
|
|||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
class Testing(models.Model):
|
class Testing(models.Model):
|
||||||
user = models.ForeignKey(User, on_delete=models.CASCADE)
|
"""the fact of passing the test by a specific user"""
|
||||||
|
user = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name="Пользователь")
|
||||||
test = models.ForeignKey(Test, on_delete=models.PROTECT, blank=False, verbose_name="Тест")
|
test = models.ForeignKey(Test, on_delete=models.PROTECT, blank=False, verbose_name="Тест")
|
||||||
completion_date = models.DateTimeField(blank=True, null=True, verbose_name="Дата завершения тестирования")
|
datestart = models.DateTimeField(default=datetime.datetime.now, verbose_name='Дата и время начала тестирования')
|
||||||
|
completion_date = models.DateTimeField(blank=True,
|
||||||
|
null=True,
|
||||||
|
verbose_name="Дата завершения тестирования")
|
||||||
test_passed = models.BooleanField(blank=False, verbose_name="Тест пройден")
|
test_passed = models.BooleanField(blank=False, verbose_name="Тест пройден")
|
||||||
|
is_active = models.BooleanField(default=True, verbose_name="Тестирование активно")
|
||||||
|
news = models.ForeignKey(News, on_delete=models.CASCADE, null=True, blank=True, verbose_name='Новость')
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = "Тестирование"
|
verbose_name = "Тестирование"
|
||||||
verbose_name_plural = "Тестирования"
|
verbose_name_plural = "Тестирования"
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.test.name
|
return self.test.name
|
||||||
|
|
||||||
class TestAttempt(models.Model):
|
class TestAttempt(models.Model):
|
||||||
testing = models.ForeignKey(Testing, on_delete=models.CASCADE)
|
"""a separate attempt by a user to pass a test"""
|
||||||
|
testing = models.ForeignKey(Testing, verbose_name='Тест', on_delete=models.CASCADE)
|
||||||
score = models.FloatField(verbose_name='Результат', default=0.0)
|
score = models.FloatField(verbose_name='Результат', default=0.0)
|
||||||
attempt_number = models.IntegerField(verbose_name='Номер попытки', default=1)
|
attempt_number = models.IntegerField(verbose_name='Номер попытки', default=1)
|
||||||
completion_date = models.DateTimeField(default=datetime.datetime.now, verbose_name="Дата прохождения теста")
|
completion_date = models.DateTimeField(default=datetime.datetime.now,
|
||||||
|
verbose_name="Дата прохождения теста")
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = 'Попытка прохождения теста'
|
verbose_name = 'Попытка прохождения теста'
|
||||||
verbose_name_plural = 'Попытки прохождения тестов'
|
verbose_name_plural = 'Попытки прохождения тестов'
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
employee = DictEmployee.objects.filter(user=self.testing.user).first()
|
||||||
|
employee = employee.fio if employee else self.testing.user.username
|
||||||
|
return f"Попытка №{self.attempt_number} теста '{self.testing.test.name}' пользователя {employee}"
|
||||||
|
|
||||||
class TestResult(models.Model):
|
class TestResult(models.Model):
|
||||||
|
"""the result for a specific answer within an attempt"""
|
||||||
attempt = models.ForeignKey(TestAttempt, on_delete=models.CASCADE, related_name='test_results')
|
attempt = models.ForeignKey(TestAttempt, on_delete=models.CASCADE, related_name='test_results')
|
||||||
answer = models.ForeignKey(TestAnswer, on_delete=models.CASCADE)
|
question = models.ForeignKey(TestQuestion, on_delete=models.CASCADE, null=True, blank=True)
|
||||||
|
answer = models.ForeignKey(TestAnswer, on_delete=models.CASCADE, null=True)
|
||||||
comment = models.TextField(null=True, blank=True)
|
comment = models.TextField(null=True, blank=True)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
# pylint: skip-file
|
# pylint: skip-file
|
||||||
import base64
|
import base64
|
||||||
|
import os
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
from cryptography.fernet import Fernet
|
from cryptography.fernet import Fernet
|
||||||
@@ -67,6 +68,19 @@ class TestSerializer(serializers.ModelSerializer):
|
|||||||
|
|
||||||
|
|
||||||
class TestingSeriaizer(serializers.ModelSerializer):
|
class TestingSeriaizer(serializers.ModelSerializer):
|
||||||
|
user_details = serializers.SerializerMethodField()
|
||||||
|
|
||||||
|
def get_user_details(self, obj):
|
||||||
|
try:
|
||||||
|
dict_employee = obj.user.user
|
||||||
|
return {
|
||||||
|
'id': dict_employee.id,
|
||||||
|
'fio': dict_employee.fio,
|
||||||
|
'login': dict_employee.login
|
||||||
|
}
|
||||||
|
except:
|
||||||
|
return None
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Testing
|
model = Testing
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
@@ -80,19 +94,85 @@ class TestAttemptSerializer(serializers.ModelSerializer):
|
|||||||
|
|
||||||
class TestResultSerializer(serializers.ModelSerializer):
|
class TestResultSerializer(serializers.ModelSerializer):
|
||||||
attempt = TestAttemptSerializer(read_only=True)
|
attempt = TestAttemptSerializer(read_only=True)
|
||||||
answer = serializers.PrimaryKeyRelatedField(queryset=TestAnswer.objects.all(), many=False)
|
question = serializers.PrimaryKeyRelatedField(
|
||||||
comment = serializers.CharField(allow_null=True)
|
queryset=TestQuestion.objects.all(),
|
||||||
|
allow_null=True
|
||||||
|
)
|
||||||
|
answer = serializers.PrimaryKeyRelatedField(
|
||||||
|
queryset=TestAnswer.objects.all(),
|
||||||
|
allow_null=True,
|
||||||
|
many=False)
|
||||||
|
comment = serializers.CharField(allow_null=True, required=False)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = TestResult
|
model = TestResult
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
|
||||||
|
class TestFileSerializer(serializers.ModelSerializer):
|
||||||
|
filename= serializers.SerializerMethodField()
|
||||||
|
class Meta:
|
||||||
|
model = TestFile
|
||||||
|
fields = ['file','filename']
|
||||||
|
|
||||||
|
def get_filename(self,obj):
|
||||||
|
return os.path.basename(obj.file.name)
|
||||||
|
|
||||||
|
|
||||||
class TestsSerializer(serializers.ModelSerializer):
|
class TestsSerializer(serializers.ModelSerializer):
|
||||||
|
datestart = serializers.SerializerMethodField()
|
||||||
|
dateend = serializers.SerializerMethodField()
|
||||||
|
is_passed = serializers.SerializerMethodField()
|
||||||
|
is_active = serializers.SerializerMethodField()
|
||||||
|
files = serializers.SerializerMethodField()
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Test
|
model = Test
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
|
||||||
|
def get_files(self,obj):
|
||||||
|
return TestFileSerializer(obj.test_files, many=True).data
|
||||||
|
|
||||||
|
def get_datestart(self, obj):
|
||||||
|
user = self.context['request'].user
|
||||||
|
if not user.is_authenticated:
|
||||||
|
return None
|
||||||
|
|
||||||
|
# testing = Testing.objects.filter(test=obj, user=user, is_active=True).order_by('-completion_date').first()
|
||||||
|
testing = Testing.objects.filter(test=obj, user=user, is_active=True).first()
|
||||||
|
if testing and testing.datestart:
|
||||||
|
return testing.datestart
|
||||||
|
return None
|
||||||
|
|
||||||
|
def get_dateend(self, obj):
|
||||||
|
user = self.context['request'].user
|
||||||
|
if not user.is_authenticated:
|
||||||
|
return None
|
||||||
|
|
||||||
|
# testing = Testing.objects.filter(test=obj, user=user, is_active=True).order_by('-completion_date').first()
|
||||||
|
testing = Testing.objects.filter(test=obj, user=user, is_active=True).first()
|
||||||
|
if testing and testing.completion_date:
|
||||||
|
return testing.completion_date
|
||||||
|
return None
|
||||||
|
|
||||||
|
def get_is_passed(self, obj):
|
||||||
|
user = self.context['request'].user
|
||||||
|
if not user.is_authenticated:
|
||||||
|
return None
|
||||||
|
|
||||||
|
testing = Testing.objects.filter(test=obj, user=user, is_active=True).first()
|
||||||
|
if testing and testing.test_passed:
|
||||||
|
return testing.test_passed
|
||||||
|
return None
|
||||||
|
|
||||||
|
def get_is_active(self, obj):
|
||||||
|
user = self.context['request'].user
|
||||||
|
if not user.is_authenticated:
|
||||||
|
return None
|
||||||
|
|
||||||
|
testing = Testing.objects.filter(test=obj, user=user, is_active=True).first()
|
||||||
|
if testing and testing.is_active:
|
||||||
|
return testing.is_active
|
||||||
|
return False
|
||||||
|
|
||||||
def create(self, validated_data):
|
def create(self, validated_data):
|
||||||
user = self.context['request'].user
|
user = self.context['request'].user
|
||||||
if user.is_authenticated:
|
if user.is_authenticated:
|
||||||
|
|||||||
@@ -3,9 +3,11 @@ from .views import *
|
|||||||
|
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('testdetail/<int:id>/', TestDetail.as_view(),name='TestDetail'),
|
|
||||||
path('gettests/', GetTests.as_view(), name="GetTests"),
|
path('gettests/', GetTests.as_view(), name="GetTests"),
|
||||||
|
path('testdetail/<int:id>/', TestDetail.as_view(),name='TestDetail'),
|
||||||
|
path('testcreate/', TestCreate.as_view(),name='TestCreate'),
|
||||||
|
path('testingview/', TestingView.as_view(), name="TestingView"),
|
||||||
# path('gettesting/', GetTesting.as_view(), name="GetTesting"),
|
# path('gettesting/', GetTesting.as_view(), name="GetTesting"),
|
||||||
path('testresultview/', TestResultView.as_view(), name="TestResultView"),
|
path('testresultview/', TestResultView.as_view(), name="TestResultView"),
|
||||||
|
path('getusers/', GetUsers.as_view(), name="GetUsers"),
|
||||||
]
|
]
|
||||||
|
|
||||||
+392
-45
@@ -7,7 +7,9 @@ from userauth.models import *
|
|||||||
from .serializers import *
|
from .serializers import *
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from rest_framework import generics
|
from rest_framework import generics
|
||||||
|
from rest_framework.generics import ListAPIView
|
||||||
from navigation.models import News
|
from navigation.models import News
|
||||||
|
from django.db import DatabaseError
|
||||||
import json
|
import json
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
import os
|
import os
|
||||||
@@ -21,6 +23,9 @@ from cryptography.fernet import Fernet
|
|||||||
from django.db.models import F
|
from django.db.models import F
|
||||||
from drf_yasg import openapi
|
from drf_yasg import openapi
|
||||||
from drf_yasg.utils import swagger_auto_schema
|
from drf_yasg.utils import swagger_auto_schema
|
||||||
|
from vote.views import make_clickable, set_real_departments
|
||||||
|
from vote.serializers import DictEmployeeSerializer
|
||||||
|
import pytz
|
||||||
|
|
||||||
class GetTests(generics.ListAPIView):
|
class GetTests(generics.ListAPIView):
|
||||||
queryset = Test.objects.all()
|
queryset = Test.objects.all()
|
||||||
@@ -34,7 +39,9 @@ class GetTests(generics.ListAPIView):
|
|||||||
openapi.Parameter(
|
openapi.Parameter(
|
||||||
'status',
|
'status',
|
||||||
openapi.IN_QUERY,
|
openapi.IN_QUERY,
|
||||||
description="Статус тестов (например, 'active', 'completed'). Пустое значение вернет все тесты",
|
description=("Статус тестов (например, 'active', 'completed'). "
|
||||||
|
"Пустое значение вернет все тесты."
|
||||||
|
),
|
||||||
type=openapi.TYPE_STRING,
|
type=openapi.TYPE_STRING,
|
||||||
required=False,
|
required=False,
|
||||||
),
|
),
|
||||||
@@ -45,6 +52,7 @@ class GetTests(generics.ListAPIView):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
def get (self, request, *args, **kwargs):
|
def get (self, request, *args, **kwargs):
|
||||||
|
"""receives tests assigned to the user"""
|
||||||
user = request.user
|
user = request.user
|
||||||
# user = User.objects.get(username='9966-00-125')
|
# user = User.objects.get(username='9966-00-125')
|
||||||
status = request.query_params.get('status')
|
status = request.query_params.get('status')
|
||||||
@@ -56,38 +64,68 @@ class GetTests(generics.ListAPIView):
|
|||||||
return Response(serialized_tests)
|
return Response(serialized_tests)
|
||||||
|
|
||||||
def get_tests_by_status(self, status, now, user):
|
def get_tests_by_status(self, status, now, user):
|
||||||
|
"""Returns a QuerySet of tests filtered by status for a given user."""
|
||||||
print(status)
|
print(status)
|
||||||
if status is None:
|
base_filters = {
|
||||||
return Test.objects.all().order_by('dateend')
|
'testing__user': user,
|
||||||
|
'testing__is_active': True,
|
||||||
status_filters = {
|
'is_available': True,
|
||||||
'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')
|
if status is None:
|
||||||
|
return Test.objects.filter(is_available=True)
|
||||||
|
|
||||||
|
if status == 'active':
|
||||||
|
filters = {**base_filters,
|
||||||
|
'testing__datestart__lte': now,
|
||||||
|
'testing__completion_date__gte': now}
|
||||||
|
elif status == 'completed':
|
||||||
|
filters = {**base_filters,
|
||||||
|
'testing__completion_date__lt': now}
|
||||||
|
else:
|
||||||
|
return Test.objects.none()
|
||||||
|
|
||||||
|
return Test.objects.filter(**filters).distinct()
|
||||||
|
|
||||||
def set_attemps_number(self, user, tests):
|
def set_attemps_number(self, user, tests):
|
||||||
attempt_counts = TestAttempt.objects.filter(testing__user=user, testing__test__in=tests).values('testing__test').annotate(count=Count('testing__test'))
|
"""Updates the number of attempts remaining for each test for the user."""
|
||||||
|
attempt_counts = TestAttempt.objects.filter(testing__user=user,
|
||||||
|
testing__test__in=tests,
|
||||||
|
testing__is_active=True
|
||||||
|
).values('testing__test'
|
||||||
|
).annotate(count=Count('testing__test'))
|
||||||
attempt_counts = {item['testing__test']: item['count'] for item in attempt_counts}
|
attempt_counts = {item['testing__test']: item['count'] for item in attempt_counts}
|
||||||
|
|
||||||
for test in tests:
|
for test in tests:
|
||||||
test.attemps_number = test.attemps_number - attempt_counts.get(test.id, 0)
|
test.attemps_number = test.attemps_number - attempt_counts.get(test.id, 0)
|
||||||
|
|
||||||
|
def delete(self, request):
|
||||||
|
"""makes the test not available"""
|
||||||
|
|
||||||
|
test_id = request.data.get("test_id")
|
||||||
|
try:
|
||||||
|
test = Test.objects.get(id=test_id)
|
||||||
|
test.is_available = False
|
||||||
|
test.save()
|
||||||
|
# testings = Testing.objects.filter(test=test)
|
||||||
|
# testings.update(is_active=False)
|
||||||
|
return Response(
|
||||||
|
{"status": "success", "message": "Test is not available."},
|
||||||
|
status=200,
|
||||||
|
)
|
||||||
|
except DatabaseError as e:
|
||||||
|
print(e)
|
||||||
|
return Response({"status": "error", "message": str(e)}, status=400)
|
||||||
|
|
||||||
class TestDetail(generics.RetrieveUpdateDestroyAPIView):
|
class TestDetail(generics.RetrieveUpdateDestroyAPIView):
|
||||||
|
"""comment"""
|
||||||
queryset = Test.objects.all()
|
queryset = Test.objects.all()
|
||||||
serializer_class = TestSerializer
|
serializer_class = TestSerializer
|
||||||
lookup_url_kwarg = 'id'
|
lookup_url_kwarg = 'id'
|
||||||
lookup_field = 'id'
|
lookup_field = 'id'
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
|
"""Processes a GET request to retrieve detailed information about a test."""
|
||||||
test = self.get_object()
|
test = self.get_object()
|
||||||
number_of_questions = test.question_count
|
number_of_questions = test.question_count
|
||||||
random_questions = test.questions.order_by('?')[:number_of_questions]
|
random_questions = test.questions.order_by('?')[:number_of_questions]
|
||||||
@@ -96,6 +134,93 @@ class TestDetail(generics.RetrieveUpdateDestroyAPIView):
|
|||||||
|
|
||||||
return Response(test_serialized)
|
return Response(test_serialized)
|
||||||
|
|
||||||
|
class TestCreate(APIView):
|
||||||
|
"""
|
||||||
|
create test
|
||||||
|
"""
|
||||||
|
|
||||||
|
def post(self, request):
|
||||||
|
"""
|
||||||
|
create test
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
|
||||||
|
self.create_test(request)
|
||||||
|
|
||||||
|
return Response(
|
||||||
|
{"status": "success", "message": "Test created successfully."},
|
||||||
|
status=200,
|
||||||
|
)
|
||||||
|
except ValueError as e:
|
||||||
|
|
||||||
|
return Response({"status": "error", "message": str(e)}, status=400)
|
||||||
|
|
||||||
|
except DatabaseError as e:
|
||||||
|
|
||||||
|
return Response({"status": "error", "message": str(e)}, status=400)
|
||||||
|
|
||||||
|
def create_test(self, request):
|
||||||
|
"""
|
||||||
|
create test
|
||||||
|
"""
|
||||||
|
user = request.user
|
||||||
|
|
||||||
|
test_image = (
|
||||||
|
request.FILES.get("image")
|
||||||
|
if "image" in request.FILES else None
|
||||||
|
)
|
||||||
|
|
||||||
|
test = Test.objects.create(
|
||||||
|
file=test_image,
|
||||||
|
name=request.data["name"],
|
||||||
|
description=request.data["description"],
|
||||||
|
author=user,
|
||||||
|
pass_perc=request.data["pass_perc"],
|
||||||
|
time=request.data["time"],
|
||||||
|
question_count=request.data["question_count"],
|
||||||
|
attemps_number=request.data["attemps_number"],
|
||||||
|
is_available = True
|
||||||
|
)
|
||||||
|
|
||||||
|
test_files=[TestFile(file=file,test=test) for file in request.FILES.getlist("test_files")]
|
||||||
|
if len(test_files)>0:
|
||||||
|
TestFile.objects.bulk_create(test_files)
|
||||||
|
|
||||||
|
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 = TestQuestion.objects.create(
|
||||||
|
name=question_data["text"],
|
||||||
|
test=test,
|
||||||
|
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
|
||||||
|
)
|
||||||
|
TestAnswer.objects.create(
|
||||||
|
name=answer["text"],
|
||||||
|
file=answer_image,
|
||||||
|
question=question,
|
||||||
|
right_wrong=answer["right_wrong"],
|
||||||
|
)
|
||||||
|
|
||||||
# class GetTesting(APIView):
|
# class GetTesting(APIView):
|
||||||
|
|
||||||
# def get(self, request):
|
# def get(self, request):
|
||||||
@@ -108,8 +233,162 @@ class TestDetail(generics.RetrieveUpdateDestroyAPIView):
|
|||||||
# test['test_name'] = test_names[test['id']]
|
# test['test_name'] = test_names[test['id']]
|
||||||
# return Response(serializer)
|
# return Response(serializer)
|
||||||
|
|
||||||
class TestResultView(generics.ListCreateAPIView):
|
class TestingView(generics.ListCreateAPIView):
|
||||||
|
"""API for testing."""
|
||||||
|
queryset = Testing.objects.all()
|
||||||
|
serializer_class = TestingSeriaizer
|
||||||
|
pagination_class = None
|
||||||
|
|
||||||
|
@swagger_auto_schema(
|
||||||
|
operation_description="""Получить все назначения теста
|
||||||
|
*Нужно авторизоваться!""",
|
||||||
|
manual_parameters=[
|
||||||
|
openapi.Parameter(
|
||||||
|
'test_id',
|
||||||
|
openapi.IN_QUERY,
|
||||||
|
description="ID теста",
|
||||||
|
type=openapi.TYPE_INTEGER,
|
||||||
|
required=False,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
responses={
|
||||||
|
200: "success",
|
||||||
|
400: 'error',
|
||||||
|
}
|
||||||
|
)
|
||||||
|
def get(self, request):
|
||||||
|
"""Get all testing records for a test"""
|
||||||
|
test_id = request.query_params.get('test_id')
|
||||||
|
try:
|
||||||
|
if test_id:
|
||||||
|
testings = Testing.objects.filter(test_id=test_id,
|
||||||
|
is_active=True).select_related('user__user')
|
||||||
|
else:
|
||||||
|
testings = Testing.objects.filter(is_active=True
|
||||||
|
).select_related('user__user')
|
||||||
|
|
||||||
|
serializer = self.get_serializer(testings, many=True)
|
||||||
|
return Response(serializer.data)
|
||||||
|
except DatabaseError as e:
|
||||||
|
print(e)
|
||||||
|
return Response({"status": "error", "message": str(e)}, status=400)
|
||||||
|
|
||||||
|
def post(self, request):
|
||||||
|
"""create testing"""
|
||||||
|
try:
|
||||||
|
dictemployees = DictEmployee.objects.filter(id__in=request.data["user_id"])
|
||||||
|
users = User.objects.filter(user__in=dictemployees).distinct()
|
||||||
|
test = Test.objects.get(id=request.data["test_id"])
|
||||||
|
testings =[]
|
||||||
|
for user in users:
|
||||||
|
testing = Testing.objects.create(
|
||||||
|
user=user,
|
||||||
|
test=test,
|
||||||
|
datestart=request.data["datestart"],
|
||||||
|
completion_date=request.data["completion_date"],
|
||||||
|
test_passed=False,
|
||||||
|
)
|
||||||
|
testings.append(testing)
|
||||||
|
if request.data.get("news"):
|
||||||
|
if testings:
|
||||||
|
self.create_news(request, testings)
|
||||||
|
return Response(
|
||||||
|
{"status": "success", "message": "Testing created successfully."},
|
||||||
|
status=200,
|
||||||
|
)
|
||||||
|
except ValueError as e:
|
||||||
|
|
||||||
|
return Response({"status": "error", "message": str(e)}, status=400)
|
||||||
|
|
||||||
|
except DatabaseError as e:
|
||||||
|
print(e)
|
||||||
|
return Response({"status": "error", "message": str(e)}, status=400)
|
||||||
|
|
||||||
|
def put(self, request):
|
||||||
|
"""when removing testing from an employee"""
|
||||||
|
try:
|
||||||
|
testing_ids = request.data.get("id", [])
|
||||||
|
testings = Testing.objects.filter(id__in=testing_ids)
|
||||||
|
testings.update(is_active=False)
|
||||||
|
news_ids = testings.values_list('news_id', flat=True).distinct()
|
||||||
|
news_ids_list = [nid for nid in news_ids if nid is not None]
|
||||||
|
for testing in testings:
|
||||||
|
if testing.news:
|
||||||
|
self.change_news(testing)
|
||||||
|
testing.news = None
|
||||||
|
testing.save()
|
||||||
|
if not Testing.objects.filter(news__id__in=news_ids_list):
|
||||||
|
News.objects.filter(id__in=news_ids_list).delete()
|
||||||
|
return Response({"status": "success", "message": "Testing is not active."},
|
||||||
|
status=200)
|
||||||
|
except DatabaseError as e:
|
||||||
|
print(e)
|
||||||
|
return Response({"status": "error", "message": str(e)}, status=400)
|
||||||
|
|
||||||
|
def delete(self, request):
|
||||||
|
"""delete testing"""
|
||||||
|
testing_id = request.data.get("id")
|
||||||
|
try:
|
||||||
|
testing = Testing.objects.get(id=testing_id)
|
||||||
|
testing.delete()
|
||||||
|
return Response({"status": "success", "message": "Testing deleted successfully."},
|
||||||
|
status=200)
|
||||||
|
except DatabaseError as e:
|
||||||
|
print(e)
|
||||||
|
return Response({"status": "error", "message": str(e)}, status=400)
|
||||||
|
|
||||||
|
def create_news(self, request, testings):
|
||||||
|
"""
|
||||||
|
Комментарий
|
||||||
|
"""
|
||||||
|
test_name = testings[0].test.name
|
||||||
|
test_id = testings[0].test.id
|
||||||
|
test_file = testings[0].test.file
|
||||||
|
date_str = request.data["completion_date"]
|
||||||
|
if date_str.endswith('Z'):
|
||||||
|
date_str = date_str[:-1] + '+0000' # pytz требует формат +HHMM
|
||||||
|
|
||||||
|
dt_utc = datetime.strptime(date_str, "%Y-%m-%dT%H:%M:%S.%f%z")
|
||||||
|
msk_tz = pytz.timezone("Europe/Moscow")
|
||||||
|
dt_msk = dt_utc.astimezone(msk_tz)
|
||||||
|
formatted_date = dt_msk.strftime("%d.%m.%Y %H:%M")
|
||||||
|
|
||||||
|
testing_url = make_clickable(test_name,
|
||||||
|
f"/test/testdetail/{test_id}?mode=exam")
|
||||||
|
text = f'Пройдите тестирование "{testing_url}" до {formatted_date} '
|
||||||
|
texts = []
|
||||||
|
for testing in testings:
|
||||||
|
texts.append(testing.user.user.fio)
|
||||||
|
text += ", ".join(testing.user.user.fio for testing in testings) + "."
|
||||||
|
news = News(
|
||||||
|
title="Пройдите тестирование!",
|
||||||
|
text=text,
|
||||||
|
cdate=request.data["datestart"],
|
||||||
|
author=request.user,
|
||||||
|
link=test_file,
|
||||||
|
)
|
||||||
|
news.save()
|
||||||
|
for testing in testings:
|
||||||
|
testing.news = news
|
||||||
|
testing.save()
|
||||||
|
|
||||||
|
def change_news(self, testing):
|
||||||
|
"""change news if the test assignment for an employee has been removed"""
|
||||||
|
if not testing.news:
|
||||||
|
return
|
||||||
|
user_fio = testing.user.user.fio
|
||||||
|
new_text = testing.news.text
|
||||||
|
substrings = [f'{user_fio}, ', f', {user_fio}']
|
||||||
|
|
||||||
|
for substr in substrings:
|
||||||
|
if substr in new_text:
|
||||||
|
new_text = new_text.replace(substr, "")
|
||||||
|
break
|
||||||
|
testing.news.text = new_text
|
||||||
|
testing.news.save()
|
||||||
|
|
||||||
|
class TestResultView(generics.ListCreateAPIView):
|
||||||
|
"""API for getting and saving user test results."""
|
||||||
queryset = TestResult.objects.all()
|
queryset = TestResult.objects.all()
|
||||||
serializer_class = TestResultSerializer
|
serializer_class = TestResultSerializer
|
||||||
pagination_class = None
|
pagination_class = None
|
||||||
@@ -132,13 +411,20 @@ class TestResultView(generics.ListCreateAPIView):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
|
"""Get the results of the last user test attempt."""
|
||||||
user = request.user
|
user = request.user
|
||||||
# user = User.objects.get(username = "9966-00-125")
|
# user = User.objects.get(username = "9966-00-125")
|
||||||
test_id = request.GET.get('id')
|
test_id = request.GET.get('id')
|
||||||
last_attempt = TestAttempt.objects.filter(testing__user=user, testing__test__id=test_id).order_by('-completion_date').first()
|
last_attempt = TestAttempt.objects.filter(testing__user=user,
|
||||||
answer_ids = TestResult.objects.filter(attempt=last_attempt).values_list('answer__id', flat=True)
|
testing__test__id=test_id,
|
||||||
test_info = self.get_test_info(answer_ids)
|
testing__is_active=True,
|
||||||
return Response(data={'score': test_info['score'], 'answered_questions_total': test_info['answered_questions_total']})
|
).order_by('-completion_date').first()
|
||||||
|
answer_ids = TestResult.objects.filter(attempt=last_attempt
|
||||||
|
).values_list('answer__id', flat=True)
|
||||||
|
test_info = self.get_test_info(answer_ids, test_id)
|
||||||
|
return Response(data={'score': test_info['score'],
|
||||||
|
'answered_questions_total': test_info['answered_questions_total'],
|
||||||
|
'is_passed': test_info['is_passed']})
|
||||||
|
|
||||||
@swagger_auto_schema(
|
@swagger_auto_schema(
|
||||||
operation_description=""" Сохранить результаты тестов
|
operation_description=""" Сохранить результаты тестов
|
||||||
@@ -147,7 +433,8 @@ class TestResultView(generics.ListCreateAPIView):
|
|||||||
openapi.Parameter(
|
openapi.Parameter(
|
||||||
'status',
|
'status',
|
||||||
openapi.IN_QUERY,
|
openapi.IN_QUERY,
|
||||||
description="Статус тестов (например, 'testing'). Пустое значение - режим тренировки",
|
description=("Статус тестов (например, 'testing'). "
|
||||||
|
"Пустое значение - режим тренировки"),
|
||||||
type=openapi.TYPE_STRING,
|
type=openapi.TYPE_STRING,
|
||||||
required=False,
|
required=False,
|
||||||
),
|
),
|
||||||
@@ -167,39 +454,78 @@ class TestResultView(generics.ListCreateAPIView):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
def post(self, request, *args, **kwargs):
|
def post(self, request, *args, **kwargs):
|
||||||
user = request.user
|
"""Saves the results of a new test attempt."""
|
||||||
# user = User.objects.get(username = "9966-00-125")
|
try:
|
||||||
status = request.query_params.get('status')
|
user = request.user
|
||||||
answer_ids = [item['answer'] for item in request.data]
|
# user = User.objects.get(username = "9966-00-125")
|
||||||
test_info = self.get_test_info(answer_ids)
|
status = request.query_params.get('status')
|
||||||
if status == 'testing':
|
test_id = request.query_params.get('id')
|
||||||
test_attempt = self.create_test_attempt(user, test_info)
|
answer_ids = []
|
||||||
|
prepared_data = []
|
||||||
|
for data in request.data:
|
||||||
|
question_id = data.get('question_id')
|
||||||
|
answers_id = data.get('answers_id', [])
|
||||||
|
for sublist in answers_id:
|
||||||
|
if isinstance(sublist, list):
|
||||||
|
answer_ids.extend(sublist)
|
||||||
|
else:
|
||||||
|
answer_ids.append(sublist)
|
||||||
|
if answers_id:
|
||||||
|
for answer_id in answers_id:
|
||||||
|
prepared_data.append({
|
||||||
|
'question': question_id,
|
||||||
|
'answer': answer_id,
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
prepared_data.append({
|
||||||
|
'question': question_id,
|
||||||
|
'answer': None,
|
||||||
|
})
|
||||||
|
# answer_ids = [item['answer'] for item in request.data]
|
||||||
|
test_info = self.get_test_info(answer_ids, test_id)
|
||||||
|
if status == 'testing':
|
||||||
|
test_attempt, testing = self.create_test_attempt(user, test_info)
|
||||||
|
|
||||||
serializer = self.get_serializer(data=request.data, many=True)
|
# serializer = self.get_serializer(data=request.data, many=True)
|
||||||
if serializer.is_valid():
|
serializer = self.get_serializer(data=prepared_data, many=True)
|
||||||
serializer.save(attempt=test_attempt)
|
if serializer.is_valid():
|
||||||
self.update_testing(user, test_info)
|
serializer.save(attempt=test_attempt)
|
||||||
|
self.update_testing(test_info, testing)
|
||||||
|
|
||||||
return Response(data={'score': test_info['score'], 'answered_questions_total': test_info['answered_questions_total']})
|
return Response(data={'score': test_info['score'],
|
||||||
|
'answered_questions_total': test_info['answered_questions_total'],
|
||||||
|
'is_passed': test_info['is_passed']})
|
||||||
|
except Exception as e: #pylint: disable=W0718
|
||||||
|
print(e)
|
||||||
|
return Response({"status": "error", "message": str(e)}, status=400)
|
||||||
|
|
||||||
def create_test_attempt(self, user, test_info):
|
def create_test_attempt(self, user, test_info):
|
||||||
|
"""Creates a new test attempt for the user."""
|
||||||
test = test_info['test']
|
test = test_info['test']
|
||||||
score = test_info['score']
|
score = test_info['score']
|
||||||
testing = Testing.objects.get(user=user, test=test)
|
testing = Testing.objects.get(user=user, test=test, is_active=True)
|
||||||
attempt_count = get_attempt_count(testing)+ 1
|
attempt_count = get_attempt_count(testing)+ 1
|
||||||
test_attempt = TestAttempt.objects.create(testing=testing , score=score , attempt_number=attempt_count , completion_date= datetime.now())
|
test_attempt = TestAttempt.objects.create(testing=testing,
|
||||||
return test_attempt
|
score=score,
|
||||||
|
attempt_number=attempt_count,
|
||||||
|
completion_date= datetime.now())
|
||||||
|
return test_attempt, testing
|
||||||
|
|
||||||
def update_testing(self, user, test_info):
|
def update_testing(self, test_info, testing):
|
||||||
test = test_info['test']
|
"""Updates or creates a Testing record with a test passing flag."""
|
||||||
test_passed = test_info['is_passed']
|
test_passed = test_info['is_passed']
|
||||||
Testing.objects.update_or_create(user=user, test=test, defaults = {"test_passed":test_passed})
|
testing.test_passed = test_passed
|
||||||
|
testing.save()
|
||||||
def get_test_info(self, answer_ids):
|
|
||||||
|
|
||||||
|
def get_test_info(self, answer_ids, test_id):
|
||||||
|
"""Calculates test results from a list of answer IDs."""
|
||||||
test_answers = TestAnswer.objects.filter(id__in=answer_ids)
|
test_answers = TestAnswer.objects.filter(id__in=answer_ids)
|
||||||
test = test_answers[0].question.test
|
test = Test.objects.get(id=test_id)
|
||||||
answered_questions_total = test_answers.values('question').distinct().count()
|
answered_questions_total = test_answers.values('question').distinct().count()
|
||||||
|
q_count = test.question_count
|
||||||
|
all_questions = len(TestQuestion.objects.filter(test=test))
|
||||||
|
if all_questions <= q_count:
|
||||||
|
q_count = all_questions
|
||||||
|
|
||||||
correct_questions = sum(
|
correct_questions = sum(
|
||||||
TestAnswer.objects.filter(
|
TestAnswer.objects.filter(
|
||||||
@@ -212,9 +538,14 @@ class TestResultView(generics.ListCreateAPIView):
|
|||||||
for question in set(test_answers.values_list('question', flat=True))
|
for question in set(test_answers.values_list('question', flat=True))
|
||||||
)
|
)
|
||||||
|
|
||||||
pass_perc = test_answers[0].question.test.pass_perc
|
pass_perc = test.pass_perc
|
||||||
|
correct_answers_perc = 0
|
||||||
|
if q_count !=0:
|
||||||
|
correct_answers_perc = correct_questions/q_count*100
|
||||||
|
# if answered_questions_total !=0:
|
||||||
|
# correct_answers_perc = correct_questions/answered_questions_total*100
|
||||||
result = {
|
result = {
|
||||||
"is_passed": correct_questions >= pass_perc,
|
"is_passed": correct_answers_perc >= pass_perc,
|
||||||
"score": correct_questions,
|
"score": correct_questions,
|
||||||
"test": test,
|
"test": test,
|
||||||
"answered_questions_total": answered_questions_total,
|
"answered_questions_total": answered_questions_total,
|
||||||
@@ -222,4 +553,20 @@ class TestResultView(generics.ListCreateAPIView):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
def get_attempt_count(testing):
|
def get_attempt_count(testing):
|
||||||
|
"""get attempt count"""
|
||||||
return TestAttempt.objects.filter(testing=testing).count()
|
return TestAttempt.objects.filter(testing=testing).count()
|
||||||
|
|
||||||
|
class GetUsers(APIView):
|
||||||
|
"""
|
||||||
|
Комментарий
|
||||||
|
"""
|
||||||
|
|
||||||
|
def get(self, request):
|
||||||
|
"""
|
||||||
|
Комментарий
|
||||||
|
"""
|
||||||
|
dictemployees = DictEmployee.objects.filter(deleted=0,id__in=User.objects.filter(
|
||||||
|
user__isnull=False).values_list('user_id', flat=True))
|
||||||
|
set_real_departments(dictemployees)
|
||||||
|
employees_serializer = DictEmployeeSerializer(dictemployees, many=True).data
|
||||||
|
return Response(employees_serializer)
|
||||||
@@ -0,0 +1,173 @@
|
|||||||
|
# Generated by Django 4.2.3 on 2025-01-31 09:39
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='DictCompetences',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('name', models.CharField(max_length=100)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'db_table': 'dict_competences',
|
||||||
|
'db_table_comment': '╤яЁртюўэшъ ъюьяхЄхэЎшщ',
|
||||||
|
'managed': False,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='DictCompetencesType',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('name', models.CharField(db_comment='═ршьхэютрэшх уЁєяя√ ъюьяхЄхэЎшщ', max_length=50)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'db_table': 'dict_competences_type',
|
||||||
|
'db_table_comment': '├Ёєяя√ ъюьяхЄхэЎшщ',
|
||||||
|
'managed': False,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='DictDepartment',
|
||||||
|
fields=[
|
||||||
|
('id', models.PositiveIntegerField(db_comment='╥рсхы№э√щ эюьхЁ', primary_key=True, serialize=False)),
|
||||||
|
('name', models.CharField(db_comment='═рчтрэшх юЄфхыр', max_length=500)),
|
||||||
|
('deleted', models.IntegerField(db_comment='╠рЁъх єфрыхэш\xa0 чряшёш')),
|
||||||
|
('name_from_ad', models.CharField(blank=True, db_column='name_from_AD', db_comment='═рчтрэшх юЄфхыр т AD', max_length=500, null=True)),
|
||||||
|
('name_position_chief', models.CharField(db_comment='═рчтрэшх фюыцэюёЄш эрўры№эшър юЄфхыр', max_length=500)),
|
||||||
|
('code_department', models.CharField(max_length=2)),
|
||||||
|
('order_department', models.IntegerField()),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Отдел',
|
||||||
|
'verbose_name_plural': 'Отделы',
|
||||||
|
'db_table': 'dict_department',
|
||||||
|
'db_table_comment': '╤яЁртюўэшъ юЄфхыют',
|
||||||
|
'managed': False,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='DictEmployee',
|
||||||
|
fields=[
|
||||||
|
('id', models.PositiveIntegerField(db_comment='╥рсхы№э√щ эюьхЁ', primary_key=True, serialize=False)),
|
||||||
|
('login', models.CharField(blank=True, db_comment='ыюушэ(sAMAccountName)', max_length=100, null=True)),
|
||||||
|
('password', models.CharField(blank=True, db_comment='╧рЁюы№ фы\xa0 тїюфр эр яюЁЄры', max_length=100, null=True)),
|
||||||
|
('fio', models.CharField(blank=True, db_column='FIO', db_comment='╘╚╬(cn)', max_length=300, null=True)),
|
||||||
|
('familyname', models.CharField(blank=True, db_comment='╘рьшыш\xa0(sn)', max_length=100, null=True)),
|
||||||
|
('name', models.CharField(blank=True, db_comment='╚ь\xa0', max_length=100, null=True)),
|
||||||
|
('parentname', models.CharField(blank=True, db_comment='╬ЄўхёЄтю', max_length=100, null=True)),
|
||||||
|
('department', models.CharField(blank=True, db_comment='╬Єфхы(department)', max_length=500, null=True)),
|
||||||
|
('post', models.CharField(blank=True, db_comment='фюыцэюёЄ№(title)', max_length=500, null=True)),
|
||||||
|
('room', models.CharField(blank=True, db_comment='ърсшэхЄ(physicalDeliveryOfficeName)', max_length=20, null=True)),
|
||||||
|
('email', models.CharField(blank=True, db_comment='рфЁхё ¤ыхъЄЁюээющ яюўЄ√(mail)', max_length=100, null=True)),
|
||||||
|
('tel', models.CharField(blank=True, db_comment='уюЁюфёъющ ЄхыхЇюэ(telephoneNumber)', max_length=20, null=True)),
|
||||||
|
('iptel', models.CharField(blank=True, db_comment='тэєЄЁхээшщ ЄхыхЇюэ(OfficePhone)', max_length=20, null=True)),
|
||||||
|
('workstatus', models.CharField(blank=True, db_column='WorkStatus', db_comment='ёЄрЄєё', max_length=500, null=True)),
|
||||||
|
('is_curator', models.PositiveIntegerField(db_comment='╠рЁъхЁ ъєЁрЄюЁр')),
|
||||||
|
('datebegin', models.DateField(blank=True, db_column='DateBegin', db_comment='─рЄр яЁшхьр эр ЁрсюЄє', null=True)),
|
||||||
|
('dateend', models.DateField(blank=True, db_column='DateEnd', db_comment='─рЄр єтюы№эхэш\xa0', null=True)),
|
||||||
|
('workstatus2', models.CharField(blank=True, db_column='WorkStatus2', db_comment='ёЄрЄєё єўхЄэющ чряшёш(Enabled)', max_length=500, null=True)),
|
||||||
|
('deleted', models.PositiveIntegerField(db_comment='╠рЁъхЁ єфрыхэш\xa0')),
|
||||||
|
('deleteddate', models.DateField(blank=True, db_column='deletedDate', db_comment='─рЄр чряюыэхэш\xa0 ьрЁъхЁр єфрыхэш\xa0', null=True)),
|
||||||
|
('is_responsible', models.PositiveIntegerField(db_comment='╙фрышЄ№')),
|
||||||
|
('is_changed', models.PositiveIntegerField(db_comment='╧Ёшчэръ эрышўш\xa0 шчьхэхэшщ')),
|
||||||
|
('birthdate', models.DateField(blank=True, db_column='BirthDate', db_comment='─рЄр Ёюцфхэш\xa0 ёюЄЁєфэшър', null=True)),
|
||||||
|
('lotus', models.CharField(blank=True, db_column='lotus', db_comment='ёЄрЄєё єўхЄэющ чряшёш(Enabled)', max_length=200, null=True)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'db_table': 'dict_employee',
|
||||||
|
'db_table_comment': '╤яшёюъ ёюЄЁєфэшъют',
|
||||||
|
'managed': False,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='DictPosition',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('name', models.CharField(db_comment='═ршьхэютрэшх фюыцэюёЄш', max_length=1024)),
|
||||||
|
('order_position', models.IntegerField()),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'db_table': 'dict_position',
|
||||||
|
'db_table_comment': '╤яЁртюўэшъ фюыцэюёЄхщ',
|
||||||
|
'managed': False,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='MatrixCompetences',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'db_table': 'matrix_competences',
|
||||||
|
'db_table_comment': '╠рЄЁшЎр ъюьяхЄхэЎшщ',
|
||||||
|
'managed': False,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Sprstaff',
|
||||||
|
fields=[
|
||||||
|
('tn', models.SmallIntegerField(db_comment='╥рсхы№э√щ эюьхЁ', primary_key=True, serialize=False)),
|
||||||
|
('login', models.CharField(blank=True, db_comment='ыюушэ(sAMAccountName)', max_length=100, null=True)),
|
||||||
|
('fio', models.CharField(blank=True, db_column='FIO', db_comment='╘╚╬(cn)', max_length=300, null=True)),
|
||||||
|
('f', models.CharField(blank=True, db_column='F', db_comment='╘рьшыш\xa0(sn)', max_length=100, null=True)),
|
||||||
|
('i', models.CharField(blank=True, db_column='I', db_comment='╚ь\xa0', max_length=100, null=True)),
|
||||||
|
('o', models.CharField(blank=True, db_column='O', db_comment='╬ЄўхёЄтю', max_length=100, null=True)),
|
||||||
|
('department', models.CharField(blank=True, db_comment='╬Єфхы(department)', max_length=500, null=True)),
|
||||||
|
('post', models.CharField(blank=True, db_comment='фюыцэюёЄ№(title)', max_length=500, null=True)),
|
||||||
|
('room', models.CharField(blank=True, db_comment='ърсшэхЄ(physicalDeliveryOfficeName)', max_length=20, null=True)),
|
||||||
|
('email', models.CharField(blank=True, db_comment='рфЁхё ¤ыхъЄЁюээющ яюўЄ√(mail)', max_length=50, null=True)),
|
||||||
|
('tel', models.CharField(blank=True, db_comment='уюЁюфёъющ ЄхыхЇюэ(telephoneNumber)', max_length=20, null=True)),
|
||||||
|
('iptel', models.CharField(blank=True, db_comment='тэєЄЁхээшщ ЄхыхЇюэ(OfficePhone)', max_length=20, null=True)),
|
||||||
|
('workstatus', models.CharField(blank=True, db_column='WorkStatus', db_comment='ёЄрЄєё', max_length=500, null=True)),
|
||||||
|
('datebegin', models.DateField(blank=True, db_column='DateBegin', db_comment='─рЄр яЁшхьр эр ЁрсюЄє', null=True)),
|
||||||
|
('dateend', models.DateField(blank=True, db_column='DateEnd', db_comment='─рЄр єтюы№эхэш\xa0', null=True)),
|
||||||
|
('workstatus2', models.CharField(blank=True, db_column='WorkStatus2', db_comment='ёЄрЄєё єўхЄэющ чряшёш(Enabled)', max_length=500, null=True)),
|
||||||
|
('workstatus3', models.TextField(blank=True, db_column='WorkStatus3', null=True)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'db_table': 'sprstaff',
|
||||||
|
'db_table_comment': '╤яшёюъ ёюЄЁєфэшъют',
|
||||||
|
'managed': False,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Table14',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('fio', models.CharField(blank=True, db_column='FIO', max_length=100, null=True)),
|
||||||
|
('col_2', models.CharField(blank=True, db_column='COL 2', max_length=30, null=True)),
|
||||||
|
('col_3', models.CharField(blank=True, db_column='COL 3', max_length=22, null=True)),
|
||||||
|
('col_4', models.CharField(blank=True, db_column='COL 4', max_length=23, null=True)),
|
||||||
|
('col_5', models.CharField(blank=True, db_column='COL 5', max_length=12, null=True)),
|
||||||
|
('col_6', models.CharField(blank=True, db_column='COL 6', max_length=7, null=True)),
|
||||||
|
('col_7', models.CharField(blank=True, db_column='COL 7', max_length=6, null=True)),
|
||||||
|
('col_8', models.CharField(blank=True, db_column='COL 8', max_length=6, null=True)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'db_table': 'table 14',
|
||||||
|
'managed': False,
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='EmployeeDepartment',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('department', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='userauth.dictdepartment')),
|
||||||
|
('employee', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='real_department', to='userauth.dictemployee')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Сотрудник и его реальный отдел',
|
||||||
|
'verbose_name_plural': 'Сотрудники и их реальные отделы',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
||||||
Whitespace-only changes.
+19
-3
@@ -1,6 +1,22 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from .models import *
|
from .models import *
|
||||||
|
import nested_admin
|
||||||
|
|
||||||
admin.site.register(Vote)
|
# admin.site.register(Vote)
|
||||||
admin.site.register(Question)
|
# admin.site.register(Question)
|
||||||
admin.site.register(Answer)
|
# admin.site.register(Answer)
|
||||||
|
|
||||||
|
class AnswerInline(nested_admin.NestedTabularInline):
|
||||||
|
model = Answer
|
||||||
|
extra = 1
|
||||||
|
fields = ('name', 'file')
|
||||||
|
|
||||||
|
class QuestionInline(nested_admin.NestedStackedInline):
|
||||||
|
model = Question
|
||||||
|
inlines = [AnswerInline]
|
||||||
|
extra = 1
|
||||||
|
fields = ('name', 'file')
|
||||||
|
|
||||||
|
@admin.register(Vote)
|
||||||
|
class VoteAdmin(nested_admin.NestedModelAdmin):
|
||||||
|
inlines = [QuestionInline]
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
# Generated by Django 4.2.3 on 2025-01-31 09:42
|
||||||
|
|
||||||
|
import datetime
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
|
||||||
|
]
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
# Generated by Django 4.2.3 on 2025-01-31 09:54
|
||||||
|
|
||||||
|
import datetime
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
('vote', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Answer',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('name', models.CharField(max_length=255)),
|
||||||
|
('file', models.FileField(blank=True, null=True, upload_to='vote/answer_files/')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Ответ',
|
||||||
|
'verbose_name_plural': 'Ответы',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Vote',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('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(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL, verbose_name='Создатель голосования')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Голосование',
|
||||||
|
'verbose_name_plural': 'Голосования',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Result',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('comment', models.TextField(blank=True, null=True)),
|
||||||
|
('answer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='vote.answer')),
|
||||||
|
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Результат',
|
||||||
|
'verbose_name_plural': 'Результаты',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Question',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('name', models.CharField(max_length=255)),
|
||||||
|
('file', models.ImageField(blank=True, null=True, upload_to='vote/question_images/')),
|
||||||
|
('numb', models.PositiveIntegerField()),
|
||||||
|
('settings', models.JSONField(default=dict, verbose_name='Json настроек голосования')),
|
||||||
|
('vote', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='questions', to='vote.vote')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Вопрос',
|
||||||
|
'verbose_name_plural': 'Вопросы',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='answer',
|
||||||
|
name='question',
|
||||||
|
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='answers', to='vote.question'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
# Generated by Django 4.2.3 on 2025-02-11 12:02
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
|
||||||
|
('vote', '0002_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='vote',
|
||||||
|
name='news',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='navigation.news', verbose_name='Новость'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
# Generated by Django 5.1.6 on 2025-06-19 08:01
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("vote", "0003_vote_news"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="answer",
|
||||||
|
name="file",
|
||||||
|
field=models.FileField(
|
||||||
|
blank=True, null=True, upload_to="vote/answer_files/", verbose_name="Картинка"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="answer",
|
||||||
|
name="name",
|
||||||
|
field=models.CharField(max_length=255, verbose_name="Ответ"),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="question",
|
||||||
|
name="file",
|
||||||
|
field=models.ImageField(
|
||||||
|
blank=True, null=True, upload_to="vote/question_images/", verbose_name="Картинка"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="question",
|
||||||
|
name="name",
|
||||||
|
field=models.CharField(max_length=255, verbose_name="Вопрос"),
|
||||||
|
),
|
||||||
|
]
|
||||||
Whitespace-only changes.
@@ -26,9 +26,9 @@ class Vote(models.Model):
|
|||||||
verbose_name_plural = "Голосования"
|
verbose_name_plural = "Голосования"
|
||||||
|
|
||||||
class Question(models.Model):
|
class Question(models.Model):
|
||||||
name = models.CharField(max_length=255)
|
name = models.CharField(max_length=255, verbose_name="Вопрос")
|
||||||
vote = models.ForeignKey(Vote, related_name='questions', on_delete=models.CASCADE)
|
vote = models.ForeignKey(Vote, related_name='questions', on_delete=models.CASCADE)
|
||||||
file = models.ImageField(upload_to='vote/question_images/', null=True, blank=True)
|
file = models.ImageField(upload_to='vote/question_images/', null=True, blank=True,verbose_name='Картинка')
|
||||||
numb = models.PositiveIntegerField()
|
numb = models.PositiveIntegerField()
|
||||||
settings = models.JSONField(default=dict, verbose_name='Json настроек голосования')
|
settings = models.JSONField(default=dict, verbose_name='Json настроек голосования')
|
||||||
|
|
||||||
@@ -40,8 +40,8 @@ class Question(models.Model):
|
|||||||
verbose_name_plural = "Вопросы"
|
verbose_name_plural = "Вопросы"
|
||||||
|
|
||||||
class Answer(models.Model):
|
class Answer(models.Model):
|
||||||
name = models.CharField(max_length=255)
|
name = models.CharField(max_length=255, verbose_name='Ответ')
|
||||||
file = models.FileField(upload_to='vote/answer_files/', null=True, blank=True)
|
file = models.FileField(upload_to='vote/answer_files/', null=True, blank=True,verbose_name='Картинка')
|
||||||
question = models.ForeignKey(Question, related_name='answers', on_delete=models.CASCADE)
|
question = models.ForeignKey(Question, related_name='answers', on_delete=models.CASCADE)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
|||||||
@@ -269,7 +269,8 @@ class VoteCreate(APIView):
|
|||||||
text=f'Пройдите голосование "{vote_url}" до {formatted_date}',
|
text=f'Пройдите голосование "{vote_url}" до {formatted_date}',
|
||||||
cdate=request.data["startDate"],
|
cdate=request.data["startDate"],
|
||||||
author=request.user,
|
author=request.user,
|
||||||
link=os.path.join("defaultimg", "vote.png"),
|
link = None
|
||||||
|
# link=os.path.join("defaultimg", "vote.png"),
|
||||||
)
|
)
|
||||||
news.save()
|
news.save()
|
||||||
vote.news = news
|
vote.news = news
|
||||||
|
|||||||
+10
-2
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "front",
|
"name": "front",
|
||||||
"version": "1.0.2",
|
"version": "1.2.2",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
@@ -36,7 +36,15 @@
|
|||||||
"vue3-autocounter": "^1.0.8",
|
"vue3-autocounter": "^1.0.8",
|
||||||
"vuelidate": "^0.7.7",
|
"vuelidate": "^0.7.7",
|
||||||
"vuetify": "^3.7.8",
|
"vuetify": "^3.7.8",
|
||||||
"webfontloader": "^1.6.28"
|
"webfontloader": "^1.6.28",
|
||||||
|
"@fullcalendar/core": "^6.1.19",
|
||||||
|
"@fullcalendar/daygrid": "^6.1.19",
|
||||||
|
"@fullcalendar/interaction": "^6.1.19",
|
||||||
|
"@fullcalendar/multimonth": "^6.1.19",
|
||||||
|
"@fullcalendar/timegrid": "^6.1.19",
|
||||||
|
"@fullcalendar/list": "6.1.19",
|
||||||
|
"@fullcalendar/vue3": "^6.1.19",
|
||||||
|
"@fullcalendar/rrule": "^6.1.15"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@commitlint/cli": "^19.7.1",
|
"@commitlint/cli": "^19.7.1",
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import { useAccountStore } from '@/store/AccountStore';
|
|||||||
* Получаем информацию о юзере из стора.
|
* Получаем информацию о юзере из стора.
|
||||||
*/
|
*/
|
||||||
const accountStore = useAccountStore();
|
const accountStore = useAccountStore();
|
||||||
console.log("dfdffdfdf");
|
|
||||||
accountStore.setUser(accountStore.getuserFromStorage());
|
accountStore.setUser(accountStore.getuserFromStorage());
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -161,9 +161,6 @@ export default {
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
console.log(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
<v-row class="flex-grow-0">
|
<v-row class="flex-grow-0">
|
||||||
<v-col class="d-flex flex-column ">
|
<v-col class="d-flex flex-column ">
|
||||||
<v-img
|
<v-img
|
||||||
:src="`${burl}${news.link}`"
|
:src="news.link ? `${burl}${news.link}` : defaultImage"
|
||||||
height="170px"
|
height="170px"
|
||||||
width="92%"
|
width="92%"
|
||||||
class="mx-auto"
|
class="mx-auto"
|
||||||
@@ -41,6 +41,7 @@
|
|||||||
<v-icon
|
<v-icon
|
||||||
size="x-small"
|
size="x-small"
|
||||||
class="me-1"
|
class="me-1"
|
||||||
|
color="teal-darken-4"
|
||||||
:icon="news.scores.filter(e=> e.user==accountStore.user.login && e.score == true).length>0?'mdi-thumb-up':'mdi-thumb-up-outline'"
|
:icon="news.scores.filter(e=> e.user==accountStore.user.login && e.score == true).length>0?'mdi-thumb-up':'mdi-thumb-up-outline'"
|
||||||
@click="toggleIncrementLike(news.id, true)"
|
@click="toggleIncrementLike(news.id, true)"
|
||||||
/>
|
/>
|
||||||
@@ -53,6 +54,7 @@
|
|||||||
<v-icon
|
<v-icon
|
||||||
size="x-small"
|
size="x-small"
|
||||||
class="me-1"
|
class="me-1"
|
||||||
|
color="teal-darken-4"
|
||||||
:icon="news.scores.filter(e=> e.user==accountStore.user.login && e.score == false).length>0?'mdi-thumb-down':'mdi-thumb-down-outline'"
|
:icon="news.scores.filter(e=> e.user==accountStore.user.login && e.score == false).length>0?'mdi-thumb-down':'mdi-thumb-down-outline'"
|
||||||
@click="toggleIncrementLike(news.id, false)"
|
@click="toggleIncrementLike(news.id, false)"
|
||||||
/>
|
/>
|
||||||
@@ -65,6 +67,7 @@
|
|||||||
<v-icon
|
<v-icon
|
||||||
size="x-small"
|
size="x-small"
|
||||||
class="me-1"
|
class="me-1"
|
||||||
|
color="teal-darken-4"
|
||||||
icon="mdi-message-text-outline"
|
icon="mdi-message-text-outline"
|
||||||
/>
|
/>
|
||||||
<span class="subheading">
|
<span class="subheading">
|
||||||
@@ -76,6 +79,7 @@
|
|||||||
<v-icon
|
<v-icon
|
||||||
size="x-small"
|
size="x-small"
|
||||||
class="me-1 mb-1"
|
class="me-1 mb-1"
|
||||||
|
color="teal-darken-4"
|
||||||
icon="mdi-image"
|
icon="mdi-image"
|
||||||
/>
|
/>
|
||||||
<span class="subheading">
|
<span class="subheading">
|
||||||
@@ -102,8 +106,7 @@
|
|||||||
<v-row class="flex-grow-0 ma-0">
|
<v-row class="flex-grow-0 ma-0">
|
||||||
<v-col class="d-flex justify-space-between">
|
<v-col class="d-flex justify-space-between">
|
||||||
<v-btn
|
<v-btn
|
||||||
color="more_details_btn"
|
color="teal-darken-4"
|
||||||
|
|
||||||
:to='`/newsfull?id=${news.id}`'
|
:to='`/newsfull?id=${news.id}`'
|
||||||
size="small"
|
size="small"
|
||||||
rounded="xl"
|
rounded="xl"
|
||||||
@@ -125,6 +128,7 @@ import { axiosApiInstance } from '@/utils/axios-api'
|
|||||||
import {splitname} from '@/utils/universal_functions'
|
import {splitname} from '@/utils/universal_functions'
|
||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
import icoUser from '@/components/UI/fiousercard/icoUser.vue'
|
import icoUser from '@/components/UI/fiousercard/icoUser.vue'
|
||||||
|
import defaultImage from '@/assets/emblem.png'
|
||||||
|
|
||||||
const accountStore = useAccountStore()
|
const accountStore = useAccountStore()
|
||||||
|
|
||||||
@@ -179,7 +183,8 @@ export default {
|
|||||||
splitname,
|
splitname,
|
||||||
toggleIncrementLike,
|
toggleIncrementLike,
|
||||||
openOneImg,
|
openOneImg,
|
||||||
formatDate
|
formatDate,
|
||||||
|
defaultImage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,12 +12,19 @@
|
|||||||
>
|
>
|
||||||
<template #prepend-item>
|
<template #prepend-item>
|
||||||
<v-checkbox
|
<v-checkbox
|
||||||
:model-value="(selectedEmployees?.length || 0) === allEmployees.length"
|
:model-value="(selectedEmployees?.length || 0) === availableEmployees.length"
|
||||||
class="pa-0"
|
class="pa-0"
|
||||||
label="Все"
|
label="Все"
|
||||||
@click="handleSelectAll"
|
@click="handleSelectAll"
|
||||||
></v-checkbox>
|
></v-checkbox>
|
||||||
</template>
|
</template>
|
||||||
|
<template #no-data>
|
||||||
|
<v-list-item>
|
||||||
|
<v-list-item-title class="text-grey">
|
||||||
|
Нет доступных данных
|
||||||
|
</v-list-item-title>
|
||||||
|
</v-list-item>
|
||||||
|
</template>
|
||||||
<template #selection="{ item }">
|
<template #selection="{ item }">
|
||||||
<v-chip :prepend-avatar="checkremote(`${spravURL}${item.raw.login}.jpg`)">
|
<v-chip :prepend-avatar="checkremote(`${spravURL}${item.raw.login}.jpg`)">
|
||||||
{{ item.raw.familyname }}
|
{{ item.raw.familyname }}
|
||||||
@@ -30,17 +37,35 @@
|
|||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<v-list-item
|
<v-list-item
|
||||||
:append-avatar="checkremote(`${spravURL}${data.item.raw.login}.jpg`)
|
:append-avatar="checkremote(`${spravURL}${data.item.raw.login}.jpg`)"
|
||||||
" density="compact" slim @click="onEmployeesChange(data.item.raw.id)"
|
density="compact"
|
||||||
|
slim
|
||||||
|
@click="onEmployeesChange(data.item.raw.id)"
|
||||||
|
:disabled="isEmployeeAssigned(data.item.raw.id)"
|
||||||
|
:class="{ 'opacity-50': isEmployeeAssigned(data.item.raw.id) }"
|
||||||
>
|
>
|
||||||
<template #prepend>
|
<template #prepend>
|
||||||
<v-checkbox
|
<v-checkbox
|
||||||
:model-value="selectedEmployees.includes(data.item.raw.id)"
|
:model-value="selectedEmployees.includes(data.item.raw.id)"
|
||||||
|
:disabled="isEmployeeAssigned(data.item.raw.id)"
|
||||||
density="compact"
|
density="compact"
|
||||||
hide-details
|
hide-details
|
||||||
></v-checkbox>
|
></v-checkbox>
|
||||||
</template>
|
</template>
|
||||||
<v-list-item-title class="text-third" v-text="data.item.raw.fio"></v-list-item-title>
|
<v-list-item-title
|
||||||
|
class="text-third"
|
||||||
|
:class="{ 'text-orange-darken-2': isEmployeeAssigned(data.item.raw.id) }"
|
||||||
|
>
|
||||||
|
{{ data.item.raw.fio }}
|
||||||
|
<v-icon
|
||||||
|
v-if="isEmployeeAssigned(data.item.raw.id)"
|
||||||
|
color="orange-darken-2"
|
||||||
|
size="small"
|
||||||
|
class="ml-2"
|
||||||
|
>
|
||||||
|
mdi-check-circle
|
||||||
|
</v-icon>
|
||||||
|
</v-list-item-title>
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
@@ -48,21 +73,45 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { computed, ref } from 'vue';
|
import { computed, ref, watch } from 'vue';
|
||||||
import { getEmployees, spravURL } from '@/utils/axios-api';
|
import { getEmployees, getUsers, spravURL } from '@/utils/axios-api';
|
||||||
import { checkremote } from '@/utils/universal_functions.js';
|
import { checkremote } from '@/utils/universal_functions.js';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
modelValue: Array,
|
modelValue: Array,
|
||||||
|
assignedEmployees: {
|
||||||
|
type: Array,
|
||||||
|
default: () => []
|
||||||
|
},
|
||||||
|
useUsersApi: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
}
|
||||||
},
|
},
|
||||||
emits: ['update:modelValue'],
|
emits: ['update:modelValue'],
|
||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
const selectedEmployees = ref(props.modelValue || []);
|
const selectedEmployees = ref(props.modelValue || []);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.modelValue,
|
||||||
|
(newValue) => {
|
||||||
|
if (newValue !== undefined) {
|
||||||
|
selectedEmployees.value = [...newValue];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ deep: true },
|
||||||
|
);
|
||||||
|
|
||||||
const groupedEmployees = ref([]);
|
const groupedEmployees = ref([]);
|
||||||
const allEmployees = computed(() => [...groupedEmployees.value]);
|
const allEmployees = computed(() => [...groupedEmployees.value]);
|
||||||
|
|
||||||
getEmployees().then((r) => (groupedEmployees.value = r));
|
const availableEmployees = computed(() =>
|
||||||
|
allEmployees.value.filter(emp => !isEmployeeAssigned(emp.id))
|
||||||
|
);
|
||||||
|
|
||||||
|
// Используем getUsers если установлен флаг useUsersApi, иначе используем getEmployees
|
||||||
|
(props.useUsersApi ? getUsers() : getEmployees()).then((r) => (groupedEmployees.value = r));
|
||||||
|
|
||||||
const allEmployeesgroupedbydep = computed(() => {
|
const allEmployeesgroupedbydep = computed(() => {
|
||||||
let groupped = [];
|
let groupped = [];
|
||||||
@@ -75,7 +124,15 @@ export default {
|
|||||||
return groupped;
|
return groupped;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const isEmployeeAssigned = (employeeId) => {
|
||||||
|
return props.assignedEmployees.includes(employeeId);
|
||||||
|
};
|
||||||
|
|
||||||
const onEmployeesChange = (employeeId) => {
|
const onEmployeesChange = (employeeId) => {
|
||||||
|
if (isEmployeeAssigned(employeeId)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const index = selectedEmployees.value.indexOf(employeeId);
|
const index = selectedEmployees.value.indexOf(employeeId);
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
selectedEmployees.value.splice(index, 1);
|
selectedEmployees.value.splice(index, 1);
|
||||||
@@ -86,10 +143,12 @@ export default {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSelectAll = () => {
|
const handleSelectAll = () => {
|
||||||
if (selectedEmployees.value.length === allEmployees.value.length) {
|
const unassignedEmployees = availableEmployees.value.map(emp => emp.id);
|
||||||
|
|
||||||
|
if (selectedEmployees.value.length === unassignedEmployees.length) {
|
||||||
selectedEmployees.value = [];
|
selectedEmployees.value = [];
|
||||||
} else {
|
} else {
|
||||||
selectedEmployees.value = allEmployees.value.map(emp => emp.id);
|
selectedEmployees.value = unassignedEmployees;
|
||||||
}
|
}
|
||||||
emit('update:modelValue', selectedEmployees.value);
|
emit('update:modelValue', selectedEmployees.value);
|
||||||
};
|
};
|
||||||
@@ -101,7 +160,9 @@ export default {
|
|||||||
handleSelectAll,
|
handleSelectAll,
|
||||||
checkremote,
|
checkremote,
|
||||||
spravURL,
|
spravURL,
|
||||||
allEmployees
|
allEmployees,
|
||||||
|
availableEmployees,
|
||||||
|
isEmployeeAssigned
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
v-model="selectedDate"
|
v-model="selectedDate"
|
||||||
show-adjacent-months
|
show-adjacent-months
|
||||||
hide-header
|
hide-header
|
||||||
|
:min="new Date().toISOString().slice(0, 10)"
|
||||||
@update:modelValue="dateStart"
|
@update:modelValue="dateStart"
|
||||||
border
|
border
|
||||||
/>
|
/>
|
||||||
@@ -53,25 +54,22 @@ export default {
|
|||||||
props: {
|
props: {
|
||||||
datedefault: {
|
datedefault: {
|
||||||
type: Date,
|
type: Date,
|
||||||
default: ''
|
default: () => new Date()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
setup(props, {emit}) {
|
setup(props, {emit}) {
|
||||||
const appStore = useAppStore()
|
const appStore = useAppStore()
|
||||||
const maxdate = formatDash(new Date())
|
|
||||||
const menudate = ref(false)
|
const menudate = ref(false)
|
||||||
const selectedDate = ref(null)
|
const selectedDate = ref(props.datedefault ? formatDash(new Date(props.datedefault)) : formatDash(new Date()))
|
||||||
|
|
||||||
const dateStart = () => {
|
const dateStart = () => {
|
||||||
emit('returndate', selectedDate.value)
|
if (selectedDate.value) {
|
||||||
menudate.value=false
|
emit('returndate', selectedDate.value)
|
||||||
|
menudate.value = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
menudate,
|
menudate,
|
||||||
selectedDate,
|
selectedDate,
|
||||||
|
|||||||
@@ -1,151 +1,431 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-col>
|
<v-col>
|
||||||
<v-file-input
|
<div class="custom-file-input-wrapper">
|
||||||
label="Файлы"
|
<label class="v-label v-field-label v-field-label--floating">
|
||||||
chips
|
Добавить файл (размер файла не должен превышать 2Мб)
|
||||||
multiple
|
</label>
|
||||||
v-model="eventFiles"
|
|
||||||
density="compact"
|
|
||||||
variant="outlined"
|
|
||||||
@click.stop=""
|
|
||||||
>
|
|
||||||
<template v-slot:selection="{ fileNames }">
|
|
||||||
<template v-for="(fileName, index) in fileNames" :key="fileName">
|
|
||||||
<v-chip
|
|
||||||
v-if="index < 4"
|
|
||||||
class="me-2"
|
|
||||||
color="teal-darken-3"
|
|
||||||
size="small"
|
|
||||||
label
|
|
||||||
>
|
|
||||||
{{ fileName }}
|
|
||||||
</v-chip>
|
|
||||||
|
|
||||||
<span
|
<!-- Область, куда можно перетащить файлы -->
|
||||||
v-else-if="index === 4"
|
<div
|
||||||
class="text-overline text-grey-darken-3 mx-2"
|
class="file-input-area"
|
||||||
>
|
@click="triggerFileInput"
|
||||||
+{{ files.length - 4 }} файла(ов)
|
@drop="handleDrop"
|
||||||
</span>
|
@dragover.prevent
|
||||||
</template>
|
@dragenter.prevent
|
||||||
</template>
|
>
|
||||||
</v-file-input>
|
<!-- Кастомные чипы новых файлов ВНУТРИ "инпута" -->
|
||||||
|
<div class="chips-container" v-if="localNewFiles.length > 0">
|
||||||
|
<template v-for="(file, index) in localNewFiles" :key="getFileKey(file, index)">
|
||||||
|
<v-chip
|
||||||
|
class="file-chip"
|
||||||
|
color="grey-darken-1"
|
||||||
|
size="small"
|
||||||
|
label
|
||||||
|
closable
|
||||||
|
@click:close="removeNewFile(index)"
|
||||||
|
>
|
||||||
|
<v-icon start size="small">mdi-file-plus</v-icon>
|
||||||
|
<span class="text-truncate" style="max-width: 100px">
|
||||||
|
{{ file.name }}({{ formatFileSize(file.size) }})
|
||||||
|
</span>
|
||||||
|
</v-chip>
|
||||||
|
</template>
|
||||||
|
<span class="file-counter text-caption text-grey">
|
||||||
|
{{ localNewFiles.length }}/{{ MAX_NEW_FILES }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Плейсхолдер, когда файлов нет -->
|
||||||
|
<div v-else class="placeholder">
|
||||||
|
<v-icon class="me-1">mdi-paperclip</v-icon>
|
||||||
|
<span class="text-caption">Перетащите файлы сюда или кликните для выбора</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Скрытый настоящий input -->
|
||||||
|
<input
|
||||||
|
ref="fileInputRef"
|
||||||
|
type="file"
|
||||||
|
multiple
|
||||||
|
style="display: none"
|
||||||
|
@change="handleFileSelect"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Область ошибок -->
|
||||||
|
<div class="error-messages" v-if="errorMessages.length">
|
||||||
|
<div v-for="(error, index) in errorMessages" :key="index" class="text-caption text-error">
|
||||||
|
{{ error }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Существующие файлы из БД -->
|
||||||
|
<div class="existing-files-section mb-4">
|
||||||
|
<div class="text-caption text-grey mb-2">Прикрепленные файлы:</div>
|
||||||
|
<div>
|
||||||
|
<template v-if="existingFiles.length">
|
||||||
|
<v-chip
|
||||||
|
v-for="file in existingFiles"
|
||||||
|
:key="file.id"
|
||||||
|
class="me-2 mb-1 "
|
||||||
|
color="teal-darken-3"
|
||||||
|
|
||||||
|
label
|
||||||
|
@click:close="removeExistingFile(file.id)"
|
||||||
|
>
|
||||||
|
<v-icon start class="pb-1">{{ getFileIcon(file) }}</v-icon>
|
||||||
|
{{ getFileName(file) }}
|
||||||
|
<v-icon
|
||||||
|
class="ms-1 download-icon"
|
||||||
|
@click.stop="downloadExistingFile(file)"
|
||||||
|
title="Скачать файл"
|
||||||
|
>
|
||||||
|
mdi-download
|
||||||
|
</v-icon>
|
||||||
|
<v-icon
|
||||||
|
class="ms-1 close-icon"
|
||||||
|
@click.stop="removeExistingFile(file.id)"
|
||||||
|
title="Удалить файл"
|
||||||
|
>
|
||||||
|
mdi-close
|
||||||
|
</v-icon>
|
||||||
|
</v-chip>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<span class="text-caption text-grey">Файлов нет</span>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</v-col>
|
</v-col>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { computed, ref } from "vue";
|
import { computed, ref, watch } from 'vue';
|
||||||
import { get_name } from "@/utils/universal_functions";
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
files: {
|
files: {
|
||||||
type: Object,
|
type: Array,
|
||||||
default: () => {},
|
default: () => [],
|
||||||
|
},
|
||||||
|
newFiles: {
|
||||||
|
type: Array,
|
||||||
|
default: [],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
emits: ['update:files', 'update:newFiles', 'postFiles'],
|
||||||
|
|
||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
|
const localNewFiles = ref([]);
|
||||||
|
const errorMessages = ref([]);
|
||||||
|
const MAX_FILE_SIZE = 2 * 1024 * 1024; // 2 МБ
|
||||||
|
const MAX_NEW_FILES = 5;
|
||||||
|
|
||||||
const propsFiles = computed({
|
const fileInputRef = ref(null);
|
||||||
get: () => props.files,
|
|
||||||
set: (value) => emit("update:files", value),
|
|
||||||
});
|
|
||||||
|
|
||||||
const arrFiles = ref([]);
|
watch(
|
||||||
|
() => props.newFiles,
|
||||||
const eventFiles = computed({
|
(newVal) => {
|
||||||
get() {
|
localNewFiles.value = Array.isArray(newVal) ? [...newVal] : [];
|
||||||
propsFiles.value.forEach((e) =>
|
|
||||||
{
|
|
||||||
|
|
||||||
arrFiles.value.push(
|
|
||||||
dataURLtoFile(
|
|
||||||
"data:text/plain;base64,aGVsbG8gd29ybGQ=",
|
|
||||||
get_name(decodeURI(e.file))
|
|
||||||
)
|
|
||||||
)}
|
|
||||||
);
|
|
||||||
return arrFiles.value;
|
|
||||||
},
|
},
|
||||||
|
{ immediate: true },
|
||||||
|
);
|
||||||
|
|
||||||
set(newValue) {
|
// Существующие файлы из event.files
|
||||||
let newFile = []
|
const existingFiles = computed(() => (Array.isArray(props.files) ? props.files : []));
|
||||||
arrFiles.value = [];
|
|
||||||
if (newValue.length == 0) {
|
|
||||||
arrFiles.value = [];
|
|
||||||
propsFiles.value = [];
|
|
||||||
} else {
|
|
||||||
newValue.forEach((e) => {
|
|
||||||
arrFiles.value.push(e)
|
|
||||||
newFile.push(e)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
emit("postFiles", newFile);
|
const triggerFileInput = () => {
|
||||||
|
if (fileInputRef.value) {
|
||||||
|
fileInputRef.value.click();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleFileSelect = (event) => {
|
||||||
|
const files = Array.from(event.target.files || []);
|
||||||
|
if (files.length > 0) {
|
||||||
|
handleFilesChange(files);
|
||||||
|
}
|
||||||
|
// Очищаем input для возможности выбора тех же файлов снова
|
||||||
|
event.target.value = '';
|
||||||
|
};
|
||||||
|
|
||||||
},
|
// Обработка drag & drop
|
||||||
});
|
const handleDrop = (event) => {
|
||||||
//
|
event.preventDefault();
|
||||||
|
const files = Array.from(event.dataTransfer.files || []);
|
||||||
|
if (files.length > 0) {
|
||||||
|
handleFilesChange(files);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
function dataURLtoFile(dataurl, filename) {
|
const formatFileSize = (bytes) => {
|
||||||
var arr = dataurl.split(","),
|
if (bytes === 0) return '0 Б';
|
||||||
mime = arr[0].match(/:(.*?);/)[1],
|
const k = 1024;
|
||||||
bstr = atob(arr[1]),
|
const sizes = ['Б', 'КБ', 'МБ', 'ГБ'];
|
||||||
n = bstr.length,
|
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||||
u8arr = new Uint8Array(n);
|
return parseFloat((bytes / Math.pow(k, i)).toFixed(1)) + ' ' + sizes[i];
|
||||||
|
};
|
||||||
|
|
||||||
while (n--) {
|
const validateFiles = (files) => {
|
||||||
u8arr[n] = bstr.charCodeAt(n);
|
errorMessages.value = [];
|
||||||
|
|
||||||
|
const currentFiles = Array.isArray(localNewFiles.value) ? localNewFiles.value : [];
|
||||||
|
const totalFiles = currentFiles.length + files.length;
|
||||||
|
|
||||||
|
// Проверка количества
|
||||||
|
if (totalFiles > MAX_NEW_FILES) {
|
||||||
|
errorMessages.value.push(`Можно добавить не более ${MAX_NEW_FILES} файлов`);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new File([u8arr], filename, { type: mime });
|
// Проверка размера
|
||||||
}
|
const oversizedFiles = files.filter((file) => file.size > MAX_FILE_SIZE);
|
||||||
|
if (oversizedFiles.length > 0) {
|
||||||
|
errorMessages.value.push(
|
||||||
|
`Следующие файлы превышают 2 МБ: ${oversizedFiles.map((f) => f.name).join(', ')}`,
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
// const eventFiles = computed({
|
const getFileKey = (file, index) => {
|
||||||
// get() {
|
return file instanceof File
|
||||||
// if (propsFiles.value.length > 0) {
|
? `${file.name}-${file.size}-${file.lastModified}`
|
||||||
// propsFiles.value.forEach((e) =>
|
: file.id || index;
|
||||||
// files.value.push(
|
};
|
||||||
// dataURLtoFile(
|
|
||||||
// "data:text/plain;base64,aGVsbG8gd29ybGQ=",
|
|
||||||
// get_name(decodeURI(e.file))
|
|
||||||
// )
|
|
||||||
// )
|
|
||||||
// );
|
|
||||||
// // let file = dataURLtoFile(
|
|
||||||
// // "data:text/plain;base64,aGVsbG8gd29ybGQ=",
|
|
||||||
// // get_name(
|
|
||||||
// // decodeURI(propsFiles.value.event.files[0].file)
|
|
||||||
// // )
|
|
||||||
// // );
|
|
||||||
|
|
||||||
// // files.value.push(file);
|
// Получаем имя файла из объекта файла
|
||||||
// }
|
const getFileName = (fileData) => {
|
||||||
|
if (fileData instanceof File) {
|
||||||
|
return cleanFileName(fileData.name);
|
||||||
|
}
|
||||||
|
// Для существующих файлов с бэка - извлекаем имя из пути
|
||||||
|
if (fileData.file) {
|
||||||
|
try {
|
||||||
|
const filePath = fileData.file.split('?')[0]; // Убираем параметры
|
||||||
|
const fileName = filePath.split('/').pop(); // Берем последнюю часть пути
|
||||||
|
return cleanFileName(fileName) || 'Файл';
|
||||||
|
} catch {
|
||||||
|
return 'Файл';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return cleanFileName(fileData.name || 'Файл');
|
||||||
|
};
|
||||||
|
|
||||||
|
const cleanFileName = (fileName) => {
|
||||||
|
// Убираем суффиксы в скобках (1), (2) и т.д.
|
||||||
|
return fileName.replace(/\s*\(\d+\)(?=\.\w+$|$)/, '');
|
||||||
|
};
|
||||||
|
|
||||||
|
// Иконка в зависимости от типа файла
|
||||||
|
const getFileIcon = (fileData) => {
|
||||||
|
let fileName = '';
|
||||||
|
|
||||||
|
if (fileData instanceof File) {
|
||||||
|
fileName = fileData.name;
|
||||||
|
} else {
|
||||||
|
fileName = getFileName(fileData);
|
||||||
|
}
|
||||||
|
|
||||||
|
const extension = fileName.split('.').pop()?.toLowerCase() || '';
|
||||||
|
const iconMap = {
|
||||||
|
pdf: 'mdi-file-pdf',
|
||||||
|
doc: 'mdi-file-word',
|
||||||
|
docx: 'mdi-file-word',
|
||||||
|
xls: 'mdi-file-excel',
|
||||||
|
xlsx: 'mdi-file-excel',
|
||||||
|
jpg: 'mdi-file-image',
|
||||||
|
jpeg: 'mdi-file-image',
|
||||||
|
png: 'mdi-file-image',
|
||||||
|
gif: 'mdi-file-image',
|
||||||
|
svg: 'mdi-file-image',
|
||||||
|
zip: 'mdi-folder-zip',
|
||||||
|
rar: 'mdi-folder-zip',
|
||||||
|
'7z': 'mdi-folder-zip',
|
||||||
|
txt: 'mdi-file-document',
|
||||||
|
json: 'mdi-code-json',
|
||||||
|
js: 'mdi-language-javascript',
|
||||||
|
vue: 'mdi-vuejs',
|
||||||
|
html: 'mdi-language-html5',
|
||||||
|
css: 'mdi-language-css3',
|
||||||
|
};
|
||||||
|
return iconMap[extension] || 'mdi-file';
|
||||||
|
};
|
||||||
|
|
||||||
|
// Обработка изменения новых файлов
|
||||||
|
const handleFilesChange = (newFiles) => {
|
||||||
|
if (!newFiles || newFiles.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const validFiles = newFiles.filter((file) => file instanceof File);
|
||||||
|
|
||||||
|
if (validFiles.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Валидация
|
||||||
|
if (!validateFiles(validFiles)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// localNewFiles.value = [...validFiles];
|
||||||
|
const currentFiles = Array.isArray(localNewFiles.value) ? localNewFiles.value : [];
|
||||||
|
const updatedFiles = [...currentFiles, ...validFiles];
|
||||||
|
localNewFiles.value = updatedFiles;
|
||||||
|
|
||||||
|
emit('update:newFiles', updatedFiles);
|
||||||
|
emit('postFiles', updatedFiles);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Удаление существующего файла
|
||||||
|
const removeExistingFile = (fileId) => {
|
||||||
|
try {
|
||||||
|
// Создаем копию event и удаляем файл
|
||||||
|
const updatedFiles = existingFiles.value.filter((file) => file.id !== fileId);
|
||||||
|
// props.files = updatedFiles;
|
||||||
|
emit('update:files', updatedFiles);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Ошибка при удалении файла:', error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Удаление нового файла (еще не загруженного)
|
||||||
|
const removeNewFile = (index) => {
|
||||||
|
const updatedFiles = localNewFiles.value.filter((_, i) => i !== index);
|
||||||
|
localNewFiles.value = updatedFiles;
|
||||||
|
// localNewFiles.value.splice(index, 1);
|
||||||
|
// emit('postFiles', localNewFiles.value);
|
||||||
|
emit('update:newFiles', updatedFiles);
|
||||||
|
emit('postFiles', updatedFiles);
|
||||||
|
};
|
||||||
|
|
||||||
|
const downloadExistingFile = async (file) => {
|
||||||
|
try {
|
||||||
|
const getOriginalFileName = (filePath) => {
|
||||||
|
try {
|
||||||
|
const pathParts = filePath.split('/');
|
||||||
|
return pathParts[pathParts.length - 1];
|
||||||
|
} catch {
|
||||||
|
return 'file';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const fileName = getOriginalFileName(file.file);
|
||||||
|
const fileUrl = file.file;
|
||||||
|
// Создаем временную ссылку для скачивания
|
||||||
|
const link = document.createElement('a');
|
||||||
|
link.href = fileUrl;
|
||||||
|
link.download = fileName; // Указываем имя файла при скачивании
|
||||||
|
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
document.body.removeChild(link);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Ошибка при скачивании файла:', error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// return files.value;
|
|
||||||
// },
|
|
||||||
// set(newValue) {
|
|
||||||
// // console.log(newValue,'file')
|
|
||||||
// newValue.forEach((e) => {
|
|
||||||
// if (!files.value.some((l) => l.name == e.name.split(" ").join("_"))) {
|
|
||||||
// files.value.push(e);
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// if (newValue.length == 0) {
|
|
||||||
// files.value = [];
|
|
||||||
// propsFiles.value = [];
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// });
|
|
||||||
return {
|
return {
|
||||||
eventFiles,
|
localNewFiles,
|
||||||
arrFiles,
|
existingFiles,
|
||||||
|
handleFilesChange,
|
||||||
|
removeExistingFile,
|
||||||
|
removeNewFile,
|
||||||
|
getFileName,
|
||||||
|
getFileIcon,
|
||||||
|
formatFileSize,
|
||||||
|
errorMessages,
|
||||||
|
validateFiles,
|
||||||
|
getFileKey,
|
||||||
|
MAX_NEW_FILES,
|
||||||
|
fileInputRef,
|
||||||
|
handleFileSelect,
|
||||||
|
triggerFileInput,
|
||||||
|
handleDrop,
|
||||||
|
cleanFileName,
|
||||||
|
downloadExistingFile,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style></style>
|
<style scoped>
|
||||||
|
:deep(.v-chip) {
|
||||||
|
border-radius: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.custom-file-input-wrapper {
|
||||||
|
border: 1px solid rgba(0, 0, 0, 0.38);
|
||||||
|
border-radius: 4px;
|
||||||
|
padding: 12px;
|
||||||
|
position: relative;
|
||||||
|
background-color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.custom-file-input-wrapper:focus-within {
|
||||||
|
border-color: #1976d2;
|
||||||
|
border-width: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.file-input-area {
|
||||||
|
min-height: 40px;
|
||||||
|
cursor: pointer;
|
||||||
|
padding: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chips-container {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.file-chip {
|
||||||
|
max-width: 150px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.file-counter {
|
||||||
|
margin-left: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.placeholder {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
color: rgba(0, 0, 0, 0.6);
|
||||||
|
padding: 8px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.error-messages {
|
||||||
|
margin-top: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-error {
|
||||||
|
color: #d32f2f;
|
||||||
|
}
|
||||||
|
|
||||||
|
.existing-files-section {
|
||||||
|
border-top: 1px solid #e0e0e0;
|
||||||
|
padding-top: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.download-icon {
|
||||||
|
cursor: pointer;
|
||||||
|
opacity: 0.7;
|
||||||
|
transition: opacity 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.download-icon:hover {
|
||||||
|
opacity: 1;
|
||||||
|
color: #024e45;
|
||||||
|
}
|
||||||
|
|
||||||
|
.close-icon:hover {
|
||||||
|
opacity: 1;
|
||||||
|
color: #024e45 ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
</style>
|
||||||
@@ -4,10 +4,11 @@
|
|||||||
v-if="from_which == 'dialog-search'"
|
v-if="from_which == 'dialog-search'"
|
||||||
class="pl-4 h-100 text-left pa-2"
|
class="pl-4 h-100 text-left pa-2"
|
||||||
@click="open = true"
|
@click="open = true"
|
||||||
|
active-color="teal-darken-4"
|
||||||
>
|
>
|
||||||
<template v-slot:prepend>
|
<template v-slot:prepend>
|
||||||
<v-avatar
|
<v-avatar
|
||||||
color="grey-darken-3"
|
:color="'teal-darken-4'"
|
||||||
:image="checkremote(`${spravURL}${author.login}.jpg`)"
|
:image="checkremote(`${spravURL}${author.login}.jpg`)"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
@@ -23,16 +24,17 @@
|
|||||||
v-if="from_which == 'top-user'"
|
v-if="from_which == 'top-user'"
|
||||||
class="h-100 text-left pa-0 pl-0"
|
class="h-100 text-left pa-0 pl-0"
|
||||||
@click="open = true"
|
@click="open = true"
|
||||||
|
active-color="teal-darken-4"
|
||||||
>
|
>
|
||||||
<v-chip
|
<v-chip
|
||||||
class="cursor-pointer pa-0"
|
class="cursor-pointer pa-0"
|
||||||
variant="text"
|
variant="text"
|
||||||
label
|
label
|
||||||
color="grey-darken-3"
|
color="teal-darken-4"
|
||||||
size="small"
|
size="small"
|
||||||
>
|
>
|
||||||
<v-avatar
|
<v-avatar
|
||||||
color="grey-darken-3"
|
color="teal-darken-4"
|
||||||
:image="checkremote(`${spravURL}${author.login}.jpg`)"
|
:image="checkremote(`${spravURL}${author.login}.jpg`)"
|
||||||
class="mr-2"
|
class="mr-2"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
v-bind="attrs"
|
v-bind="attrs"
|
||||||
v-on="on"
|
v-on="on"
|
||||||
size="large"
|
size="large"
|
||||||
color="indigo"
|
color="teal-darken-4"
|
||||||
icon="mdi-owl"
|
icon="mdi-owl"
|
||||||
@click="menu = !menu"
|
@click="menu = !menu"
|
||||||
></v-icon>
|
></v-icon>
|
||||||
|
|||||||
@@ -1,98 +1,21 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-row no-gutters>
|
<v-row no-gutters>
|
||||||
<v-col class="flex-grow-0 d-flex flex-column">
|
<v-col class="flex-grow-0 d-flex flex-column">
|
||||||
<v-card class="h-100 rounded-0 d-flex flex-colmn" width="250">
|
<mini-calendar />
|
||||||
<v-row no-gutters class="flex-column">
|
|
||||||
<v-col class="flex-grow-0 px-2 pt-1">
|
|
||||||
<v-text-field
|
|
||||||
density="compact"
|
|
||||||
clearable
|
|
||||||
append-inner-icon="mdi-magnify"
|
|
||||||
hide-details
|
|
||||||
class="py-3"
|
|
||||||
label="Найти событие"
|
|
||||||
rows="1"
|
|
||||||
no-resize
|
|
||||||
variant="outlined"
|
|
||||||
/>
|
|
||||||
</v-col>
|
|
||||||
<v-col class="flex-grow-0 px-2">
|
|
||||||
<v-btn
|
|
||||||
type="submit"
|
|
||||||
class="text-subtitle-1 font-weight-light"
|
|
||||||
color="btn_text"
|
|
||||||
block
|
|
||||||
elevation="1"
|
|
||||||
@click="createEvent()"
|
|
||||||
>Создать событие</v-btn
|
|
||||||
>
|
|
||||||
<!-- {{eventFromCalendar}} -->
|
|
||||||
</v-col>
|
|
||||||
<v-col class="w100" lg="3">
|
|
||||||
<v-locale-provider locale="ru">
|
|
||||||
<v-date-picker
|
|
||||||
ref="cal"
|
|
||||||
v-model="selectdate"
|
|
||||||
color="btn_text"
|
|
||||||
class="rounded-0 minCal"
|
|
||||||
max-width="250"
|
|
||||||
hide-header
|
|
||||||
show-adjacent-months
|
|
||||||
@click="CheckingStore"
|
|
||||||
@update:month="getMonth"
|
|
||||||
@update:year="getYear"
|
|
||||||
>
|
|
||||||
</v-date-picker>
|
|
||||||
</v-locale-provider>
|
|
||||||
</v-col>
|
|
||||||
|
|
||||||
<v-col class="flex-column d-flex">
|
|
||||||
<v-row no-gutters class="h-0 overflow-auto flex-column flex-nowrap">
|
|
||||||
<v-col>
|
|
||||||
<calendar-my
|
|
||||||
:calendars="
|
|
||||||
calendarForMy.filter((e) => e.author == accountStore.user.is_idEmployee)
|
|
||||||
"
|
|
||||||
title="Мои календари"
|
|
||||||
@getCalendar="getCalendar"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<calendar-my
|
|
||||||
:calendars="
|
|
||||||
calendarForMy.filter((e) => e.author != accountStore.user.is_idEmployee)
|
|
||||||
"
|
|
||||||
title="Подписки"
|
|
||||||
/>
|
|
||||||
</v-col>
|
|
||||||
</v-row>
|
|
||||||
</v-col>
|
|
||||||
</v-row>
|
|
||||||
</v-card>
|
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col class="d-flex flex-column">
|
<v-col class="d-flex flex-column">
|
||||||
<calendar-full
|
<custom-calendar @openEventDialog="openEventDialog" />
|
||||||
:allEvent="calendarForMy.filter((e) => e.events.length > 0)"
|
|
||||||
@getEvent="createEvent"
|
|
||||||
@update:allEvent="infoEvent($event)"
|
|
||||||
/>
|
|
||||||
</v-col>
|
</v-col>
|
||||||
|
|
||||||
<!-- <v-navigation-drawer
|
<v-dialog v-model="showEventDialog" max-width="700">
|
||||||
v-model="drawer_right"
|
|
||||||
floating
|
|
||||||
permanent
|
|
||||||
location="right"
|
|
||||||
rail-width="400"
|
|
||||||
rail
|
|
||||||
>
|
|
||||||
</v-navigation-drawer> -->
|
|
||||||
<v-dialog v-model="showDialog" max-width="700">
|
|
||||||
<event-create
|
<event-create
|
||||||
@closeDialog="showDialog = false"
|
@closeDialog="closeEventDialog"
|
||||||
:eventCalendar="eventFromCalendar"
|
:eventCalendar="eventFromCalendar"
|
||||||
@update:eventCalendar="eventFromCalendar = $event"
|
:myCalendars="calendarStore.myCalendars"
|
||||||
@getCalendar="getCalendar"
|
@getCalendar="getCalendar"
|
||||||
|
@update:eventCalendar="eventFromCalendar = $event"
|
||||||
ref="createEvents"
|
ref="createEvents"
|
||||||
|
:key="eventKey"
|
||||||
/>
|
/>
|
||||||
</v-dialog>
|
</v-dialog>
|
||||||
</v-row>
|
</v-row>
|
||||||
@@ -102,26 +25,29 @@
|
|||||||
import { ref, onMounted, watch } from 'vue';
|
import { ref, onMounted, watch } from 'vue';
|
||||||
import { useWeekendsStore } from '@/store/WeekendsStore';
|
import { useWeekendsStore } from '@/store/WeekendsStore';
|
||||||
import EventCreate from '@/components/calendar_of_events/event-create.vue';
|
import EventCreate from '@/components/calendar_of_events/event-create.vue';
|
||||||
import CalendarMy from '@/components/calendar_of_events/calendar-my.vue';
|
import CustomCalendar from '@/components/calendar_of_events/UI_calendar/CustomCalendar.vue';
|
||||||
|
import { useCalendarStore } from '@/store/calendarStore';
|
||||||
|
import { storeToRefs } from 'pinia';
|
||||||
|
import MiniCalendar from '@/components/calendar_of_events/UI_calendar/MiniCalendar.vue';
|
||||||
import { axiosApiInstance } from '@/utils/axios-api';
|
import { axiosApiInstance } from '@/utils/axios-api';
|
||||||
import { useAccountStore } from '@/store/AccountStore';
|
import { useAccountStore } from '@/store/AccountStore';
|
||||||
import CalendarFull from '@/components/calendar_of_events/UI_calendar/calendarFull.vue';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: { EventCreate, CalendarMy, CalendarFull },
|
components: { EventCreate, MiniCalendar, CustomCalendar },
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
const accountStore = useAccountStore();
|
|
||||||
const showDialog = ref(false);
|
|
||||||
const week = useWeekendsStore();
|
const week = useWeekendsStore();
|
||||||
const drawer_right = ref(false);
|
|
||||||
const cal = ref(null);
|
|
||||||
const selectdate = ref(new Date());
|
const selectdate = ref(new Date());
|
||||||
const MyYear = ref(selectdate.value.getFullYear());
|
const MyYear = ref(selectdate.value.getFullYear());
|
||||||
const MyMonth = ref(selectdate.value.getMonth() + 1);
|
const MyMonth = ref(selectdate.value.getMonth() + 1);
|
||||||
const calendarForMy = ref([]);
|
const calendarForMy = ref([]);
|
||||||
const eventFromCalendar = ref({});
|
const eventFromCalendar = ref({});
|
||||||
const createEvents = ref(null);
|
const eventKey = ref(0);
|
||||||
|
const isClosingDialog = ref(false);
|
||||||
|
|
||||||
|
const calendarStore = useCalendarStore();
|
||||||
|
const accountStore = useAccountStore();
|
||||||
|
|
||||||
|
const { selectedDate, showEventDialog } = storeToRefs(calendarStore); // синхронизируем с date-picker
|
||||||
|
|
||||||
const getMonth = (month) => {
|
const getMonth = (month) => {
|
||||||
MyMonth.value = month + 1;
|
MyMonth.value = month + 1;
|
||||||
@@ -131,79 +57,59 @@ export default {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getCalendar = () => {
|
const getCalendar = () => {
|
||||||
axiosApiInstance.get(`api/calendar_of_events/my_calendars/`).then((res) => {
|
calendarStore.loadCalendars();
|
||||||
res.data.forEach((e) => (e.visible = accountStore.calendar.includes(e.id) ? false : true));
|
|
||||||
calendarForMy.value = res.data;
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
getCalendar();
|
const getEvent = (idEvent) => {
|
||||||
|
if (!idEvent) {
|
||||||
const getEvents = (idEvent, clik) => {
|
eventFromCalendar.value = createEmptyEvent();
|
||||||
axiosApiInstance
|
return;
|
||||||
.get(`api/calendar_of_events/my_events/${idEvent === undefined ? '' : `?id=${idEvent}`}`)
|
} else {
|
||||||
.then((res) => {
|
axiosApiInstance.get(`api/calendar_of_events/my_events/?id=${idEvent}`).then((res) => {
|
||||||
if (idEvent === undefined) {
|
|
||||||
res.data.event = {
|
|
||||||
name: '',
|
|
||||||
participant: [accountStore.user.is_idEmployee],
|
|
||||||
files: [],
|
|
||||||
date_start: new Date(),
|
|
||||||
date_end: new Date(),
|
|
||||||
period: null,
|
|
||||||
description: '',
|
|
||||||
calendar: null,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
eventFromCalendar.value = res.data;
|
eventFromCalendar.value = res.data;
|
||||||
|
calendarStore.openEventDialog();
|
||||||
if (clik) showDialog.value = true;
|
|
||||||
});
|
});
|
||||||
};
|
|
||||||
|
|
||||||
getEvents();
|
|
||||||
|
|
||||||
const createEvent = (idEv) => {
|
|
||||||
getEvents(idEv, true);
|
|
||||||
if (idEv) {
|
|
||||||
getCalendar();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const weekendsData = () => {
|
const createEmptyEvent = () => ({
|
||||||
cal.value.$el.querySelectorAll('.v-date-picker-month__day').forEach((e) => {
|
event: {
|
||||||
let datas = e.getAttribute('data-v-date');
|
name: '',
|
||||||
let weeks = new Date(datas).getDay() === 6 || new Date(datas).getDay() === 0;
|
participant: [accountStore.user.is_idEmployee],
|
||||||
if (weeks) {
|
files: [],
|
||||||
e.querySelectorAll('span').forEach((n) => {
|
date_start: new Date().toISOString(),
|
||||||
n.classList.add('text-red');
|
date_end: new Date().toISOString(),
|
||||||
});
|
period: null,
|
||||||
}
|
description: '',
|
||||||
if (MyMonth.value in week.week[MyYear.value]) {
|
calendar: null,
|
||||||
if (week.week[MyYear.value][MyMonth.value].includes(datas)) {
|
},
|
||||||
e.querySelectorAll('span').forEach((n) => {
|
});
|
||||||
n.classList.add('text-red');
|
|
||||||
if (n.classList.contains('text-red') && weeks) {
|
const openEventDialog = (selectedEvent) => {
|
||||||
n.classList.replace('text-red', 'text-black');
|
// Всегда сбрасываем данные перед открытием нового диалога
|
||||||
}
|
if (!selectedEvent) {
|
||||||
});
|
eventFromCalendar.value = createEmptyEvent();
|
||||||
}
|
eventKey.value++;
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
getEvent(selectedEvent?.event?.id);
|
||||||
|
calendarStore.openEventDialog();
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
getEvent();
|
||||||
week.getWeekend(MyYear.value);
|
week.getWeekend(MyYear.value);
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(
|
const closeEventDialog = () => {
|
||||||
() => week.week,
|
calendarStore.closeEventDialog();
|
||||||
(newValue) => {
|
|
||||||
if (newValue) {
|
// При ручном закрытии сбрасываем данные сразу
|
||||||
weekendsData();
|
setTimeout(() => {
|
||||||
}
|
eventFromCalendar.value = createEmptyEvent();
|
||||||
},
|
eventKey.value++;
|
||||||
);
|
}, 200);
|
||||||
|
};
|
||||||
|
|
||||||
const CheckingStore = () => {
|
const CheckingStore = () => {
|
||||||
if (MyYear.value in week.week) {
|
if (MyYear.value in week.week) {
|
||||||
@@ -213,44 +119,42 @@ export default {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const infoEvent = (i) => {
|
watch(
|
||||||
console.log(i, 'iiiiiiiiii');
|
() => calendarStore.showEventDialog,
|
||||||
};
|
(newValue, oldValue) => {
|
||||||
|
if (!newValue && oldValue) {
|
||||||
|
// Диалог был открыт и закрыт не через нашу кнопку
|
||||||
|
// Добавляем проверку чтобы не сбрасывать при инициализации
|
||||||
|
if (eventFromCalendar.value.event?.id) {
|
||||||
|
setTimeout(() => {
|
||||||
|
eventFromCalendar.value = createEmptyEvent();
|
||||||
|
eventKey.value++;
|
||||||
|
}, 200);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
drawer_right,
|
selectedDate,
|
||||||
selectdate,
|
|
||||||
cal,
|
|
||||||
getMonth,
|
getMonth,
|
||||||
getYear,
|
getYear,
|
||||||
weekendsData,
|
|
||||||
week,
|
week,
|
||||||
CheckingStore,
|
CheckingStore,
|
||||||
showDialog,
|
showEventDialog,
|
||||||
calendarForMy,
|
calendarForMy,
|
||||||
accountStore,
|
|
||||||
getCalendar,
|
getCalendar,
|
||||||
|
getEvent,
|
||||||
eventFromCalendar,
|
eventFromCalendar,
|
||||||
createEvent,
|
calendarStore,
|
||||||
infoEvent,
|
accountStore,
|
||||||
createEvents,
|
closeEventDialog,
|
||||||
|
openEventDialog,
|
||||||
|
createEmptyEvent,
|
||||||
|
eventKey,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style scoped></style>
|
||||||
.minCal .v-date-picker-month__day {
|
|
||||||
height: 31px;
|
|
||||||
width: 31px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.minCal .v-btn--icon.v-btn--density-default {
|
|
||||||
width: calc(var(--v-btn-height) + 12px);
|
|
||||||
height: calc(var(--v-btn-height) + 6px);
|
|
||||||
}
|
|
||||||
|
|
||||||
.minCal .v-btn__content {
|
|
||||||
font-weight: 410;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -0,0 +1,543 @@
|
|||||||
|
<template>
|
||||||
|
<v-col cols="12">
|
||||||
|
<v-card>
|
||||||
|
<v-card-text>
|
||||||
|
<!-- Контролы навигации -->
|
||||||
|
<v-row no-gutters class="mb-4" align="center" justify="space-between">
|
||||||
|
<v-col md="4" class="flex-grow-0 d-flex align-center">
|
||||||
|
<v-btn
|
||||||
|
v-show="!forHomePage"
|
||||||
|
variant="outlined"
|
||||||
|
class="text-subtitle-2 mr-2"
|
||||||
|
@click="handleToday"
|
||||||
|
density="comfortable"
|
||||||
|
>
|
||||||
|
Сегодня
|
||||||
|
</v-btn>
|
||||||
|
<v-btn
|
||||||
|
variant="text"
|
||||||
|
@click="handlePrev"
|
||||||
|
:elevation="0"
|
||||||
|
style="border-radius: 4px"
|
||||||
|
density="compact"
|
||||||
|
icon
|
||||||
|
>
|
||||||
|
<v-icon size="large">mdi-chevron-left</v-icon>
|
||||||
|
</v-btn>
|
||||||
|
|
||||||
|
<v-btn
|
||||||
|
variant="text"
|
||||||
|
@click="handleNext"
|
||||||
|
:elevation="0"
|
||||||
|
style="border-radius: 4px"
|
||||||
|
density="compact"
|
||||||
|
icon
|
||||||
|
>
|
||||||
|
<v-icon size="large">mdi-chevron-right</v-icon>
|
||||||
|
</v-btn>
|
||||||
|
<span v-if="!forHomePage" class="text-h6 text-no-wrap ml-2">
|
||||||
|
{{ currentTitle }}
|
||||||
|
</span>
|
||||||
|
<span v-else class="text-caption text-no-wrap ml-2">
|
||||||
|
{{ currentTitle }}
|
||||||
|
</span>
|
||||||
|
</v-col>
|
||||||
|
|
||||||
|
<v-col class="flex-grow-0 d-flex justify-end">
|
||||||
|
<v-btn-toggle
|
||||||
|
v-show="!forHomePage"
|
||||||
|
v-model="currentView"
|
||||||
|
mandatory
|
||||||
|
divided
|
||||||
|
variant="plain"
|
||||||
|
density="comfortable"
|
||||||
|
>
|
||||||
|
<v-btn value="timeGridDay">День</v-btn>
|
||||||
|
<v-btn value="timeGridWeek">Неделя</v-btn>
|
||||||
|
<v-btn value="dayGridMonth">Месяц</v-btn>
|
||||||
|
<v-btn value="multiMonthYear">Год</v-btn>
|
||||||
|
<v-btn value="listWeek">Расписание</v-btn>
|
||||||
|
</v-btn-toggle>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
<div class="flex-grow-1">
|
||||||
|
<!-- VCalendar -->
|
||||||
|
<FullCalendar ref="calendarRef" :options="calendarOptions" class="compact-calendar" />
|
||||||
|
</div>
|
||||||
|
</v-card-text>
|
||||||
|
</v-card>
|
||||||
|
</v-col>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
import { ref, watch, nextTick, computed } from 'vue';
|
||||||
|
import { storeToRefs } from 'pinia';
|
||||||
|
import dayGridPlugin from '@fullcalendar/daygrid';
|
||||||
|
import timeGridPlugin from '@fullcalendar/timegrid';
|
||||||
|
import multiMonthPlugin from '@fullcalendar/multimonth';
|
||||||
|
import interactionPlugin from '@fullcalendar/interaction';
|
||||||
|
import listPlugin from '@fullcalendar/list';
|
||||||
|
import ruLocale from '@fullcalendar/core/locales/ru';
|
||||||
|
import rrulePlugin from '@fullcalendar/rrule';
|
||||||
|
import { onMounted } from 'vue';
|
||||||
|
import { useCalendarStore } from '@/store/calendarStore';
|
||||||
|
import { useRecurrence } from '@/components/calendar_of_events/composables/useReccurrence';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'CustomCalendar',
|
||||||
|
props: {
|
||||||
|
view: {
|
||||||
|
type: String,
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
forHomePage: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
emits: ['openEventDialog'],
|
||||||
|
setup(props, { emit }) {
|
||||||
|
const calendarRef = ref(null);
|
||||||
|
const currentView = ref('dayGridMonth');
|
||||||
|
const calendarApi = ref(null);
|
||||||
|
const currentTitle = ref('Календарь');
|
||||||
|
|
||||||
|
const calendarStore = useCalendarStore();
|
||||||
|
const { selectedDate, lastUpdatedBy, allEvents, calendarColorMap } = storeToRefs(calendarStore);
|
||||||
|
const { parseRecurrenceOptions, isRecurringEvent } = useRecurrence();
|
||||||
|
|
||||||
|
const handleEventClick = (info) => {
|
||||||
|
if (calendarStore.canEditEvent(info.event.id)) {
|
||||||
|
emit('openEventDialog', info);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const calendarOptions = ref({
|
||||||
|
plugins: [
|
||||||
|
dayGridPlugin,
|
||||||
|
timeGridPlugin,
|
||||||
|
multiMonthPlugin,
|
||||||
|
interactionPlugin,
|
||||||
|
listPlugin,
|
||||||
|
rrulePlugin,
|
||||||
|
],
|
||||||
|
initialView: props.forHomePage ? props.view : currentView.value,
|
||||||
|
locales: [ruLocale],
|
||||||
|
locale: 'ru',
|
||||||
|
firstDay: 1,
|
||||||
|
headerToolbar: false,
|
||||||
|
height: '80vh',
|
||||||
|
aspectRatio: 1.5,
|
||||||
|
weekNumbers: true,
|
||||||
|
weekNumberFormat: {
|
||||||
|
week: 'numeric',
|
||||||
|
},
|
||||||
|
weekNumberCalculation: 'ISO', // ISO стандарт (понедельник - первый день)
|
||||||
|
selectable: true,
|
||||||
|
unselectAuto: false,
|
||||||
|
selectMirror: false,
|
||||||
|
|
||||||
|
dayCellDidMount: (arg) => {
|
||||||
|
const date = arg.date;
|
||||||
|
const dayInfo = calendarStore.isNonWorkingDay(date);
|
||||||
|
|
||||||
|
if (dayInfo.isHoliday === true) {
|
||||||
|
arg.el.classList.add('non-working-day');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dayInfo.isWeekendForStyling === true) {
|
||||||
|
arg.el.classList.add('grey-background');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
views: {
|
||||||
|
timeGridDay: {
|
||||||
|
type: 'timeGrid',
|
||||||
|
duration: { days: 1 },
|
||||||
|
slotDuration: '01:00:00',
|
||||||
|
slotLabelInterval: '01:00:00',
|
||||||
|
slotLabelFormat: {
|
||||||
|
hour: '2-digit',
|
||||||
|
minute: '2-digit',
|
||||||
|
hour12: false,
|
||||||
|
meridiem: false,
|
||||||
|
},
|
||||||
|
allDaySlot: false,
|
||||||
|
allDaySlot: false,
|
||||||
|
slotMinTime: '07:00:00',
|
||||||
|
slotMaxTime: '22:00:00',
|
||||||
|
expandRows: true,
|
||||||
|
dayHeaderFormat: {
|
||||||
|
weekday: 'long',
|
||||||
|
day: 'numeric',
|
||||||
|
month: 'long',
|
||||||
|
omitCommas: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
timeGridWeek: {
|
||||||
|
type: 'timeGrid',
|
||||||
|
duration: { weeks: 1 },
|
||||||
|
slotDuration: '01:00:00',
|
||||||
|
slotMinTime: '07:00:00',
|
||||||
|
slotMaxTime: '22:00:00',
|
||||||
|
allDaySlot: false,
|
||||||
|
expandRows: true,
|
||||||
|
dayHeaderFormat: { weekday: 'short', day: 'numeric' },
|
||||||
|
titleFormat: {
|
||||||
|
day: 'numeric',
|
||||||
|
month: 'long',
|
||||||
|
omitCommas: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
dayGridMonth: {
|
||||||
|
type: 'dayGrid',
|
||||||
|
fixedWeekCount: false,
|
||||||
|
dayHeaderFormat: { weekday: 'short' },
|
||||||
|
weekNumbers: true,
|
||||||
|
|
||||||
|
weekNumberFormat: { week: 'numeric' },
|
||||||
|
weekNumberContent: (arg) => {
|
||||||
|
return arg.num;
|
||||||
|
},
|
||||||
|
weekText: 'Нед.',
|
||||||
|
},
|
||||||
|
multiMonthYear: {
|
||||||
|
type: 'multiMonth',
|
||||||
|
duration: { years: 1 },
|
||||||
|
multiMonthMaxColumns: 4,
|
||||||
|
fixedWeekCount: false,
|
||||||
|
weekNumbers: false,
|
||||||
|
},
|
||||||
|
listWeek: {
|
||||||
|
type: 'list',
|
||||||
|
duration: { weeks: 1 },
|
||||||
|
listDayFormat: {
|
||||||
|
weekday: 'long',
|
||||||
|
day: 'numeric',
|
||||||
|
month: 'long',
|
||||||
|
},
|
||||||
|
listDaySideFormat: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
events: [],
|
||||||
|
editable: true,
|
||||||
|
selectable: true,
|
||||||
|
|
||||||
|
eventClick: handleEventClick,
|
||||||
|
|
||||||
|
dateClick: (info) => {
|
||||||
|
calendarStore.setSelectedDateFromCalendar(info);
|
||||||
|
handleDateSelection(info.dateStr);
|
||||||
|
handleCalendarDateClick(info);
|
||||||
|
calendarApi.value?.unselect();
|
||||||
|
},
|
||||||
|
|
||||||
|
datesSet: (info) => {
|
||||||
|
if (info.view.type === 'listWeek' && selectedDate.value) {
|
||||||
|
const date = new Date(selectedDate.value);
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
weekday: 'long',
|
||||||
|
day: 'numeric',
|
||||||
|
month: 'long',
|
||||||
|
year: 'numeric',
|
||||||
|
};
|
||||||
|
|
||||||
|
const formattedDate = date.toLocaleDateString('ru-RU', options);
|
||||||
|
currentTitle.value = `Расписание на ${formattedDate}`;
|
||||||
|
} else {
|
||||||
|
currentTitle.value = info.view.title;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selectedDate?.value) {
|
||||||
|
handleDateSelection(selectedDate.value);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const handleCalendarDateClick = (info) => {
|
||||||
|
calendarStore.setSelectedDateFromCalendar(info);
|
||||||
|
currentTitle.value = info.view.title;
|
||||||
|
|
||||||
|
const calendarApi = calendarRef.value.getApi();
|
||||||
|
// Переходим к выбранной дате в дневном виде
|
||||||
|
calendarApi.gotoDate(info.date);
|
||||||
|
calendarApi.changeView('listWeek');
|
||||||
|
currentView.value = 'listWeek';
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleToday = () => {
|
||||||
|
calendarApi.value?.today();
|
||||||
|
// Получаем текущую дату из календаря и передаем в стор
|
||||||
|
const currentDate = calendarApi.value?.getDate();
|
||||||
|
if (currentDate) {
|
||||||
|
// Создаем объект похожий на info из FullCalendar
|
||||||
|
const todayInfo = {
|
||||||
|
dateStr: currentDate.toISOString().split('T')[0],
|
||||||
|
};
|
||||||
|
calendarStore.setSelectedDateFromCalendar(todayInfo);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handlePrev = () => {
|
||||||
|
calendarApi.value?.prev();
|
||||||
|
const currentDate = calendarApi.value?.getDate();
|
||||||
|
if (currentDate) {
|
||||||
|
const dateInfo = {
|
||||||
|
dateStr: currentDate.toISOString().split('T')[0],
|
||||||
|
};
|
||||||
|
calendarStore.setSelectedDateFromCalendar(dateInfo);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleNext = () => {
|
||||||
|
calendarApi.value?.next();
|
||||||
|
|
||||||
|
const currentDate = calendarApi.value?.getDate();
|
||||||
|
if (currentDate) {
|
||||||
|
const dateInfo = {
|
||||||
|
dateStr: currentDate.toISOString().split('T')[0],
|
||||||
|
};
|
||||||
|
calendarStore.setSelectedDateFromCalendar(dateInfo);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Функция обновления выделения
|
||||||
|
const handleDateSelection = (dateStr) => {
|
||||||
|
// Убираем предыдущее выделение
|
||||||
|
const previousSelected = document.querySelectorAll('.fc-day-selected-custom');
|
||||||
|
previousSelected.forEach((el) => el.classList.remove('fc-day-selected-custom'));
|
||||||
|
|
||||||
|
// Добавляем новое выделение
|
||||||
|
const dayElements = document.querySelectorAll(`[data-date="${dateStr}"]`);
|
||||||
|
dayElements.forEach((el) => el.classList.add('fc-day-selected-custom'));
|
||||||
|
|
||||||
|
selectedDate.value = dateStr;
|
||||||
|
};
|
||||||
|
|
||||||
|
// const calendarColorMap = computed(() => {
|
||||||
|
// const map = new Map();
|
||||||
|
// calendarStore.myCalendars.forEach((calendar) => {
|
||||||
|
// map.set(calendar.id, calendar.cl_color);
|
||||||
|
// });
|
||||||
|
// return map;
|
||||||
|
// });
|
||||||
|
|
||||||
|
// Обновление событий в календаре
|
||||||
|
const updateCalendarEvents = () => {
|
||||||
|
if (calendarRef.value) {
|
||||||
|
const api = calendarRef.value.getApi();
|
||||||
|
api.removeAllEvents();
|
||||||
|
allEvents.value.forEach((event) => {
|
||||||
|
const eventColor = calendarColorMap.value.get(event.calendar) || '#3788d8';
|
||||||
|
const rruleOptions = isRecurringEvent(event)
|
||||||
|
? parseRecurrenceOptions(event.period, event.date_start)
|
||||||
|
: null;
|
||||||
|
|
||||||
|
const baseEvent = {
|
||||||
|
id: event.id,
|
||||||
|
title: event.name,
|
||||||
|
start:new Date(event.date_start),
|
||||||
|
end: new Date(event.date_end),
|
||||||
|
allDay: event.all_day,
|
||||||
|
textColor: '#ffffff',
|
||||||
|
backgroundColor: eventColor,
|
||||||
|
borderColor: eventColor,
|
||||||
|
};
|
||||||
|
if (!rruleOptions) {
|
||||||
|
api.addEvent(baseEvent);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
api.addEvent({
|
||||||
|
...baseEvent,
|
||||||
|
rrule: {
|
||||||
|
...rruleOptions,
|
||||||
|
},
|
||||||
|
extendedProps: {
|
||||||
|
originalEvent: event,
|
||||||
|
isRecurring: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
nextTick(() => {
|
||||||
|
if (calendarRef.value && calendarRef.value.getApi) {
|
||||||
|
calendarApi.value = calendarRef.value.getApi();
|
||||||
|
updateCalendarEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selectedDate.value != undefined && selectedDate.value) {
|
||||||
|
handleDateSelection(selectedDate.value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
const currentYear = new Date().getFullYear();
|
||||||
|
calendarStore.fetchHolidays(currentYear);
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(selectedDate, (newDate) => {
|
||||||
|
if (newDate && calendarApi.value && lastUpdatedBy.value !== 'calendar') {
|
||||||
|
nextTick(() => {
|
||||||
|
calendarApi.value.gotoDate(newDate);
|
||||||
|
handleDateSelection(newDate);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(currentView, (newView) => {
|
||||||
|
if (calendarApi.value) {
|
||||||
|
calendarApi.value.changeView(newView);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(
|
||||||
|
[allEvents],
|
||||||
|
([newEvents]) => {
|
||||||
|
if (newEvents.length > 0) {
|
||||||
|
updateCalendarEvents();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ deep: true, immediate: true },
|
||||||
|
);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.eventCalendar,
|
||||||
|
(newEvent) => {
|
||||||
|
if (calendarRef.value) {
|
||||||
|
const api = calendarRef.value.getApi();
|
||||||
|
api.refetchEvents(); // Обновляем события в календаре
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ deep: true },
|
||||||
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
currentTitle,
|
||||||
|
calendarRef,
|
||||||
|
currentView,
|
||||||
|
calendarOptions,
|
||||||
|
handleToday,
|
||||||
|
handleNext,
|
||||||
|
handlePrev,
|
||||||
|
handleCalendarDateClick,
|
||||||
|
handleDateSelection,
|
||||||
|
updateCalendarEvents,
|
||||||
|
handleEventClick,
|
||||||
|
calendarStore,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<style scoped>
|
||||||
|
:deep(.fc-daygrid-day-number) {
|
||||||
|
display: flex !important;
|
||||||
|
justify-content: center !important;
|
||||||
|
align-items: center !important;
|
||||||
|
width: 100% !important;
|
||||||
|
height: 100% !important;
|
||||||
|
margin: 0 !important;
|
||||||
|
padding: 0.6rem !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* текущая дата обводка */
|
||||||
|
:deep(.fc-day-today) {
|
||||||
|
background-color: transparent !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.fc-day-today .fc-daygrid-day-number) {
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
|
color: #00897b;
|
||||||
|
|
||||||
|
&::before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
width: 32px;
|
||||||
|
height: 32px;
|
||||||
|
border: 1px solid #00897b;
|
||||||
|
border-radius: 50%;
|
||||||
|
z-index: -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Выбранная дата заливка */
|
||||||
|
|
||||||
|
:deep(.fc-day-selected-custom) {
|
||||||
|
background-color: transparent !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.fc-day-selected-custom .fc-daygrid-day-number) {
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
|
color: white !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.fc-day-selected-custom .fc-daygrid-day-number::before) {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
width: 32px;
|
||||||
|
height: 32px;
|
||||||
|
background-color: #00897b;
|
||||||
|
border-radius: 50%;
|
||||||
|
z-index: -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.fc-multiMonthYear-view) {
|
||||||
|
.fc-day-today .fc-daygrid-day-number::before,
|
||||||
|
.fc-day-selected-custom .fc-daygrid-day-number::before {
|
||||||
|
width: 24px;
|
||||||
|
height: 24px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.v-btn--active) {
|
||||||
|
background-color: transparent !important;
|
||||||
|
color: #00897b !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.fc .fc-timegrid-col.fc-day-today) {
|
||||||
|
background-color: #e0f2f1 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.fc-highlight) {
|
||||||
|
background-color: transparent !important;
|
||||||
|
}
|
||||||
|
:deep(.fc-day) {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.fc-popover) {
|
||||||
|
background-color: rgb(248, 244, 244) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.non-working-day {
|
||||||
|
color: red !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.fc-daygrid-day.non-working-day .fc-daygrid-day-number) {
|
||||||
|
color: #d32f2f !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.fc-daygrid-day.grey-background.fc-daygrid-day-number) {
|
||||||
|
background-color: rgb(196, 187, 187) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grey-background {
|
||||||
|
background-color: rgb(240, 229, 229) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.fc-day.grey-background) {
|
||||||
|
background-color: #f5f5f5 !important;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,534 @@
|
|||||||
|
<template>
|
||||||
|
<v-card class="home-calendar-widget" elevation="2" rounded="lg">
|
||||||
|
<v-card-text class="pa-4">
|
||||||
|
<v-row no-gutters class="calendar-pair">
|
||||||
|
<!-- Месячный календарь -->
|
||||||
|
<v-col cols="7" class="pr-2">
|
||||||
|
<div class="calendar-header">
|
||||||
|
<v-btn icon size="small" @click="prevMonth" class="nav-btn">
|
||||||
|
<v-icon>mdi-chevron-left</v-icon>
|
||||||
|
</v-btn>
|
||||||
|
<span class="month-title">{{ currentMonth }}</span>
|
||||||
|
<v-btn icon size="small" @click="nextMonth" class="nav-btn">
|
||||||
|
<v-icon>mdi-chevron-right</v-icon>
|
||||||
|
</v-btn>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<v-table class="month-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th v-for="day in russianWeekdays" :key="day" class="weekday-header">
|
||||||
|
{{ day }}
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr v-for="(week, weekIndex) in calendarWeeks" :key="weekIndex">
|
||||||
|
<td
|
||||||
|
v-for="day in week"
|
||||||
|
:key="day.date"
|
||||||
|
class="day-cell"
|
||||||
|
:class="{
|
||||||
|
'current-month': day.isCurrentMonth,
|
||||||
|
today: isToday(day.date),
|
||||||
|
selected: isSelected(day.date),
|
||||||
|
'non-working-day': calendarStore.isNonWorkingDay(day.date).isHoliday,
|
||||||
|
'grey-background': calendarStore.isNonWorkingDay(day.date).isWeekendForStyling,
|
||||||
|
}"
|
||||||
|
@click="onDateClick(day.date)"
|
||||||
|
>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="day-content">
|
||||||
|
<span class="day-number">{{ day.day }}</span>
|
||||||
|
<div class="day-events">
|
||||||
|
<span
|
||||||
|
v-for="event in getDayEvents(day.date)"
|
||||||
|
:key="event.id"
|
||||||
|
class="event-indicator"
|
||||||
|
:style="{ backgroundColor: event.color }"
|
||||||
|
></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</v-table>
|
||||||
|
</v-col>
|
||||||
|
|
||||||
|
<!-- Дневное расписание -->
|
||||||
|
<v-col cols="5" class="pl-2">
|
||||||
|
<div class="schedule-header">
|
||||||
|
<h3 class="day-title">Сегодня, {{ formattedSelectedDate }}</h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<v-card variant="outlined" class="day-schedule" elevation="0">
|
||||||
|
<v-list density="comfortable" class="py-0">
|
||||||
|
<v-list-item
|
||||||
|
v-for="event in dayEvents"
|
||||||
|
:key="event.id"
|
||||||
|
class="schedule-item"
|
||||||
|
:class="{ 'current-event': isCurrentEvent(event) }"
|
||||||
|
>
|
||||||
|
<template #prepend>
|
||||||
|
<div
|
||||||
|
class="event-color-indicator"
|
||||||
|
:style="{ backgroundColor: event.color }"
|
||||||
|
></div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<v-list-item-title class="event-time">
|
||||||
|
{{ formatTime(event.start) }}
|
||||||
|
</v-list-item-title>
|
||||||
|
<v-list-item-subtitle class="event-title">
|
||||||
|
{{ event.title }}
|
||||||
|
</v-list-item-subtitle>
|
||||||
|
</v-list-item>
|
||||||
|
|
||||||
|
<v-list-item v-if="dayEvents.length === 0" class="no-events">
|
||||||
|
<v-list-item-title class="text-grey text-center">
|
||||||
|
На этот день событий нет
|
||||||
|
</v-list-item-title>
|
||||||
|
</v-list-item>
|
||||||
|
</v-list>
|
||||||
|
</v-card>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
</v-card-text>
|
||||||
|
</v-card>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { ref, computed, onMounted, watch } from 'vue';
|
||||||
|
import { storeToRefs } from 'pinia';
|
||||||
|
import { useCalendarStore } from '@/store/calendarStore';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'HomeCalendarWidget',
|
||||||
|
|
||||||
|
setup() {
|
||||||
|
// Реактивные данные
|
||||||
|
const currentDate = ref(new Date());
|
||||||
|
const selectedDate = ref(''); // Будет установлено в формате YYYY-MM-DD
|
||||||
|
const currentYear = new Date().getFullYear();
|
||||||
|
|
||||||
|
// Работа с хранилищем
|
||||||
|
const calendarStore = useCalendarStore();
|
||||||
|
const { allEvents, calendarColorMap } = storeToRefs(calendarStore);
|
||||||
|
|
||||||
|
// Утилиты для работы с датами (главный источник проблем!)
|
||||||
|
const formatToLocalDate = (date) => {
|
||||||
|
const year = date.getFullYear();
|
||||||
|
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||||
|
const day = String(date.getDate()).padStart(2, '0');
|
||||||
|
return `${year}-${month}-${day}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getStartOfDay = (date) => {
|
||||||
|
const newDate = new Date(date);
|
||||||
|
newDate.setHours(0, 0, 0, 0);
|
||||||
|
return newDate;
|
||||||
|
};
|
||||||
|
|
||||||
|
const areDatesEqual = (date1, date2) => {
|
||||||
|
return getStartOfDay(date1).getTime() === getStartOfDay(date2).getTime();
|
||||||
|
};
|
||||||
|
|
||||||
|
// Преобразование событий с защитой от ошибок
|
||||||
|
const events = computed(() => {
|
||||||
|
const userEvents = allEvents.value.map((event) => {
|
||||||
|
const eventColor = calendarColorMap.value.get(event.calendar) || event.color || '#1976d2';
|
||||||
|
return {
|
||||||
|
id: event.id,
|
||||||
|
title: event.name || event.title || 'Без названия',
|
||||||
|
start: event.date_start || event.start,
|
||||||
|
end: event.date_end || event.end,
|
||||||
|
description: event.description,
|
||||||
|
color: eventColor || '#1976d2',
|
||||||
|
calendar: event.calendar,
|
||||||
|
isHoliday: false,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
return [...userEvents];
|
||||||
|
});
|
||||||
|
|
||||||
|
const russianWeekdays = ['Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб', 'Вс'];
|
||||||
|
|
||||||
|
// Генерация календаря
|
||||||
|
const calendarWeeks = computed(() => {
|
||||||
|
const year = currentDate.value.getFullYear();
|
||||||
|
const month = currentDate.value.getMonth();
|
||||||
|
|
||||||
|
const firstDay = new Date(year, month, 1);
|
||||||
|
const lastDay = new Date(year, month + 1, 0);
|
||||||
|
|
||||||
|
const weeks = [];
|
||||||
|
let week = [];
|
||||||
|
|
||||||
|
// Находим понедельник первой недели
|
||||||
|
const startDay = new Date(firstDay);
|
||||||
|
startDay.setDate(startDay.getDate() - ((startDay.getDay() + 6) % 7));
|
||||||
|
|
||||||
|
// Генерируем 6 недель (фиксированное количество для стабильности)
|
||||||
|
for (let i = 0; i < 42; i++) {
|
||||||
|
const currentDay = new Date(startDay);
|
||||||
|
currentDay.setDate(startDay.getDate() + i);
|
||||||
|
|
||||||
|
week.push({
|
||||||
|
day: currentDay.getDate(),
|
||||||
|
date: formatToLocalDate(currentDay),
|
||||||
|
isCurrentMonth: currentDay.getMonth() === month,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (week.length === 7) {
|
||||||
|
weeks.push([...week]);
|
||||||
|
week = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return weeks;
|
||||||
|
});
|
||||||
|
|
||||||
|
const currentMonth = computed(() => {
|
||||||
|
return currentDate.value.toLocaleDateString('ru-RU', {
|
||||||
|
month: 'long',
|
||||||
|
year: 'numeric',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const formattedSelectedDate = computed(() => {
|
||||||
|
if (!selectedDate.value) return '';
|
||||||
|
|
||||||
|
// Добавляем время для избежания смещения часовых поясов
|
||||||
|
const date = new Date(selectedDate.value + 'T12:00:00');
|
||||||
|
return date.toLocaleDateString('ru-RU', {
|
||||||
|
day: 'numeric',
|
||||||
|
month: 'long',
|
||||||
|
year: 'numeric',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const dayEvents = computed(() => {
|
||||||
|
if (!selectedDate.value) return [];
|
||||||
|
|
||||||
|
const selected = new Date(selectedDate.value + 'T12:00:00');
|
||||||
|
|
||||||
|
return events.value
|
||||||
|
.filter((event) => {
|
||||||
|
const eventDate = new Date(event.start);
|
||||||
|
return areDatesEqual(eventDate, selected);
|
||||||
|
})
|
||||||
|
.sort((a, b) => new Date(a.start).getTime() - new Date(b.start).getTime());
|
||||||
|
});
|
||||||
|
|
||||||
|
// Методы
|
||||||
|
const isToday = (date) => {
|
||||||
|
const today = new Date();
|
||||||
|
const checkDate = new Date(date + 'T12:00:00');
|
||||||
|
return areDatesEqual(today, checkDate);
|
||||||
|
};
|
||||||
|
|
||||||
|
const isSelected = (date) => {
|
||||||
|
return date === selectedDate.value;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getDayEvents = (date) => {
|
||||||
|
const checkDate = new Date(date + 'T12:00:00');
|
||||||
|
|
||||||
|
return events.value.filter((event) => {
|
||||||
|
const eventDate = new Date(event.start);
|
||||||
|
return areDatesEqual(eventDate, checkDate);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const isCurrentEvent = (event) => {
|
||||||
|
const now = new Date();
|
||||||
|
const start = new Date(event.start);
|
||||||
|
const end = new Date(event.end);
|
||||||
|
return now >= start && now <= end;
|
||||||
|
};
|
||||||
|
|
||||||
|
const formatTime = (dateString) => {
|
||||||
|
return new Date(dateString).toLocaleTimeString('ru-RU', {
|
||||||
|
hour: '2-digit',
|
||||||
|
minute: '2-digit',
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const onDateClick = (date) => {
|
||||||
|
selectedDate.value = date;
|
||||||
|
};
|
||||||
|
|
||||||
|
const prevMonth = () => {
|
||||||
|
const date = new Date(currentDate.value);
|
||||||
|
date.setMonth(date.getMonth() - 1);
|
||||||
|
currentDate.value = date;
|
||||||
|
};
|
||||||
|
|
||||||
|
const nextMonth = () => {
|
||||||
|
const date = new Date(currentDate.value);
|
||||||
|
date.setMonth(date.getMonth() + 1);
|
||||||
|
currentDate.value = date;
|
||||||
|
};
|
||||||
|
|
||||||
|
const isWeekendOrHoliday = (dateString) => {
|
||||||
|
const dayInfo = calendarStore.isNonWorkingDay(dateString);
|
||||||
|
return dayInfo.isHoliday || dayInfo.isWeekendForStyling;
|
||||||
|
};
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
selectedDate.value = formatToLocalDate(new Date());
|
||||||
|
calendarStore.fetchHolidays(currentYear);
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(
|
||||||
|
calendarColorMap,
|
||||||
|
(newMap) => {
|
||||||
|
newMap.value;
|
||||||
|
},
|
||||||
|
{ deep: true },
|
||||||
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
// Реактивные данные
|
||||||
|
currentDate,
|
||||||
|
selectedDate,
|
||||||
|
|
||||||
|
// Вычисляемые свойства
|
||||||
|
events,
|
||||||
|
russianWeekdays,
|
||||||
|
calendarWeeks,
|
||||||
|
currentMonth,
|
||||||
|
formattedSelectedDate,
|
||||||
|
dayEvents,
|
||||||
|
isWeekendOrHoliday,
|
||||||
|
|
||||||
|
// Методы
|
||||||
|
isToday,
|
||||||
|
isSelected,
|
||||||
|
getDayEvents,
|
||||||
|
isCurrentEvent,
|
||||||
|
formatTime,
|
||||||
|
onDateClick,
|
||||||
|
prevMonth,
|
||||||
|
nextMonth,
|
||||||
|
|
||||||
|
calendarStore,
|
||||||
|
allEvents,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.home-calendar-widget {
|
||||||
|
width: 100%;
|
||||||
|
/* width: 700px; */
|
||||||
|
height: 100%;
|
||||||
|
font-family: 'Roboto', sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
.calendar-pair {
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Месячный календарь */
|
||||||
|
.calendar-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
padding: 0 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.month-title {
|
||||||
|
font-size: 1.1rem;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #333;
|
||||||
|
text-transform: capitalize;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-btn {
|
||||||
|
width: 28px;
|
||||||
|
height: 28px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.month-table {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.weekday-header {
|
||||||
|
font-size: 0.8rem;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #666;
|
||||||
|
text-align: center;
|
||||||
|
padding: 8px 4px;
|
||||||
|
border-bottom: 1px solid #afadad;
|
||||||
|
}
|
||||||
|
|
||||||
|
.day-cell {
|
||||||
|
width: 14.28%;
|
||||||
|
height: 15%;
|
||||||
|
/* height: 50px; */
|
||||||
|
text-align: center;
|
||||||
|
cursor: pointer;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.day-cell:hover {
|
||||||
|
background-color: #f5f5f5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.day-cell.current-month {
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.day-cell:not(.current-month) {
|
||||||
|
color: #ccc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.day-cell.today {
|
||||||
|
background-color: #e3f2fd;
|
||||||
|
}
|
||||||
|
|
||||||
|
.day-cell.selected {
|
||||||
|
background-color: #00897b;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.day-cell.selected .day-number {
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.day-content {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
height: 100%;
|
||||||
|
padding: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.day-number {
|
||||||
|
font-size: 0.9rem;
|
||||||
|
font-weight: 500;
|
||||||
|
margin-bottom: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.day-events {
|
||||||
|
display: flex;
|
||||||
|
gap: 2px;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-indicator {
|
||||||
|
width: 6px;
|
||||||
|
height: 6px;
|
||||||
|
border-radius: 50%;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-color-indicator {
|
||||||
|
width: 10px;
|
||||||
|
height: 10px;
|
||||||
|
border-radius: 50%;
|
||||||
|
margin-right: 12px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Дневное расписание */
|
||||||
|
.schedule-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
padding: 0 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.day-title {
|
||||||
|
font-size: 1.2rem;
|
||||||
|
font-weight: 600;
|
||||||
|
margin: 0;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.day-schedule {
|
||||||
|
height: 90%;
|
||||||
|
overflow-y: auto;
|
||||||
|
border: 1px solid #e0e0e0;
|
||||||
|
border-radius: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.schedule-item {
|
||||||
|
min-height: 48px;
|
||||||
|
padding: 8px 12px;
|
||||||
|
border-left: 4px solid transparent;
|
||||||
|
border-bottom: 1px solid #d3cecede;
|
||||||
|
}
|
||||||
|
|
||||||
|
.schedule-item:last-child {
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.schedule-item.current-event {
|
||||||
|
border-left-color: #2196f3;
|
||||||
|
background-color: #f8f9fa;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-time {
|
||||||
|
font-size: 0.8rem;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #302f2f;
|
||||||
|
margin-bottom: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.event-title {
|
||||||
|
font-size: 0.9rem;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
color: #1b1b1b;
|
||||||
|
}
|
||||||
|
|
||||||
|
.no-events {
|
||||||
|
min-height: 120px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Скроллбар */
|
||||||
|
.day-schedule::-webkit-scrollbar {
|
||||||
|
width: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.day-schedule::-webkit-scrollbar-track {
|
||||||
|
background: #f1f1f1;
|
||||||
|
border-radius: 0 8px 8px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.day-schedule::-webkit-scrollbar-thumb {
|
||||||
|
background: #c1c1c1;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.day-schedule::-webkit-scrollbar-thumb:hover {
|
||||||
|
background: #a8a8a8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.non-working-day {
|
||||||
|
color: red !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grey-background {
|
||||||
|
background-color: rgb(243, 243, 243) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.day-cell:not(.current-month).non-working-day {
|
||||||
|
color: inherit !important;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,239 @@
|
|||||||
|
<template>
|
||||||
|
<v-card class="h-100 rounded-0 d-flex flex-colmn">
|
||||||
|
<v-row no-gutters class="flex-column">
|
||||||
|
<v-col class="flex-grow-0 px-2 pt-1">
|
||||||
|
<v-text-field
|
||||||
|
density="compact"
|
||||||
|
clearable
|
||||||
|
append-inner-icon="mdi-magnify"
|
||||||
|
hide-details
|
||||||
|
class="py-3"
|
||||||
|
label="Найти событие"
|
||||||
|
rows="1"
|
||||||
|
no-resize
|
||||||
|
variant="outlined"
|
||||||
|
/>
|
||||||
|
</v-col>
|
||||||
|
<v-col class="flex-grow-0 px-2">
|
||||||
|
<v-btn
|
||||||
|
type="submit"
|
||||||
|
class="text-subtitle-1 font-weight-light"
|
||||||
|
color="btn_text"
|
||||||
|
block
|
||||||
|
elevation="1"
|
||||||
|
@click="openEventDialog"
|
||||||
|
>Создать событие</v-btn
|
||||||
|
>
|
||||||
|
<!-- {{eventFromCalendar}} -->
|
||||||
|
</v-col>
|
||||||
|
<v-col lg="3">
|
||||||
|
<v-locale-provider locale="ru">
|
||||||
|
<v-date-picker
|
||||||
|
v-model="selectedDate"
|
||||||
|
color="btn_text"
|
||||||
|
class="rounded-0 minCal"
|
||||||
|
hide-header
|
||||||
|
show-adjacent-months
|
||||||
|
@update:modelValue="handleDateClick"
|
||||||
|
>
|
||||||
|
</v-date-picker>
|
||||||
|
</v-locale-provider>
|
||||||
|
</v-col>
|
||||||
|
|
||||||
|
<v-col class="flex-column d-flex">
|
||||||
|
<v-row no-gutters class="h-0 overflow-auto flex-column flex-nowrap">
|
||||||
|
<v-col>
|
||||||
|
<calendar-my
|
||||||
|
:calendars="myCalendars"
|
||||||
|
title="Мои календари"
|
||||||
|
@getCalendar="loadCalendars"
|
||||||
|
/>
|
||||||
|
<calendar-my :calendars="subscribedCalendars" title="Подписки" />
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
</v-card>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
import { useCalendarStore } from '@/store/calendarStore';
|
||||||
|
import { useAccountStore } from '@/store/AccountStore';
|
||||||
|
import CalendarMy from '@/components/calendar_of_events/calendar-my.vue';
|
||||||
|
import { onMounted, watch, ref, nextTick } from 'vue';
|
||||||
|
import { storeToRefs } from 'pinia';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'MiniCalendar',
|
||||||
|
components: { CalendarMy },
|
||||||
|
setup() {
|
||||||
|
const calendarStore = useCalendarStore();
|
||||||
|
const accountStore = useAccountStore();
|
||||||
|
|
||||||
|
const { selectedDate, myCalendars, subscribedCalendars } = storeToRefs(calendarStore);
|
||||||
|
|
||||||
|
const { user } = storeToRefs(accountStore);
|
||||||
|
|
||||||
|
const handleDateClick = (date) => {
|
||||||
|
calendarStore.setSelectedDateFromPicker(date);
|
||||||
|
setTimeout(updateCalendarDays, 200);
|
||||||
|
};
|
||||||
|
|
||||||
|
const openEventDialog = () => {
|
||||||
|
calendarStore.openEventDialog();
|
||||||
|
};
|
||||||
|
|
||||||
|
const loadCalendars = () => {
|
||||||
|
calendarStore.loadCalendars();
|
||||||
|
};
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
loadCalendars();
|
||||||
|
|
||||||
|
updateCalendarDays();
|
||||||
|
setInterval(updateCalendarDays, 500);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Реакция на изменения пользователя
|
||||||
|
watch(user, (newUser) => {
|
||||||
|
if (newUser) {
|
||||||
|
loadCalendars();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Функция для добавления классов дням
|
||||||
|
const updateCalendarDays = () => {
|
||||||
|
nextTick(() => {
|
||||||
|
setTimeout(() => {
|
||||||
|
const dayButtons = document.querySelectorAll('.minCal .v-date-picker-month__day-btn');
|
||||||
|
|
||||||
|
dayButtons.forEach((button) => {
|
||||||
|
// Ищем дату в разных возможных атрибутах
|
||||||
|
const ariaLabel = button.getAttribute('aria-label');
|
||||||
|
|
||||||
|
if (ariaLabel) {
|
||||||
|
try {
|
||||||
|
// Парсим дату из aria-label "воскресенье, 28 сентября 2025 г."
|
||||||
|
|
||||||
|
const dayDate = parseDateFromAriaLabel(ariaLabel);
|
||||||
|
if (dayDate) {
|
||||||
|
const dayInfo = calendarStore.isNonWorkingDay(dayDate);
|
||||||
|
|
||||||
|
// Очищаем предыдущие классы
|
||||||
|
button.classList.remove('weekend-day', 'holiday-day');
|
||||||
|
|
||||||
|
// Добавляем классы по условию
|
||||||
|
if (dayInfo?.isWeekendForStyling) {
|
||||||
|
button.classList.add('weekend-day');
|
||||||
|
}
|
||||||
|
if (dayInfo?.isHoliday) {
|
||||||
|
button.classList.add('holiday-day');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error processing day:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, 100);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const parseDateFromAriaLabel = (ariaLabel) => {
|
||||||
|
try {
|
||||||
|
// Убираем день недели и запятую, оставляем "28 сентября 2025 г."
|
||||||
|
const datePart = ariaLabel.replace(/^[^,]+,?\s*/, '');
|
||||||
|
|
||||||
|
// Заменяем русские названия месяцев на английские
|
||||||
|
const monthMap = {
|
||||||
|
января: 'January',
|
||||||
|
февраля: 'February',
|
||||||
|
марта: 'March',
|
||||||
|
апреля: 'April',
|
||||||
|
мая: 'May',
|
||||||
|
июня: 'June',
|
||||||
|
июля: 'July',
|
||||||
|
августа: 'August',
|
||||||
|
сентября: 'September',
|
||||||
|
октября: 'October',
|
||||||
|
ноября: 'November',
|
||||||
|
декабря: 'December',
|
||||||
|
};
|
||||||
|
|
||||||
|
let englishDateStr = datePart;
|
||||||
|
for (const [ru, en] of Object.entries(monthMap)) {
|
||||||
|
englishDateStr = englishDateStr.replace(ru, en);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Убираем " г." в конце
|
||||||
|
englishDateStr = englishDateStr.replace(' г.', '');
|
||||||
|
|
||||||
|
const dayDate = new Date(englishDateStr);
|
||||||
|
|
||||||
|
return isNaN(dayDate.getTime()) ? null : dayDate;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Parse error:', error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
accountStore,
|
||||||
|
user,
|
||||||
|
myCalendars,
|
||||||
|
subscribedCalendars,
|
||||||
|
selectedDate,
|
||||||
|
openEventDialog,
|
||||||
|
loadCalendars,
|
||||||
|
handleDateClick,
|
||||||
|
updateCalendarDays,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<style scoped>
|
||||||
|
/* .minCal:deep(.v-date-picker-month__days) {
|
||||||
|
display: grid !important;
|
||||||
|
grid-template-columns: repeat(7, 40px) !important;
|
||||||
|
gap: 3px !important;
|
||||||
|
width: 250px !important;
|
||||||
|
justify-content: center !important;
|
||||||
|
margin: 0 auto !important;
|
||||||
|
} */
|
||||||
|
|
||||||
|
.minCal .v-date-picker-monWth__day {
|
||||||
|
height: 31px;
|
||||||
|
width: 31px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.minCal .v-btn--icon.v-btn--density-default {
|
||||||
|
width: calc(var(--v-btn-height) + 12px);
|
||||||
|
height: calc(var(--v-btn-height) + 6px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.minCal .v-btn__content {
|
||||||
|
font-weight: 410;
|
||||||
|
}
|
||||||
|
|
||||||
|
.minCal:deep(.v-date-picker-years__content) {
|
||||||
|
gap: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* СТИЛИ ДЛЯ ВЫХОДНЫХ И ПРАЗДНИКОВ */
|
||||||
|
|
||||||
|
.minCal:deep(.weekend-day .v-btn__content) {
|
||||||
|
color: #666 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.minCal:deep(.holiday-day .v-btn__content) {
|
||||||
|
color: #ff4444 !important;
|
||||||
|
font-weight: bold !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.minCal:deep(.weekend-day.holiday-day) {
|
||||||
|
background-color: #ffe0e0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.minCal:deep(.weekend-day.holiday-day .v-btn__content) {
|
||||||
|
color: #cc0000 !important;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
+1
-3
@@ -93,7 +93,7 @@ export default {
|
|||||||
{ type: "day", text: "День" },
|
{ type: "day", text: "День" },
|
||||||
{ type: "week", text: "Неделя" },
|
{ type: "week", text: "Неделя" },
|
||||||
{ type: "month", text: "Месяц" },
|
{ type: "month", text: "Месяц" },
|
||||||
{ type: "modntdh", text: "Год" },
|
// { type: "modntdh", text: "Год" },
|
||||||
{ type: "modnth", text: "Расписание" },
|
{ type: "modnth", text: "Расписание" },
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -136,7 +136,6 @@ export default {
|
|||||||
});
|
});
|
||||||
|
|
||||||
let actRule = rule.all();
|
let actRule = rule.all();
|
||||||
console.log(actRule, '--------------------------------actRule')
|
|
||||||
|
|
||||||
let lastDateMonth = new Date(
|
let lastDateMonth = new Date(
|
||||||
new Date(dayNextMonth.value).setDate(
|
new Date(dayNextMonth.value).setDate(
|
||||||
@@ -332,7 +331,6 @@ export default {
|
|||||||
|
|
||||||
}
|
}
|
||||||
if (ev.rule.freq == 0) {
|
if (ev.rule.freq == 0) {
|
||||||
console.log(ev, 'ev')
|
|
||||||
if (zeroTime(day.date) == zeroTime(ev.start_event)) {
|
if (zeroTime(day.date) == zeroTime(ev.start_event)) {
|
||||||
return "rounded-e-lg"
|
return "rounded-e-lg"
|
||||||
}
|
}
|
||||||
@@ -2,10 +2,10 @@
|
|||||||
<v-col lg="3" :class="`order-${order[0]}`">
|
<v-col lg="3" :class="`order-${order[0]}`">
|
||||||
<v-menu
|
<v-menu
|
||||||
v-model="menudate"
|
v-model="menudate"
|
||||||
:close-on-content-click="false"
|
|
||||||
:nudge-right="40"
|
:nudge-right="40"
|
||||||
transition="scale-transition"
|
transition="scale-transition"
|
||||||
offset-y
|
offset-y
|
||||||
|
:close-on-content-click="false"
|
||||||
>
|
>
|
||||||
<template v-slot:activator="{ props }">
|
<template v-slot:activator="{ props }">
|
||||||
<v-textarea
|
<v-textarea
|
||||||
@@ -21,12 +21,7 @@
|
|||||||
hide-details
|
hide-details
|
||||||
>
|
>
|
||||||
<template v-slot:prepend-inner>
|
<template v-slot:prepend-inner>
|
||||||
<v-icon
|
<v-icon v-bind="props" icon="mdi-calendar-today" color="cyan-darken-3" size="x-small" />
|
||||||
v-bind="props"
|
|
||||||
icon="mdi-calendar-today"
|
|
||||||
color="cyan-darken-3"
|
|
||||||
size="x-small"
|
|
||||||
/>
|
|
||||||
</template>
|
</template>
|
||||||
</v-textarea>
|
</v-textarea>
|
||||||
</template>
|
</template>
|
||||||
@@ -38,7 +33,7 @@
|
|||||||
hide-header
|
hide-header
|
||||||
border
|
border
|
||||||
no-time
|
no-time
|
||||||
:max="order[0] == 2 ? new Date(limitation) : endMax()"
|
:max="endMax()"
|
||||||
:min="order[0] == 2 ? startMin() : minData()"
|
:min="order[0] == 2 ? startMin() : minData()"
|
||||||
/>
|
/>
|
||||||
</v-locale-provider>
|
</v-locale-provider>
|
||||||
@@ -66,29 +61,24 @@
|
|||||||
activator="parent"
|
activator="parent"
|
||||||
transition="scale-transition"
|
transition="scale-transition"
|
||||||
>
|
>
|
||||||
<v-time-picker
|
<v-time-picker v-if="menutime" v-model="timeEvent" full-width format="24hr"></v-time-picker>
|
||||||
v-if="menutime"
|
|
||||||
v-model="timeEvent"
|
|
||||||
full-width
|
|
||||||
format="24hr"
|
|
||||||
></v-time-picker>
|
|
||||||
</v-menu>
|
</v-menu>
|
||||||
</v-col>
|
</v-col>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { ref, computed } from "vue";
|
import { ref, computed } from 'vue';
|
||||||
import { formatComa, formatDash } from "@/utils/universal_functions";
|
import { formatComa } from '@/utils/universal_functions';
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
dateEvent: {
|
dateEvent: {
|
||||||
type: String,
|
type: String,
|
||||||
default: "",
|
default: '',
|
||||||
},
|
},
|
||||||
|
|
||||||
limitation: {
|
limitation: {
|
||||||
type: String,
|
type: String,
|
||||||
default: "",
|
default: '',
|
||||||
},
|
},
|
||||||
|
|
||||||
order: {
|
order: {
|
||||||
@@ -103,15 +93,21 @@ export default {
|
|||||||
type: Number,
|
type: Number,
|
||||||
default: -1,
|
default: -1,
|
||||||
},
|
},
|
||||||
|
isStart: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
emits: ['update:dateEvent', 'adjustEndDate'],
|
||||||
|
|
||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
const menudate = ref(false);
|
const menudate = ref(false);
|
||||||
const menutime = ref(false);
|
const menutime = ref(false);
|
||||||
|
|
||||||
const propsDateEvent = computed({
|
const propsDateEvent = computed({
|
||||||
get: () => new Date(props.dateEvent),
|
get: () => new Date(props.dateEvent),
|
||||||
set: (value) => emit("update:dateEvent", value),
|
set: (value) => emit('update:dateEvent', value),
|
||||||
});
|
});
|
||||||
|
|
||||||
const modelDate = computed({
|
const modelDate = computed({
|
||||||
@@ -119,77 +115,59 @@ export default {
|
|||||||
return propsDateEvent.value;
|
return propsDateEvent.value;
|
||||||
},
|
},
|
||||||
set(newValue) {
|
set(newValue) {
|
||||||
creatwdDate(newValue, timeEvent.value);
|
createdDate(newValue, timeEvent.value);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const timeEvent = computed({
|
const timeEvent = computed({
|
||||||
get() {
|
get() {
|
||||||
return `${new Date(propsDateEvent.value).getHours()}:${String(
|
return `${new Date(propsDateEvent.value).getHours()}:${String(
|
||||||
new Date(propsDateEvent.value).getMinutes()
|
new Date(propsDateEvent.value).getMinutes(),
|
||||||
).padStart(2, "0")}`;
|
).padStart(2, '0')}`;
|
||||||
},
|
},
|
||||||
|
|
||||||
set(newValue) {
|
set(newValue) {
|
||||||
creatwdDate(modelDate.value, newValue);
|
createdDate(modelDate.value, newValue);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const creatwdDate = (date, time) => {
|
const createdDate = (date, time) => {
|
||||||
let tzero = time.split(":");
|
const [hours, minutes] = time.split(':').map(Number);
|
||||||
time = tzero[0].padStart(2, "0") + ":" + tzero[1];
|
const newDate = new Date(date);
|
||||||
|
newDate.setHours(hours, minutes, 0, 0);
|
||||||
|
|
||||||
if (props.order[0] == 4) {
|
if (props.order[0] == 4) {
|
||||||
if (time == "0:00") {
|
const startDate = new Date(props.limitation);
|
||||||
propsDateEvent.value = date;
|
if (newDate <= startDate) {
|
||||||
} else if (
|
const correctedDate = new Date(startDate);
|
||||||
new Date(formatDash(date) + "T" + time) >= new Date(props.limitation)
|
correctedDate.setHours(startDate.getHours() + 1);
|
||||||
) {
|
propsDateEvent.value = correctedDate;
|
||||||
propsDateEvent.value = new Date(formatDash(date) + "T" + time);
|
|
||||||
} else {
|
} else {
|
||||||
propsDateEvent.value = new Date(props.limitation);
|
propsDateEvent.value = newDate;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
propsDateEvent.value =
|
propsDateEvent.value = newDate;
|
||||||
time == "0:00" ? date : new Date(formatDash(date) + "T" + time);
|
const currentEnd = new Date(props.limitation);
|
||||||
|
if (newDate > currentEnd) {
|
||||||
|
const newEnd = new Date(newDate);
|
||||||
|
newEnd.setHours(newDate.getHours() + 1);
|
||||||
|
emit('adjustEndDate', newEnd.toISOString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
menudate.value = false;
|
||||||
|
menutime.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const minData = () => {
|
const minData = () => {
|
||||||
let h = `${new Date(props.limitation).getHours()}:${String(
|
return new Date(props.limitation);
|
||||||
new Date(props.limitation).getMinutes()
|
|
||||||
).padStart(2, "0")}`;
|
|
||||||
let min =
|
|
||||||
h == "0:00"
|
|
||||||
? new Date(props.limitation)
|
|
||||||
: new Date(
|
|
||||||
new Date(props.limitation).setDate(
|
|
||||||
new Date(props.limitation).getDate() - 1
|
|
||||||
)
|
|
||||||
);
|
|
||||||
return new Date(min);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const startMin = () => {
|
const startMin = () => {
|
||||||
if (props.rule == 2) {
|
return new Date(); // ← По умолчанию: нельзя выбрать прошедшие даты
|
||||||
return new Date(
|
|
||||||
new Date(props.limitation).setDate(
|
|
||||||
new Date(props.limitation).getDate() - 7
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const endMax = () => {
|
const endMax = () => {
|
||||||
if (props.rule == 2) {
|
return null; // ← Без ограничения сверху
|
||||||
return new Date(
|
|
||||||
new Date(props.limitation).setDate(
|
|
||||||
new Date(props.limitation).getDate() + 6
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -109,11 +109,9 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
console.log("sd")
|
|
||||||
const filtered = ref('');
|
const filtered = ref('');
|
||||||
const accountStore = useAccountStore();
|
const accountStore = useAccountStore();
|
||||||
const back = ref([]);
|
const back = ref([]);
|
||||||
|
|
||||||
const staffed = computed({
|
const staffed = computed({
|
||||||
get() {
|
get() {
|
||||||
if (props.okey == 'editor') {
|
if (props.okey == 'editor') {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<dialog-create
|
<dialog-create
|
||||||
:title="titleCard"
|
:title="titleCard"
|
||||||
:newOrOld="newCalendar"
|
:newOrOld="isNewCalendar"
|
||||||
@closeDialog="$emit('closeDialog')"
|
@closeDialog="$emit('closeDialog')"
|
||||||
@delObject="delCalendar(propsCalendar.id)"
|
@delObject="delCalendar(propsCalendar.id)"
|
||||||
@postData="postCalendar"
|
@postData="postCalendar"
|
||||||
@@ -150,20 +150,14 @@ export default {
|
|||||||
cl_descr: [(val) => req(val)],
|
cl_descr: [(val) => req(val)],
|
||||||
};
|
};
|
||||||
|
|
||||||
const titleCard = ref('');
|
const isNewCalendar = computed(() => !propsCalendar.value.id);
|
||||||
const newCalendar = ref(false);
|
const isAuthor = computed(() => propsCalendar.value.author === accountStore.user.is_idEmployee);
|
||||||
|
|
||||||
const calendarNewOrOld = () => {
|
const titleCard = computed(() =>
|
||||||
if ('id' in propsCalendar.value) {
|
isNewCalendar.value ? 'Новый календарь' : 'Редактирование календаря',
|
||||||
titleCard.value = 'Редактирование календаря';
|
);
|
||||||
if (propsCalendar.value.author != accountStore.user.is_idEmployee) newCalendar.value = true;
|
|
||||||
} else {
|
|
||||||
titleCard.value = 'Новый календарь';
|
|
||||||
|
|
||||||
newCalendar.value = true;
|
const newCalendar = computed(() => (isNewCalendar.value ? true : !isAuthor.value));
|
||||||
}
|
|
||||||
};
|
|
||||||
calendarNewOrOld();
|
|
||||||
|
|
||||||
const postCalendar = (val) => {
|
const postCalendar = (val) => {
|
||||||
if (val) {
|
if (val) {
|
||||||
@@ -213,21 +207,21 @@ export default {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const color = [
|
const color = [
|
||||||
'red',
|
'#3788d8', // Синий (аналог default FullCalendar)
|
||||||
'pink',
|
'#4caf50', // Зеленый
|
||||||
'deep-orange',
|
'#ff9800', // Оранжевый
|
||||||
'amber',
|
'#9c27b0', // Фиолетовый
|
||||||
'yellow',
|
'#2196f3', // Голубой
|
||||||
'lime',
|
'#795548', // Коричневый
|
||||||
'light-green',
|
'#607d8b', // Серо-голубой
|
||||||
'green',
|
'#e91e63', // Розовый
|
||||||
'light-blue',
|
'#00bcd4', // Бирюзовый
|
||||||
'blue',
|
'#8bc34a', // Салатовый
|
||||||
'indigo',
|
'#ff5722', // Красно-оранжевый
|
||||||
'deep-purple',
|
'#673ab7', // Темно-фиолетовый
|
||||||
'purple',
|
'#3f51b5', // Индиго
|
||||||
'blue-grey',
|
'#009688', // Зелено-бирюзовый
|
||||||
'brown',
|
'#ffc107', // Янтарный
|
||||||
];
|
];
|
||||||
|
|
||||||
const colorPik = (col) => {
|
const colorPik = (col) => {
|
||||||
@@ -266,6 +260,7 @@ export default {
|
|||||||
titleCard,
|
titleCard,
|
||||||
newCalendar,
|
newCalendar,
|
||||||
newStaff,
|
newStaff,
|
||||||
|
isNewCalendar,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,12 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-expansion-panels
|
<v-expansion-panels class="calendar" variant="accordion" flat tile static v-model="openGroup">
|
||||||
class="calendar"
|
|
||||||
variant="accordion"
|
|
||||||
flat
|
|
||||||
tile
|
|
||||||
static
|
|
||||||
v-model="openGroup"
|
|
||||||
>
|
|
||||||
<v-expansion-panel elevation="0" flat tile static>
|
<v-expansion-panel elevation="0" flat tile static>
|
||||||
<v-expansion-panel-title flat tile static class="py-0 px-3">
|
<v-expansion-panel-title flat tile static class="py-0 px-3">
|
||||||
<div @click.stop="">
|
<div @click.stop="">
|
||||||
@@ -37,26 +30,23 @@
|
|||||||
<v-checkbox-btn
|
<v-checkbox-btn
|
||||||
class="text-caption"
|
class="text-caption"
|
||||||
:class="`text-${x.cl_color}`"
|
:class="`text-${x.cl_color}`"
|
||||||
v-model="x.visible"
|
|
||||||
:color="x.cl_color"
|
:color="x.cl_color"
|
||||||
@update:modelValue="chekUpdate(x)"
|
v-model="x.visible"
|
||||||
|
@update:modelValue="toggleVisiblityEvents(x)"
|
||||||
></v-checkbox-btn>
|
></v-checkbox-btn>
|
||||||
|
<!-- :model-value="x.visible" -->
|
||||||
</template>
|
</template>
|
||||||
<template v-slot:title>
|
<template v-slot:title>
|
||||||
<span class="text-body-2"> {{ x.cl_name }} </span>
|
<span class="text-body-2"> {{ x.cl_name }} </span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-slot:append>
|
<template v-slot:append>
|
||||||
|
|
||||||
<transition name="fade">
|
<transition name="fade">
|
||||||
<v-btn
|
<v-btn
|
||||||
v-if="
|
v-if="
|
||||||
x.author == accountStore.user.is_idEmployee ||
|
x.author == user.is_idEmployee ||
|
||||||
x.participant.some(
|
x.participant.some(
|
||||||
(e) =>
|
(e) => e.editor === true && e.participant_calendar === user.is_idEmployee,
|
||||||
e.editor == true &&
|
|
||||||
e.participant_calendar ==
|
|
||||||
accountStore.user.is_idEmployee
|
|
||||||
)
|
)
|
||||||
"
|
"
|
||||||
size="x-small"
|
size="x-small"
|
||||||
@@ -75,20 +65,23 @@
|
|||||||
</v-expansion-panel-text>
|
</v-expansion-panel-text>
|
||||||
</v-expansion-panel>
|
</v-expansion-panel>
|
||||||
<v-dialog v-model="showDialog" min-width="636" max-width="800">
|
<v-dialog v-model="showDialog" min-width="636" max-width="800">
|
||||||
<calendar-create
|
<calendar-create
|
||||||
@closeDialog = "showDialog = false"
|
@closeDialog="showDialog = false"
|
||||||
:calendar="calendar"
|
:calendar="calendar"
|
||||||
@update:calendar="calendar = $event"
|
@update:calendar="calendar = $event"
|
||||||
@getCalendar="$emit('getCalendar')"
|
@getCalendar="$emit('getCalendar')"
|
||||||
/>
|
/>
|
||||||
</v-dialog>
|
</v-dialog>
|
||||||
</v-expansion-panels>
|
</v-expansion-panels>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { ref } from "vue";
|
import { ref } from 'vue';
|
||||||
import calendarCreate from "@/components/calendar_of_events/calendar-create.vue";
|
import calendarCreate from '@/components/calendar_of_events/calendar-create.vue';
|
||||||
import { useAccountStore } from "@/store/AccountStore";
|
import { useAccountStore } from '@/store/AccountStore';
|
||||||
|
import { storeToRefs } from 'pinia';
|
||||||
|
import { useCalendarStore } from '@/store/calendarStore';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: { calendarCreate },
|
components: { calendarCreate },
|
||||||
|
|
||||||
@@ -99,51 +92,48 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
title: {
|
title: {
|
||||||
typr: String,
|
type: String,
|
||||||
default: "",
|
default: '',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
setup(props, { emit }) {
|
setup(props) {
|
||||||
const showDialog = ref(false);
|
const showDialog = ref(false);
|
||||||
const accountStore = useAccountStore();
|
const accountStore = useAccountStore();
|
||||||
|
const { user } = storeToRefs(accountStore);
|
||||||
|
const calendarStore = useCalendarStore();
|
||||||
|
const { toggleCalendarVisibility } = calendarStore;
|
||||||
|
|
||||||
const calendar = ref({});
|
const calendar = ref({});
|
||||||
const openGroup = ref([0]);
|
const openGroup = ref([0]);
|
||||||
const trans = ref(false);
|
const trans = ref(false);
|
||||||
const hover = ref(0);
|
const hover = ref(0);
|
||||||
|
|
||||||
const editCreatedCalendar = (cal) => {
|
const editCreatedCalendar = (cal) => {
|
||||||
|
|
||||||
if (cal === undefined) {
|
if (cal === undefined) {
|
||||||
calendar.value = {
|
calendar.value = {
|
||||||
cl_name: "",
|
cl_name: '',
|
||||||
participant: [{ editor: true, participant_calendar: accountStore.user.is_idEmployee }],
|
participant: [{ editor: true, participant_calendar: user.value.is_idEmployee }],
|
||||||
cl_color: "red",
|
cl_color: 'red',
|
||||||
cl_descr: "",
|
cl_descr: '',
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
calendar.value = cal;
|
calendar.value = cal;
|
||||||
}
|
}
|
||||||
showDialog.value = true;
|
showDialog.value = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
const chekUpdate = (cal) => {
|
const toggleVisiblityEvents = (cal) => {
|
||||||
let setcal = new Set(accountStore.calendar);
|
toggleCalendarVisibility(cal.id, cal.visible);
|
||||||
if (cal.visible == false) {
|
|
||||||
setcal.add(cal.id);
|
|
||||||
} else {
|
|
||||||
setcal.delete(cal.id);
|
|
||||||
}
|
|
||||||
accountStore.calendar = Array.from(setcal);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
showDialog,
|
|
||||||
calendar,
|
|
||||||
editCreatedCalendar,
|
|
||||||
chekUpdate,
|
|
||||||
accountStore,
|
accountStore,
|
||||||
|
user,
|
||||||
|
calendar,
|
||||||
|
showDialog,
|
||||||
|
editCreatedCalendar,
|
||||||
|
toggleVisiblityEvents,
|
||||||
openGroup,
|
openGroup,
|
||||||
trans,
|
trans,
|
||||||
hover,
|
hover,
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
import { RRule } from 'rrule';
|
||||||
|
|
||||||
|
export function useRecurrence() {
|
||||||
|
/**
|
||||||
|
* Парсит строку периода из БД и возвращает опции для RRule
|
||||||
|
*/
|
||||||
|
const parseRecurrenceOptions = (periodString, eventDateStart) => {
|
||||||
|
if (!periodString || periodString === 'null') return null;
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Пробуем распарсить как RRULE-строку
|
||||||
|
if (periodString.includes('RRULE:')) {
|
||||||
|
const rrule = RRule.fromString(periodString);
|
||||||
|
return { ...rrule.origOptions, dtstart: new Date(eventDateStart) };
|
||||||
|
}
|
||||||
|
// Пробуем распарсить как JSON
|
||||||
|
const periodData = JSON.parse(periodString);
|
||||||
|
if (periodData?.origOptions) {
|
||||||
|
const options = { ...periodData.origOptions };
|
||||||
|
if (options.dtstart && typeof options.dtstart === 'string') {
|
||||||
|
options.dtstart = new Date(eventDateStart);
|
||||||
|
}
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Parse recurrence error:', error);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Проверяет, является ли событие повторяющимся
|
||||||
|
*/
|
||||||
|
const isRecurringEvent = (event) => {
|
||||||
|
if (!event.period || event.period === 'null') return false;
|
||||||
|
return event.period.includes('RRULE:') || JSON.parse(event.period)?.origOptions;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Создает объект правила для нового события
|
||||||
|
*/
|
||||||
|
const createRecurrenceRule = (options) => {
|
||||||
|
const rrule = new RRule({
|
||||||
|
...options,
|
||||||
|
dtstart: new Date(options.dtstart),
|
||||||
|
});
|
||||||
|
return rrule.toString(); // Возвращаем строку RRULE
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
parseRecurrenceOptions,
|
||||||
|
createRecurrenceRule,
|
||||||
|
isRecurringEvent,
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<dialog-create
|
<dialog-create
|
||||||
:title="titleCard"
|
:title="titleCard"
|
||||||
:newOrOld="newEvent"
|
:newOrOld="isNewEvent"
|
||||||
@postData="postData"
|
@postData="postData"
|
||||||
@closeDialog="$emit('closeDialog')"
|
@closeDialog="$emit('closeDialog')"
|
||||||
@delObject="delEvent(propsEvent.event.id)"
|
@delObject="delEvent(propsEvent?.event?.id)"
|
||||||
ref="createDialog"
|
ref="createDialog"
|
||||||
>
|
>
|
||||||
<template v-slot:card_text>
|
<template v-slot:card_text>
|
||||||
@@ -13,9 +13,7 @@
|
|||||||
<v-row no-gutters class="align-center">
|
<v-row no-gutters class="align-center">
|
||||||
<!-- <my-helper :pretext="propsEvent.event" /> -->
|
<!-- <my-helper :pretext="propsEvent.event" /> -->
|
||||||
|
|
||||||
<v-col class="text-body-2 text-text_grey pb-5" lg="2">
|
<v-col class="text-body-2 text-text_grey pb-5" lg="2"> Название </v-col>
|
||||||
Название
|
|
||||||
</v-col>
|
|
||||||
|
|
||||||
<v-col>
|
<v-col>
|
||||||
<v-textarea
|
<v-textarea
|
||||||
@@ -30,9 +28,7 @@
|
|||||||
></v-row>
|
></v-row>
|
||||||
|
|
||||||
<v-row no-gutters class="align-center">
|
<v-row no-gutters class="align-center">
|
||||||
<v-col class="text-body-2 text-text_grey pb-5" lg="2">
|
<v-col class="text-body-2 text-text_grey pb-5" lg="2"> Участники </v-col>
|
||||||
Участники
|
|
||||||
</v-col>
|
|
||||||
<v-col>
|
<v-col>
|
||||||
<calendar-create-select
|
<calendar-create-select
|
||||||
:staff="newStaff"
|
:staff="newStaff"
|
||||||
@@ -44,8 +40,8 @@
|
|||||||
<v-col class="text-body-2 text-text_grey" lg="2"> Календарь</v-col>
|
<v-col class="text-body-2 text-text_grey" lg="2"> Календарь</v-col>
|
||||||
<v-col>
|
<v-col>
|
||||||
<v-autocomplete
|
<v-autocomplete
|
||||||
v-model="calendar"
|
v-model="myCalendar"
|
||||||
:items="propsEvent.mycalendars"
|
:items="safeCalendars"
|
||||||
label="Выберите календарь или найдите по названию"
|
label="Выберите календарь или найдите по названию"
|
||||||
item-title="cl_name"
|
item-title="cl_name"
|
||||||
item-value="id"
|
item-value="id"
|
||||||
@@ -54,70 +50,58 @@
|
|||||||
density="compact"
|
density="compact"
|
||||||
class="py-3"
|
class="py-3"
|
||||||
return-object
|
return-object
|
||||||
|
:rules="rules.calendar"
|
||||||
:disabled="'id' in propsEvent.event"
|
:disabled="'id' in propsEvent.event"
|
||||||
|
clearable
|
||||||
|
auto-select-first
|
||||||
>
|
>
|
||||||
<template v-slot:selection="{ item }">
|
<template v-slot:selection="{ item }">
|
||||||
<v-avatar
|
<v-avatar class="cursor-pointer" size="8" :color="item.raw.cl_color" />
|
||||||
class="cursor-pointer"
|
|
||||||
size="8"
|
|
||||||
:color="item.raw.cl_color"
|
|
||||||
/>
|
|
||||||
<span class="pl-2">
|
<span class="pl-2">
|
||||||
{{ item.title }}
|
{{ item.title }}
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
<template v-slot:item="{ item }">
|
<template v-slot:item="{ item, props }">
|
||||||
<v-list-item
|
<v-list-item
|
||||||
:key="item.title"
|
:key="item.raw.id"
|
||||||
:value="item"
|
:value="item"
|
||||||
color="primary"
|
color="primary"
|
||||||
@click.stop="calendar = item"
|
v-bind="props"
|
||||||
|
@click.stop="myCalendar = item.raw"
|
||||||
>
|
>
|
||||||
<template v-slot:prepend>
|
<template v-slot:prepend>
|
||||||
<v-avatar
|
<v-avatar class="cursor-pointer" size="8" :color="item.raw.cl_color" />
|
||||||
class="cursor-pointer"
|
|
||||||
size="8"
|
|
||||||
:color="item.raw.cl_color"
|
|
||||||
/>
|
|
||||||
</template>
|
</template>
|
||||||
{{ item.title }}
|
<!-- {{ item.title }} -->
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
</template>
|
</template>
|
||||||
</v-autocomplete>
|
</v-autocomplete>
|
||||||
</v-col></v-row
|
</v-col></v-row
|
||||||
>
|
>
|
||||||
<v-row no-gutters class="align-top">
|
<v-row no-gutters class="align-top">
|
||||||
<v-col class="text-body-2 text-text_grey pt-3" lg="2">
|
<v-col class="text-body-2 text-text_grey pt-3" lg="2"> Дата и время </v-col>
|
||||||
Дата и время
|
|
||||||
</v-col>
|
|
||||||
<v-col class="d-flex flex-column">
|
<v-col class="d-flex flex-column">
|
||||||
<v-row no-gutters class="gap">
|
<v-row no-gutters class="gap">
|
||||||
<time-select
|
<time-select
|
||||||
:rule="
|
:rule="selectedRule.rule ? selectedRule.rule.freq : -1"
|
||||||
returnPeriod != repeatRules[0].type
|
|
||||||
? returnPeriod.rule.freq
|
|
||||||
: -1
|
|
||||||
"
|
|
||||||
:chek="propsEvent.event.allday"
|
:chek="propsEvent.event.allday"
|
||||||
:order="[2, 1]"
|
:order="[2, 1]"
|
||||||
:dateEvent="String(propsEvent.event.date_start)"
|
:dateEvent="String(propsEvent.event.date_start)"
|
||||||
:limitation="String(propsEvent.event.date_end)"
|
:limitation="String(propsEvent.event.date_end)"
|
||||||
@update:dateEvent="propsEvent.event.date_start = $event"
|
@update:dateEvent="updateDateStart"
|
||||||
|
@adjustEndDate="handleAutoAdjustEnd"
|
||||||
/>
|
/>
|
||||||
<v-col class="order-3 flex-grow-0">
|
<v-col class="order-3 flex-grow-0">
|
||||||
<v-icon icon="mdi-minus pt-4" color="grey-darken-1" />
|
<v-icon icon="mdi-minus pt-4" color="grey-darken-1" />
|
||||||
</v-col>
|
</v-col>
|
||||||
<time-select
|
<time-select
|
||||||
:rule="
|
:rule="selectedRule.rule ? selectedRule.rule.freq : -1"
|
||||||
returnPeriod != repeatRules[0].type
|
|
||||||
? returnPeriod.rule.freq
|
|
||||||
: -1
|
|
||||||
"
|
|
||||||
:chek="propsEvent.event.allday"
|
:chek="propsEvent.event.allday"
|
||||||
:order="[4, 5]"
|
:order="[4, 5]"
|
||||||
:dateEvent="String(propsEvent.event.date_end)"
|
:dateEvent="String(propsEvent.event.date_end)"
|
||||||
:limitation="String(propsEvent.event.date_start)"
|
:limitation="String(propsEvent.event.date_start)"
|
||||||
@update:dateEvent="propsEvent.event.date_end = $event"
|
@update:dateEvent="updateDateEnd"
|
||||||
|
@adjustEndDate="handleAutoAdjustEnd"
|
||||||
/>
|
/>
|
||||||
</v-row>
|
</v-row>
|
||||||
<v-row no-gutters>
|
<v-row no-gutters>
|
||||||
@@ -127,33 +111,22 @@
|
|||||||
/>
|
/>
|
||||||
<v-col lg="7" class="pt-2 ml-5">
|
<v-col lg="7" class="pt-2 ml-5">
|
||||||
<v-autocomplete
|
<v-autocomplete
|
||||||
v-model="returnPeriod"
|
v-model="selectedRule"
|
||||||
:items="repeatRules"
|
:items="repeatRules"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
density="compact"
|
density="compact"
|
||||||
return-object
|
return-object
|
||||||
item-title="type"
|
item-title="type"
|
||||||
item-value="id"
|
item-value="id"
|
||||||
|
@update:model-value="updatePeriodRule"
|
||||||
>
|
>
|
||||||
<template v-slot:item="{ props, item }">
|
|
||||||
<v-list-item
|
|
||||||
v-bind="props"
|
|
||||||
:key="item.title"
|
|
||||||
:value="item"
|
|
||||||
color="primary"
|
|
||||||
:disabled="periodDisplayRule(item.raw.id)"
|
|
||||||
@click="returnPeriod = item.raw"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
</v-autocomplete>
|
</v-autocomplete>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row> </v-col
|
</v-row> </v-col
|
||||||
></v-row>
|
></v-row>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-row no-gutters class="align-top flex-grow-0">
|
<v-row no-gutters class="align-top flex-grow-0">
|
||||||
<v-col class="text-body-2 text-text_grey pt-3 h-0" lg="2">
|
<v-col class="text-body-2 text-text_grey pt-3 h-0" lg="2"> Напоминание </v-col>
|
||||||
Напоминание
|
|
||||||
</v-col>
|
|
||||||
<v-col class="d-flex flex-column">
|
<v-col class="d-flex flex-column">
|
||||||
<v-row no-gutters class="gap flex-grow-0">
|
<v-row no-gutters class="gap flex-grow-0">
|
||||||
<reminder-event />
|
<reminder-event />
|
||||||
@@ -172,12 +145,17 @@
|
|||||||
</v-row>
|
</v-row>
|
||||||
</v-col></v-row
|
</v-col></v-row
|
||||||
>
|
>
|
||||||
<v-row no-gutters class="align-center">
|
<v-row
|
||||||
<v-col class="text-body-2 text-text_grey pb-5" lg="2"> Файлы </v-col>
|
no-gutters
|
||||||
|
class="align-start d-flex pt-3 mb-3"
|
||||||
|
style="height: auto; min-height: 100px; max-height: 400px"
|
||||||
|
>
|
||||||
|
<v-col class="text-body-2 text-text_grey pb-5 pt-3" lg="2"> Файлы </v-col>
|
||||||
|
|
||||||
<uploading-file
|
<uploading-file
|
||||||
|
v-model:new-files="newFiles"
|
||||||
:files="propsEvent.event.files"
|
:files="propsEvent.event.files"
|
||||||
@update:files="propsEvent.event.files = $event"
|
@update:files="handleFilesUpdate"
|
||||||
@postFiles="postFiles"
|
@postFiles="postFiles"
|
||||||
/>
|
/>
|
||||||
</v-row>
|
</v-row>
|
||||||
@@ -198,18 +176,18 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { computed, ref } from "vue";
|
import { computed, ref, watch } from 'vue';
|
||||||
import { axiosApiInstance } from "@/utils/axios-api";
|
import { axiosApiInstance } from '@/utils/axios-api';
|
||||||
import DialogCreate from "@/components/calendar_of_events/UI_calendar/dialogCreate.vue";
|
import { useAccountStore } from '@/store/AccountStore';
|
||||||
import calendarCreateSelect from "@/components/calendar_of_events/calendar-create-select.vue";
|
import DialogCreate from '@/components/calendar_of_events/UI_calendar/dialogCreate.vue';
|
||||||
import { formatComa } from "@/utils/universal_functions";
|
import calendarCreateSelect from '@/components/calendar_of_events/calendar-create-select.vue';
|
||||||
import TimeSelect from "@/components/calendar_of_events/UI_calendar/timeSelect.vue";
|
import TimeSelect from '@/components/calendar_of_events/UI_calendar/timeSelect.vue';
|
||||||
import { useAccountStore } from "@/store/AccountStore";
|
import UploadingFile from '@/components/UI/defaultportal/uploading-file.vue';
|
||||||
import UploadingFile from "@/components/UI/defaultportal/uploading-file.vue";
|
import ReminderEvent from '@/components/calendar_of_events/UI_calendar/reminderEvent.vue';
|
||||||
import ReminderEvent from "@/components/calendar_of_events/UI_calendar/reminderEvent.vue";
|
import PeriodEvents from '@/components/calendar_of_events/UI_calendar/periodEvents.vue';
|
||||||
import PeriodEvents from "@/components/calendar_of_events/UI_calendar/periodEvents.vue";
|
import { useAlertStore } from '@/store/UseAlertStore';
|
||||||
import { useAlertStore } from "@/store/UseAlertStore";
|
import { RRule } from 'rrule';
|
||||||
import { RRule } from "rrule";
|
import { useRecurrence } from '@/components/calendar_of_events/composables/useReccurrence';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@@ -226,227 +204,285 @@ export default {
|
|||||||
type: Object,
|
type: Object,
|
||||||
default: () => {},
|
default: () => {},
|
||||||
},
|
},
|
||||||
|
myCalendars: {
|
||||||
|
type: Array,
|
||||||
|
default: () => [],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
|
const accountStore = useAccountStore();
|
||||||
const createDialog = ref(null);
|
const createDialog = ref(null);
|
||||||
|
|
||||||
|
const { parseRecurrenceOptions, isRecurringEvent } = useRecurrence();
|
||||||
|
|
||||||
const propsEvent = computed({
|
const propsEvent = computed({
|
||||||
get: () => {
|
get: () => {
|
||||||
return props.eventCalendar;
|
return props.eventCalendar;
|
||||||
},
|
},
|
||||||
|
|
||||||
set: (value) => emit("update:eventCalendar", value),
|
set: (value) => emit('update:eventCalendar', value),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// ВАЛИДАЦИЯ
|
||||||
|
const rules = {
|
||||||
|
name: [
|
||||||
|
(val) => !!val || 'Поле обязательно для заполнения',
|
||||||
|
(val) => (val && val.length >= 3) || 'Минимум 3 символа',
|
||||||
|
(val) => (val && val.length <= 100) || 'Максимум 100 символов',
|
||||||
|
],
|
||||||
|
calendar: [(val) => !!val || 'Выберите календарь'],
|
||||||
|
};
|
||||||
const repeatRules = [
|
const repeatRules = [
|
||||||
{ type: "Не повторять", rule: {}, id: 1 },
|
{ type: 'Не повторять', rule: null, id: 1 },
|
||||||
{ type: "Каждый день", rule: { freq: 3 }, id: 2 },
|
{
|
||||||
{ type: "Каждую неделю", rule: { freq: 2 }, id: 3 },
|
type: 'Каждый день',
|
||||||
{ type: "Каждый месяц", rule: { freq: 1 }, id: 4 },
|
rule: { freq: RRule.DAILY },
|
||||||
{ type: "Каждый год", rule: { freq: 0 }, id: 5 },
|
id: 2,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'Каждую неделю',
|
||||||
|
rule: { freq: RRule.WEEKLY },
|
||||||
|
// По умолчанию - в тот же день недели, что и начальная дата
|
||||||
|
getRule: (startDate) => {
|
||||||
|
const day = new Date(startDate).getDay();
|
||||||
|
// Преобразуем день недели в формат RRule (0 — понедельник)
|
||||||
|
const byweekday = [day === 0 ? RRule.SU : day - 1];
|
||||||
|
return { freq: RRule.WEEKLY, byweekday };
|
||||||
|
},
|
||||||
|
id: 3,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'Каждый месяц',
|
||||||
|
rule: { freq: RRule.MONTHLY },
|
||||||
|
// По умолчанию - в тот же день месяца
|
||||||
|
getRule: (startDate) => ({
|
||||||
|
freq: RRule.MONTHLY,
|
||||||
|
bymonthday: [new Date(startDate).getDate()],
|
||||||
|
}),
|
||||||
|
id: 4,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'Каждый год',
|
||||||
|
rule: { freq: RRule.YEARLY },
|
||||||
|
// По умолчанию - в тот же день и месяц
|
||||||
|
getRule: (startDate) => {
|
||||||
|
const date = new Date(startDate);
|
||||||
|
return {
|
||||||
|
freq: RRule.YEARLY,
|
||||||
|
bymonth: [date.getMonth() + 1],
|
||||||
|
bymonthday: [date.getDate()],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
id: 5,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const returnPeriod = computed({
|
const selectedRule = ref(repeatRules[0]);
|
||||||
get() {
|
|
||||||
let select = "";
|
// Инициализация при редактировании
|
||||||
if (propsEvent.value.event.period != null) {
|
const initializeRule = () => {
|
||||||
let objRule = JSON.parse(propsEvent.value.event.period);
|
if (!propsEvent.value.event.period) {
|
||||||
if (objRule != null) {
|
selectedRule.value = repeatRules[0]; // "Не повторять"
|
||||||
drawingRule(objRule.origOptions);
|
return;
|
||||||
repeatRules.findIndex(
|
}
|
||||||
(e) => e.rule.freq == objRule.origOptions.freq
|
try {
|
||||||
);
|
// Используем isRecurringEvent для проверки
|
||||||
select =
|
if (isRecurringEvent(propsEvent.value.event)) {
|
||||||
repeatRules[
|
// Парсим period с использованием parseRecurrenceOptions
|
||||||
repeatRules.findIndex(
|
const rruleOptions = parseRecurrenceOptions(
|
||||||
(e) => e.rule.freq == objRule.origOptions.freq
|
propsEvent.value.event.period,
|
||||||
)
|
propsEvent.value.event.date_start,
|
||||||
];
|
);
|
||||||
|
|
||||||
|
if (rruleOptions) {
|
||||||
|
// Находим правило в repeatRules по freq
|
||||||
|
const foundRule = repeatRules.find((rule) => rule.rule?.freq === rruleOptions.freq);
|
||||||
|
selectedRule.value = foundRule || repeatRules[0];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
select = repeatRules[0].type;
|
selectedRule.value = repeatRules[0];
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
calendarNewOrOld();
|
console.error('Error parsing period:', error, 'Raw period:', propsEvent.value.event.period);
|
||||||
|
selectedRule.value = repeatRules[0];
|
||||||
return select;
|
|
||||||
},
|
|
||||||
set(newValue) {
|
|
||||||
drawingRule(newValue.rule);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const drawingRule = (value) => {
|
|
||||||
let newRulse;
|
|
||||||
if (value.freq == 3) {
|
|
||||||
newRulse = new RRule({
|
|
||||||
...value,
|
|
||||||
dtstart: new Date(propsEvent.value.event.date_start),
|
|
||||||
until: new Date(propsEvent.value.event.date_end),
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value.freq == 2) {
|
|
||||||
newRulse = new RRule({
|
|
||||||
...value,
|
|
||||||
dtstart: new Date(propsEvent.value.event.date_start),
|
|
||||||
byweekday: getWeekNumbersBetweenDates(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (value.freq == 1) {
|
|
||||||
newRulse = new RRule({
|
|
||||||
...value,
|
|
||||||
bymonthday: getMonthBetweenDates(),
|
|
||||||
dtstart: new Date(propsEvent.value.event.date_start),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (value.freq == 0) {
|
|
||||||
newRulse = new RRule({
|
|
||||||
...value,
|
|
||||||
bymonthday: getYearBetweenDates(),
|
|
||||||
dtstart: new Date(propsEvent.value.event.date_start),
|
|
||||||
bymonth: getNumberMonth(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// byweekday: getWeekNumbersBetweenDates(),
|
|
||||||
Object.keys(value).length == 0
|
|
||||||
? (propsEvent.value.event.period = null)
|
|
||||||
: (propsEvent.value.event.period = JSON.stringify(newRulse));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const rulleWeek = [
|
|
||||||
RRule.SU,
|
|
||||||
RRule.MO,
|
|
||||||
RRule.TU,
|
|
||||||
RRule.WE,
|
|
||||||
RRule.TH,
|
|
||||||
RRule.FR,
|
|
||||||
RRule.SA,
|
|
||||||
];
|
|
||||||
|
|
||||||
const feedalert = useAlertStore().alert;
|
const feedalert = useAlertStore().alert;
|
||||||
|
|
||||||
const req = (val) => {
|
const titleCard = computed(() => {
|
||||||
return !!val || "Поле обязательно";
|
if (propsEvent.value.event.hasOwnProperty('id')) {
|
||||||
|
return 'Редактирование события';
|
||||||
|
} else {
|
||||||
|
return 'Новое событие';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const isNewEvent = computed(() => !propsEvent.value.event.hasOwnProperty('id'));
|
||||||
|
|
||||||
|
const myCalendar = ref(null);
|
||||||
|
// const isNewEvent = computed(() => !propsEvent.value.event.id);
|
||||||
|
|
||||||
|
// Computed property с защитой от undefined
|
||||||
|
const safeCalendars = computed(() => props.myCalendars || []);
|
||||||
|
|
||||||
|
const isCalendarsReady = computed(() => safeCalendars.value.length > 0);
|
||||||
|
|
||||||
|
// Computed для календаря события
|
||||||
|
const eventCalendar = computed(() => {
|
||||||
|
if (!propsEvent.value?.event?.calendar || !safeCalendars.value.length) return null;
|
||||||
|
return safeCalendars.value.find((cal) => cal.id === propsEvent.value.event.calendar);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Единоразовая инициализация при монтировании/получении данных
|
||||||
|
const initializeCalendar = () => {
|
||||||
|
if (myCalendar.value) return; // Уже инициализирован
|
||||||
|
|
||||||
|
// Приоритет 1: календарь из события (редактирование)
|
||||||
|
if (eventCalendar.value) {
|
||||||
|
myCalendar.value = eventCalendar.value;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Приоритет 2: первый доступный календарь (создание)
|
||||||
|
if (safeCalendars.value.length > 0) {
|
||||||
|
myCalendar.value = safeCalendars.value[0];
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const rules = {
|
// Инициализируем когда все готово
|
||||||
name: [(val) => req(val)],
|
watch(
|
||||||
};
|
[() => safeCalendars.value.length, () => propsEvent.value],
|
||||||
|
() => {
|
||||||
|
initializeCalendar();
|
||||||
|
},
|
||||||
|
{ immediate: true },
|
||||||
|
);
|
||||||
|
|
||||||
|
// Дополнительная защита - вотчер только на смену самого календаря
|
||||||
|
watch(eventCalendar, (newCalendar) => {
|
||||||
|
if (newCalendar && newCalendar.id !== myCalendar.value?.id) {
|
||||||
|
myCalendar.value = newCalendar;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const staff = ref([]);
|
const staff = ref([]);
|
||||||
|
|
||||||
axiosApiInstance
|
axiosApiInstance.get('api/calendar_of_events/get_employees/').then((res) => {
|
||||||
|
staff.value = res.data.filter((e) => e.employees.length > 0);
|
||||||
|
});
|
||||||
|
|
||||||
.get("api/calendar_of_events/get_employees/")
|
// const newStaff = computed({
|
||||||
.then((res) => {
|
// get() {
|
||||||
staff.value = res.data.filter((e) => e.employees.length > 0);
|
// let ns = [];
|
||||||
});
|
|
||||||
|
|
||||||
const accountStore = useAccountStore();
|
// let indCal = safeCalendars.value.findIndex((e) => e.id == myCalendar.id);
|
||||||
|
|
||||||
const newStaff = computed({
|
// staff.value.forEach((e) => {
|
||||||
get() {
|
// let emp = { ...e };
|
||||||
let ns = [];
|
// emp.employees = e.employees.filter((n) => {
|
||||||
|
// if (
|
||||||
|
// n.id == accountStore.user.is_idEmployee ||
|
||||||
|
// propsEvent.value.event.participant.some((e) => n.id == e)
|
||||||
|
// ) {
|
||||||
|
// n.selected = true;
|
||||||
|
// }
|
||||||
|
|
||||||
let indCal = propsEvent.value.mycalendars.findIndex(
|
// return propsEvent.value.mycalendars[indCal].participant.some(
|
||||||
(e) => e.id == calendar.value[0].id
|
// (part) => part.id === n.id,
|
||||||
|
// );
|
||||||
|
// });
|
||||||
|
|
||||||
|
// if (emp.employees.length > 0) ns.push(emp);
|
||||||
|
// });
|
||||||
|
// return ns;
|
||||||
|
// },
|
||||||
|
// });
|
||||||
|
|
||||||
|
const newStaff = computed(() => {
|
||||||
|
// Для нового события - все сотрудники, для существующего - фильтр по календарю
|
||||||
|
// const isNewEvent = !propsEvent.value.event.id;
|
||||||
|
|
||||||
|
if (isNewEvent) {
|
||||||
|
// НОВОЕ СОБЫТИЕ - все сотрудники
|
||||||
|
const eventParticipantIds = propsEvent.value.event.participant || [];
|
||||||
|
|
||||||
|
return staff.value
|
||||||
|
.map((department) => ({
|
||||||
|
...department,
|
||||||
|
employees: department.employees.map((employee) => ({
|
||||||
|
...employee,
|
||||||
|
selected:
|
||||||
|
employee.id === accountStore.user.is_idEmployee ||
|
||||||
|
eventParticipantIds.includes(employee.id),
|
||||||
|
})),
|
||||||
|
}))
|
||||||
|
.filter((dept) => dept.employees.length > 0);
|
||||||
|
} else {
|
||||||
|
// СУЩЕСТВУЮЩЕЕ СОБЫТИЕ - фильтр по календарю
|
||||||
|
|
||||||
|
const eventCalendarId = propsEvent.value.event.calendar;
|
||||||
|
if (!eventCalendarId) return [];
|
||||||
|
|
||||||
|
const currentCalendar = propsEvent.value.mycalendars?.find(
|
||||||
|
(cal) => parseInt(cal.id) === parseInt(eventCalendarId),
|
||||||
);
|
);
|
||||||
|
|
||||||
staff.value.forEach((e) => {
|
if (!currentCalendar?.participant) return [];
|
||||||
let emp = { ...e };
|
|
||||||
emp.employees = e.employees.filter((n) => {
|
|
||||||
if (
|
|
||||||
n.id == accountStore.user.is_idEmployee ||
|
|
||||||
propsEvent.value.event.participant.some((e) => n.id == e)
|
|
||||||
) {
|
|
||||||
n.selected = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return propsEvent.value.mycalendars[indCal].participant.some(
|
const calendarParticipantIds = new Set(currentCalendar.participant.map((p) => p.id));
|
||||||
(part) => part.id === n.id
|
const eventParticipantIds = new Set(propsEvent.value.event.participant || []);
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (emp.employees.length > 0) ns.push(emp);
|
return staff.value
|
||||||
});
|
.map((department) => ({
|
||||||
return ns;
|
...department,
|
||||||
},
|
employees: department.employees.map((employee) => ({
|
||||||
|
...employee,
|
||||||
|
selected: eventParticipantIds.has(employee.id),
|
||||||
|
// Дополнительная информация для UX
|
||||||
|
inCalendar: calendarParticipantIds.has(employee.id),
|
||||||
|
disabled: false, // Всех можно выбирать
|
||||||
|
})),
|
||||||
|
}))
|
||||||
|
.filter((dept) => dept.employees.length > 0);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const delEvent = (idev) => {
|
const delEvent = (idev) => {
|
||||||
axiosApiInstance
|
axiosApiInstance.delete(`api/calendar_of_events/my_events/?delid=${idev}`).then((result) => {
|
||||||
.delete(`api/calendar_of_events/my_events/?delid=${idev}`)
|
feedalert.alert = true;
|
||||||
.then((result) => {
|
feedalert.text = result.data.mess;
|
||||||
feedalert.alert = true;
|
feedalert.ico = 'mdi-check';
|
||||||
feedalert.text = result.data.mess;
|
feedalert.color = 'orange-accent-1';
|
||||||
feedalert.ico = "mdi-check";
|
emit('getCalendar');
|
||||||
feedalert.color = "orange-accent-1";
|
});
|
||||||
emit("getCalendar");
|
emit('closeDialog');
|
||||||
});
|
|
||||||
emit("closeDialog");
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const files = ref([]);
|
const newFiles = ref([]);
|
||||||
const postFiles = (f) => {
|
|
||||||
files.value = f;
|
const handleFilesUpdate = (updatedExistingFiles) => {
|
||||||
|
// Сохраняем новые файлы во временную переменную
|
||||||
|
const currentNewFiles = [...newFiles.value];
|
||||||
|
|
||||||
|
// Обновляем существующие файлы
|
||||||
|
propsEvent.value.event.files = updatedExistingFiles;
|
||||||
|
|
||||||
|
// Восстанавливаем новые файлы
|
||||||
|
newFiles.value = currentNewFiles;
|
||||||
};
|
};
|
||||||
|
|
||||||
const calendar = computed({
|
const postFiles = (updatedFiles) => {
|
||||||
get() {
|
newFiles.value = updatedFiles;
|
||||||
let selected = [];
|
|
||||||
if (propsEvent.value.event.calendar) {
|
|
||||||
let ind = propsEvent.value.mycalendars.findIndex(
|
|
||||||
(e) => e.id == propsEvent.value.event.calendar
|
|
||||||
);
|
|
||||||
selected.push({
|
|
||||||
cl_name: propsEvent.value.mycalendars[ind].cl_name,
|
|
||||||
cl_color: propsEvent.value.mycalendars[ind].cl_color,
|
|
||||||
id: propsEvent.value.mycalendars[ind].id,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
selected.push({
|
|
||||||
cl_name: propsEvent.value.mycalendars[0].cl_name,
|
|
||||||
cl_color: propsEvent.value.mycalendars[0].cl_color,
|
|
||||||
id: propsEvent.value.mycalendars[0].id,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (propsEvent.value.event.calendar == null)
|
|
||||||
propsEvent.value.event.calendar = propsEvent.value.mycalendars[0].id;
|
|
||||||
|
|
||||||
return selected;
|
|
||||||
},
|
|
||||||
|
|
||||||
set(newValue) {
|
|
||||||
propsEvent.value.event.calendar = newValue.value;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const titleCard = ref("");
|
|
||||||
const newEvent = ref(false);
|
|
||||||
|
|
||||||
const calendarNewOrOld = () => {
|
|
||||||
if (propsEvent.value.event.hasOwnProperty("id")) {
|
|
||||||
titleCard.value = "Редактирование события";
|
|
||||||
newEvent.value = false;
|
|
||||||
} else {
|
|
||||||
titleCard.value = "Новое событие";
|
|
||||||
newEvent.value = true;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const returnIdParticant = (idPart) => {
|
const returnIdParticant = (idPart) => {
|
||||||
idPart.staff.forEach((e) => {
|
idPart.staff.forEach((e) => {
|
||||||
if (
|
if (e.selected == true && !propsEvent.value.event.participant.includes(e.id)) {
|
||||||
e.selected == true &&
|
|
||||||
!propsEvent.value.event.participant.includes(e.id)
|
|
||||||
) {
|
|
||||||
propsEvent.value.event.participant.push(e.id);
|
propsEvent.value.event.participant.push(e.id);
|
||||||
} else {
|
} else {
|
||||||
let ind = propsEvent.value.event.participant.findIndex(
|
let ind = propsEvent.value.event.participant.findIndex((l) => l == e.id);
|
||||||
(l) => l == e.id
|
|
||||||
);
|
|
||||||
|
|
||||||
if (ind != -1) {
|
if (ind != -1) {
|
||||||
propsEvent.value.event.participant.splice(ind, 1);
|
propsEvent.value.event.participant.splice(ind, 1);
|
||||||
@@ -457,169 +493,125 @@ export default {
|
|||||||
|
|
||||||
const cbSelect = (item, arr) => {
|
const cbSelect = (item, arr) => {
|
||||||
item.forEach((e) => {
|
item.forEach((e) => {
|
||||||
if (!("employees" in e)) {
|
if (!('employees' in e)) {
|
||||||
if (!propsEvent.value.event.participant.includes(e.id)) {
|
if (!propsEvent.value.event.participant.includes(e.id)) {
|
||||||
propsEvent.value.event.participant.push(e.id);
|
propsEvent.value.event.participant.push(e.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ("employees" in e) {
|
if ('employees' in e) {
|
||||||
cbSelect(e.employees);
|
cbSelect(e.employees);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const dateEvent = computed({
|
|
||||||
get() {
|
|
||||||
return formatComa(new Date(propsEvent.value.event.date_start));
|
|
||||||
},
|
|
||||||
|
|
||||||
set(newValue) {
|
|
||||||
let dateParts = newValue.split(".");
|
|
||||||
|
|
||||||
// let d = new Date(propsEvent.value.event.date_start).setFullYear(parseInt(dateParts[2], 10), parseInt(dateParts[1], 10), parseInt(dateParts[0], 10))
|
|
||||||
// let d = new Date(propsEvent.value.event.date_start).setDate(new Date(2024,01,01))
|
|
||||||
// propsEvent.value.event.date_start = new Date(2024,01,01);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const menudate = ref(false);
|
const menudate = ref(false);
|
||||||
|
|
||||||
const postData = (validate) => {
|
const postData = (validate) => {
|
||||||
if (validate) {
|
if (validate) {
|
||||||
|
updatePeriodRule(selectedRule.value);
|
||||||
|
propsEvent.value.event.calendar = myCalendar.value.id;
|
||||||
|
|
||||||
let postEvent = new FormData();
|
let postEvent = new FormData();
|
||||||
|
|
||||||
postEvent.append(
|
postEvent.append(
|
||||||
"event",
|
'event',
|
||||||
JSON.stringify({ ...propsEvent.value.event })
|
JSON.stringify({ ...propsEvent.value.event, files: propsEvent.value.event.files }),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
console.log([propsEvent.value]);
|
||||||
if (propsEvent.value.event.files !== null) {
|
if (propsEvent.value.event.files !== null) {
|
||||||
files.value.forEach((e) => postEvent.append("files", e));
|
newFiles.value.forEach((e) => postEvent.append('files', e));
|
||||||
}
|
}
|
||||||
|
|
||||||
axiosApiInstance
|
axiosApiInstance.post('api/calendar_of_events/my_events/', postEvent).then((result) => {
|
||||||
.post("api/calendar_of_events/my_events/", postEvent)
|
feedalert.alert = true;
|
||||||
.then((result) => {
|
feedalert.text = result.data.mess;
|
||||||
feedalert.alert = true;
|
feedalert.ico = 'mdi-check';
|
||||||
feedalert.text = result.data.mess;
|
feedalert.color = 'green-darken-4';
|
||||||
feedalert.ico = "mdi-check";
|
emit('getCalendar');
|
||||||
feedalert.color = "green-darken-4";
|
emit('closeDialog');
|
||||||
emit("getCalendar");
|
});
|
||||||
emit("closeDialog");
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const getWeekNumbersBetweenDates = () => {
|
const handleAutoAdjustEnd = (newEndDate) => {
|
||||||
const start = new Date(propsEvent.value.event.date_start);
|
propsEvent.value.event.date_end = newEndDate;
|
||||||
const end = new Date(propsEvent.value.event.date_end);
|
};
|
||||||
let s = start.getDay();
|
|
||||||
let e = end.getDay();
|
const updateDateStart = (newDate) => {
|
||||||
const weekNumbers = [];
|
// Нормализуем к ISO строке
|
||||||
if (start.getDay() > end.getDay()) {
|
const normalizedDate = new Date(newDate).toISOString();
|
||||||
e = 6;
|
propsEvent.value.event.date_start = normalizedDate;
|
||||||
for (let x = s; x <= e; x++) {
|
|
||||||
weekNumbers.push(x);
|
// При изменении даты начала - обновляем правило повторений
|
||||||
|
const startDate = new Date(normalizedDate);
|
||||||
|
const endDate = new Date(propsEvent.value.event.date_end);
|
||||||
|
|
||||||
|
if (startDate > endDate) {
|
||||||
|
const adjustedEnd = new Date(startDate);
|
||||||
|
adjustedEnd.setHours(startDate.getHours() + 1);
|
||||||
|
propsEvent.value.event.date_end = adjustedEnd.toISOString(); // Тоже ISO
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selectedRule.value.rule) {
|
||||||
|
updatePeriodRule(selectedRule.value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const updateDateEnd = (newDate) => {
|
||||||
|
// Нормализуем к ISO строке
|
||||||
|
propsEvent.value.event.date_end = new Date(newDate).toISOString();
|
||||||
|
};
|
||||||
|
|
||||||
|
// функция обновления периода
|
||||||
|
const updatePeriodRule = (rule) => {
|
||||||
|
selectedRule.value = rule;
|
||||||
|
|
||||||
|
if (!rule.rule) {
|
||||||
|
propsEvent.value.event.period = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const dtstart = new Date(propsEvent.value.event.date_start);
|
||||||
|
|
||||||
|
const ruleOptions = {
|
||||||
|
...rule.rule,
|
||||||
|
dtstart: dtstart,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (rule.rule.freq === RRule.WEEKLY) {
|
||||||
|
const day = new Date(propsEvent.value.event.date_start).getDay();
|
||||||
|
// Преобразуем день недели в формат RRule (0 — понедельник)
|
||||||
|
const byweekday = [day === 0 ? RRule.SU : day - 1];
|
||||||
|
ruleOptions.byweekday = byweekday;
|
||||||
|
}
|
||||||
|
if (rule.rule.freq === RRule.MONTHLY) {
|
||||||
|
ruleOptions.bymonthday = [new Date(propsEvent.value.event.date_start).getDate()];
|
||||||
|
}
|
||||||
|
if (rule.rule.freq === RRule.YEARLY) {
|
||||||
|
const date = new Date(propsEvent.value.event.date_start);
|
||||||
|
ruleOptions.bymonth = [date.getMonth() + 1];
|
||||||
|
ruleOptions.bymonthday = [date.getDate()];
|
||||||
|
}
|
||||||
|
const rrule = new RRule(ruleOptions);
|
||||||
|
|
||||||
|
propsEvent.value.event.period = rrule.toString();
|
||||||
|
};
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => propsEvent.value.event?.period,
|
||||||
|
(newPeriod) => {
|
||||||
|
if (newPeriod) {
|
||||||
|
initializeRule();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (start.getDay() != end.getDay() && start.getDay() > end.getDay()) {
|
|
||||||
s = 0;
|
|
||||||
|
|
||||||
for (let x = s; x <= end.getDay(); x++) {
|
|
||||||
weekNumbers.push(x);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (start.getDay() < end.getDay()) {
|
|
||||||
for (let x = s; x <= end.getDay(); x++) {
|
|
||||||
weekNumbers.push(x);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (start.getDay() == end.getDay()) {
|
|
||||||
weekNumbers.push(start.getDay());
|
|
||||||
}
|
|
||||||
let rulesWeek = [];
|
|
||||||
weekNumbers.forEach((i) => {
|
|
||||||
rulesWeek.push(rulleWeek[i]);
|
|
||||||
});
|
|
||||||
|
|
||||||
return rulesWeek;
|
|
||||||
};
|
|
||||||
|
|
||||||
const getMonthBetweenDates = () => {
|
|
||||||
const start = new Date(propsEvent.value.event.date_start);
|
|
||||||
const end = new Date(propsEvent.value.event.date_end);
|
|
||||||
let s = start.getDate();
|
|
||||||
let e = end.getDate();
|
|
||||||
|
|
||||||
const dateNumbers = [];
|
|
||||||
for (let x = s; x <= e; x++) {
|
|
||||||
dateNumbers.push(x);
|
|
||||||
}
|
|
||||||
console.log(dateNumbers.length, "дни в месяце");
|
|
||||||
return dateNumbers;
|
|
||||||
};
|
|
||||||
|
|
||||||
const getYearBetweenDates = () => {
|
|
||||||
const start = new Date(propsEvent.value.event.date_start);
|
|
||||||
const end = new Date(propsEvent.value.event.date_end);
|
|
||||||
let dates = getDatesBetweenDates(start, end);
|
|
||||||
let date = [];
|
|
||||||
dates.forEach((e) => date.push(new Date(e).getDate()));
|
|
||||||
return date;
|
|
||||||
};
|
|
||||||
|
|
||||||
const getNumberMonth = () => {
|
|
||||||
const start = new Date(propsEvent.value.event.date_start);
|
|
||||||
const end = new Date(propsEvent.value.event.date_end);
|
|
||||||
let sm = start.getMonth();
|
|
||||||
let em = end.getMonth();
|
|
||||||
let month = [];
|
|
||||||
month.push(sm + 1);
|
|
||||||
|
|
||||||
if (!month.includes(em + 1)) month.push(em + 1);
|
|
||||||
console.log(month, "month");
|
|
||||||
return month;
|
|
||||||
};
|
|
||||||
|
|
||||||
const getDatesBetweenDates = (startDate, endDate) => {
|
|
||||||
let dates = [];
|
|
||||||
let currentDate = new Date(startDate);
|
|
||||||
|
|
||||||
while (currentDate <= endDate) {
|
|
||||||
dates.push(new Date(currentDate));
|
|
||||||
currentDate.setDate(currentDate.getDate() + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return dates;
|
|
||||||
};
|
|
||||||
|
|
||||||
const what = (w) => {
|
|
||||||
console.log(w, "?????????????????????????????????");
|
|
||||||
};
|
|
||||||
|
|
||||||
const periodDisplayRule = (idItem) => {
|
|
||||||
if (getNumberOfDays.value >= 7 && idItem == 3) {
|
|
||||||
return true;
|
|
||||||
} else return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
const getNumberOfDays = computed({
|
|
||||||
get() {
|
|
||||||
const start = new Date(propsEvent.value.event.date_start);
|
|
||||||
const end = new Date(propsEvent.value.event.date_end);
|
|
||||||
const oneDay = 1000 * 60 * 60 * 24;
|
|
||||||
const diffInTime = end.getTime() - start.getTime();
|
|
||||||
const diffInDays = Math.round(diffInTime / oneDay);
|
|
||||||
|
|
||||||
return diffInDays;
|
|
||||||
},
|
},
|
||||||
});
|
{ immediate: true },
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
menudate,
|
menudate,
|
||||||
titleCard,
|
titleCard,
|
||||||
newEvent,
|
|
||||||
propsEvent,
|
propsEvent,
|
||||||
dateEvent,
|
|
||||||
calendar,
|
|
||||||
staff,
|
staff,
|
||||||
newStaff,
|
newStaff,
|
||||||
returnIdParticant,
|
returnIdParticant,
|
||||||
@@ -627,14 +619,23 @@ export default {
|
|||||||
postData,
|
postData,
|
||||||
rules,
|
rules,
|
||||||
delEvent,
|
delEvent,
|
||||||
|
myCalendar,
|
||||||
|
safeCalendars,
|
||||||
|
isCalendarsReady,
|
||||||
|
isNewEvent,
|
||||||
|
|
||||||
repeatRules,
|
repeatRules,
|
||||||
returnPeriod,
|
updatePeriodRule,
|
||||||
periodDisplayRule,
|
selectedRule,
|
||||||
what,
|
updateDateEnd,
|
||||||
|
updateDateStart,
|
||||||
|
initializeRule,
|
||||||
|
|
||||||
createDialog,
|
createDialog,
|
||||||
getMonthBetweenDates,
|
handleAutoAdjustEnd,
|
||||||
|
newFiles,
|
||||||
|
handleFilesUpdate,
|
||||||
|
initializeCalendar,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -9,13 +9,17 @@
|
|||||||
hide-delimiters
|
hide-delimiters
|
||||||
hide-delimiter-background
|
hide-delimiter-background
|
||||||
:show-arrows="carous.length < 2 ? false : 'hover'"
|
:show-arrows="carous.length < 2 ? false : 'hover'"
|
||||||
color="white"
|
color="teal-darken-4"
|
||||||
@update:modelValue="slidechanged"
|
@update:modelValue="slidechanged"
|
||||||
>
|
>
|
||||||
<template 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>
|
<v-carousel-item v-if="!x.link.endsWith('mp4')" :src="`${burl}${x.link}`" cover eager>
|
||||||
<v-container fill-height fluid pa-0 ma-0 pb-3 class="flex-column h-100 d-flex">
|
<v-container fill-height fluid pa-0 ma-0 pb-3 class="flex-column h-100 d-flex">
|
||||||
<v-card v-if="x.text !== '' || x.title != null" class="bgCard h-100 d-flex flex-column">
|
<v-card
|
||||||
|
v-if="x.text !== '' || x.title != null"
|
||||||
|
class="bgCard h-100 d-flex flex-column"
|
||||||
|
style="background: rgba(255, 255, 255, 0.3) !important; background-color: rgba(255, 255, 255, 0.3) !important;"
|
||||||
|
>
|
||||||
<v-card-title
|
<v-card-title
|
||||||
v-if="x.title != null"
|
v-if="x.title != null"
|
||||||
class="text-h3 text-uppercase titles text-text_carous ma-1 mb-0"
|
class="text-h3 text-uppercase titles text-text_carous ma-1 mb-0"
|
||||||
@@ -176,7 +180,17 @@ export default {
|
|||||||
<style>
|
<style>
|
||||||
.titles {
|
.titles {
|
||||||
font-family: cursive !important;
|
font-family: cursive !important;
|
||||||
background: #ffffff8c;
|
background: rgba(255, 255, 255, 0.7) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bgCard {
|
||||||
|
background: rgba(255, 255, 255, 0.5) !important;
|
||||||
|
background-color: rgba(255, 255, 255, 0.5) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.v-card.bgCard {
|
||||||
|
background: rgba(255, 255, 255, 0.5) !important;
|
||||||
|
background-color: rgba(255, 255, 255, 0.5) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.textareas .v-field__input {
|
.textareas .v-field__input {
|
||||||
@@ -187,3 +201,19 @@ export default {
|
|||||||
cursor: default !important;
|
cursor: default !important;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
<style scoped>
|
||||||
|
.bgCard {
|
||||||
|
background: rgba(255, 255, 255, 0.3) !important;
|
||||||
|
background-color: rgba(255, 255, 255, 0.3) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.v-card.bgCard {
|
||||||
|
background: rgba(255, 255, 255, 0.3) !important;
|
||||||
|
background-color: rgba(255, 255, 255, 0.3) !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.titles, .text-text_carous, .text-text_caroustext-black, .v-card-title, .v-card-text, .v-textarea .v-field__input {
|
||||||
|
color: #111 !important;
|
||||||
|
text-shadow: none !important;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
</v-card-title>
|
</v-card-title>
|
||||||
<v-card-text
|
<v-card-text
|
||||||
@click="detailRound(x.position, x.position__name)"
|
@click="detailRound(x.position, x.position__name)"
|
||||||
class="numstyle mt-2 py-0 font-weight-bold cursor-pointer bg-black_and_white"
|
class="numstyle mt-2 py-0 font-weight-bold cursor-pointer bg-black_and_white text-teal-darken-4"
|
||||||
>
|
>
|
||||||
|
|
||||||
<vue3-autocounter
|
<vue3-autocounter
|
||||||
@@ -53,7 +53,7 @@
|
|||||||
v-if="accountStore.user.is_staff"
|
v-if="accountStore.user.is_staff"
|
||||||
v-model="changeData"
|
v-model="changeData"
|
||||||
class="pl-3 d-flex justify-end"
|
class="pl-3 d-flex justify-end"
|
||||||
color="white"
|
color="teal-darken-4"
|
||||||
@click="changeData=!changeData">
|
@click="changeData=!changeData">
|
||||||
</v-switch>
|
</v-switch>
|
||||||
</v-col>
|
</v-col>
|
||||||
@@ -181,7 +181,6 @@ export default {
|
|||||||
const onPickFile = (ex) => {
|
const onPickFile = (ex) => {
|
||||||
const sdata = new FormData()
|
const sdata = new FormData()
|
||||||
sdata.append('dailyfiles', dailyfiles.value)
|
sdata.append('dailyfiles', dailyfiles.value)
|
||||||
console.log(dailyfiles.value);
|
|
||||||
axiosApiInstance.post(`api/general_vacation/dailyroundup/?excel=${ex}`, sdata).then(result => {
|
axiosApiInstance.post(`api/general_vacation/dailyroundup/?excel=${ex}`, sdata).then(result => {
|
||||||
info.value = result.data
|
info.value = result.data
|
||||||
dailyfun()
|
dailyfun()
|
||||||
@@ -236,3 +235,13 @@ export default {
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.numstyle {
|
||||||
|
font-size: 2.8rem !important;
|
||||||
|
font-weight: 900 !important;
|
||||||
|
color: #222 !important;
|
||||||
|
letter-spacing: 0.05em;
|
||||||
|
font-family: 'Montserrat', 'Arial', sans-serif;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -77,7 +77,6 @@ export default {
|
|||||||
const onPickFile = (ex) => {
|
const onPickFile = (ex) => {
|
||||||
const sdata = new FormData()
|
const sdata = new FormData()
|
||||||
sdata.append('dailyfiles', dailyfiles.value)
|
sdata.append('dailyfiles', dailyfiles.value)
|
||||||
console.log(dailyfiles.value);
|
|
||||||
axiosApiInstance.post(`api/general_vacation/dailyroundup/?excel=${ex}`, sdata).then(result => {
|
axiosApiInstance.post(`api/general_vacation/dailyroundup/?excel=${ex}`, sdata).then(result => {
|
||||||
textFromAlert(result.data['mess'])
|
textFromAlert(result.data['mess'])
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<v-col class="flex-column d-flex">
|
<v-col class="flex-column d-flex">
|
||||||
<v-row class="flex-grow-0">
|
<v-row class="flex-grow-0">
|
||||||
<v-col class="pb-0 pr-0">
|
<v-col class="pb-0 pr-0">
|
||||||
<v-card height="350px" class="rounded-b-0">
|
<v-card class="rounded-b-0">
|
||||||
<v-card-title class="pt-0 pb-1 flex-column d-flex">
|
<v-card-title class="pt-0 pb-1 flex-column d-flex">
|
||||||
<v-row>
|
<v-row>
|
||||||
<v-col lg="9" class="pt-4">
|
<v-col lg="9" class="pt-4">
|
||||||
@@ -58,11 +58,11 @@
|
|||||||
|
|
||||||
<!-- -->
|
<!-- -->
|
||||||
<v-img
|
<v-img
|
||||||
:src="`${burl}${newsFull.link}`"
|
:src="newsFull.link ? `${burl}${newsFull.link}` : defaultImage"
|
||||||
height="450px"
|
height="450px"
|
||||||
width="96%"
|
width="96%"
|
||||||
class="mx-auto"
|
class="mx-auto"
|
||||||
cover
|
contain
|
||||||
@click="openOneImg(newsFull.link)"
|
@click="openOneImg(newsFull.link)"
|
||||||
/>
|
/>
|
||||||
</v-card>
|
</v-card>
|
||||||
@@ -282,7 +282,7 @@
|
|||||||
variant="text"
|
variant="text"
|
||||||
size="small"
|
size="small"
|
||||||
icon="mdi-delete"
|
icon="mdi-delete"
|
||||||
color="delete_btn"
|
color="teal-darken-4"
|
||||||
@click="deletComment(y.id, newsFull.id)"
|
@click="deletComment(y.id, newsFull.id)"
|
||||||
/>
|
/>
|
||||||
</v-col>
|
</v-col>
|
||||||
@@ -353,6 +353,7 @@
|
|||||||
density="compact"
|
density="compact"
|
||||||
variant="text"
|
variant="text"
|
||||||
icon="mdi-close"
|
icon="mdi-close"
|
||||||
|
color="teal-darken-4"
|
||||||
@click="dialogfoto = false"
|
@click="dialogfoto = false"
|
||||||
/>
|
/>
|
||||||
</v-col>
|
</v-col>
|
||||||
@@ -364,6 +365,7 @@
|
|||||||
density="compact"
|
density="compact"
|
||||||
variant="text"
|
variant="text"
|
||||||
icon="mdi-chevron-left"
|
icon="mdi-chevron-left"
|
||||||
|
color="teal-darken-4"
|
||||||
@click="
|
@click="
|
||||||
indximg != 0
|
indximg != 0
|
||||||
? (indximg -= 1)
|
? (indximg -= 1)
|
||||||
@@ -382,6 +384,7 @@
|
|||||||
density="compact"
|
density="compact"
|
||||||
variant="text"
|
variant="text"
|
||||||
icon="mdi-chevron-right"
|
icon="mdi-chevron-right"
|
||||||
|
color="teal-darken-4"
|
||||||
@click="
|
@click="
|
||||||
indximg != newsFull.gallery.length - 1
|
indximg != newsFull.gallery.length - 1
|
||||||
? (indximg += 1)
|
? (indximg += 1)
|
||||||
@@ -422,6 +425,7 @@
|
|||||||
density="compact"
|
density="compact"
|
||||||
variant="text"
|
variant="text"
|
||||||
icon="mdi-close"
|
icon="mdi-close"
|
||||||
|
color="teal-darken-4"
|
||||||
@click="dialogfotoOne = false"
|
@click="dialogfotoOne = false"
|
||||||
/>
|
/>
|
||||||
</v-col>
|
</v-col>
|
||||||
@@ -446,6 +450,7 @@ import { spravURL } from "@/utils/axios-api";
|
|||||||
import { useAccountStore } from "@/store/AccountStore";
|
import { useAccountStore } from "@/store/AccountStore";
|
||||||
import { format } from "date-fns";
|
import { format } from "date-fns";
|
||||||
import icoUser from "@/components/UI/fiousercard/icoUser.vue";
|
import icoUser from "@/components/UI/fiousercard/icoUser.vue";
|
||||||
|
import defaultImage from '@/assets/emblem.png';
|
||||||
|
|
||||||
const accountStore = useAccountStore();
|
const accountStore = useAccountStore();
|
||||||
|
|
||||||
@@ -586,6 +591,7 @@ export default {
|
|||||||
spravURL,
|
spravURL,
|
||||||
splitname,
|
splitname,
|
||||||
accountStore,
|
accountStore,
|
||||||
|
defaultImage,
|
||||||
formatText,
|
formatText,
|
||||||
dateformat,
|
dateformat,
|
||||||
textcomment,
|
textcomment,
|
||||||
|
|||||||
@@ -56,7 +56,7 @@
|
|||||||
size="small"
|
size="small"
|
||||||
variant="text"
|
variant="text"
|
||||||
icon="mdi-newspaper"
|
icon="mdi-newspaper"
|
||||||
color="blue-darken-4"
|
color="teal-darken-4"
|
||||||
:to='`/news`'
|
:to='`/news`'
|
||||||
/>
|
/>
|
||||||
</v-col>
|
</v-col>
|
||||||
|
|||||||
@@ -0,0 +1,336 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<v-dialog
|
||||||
|
:model-value="modelValue"
|
||||||
|
@update:model-value="$emit('update:modelValue', $event)"
|
||||||
|
max-width="800"
|
||||||
|
persistent
|
||||||
|
>
|
||||||
|
<v-card class="rounded-lg" color="cards">
|
||||||
|
<v-card-title class="text-h5 font-weight-medium px-4 py-3 bg-teal-darken-4 text-white d-flex align-center">
|
||||||
|
<span>Назначение теста</span>
|
||||||
|
<v-spacer></v-spacer>
|
||||||
|
<v-btn
|
||||||
|
icon="mdi-close"
|
||||||
|
variant="text"
|
||||||
|
color="white"
|
||||||
|
@click="$emit('update:modelValue', false)"
|
||||||
|
></v-btn>
|
||||||
|
</v-card-title>
|
||||||
|
<v-divider></v-divider>
|
||||||
|
<v-card-text class="px-4 py-4">
|
||||||
|
<div class="text-subtitle-1 font-weight-medium mb-3 text-teal-darken-1">Выберите сотрудников</div>
|
||||||
|
<SearcEmployess
|
||||||
|
:modelValue="selectedEmployees"
|
||||||
|
:assignedEmployees="assignedEmployees"
|
||||||
|
:useUsersApi="true"
|
||||||
|
@update:modelValue="handleEmployeeSelection"
|
||||||
|
class="mb-6"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<v-divider class="mb-4"></v-divider>
|
||||||
|
|
||||||
|
<div class="d-flex gap-4 mb-6">
|
||||||
|
<div class="flex-grow-1">
|
||||||
|
<div class="d-flex align-center mb-2">
|
||||||
|
<v-icon icon="mdi-calendar-clock-outline" color="teal-darken-2" class="mr-2"></v-icon>
|
||||||
|
<span class="text-subtitle-1 font-weight-medium text-teal-darken-1">Дата начала теста</span>
|
||||||
|
</div>
|
||||||
|
<date-select
|
||||||
|
:datedefault="startDate"
|
||||||
|
@returndate="(date) => handleDateChange(date, 'start')"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex-grow-1">
|
||||||
|
<div class="d-flex align-center mb-2">
|
||||||
|
<v-icon icon="mdi-calendar-clock" color="teal-darken-2" class="mr-2"></v-icon>
|
||||||
|
<span class="text-subtitle-1 font-weight-medium text-teal-darken-1">Дата окончания теста</span>
|
||||||
|
</div>
|
||||||
|
<date-select
|
||||||
|
:datedefault="completionDate"
|
||||||
|
@returndate="(date) => handleDateChange(date, 'end')"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="d-flex flex-column justify-center ml-4">
|
||||||
|
<div class="d-flex align-center">
|
||||||
|
<v-icon icon="mdi-newspaper" color="teal-darken-2" class="mr-2"></v-icon>
|
||||||
|
<span class="text-subtitle-1 font-weight-medium text-teal-darken-1 mr-4">Публиковать новость</span>
|
||||||
|
<v-switch
|
||||||
|
v-model="publishNews"
|
||||||
|
color="teal-darken-2"
|
||||||
|
hide-details
|
||||||
|
inset
|
||||||
|
></v-switch>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-if="assignedEmployees?.length > 0" class="mb-4">
|
||||||
|
<div class="d-flex align-center mb-2">
|
||||||
|
<v-icon icon="mdi-account-multiple" color="orange-darken-2" class="mr-2"></v-icon>
|
||||||
|
<span class="text-subtitle-1 font-weight-medium text-orange-darken-2">
|
||||||
|
Уже назначено сотрудников: {{ assignedEmployees.length }}
|
||||||
|
</span>
|
||||||
|
<v-spacer></v-spacer>
|
||||||
|
<v-tooltip text="Снять все назначения" location="top">
|
||||||
|
<template #activator="{ props }">
|
||||||
|
<v-btn
|
||||||
|
v-bind="props"
|
||||||
|
icon="mdi-close"
|
||||||
|
variant="text"
|
||||||
|
density="compact"
|
||||||
|
color="red-darken-1"
|
||||||
|
@click="$emit('unassignAll')"
|
||||||
|
size="big"
|
||||||
|
>
|
||||||
|
<v-icon icon="mdi-close" />
|
||||||
|
</v-btn>
|
||||||
|
</template>
|
||||||
|
</v-tooltip>
|
||||||
|
</div>
|
||||||
|
<v-list density="compact" class="bg-grey-lighten-4 rounded-lg">
|
||||||
|
<template v-if="assignedEmployeesDetails.length > 0">
|
||||||
|
<v-list-item
|
||||||
|
v-for="employee in assignedEmployeesDetails"
|
||||||
|
:key="employee.id"
|
||||||
|
:prepend-avatar="checkremote(`${spravURL}${employee.login}.jpg`)"
|
||||||
|
class="py-1"
|
||||||
|
>
|
||||||
|
<template #title>
|
||||||
|
<div class="d-flex align-center">
|
||||||
|
<div>
|
||||||
|
<span class="text-orange-darken-2">{{ employee.fio }}</span>
|
||||||
|
<div class="text-caption text-grey-darken-1" v-if="employee.datestart">
|
||||||
|
Дата начала: {{ new Date(employee.datestart).toLocaleDateString('ru-RU') }}
|
||||||
|
</div>
|
||||||
|
<div class="text-caption text-grey-darken-1" v-if="employee.completion_date">
|
||||||
|
Дата окончания: {{ new Date(employee.completion_date).toLocaleDateString('ru-RU') }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<v-tooltip text="Снять назначение" location="top">
|
||||||
|
<template #activator="{ props }">
|
||||||
|
<v-btn
|
||||||
|
v-bind="props"
|
||||||
|
icon="mdi-close"
|
||||||
|
variant="text"
|
||||||
|
density="compact"
|
||||||
|
color="red-darken-1"
|
||||||
|
class="ml-auto"
|
||||||
|
@click="$emit('unassign', employee)"
|
||||||
|
>
|
||||||
|
<v-icon icon="mdi-close" />
|
||||||
|
</v-btn>
|
||||||
|
</template>
|
||||||
|
</v-tooltip>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</v-list-item>
|
||||||
|
</template>
|
||||||
|
<v-list-item v-else>
|
||||||
|
<template #title>
|
||||||
|
<span class="text-grey-darken-1">Загрузка списка сотрудников...</span>
|
||||||
|
</template>
|
||||||
|
</v-list-item>
|
||||||
|
</v-list>
|
||||||
|
</div>
|
||||||
|
<div v-if="selectedEmployees?.length > 0" class="mt-4">
|
||||||
|
Выбрано для назначения: {{ selectedEmployees.length }}
|
||||||
|
</div>
|
||||||
|
</v-card-text>
|
||||||
|
<v-divider></v-divider>
|
||||||
|
<v-card-actions class="pa-4" color="cards">
|
||||||
|
<v-spacer />
|
||||||
|
<v-btn
|
||||||
|
color="grey"
|
||||||
|
variant="outlined"
|
||||||
|
prepend-icon="mdi-close"
|
||||||
|
class="mr-3"
|
||||||
|
@click="$emit('update:modelValue', false)"
|
||||||
|
>
|
||||||
|
Отмена
|
||||||
|
</v-btn>
|
||||||
|
<v-btn
|
||||||
|
color="teal-darken-4"
|
||||||
|
prepend-icon="mdi-check"
|
||||||
|
@click="handleAssign"
|
||||||
|
:disabled="!selectedEmployees.length"
|
||||||
|
>
|
||||||
|
Назначить тест
|
||||||
|
</v-btn>
|
||||||
|
</v-card-actions>
|
||||||
|
</v-card>
|
||||||
|
</v-dialog>
|
||||||
|
|
||||||
|
<v-snackbar
|
||||||
|
v-model="snackbar.show"
|
||||||
|
:color="snackbar.color"
|
||||||
|
:timeout="3000"
|
||||||
|
>
|
||||||
|
{{ snackbar.text }}
|
||||||
|
</v-snackbar>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import SearcEmployess from '@/components/UI/SearcEmployess.vue';
|
||||||
|
import DateSelect from '@/components/UI/date-select.vue';
|
||||||
|
import { spravURL } from '@/utils/axios-api';
|
||||||
|
import { checkremote } from '@/utils/universal_functions.js';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'AssignTestDialog',
|
||||||
|
components: {
|
||||||
|
SearcEmployess,
|
||||||
|
DateSelect
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
modelValue: {
|
||||||
|
type: Boolean,
|
||||||
|
required: true
|
||||||
|
},
|
||||||
|
assignedEmployees: {
|
||||||
|
type: Array,
|
||||||
|
default: () => []
|
||||||
|
},
|
||||||
|
assignedEmployeesDetails: {
|
||||||
|
type: Array,
|
||||||
|
default: () => []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
emits: ['update:modelValue', 'assign', 'unassign', 'unassignAll'],
|
||||||
|
setup(props, { emit }) {
|
||||||
|
const selectedEmployees = ref([]);
|
||||||
|
const publishNews = ref(false);
|
||||||
|
|
||||||
|
// Устанавливаем начальные даты
|
||||||
|
const currentDate = new Date();
|
||||||
|
const defaultStartDate = new Date(currentDate);
|
||||||
|
defaultStartDate.setHours(8, 0, 0, 0);
|
||||||
|
|
||||||
|
const defaultEndDate = new Date(currentDate);
|
||||||
|
defaultEndDate.setHours(18, 0, 0, 0);
|
||||||
|
|
||||||
|
const startDate = ref(defaultStartDate);
|
||||||
|
const completionDate = ref(defaultEndDate);
|
||||||
|
|
||||||
|
const snackbar = ref({
|
||||||
|
show: false,
|
||||||
|
text: '',
|
||||||
|
color: 'error'
|
||||||
|
});
|
||||||
|
|
||||||
|
const showSnackbar = (text, color = 'error') => {
|
||||||
|
snackbar.value = {
|
||||||
|
show: true,
|
||||||
|
text,
|
||||||
|
color
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleEmployeeSelection = (value) => {
|
||||||
|
selectedEmployees.value = value;
|
||||||
|
// Сбросить переключатель "Публиковать новость", если выбрано меньше 2 сотрудников
|
||||||
|
if (value?.length < 2) {
|
||||||
|
publishNews.value = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleDateChange = (date, type = 'end') => {
|
||||||
|
if (!date) return;
|
||||||
|
|
||||||
|
const newDate = new Date(date);
|
||||||
|
if (type === 'end') {
|
||||||
|
newDate.setHours(18, 0, 0, 0);
|
||||||
|
completionDate.value = newDate;
|
||||||
|
|
||||||
|
if (startDate.value && newDate < startDate.value) {
|
||||||
|
startDate.value = newDate;
|
||||||
|
startDate.value.setHours(9, 0, 0, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
newDate.setHours(9, 0, 0, 0);
|
||||||
|
startDate.value = newDate;
|
||||||
|
|
||||||
|
if (completionDate.value && newDate > completionDate.value) {
|
||||||
|
completionDate.value = newDate;
|
||||||
|
completionDate.value.setHours(18, 0, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleAssign = () => {
|
||||||
|
if (!selectedEmployees.value.length) {
|
||||||
|
showSnackbar('Выберите хотя бы одного сотрудника');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!completionDate.value || !startDate.value) {
|
||||||
|
showSnackbar('Укажите дату начала и окончания теста');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const today = new Date();
|
||||||
|
today.setHours(0, 0, 0, 0);
|
||||||
|
if (completionDate.value < today || startDate.value < today) {
|
||||||
|
showSnackbar('Нельзя назначить прошедшую дату');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (startDate.value > completionDate.value) {
|
||||||
|
showSnackbar('Дата начала не может быть позже даты окончания');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
emit('assign', {
|
||||||
|
selectedEmployees: selectedEmployees.value,
|
||||||
|
completionDate: completionDate.value,
|
||||||
|
startDate: startDate.value,
|
||||||
|
news: publishNews.value
|
||||||
|
});
|
||||||
|
|
||||||
|
selectedEmployees.value = [];
|
||||||
|
publishNews.value = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
const spravURLFunc = () => spravURL;
|
||||||
|
|
||||||
|
return {
|
||||||
|
selectedEmployees,
|
||||||
|
completionDate,
|
||||||
|
startDate,
|
||||||
|
publishNews,
|
||||||
|
handleEmployeeSelection,
|
||||||
|
handleAssign,
|
||||||
|
handleDateChange,
|
||||||
|
checkremote,
|
||||||
|
spravURL: spravURLFunc(),
|
||||||
|
snackbar
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
:deep(.v-card) {
|
||||||
|
background-color: rgb(var(--v-theme-cards));
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.v-card-text) {
|
||||||
|
color: rgb(var(--v-theme-text_carous));
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.v-label) {
|
||||||
|
color: rgb(var(--v-theme-text_carous));
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.v-field) {
|
||||||
|
background-color: rgb(var(--v-theme-cards));
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.v-text-field) {
|
||||||
|
background-color: rgb(var(--v-theme-cards));
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,25 +1,96 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-container class="pa-4">
|
<v-container :class="{ 'pa-4': !isDialog, 'pa-0': isDialog }">
|
||||||
<v-row class="justify-center mt-6">
|
<v-row
|
||||||
<v-col cols="12" md="8" lg="6">
|
class="justify-center"
|
||||||
<v-card elevation="2">
|
:class="{ 'mt-6': !isDialog, 'ma-0': isDialog }"
|
||||||
<v-card-title class="text-h6 font-weight-bold">Информация</v-card-title>
|
>
|
||||||
<v-card-text class="d-flex flex-lg-column ga-6 border-b-thin">
|
<v-col
|
||||||
<p>
|
:cols="isDialog ? 12 : '12'"
|
||||||
{{ data?.description }}
|
:md="isDialog ? 12 : '8'"
|
||||||
</p>
|
:lg="isDialog ? 12 : '6'"
|
||||||
<p>
|
class="pa-0"
|
||||||
<strong>Время на прохождение — {{ data?.time }} минут</strong>
|
>
|
||||||
</p>
|
<v-card :elevation="isDialog ? 0 : 2" class="rounded-lg" color="cards">
|
||||||
<p>
|
<v-card-title v-if="!isDialog" class="text-h6 font-weight-bold"
|
||||||
<strong>Срок окончания — {{ new Date(data?.dateend).toLocaleDateString() }}</strong>
|
>Информация</v-card-title
|
||||||
</p>
|
>
|
||||||
|
<v-card-text
|
||||||
|
:class="[
|
||||||
|
'd-flex flex-column ga-6',
|
||||||
|
{ 'border-b-thin': !isDialog, 'pa-0': isDialog },
|
||||||
|
]"
|
||||||
|
>
|
||||||
|
<div class="test-info">
|
||||||
|
<div class="d-flex justify-center mb-4">
|
||||||
|
<v-img
|
||||||
|
:src="data?.file || defaultImage"
|
||||||
|
class="rounded-lg"
|
||||||
|
max-height="200"
|
||||||
|
contain
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="text-body-1 mb-4"
|
||||||
|
v-html="formatDescription(data?.description)"
|
||||||
|
></div>
|
||||||
|
|
||||||
|
<div class="d-flex align-center mb-3">
|
||||||
|
<v-icon
|
||||||
|
icon="mdi-clock-outline"
|
||||||
|
color="teal-darken-2"
|
||||||
|
class="mr-2"
|
||||||
|
/>
|
||||||
|
<span class="text-body-1">
|
||||||
|
<strong>Время на прохождение:</strong> {{ formatTime.value }}
|
||||||
|
{{ formatTime.unit }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="d-flex align-center mb-3">
|
||||||
|
<v-icon
|
||||||
|
icon="mdi-format-list-numbered"
|
||||||
|
color="teal-darken-2"
|
||||||
|
class="mr-2"
|
||||||
|
/>
|
||||||
|
<span class="text-body-1">
|
||||||
|
<strong>Количество вопросов:</strong>
|
||||||
|
{{ data?.question_count }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="d-flex align-center mb-3" v-if="isExamMode">
|
||||||
|
<v-icon icon="mdi-refresh" color="teal-darken-2" class="mr-2" />
|
||||||
|
<span class="text-body-1">
|
||||||
|
<strong>Количество попыток:</strong> {{ remainingAttempts !== undefined ? remainingAttempts : data?.attemps_number }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="d-flex align-center">
|
||||||
|
<v-icon icon="mdi-percent" color="teal-darken-2" class="mr-2" />
|
||||||
|
<span class="text-body-1">
|
||||||
|
<strong>Проходной балл:</strong> {{ data?.pass_perc }}%
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</v-card-text>
|
</v-card-text>
|
||||||
<v-card-actions class="mx-2 my-4">
|
<v-card-actions v-if="!isDialog" class="mx-2 my-4">
|
||||||
<p>Попытка 1 из {{ data?.attemps_number }}</p>
|
<v-btn
|
||||||
<v-btn color="white" class="ml-auto bg-teal-darken-1 px-9" @click="startTest">
|
v-if="!isExamMode || remainingAttempts === undefined || remainingAttempts > 0"
|
||||||
Начать
|
color="btn_text"
|
||||||
|
class="ml-auto px-9 text-white"
|
||||||
|
@click="startTest"
|
||||||
|
>
|
||||||
|
{{ isExamMode ? "Начать" : "Тренироваться" }}
|
||||||
</v-btn>
|
</v-btn>
|
||||||
|
<v-alert
|
||||||
|
v-else
|
||||||
|
type="warning"
|
||||||
|
class="ml-auto my-2 w-100"
|
||||||
|
border="start"
|
||||||
|
density="compact"
|
||||||
|
>
|
||||||
|
Все попытки израсходованы
|
||||||
|
</v-alert>
|
||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
</v-card>
|
</v-card>
|
||||||
</v-col>
|
</v-col>
|
||||||
@@ -28,10 +99,97 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { useRoute } from "vue-router";
|
||||||
|
import { computed } from "vue";
|
||||||
|
import defaultImage from "@/assets/emblem.png";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
startTest: Function,
|
startTest: Function,
|
||||||
data: Object,
|
data: Object,
|
||||||
|
isDialog: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
remainingAttempts: {
|
||||||
|
type: Number,
|
||||||
|
default: undefined
|
||||||
|
}
|
||||||
|
},
|
||||||
|
setup(props) {
|
||||||
|
const route = useRoute();
|
||||||
|
const isExamMode = computed(() => route.query.mode === "exam");
|
||||||
|
|
||||||
|
const formatTime = computed(() => {
|
||||||
|
if (!props.data?.time) return { value: 0, unit: "минут" };
|
||||||
|
|
||||||
|
const time = Number(props.data.time);
|
||||||
|
|
||||||
|
// Всегда считаем, что время приходит в минутах
|
||||||
|
if (time >= 60) {
|
||||||
|
const hours = Math.floor(time / 60);
|
||||||
|
const minutes = time % 60;
|
||||||
|
if (minutes === 0) {
|
||||||
|
return {
|
||||||
|
value: hours,
|
||||||
|
unit: hours === 1 ? "час" : hours >= 2 && hours <= 4 ? "часа" : "часов",
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
value: `${hours} ч. ${minutes}`,
|
||||||
|
unit: minutes === 1 ? "мин." : "мин.",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Если меньше 60, значит это просто минуты
|
||||||
|
return {
|
||||||
|
value: time,
|
||||||
|
unit: time === 1 ? "минута" : time >= 2 && time <= 4 ? "минуты" : "минут",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const timeWordDeclension = computed(() => {
|
||||||
|
if (!props.data?.time) return "минут";
|
||||||
|
|
||||||
|
const lastDigit = props.data.time % 10;
|
||||||
|
const lastTwoDigits = props.data.time % 100;
|
||||||
|
|
||||||
|
if (lastTwoDigits >= 11 && lastTwoDigits <= 14) return "минут";
|
||||||
|
if (lastDigit === 1) return "минута";
|
||||||
|
if (lastDigit >= 2 && lastDigit <= 4) return "минуты";
|
||||||
|
return "минут";
|
||||||
|
});
|
||||||
|
|
||||||
|
const formatDescription = (text) => {
|
||||||
|
if (!text) return "";
|
||||||
|
return text.replace(/\r?\n/g, "<br>");
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
isExamMode,
|
||||||
|
timeWordDeclension,
|
||||||
|
formatDescription,
|
||||||
|
formatTime,
|
||||||
|
defaultImage,
|
||||||
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.test-info {
|
||||||
|
padding: 16px;
|
||||||
|
border-radius: 8px;
|
||||||
|
background-color: rgba(var(--v-theme-btn_text), 0.05);
|
||||||
|
color: rgb(var(--v-theme-text_carous));
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.v-card-text) {
|
||||||
|
color: rgb(var(--v-theme-text_carous));
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.v-card-title) {
|
||||||
|
color: rgb(var(--v-theme-text_carous));
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,57 +1,99 @@
|
|||||||
<!-- Раздел с назначенным тестированием -->
|
<!-- Раздел с назначенным тестированием -->
|
||||||
<template>
|
<template>
|
||||||
<div class="my-4 text-h5">{{ title }}</div>
|
<!-- <div class="my-4 text-h5 font-weight-medium">{{ title }}</div> -->
|
||||||
|
<div :class="containerClass">
|
||||||
<v-container :fluid="true">
|
<v-container :fluid="true">
|
||||||
<v-row>
|
<v-row>
|
||||||
<v-text-field
|
<v-text-field
|
||||||
v-model="search"
|
v-model="search"
|
||||||
append-inner-icon="mdi-magnify"
|
append-inner-icon="mdi-magnify"
|
||||||
label="Найти тестирование по названию"
|
label="Найти тестирование по названию"
|
||||||
variant="solo"
|
variant="outlined"
|
||||||
|
density="comfortable"
|
||||||
|
bg-color="grey-lighten-4"
|
||||||
|
class="search-field"
|
||||||
|
hide-details
|
||||||
@click:append-inner="searchTest"
|
@click:append-inner="searchTest"
|
||||||
clearable
|
clearable
|
||||||
/>
|
/>
|
||||||
</v-row>
|
</v-row>
|
||||||
</v-container>
|
</v-container>
|
||||||
<!-- Карточка где буду отрисовываться тесты в цикле -->
|
<!-- Карточка где буду отрисовываться тесты в цикле -->
|
||||||
<v-card v-for="cardValue in searchTest" :key="cardValue.id" class="my-2 border-sm">
|
<v-card
|
||||||
<v-row class="pa-2">
|
v-for="cardValue in searchTest"
|
||||||
|
:key="cardValue.id"
|
||||||
|
class="my-4 test-card"
|
||||||
|
elevation="2"
|
||||||
|
:class="{ 'passed-test': activeTab === 0 && cardValue.is_passed }"
|
||||||
|
>
|
||||||
|
<v-row class="pa-4">
|
||||||
<v-col cols="2" class="justify-center my-auto">
|
<v-col cols="2" class="justify-center my-auto">
|
||||||
<v-img :src="cardValue.file" class="mx-auto" />
|
<v-img
|
||||||
|
:src="cardValue.file || defaultImage"
|
||||||
|
class="mx-auto rounded-lg"
|
||||||
|
max-height="120"
|
||||||
|
contain
|
||||||
|
/>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col cols="auto" class="d-flex flex-grow-1">
|
<v-col cols="auto" class="d-flex flex-grow-1">
|
||||||
<div class="d-flex flex-column justify-center 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-h6 font-weight-bold mb-2">{{ cardValue.name }}</div>
|
||||||
<div class="text-body-1 text-disabled mb-2" style="max-width: 600px">
|
<div class="text-body-1 text-grey-darken-1 mb-4 test-description" style="max-width: 600px" v-html="formatDescription(cardValue.description)"></div>
|
||||||
{{ cardValue.description }}
|
<div class="d-flex flex-wrap gap-4">
|
||||||
</div>
|
|
||||||
<div class="d-flex ga-4">
|
|
||||||
<slot name="results"></slot>
|
<slot name="results"></slot>
|
||||||
<div v-for="icon in activeTabIcon">
|
<div v-for="icon in activeTabIcon" class="d-inline-flex align-center test-info-item">
|
||||||
<v-icon :color="icon.color" :icon="icon.icon" size="large" />
|
<v-icon :color="icon.color" :icon="icon.icon" size="small" class="mr-2" />
|
||||||
<span class="ml-1">{{ momenter(cardValue[icon.field], icon.field) }}</span>
|
<span class="text-body-2">{{ momenter(cardValue[icon.field], icon.field) }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</v-col>
|
</v-col>
|
||||||
<v-col cols="auto" class="align-self-center">
|
<v-col cols="auto" class="align-self-center">
|
||||||
<slot name="buttons" :cardValue="cardValue"></slot>
|
<template v-if="activeTab === 0 && cardValue.is_passed">
|
||||||
|
<div class="d-flex align-center status-badge success">
|
||||||
|
<v-icon color="teal-darken-1" icon="mdi-check-circle-outline" size="small" class="mr-2" />
|
||||||
|
<span class="text-teal-darken-1 text-body-2 font-weight-medium">Сдано успешно</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<template v-else-if="cardValue.attemps_number > 0">
|
||||||
|
<slot name="buttons" :cardValue="cardValue"></slot>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<div>
|
||||||
|
<div class="d-flex status-badge error mb-2">
|
||||||
|
<v-icon color="red-darken-1" icon="mdi-alert-circle-outline" size="small" class="mr-2" />
|
||||||
|
<span class="text-red-darken-1 text-body-2 font-weight-medium">Попытки закончились</span>
|
||||||
|
</div>
|
||||||
|
<div class="text-caption text-grey-darken-1 text-center">
|
||||||
|
Для повторного прохождения<br>обратитесь к администратору
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
</v-card>
|
</v-card>
|
||||||
<!-- Если данные отсутствуют, выводим сообщение об этом -->
|
<!-- Если данные отсутствуют, выводим сообщение об этом -->
|
||||||
<v-container v-if="!searchTest.length" :fluid="true" class="h-100">
|
<v-container
|
||||||
<v-row class="align-center flex-column">
|
v-if="!searchTest.length"
|
||||||
<v-icon icon="mdi-note-off-outline" color="grey-lighten-1" size="x-large" />
|
:fluid="true"
|
||||||
<v-card-title class="text-h4 text-grey-lighten-1">Данные не найдены</v-card-title>
|
class="empty-state"
|
||||||
|
style="min-height: 70vh;"
|
||||||
|
>
|
||||||
|
<v-row class="align-center flex-column pa-8" style="min-height: 300px;">
|
||||||
|
<v-icon icon="mdi-note-off-outline" color="grey-lighten-1" size="64" class="mb-4" />
|
||||||
|
<v-card-title class="text-h5 text-grey-darken-1 font-weight-medium text-center">
|
||||||
|
Данные не найдены
|
||||||
|
</v-card-title>
|
||||||
</v-row>
|
</v-row>
|
||||||
</v-container>
|
</v-container>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import { declOfNum } from '@/utils/universal_functions';
|
import { declOfNum } from '@/utils/universal_functions';
|
||||||
import { baseURL } from '@/utils/axios-api';
|
import { baseURL } from '@/utils/axios-api';
|
||||||
|
import defaultImage from '@/assets/emblem.png';
|
||||||
import { ref, computed } from 'vue';
|
import { ref, computed } from 'vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -68,13 +110,25 @@ export default {
|
|||||||
type: Array,
|
type: Array,
|
||||||
default: () => [],
|
default: () => [],
|
||||||
},
|
},
|
||||||
|
class: {
|
||||||
|
type: [String, Object, Array],
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
setup(props) {
|
setup(props) {
|
||||||
const search = ref('');
|
const search = ref('');
|
||||||
|
|
||||||
|
// Create a computed property to handle the containerClass
|
||||||
|
const containerClass = computed(() => props.class);
|
||||||
|
|
||||||
const searchTest = computed(() => {
|
const searchTest = computed(() => {
|
||||||
if (!search.value) return props.testingCard;
|
let filteredTests = props.testingCard;
|
||||||
return props.testingCard.filter((item) =>
|
// Фильтруем неактивные тесты только во вкладке "Назначенные"
|
||||||
|
if (props.activeTab === 0) {
|
||||||
|
filteredTests = props.testingCard.filter((test) => test.is_active);
|
||||||
|
}
|
||||||
|
if (!search.value) return filteredTests;
|
||||||
|
return filteredTests.filter((item) =>
|
||||||
item.name.toLowerCase().includes(search.value.toLowerCase()),
|
item.name.toLowerCase().includes(search.value.toLowerCase()),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -117,11 +171,78 @@ export default {
|
|||||||
return val + declOfNum(val, [' вопрос', ' вопроса', ' вопросов']);
|
return val + declOfNum(val, [' вопрос', ' вопроса', ' вопросов']);
|
||||||
} else if (field === 'time') {
|
} else if (field === 'time') {
|
||||||
return val + declOfNum(val, [' минута', ' минуты', ' минут']);
|
return val + declOfNum(val, [' минута', ' минуты', ' минут']);
|
||||||
|
} else if (field === 'attemps_number') {
|
||||||
|
return val + declOfNum(val, [' попытка', ' попытки', ' попыток']);
|
||||||
}
|
}
|
||||||
return val;
|
return val;
|
||||||
};
|
};
|
||||||
|
|
||||||
return { search, searchTest, momenter, activeTabIcon, baseURL };
|
const formatDescription = (text) => {
|
||||||
|
if (!text) return '';
|
||||||
|
// Заменяем \r\n и \n на <br>
|
||||||
|
return text.replace(/\r?\n/g, '<br>');
|
||||||
|
};
|
||||||
|
|
||||||
|
return { search, searchTest, momenter, activeTabIcon, baseURL, formatDescription, defaultImage, containerClass };
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.test-card {
|
||||||
|
border: 1px solid rgba(var(--v-border-color), 0.12);
|
||||||
|
background-color: rgb(var(--v-theme-cards));
|
||||||
|
}
|
||||||
|
|
||||||
|
.passed-test {
|
||||||
|
border-left: 4px solid rgb(var(--v-theme-btn_text));
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-field {
|
||||||
|
max-width: 400px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.test-info-item {
|
||||||
|
padding: 4px 12px;
|
||||||
|
background: rgba(var(--v-theme-btn_text), 0.05);
|
||||||
|
border-radius: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-badge {
|
||||||
|
padding: 8px 16px;
|
||||||
|
border-radius: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-badge.success {
|
||||||
|
background: rgba(var(--v-theme-btn_text), 0.1);
|
||||||
|
color: rgb(var(--v-theme-black_and_white));
|
||||||
|
}
|
||||||
|
|
||||||
|
.status-badge.error {
|
||||||
|
background: rgba(244, 67, 54, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.no-attempts-container {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
padding: 12px;
|
||||||
|
max-width: 200px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-state {
|
||||||
|
min-height: 300px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
background: rgba(var(--v-border-color), 0.05);
|
||||||
|
border-radius: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.test-description {
|
||||||
|
white-space: pre-wrap;
|
||||||
|
word-wrap: break-word;
|
||||||
|
color: rgb(var(--v-theme-text_carous));
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<template>
|
||||||
|
<v-card class="mx-auto my-auto pa-5 text-center" max-width="600">
|
||||||
|
<v-icon color="teal-darken-1" size="x-large" class="mb-5">mdi-check-circle</v-icon>
|
||||||
|
<h1 class="text-h4 mb-4">Тест успешно создан</h1>
|
||||||
|
<p class="text-body-1 mb-4">Тест добавлен в каталог и готов к назначению сотрудникам</p>
|
||||||
|
<slot></slot>
|
||||||
|
</v-card>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: "CreatedTest"
|
||||||
|
};
|
||||||
|
</script>
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- Блок информации о тесте -->
|
<!-- Блок информации о тесте -->
|
||||||
<BodyDetailTesting v-if="!testStarted && !testFinished" :data="data" :startTest="startTest" />
|
<BodyDetailTesting v-if="!testStarted && !testFinished" :data="data" :startTest="startTest" :remainingAttempts="remainingAttempts" />
|
||||||
|
|
||||||
<!-- Вопросы теста -->
|
<!-- Вопросы теста -->
|
||||||
<QuestionBlock
|
<QuestionBlock
|
||||||
@@ -23,6 +23,7 @@
|
|||||||
:answers="answers"
|
:answers="answers"
|
||||||
:finishTest="openFinishDialog"
|
:finishTest="openFinishDialog"
|
||||||
@change-question="changeQuestion"
|
@change-question="changeQuestion"
|
||||||
|
@answer-changed="onAnswerChanged"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- Результаты теста -->
|
<!-- Результаты теста -->
|
||||||
@@ -33,7 +34,11 @@
|
|||||||
:correctAnswers="correctAnswers"
|
:correctAnswers="correctAnswers"
|
||||||
:answeredQuestions="answeredQuestions"
|
:answeredQuestions="answeredQuestions"
|
||||||
:totalQuestions="data.question_count"
|
:totalQuestions="data.question_count"
|
||||||
:formattedTime="formattedTime"
|
:formattedTime="formatSpentTime"
|
||||||
|
:questions="data?.questions"
|
||||||
|
:userAnswers="answers"
|
||||||
|
:remainingAttempts="remainingAttempts"
|
||||||
|
@restart="startTest"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- Диалог подтверждения завершения теста -->
|
<!-- Диалог подтверждения завершения теста -->
|
||||||
@@ -42,8 +47,14 @@
|
|||||||
<v-card-title class="text-h6">Завершить тест?</v-card-title>
|
<v-card-title class="text-h6">Завершить тест?</v-card-title>
|
||||||
<v-card-text>Вы уверены, что хотите завершить тестирование?</v-card-text>
|
<v-card-text>Вы уверены, что хотите завершить тестирование?</v-card-text>
|
||||||
<v-card-actions class="d-flex justify-end">
|
<v-card-actions class="d-flex justify-end">
|
||||||
<v-btn color="teal-darken-4" @click="finishTest">Да, завершить</v-btn>
|
<v-btn variant="tonal" color="teal-darken-4" @click="finishTest">
|
||||||
<v-btn color="grey" @click="showFinishDialog = false">Отмена</v-btn>
|
<v-icon start>mdi-check</v-icon>
|
||||||
|
Да, завершить
|
||||||
|
</v-btn>
|
||||||
|
<v-btn variant="outlined" color="grey" @click="showFinishDialog = false">
|
||||||
|
<v-icon start>mdi-close</v-icon>
|
||||||
|
Отмена
|
||||||
|
</v-btn>
|
||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
</v-card>
|
</v-card>
|
||||||
</v-dialog>
|
</v-dialog>
|
||||||
@@ -56,7 +67,7 @@ import HeaderDetailTesting from '@/components/testing/HeaderDetailTesting.vue';
|
|||||||
import BodyDetailTesting from '@/components/testing/BodyDetailTesting.vue';
|
import BodyDetailTesting from '@/components/testing/BodyDetailTesting.vue';
|
||||||
import QuestionBlock from '@/components/testing/QuestionBlock.vue';
|
import QuestionBlock from '@/components/testing/QuestionBlock.vue';
|
||||||
import TestResults from '@/components/testing/TestResults.vue';
|
import TestResults from '@/components/testing/TestResults.vue';
|
||||||
import { axiosApiInstance } from '@/utils/axios-api';
|
import { axiosApiInstance, getActiveTest } from '@/utils/axios-api';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -70,57 +81,170 @@ export default {
|
|||||||
const currentQuestion = ref(0);
|
const currentQuestion = ref(0);
|
||||||
let timer = null;
|
let timer = null;
|
||||||
const data = ref(null);
|
const data = ref(null);
|
||||||
|
const testingId = ref(null);
|
||||||
|
const testResults = ref(null);
|
||||||
|
const spentTime = ref(0);
|
||||||
|
const remainingAttempts = ref(undefined);
|
||||||
|
|
||||||
|
const formatSpentTime = computed(() => {
|
||||||
|
const minutes = Math.floor(spentTime.value / 60);
|
||||||
|
const seconds = spentTime.value % 60;
|
||||||
|
return `${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}`;
|
||||||
|
});
|
||||||
|
|
||||||
const getTestById = async (id) => {
|
const getTestById = async (id) => {
|
||||||
|
// Загружаем детали теста из API testdetail
|
||||||
const resp = await axiosApiInstance.get(`/api/tests/testdetail/${id}`);
|
const resp = await axiosApiInstance.get(`/api/tests/testdetail/${id}`);
|
||||||
data.value = resp.data;
|
data.value = resp.data;
|
||||||
// console.log(data.value);
|
|
||||||
|
try {
|
||||||
|
// Проверяем оставшиеся попытки из API gettests со статусом active
|
||||||
|
const activeTest = await getActiveTest(id);
|
||||||
|
|
||||||
|
// Если нашли тест в активных, проверяем количество попыток
|
||||||
|
if (activeTest) {
|
||||||
|
remainingAttempts.value = activeTest.attemps_number;
|
||||||
|
} else {
|
||||||
|
// Если тест не найден в активных, устанавливаем 0 попыток
|
||||||
|
remainingAttempts.value = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Получаем данные о назначениях теста
|
||||||
|
const testingResp = await axiosApiInstance.get(`/api/tests/testingview/?test_id=${id}`);
|
||||||
|
const userTestings = testingResp.data;
|
||||||
|
if (userTestings?.length > 0) {
|
||||||
|
const testMode = route.query.mode;
|
||||||
|
const isFormalTesting = testMode === 'exam' || testMode === 'retry';
|
||||||
|
|
||||||
|
const sortedTestings = [...userTestings].sort((a, b) => {
|
||||||
|
return new Date(b.completion_date) - new Date(a.completion_date);
|
||||||
|
});
|
||||||
|
|
||||||
|
const activeTestings = sortedTestings.filter(t =>
|
||||||
|
isFormalTesting ? !t.completed : true
|
||||||
|
);
|
||||||
|
if (activeTestings.length > 0) {
|
||||||
|
testingId.value = activeTestings[0].id;
|
||||||
|
} else if (sortedTestings.length > 0) {
|
||||||
|
testingId.value = sortedTestings[0].id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error getting testing record:', error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const formattedTime = computed(() => {
|
const formattedTime = computed(() => {
|
||||||
if (!data.value?.time) return '00:00';
|
if (!data.value?.time) return '00:00';
|
||||||
|
|
||||||
// Если тест не запущен и не завершён — считаем, что время в data.value.time в минутах
|
|
||||||
if (!testStarted.value && !testFinished.value) {
|
if (!testStarted.value && !testFinished.value) {
|
||||||
return `${String(data.value.time).padStart(2, '0')}:00`;
|
return `${String(data.value.time).padStart(2, '0')}:00`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Если тест запущен или завершён — data.value.time уже в секундах
|
|
||||||
const minutes = Math.floor(data.value.time / 60);
|
const minutes = Math.floor(data.value.time / 60);
|
||||||
const seconds = data.value.time % 60;
|
const seconds = data.value.time % 60;
|
||||||
return `${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}`;
|
return `${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}`;
|
||||||
});
|
});
|
||||||
|
|
||||||
const startTest = () => {
|
const startTest = async () => {
|
||||||
|
await getTestById(testId);
|
||||||
|
|
||||||
|
const isExamMode = route.query.mode === 'exam';
|
||||||
|
if (isExamMode && remainingAttempts.value !== undefined && remainingAttempts.value <= 0) {
|
||||||
|
console.log('Нет оставшихся попыток для прохождения теста');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
testStarted.value = true;
|
testStarted.value = true;
|
||||||
testFinished.value = false;
|
testFinished.value = false;
|
||||||
|
currentQuestion.value = 0;
|
||||||
|
|
||||||
// Переводим минуты в секунды перед запуском таймера
|
answers.value = data.value.questions.map((question) => {
|
||||||
data.value = { ...data.value, time: data.value.time * 60 };
|
const correctAnswersCount = question.answers.filter(answer => answer.right_wrong).length;
|
||||||
|
return correctAnswersCount > 1 ? [] : null;
|
||||||
|
});
|
||||||
|
|
||||||
|
const initialTime = data.value.time * 60;
|
||||||
|
data.value = { ...data.value, time: initialTime };
|
||||||
|
spentTime.value = 0;
|
||||||
|
|
||||||
|
if (timer) {
|
||||||
|
clearInterval(timer);
|
||||||
|
}
|
||||||
|
|
||||||
timer = setInterval(() => {
|
timer = setInterval(() => {
|
||||||
if (data.value?.time > 0) {
|
if (data.value?.time > 0) {
|
||||||
data.value = { ...data.value, time: data.value.time - 1 };
|
data.value.time = data.value.time - 1;
|
||||||
|
spentTime.value += 1;
|
||||||
} else {
|
} else {
|
||||||
finishTest(); // Завершаем тест, если время закончилось
|
finishTest();
|
||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
};
|
};
|
||||||
|
|
||||||
const finishTest = () => {
|
const finishTest = async () => {
|
||||||
clearInterval(timer);
|
clearInterval(timer);
|
||||||
testStarted.value = false;
|
testStarted.value = false;
|
||||||
testFinished.value = true;
|
testFinished.value = true;
|
||||||
showFinishDialog.value = false;
|
showFinishDialog.value = false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
let answersToSubmit = [];
|
||||||
|
data.value.questions.forEach((question, questionIndex) => {
|
||||||
|
const answer = answers.value[questionIndex];
|
||||||
|
let selectedIds = [];
|
||||||
|
if (answer !== null) {
|
||||||
|
if (Array.isArray(answer)) {
|
||||||
|
selectedIds = answer.map((answerText) => {
|
||||||
|
const selectedAnswer = question.answers.find((a) => a.name === answerText);
|
||||||
|
return selectedAnswer ? selectedAnswer.id : null;
|
||||||
|
}).filter(Boolean);
|
||||||
|
} else {
|
||||||
|
const selectedAnswer = question.answers.find((a) => a.name === answer);
|
||||||
|
if (selectedAnswer) selectedIds = [selectedAnswer.id];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
answersToSubmit.push({
|
||||||
|
question_id: question.id,
|
||||||
|
answers_id: selectedIds,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const testMode = route.query.mode;
|
||||||
|
const isFormalTesting = testMode === 'exam' || testMode === 'retry';
|
||||||
|
|
||||||
|
const queryParams = new URLSearchParams();
|
||||||
|
if (isFormalTesting) {
|
||||||
|
queryParams.append('status', 'testing');
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await axiosApiInstance.post(
|
||||||
|
`/api/tests/testresultview/?${queryParams.toString()}&id=${testId}`,
|
||||||
|
answersToSubmit,
|
||||||
|
);
|
||||||
|
|
||||||
|
testResults.value = response.data;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Ошибка при отправке результатов теста:', error);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const answers = ref([]);
|
const answers = ref([]);
|
||||||
|
|
||||||
watch(data.value?.questions, (newData) => {
|
watch(
|
||||||
if (newData && Array.isArray(newData.questions)) {
|
() => data.value?.questions,
|
||||||
answers.value = newData.questions.map(() => null);
|
(newQuestions) => {
|
||||||
}
|
if (newQuestions && Array.isArray(newQuestions)) {
|
||||||
});
|
if (!answers.value || answers.value.length === 0) {
|
||||||
|
answers.value = newQuestions.map((question) => {
|
||||||
|
const correctAnswersCount = question.answers.filter(answer => answer.right_wrong).length;
|
||||||
|
return correctAnswersCount > 1 ? [] : null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ deep: true }
|
||||||
|
);
|
||||||
|
|
||||||
const correctAnswers = computed(
|
const correctAnswers = computed(
|
||||||
() =>
|
() =>
|
||||||
@@ -129,28 +253,30 @@ export default {
|
|||||||
(a) => a.right_wrong,
|
(a) => a.right_wrong,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!correctAnswerObjs.length) return false; // Если нет правильных ответов, пропускаем
|
if (!correctAnswerObjs.length) return false;
|
||||||
|
|
||||||
const correctNames = correctAnswerObjs.map((a) => a.name); // Все правильные варианты
|
const correctNames = correctAnswerObjs.map((a) => a.name);
|
||||||
|
|
||||||
// Если пользователь выбрал несколько вариантов, сравниваем как массивы
|
|
||||||
if (Array.isArray(answer)) {
|
if (Array.isArray(answer)) {
|
||||||
return (
|
return (
|
||||||
answer.length === correctNames.length && // Должно совпадать количество
|
answer.length === correctNames.length &&
|
||||||
answer.every((ans) => correctNames.includes(ans)) // Все варианты должны быть правильными
|
answer.every((ans) => correctNames.includes(ans))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Если один вариант ответа — сравниваем просто строку
|
|
||||||
return correctNames.includes(answer);
|
return correctNames.includes(answer);
|
||||||
}).length,
|
}).length,
|
||||||
);
|
);
|
||||||
|
|
||||||
const answeredQuestions = computed(
|
const answeredQuestions = computed(
|
||||||
() => answers.value.filter((answer) => answer !== null).length,
|
() => answers.value.filter((answer) => {
|
||||||
|
if (answer === null || answer === undefined) return false;
|
||||||
|
if (Array.isArray(answer)) return answer.length > 0;
|
||||||
|
return true;
|
||||||
|
}).length,
|
||||||
);
|
);
|
||||||
|
|
||||||
const testPassed = computed(() => correctAnswers.value >= data?.value.questions.length / 2);
|
const testPassed = computed(() => testResults.value?.is_passed ?? false);
|
||||||
|
|
||||||
const changeQuestion = (newIndex) => {
|
const changeQuestion = (newIndex) => {
|
||||||
if (newIndex >= 0 && newIndex < data?.value.questions.length) {
|
if (newIndex >= 0 && newIndex < data?.value.questions.length) {
|
||||||
@@ -158,6 +284,13 @@ export default {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onAnswerChanged = (questionIndex, value) => {
|
||||||
|
|
||||||
|
const newAnswers = [...answers.value];
|
||||||
|
newAnswers[questionIndex] = value;
|
||||||
|
answers.value = newAnswers;
|
||||||
|
};
|
||||||
|
|
||||||
const openFinishDialog = () => {
|
const openFinishDialog = () => {
|
||||||
showFinishDialog.value = true;
|
showFinishDialog.value = true;
|
||||||
};
|
};
|
||||||
@@ -174,18 +307,87 @@ export default {
|
|||||||
testStarted,
|
testStarted,
|
||||||
testFinished,
|
testFinished,
|
||||||
formattedTime,
|
formattedTime,
|
||||||
|
formatSpentTime,
|
||||||
startTest,
|
startTest,
|
||||||
finishTest,
|
finishTest,
|
||||||
answers,
|
answers,
|
||||||
currentQuestion,
|
currentQuestion,
|
||||||
changeQuestion,
|
changeQuestion,
|
||||||
|
onAnswerChanged,
|
||||||
showFinishDialog,
|
showFinishDialog,
|
||||||
openFinishDialog,
|
openFinishDialog,
|
||||||
correctAnswers,
|
correctAnswers,
|
||||||
answeredQuestions,
|
answeredQuestions,
|
||||||
testPassed,
|
testPassed,
|
||||||
data,
|
data,
|
||||||
|
remainingAttempts,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.v-container {
|
||||||
|
background-color: rgb(var(--v-theme-background));
|
||||||
|
border-radius: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.v-btn {
|
||||||
|
transition: transform 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.v-btn:hover {
|
||||||
|
transform: translateY(-2px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.v-dialog .v-card {
|
||||||
|
border-radius: 8px;
|
||||||
|
background-color: rgb(var(--v-theme-cards));
|
||||||
|
}
|
||||||
|
|
||||||
|
.v-dialog .v-card-title {
|
||||||
|
background-color: rgb(var(--v-theme-btn_text));
|
||||||
|
color: rgb(var(--v-theme-black_and_white));
|
||||||
|
padding: 16px;
|
||||||
|
border-top-left-radius: 4px;
|
||||||
|
border-top-right-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.v-dialog .v-card-actions {
|
||||||
|
padding: 16px;
|
||||||
|
background-color: rgb(var(--v-theme-background));
|
||||||
|
border-bottom-left-radius: 8px;
|
||||||
|
border-bottom-right-radius: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.v-label) {
|
||||||
|
margin-bottom: 8px;
|
||||||
|
color: rgb(var(--v-theme-btn_text));
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.v-img) {
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.timer {
|
||||||
|
font-size: 1.2rem;
|
||||||
|
color: rgb(var(--v-theme-btn_text));
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes fadeIn {
|
||||||
|
from {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateY(20px);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
opacity: 1;
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.question-enter-active {
|
||||||
|
animation: fadeIn 0.3s ease-out;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,27 +1,38 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-container class="pa-4">
|
<v-container class="pa-4">
|
||||||
<v-row align="center" class="border-b-thin">
|
<v-row align="center" class="border-b-thin mb-4">
|
||||||
<v-col class="text-h6 font-weight-regular">
|
<v-col class="text-h5 font-weight-medium text-teal-darken-2">
|
||||||
{{ data?.name }}
|
{{ data?.name }}
|
||||||
</v-col>
|
</v-col>
|
||||||
<span class="text-h6 text-grey-darken-1 font-weight-bold mr-4">{{ formattedTime }}</span>
|
<span class="text-h6 text-grey-darken-1 font-weight-medium mr-4">{{ formattedTime }}</span>
|
||||||
</v-row>
|
</v-row>
|
||||||
|
|
||||||
<v-row align="center" class="border-b-thin pa-2">
|
<v-row align="center" class="border-b-thin pa-2">
|
||||||
<v-btn
|
<v-btn
|
||||||
elevation="1"
|
elevation="1"
|
||||||
color="teal-darken-1"
|
color="teal-darken-2"
|
||||||
size="x-small"
|
size="small"
|
||||||
rounded
|
rounded
|
||||||
|
class="mr-4"
|
||||||
icon="mdi-information-outline"
|
icon="mdi-information-outline"
|
||||||
/>
|
@click="showInfoDialog = true"
|
||||||
|
>
|
||||||
|
<v-icon icon="mdi-information-outline" />
|
||||||
|
<v-tooltip
|
||||||
|
activator="parent"
|
||||||
|
location="top"
|
||||||
|
>
|
||||||
|
Информация о тесте
|
||||||
|
</v-tooltip>
|
||||||
|
</v-btn>
|
||||||
|
|
||||||
<!-- Пагинация только при запущенном тесте -->
|
|
||||||
<v-pagination
|
<v-pagination
|
||||||
v-if="testStarted"
|
v-if="testStarted"
|
||||||
:length="totalQuestions"
|
:length="totalQuestions"
|
||||||
:total-visible="5"
|
:total-visible="5"
|
||||||
active-color="teal-darken-4"
|
active-color="teal-darken-2"
|
||||||
|
density="comfortable"
|
||||||
|
class="mx-4"
|
||||||
:model-value="currentQuestion + 1"
|
:model-value="currentQuestion + 1"
|
||||||
@update:model-value="changePage"
|
@update:model-value="changePage"
|
||||||
></v-pagination>
|
></v-pagination>
|
||||||
@@ -30,8 +41,10 @@
|
|||||||
v-if="testStarted"
|
v-if="testStarted"
|
||||||
elevation="0"
|
elevation="0"
|
||||||
color="red-darken-1"
|
color="red-darken-1"
|
||||||
|
variant="tonal"
|
||||||
rounded="lg"
|
rounded="lg"
|
||||||
class="ml-auto"
|
class="ml-auto px-6"
|
||||||
|
prepend-icon="mdi-close-circle"
|
||||||
@click="finishTest"
|
@click="finishTest"
|
||||||
>
|
>
|
||||||
Завершить
|
Завершить
|
||||||
@@ -39,22 +52,60 @@
|
|||||||
<v-btn
|
<v-btn
|
||||||
v-else
|
v-else
|
||||||
elevation="0"
|
elevation="0"
|
||||||
color="grey-lighten-3"
|
color="teal-darken-1"
|
||||||
|
variant="tonal"
|
||||||
rounded="lg"
|
rounded="lg"
|
||||||
class="ml-auto"
|
class="ml-auto px-6"
|
||||||
|
prepend-icon="mdi-exit-to-app"
|
||||||
@click="showExitDialog = true"
|
@click="showExitDialog = true"
|
||||||
>
|
>
|
||||||
Выйти
|
Выйти
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</v-row>
|
</v-row>
|
||||||
|
|
||||||
|
<!-- Диалоговое окно информации -->
|
||||||
|
<v-dialog v-model="showInfoDialog" width="600">
|
||||||
|
<v-card class="rounded-lg">
|
||||||
|
<v-card-title class="d-flex justify-space-between align-center px-4 py-3 bg-teal-darken-2">
|
||||||
|
<span class="text-white font-weight-medium">Информация о тесте</span>
|
||||||
|
<v-btn
|
||||||
|
icon="mdi-close"
|
||||||
|
variant="text"
|
||||||
|
color="white"
|
||||||
|
size="small"
|
||||||
|
@click="showInfoDialog = false"
|
||||||
|
/>
|
||||||
|
</v-card-title>
|
||||||
|
<v-card-text class="px-4 py-4">
|
||||||
|
<BodyDetailTesting
|
||||||
|
:data="data"
|
||||||
|
:startTest="startTest"
|
||||||
|
:isDialog="true"
|
||||||
|
/>
|
||||||
|
</v-card-text>
|
||||||
|
</v-card>
|
||||||
|
</v-dialog>
|
||||||
|
|
||||||
<!-- Диалоговое окно выхода -->
|
<!-- Диалоговое окно выхода -->
|
||||||
<v-dialog v-model="showExitDialog" width="400">
|
<v-dialog v-model="showExitDialog" width="400">
|
||||||
<v-card>
|
<v-card class="rounded-lg">
|
||||||
<v-card-title class="text-h6">Вы действительно хотите выйти?</v-card-title>
|
<v-card-title class="text-h6 pa-4 bg-grey-lighten-4">Вы действительно хотите выйти?</v-card-title>
|
||||||
<v-card-actions>
|
<v-card-actions class="pa-4">
|
||||||
<v-btn color="red" @click="exitTest">Да</v-btn>
|
<v-spacer></v-spacer>
|
||||||
<v-btn color="grey" @click="showExitDialog = false">Отмена</v-btn>
|
<v-btn
|
||||||
|
color="grey-darken-1"
|
||||||
|
variant="text"
|
||||||
|
@click="showExitDialog = false"
|
||||||
|
>
|
||||||
|
Отмена
|
||||||
|
</v-btn>
|
||||||
|
<v-btn
|
||||||
|
color="red-darken-1"
|
||||||
|
variant="tonal"
|
||||||
|
@click="exitTest"
|
||||||
|
>
|
||||||
|
Да, выйти
|
||||||
|
</v-btn>
|
||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
</v-card>
|
</v-card>
|
||||||
</v-dialog>
|
</v-dialog>
|
||||||
@@ -63,8 +114,12 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
|
import BodyDetailTesting from '@/components/testing/BodyDetailTesting.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
components: {
|
||||||
|
BodyDetailTesting
|
||||||
|
},
|
||||||
props: {
|
props: {
|
||||||
testStarted: Boolean,
|
testStarted: Boolean,
|
||||||
formattedTime: String,
|
formattedTime: String,
|
||||||
@@ -77,10 +132,12 @@ export default {
|
|||||||
default: 'Тест',
|
default: 'Тест',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
startTest: Function,
|
||||||
},
|
},
|
||||||
emits: ['change-question'],
|
emits: ['change-question'],
|
||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
const showExitDialog = ref(false);
|
const showExitDialog = ref(false);
|
||||||
|
const showInfoDialog = ref(false);
|
||||||
|
|
||||||
const exitTest = () => {
|
const exitTest = () => {
|
||||||
showExitDialog.value = false;
|
showExitDialog.value = false;
|
||||||
@@ -91,7 +148,7 @@ export default {
|
|||||||
emit('change-question', newPage - 1);
|
emit('change-question', newPage - 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
return { showExitDialog, exitTest, changePage };
|
return { showExitDialog, showInfoDialog, exitTest, changePage };
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
Loaded 100 of 135 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user