scorpio 2 years ago
parent
commit
9e5971954d

+ 3 - 0
src/api/resource/index.js

@@ -132,6 +132,9 @@ export default {
   fileDetail(id) {
     return fetch('/wutong-library/library/detail/' + id)
   },
+  fileInfo(params) {
+    return fetch('/wutong-file/file/detail', params)
+  },
   /**
    * 删除文件
    * @param params

+ 2 - 2
src/views/dash/compoents/read.vue

@@ -19,8 +19,8 @@
 
       <div class="flex flex-center flex-col" style="flex: 1">
         <img
-          src="../../../assets/img/code.png"
-          style="width: 80px; height: 80px"
+          src="https://wutong-1302848345.cos.ap-chengdu.myqcloud.com/wtzx/4a721f77f9c24f55bacfe032b8060ba8.jpg"
+          style="width: 180px; height: 180px"
         />
         <span class="mt-10 font-13"
           >微信扫描关注公众号<br />及时掌握更多资讯</span

+ 30 - 19
src/views/resource/component/preview.vue

@@ -2,7 +2,7 @@
   <div>
     <div @click="detail">
       <slot name="title">
-        <el-button type="primary" text @click="detail">查看</el-button>
+        <el-button type="primary" text>查看</el-button>
       </slot>
     </div>
     <el-image-viewer
@@ -34,7 +34,12 @@
           <el-button type="primary" icon="Download" @click="downloadClick"
             >下 载</el-button
           >
-          <share class="ml-20" :row="data" v-if="isAccess === 2" />
+          <share
+            class="ml-20"
+            :project-id="projectId"
+            :ids="id"
+            v-if="isAccess === 2"
+          />
         </div>
       </div>
     </el-drawer>
@@ -64,6 +69,10 @@ export default {
       type: Boolean,
       default: false
     },
+    projectId: {
+      type: String,
+      default: ''
+    },
     id: {
       type: String,
       default: null
@@ -78,36 +87,38 @@ export default {
     }
   },
   methods: {
-    openFile() {
-      if (
-        this.data.fileAttach.id === -1 ||
-        api.offices.includes(this.data.fileAttach.suffix)
-      ) {
-        this.show = true
-      } else {
-        this.preList.length = 0
-        this.preList.push(this.data.url)
-        this.showImage = true
-      }
-    },
     detail() {
-      console.log(Number(this.id, 10))
       if (Number(this.id, 10).toString() === 'NaN') {
+        // 如果id 不是数字开头,即mongo 62开头的id,查看文章详情
         this.$api.resource.fileDetail(this.id).then(res => {
           if (res.code === 200) {
             this.data = res.data
-            this.openFile()
+            this.show = true
           }
         })
       } else {
-        this.$api.resource.fileDetailByFile(this.id).then(res => {
+        this.$api.resource.fileInfo({ id: this.id }).then(res => {
           if (res.code === 200) {
-            this.data = res.data
-            this.openFile()
+            const tmp = res.data
+            if (api.offices.includes(tmp.suffix)) {
+              this.openByFile()
+            } else {
+              this.preList.length = 0
+              this.preList.push(tmp.filePath)
+              this.showImage = true
+            }
           }
         })
       }
     },
+    openByFile() {
+      this.$api.resource.fileDetailByFile(this.id).then(res => {
+        if (res.code === 200) {
+          this.data = res.data
+          this.show = true
+        }
+      })
+    },
     async downloadClick() {
       const link = document.createElement('a')
       link.href = this.data.url

+ 13 - 7
src/views/resource/component/share.vue

@@ -37,8 +37,14 @@ export default {
     VueQr
   },
   props: {
-    row: {
-      type: Object,
+    projectId: {
+      required: true,
+      type: String,
+      default: null
+    },
+    ids: {
+      required: true,
+      type: String,
       default: null
     }
   },
@@ -55,27 +61,27 @@ export default {
   data() {
     return {
       show: false,
-      url: 'http://localhost:5173/resource?id=64b79edd8ce2593744685a3e&type=0',
       logoSrc: new URL('@/assets/img/logo.png', import.meta.url).href,
       qrCodeText: '',
       deptId: ''
     }
   },
   mounted() {
-    // fixme 项目经理
     this.getProjectInfo()
   },
   methods: {
     getProjectInfo() {
-      this.$api.project.projectInfo(this.row.projectId).then(res => {
+      if (this.projectId.length === 0) {
+        return
+      }
+      this.$api.project.projectInfo(this.projectId).then(res => {
         if (res.code === 200) {
-          console.log(res)
           this.deptId = res.data.createDept
         }
       })
     },
     getQrCode() {
-      this.$api.resource.shareFiles({ ids: this.row.id }).then(res => {
+      this.$api.resource.shareFiles({ ids: this.ids }).then(res => {
         if (res.code === 200) {
           this.qrCodeText =
             website.baseUrl +

+ 1 - 0
src/views/resource/component/xtable.vue

@@ -59,6 +59,7 @@
                   <preview
                     :id="row.fileId"
                     :is-access="row.isAccess"
+                    :project-id="row.projectId"
                     v-if="row.type === 1"
                     ref="preview"
                   />