Browse Source

`文件删除、下载`

wenhongquan 1 year ago
parent
commit
5a193b8229

+ 2 - 1
package.json

@@ -24,9 +24,10 @@
     "animate.css": "4.1.1",
     "await-to-js": "^3.0.0",
     "axios": "^1.3.4",
+    "base-64": "^1.0.0",
     "crypto-js": "^4.1.1",
     "echarts": "5.4.0",
-    "element-plus": "2.2.27",
+    "element-plus": "2.5.0",
     "file-saver": "2.0.5",
     "fuse.js": "6.6.2",
     "js-cookie": "3.0.1",

+ 2 - 2
src/api/system/oss/index.ts

@@ -12,9 +12,9 @@ export function listOss(query: OssQuery): AxiosPromise<OssVO[]> {
 }
 
 // 查询OSS对象基于id串
-export function listByIds(ossId: string | number): AxiosPromise<OssVO[]> {
+export function listByIds(ossId: string | number, type = 1): AxiosPromise<OssVO[]> {
   return request({
-    url: '/resource/oss/listByIds/' + ossId,
+    url: '/resource/oss/listByIds/' + ossId + '?type=' + type,
     method: 'get'
   });
 }

+ 26 - 13
src/components/pdfview/index.vue

@@ -1,39 +1,52 @@
 <template>
-  <div v-for="page in pages" :key="page" style="width: 100%;">
+  <div style="width: 100%;height:100%;position:absolute">
+    <!-- <el-watermark :font="font" :content="content" style="width: 100%;height:100%;position:absolute"> -->
+      <iframe style="width:100%;height:100%;border:none" :src="`${currentPdf}`" />
+    <!-- </el-watermark> -->
+  </div>
+  <!-- <div v-for="page in pages" :key="page" style="width: 100%;">
     <VuePDF :pdf="pdf" fit-parent :watermark-text="watermarkText" :watermark-options="watermarkOptions" :page="page">
       <div v-loading="true"></div>
     </VuePDF>
-  </div>
+  </div> -->
 </template>
 <script lang="ts" setup>
 import {ref, onMounted, watchEffect} from 'vue'
-import { VuePDF, usePDF } from '@tato30/vue-pdf'
+// import { VuePDF, usePDF } from '@tato30/vue-pdf'
 import { propTypes } from '@/utils/propTypes';
+import base64 from 'base-64';
 
 const props = defineProps({
   src: propTypes.string.def(''),
 });
+const content = ref(["text"])
+
+const font = ref({
+  color: 'rgba(0, 0, 0, .15)',
+})
 
 
 const currentPdf = ref(props.src)
 watchEffect(() => {
-  currentPdf.value = props.src;
+
+  //http://127.0.0.1:8012/onlinePreview?url='+encodeURIComponent(base64Encode(url))
+  currentPdf.value = `http://127.0.0.1:8012/onlinePreview?url=${encodeURIComponent(base64.encode(props.src))}&watermarkTxt=${encodeURIComponent('动态水印')}`;
 
   // currentPdf.value = props.src.replaceAll("https://njdnyjsfilesystem.s3.cn-east-1.qiniucs.com","http://sdrqczwd3.hd-bkt.clouddn.com");
 })
 
 
 
-const { pdf, pages } = usePDF(currentPdf)
+// const { pdf, pages } = usePDF(currentPdf)
 
-const watermarkOptions = ref({
-   columns: 4,
-  rows: 10,
-  color: 'rgba(211, 210, 211, 0.8)',
-  rotation: 45,
-  fontSize: 18,
-});
-const watermarkText = ref('sample')
+// const watermarkOptions = ref({
+//    columns: 4,
+//   rows: 10,
+//   color: 'rgba(211, 210, 211, 0.8)',
+//   rotation: 45,
+//   fontSize: 18,
+// });
+// const watermarkText = ref('sample')
 </script>
 
 <style lang="scss" scoped></style>

+ 4 - 3
src/views/file/list/index.vue

@@ -120,7 +120,7 @@
     <el-dialog v-model="pdfviewshow" :title="`文件预览`" width="60vw" >
 
 
-        <div style="position: relative;min-height: 80vh;">
+        <div style="position: relative;min-height:70vh;">
            <el-affix :offset="400" style="width: 100%;">
               <div style="position: absolute;">
                  <el-button type="primary" icon="DArrowLeft" :disabled="ccindex<=0" @click="fileindexlook(ccindex-1)"></el-button>
@@ -152,7 +152,8 @@
 </template>
 
 <script lang="ts" setup>
-import { ref,onMounted } from "vue";
+import { ref, onMounted } from "vue";
+const { proxy } = getCurrentInstance() as ComponentInternalInstance;
 import {
   listByIds,
   listArchivesFileList,
@@ -218,7 +219,7 @@ const filepreview = (file) => {
 
 }
 const downloadfile = (file) => {
-
+     proxy?.$download.oss(file.ossId)
  }
 
 

+ 20 - 5
src/views/project/list/index.vue

@@ -207,7 +207,7 @@
     <el-dialog v-model="pdfviewshow" :title="`文件预览`" width="60vw" >
 
 
-        <div style="position: relative;">
+        <div style="position: relative;min-height:78vh">
            <el-affix :offset="400" style="width: 100%;">
                <div style="position: absolute;">
                  <el-button type="primary" icon="DArrowLeft" :disabled="ccindex<=0" @click="fileindexlook(ccindex-1)"></el-button>
@@ -228,7 +228,7 @@
         <div class="dialog-footer">
           <el-button @click="pdfviewshow = false">关闭</el-button>
 
-          <el-button type="primary" @click="downloadfile">
+          <el-button type="primary" @click="downloadfile(currentfile)">
             下载
           </el-button>
         </div>
@@ -338,9 +338,9 @@
         <el-table-column prop="date" label="操作" >
           <template #default="scope">
              <div style="display: flex;gap:5px">
-               <div> <el-button type="text" >删除</el-button></div>
+               <div> <el-button type="text" @click="filedel(scope.row)">删除</el-button></div>
                <div> <el-button type="text" @click="filepreview(scope.row)" >预览</el-button></div>
-               <div> <el-button type="text" >下载</el-button></div>
+               <div> <el-button type="text" @click="downloadfile(scope.row)">下载</el-button></div>
              </div>
 
           </template>
@@ -542,6 +542,21 @@ const deleteitem = (id: any) => {
 };
 
 
+const filedel = (item) => {
+  ElMessageBox.confirm('确定删除该文件?')
+    .then(() => {
+      delOss(item.ossId).then(res => {
+        ElMessage.success("删除成功");
+        setTimeout(() => {
+           getArchive_files(currentitem.value.id).then((res1) => {
+          filelist.value = res1.data
+        });
+        }, 1000);
+
+      })
+    });
+}
+
 const lookfiles = (item) => {
   currentitem.value = item;
   drawer.value = true;
@@ -610,7 +625,7 @@ const filepreview = (file) => {
   });
 }
 const downloadfile = (file) => {
-
+   proxy?.$download.oss(file.ossId)
 }