Merge branch 'P-29' into P-29I
This commit is contained in:
commit
6990f23d52
3 files changed
+51
-63
No files matched your search
@@ -12,7 +12,7 @@
|
||||
<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>
|
||||
<MainInfoSafety :formainpage="safetyData.mainpage_file"></MainInfoSafety>
|
||||
</v-window-item>
|
||||
<v-window-item value="document" class="h-100">
|
||||
<v-row no-gutters class="gap h-100 ">
|
||||
@@ -59,9 +59,11 @@
|
||||
{{ 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>
|
||||
@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>
|
||||
@click="downloadItem(burl + checkNameFiles(file), get_name(decodeURI(file.file_name)))">
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
</v-container>
|
||||
</v-card>
|
||||
@@ -96,9 +98,9 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onBeforeMount, computed } from 'vue';
|
||||
import { ref, onBeforeMount } from 'vue';
|
||||
import { pagecounter } from '@/utils/universal_functions';
|
||||
import { axiosApiInstance, baseURL, spravURLBase } from '@/utils/axios-api';
|
||||
import { axiosApiInstance, baseURL } from '@/utils/axios-api';
|
||||
import { saveAs } from 'file-saver';
|
||||
import { useRoute } from 'vue-router'
|
||||
|
||||
@@ -108,7 +110,7 @@ import MainInfoSafety from './MainInfoSafety.vue';
|
||||
|
||||
pagecounter();
|
||||
|
||||
const safetyData = ref({categories:[]});
|
||||
const safetyData = ref({});
|
||||
const responsibilityData = ref();
|
||||
const showMore = ref(false);
|
||||
const showFile = ref(true);
|
||||
@@ -120,45 +122,21 @@ const route = useRoute();
|
||||
|
||||
// Вынес запрос в отдельную функцию, чтобы избежать дублирования одного и того же запроса на сервер.
|
||||
function getSafety() {
|
||||
console.log(route.params);
|
||||
axiosApiInstance.get(`api/safety/?chapter=${route.params.chapter}`).then(result => {
|
||||
safetyData.value = result.data
|
||||
// console.log(safetyData.value);
|
||||
safetyData.value = result.data
|
||||
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
|
||||
// })
|
||||
// }
|
||||
|
||||
// getResponsibility()
|
||||
|
||||
onBeforeMount(() => getSafety());
|
||||
|
||||
const downloadItem = (url, fileName) => {
|
||||
axiosApiInstance.get(url, { responseType: 'blob' })
|
||||
.then(response => {
|
||||
saveAs(response.data, fileName)
|
||||
})
|
||||
.then(response => {
|
||||
saveAs(response.data, fileName)
|
||||
})
|
||||
};
|
||||
|
||||
function openPDF(url) {
|
||||
|
||||
@@ -4,7 +4,10 @@
|
||||
<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" />
|
||||
<VuePdfEmbed v-if="schema.url.endsWith('.pdf')"
|
||||
:source="burl + schema.url"
|
||||
width="500"
|
||||
@click="openFirstPlan_opener(schema)"/>
|
||||
<v-img v-else
|
||||
class="cursor-pointer"
|
||||
:src="burl + schema.url"
|
||||
@@ -29,20 +32,31 @@
|
||||
<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-card-actions class="d-flex justify-space-between">
|
||||
<v-btn
|
||||
density="compact"
|
||||
variant="text"
|
||||
icon="mdi-close"
|
||||
@click="openFirstPlan = false">
|
||||
</v-btn>
|
||||
<v-btn class="d-flex align-center" icon='mdi-file-download-outline' color="green"
|
||||
@click="downloadFile(urlschema)">
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
<VuePdfEmbed v-if="urlschema.endsWith('.pdf')"
|
||||
:source="urlschema"
|
||||
width="500"
|
||||
@click="openFirstPlan = false"/>
|
||||
<v-img
|
||||
v-else
|
||||
:src="urlschema"
|
||||
class="cursor-pointer"
|
||||
height="100%"
|
||||
width="100%"
|
||||
@click="openFirstPlan = false">
|
||||
</v-img>
|
||||
</v-card>
|
||||
|
||||
</v-row>
|
||||
</v-dialog>
|
||||
</v-col>
|
||||
@@ -53,7 +67,9 @@
|
||||
<script setup>
|
||||
import { baseURL, axiosApiInstance } from '@/utils/axios-api'
|
||||
import { ref } from 'vue';
|
||||
|
||||
import VuePdfEmbed from 'vue-pdf-embed';
|
||||
import { saveAs } from 'file-saver';
|
||||
|
||||
defineProps(
|
||||
{
|
||||
@@ -62,23 +78,22 @@ defineProps(
|
||||
},
|
||||
)
|
||||
|
||||
const downloadFile = (url, fileName) => {
|
||||
axiosApiInstance.get(url, { responseType: 'blob' })
|
||||
.then(response => {
|
||||
saveAs(response.data, fileName)
|
||||
})
|
||||
};
|
||||
|
||||
const urlschema=ref(null)
|
||||
const burl = baseURL.slice(0,-1)
|
||||
const openFirstPlan = 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
|
||||
// })
|
||||
// }
|
||||
|
||||
// getResponsibility()
|
||||
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
Reference in new issue
Block a user