прокинут API к БД, начата работа по выводу данных на клиент
This commit is contained in:
1 parent
568b67d959
commit
84428ee4bd
5 files changed
+41
-15
No files matched your search
@@ -60,15 +60,22 @@
|
||||
</v-card>
|
||||
</v-row>
|
||||
<v-row class="ma-0 overflow-auto h-0">
|
||||
<v-card
|
||||
title="Здесь отображаем файлы по пожарной комиссии"
|
||||
class="overflow-y-auto flex-grow-1 flex-shrink-1 h-100">
|
||||
<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 }}</v-card-text>
|
||||
</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-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">
|
||||
@@ -87,7 +94,7 @@
|
||||
block
|
||||
@click="showFile = false">Закрыть</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-card> -->
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-window-item>
|
||||
@@ -114,13 +121,14 @@ import MainInfoSafety from './MainInfoSafety.vue';
|
||||
pagecounter();
|
||||
|
||||
const safetyData = ref([]);
|
||||
const responsibilityData = ref();
|
||||
const showMore = ref(false);
|
||||
const showFile = ref(false);
|
||||
let pdfSource = '';
|
||||
const loading = ref(false);
|
||||
const tab = ref('')
|
||||
const burl = baseURL.slice(0,-1)
|
||||
const route = useRoute()
|
||||
const tab = ref('');
|
||||
const burl = baseURL.slice(0,-1);
|
||||
const route = useRoute();
|
||||
|
||||
// Вынес запрос в отдельную функцию, чтобы избежать дублирования одного и того же запроса на сервер.
|
||||
function getSafety() {
|
||||
@@ -129,9 +137,18 @@ function getSafety() {
|
||||
})
|
||||
}
|
||||
|
||||
function getResponsibility() {
|
||||
axiosApiInstance.get(`api/safety/committee_files/`).then(result => {
|
||||
responsibilityData.value = result.data
|
||||
console.log(responsibilityData.value);
|
||||
})
|
||||
}
|
||||
|
||||
getResponsibility()
|
||||
|
||||
onBeforeMount(() => getSafety());
|
||||
// Хук обновления реализует возможность динамической подгрузки данных при переключении между вкладками раздела безопасность
|
||||
onUpdated(() => getSafety())
|
||||
onUpdated(() => getSafety());
|
||||
|
||||
// Проверяем по ID на какой категории срабатывает клик на раскрытии/скрытии, чтобы избежать срабатывания у всех категорий одновременно
|
||||
showMore.value = safetyData.value.reduce((acc, value) => {
|
||||
|
||||
@@ -131,7 +131,6 @@ const responsibility = ref([])
|
||||
function getResponsibility() {
|
||||
axiosApiInstance.get(`api/safety/responsibility/`).then(result => {
|
||||
responsibility.value = result.data.users
|
||||
console.log(responsibility.value);
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -169,8 +169,8 @@ class BirthdayText(models.Model):
|
||||
|
||||
class Screensaver(models.Model):
|
||||
img = models.ImageField(upload_to='screengallery/%Y/%m/%d', null=True, verbose_name='Изображение')
|
||||
cdate =models.DateField(default=date.today().replace(year=1990), null=True, verbose_name='Дата начала периода')
|
||||
enddate = models.DateField(default= date.today().replace(year=1990), verbose_name='Дата окончания периода', null=True)
|
||||
cdate =models.DateField(default=date.today().replace(year=1988), null=True, verbose_name='Дата начала периода')
|
||||
enddate = models.DateField(default= date.today().replace(year=1988), verbose_name='Дата окончания периода', null=True)
|
||||
|
||||
class Meta:
|
||||
|
||||
|
||||
+2
-1
@@ -5,5 +5,6 @@ from .views import *
|
||||
|
||||
urlpatterns = [
|
||||
path('files/', SafetyFileAPIView.as_view(), name='safety_files'),
|
||||
path('responsibility/', SafetyResponsebilityAPIView.as_view(), name='responsibility'),
|
||||
path('responsibility/', SafetyResponsebilityAPIView.as_view(), name='responsibility'),
|
||||
path('committee_files/', CommitteeFilesAPIView.as_view(), name='committee_files')
|
||||
]
|
||||
+11
-2
@@ -5,7 +5,7 @@ from rest_framework.views import APIView
|
||||
from rest_framework.response import Response
|
||||
from .serializers import *
|
||||
from .models import *
|
||||
from userauth.serializers import OrderResponsibilitySerializer
|
||||
from userauth.serializers import *
|
||||
from userauth.models import *
|
||||
# Create your views here.
|
||||
|
||||
@@ -41,4 +41,13 @@ class SafetyResponsebilityAPIView(APIView):
|
||||
fireuser = OrderResponsibility.objects.get(id=54)
|
||||
responsobility_users = OrderResponsibilitySerializer(fireuser)
|
||||
|
||||
return Response(responsobility_users.data)
|
||||
return Response(responsobility_users.data)
|
||||
|
||||
class CommitteeFilesAPIView(APIView):
|
||||
|
||||
def get(self, request):
|
||||
|
||||
committee_files = Committee1.objects.get(id=106)
|
||||
files = Committee1Serializer(committee_files)
|
||||
|
||||
return Response(files.data)
|
||||
Reference in new issue
Block a user