Merge remote-tracking branch 'origin/52_fire' into develop

This commit is contained in:
Nukeap committed 2024-05-16 15:42:36 +03:00
commit 3efc8fdfcd
14 files changed
+347 -394

No files matched your search

+1 -1
View File
@@ -66,5 +66,5 @@ urlpatterns = [
path('api/general_vacation/', include('general_vacation.urls')),
path('api/about_inspection/', include('about_inspection.urls')),
path('api/calendar_of_events/', include('calendar_of_events.urls')),
path('api/safety/', include('safety.urls'))
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
+10 -7
View File
@@ -1,13 +1,16 @@
from django.contrib import admin
from .models import SafetyFile
from .models import SafetyFile, SafetyType, SafetyDocumentCategory
# Register your models here.
class SafetyFileAdmin(admin.ModelAdmin):
list_display = ('name', 'chapter_id', 'category_id', 'sign_date')
list_editable = ('sign_date', 'category_id')
list_filter = ('name', 'sign_date', 'category_id',)
fields = ('name', 'url', 'chapter_id', 'category_id', 'sign_date')
admin.site.register(SafetyFile, SafetyFileAdmin)
list_display = ('name', 'chapter', 'category', 'sign_date', 'formainpage')
list_editable = ('sign_date', 'category', 'formainpage')
list_filter = ('name', 'sign_date', 'category',)
fields = ('name', 'url', 'chapter', 'category', 'sign_date', 'formainpage')
admin.site.register(SafetyType)
admin.site.register(SafetyDocumentCategory)
admin.site.register(SafetyFile, SafetyFileAdmin)
+13 -28
View File
@@ -1,42 +1,27 @@
from django.db import models
from enum import Enum
# Create your models here.
class EnumChoice(Enum):
@classmethod
def get_choices(cls):
return [(enum_.name, enum_.value) for enum_ in cls]
class SafetyDocumentCategory(models.Model):
name = models.CharField(max_length=255)
class SafetyChapter(EnumChoice):
fire_safety = "Пожарная безопасность"
information_safety = "Информационная безопасность"
occupational_safety = "Охрана труда"
access_mode = "Пропускной и внутриобъектовый режим"
civil_defense = "Гражданская оборона"
state_secrets = "Защита гостайны"
military_registration = "Мобилизационная подготовка и воинский учет"
def __str__(self):
return str(self.name)
class SafetyDocumentCategory(EnumChoice):
regulations = "Нормативные документы"
instructions = "Инструкции"
orders = "Приказы"
provisions = "Положения"
educational_materials = "Учебные материалы"
laws = "Законы"
decrees = "Указы"
resolutions = "Постановления"
thematic_materials = "Тематические материалы"
methodological_materials = "Методологические материалы"
evacuation_plan = 'План эвакуации'
class SafetyType(models.Model):
name = models.CharField(max_length=255)
path = models.CharField(max_length=255, null=True)
def __str__(self):
return str(self.name)
# Общая модель для раздела "Безопасность"
class SafetyFile(models.Model):
name = models.CharField(verbose_name='Имя документа', max_length=255)
url = models.FileField(verbose_name='Путь до файла',upload_to='safety')
chapter_id = models.CharField(verbose_name='Раздел', max_length=255, blank=False, db_index=True, choices=SafetyChapter.get_choices())
category_id = models.CharField(verbose_name='Категория документа', max_length=255, blank=False, db_index=True, choices=SafetyDocumentCategory.get_choices())
chapter = models.ForeignKey('SafetyType', models.DO_NOTHING, null=True, verbose_name='Раздел', related_name="type_file")
category = models.ForeignKey('SafetyDocumentCategory', models.DO_NOTHING, null=True, verbose_name='Категория документа')
formainpage = models.BooleanField(default=False, verbose_name="Основная информация")
sign_date = models.DateField(verbose_name='Дата документа')
created_at = models.DateTimeField(verbose_name='Дата загрузки файла', auto_now_add=True)
update_at = models.DateTimeField(verbose_name='Дата обновления файла', auto_now=True)
+38 -5
View File
@@ -1,10 +1,43 @@
from rest_framework import serializers
from .models import *
from django.db.models import Count
class OneFileSerializer(serializers.ModelSerializer):
class Meta:
model = SafetyFile
fields = '__all__'
class SafetyTypeSerializer(serializers.ModelSerializer):
class Meta:
model = SafetyType
fields = '__all__'
class SafetyFileSerializer(serializers.ModelSerializer):
chapter_name = serializers.CharField(source='get_chapter_id_display')
category_name = serializers.CharField(source='get_category_id_display')
# chapter_name = serializers.CharField(source='get_chapter_id_display')
# category_name = serializers.CharField(source='get_category_id_display')
categories = serializers.SerializerMethodField('get_categories')
class Meta:
model = SafetyFile
fields = '__all__'
model = SafetyType
fields = '__all__'
def get_categories(self, obj):
files = obj.type_file.all().order_by('category__name')
categories = files.values("category","category__name").distinct()
for x in files:
for y in categories:
if 'files' not in y.keys():
y['files'] = []
if x.category.id == y['category']:
y['files'].append(OneFileSerializer(x).data)
return categories
+1
View File
@@ -4,6 +4,7 @@ from rest_framework.routers import DefaultRouter
from .views import *
urlpatterns = [
path('gettypes/', SafetyTypeAPIView.as_view(), name="SafetyTypeAPIView"),
path('files/', SafetyFileAPIView.as_view(), name='safety_files'),
path('responsibility/', SafetyResponsebilityAPIView.as_view(), name='responsibility'),
path('committee_files/', CommitteeFilesAPIView.as_view(), name='committee_files')
+10 -22
View File
@@ -1,5 +1,6 @@
from itertools import groupby
from django.db.models import Count
from rest_framework.generics import ListAPIView
from django.shortcuts import render
from rest_framework.views import APIView
from rest_framework.response import Response
@@ -9,30 +10,17 @@ from userauth.serializers import *
from userauth.models import *
# Create your views here.
class SafetyTypeAPIView(ListAPIView):
def get(self, request):
chapters = SafetyType.objects.annotate(Count("type_file")).filter(type_file__count__gt=0)
return Response(SafetyTypeSerializer(chapters, many=True).data)
class SafetyFileAPIView(APIView):
def get(self, request):
chapters = self.request.query_params.get('chapter_id', 1)
all_file = SafetyFile.objects.filter(chapter_id=chapters).order_by('chapter_id', 'category_id').all()
serializer_for_file = SafetyFileSerializer(instance=all_file, many=True)
data = []
for (chapter_id, chapter_name), row in groupby(serializer_for_file.data, lambda x: (x['chapter_id'], x['chapter_name'])):
chapter = {
'id': chapter_id,
'name': chapter_name,
'categories': []
}
data.append(chapter)
for (category_id, category_name), files in groupby(row, lambda x: (x['category_id'], x['category_name'])):
chapter['categories'].append({
'id': category_id,
'name': category_name,
'files': [file for file in files]
})
return Response(data)
chapters = self.request.query_params.get('chapter', "fire_safety")
safety_group = SafetyType.objects.get(path=chapters)
return Response(SafetyFileSerializer(safety_group).data)
class SafetyResponsebilityAPIView(APIView):
+14 -1
View File
@@ -27,8 +27,21 @@ class DictDepartmentAdmin(admin.ModelAdmin):
qs = super().get_queryset(request)
qs = qs.filter(deleted=0)
return qs
# class DictEmployeeAdmin(admin.ModelAdmin):
class IlineComitteeFiles(admin.StackedInline):
# readonly_fields = ['file_name']
model = Committee1Files
extra = 0
class InlineComiteePeople(admin.StackedInline):
model = Committee2
extra = 0
class Committee1Admin(admin.ModelAdmin):
# list_display = ('name', 'num_start', 'date_start', 'num_finish', 'date_finish')
inlines = [IlineComitteeFiles, InlineComiteePeople]
admin.site.register(Committee1, Committee1Admin)
admin.site.register(DictEmployee,DictEmployeeAdmin)
admin.site.register(DictDepartment, DictDepartmentAdmin )
+23 -1
View File
@@ -23,16 +23,26 @@ class Committee1(models.Model):
db_table = 'committee1'
db_table_comment = '╤яшёюъ ъюьшёёшщ'
def __str__(self):
return str(self.name)
class Committee1Files(models.Model):
id_committee1 = models.ForeignKey(Committee1, models.DO_NOTHING, db_column='id_committee1', db_comment='╚─ ъюьшёёшш')
file_name = models.CharField(max_length=1024, db_comment='╚ь  Їрщыр')
file_name = models.FileField(null=True, blank=True, upload_to='comitee_files')
# file_name = models.CharField(max_length=1024, db_comment='╚ь Їрщыр')
is_actual = models.IntegerField(db_comment='╧Ёшчэръ ръЄєры№эюёЄш Їрщыр')
class Meta:
managed = False
db_table = 'committee1_files'
def __str__(self):
return str(self.file_name)
def save(self, *args, **kwargs):
super().save(*args, **kwargs)
class Committee2(models.Model):
id_committee1 = models.ForeignKey(Committee1, models.DO_NOTHING, db_column='id_committee1', db_comment='╙эшъры№э√щ эюьхЁ ъюьшёёшш')
@@ -45,6 +55,9 @@ class Committee2(models.Model):
db_table = 'committee2'
db_table_comment = '╤юёЄрт ъюьшёёшщ'
def __str__(self):
return str(self.id_dict_committee_position.name)
class DictCommitteeExpert(models.Model):
fio = models.CharField(max_length=250, blank=True, null=True, db_comment='╘╚╬ ¤ъёяхЁЄр')
@@ -54,6 +67,9 @@ class DictCommitteeExpert(models.Model):
managed = False
db_table = 'dict_committee_expert'
db_table_comment = '╤яЁртюўэшъ эхчртшёшь√ї ¤ъёяхЁЄют'
def __str__(self):
return str(self.fio)
class DictCommitteeOrderAddon(models.Model):
@@ -79,6 +95,9 @@ class DictCommitteePosition(models.Model):
db_table = 'dict_committee_position'
db_table_comment = '╤яЁртюўэшъ фюыцэюёЄхщ ъюьшёёшщ'
def __str__(self):
return str(self.name_short)
class DictCommitteeType(models.Model):
name = models.CharField(max_length=100, blank=True, null=True, db_comment='═ршьхэютрэшх тшфр ъюьшёёшш')
@@ -88,6 +107,9 @@ class DictCommitteeType(models.Model):
db_table = 'dict_committee_type'
db_table_comment = '╤яЁртюўэшъ тшфют ъюьшёёшщ'
def __str__(self):
return str(self.name)
class DictCompetences(models.Model):
id_dict_competences_type = models.ForeignKey('DictCompetencesType', models.DO_NOTHING, db_column='id_dict_competences_type', db_comment='шфхэЄшЇшърЄюЁ уЁєяя√ ъюьяхЄхэЎшш')
+2 -2
View File
@@ -31,7 +31,7 @@ class OrderResponsibilitySerializer(serializers.ModelSerializer):
fields = '__all__'
def respons_users(self,obj):
data = OrderResponsibilityEmployee.objects.filter(id_order_responsibility=obj.id)
data = OrderResponsibilityEmployee.objects.filter(id_order_responsibility=obj.id).order_by("id_dict_employee_id__id_dict_position__order_position","id_dict_employee_id__familyname")
return ResponsibilityUsersSerializer(data,many=True).data
class Committee1FilesSerializer(serializers.ModelSerializer):
@@ -40,7 +40,7 @@ class Committee1FilesSerializer(serializers.ModelSerializer):
"""
class Meta:
model = Committee1Files
exclude=['id_committee1']
fields = '__all__'
class Committee1Serializer(serializers.ModelSerializer):
""" Забирает всю информацию по комиссиям с типом
+23 -14
View File
@@ -295,7 +295,7 @@ import { useTheme } from "vuetify";
import AuthForm from '@/components/UI/Auth-form.vue'
import OnlineUsers from '@/components/UI/fiousercard/onlineUsers.vue'
import CardLike from '@/components/cardLike.vue'
import { clearAxios } from '@/utils/axios-api'
import { axiosApiInstance, clearAxios } from '@/utils/axios-api'
import { baseURL } from '@/utils/axios-api'
import VcardUser from '@/components/UI/fiousercard/vcardUser.vue'
@@ -381,7 +381,7 @@ export default {
// ]
const navigations = [
const navigations = ref([
{
name: 'Структура',
@@ -424,16 +424,6 @@ export default {
ico: 'mdi-newspaper',
path: "/news"
},
{
name: 'Безопасность',
ico: 'mdi-security',
submenu: [
{
name: 'Пожарная безопасность',
path: "/fire_safety"
},
]
},
{
name: 'О портале',
ico: 'mdi-information-variant',
@@ -456,8 +446,8 @@ export default {
// ico: 'mdi-cake-variant',
// path: "/fnshol"
// }
]
])
const imageSrc = computed(() => {
return new URL(`@/assets/FNS-logo-xs.png`, import.meta.url).href;
})
@@ -467,7 +457,26 @@ export default {
// feedalert.value=true
}
const getSafetyChapter = () => {
axiosApiInstance.get('api/safety/gettypes/').then(response => {
response.data.forEach(item => {
if(!item.path.startsWith('/')) {
item.path = '/' + item.path
}
});
if (response.data.length > 0) {
let safetyMenu = {
name: 'Безопасность',
ico: 'mdi-security',
submenu: response.data
}
navigations.value.splice(5, 0, safetyMenu)
}
})
}
getSafetyChapter()
return {
theme,
+1 -1
View File
@@ -75,7 +75,7 @@ const routes = [
}
},
{
path: '/:chapter_id',
path: '/:chapter',
component: () => import('@/views/safety/ChaptersSafety.vue'),
meta: {
title: "Разделы безопасности",
+2 -2
View File
@@ -1,7 +1,7 @@
import {useAccountStore} from '@/store/AccountStore'
import axios from "axios";
const spravURL = 'http://10.252.44.33/accounting6/images/photo/'
const spravURLBase = 'http://10.252.44.33/accounting6/'
const baseURL = process.env.NODE_ENV == 'development'? 'http://127.0.0.1:8000/': `http://${window.location.host}/`;
const baseWS = process.env.NODE_ENV == 'development'? 'ws://127.0.0.1:8000/': `ws://${window.location.host}/`;
// const baseURL = process.env.NODE_ENV == 'development'? 'http://127.0.0.1:8000/': `http://10.252.44.60:9965/`;
@@ -89,4 +89,4 @@ async error => {
})
export { axiosApiInstance, clearAxios, baseURL,spravURL,baseWS }
export { axiosApiInstance, clearAxios, baseURL,spravURL, spravURLBase, baseWS }
+154 -202
View File
@@ -1,236 +1,188 @@
<template>
<v-row no-gutters class="flex-column h-100 gap pa-1">
<v-col lg="1" class="w100 h-100">
<v-card>
<v-tabs
v-model="tab"
bg-color="teal-darken-1"
slider-color="teal-darken-2"
:grow="true"
>
<v-tab selected-class="isActiveTab" value="mainInfo"
>Основная информация</v-tab
>
<v-tab selected-class="isActiveTab" value="document"
>Документация</v-tab
>
<v-tab selected-class="isActiveTab" value="testings"
>Тестирование</v-tab
>
</v-tabs>
</v-card>
</v-col>
<v-col class="w100 h-100">
<v-window v-model="tab" class="h-100">
<v-window-item no-gutters class="gap h-100" value="mainInfo">
<MainInfoSafety></MainInfoSafety>
</v-window-item>
<v-window-item value="document" class="h-100">
<v-row no-gutters class="gap h-100">
<v-col lg="6">
<!---->
<v-card class="h-100 flex-column d-flex gap">
<v-row class="ma-0 my-3 overflow-auto h-0 pb-1">
<v-card
v-for="item in safetyData"
:key="item.id"
class="overflow-y-auto flex-grow-1 flex-shrink-1 h-100"
>
<v-card-title>{{ item.name }}</v-card-title>
<v-container
v-for="category in item.categories"
:key="item.id + category.id"
:fluid="true"
class="py-0"
>
<v-card-actions v-if="category.id != 'evacuation_plan'">
<v-btn
@click="
showMore[item.id + category.id] =
!showMore[item.id + category.id]
"
variant="text"
>
{{ category.name }}
</v-btn>
<v-btn
:icon="
showMore[item.id + category.id]
? 'mdi-chevron-up'
: 'mdi-chevron-down'
"
@click="
showMore[item.id + category.id] =
!showMore[item.id + category.id]
"
>
</v-btn>
</v-card-actions>
<v-expand-transition>
<div v-show="showMore[item.id + category.id]">
<v-card-actions
v-for="file in category.files"
:key="file.id"
class="overflow-y-auto"
>
<v-card-text
class="cursor-pointer"
:ref_="openPDF(burl + file.url)"
@click="
openPDF(burl + file.url), (loading = true)
"
>
{{ file.name }}
</v-card-text>
<v-btn
icon="mdi-file-pdf-box"
color="red"
@click="
openPDF(burl + file.url), (loading = true)
"
></v-btn>
<v-btn
icon="mdi-file-download-outline"
color="green"
@click="downloadItem(burl + file.url, file.name)"
></v-btn>
</v-card-actions>
</div>
</v-expand-transition>
</v-container>
</v-card>
</v-row>
<v-row class="ma-0 overflow-auto h-0">
<v-card
class="overflow-y-auto flex-grow-1 flex-shrink-1 h-100"
>
<v-card-title>{{ responsibilityData.name }}</v-card-title>
<v-container
v-for="file in responsibilityData.files"
:fluid="true"
class="py-0"
>
<v-card-actions :key="file.id">
<v-card-text>{{
file.file_name.replace(/\.[^/.]+$/, "")
}}</v-card-text>
<v-btn
icon="mdi-file-pdf-box"
color="red"
@click="openPDF(burl + file.url), (loading = true)"
></v-btn>
<v-btn
icon="mdi-file-download-outline"
color="green"
@click="
downloadItem(burl + file.file_name, file.file_name)
"
></v-btn>
<!-- @click="downloadItem(burl + file.file_name, file.file_name)" -->
</v-card-actions>
</v-container>
</v-card>
</v-row>
</v-card>
</v-col>
<v-col>
<!-- <v-card class="h-100 flex-column d-flex gap">
<v-row class="ma-0 overflow-auto h-0">
<v-card v-show="showFile" class="mr-2 flex-grow-1 flex-shrink-1 h-100 pa-2 overflow-auto">
<v-container v-if="loading">
<v-progress-linear
:rounded="5"
indeterminate
color="teal">
</v-progress-linear>
</v-container>
<VuePdfEmbed :source="pdfSource" width="720" @rendered="loading = false"/>
</v-card>
</v-row>
<v-card-actions v-show="showFile">
<v-btn
position="sticky"
block
@click="showFile = false">Закрыть</v-btn>
</v-card-actions>
</v-card> -->
</v-col>
</v-row>
</v-window-item>
<v-window-item value="testings" no-gutters class="gap h-100">
<TestSafety></TestSafety>
</v-window-item>
</v-window>
</v-col>
</v-row>
<v-row no-gutters class="flex-column h-100 gap pa-1">
<v-col class="w100 h-100 flex-grow-0">
<v-card>
<v-tabs v-model="tab" bg-color="bg_tab" slider-color="slider_tab" selected-class="isActiveTab" :grow="true">
<v-tab value="mainInfo">Основная информация</v-tab>
<v-tab value="document">Документация</v-tab>
<v-tab value="testings">Тестирование</v-tab>
</v-tabs>
</v-card>
</v-col>
<v-col class="w100 h-100">
<v-window v-model="tab" class="h-100">
<v-window-item no-gutters class="gap h-100" value="mainInfo">
<MainInfoSafety :formainpage="formainpage"></MainInfoSafety>
</v-window-item>
<v-window-item value="document" class="h-100">
<v-row no-gutters class="gap h-100 ">
<v-col lg="6">
<v-card class="h-100 flex-column d-flex gap ">
<v-row class="ma-0 overflow-auto pb-1 ">
<v-card class="overflow-y-auto flex-grow-1 flex-shrink-1 h-100">
<v-card-title>{{ safetyData.name }}</v-card-title>
<v-expansion-panels
multiple
flat>
<v-expansion-panel elevation=0 v-for="category in safetyData.categories"
:key="category.id" class="py-0">
<v-expansion-panel-title class="font-weight-medium">{{
category.category__name }}</v-expansion-panel-title>
<v-expansion-panel-text>
<div v-for="file in category.files" :key="file.id"
class="overflow-y-auto d-flex justify-space-between">
<div class="cursor-pointer"
@click="openPDF(file.url), loading = true">
{{ file.name }}
</div>
<div>
<v-btn variant="text" icon="mdi-file-pdf-box"
color="red"
@click="openPDF(file.url), loading = true"></v-btn>
<v-btn variant="text"
icon='mdi-file-download-outline' color="green"
@click="downloadItem(burl + file.url, file.name)"></v-btn>
</div>
</div>
</v-expansion-panel-text>
</v-expansion-panel>
</v-expansion-panels>
</v-card>
</v-row>
<v-row class="ma-0 overflow-auto bg-yellow ">
<v-card class="overflow-y-auto flex-grow-1 h-100">
<v-card-title>{{ responsibilityData.name }}</v-card-title>
<v-container v-for="file in responsibilityData.files" :fluid="true" class="py-0">
<v-card-actions :key="file.id">
<v-card-text class="cursor-pointer"
@click="openPDF(checkNameFiles(file)), loading = true">
{{ get_name(decodeURI(file.file_name.replace(/\.[^/.]+$/, ""))) }}
</v-card-text>
<v-btn icon="mdi-file-pdf-box" color="red"
@click="openPDF(checkNameFiles(file)), loading = true"></v-btn>
<v-btn icon='mdi-file-download-outline' color="green"
@click="downloadItem(burl + checkNameFiles(file), get_name(decodeURI(file.file_name)))"></v-btn>
</v-card-actions>
</v-container>
</v-card>
</v-row>
</v-card>
</v-col>
<v-col>
<v-card class="h-100 flex-column d-flex gap">
<v-row class="ma-0 overflow-auto h-0">
<v-card v-show="showFile"
class="mr-2 flex-grow-1 flex-shrink-1 h-100 pa-2 overflow-auto">
<v-container v-if="loading">
<v-progress-linear :rounded="5" indeterminate color="teal">
</v-progress-linear>
</v-container>
<VuePdfEmbed :source="pdfSource" width="720" @rendered="loading = false" />
</v-card>
</v-row>
<v-card-actions v-show="showFile">
<v-btn position="sticky" block @click="showFile = false">Закрыть</v-btn>
</v-card-actions>
</v-card>
</v-col>
</v-row>
</v-window-item>
<v-window-item value="testings" no-gutters class="gap h-100 ">
<TestSafety></TestSafety>
</v-window-item>
</v-window>
</v-col>
</v-row>
</template>
<script setup>
import { ref, onBeforeMount, onUpdated } from "vue";
import { pagecounter } from "@/utils/universal_functions";
import { axiosApiInstance, baseURL } from "@/utils/axios-api";
import { saveAs } from "file-saver";
import { useRoute } from "vue-router";
import { ref, onBeforeMount, computed } from 'vue';
import { pagecounter } from '@/utils/universal_functions';
import { axiosApiInstance, baseURL, spravURLBase } from '@/utils/axios-api';
import { saveAs } from 'file-saver';
import { useRoute } from 'vue-router'
import VuePdfEmbed from "vue-pdf-embed";
import TestSafety from "./TestSafety.vue";
import MainInfoSafety from "./MainInfoSafety.vue";
import VuePdfEmbed from 'vue-pdf-embed';
import TestSafety from './TestSafety.vue';
import MainInfoSafety from './MainInfoSafety.vue';
pagecounter();
const safetyData = ref([]);
const safetyData = ref({categories:[]});
const responsibilityData = ref();
const showMore = ref(false);
const showFile = ref(false);
let pdfSource = "";
const showFile = ref(true);
let pdfSource = ref("");
const loading = ref(false);
const tab = ref("");
const tab = ref('');
const burl = baseURL.slice(0, -1);
const route = useRoute();
// Вынес запрос в отдельную функцию, чтобы избежать дублирования одного и того же запроса на сервер.
function getSafety() {
axiosApiInstance
.get(`api/safety/files/?chapter_id=${route.params.chapter_id}`)
.then((result) => {
safetyData.value = result.data;
});
axiosApiInstance.get(`api/safety/files/?chapter=${route.params.chapter}`).then(result => {
safetyData.value = result.data
// console.log(safetyData.value);
loading.value = true
pdfSource.value = burl + safetyData.value.categories[0].files[0].url
// console.log(safetyData.value);
})
}
const formainpage = computed({
get() {
let arr = []
safetyData.value.categories.forEach(element => {
element.files.forEach((e) => {
if (e.formainpage == true) {
arr.push(e)
}
})
})
return arr
}
})
function getResponsibility() {
axiosApiInstance.get(`api/safety/committee_files/`).then((result) => {
responsibilityData.value = result.data;
});
axiosApiInstance.get(`api/safety/committee_files/`).then(result => {
responsibilityData.value = result.data
})
}
getResponsibility();
getResponsibility()
onBeforeMount(() => getSafety());
// Хук обновления реализует возможность динамической подгрузки данных при переключении между вкладками раздела безопасность
onUpdated(() => getSafety());
// Проверяем по ID на какой категории срабатывает клик на раскрытии/скрытии, чтобы избежать срабатывания у всех категорий одновременно
showMore.value = safetyData.value.reduce((acc, value) => {
acc[value.id] = false;
return acc;
}, {});
const downloadItem = (url, fileName) => {
axiosApiInstance.get(url, { responseType: "blob" }).then((response) => {
saveAs(response.data, fileName);
});
axiosApiInstance.get(url, { responseType: 'blob' })
.then(response => {
saveAs(response.data, fileName)
})
};
function openPDF(url) {
showFile.value = true;
if (showFile) {
return (pdfSource = url);
}
pdfSource.value = burl + url
showFile.value = true
};
function get_name(namestr) {
let arr = namestr.split("/")
return arr[arr.length - 1]
}
function checkNameFiles(obj) {
if (obj.file_name.includes('/media/comitee_files/')) {
return obj.file_name
}
else {
return spravURLBase + `files/committee1_docs/${obj.id_committee1}/${get_name(obj.file_name)}`
}
}
</script>
<style>
.isActiveTab {
background-color: #68c3ff70;
background-color: #E0F2F1;
color: #004D40;
}
</style>
</style>
+55 -108
View File
@@ -1,106 +1,19 @@
<template>
<v-card class="h-100">
<v-row no-gutters class="h-100">
<v-col cols="9">
<v-card class="h-100 d-flex flex-column">
<v-row class="ma-0 overflow-auto h-0">
<v-col
cols="6"
class="h-100 gap">
<v-card class="h-100">
<v-img
class="cursor-pointer"
:src="`${burl}/media/safety/schemas/Схема1.jpg`"
height="100%"
@click="openFirstPlan = true">
</v-img>
</v-card>
<v-dialog v-model="openFirstPlan" :width="900" height="100%">
<v-row class="ma-0 overflow-auto h-0">
<v-card class="h-100 w-100 pa-0 flex-grow-0">
<v-btn
density="compact"
variant="text"
icon="mdi-close"
@click="openFirstPlan = false">
</v-btn>
<v-img
:src="`${burl}/media/safety/schemas/Схема1.jpg`"
class="cursor-pointer"
height="100%"
width="100%"
@click="openFirstPlan = false">
</v-img>
</v-card>
</v-row>
</v-dialog>
</v-col>
<v-col
cols="6"
class="h-100 gap">
<v-card class="h-100">
<v-img
:src="`${burl}/media/safety/schemas/Схема2.jpg`"
class="cursor-pointer"
height="100%"
@click="openSecondPlan = true">
</v-img>
<v-dialog v-model="openSecondPlan" :width="900" height="100%">
<v-row class="ma-0 overflow-auto h-0">
<v-card class="h-100 w-100 pa-0 flex-grow-0">
<v-btn
density="compact"
variant="text"
icon="mdi-close"
@click="openSecondPlan = false">
</v-btn>
<v-img
:src="`${burl}/media/safety/schemas/Схема2.jpg`"
class="cursor-pointer"
height="100%"
width="100%"
@click="openSecondPlan = false">
</v-img>
</v-card>
</v-row>
</v-dialog>
</v-card>
</v-col>
</v-row>
<v-row class="ma-0 overflow-auto h-0">
<v-col class="h-100 gap">
<v-card class="h-100">
<v-img
:src="`${burl}/media/safety/schemas/План.jpg`" @click="openImg = true"
class="cursor-pointer"
height="100%"
width="100%">
</v-img>
<v-dialog v-model="openImg" :width="900" height="100%">
<v-row class="ma-0 overflow-auto h-0">
<v-card class="h-100 w-100 pa-0 flex-grow-0">
<v-btn
density="compact"
variant="text"
icon="mdi-close"
@click="openImg = false">
</v-btn>
<v-img
:src="`${burl}/media/safety/schemas/План.jpg`"
class="cursor-pointer"
height="100%"
width="100%"
@click="openImg = false">
</v-img>
</v-card>
</v-row>
</v-dialog>
</v-card>
</v-col>
</v-row>
</v-card>
<v-row no-gutters class="gap h-100 ">
<v-col cols="9" class="flex-column" >
<v-row no-gutters class="h-100 justify-center">
<v-col lg="6" class="meheight" v-for="schema in formainpage" :key="schema.id">
<VuePdfEmbed v-if="schema.url.endsWith('.pdf')" :source="burl + schema.url" width="500" />
<v-img v-else
class="cursor-pointer"
:src="burl + schema.url"
@click="openFirstPlan_opener(schema)">
</v-img>
</v-col>
</v-row>
</v-col>
<v-col cols="3" class="w100">
<v-col class="w100">
<v-card class="h-100 d-flex flex-column">
<v-card-title class="text-wrap">Ответственные за противопожарную безопасность</v-card-title>
<v-row class="ma-0 overflow-auto h-0">
@@ -112,23 +25,52 @@
</list-user>
</v-card>
</v-row>
</v-card>
</v-card>
<v-dialog v-model="openFirstPlan" :width="900" height="100%">
<v-row class="ma-0 overflow-auto h-0">
<v-card class="h-100 w-100 pa-0 flex-grow-0">
<v-btn
density="compact"
variant="text"
icon="mdi-close"
@click="openFirstPlan = false">
</v-btn>
<v-img
:src="urlschema"
class="cursor-pointer"
height="100%"
width="100%"
@click="openFirstPlan = false">
</v-img>
</v-card>
</v-row>
</v-dialog>
</v-col>
</v-row>
</v-card>
</template>
<script setup>
import { baseURL, axiosApiInstance } from '@/utils/axios-api'
import { ref } from 'vue';
import VuePdfEmbed from 'vue-pdf-embed';
defineProps(
{
formainpage: Object,
require:true
},
)
const urlschema=ref(null)
const burl = baseURL.slice(0,-1)
const openImg = ref(false)
const openFirstPlan = ref(false)
const openSecondPlan = ref(false)
const responsibility = ref([])
function openFirstPlan_opener(schema){
urlschema.value = burl + schema.url
openFirstPlan.value = true
}
function getResponsibility() {
axiosApiInstance.get(`api/safety/responsibility/`).then(result => {
responsibility.value = result.data.users
@@ -137,5 +79,10 @@ function getResponsibility() {
getResponsibility()
</script>
</script>
<style>
.meheight {
max-height: 44vh;
}
</style>