Merge branch 'P-25' of http://sulaco.nodered.ru:5223/COD2/PORTAL_COD2 into P-25
This commit is contained in:
commit
4cd8f88a7e
4 files changed
+103
-46
No files matched your search
@@ -20,9 +20,13 @@ class SafetyTypeSerializer(serializers.ModelSerializer):
|
|||||||
|
|
||||||
|
|
||||||
class Committee1FilesSerializer(serializers.ModelSerializer):
|
class Committee1FilesSerializer(serializers.ModelSerializer):
|
||||||
|
typeoffile = serializers.SerializerMethodField('typeoffiledef', read_only=True)
|
||||||
|
parent = serializers.IntegerField(source = 'id_committee1.id')
|
||||||
|
def typeoffiledef(self,obj):
|
||||||
|
return 'comm'
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Committee1Files
|
model = Committee1Files
|
||||||
fields = ['id','file_name','is_actual']
|
fields = ['id','file_name','is_actual', 'typeoffile','parent']
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -63,10 +67,13 @@ class Commettee1Serializer(serializers.ModelSerializer):
|
|||||||
|
|
||||||
|
|
||||||
class OrderResponsibilityFilesSerializer(serializers.ModelSerializer):
|
class OrderResponsibilityFilesSerializer(serializers.ModelSerializer):
|
||||||
|
typeoffile = serializers.SerializerMethodField('typeoffiledef', read_only=True)
|
||||||
|
parent = serializers.IntegerField(source = 'id_order_responsibility.id')
|
||||||
|
def typeoffiledef(self,obj):
|
||||||
|
return 'resp'
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Committee1Files
|
model = Committee1Files
|
||||||
fields = ['id','file_name','is_actual']
|
fields = ['id','file_name','is_actual','typeoffile','parent']
|
||||||
|
|
||||||
class OrderResponsibilitySerializer(serializers.ModelSerializer):
|
class OrderResponsibilitySerializer(serializers.ModelSerializer):
|
||||||
employee = serializers.SerializerMethodField('get_respons')
|
employee = serializers.SerializerMethodField('get_respons')
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
></MainInfoSafety>
|
></MainInfoSafety>
|
||||||
</v-window-item>
|
</v-window-item>
|
||||||
<v-window-item class="gap h-100" value="document">
|
<v-window-item class="gap h-100" value="document">
|
||||||
<documentation-safety />
|
<documentation-safety :docSections = "safetyData" />
|
||||||
</v-window-item>
|
</v-window-item>
|
||||||
<v-window-item class="gap h-100" value="testings">
|
<v-window-item class="gap h-100" value="testings">
|
||||||
<TestSafety></TestSafety>
|
<TestSafety></TestSafety>
|
||||||
|
|||||||
@@ -1,10 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<v-row
|
<v-row no-gutters class="h-100 gap">
|
||||||
no-gutters
|
|
||||||
class="h-100 gap"
|
|
||||||
|
|
||||||
>
|
|
||||||
<!-- v-if="Object.keys(docSections).length > 0" -->
|
|
||||||
<v-col class="d-flex">
|
<v-col class="d-flex">
|
||||||
<v-row no-gutters class="flex-column gap">
|
<v-row no-gutters class="flex-column gap">
|
||||||
<v-col lg="6" class="w100 d-flex flex-column">
|
<v-col lg="6" class="w100 d-flex flex-column">
|
||||||
@@ -37,7 +32,7 @@
|
|||||||
color="primary"
|
color="primary"
|
||||||
density="compact"
|
density="compact"
|
||||||
@click="
|
@click="
|
||||||
openPDF(file.file_name, file.id), (loading = true)
|
openPDF(file)
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
<span class="text-body-2 text-wrap">
|
<span class="text-body-2 text-wrap">
|
||||||
@@ -53,10 +48,7 @@
|
|||||||
<v-icon
|
<v-icon
|
||||||
icon="mdi-file-download-outline"
|
icon="mdi-file-download-outline"
|
||||||
@click="
|
@click="
|
||||||
downloadItem(
|
downloadItem(file)
|
||||||
burl + file.file_name,
|
|
||||||
get_name(decodeURI(file.file_name))
|
|
||||||
)
|
|
||||||
"
|
"
|
||||||
/></v-col>
|
/></v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
@@ -96,7 +88,7 @@
|
|||||||
color="primary"
|
color="primary"
|
||||||
density="compact"
|
density="compact"
|
||||||
@click="
|
@click="
|
||||||
openPDF(file.file_name, file.id), (loading = true)
|
openPDF(file)
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
<span class="text-body-2 text-wrap">
|
<span class="text-body-2 text-wrap">
|
||||||
@@ -112,10 +104,7 @@
|
|||||||
<v-icon
|
<v-icon
|
||||||
icon="mdi-file-download-outline"
|
icon="mdi-file-download-outline"
|
||||||
@click="
|
@click="
|
||||||
downloadItem(
|
downloadItem(file)
|
||||||
burl + file.file_name,
|
|
||||||
get_name(decodeURI(file.file_name))
|
|
||||||
)
|
|
||||||
"
|
"
|
||||||
/></v-col>
|
/></v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
@@ -127,29 +116,36 @@
|
|||||||
</v-row>
|
</v-row>
|
||||||
</v-col>
|
</v-col>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<v-col class="d-flex flex-column">
|
<v-col class="d-flex flex-column">
|
||||||
|
|
||||||
<v-card class="flex-column h-100 d-flex rounded-0">
|
<v-card class="flex-column h-100 d-flex rounded-0">
|
||||||
<v-row no-gutters class="h-0 overflow-auto">
|
<v-row no-gutters class="h-0 overflow-auto">
|
||||||
<v-col class="align-self-center text-center">
|
<v-col class="d-flex flex-column "
|
||||||
|
:class="!loading?'align-center align-self-center':''">
|
||||||
|
|
||||||
<v-container v-if="loading">
|
<v-container v-if="loading">
|
||||||
<v-progress-linear :rounded="5" indeterminate color="teal">
|
<v-progress-linear :rounded="5" indeterminate color="teal" />
|
||||||
</v-progress-linear>
|
|
||||||
</v-container>
|
</v-container>
|
||||||
|
|
||||||
|
|
||||||
<VuePdfEmbed
|
<VuePdfEmbed
|
||||||
|
|
||||||
v-show="showFile"
|
v-show="showFile"
|
||||||
:source="pdfSource"
|
:source="pdfSource"
|
||||||
width="720"
|
width="720"
|
||||||
@rendered="loading = false"
|
@rendered="loading = false"
|
||||||
@loading-failed="handlePdfError"
|
@loading-failed="handlePdfError"
|
||||||
/>
|
/>
|
||||||
|
<v-card-text v-show="!showFile" >
|
||||||
|
<span class="text-h5 text-grey"
|
||||||
|
>
|
||||||
|
{{ err }}
|
||||||
|
</span>
|
||||||
|
</v-card-text>
|
||||||
|
|
||||||
{{err}}
|
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
|
|
||||||
|
|
||||||
<v-divider />
|
<v-divider />
|
||||||
<v-card-actions v-show="showFile">
|
<v-card-actions v-show="showFile">
|
||||||
<v-btn position="sticky" block @click="closeFile">Закрыть</v-btn>
|
<v-btn position="sticky" block @click="closeFile">Закрыть</v-btn>
|
||||||
@@ -157,14 +153,14 @@
|
|||||||
</v-card>
|
</v-card>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
<!-- <v-row v-else>{{ Object.keys(docSections).length > 0 }}</v-row> -->
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { ref } from "vue";
|
import { ref, computed } from "vue";
|
||||||
import { axiosApiInstance, baseURL } from "@/utils/axios-api";
|
import { axiosApiInstance, baseURL, spravURLBase } 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";
|
||||||
|
import { triggerRef } from "vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
@@ -180,40 +176,62 @@ export default {
|
|||||||
VuePdfEmbed,
|
VuePdfEmbed,
|
||||||
},
|
},
|
||||||
|
|
||||||
setup() {
|
setup(props, { emit }) {
|
||||||
const loading = ref(false);
|
const loading = ref(true);
|
||||||
|
const burl = baseURL.slice(0, -1);
|
||||||
const pdfSource = ref("");
|
const pdfSource = ref("");
|
||||||
|
|
||||||
const burl = baseURL.slice(0, -1);
|
const showFile = ref(true);
|
||||||
const showFile = ref(false);
|
|
||||||
const filId = ref(null);
|
const filId = ref(null);
|
||||||
const err = ref('s')
|
const err = ref("Файл не выбран");
|
||||||
|
|
||||||
const downloadItem = (url, fileName) => {
|
const downloadItem = (file) => {
|
||||||
|
|
||||||
|
let url = development.value ? burl + file.file_name : spravURLBase + `files/${file.typeoffile == 'comm' ? 'committee1_docs' : 'order_responsibility_docs'}/${file.parent}/${file.name}`
|
||||||
|
console.log(burl + file.file_name);
|
||||||
axiosApiInstance.get(url, { responseType: "blob" }).then((response) => {
|
axiosApiInstance.get(url, { responseType: "blob" }).then((response) => {
|
||||||
saveAs(response.data, fileName);
|
saveAs(response.data, get_name(decodeURI(file.file_name)));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const openPDF = (url, id) => {
|
const openPDF = (file) => {
|
||||||
pdfSource.value = burl + url;
|
console.log(file, "fil");
|
||||||
|
|
||||||
|
|
||||||
|
let source =development.value ? burl + file.file_name : spravURLBase + `files/${file.typeoffile == 'comm' ? 'committee1_docs' : 'order_responsibility_docs'}/${file.parent}/${file.name}`
|
||||||
|
if(source!=pdfSource.value){
|
||||||
|
loading.value = true
|
||||||
|
pdfSource.value = source
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
showFile.value = true;
|
showFile.value = true;
|
||||||
filId.value = id;
|
filId.value = file.id;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const development = computed({
|
||||||
|
get() {
|
||||||
|
return process.env.NODE_ENV == "development" ? true : false;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// process.env.NODE_ENV == "development" ? true : false;
|
||||||
|
|
||||||
const get_name = (namestr) => {
|
const get_name = (namestr) => {
|
||||||
let arr = namestr.split("/");
|
let arr = namestr.split("/");
|
||||||
return arr[arr.length - 1];
|
return arr[arr.length - 1];
|
||||||
};
|
};
|
||||||
|
|
||||||
const closeFile = () => {
|
const closeFile = () => {
|
||||||
|
err.value = "Файл не выбран"
|
||||||
showFile.value = false;
|
showFile.value = false;
|
||||||
filId.value = null;
|
filId.value = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
const handlePdfError = (error) => {
|
const handlePdfError = (error) => {
|
||||||
err.value = "Файл не найден"
|
showFile.value=false
|
||||||
loading.value = false
|
err.value = "Файл не найден";
|
||||||
|
loading.value = false;
|
||||||
|
|
||||||
// if (error.status === 404) {
|
// if (error.status === 404) {
|
||||||
// console.error('PDF file not found');
|
// console.error('PDF file not found');
|
||||||
@@ -221,7 +239,33 @@ export default {
|
|||||||
// } else {
|
// } else {
|
||||||
// console.error('An error occurred while loading the PDF:', error);
|
// console.error('An error occurred while loading the PDF:', error);
|
||||||
// }
|
// }
|
||||||
}
|
};
|
||||||
|
|
||||||
|
const firstFile = () => {
|
||||||
|
loading.value = false;
|
||||||
|
let files = []
|
||||||
|
props.docSections.type_comm.forEach(el => {
|
||||||
|
// console.log(el);
|
||||||
|
files.push(...el.comm.comitee_files)
|
||||||
|
});
|
||||||
|
|
||||||
|
props.docSections.type_resp.forEach(el => {
|
||||||
|
files.push(...el.resp.get_resp_files)
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
pdfSource.value =development.value ? burl + files[0].file_name : spravURLBase + `files/${files[0].typeoffile == 'comm' ? 'committee1_docs' : 'order_responsibility_docs'}/${files[0].parent}/${files[0].name}`
|
||||||
|
|
||||||
|
// = source
|
||||||
|
|
||||||
|
// pdfSource.value =
|
||||||
|
// burl + files[0].file_name;
|
||||||
|
filId.value = files[0].id;
|
||||||
|
console.log(pdfSource.value, "-------------------------------");
|
||||||
|
};
|
||||||
|
|
||||||
|
firstFile();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
downloadItem,
|
downloadItem,
|
||||||
@@ -234,10 +278,15 @@ export default {
|
|||||||
burl,
|
burl,
|
||||||
showFile,
|
showFile,
|
||||||
closeFile,
|
closeFile,
|
||||||
err
|
err,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// http://10.252.44.33/accounting6/index.php?controller=OrderResponsibility&action=DownloadFile&fld_file=222&fld_order_responsibility=11
|
||||||
|
// http://10.252.44.33/accounting6/index.php?controller=Committee&action=DownloadFile&fld_file=412&fld_committee=29
|
||||||
|
// \\10.252.44.33\Webserver\data\htdocs\accounting6\files\committee1_docs\2
|
||||||
|
// \\10.252.44.33\Webserver\data\htdocs\accounting6\files\order_responsibility_docs\12
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style></style>
|
<style></style>
|
||||||
@@ -87,7 +87,7 @@
|
|||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
|
|
||||||
<!-- <v-dialog v-model="openFirstPlan" :width="900" height="100%">
|
<v-dialog v-model="openFirstPlan" :width="900" height="100%">
|
||||||
<v-row class="ma-0 overflow-auto h-0">
|
<v-row class="ma-0 overflow-auto h-0">
|
||||||
<v-card class="h-100 w-100 pa-0">
|
<v-card class="h-100 w-100 pa-0">
|
||||||
<v-card-actions class="d-flex justify-space-between">
|
<v-card-actions class="d-flex justify-space-between">
|
||||||
@@ -101,6 +101,7 @@
|
|||||||
@click="downloadFile(urlschema)">
|
@click="downloadFile(urlschema)">
|
||||||
</v-btn>
|
</v-btn>
|
||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
|
|
||||||
<VuePdfEmbed v-if="urlschema.endsWith('.pdf')"
|
<VuePdfEmbed v-if="urlschema.endsWith('.pdf')"
|
||||||
:source="urlschema"
|
:source="urlschema"
|
||||||
width="500"
|
width="500"
|
||||||
@@ -115,7 +116,7 @@
|
|||||||
</v-img>
|
</v-img>
|
||||||
</v-card>
|
</v-card>
|
||||||
</v-row>
|
</v-row>
|
||||||
</v-dialog> -->
|
</v-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
|||||||
Reference in new issue
Block a user