wenhongquan 1 year ago
parent
commit
5ebeb40cbe

+ 1 - 1
package.json

@@ -21,7 +21,6 @@
     "@tato30/vue-pdf": "^1.10.0",
     "@vant/auto-import-resolver": "^1.2.1",
     "@vueup/vue-quill": "1.2.0",
-    "@vueuse/core": "9.5.0",
     "animate.css": "4.1.1",
     "await-to-js": "^3.0.0",
     "axios": "^1.3.4",
@@ -38,6 +37,7 @@
     "path-browserify": "1.0.1",
     "path-to-regexp": "6.2.0",
     "pinia": "2.0.22",
+    "print-js": "^1.6.0",
     "qiniu-js": "3.4.2",
     "screenfull": "6.0.0",
     "vant": "^4.9.1",

+ 8 - 2
src/components/pdfview/index.vue

@@ -1,7 +1,9 @@
 <template>
   <div style="width: 100%;height:100%;position:absolute">
     <el-watermark :font="font" :content="watertext" style="width: 100%;height:100%;position:absolute">
-      <iframe v-loading style="width:100%;height:100%;border:none" :src="`${currentPdf}`" />
+      <PicShow :src="props.src" v-if="props.ispic" />
+
+      <iframe v-loading style="width:100%;height:100%;border:none" v-if="!props.ispic" :src="`${currentPdf}`" />
       <!--      <div style="height: 100%;overflow-y: auto" v-if="!usepdf">-->
       <!--        &lt;!&ndash; <div v-for="page in pages" :key="page" style="width: 100%;">-->
       <!--          <VuePDF :pdf="pdf" fit-parent :watermark-text="watermarkText" :watermark-options="watermarkOptions" :page="page">-->
@@ -19,6 +21,8 @@ const { proxy } = getCurrentInstance() as ComponentInternalInstance;
 import { propTypes } from '@/utils/propTypes';
 import moment from 'moment';
 import useUserStore from '@/store/modules/user';
+import  PicShow from "./picShow.vue"
+
 
 const userStore = useUserStore();
 
@@ -33,6 +37,8 @@ const usepdf=ref(true);
 const props = defineProps({
   src: propTypes.string.def(''),
   size:propTypes.number.def(0),
+  ispic:propTypes.bool.def(false),
+  isprint:propTypes.number.def(0),
 });
 const content = ref(["text"])
 
@@ -53,7 +59,7 @@ watchEffect(() => {
   if (usepdf.value) {
     // if(props.size>1024*1024*20){
     // }else{
-      currentPdf.value = `https://filesystem.njdnyjs.com/preview?url=${encodeURIComponent(props.src)}`
+      currentPdf.value = `https://filesystem.njdnyjs.com/preview/?url=${encodeURIComponent(props.src)}&isprint=${props.isprint}`
     // }
     // currentPdf.value = `/preview/onlinePreview?url=${encodeURIComponent(base64.encode(props.src))}&watermarkTxt=${encodeURIComponent(watertext.value)}`;
     // currentPdf.value = `/preview/web/viewer.html?file=${encodeURIComponent(props.src)}`

+ 64 - 0
src/components/pdfview/picShow.vue

@@ -0,0 +1,64 @@
+<script lang="ts" setup>
+import {ref, computed} from 'vue'
+import {useMouseInElement} from '@vueuse/core'
+import {propTypes} from "@/utils/propTypes";
+
+
+const props = defineProps({
+  src: propTypes.string.def(''),
+});
+
+const zoom = ref(0.05)
+
+onMounted(()=>{
+  var c=document.getElementById("myCanvas");
+  var ctx=c.getContext("2d");
+  var img=document.getElementById("scream");
+  var img1=document.getElementById("scream2");
+  img1.onload = () => {
+    img.style.width=220;
+    img.style.height=img1.height*(img.style.width/img1.style.width);
+  };
+  img.addEventListener("mousemove", (e)=>{
+    // let zoom = 0.05;//相对原图的放大倍数
+    //计算放大后的位置 %
+    let x= e.offsetX/img.width;
+    let y= e.offsetY/img.height;
+    ctx.clearRect(0, 0, c.width, c.height);
+    ctx.drawImage(img,img1.width*x-img1.width*zoom.value/2,img1.height*y-img1.width*zoom.value/2,img1.width*zoom.value,img1.width*zoom.value,0,0,c.width, c.height);
+  })
+})
+
+
+
+</script>
+<template>
+  <div class="product-image">
+    <div style="display:flex;flex-direction: column;width: 220px">
+      <img id="scream" :src="props.src" width="220" />
+      <div>
+        <div>
+          <el-descriptions title="设置">
+            <el-descriptions-item label="放大倍数"> <el-input v-model="zoom" placeholder="请输入放大倍数" type="number" /></el-descriptions-item>
+          </el-descriptions>
+        </div>
+      </div>
+    </div>
+
+    <img id="scream2" :src="props.src" style="display: none;"/>
+    <canvas  id="myCanvas" width="600" height="600" style="border:1px solid #d3d3d3;margin-left: 10px">
+      您的浏览器不支持 HTML5 canvas 标签。</canvas>
+  </div>
+</template>
+
+<style lang="scss" scoped>
+.product-image{
+  display: flex;
+  width: 100%;
+  height: 100%;
+  align-items: flex-start;
+  justify-content: center;
+}
+
+</style>
+

+ 9 - 9
src/layout/index.vue

@@ -45,15 +45,15 @@ const { width } = useWindowSize();
 const WIDTH = 992; // refer to Bootstrap's responsive design
 
 watchEffect(() => {
-    if (device.value === 'mobile' && sidebar.value.opened) {
-        useAppStore().closeSideBar({ withoutAnimation: false })
-    }
-    if (width.value - 1 < WIDTH) {
-        useAppStore().toggleDevice('mobile')
-        useAppStore().closeSideBar({ withoutAnimation: true })
-    } else {
-        useAppStore().toggleDevice('desktop')
-    }
+    // if (device.value === 'mobile' && sidebar.value.opened) {
+    //     useAppStore().closeSideBar({ withoutAnimation: false })
+    // }
+    // if (width.value - 1 < WIDTH) {
+    //     useAppStore().toggleDevice('mobile')
+    //     useAppStore().closeSideBar({ withoutAnimation: true })
+    // } else {
+    //     useAppStore().toggleDevice('desktop')
+    // }
 })
 
 const navbarRef = ref(Navbar);

+ 19 - 2
src/views/file/list/index.vue

@@ -117,7 +117,7 @@
       </div>
     </div>
 
-    <el-dialog v-model="pdfviewshow" :title="`文件预览`" width="60vw">
+    <el-dialog v-model="pdfviewshow" :title="`文件预览`" width="90vw">
       <div style="position: relative; min-height: 70vh">
         <el-affix :offset="400" style="width: 100%">
           <div style="position: absolute">
@@ -137,7 +137,10 @@
             ></el-button>
           </div>
         </el-affix>
-        <pdfview :src="currentfile.url" :size="currentfile.size"></pdfview>
+        <pdfview :src="currentfile.url" :ispic="(currentfile.fileSuffix+'').indexOf('pdf')==-1" :size="currentfile.size"></pdfview>
+
+        <el-button v-hasPermi="['filemanager.project.file.download']" v-if="(currentfile.fileSuffix+'').indexOf('pdf')==-1" type="primary" style="position:absolute;right: 0;top: 0;z-index: 11" @click="printfile(currentfile)">打印</el-button>
+
       </div>
       <template #footer>
         <div class="dialog-footer">
@@ -216,6 +219,7 @@ import { getArchives } from "@/api/archives/index";
 
 import { list } from "@/api/monitor/operlog/index";
 import {ElLoading} from "element-plus";
+import printJS from "print-js";
 
 // const { proxy } = getCurrentInstance() as ComponentInternalInstance;
 // const { sys_area, sys_project_status } = toRefs<any>(
@@ -291,6 +295,19 @@ const downloadfile = (file) => {
   });
 };
 
+const printfile = (file)=>{
+  listByIds(file.ossId).then((res) => {
+    printJS({
+      printable: [
+        res.data[0].url
+      ],
+      type: "image",
+      header: "",
+      imageStyle: "width:100%;height:100%; margin-bottom:0px;",
+    });
+  });
+}
+
 
 const currentproject = ref({
   area: "",

+ 1 - 1
src/views/h5/filelist/index.vue

@@ -23,7 +23,7 @@
 
     <el-dialog v-model="pdfviewshow" :title="`文件预览`" width="90vw">
       <div style="position: relative;min-height:50vh">
-        <pdfview :src="currentfile.url" :size="currentfile.size"></pdfview>
+        <pdfview :src="currentfile.url" :ispic="(currentfile.fileSuffix+'').indexOf('pdf')==-1" :size="currentfile.size"></pdfview>
       </div>
       <!-- <div><el-affix :offset="120" position="bottom"><el-button type="text" icon="DArrowRight"></el-button></el-affix></div>
       </div> -->

+ 63 - 25
src/views/project/list/index.vue

@@ -1,7 +1,7 @@
 <!-- eslint-disable prettier/prettier -->
 <template>
   <div class="bodycontent">
-    <div class="sheard">
+    <div class="sheard1">
       <div class="searchheard">
         <div class="item">
           <div>区域:</div>
@@ -101,6 +101,7 @@
       </div>
     </div>
 
+
     <div>
       <el-table
         :data="tableData"
@@ -220,7 +221,7 @@
         />
       </div>
     </div>
-    <el-dialog v-model="pdfviewshow" :title="`文件预览`" width="60vw" >
+    <el-dialog v-model="pdfviewshow" :title="`文件预览`" width="90vw" >
 
 
         <div style="position: relative;min-height:70vh">
@@ -232,10 +233,9 @@
                  <el-button type="primary" icon="DArrowRight" :disabled="ccindex+1>=filelist.length" @click="fileindexlook(ccindex+1)"></el-button>
               </div>
            </el-affix>
-            <pdfview :src="currentfile.url" :size="currentfile.size"></pdfview>
-
-
+            <pdfview :src="currentfile.url" :ispic="(currentfile.fileSuffix+'').indexOf('pdf')==-1"  :isprint="hsp('filemanager.project.file.download')?1:0" :size="currentfile.size"></pdfview>
 
+            <el-button v-hasPermi="['filemanager.project.file.download']" v-if="(currentfile.fileSuffix+'').indexOf('pdf')==-1" type="primary" style="position:absolute;right: 0;top: 0;z-index: 11" @click="printfile(currentfile)">打印</el-button>
         </div>
         <!-- <div><el-affix :offset="120" position="bottom"><el-button type="text" icon="DArrowRight"></el-button></el-affix></div>
       </div> -->
@@ -365,7 +365,8 @@
           <template #default="scope">
             <div style="display: flex;">
                <img style="width: 25px;height:25px" :src="gettypeicon(scope.row.fileSuffix)"/>
-               <div>{{ scope.row.originalName }}</div>
+
+               <div><el-badge v-if="scope.row.isnew" value="新" style="position:absolute;right: 0;top:10px"></el-badge>{{ scope.row.originalName }}</div>
             </div>
           </template>
         </el-table-column>
@@ -410,6 +411,7 @@
       </template>
       </el-dialog>
   </div>
+
 </template>
 
 <script lang="ts" setup>
@@ -430,13 +432,22 @@ import {
   updateArchives,
   delArchives,
   getArchive_files,
-  saveArchive_files
+  saveArchive_files, getArchives
 } from "@/api/archives/index";
 import _ from "lodash";
 import {useRoute} from "vue-router";
 import useUserStore from "@/store/modules/user";
 import moment from "moment";
 import {ElLoading} from "element-plus";
+import auth from "@/plugins/auth";
+import printJS from "print-js";
+
+
+
+const hsp = (v:string)=>{
+  if(status.value=="0") return false;
+  return auth.hasPermi(v)
+}
 
 
 const userroles = useUserStore().roles;
@@ -453,7 +464,6 @@ var isnormal = false;
 
 const uploadbtnenable = ref(false);
 
-
 const searchForm = ref({
   area: "",
   qiuquan: "",
@@ -623,12 +633,12 @@ const updatecurrent = (id, status: number) => {
     id: id,
     status: status + "",
     ...(status == 4
-      ? { ext1: JSON.stringify({ projectreson: projectreson.value }) }
+      ? { ext1: JSON.stringify({ projectreson: projectreson.value }),ext2: "{}" }
       : {}),
   }).then((res) => {
     ElMessage.success("保存成功");
     shvisable.value = false;
-    getnextdata(1);
+    getnextdata(currentpage.value);
   });
 };
 
@@ -651,7 +661,7 @@ const tableRowClassName = ({ row, rowIndex }: { row: any; rowIndex: number }) =>
 const deleteitem = (id: any) => {
   delArchives(id).then((res) => {
     ElMessage.success("删除成功");
-    getnextdata(1);
+    getnextdata(currentpage.value);
   });
 };
 
@@ -662,9 +672,7 @@ const filedel = (item) => {
       delOss(item.ossId).then(res => {
         ElMessage.success("删除成功");
         setTimeout(() => {
-           getArchive_files(currentitem.value.id).then((res1) => {
-          filelist.value = res1.data
-        });
+           getfilelist()
         }, 1000);
 
       })
@@ -686,9 +694,7 @@ const deletefilebanch = () => {
         if (index == delindex) {
           ElMessage.success("删除成功");
              setTimeout(() => {
-           getArchive_files(currentitem.value.id).then((res1) => {
-          filelist.value = res1.data
-        });
+               getfilelist()
         }, 1000);
 
         }
@@ -699,14 +705,34 @@ const deletefilebanch = () => {
 }
 
 
+const getfilelist =()=>{
+  getArchives(currentitem.value.id).then(res1=>{
+    currentitem.value = res1.data;
+
+    getArchive_files(currentitem.value.id).then((res1) => {
+      if(currentitem.value.ext2!=null && currentitem.value.ext2!=undefined){
+        let filenewdata =  JSON.parse(currentitem.value.ext2);
+        if(filenewdata["newfile"]!=undefined){
+          res1.data= res1.data.map(i=>{
+            if(filenewdata["newfile"].indexOf(i.ossId)!=-1){
+              return {...i,isnew:true}
+            }else{
+              return {...i,isnew:false}
+            }
+          })
+        }
+      }
+      filelist.value = res1.data
+    });
+  })
+
+}
+
 const lookfiles = (item) => {
   currentitem.value = item;
   drawer.value = true;
   selectfiles.value = [];
-
-  getArchive_files(item.id).then((res) => {
-    filelist.value = res.data
-  });
+  getfilelist();
 };
 const showfileuplaod = ref(false);
 const uploadfilelist = ref("");
@@ -718,9 +744,7 @@ const saveuploadfiles = () => {
   saveArchive_files(currentitem.value.id, uploadfilelist.value).then(res => {
     ElMessage.success("保存成功");
     showfileuplaod.value = false;
-    getArchive_files(currentitem.value.id).then((res) => {
-    filelist.value = res.data
-  });
+    getfilelist()
   })
 }
 
@@ -794,6 +818,19 @@ const downloadfile = (file) => {
   });
 }
 
+const printfile = (file)=>{
+  listByIds(file.ossId).then((res) => {
+    printJS({
+      printable: [
+        res.data[0].url
+      ],
+      type: "image",
+      header: "",
+      imageStyle: "width:100%;height:100%; margin-bottom:0px;",
+    });
+  });
+}
+
 
 
 
@@ -830,7 +867,7 @@ const gettypeicon = (type) => {
 <style type="scss" scoped>
 .bodycontent {
   padding: 10px 15px;
-  .sheard {
+  .sheard1 {
     position: relative;
     padding: 10px 0px;
     .searchheard {
@@ -865,4 +902,5 @@ const gettypeicon = (type) => {
 .el-table .danger-row {
   --el-table-tr-bg-color: var(--el-color-danger-light-9);
 }
+
 </style>

+ 2 - 2
vite.config.ts

@@ -26,8 +26,8 @@ export default defineConfig(({ mode, command }: ConfigEnv): UserConfig => {
       open: true,
       proxy: {
         [env.VITE_APP_BASE_API]: {
-          target: 'http://localhost:8080',
-          // target: 'https://filesystem.njdnyjs.com/api',
+          // target: 'http://localhost:8080',
+          target: 'https://filesystem.njdnyjs.com/api',
           changeOrigin: true,
           ws: true,
           rewrite: (path) => path.replace(new RegExp('^' + env.VITE_APP_BASE_API), '')