Merge branch 'Alex' into razrab

This commit is contained in:
iriska-gri committed 2024-02-09 14:43:49 +03:00
commit 73f256ba17
14 files changed
+266 -43

No files matched your search

+5 -2
View File
@@ -21,7 +21,7 @@
<v-col class="pa-0" > <v-col class="pa-0" >
<v-pagination <v-pagination
v-model="page" v-model="page"
:length=countetnews+1 :length=visiblePage
:total-visible="7" :total-visible="7"
@update:modelValue="loadNewsAll" @update:modelValue="loadNewsAll"
/> />
@@ -65,14 +65,16 @@ export default {
const page = ref(1) const page = ref(1)
const countpage = ref(8) const countpage = ref(8)
const route = useRoute() const route = useRoute()
const visiblePage = ref(0)
const loadNewsAll = () => { const loadNewsAll = () => {
axiosApiInstance.get( `api/navigation/newscrossroad/?name=${route.path}&page=${page.value-1}&countpage=${countpage.value}`).then(result => { axiosApiInstance.get( `api/navigation/newscrossroad/?name=${route.path}&page=${page.value-1}&countpage=${countpage.value}`).then(result => {
newsAll.value= result.data.result newsAll.value= result.data.result
countetnews.value = result.data.countpage/countpage.value countetnews.value = result.data.countpage/countpage.value
visiblePage.value = countetnews.value <= 1 ? 1 : countetnews.value+1
} }
) )
} }
loadNewsAll() loadNewsAll()
@@ -81,6 +83,7 @@ export default {
countetnews, countetnews,
page, page,
countpage, countpage,
visiblePage,
loadNewsAll, loadNewsAll,
} }
} }
+1 -1
View File
@@ -311,7 +311,7 @@
rows="1" rows="1"
row-height="25" row-height="25"
shaped shaped
@keyup.enter.exact="addComment(newsFull.id)"
hide-details hide-details
v-model="textcomment" v-model="textcomment"
/> />
@@ -366,8 +366,13 @@ export default {
}, },
{ {
name: 'Безопасность', name: 'Безопасность',
ico: 'mdi-routes', ico: 'mdi-security',
path: "/securyty" submenu: [
{
name: 'Пожарная безопасность',
path: "/fire_safety"
},
]
}, },
{ {
name: 'О портале', name: 'О портале',
+8
View File
@@ -74,6 +74,14 @@ const routes = [
ico: "mdi-ticket" ico: "mdi-ticket"
} }
}, },
{
path: '/:chapter_id',
component: () => import('@/views/safety/ChaptersSafety.vue'),
meta: {
title: "Разделы безопасности",
ico: "mdi-fire-extinguisher",
}
},
{ {
path: '/inspection', path: '/inspection',
name: 'AboutInspectionPage', name: 'AboutInspectionPage',
+1 -2
View File
@@ -6,7 +6,6 @@ const baseURL = process.env.NODE_ENV == 'development'? 'http://127.0.0.1:8000/':
const baseWS = process.env.NODE_ENV == 'development'? 'ws://127.0.0.1:8000/': `ws://${window.location.host}/`; const baseWS = process.env.NODE_ENV == 'development'? 'ws://127.0.0.1:8000/': `ws://${window.location.host}/`;
// const baseURL = process.env.NODE_ENV == 'development'? 'http://127.0.0.1:8000/': `http://10.252.44.60:9965/`; // const baseURL = process.env.NODE_ENV == 'development'? 'http://127.0.0.1:8000/': `http://10.252.44.60:9965/`;
// const baseWS = process.env.NODE_ENV == 'development'? 'ws://127.0.0.1:8000/': `ws://10.252.44.60:9966/`; // const baseWS = process.env.NODE_ENV == 'development'? 'ws://127.0.0.1:8000/': `ws://10.252.44.60:9966/`;
const safetyURL = process.env.NODE_ENV == 'development'? 'http://127.0.0.1:8000': `http://10.252.44.60:9965`;
// для релизного меняем 'http://ukd/' // для релизного меняем 'http://ukd/'
// const baseURL = 'http://127.0.0.1:8000/'; // const baseURL = 'http://127.0.0.1:8000/';
@@ -90,4 +89,4 @@ async error => {
}) })
export { axiosApiInstance, clearAxios, baseURL,spravURL,baseWS, safetyURL } export { axiosApiInstance, clearAxios, baseURL,spravURL,baseWS }
+35 -35
View File
@@ -1,5 +1,5 @@
<template> <template>
<v-row class="pa-2"> <!-- <v-row class="pa-2">
<v-col cols="5" class="d-flex flex-column justify-start h-screen gap"> <v-col cols="5" class="d-flex flex-column justify-start h-screen gap">
<v-card v-for="item in safetyData" :key="item.id" class="overflow-y-auto mb-2 h-auto"> <v-card v-for="item in safetyData" :key="item.id" class="overflow-y-auto mb-2 h-auto">
<v-card-title>{{ item.name }}</v-card-title> <v-card-title>{{ item.name }}</v-card-title>
@@ -42,7 +42,7 @@
</v-card-actions> </v-card-actions>
</v-card> </v-card>
</v-col> </v-col>
</v-row> </v-row> -->
<!-- <v-dialog v-model="showFile" width="auto" height="auto"> <!-- <v-dialog v-model="showFile" width="auto" height="auto">
<v-card> <v-card>
<v-container v-if="loading"> <v-container v-if="loading">
@@ -61,45 +61,45 @@
</template> </template>
<script setup> <script setup>
import { ref, onBeforeMount } from 'vue'; // import { ref, onBeforeMount } from 'vue';
import { pagecounter } from '@/utils/universal_functions'; // import { pagecounter } from '@/utils/universal_functions';
import { axiosApiInstance, safetyURL } from '@/utils/axios-api'; // import { axiosApiInstance, safetyURL } from '@/utils/axios-api';
import { saveAs } from 'file-saver'; // import { saveAs } from 'file-saver';
import VuePdfEmbed from 'vue-pdf-embed'; // import VuePdfEmbed from 'vue-pdf-embed';
pagecounter(); // pagecounter();
const safetyData = ref([]); // const safetyData = ref([]);
const showMore = ref(false); // const showMore = ref(false);
const showFile = ref(false); // const showFile = ref(false);
let pdfSource = ''; // let pdfSource = '';
const loading = ref(false) // const loading = ref(false)
onBeforeMount(() => { // onBeforeMount(() => {
axiosApiInstance.get(`api/safety/files/`).then(result => { // axiosApiInstance.get(`api/safety/files/`).then(result => {
safetyData.value = result.data // safetyData.value = result.data
}) // })
}); // });
// Проверяем по ID на какой категории срабатывает клик на раскрытии/скрытии, чтобы избежать срабатывания у всех категорий одновременно // // Проверяем по ID на какой категории срабатывает клик на раскрытии/скрытии, чтобы избежать срабатывания у всех категорий одновременно
showMore.value = safetyData.value.reduce((acc, value) => { // showMore.value = safetyData.value.reduce((acc, value) => {
acc[value.id] = false // acc[value.id] = false
return acc // return acc
}, {}); // }, {});
const downloadItem = (url, fileName) => { // const downloadItem = (url, fileName) => {
axiosApiInstance.get(url, {responseType: 'blob'}) // axiosApiInstance.get(url, {responseType: 'blob'})
.then(response => { // .then(response => {
saveAs(response.data, fileName) // saveAs(response.data, fileName)
}) // })
}; // };
function openPDF(url) { // function openPDF(url) {
showFile.value = true // showFile.value = true
if (showFile) { // if (showFile) {
return pdfSource = url // return pdfSource = url
} // }
}; // };
</script> </script>
<style> <style>
@@ -0,0 +1,128 @@
<template>
<v-container :fluid="true">
<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="document">Библиотека документов</v-tab>
<v-tab selected-class="isActiveTab" value="testings">Тестирование</v-tab>
</v-tabs>
</v-card>
<v-window v-model="tab">
<v-window-item value="document">
<v-row class="my-1">
<v-col cols="5" class="d-flex justify-start h-screen">
<v-card v-for="item in safetyData" :key="item.id" class="overflow-y-auto h-auto flex-grow-1 flex-shrink-1">
<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-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>{{ 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-col>
<v-col cols="7" class="d-flex justify-start h-screen">
<v-card v-show="showFile" class="flex-grow-1 flex-shrink-1 overflow-y-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-actions>
<v-btn block @click="showFile = false">Закрыть</v-btn>
</v-card-actions>
</v-card>
</v-col>
</v-row>
</v-window-item>
<v-window-item value="testings">
<!-- Для тестов с пропсами
<TestSafety :data="data"></TestSafety>
-->
<TestSafety></TestSafety>
</v-window-item>
</v-window>
</v-container>
</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 VuePdfEmbed from 'vue-pdf-embed';
import TestSafety from './TestSafety.vue';
pagecounter();
const safetyData = 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()
// Вынес запрос в отдельную функцию, чтобы избежать дублирования одного и того же запроса на сервер.
function getSafety() {
axiosApiInstance.get(`api/safety/files/?chapter_id=${route.params.chapter_id}`).then(result => {
safetyData.value = result.data
})
}
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)
})
};
function openPDF(url) {
showFile.value = true
if (showFile) {
return pdfSource = url
}
};
</script>
<style>
.isActiveTab {
background-color: #68c3ff70;
}
</style>
+79
View File
@@ -0,0 +1,79 @@
<template>
<v-row>
<v-col cols="12">
<v-card>
<v-window v-model="step">
<v-window-item v-for="(item, index) in data" :key="index">
<v-card v-if="item.question" :title="item.question">
<v-radio-group v-model="radios" label="Выберите вариант ответа">
<v-radio v-for="answer in item.answers" :label="answer" :value="answer"></v-radio>
</v-radio-group>
</v-card>
<v-card v-if="item.checkQuestion" :title="item.checkQuestion">
<v-checkbox
v-for="answer in item.answers"
v-model="checks"
:label="answer"
:value="answer">
</v-checkbox>
</v-card>
</v-window-item>
</v-window>
<v-card-actions>
<v-btn
v-if="step > 0"
variant="text"
@click="step--">
Back
</v-btn>
<v-spacer></v-spacer>
<v-btn
v-if="step < data.length"
variant="text"
@click="step++">
Next
</v-btn>
</v-card-actions>
</v-card>
</v-col>
</v-row>
<v-row>
<v-col>
<v-card title="Результат">
<v-container>
<p>Количество баллов: {{ selected }}</p>
</v-container>
</v-card>
</v-col>
</v-row>
</template>
<script setup>
import { ref } from 'vue';
// TODO...
// Рабочий вариант с пропсами, пытаюсь реализовать компонент на пропсах
defineProps({
data: Array
})
const data = ref([
{
question: 'Вопрос 1',
answers: ['1', '2', '3', '4']
},
{
question: 'Вопрос 2',
answers: ['Rer', 'LoL', 'Fort', 'FullG']
},
{
checkQuestion: 'Вопрос с чексбоксом',
answers: ['Кукумбер', 'Сикельд']
}
])
const radios = ref('')
const checks = ref([])
const selected = ref([])
const step = ref(0)
</script>
Binary file not shown.

After

Width:  |  Height:  |  Size: 566 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 659 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

+2 -1
View File
@@ -10,7 +10,8 @@ from .models import *
class SafetyFileAPIView(APIView): class SafetyFileAPIView(APIView):
def get(self, request): def get(self, request):
all_file = SafetyFile.objects.order_by('chapter_id', 'category_id').all() 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) serializer_for_file = SafetyFileSerializer(instance=all_file, many=True)
data = [] data = []