lizhenhao 3 年 前
コミット
df3cec02d4
2 ファイル変更41 行追加1 行削除
  1. 14 0
      src/api/sys/OSSService.js
  2. 27 1
      src/views/modules/sys/project/AssessForm.vue

+ 14 - 0
src/api/sys/OSSService.js

@@ -17,6 +17,20 @@ export default class OSSSerive {
       params: {attachmentId: attachmentId}
     })
   }
+  getTemporaryUrl (url) {
+    return request({
+      url: '/oss/file/getTemporaryUrl',
+      method: 'get',
+      params: {url: url}
+    })
+  }
+  deleteMsgById (id) {
+    return request({
+      url: '/oss/file/deleteMsgById',
+      method: 'get',
+      params: {id: id}
+    })
+  }
 }
 
 export const client = new OSS({

+ 27 - 1
src/views/modules/sys/project/AssessForm.vue

@@ -345,6 +345,10 @@
 
         </el-row>
       </el-form>
+      <el-image-viewer
+        v-if="showViewer"
+        :on-close="closeViewer"
+        :url-list="[url]" />
       <span slot="footer" class="dialog-footer">
       <el-button size="small" @click="close()" icon="el-icon-circle-close">关闭</el-button>
       <el-button size="small" type="primary" v-if="method != 'view'" @click="doSubmit()" icon="el-icon-circle-check" v-noMoreClick>确定</el-button>
@@ -414,7 +418,9 @@
         },
         filesArra2: [],
         fileList: [],
-        isFlag: true
+        isFlag: true,
+        showViewer: false, // 显示查看器
+        url: ''
       }
     },
     projectService: null,
@@ -424,6 +430,15 @@
       this.projectService = new ProjectService()
     },
     methods: {
+      onPreview (url) {
+        this.url = url
+        this.showViewer = true
+      },
+      // 关闭查看器
+      closeViewer () {
+        this.url = ''
+        this.showViewer = false
+      },
       init (method, id) {
         this.ossService.findFileList(id).then(({data}) => {
           data.forEach((item) => {
@@ -560,6 +575,17 @@
       },
       showFile (row) {
         let suffix = row.name.substring(row.name.lastIndexOf('.') + 1)
+        if (suffix === 'jpg' || suffix === 'png' || suffix === 'gif' || suffix === 'bmp' || suffix === 'jpeg') {
+          if (row.url !== null && row.url !== undefined && row.url !== '') {
+            this.onPreview(row.url)
+            return
+          } else {
+            this.ossService.getTemporaryUrl(row.raw.url).then((data) => {
+              this.onPreview(data)
+            })
+            return
+          }
+        }
         if (row.url !== null && row.url !== undefined && row.url !== '') {
           if (suffix === 'pdf') {
             window.open('https://view.xdocin.com/xdoc?xdoc=' + row.url, '_blank')