This commit is contained in:
Alex committed 2024-05-22 12:10:28 +03:00
1 parent 2b2eb3bcf3
commit d1a69990fe
3 files changed
+85 -32

No files matched your search

@@ -32,7 +32,7 @@
color="primary"
density="compact"
@click="
openPDF(file.file_name, file.id), (loading = true)
openPDF(file)
"
>
<span class="text-body-2 text-wrap">
@@ -48,10 +48,7 @@
<v-icon
icon="mdi-file-download-outline"
@click="
downloadItem(
burl + file.file_name,
get_name(decodeURI(file.file_name))
)
downloadItem(file)
"
/></v-col>
</v-row>
@@ -91,7 +88,7 @@
color="primary"
density="compact"
@click="
openPDF(file.file_name, file.id), (loading = true)
openPDF(file)
"
>
<span class="text-body-2 text-wrap">
@@ -107,10 +104,7 @@
<v-icon
icon="mdi-file-download-outline"
@click="
downloadItem(
burl + file.file_name,
get_name(decodeURI(file.file_name))
)
downloadItem(file)
"
/></v-col>
</v-row>
@@ -123,15 +117,17 @@
</v-col>
<v-col class="d-flex flex-column">
<v-card class="flex-column h-100 d-flex rounded-0">
<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-progress-linear :rounded="5" indeterminate color="teal" />
</v-container>
<!-- <span v-else v-show="!showFile">
{{ err }}
</span> -->
<VuePdfEmbed
v-show="showFile"
@@ -140,7 +136,12 @@
@rendered="loading = false"
@loading-failed="handlePdfError"
/>
<v-card-text v-show="!showFile" >
<span class="text-h5 text-grey"
>
{{ err }}
</span>
</v-card-text>
</v-col>
</v-row>
@@ -155,10 +156,11 @@
</template>
<script>
import { ref } from "vue";
import { axiosApiInstance, baseURL } from "@/utils/axios-api";
import { ref, computed } from "vue";
import { axiosApiInstance, baseURL, spravURLBase } from "@/utils/axios-api";
import { saveAs } from "file-saver";
import VuePdfEmbed from "vue-pdf-embed";
import { triggerRef } from "vue";
export default {
props: {
@@ -175,37 +177,59 @@ export default {
},
setup(props, { emit }) {
const loading = ref(false);
const loading = ref(true);
const burl = baseURL.slice(0, -1);
const pdfSource = ref("");
const showFile = ref(true);
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) => {
saveAs(response.data, fileName);
saveAs(response.data, get_name(decodeURI(file.file_name)));
});
};
const openPDF = (url, id) => {
pdfSource.value = burl + url;
const openPDF = (file) => {
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;
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) => {
let arr = namestr.split("/");
return arr[arr.length - 1];
};
const closeFile = () => {
err.value = "Файл не выбран"
showFile.value = false;
filId.value = null;
};
const handlePdfError = (error) => {
showFile.value=false
err.value = "Файл не найден";
loading.value = false;
@@ -218,9 +242,26 @@ export default {
};
const firstFile = () => {
pdfSource.value =
burl + props.docSections.type_comm[0].comm.comitee_files[0].file_name;
filId.value = props.docSections.type_comm[0].comm.comitee_files[0].id;
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, "-------------------------------");
};
@@ -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>
<style></style>
@@ -87,7 +87,7 @@
</v-col>
</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-card class="h-100 w-100 pa-0">
<v-card-actions class="d-flex justify-space-between">
@@ -115,7 +115,7 @@
</v-img>
</v-card>
</v-row>
</v-dialog> -->
</v-dialog>
</template>
<script setup>