|
@@ -0,0 +1,137 @@
|
|
|
+<template>
|
|
|
+ <div style="position:relative; height: 100%;padding-bottom: 73px;">
|
|
|
+ <div style="position: relative;min-height:70vh;height: 100%">
|
|
|
+ <el-affix :offset="300" style="width: 100%;">
|
|
|
+ <div style="position: absolute;">
|
|
|
+ <el-button type="primary" icon="DArrowLeft" :disabled="ccindex<=0" @click="fileindexlook(ccindex-1)"></el-button>
|
|
|
+ </div>
|
|
|
+ <div style="float: right;">
|
|
|
+ <el-button type="primary" icon="DArrowRight" :disabled="ccindex+1>=filelist.length" @click="fileindexlook(ccindex+1)"></el-button>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <el-button
|
|
|
+ v-if="currentfile!=null && (currentfile.fileSuffix+'').indexOf('pdf')==-1 && isdownload != 0"
|
|
|
+ type="primary"
|
|
|
+ style="position:absolute;right: 10px;top: -44vh;z-index: 11"
|
|
|
+ @click="printfile(currentfile)"
|
|
|
+ >打印</el-button
|
|
|
+ >
|
|
|
+ </el-affix>
|
|
|
+ <pdfview
|
|
|
+ v-if="currentfile!=null"
|
|
|
+ :src="currentfile.url"
|
|
|
+ :ispic="(currentfile.fileSuffix+'').indexOf('pdf')==-1"
|
|
|
+ :isprint="isdownload"
|
|
|
+ :size="currentfile.size"
|
|
|
+ ></pdfview>
|
|
|
+
|
|
|
+ <div v-if="isdownload != 1" style="position:absolute;right: 0px;top: 0px;z-index: 11;width:120px;height: 50px;background: #323639"></div>
|
|
|
+ </div>
|
|
|
+ <!-- <div><el-affix :offset="120" position="bottom"><el-button type="text" icon="DArrowRight"></el-button></el-affix></div>
|
|
|
+ </div> -->
|
|
|
+ <div class="dialog-footer">
|
|
|
+ <el-button @click="close">关闭</el-button>
|
|
|
+
|
|
|
+ <el-button v-if="isdownload != 0" type="primary" @click="downloadfile(currentfile)"> 下载 </el-button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+<script lang="ts" setup>
|
|
|
+import pdfview from "@/components/pdfview/index.vue"
|
|
|
+import {ElLoading} from "element-plus";
|
|
|
+import {listByIds} from "@/api/system/oss";
|
|
|
+import printJS from "print-js";
|
|
|
+import {layer} from "@layui/layer-vue";
|
|
|
+const ccindex = ref(0);
|
|
|
+const currentfile = ref<any>(null);
|
|
|
+const filelist = ref([]);
|
|
|
+const isdownload = ref(0);
|
|
|
+
|
|
|
+const route = useRoute();
|
|
|
+
|
|
|
+const close=()=>{
|
|
|
+ if(currentid.value){
|
|
|
+ layer.close(currentid.value)
|
|
|
+ parent.layer.close(currentid.value)
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+const printfile = (file:any)=>{
|
|
|
+ listByIds(file.ossId).then((res) => {
|
|
|
+ printJS({
|
|
|
+ printable: [
|
|
|
+ res.data[0].url
|
|
|
+ ],
|
|
|
+ type: "image",
|
|
|
+ header: "",
|
|
|
+ imageStyle: "width:100%;height:100%; margin-bottom:0px;",
|
|
|
+ });
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+const downloadfile = (file:any)=>{
|
|
|
+
|
|
|
+ const loadingInstance1 = ElLoading.service({ fullscreen: true,text:"下载中..." })
|
|
|
+ // currentfile.value = file;
|
|
|
+ listByIds(file.ossId).then((res) => {
|
|
|
+ fetch(res.data[0].url)
|
|
|
+ .then(response => response.blob())
|
|
|
+ .then(blob => {
|
|
|
+ loadingInstance1.close();
|
|
|
+ const link = document.createElement('a');
|
|
|
+ link.href = URL.createObjectURL(blob);
|
|
|
+ link.download = file.originalName;
|
|
|
+ link.target = "_blank"; // 可选,如果希望在新窗口中下载文件,请取消注释此行
|
|
|
+ link.click();
|
|
|
+ });
|
|
|
+ // window.open( res.data[0].url);
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+const fileindexlook = (index:number)=>{
|
|
|
+ var item = filelist.value[index]
|
|
|
+ filepreview(item);
|
|
|
+}
|
|
|
+
|
|
|
+const filepreview = (file:any) => {
|
|
|
+ ccindex.value = filelist.value.indexOf(file)
|
|
|
+ currentfile.value = file;
|
|
|
+ listByIds(file.ossId).then((res) => {
|
|
|
+ currentfile.value.url = res.data[0].url;
|
|
|
+ parent.document.getElementsByClassName("layui-layer")[currentid.value].getElementsByClassName("layui-layer-title")[0].innerHTML = currentfile.value.originalName;
|
|
|
+ });
|
|
|
+}
|
|
|
+const currentid = ref<string|null>("");
|
|
|
+
|
|
|
+onMounted(()=>{
|
|
|
+ if(route.query&&route.query.isdownload){
|
|
|
+
|
|
|
+ isdownload.value = parseInt(route.query.isdownload+"");
|
|
|
+ try{
|
|
|
+ currentid.value = localStorage.getItem(route.query.current+"");
|
|
|
+ localStorage.removeItem(route.query.current+"")
|
|
|
+ }catch (e){ /* empty */ }
|
|
|
+ }
|
|
|
+ let index = localStorage.getItem("ccindex");
|
|
|
+ if(index){
|
|
|
+ ccindex.value = parseInt(index)
|
|
|
+ }
|
|
|
+ let currentfiles = localStorage.getItem("currentfile");
|
|
|
+ if(currentfiles){
|
|
|
+ currentfile.value = JSON.parse(currentfiles)
|
|
|
+ }
|
|
|
+ let filelists = localStorage.getItem("filelist");
|
|
|
+ if(filelists){
|
|
|
+ filelist.value = JSON.parse(filelists);
|
|
|
+ }
|
|
|
+
|
|
|
+})
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.dialog-footer{
|
|
|
+ text-align: right;
|
|
|
+ padding: 20px;
|
|
|
+}
|
|
|
+</style>
|