P-25
This commit is contained in:
1 parent
2b2eb3bcf3
commit
d1a69990fe
3 files changed
+85
-32
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')
|
||||||
|
|||||||
@@ -32,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">
|
||||||
@@ -48,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>
|
||||||
@@ -91,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">
|
||||||
@@ -107,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>
|
||||||
@@ -123,15 +117,17 @@
|
|||||||
</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>
|
<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-container>
|
</v-container>
|
||||||
<!-- <span v-else v-show="!showFile">
|
|
||||||
{{ err }}
|
|
||||||
</span> -->
|
|
||||||
<VuePdfEmbed
|
<VuePdfEmbed
|
||||||
|
|
||||||
v-show="showFile"
|
v-show="showFile"
|
||||||
@@ -140,7 +136,12 @@
|
|||||||
@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>
|
||||||
|
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
@@ -155,10 +156,11 @@
|
|||||||
</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: {
|
||||||
@@ -175,37 +177,59 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
const loading = ref(false);
|
const loading = ref(true);
|
||||||
const burl = baseURL.slice(0, -1);
|
const burl = baseURL.slice(0, -1);
|
||||||
const pdfSource = ref("");
|
const pdfSource = ref("");
|
||||||
|
|
||||||
const showFile = ref(true);
|
const showFile = ref(true);
|
||||||
const filId = ref(null);
|
const filId = ref(null);
|
||||||
const err = ref("");
|
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) => {
|
||||||
|
showFile.value=false
|
||||||
err.value = "Файл не найден";
|
err.value = "Файл не найден";
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
|
|
||||||
@@ -218,9 +242,26 @@ export default {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const firstFile = () => {
|
const firstFile = () => {
|
||||||
pdfSource.value =
|
loading.value = false;
|
||||||
burl + props.docSections.type_comm[0].comm.comitee_files[0].file_name;
|
let files = []
|
||||||
filId.value = props.docSections.type_comm[0].comm.comitee_files[0].id;
|
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, "-------------------------------");
|
console.log(pdfSource.value, "-------------------------------");
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -241,6 +282,11 @@ export default {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 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">
|
||||||
@@ -115,7 +115,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