Ver Fonte

fix bug

scorpio há 2 anos atrás
pai
commit
55c4015dff

+ 4 - 1
src/api/resource/index.js

@@ -126,9 +126,12 @@ export default {
    * @param id
    * @returns {Promise<unknown>}
    */
-  fileDetail(id) {
+  fileDetailByFile(id) {
     return fetch('/wutong-library/library/detail/file/' + id)
   },
+  fileDetail(id) {
+    return fetch('/wutong-library/library/detail/' + id)
+  },
   /**
    * 删除文件
    * @param params

+ 10 - 10
src/views/dash/compoents/notice.vue

@@ -5,13 +5,16 @@
     </el-icon>
     <div class="roll full-width">
       <ul :class="{ marquee_top: animate }">
-        <li
-          v-for="(item, index) in data"
-          :key="index"
-          class="pointer"
-          @click="checkNotice(item)"
-        >
-          <span class="main-color bold">{{ item.title }}</span>
+        <li v-for="(item, index) in data" :key="index" class="pointer">
+          <div class="flex flex-center flex-justify-between">
+            <preview :id="item.fileId">
+              <template #title>
+                <div class="main-color">
+                  {{ item.title }}
+                </div>
+              </template>
+            </preview>
+          </div>
         </li>
       </ul>
     </div>
@@ -50,9 +53,6 @@ export default {
         this.data.shift()
         this.animate = false
       }, 500)
-    },
-    checkNotice(item) {
-      console.log(item)
     }
   }
 }

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

@@ -45,7 +45,7 @@ export default {
     getList() {
       this.$api.dash.mpList().then(res => {
         if (res.code === 200) {
-          this.data = res.data[0].content
+          // this.data = res.data[0].content
         } else {
           console.log(res)
         }

+ 3 - 0
src/views/resource/component/floder.vue

@@ -49,6 +49,9 @@ export default {
 
   methods: {
     folderAdd() {
+      if (this.title.length === 0) {
+        return
+      }
       const data = {
         projectId: this.info.projectId,
         stageId: this.info.stageId,

+ 46 - 28
src/views/resource/component/preview.vue

@@ -1,6 +1,11 @@
 <template>
   <div>
-    <el-button type="primary" text @click="openFile">查看</el-button>
+    <el-button v-if="title.length === 0" type="primary" text @click="detail"
+      >查看</el-button
+    >
+    <div v-else @click="detail">
+      <slot name="title"></slot>
+    </div>
     <el-image-viewer
       v-if="showImage"
       :url-list="preList"
@@ -16,24 +21,21 @@
       </template>
       <div>
         <div v-if="data">
-          <el-empty
-            v-if="data.imgs.length === 0"
-            style="height: 90vh"
-            description="暂时无法预览,您可以点击 下载 按钮,下载原文件 "
-            class="full-height flex flex-center"
-          />
+          <div v-if="data.imgs.length === 0" class="flex flex-center">
+            <div v-html="data.content" class="preview"></div>
+          </div>
           <div v-else v-for="item in data.imgs" :key="item.id">
             <img :src="item.filePath" style="width: 1100px" />
           </div>
         </div>
         <div
           class="bottom flex flex-center flex-justify-center"
-          v-if="info.isAccess === 2 || showAction"
+          v-if="isAccess === 2 || showAction"
         >
           <el-button type="primary" icon="Download" @click="downloadClick"
             >下 载</el-button
           >
-          <share class="ml-20" :row="info" v-if="info.isAccess === 2" />
+          <share class="ml-20" :row="data" v-if="isAccess === 2" />
         </div>
       </div>
     </el-drawer>
@@ -49,25 +51,25 @@ export default {
     share
   },
   props: {
+    title: {
+      type: String,
+      default: () => {
+        return ''
+      }
+    },
+    isAccess: {
+      type: Number,
+      default: 3
+    },
     showAction: {
       type: Boolean,
       default: false
     },
-    info: {
-      type: Object,
+    id: {
+      type: String,
       default: null
     }
   },
-  watch: {
-    show: {
-      handler(val) {
-        if (val) {
-          this.detail()
-        }
-      },
-      immediate: true
-    }
-  },
   data() {
     return {
       show: false,
@@ -78,27 +80,39 @@ export default {
   },
   methods: {
     openFile() {
-      if (api.offices.includes(this.info.suffix)) {
+      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.info.url)
+        this.preList.push(this.data.url)
         this.showImage = true
       }
     },
     detail() {
-      this.$api.resource
-        .fileDetail(this.info.fileId ? this.info.fileId : this.info.id)
-        .then(res => {
+      console.log(Number(this.id, 10))
+      if (Number(this.id, 10) === 'NaN') {
+        this.$api.resource.fileDetail(this.id).then(res => {
           if (res.code === 200) {
             this.data = res.data
+            this.openFile()
           }
         })
+      } else {
+        this.$api.resource.fileDetailByFile(this.id).then(res => {
+          if (res.code === 200) {
+            this.data = res.data
+            this.openFile()
+          }
+        })
+      }
     },
     async downloadClick() {
       const link = document.createElement('a')
-      link.href = this.info.url
-      link.download = this.info.title
+      link.href = this.data.url
+      link.download = this.data.title
       link.click()
     }
   }
@@ -106,6 +120,10 @@ export default {
 </script>
 
 <style lang="scss" scoped>
+.preview {
+  width: 960px;
+  padding: 20px;
+}
 .bottom {
   position: fixed;
   bottom: 0;

+ 0 - 8
src/views/resource/component/row1.vue

@@ -4,14 +4,6 @@
       v-if="index === 0"
       class="flex flex-align-center full-height cell full-width"
     >
-      <!--      <el-checkbox-->
-      <!--        v-if="showCheckBox"-->
-      <!--        v-model="info.checked"-->
-      <!--        :disabled="folderChecked === false && row.type === 2"-->
-      <!--        class="padding-right"-->
-      <!--        @change="rowChecked(row)"-->
-      <!--      />-->
-
       <div v-if="showCheckBox" class="margin">
         <el-icon
           v-if="folderChecked === false && row.type === 2"

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

@@ -56,7 +56,12 @@
                 class="flex flex-center"
               >
                 <div>
-                  <preview :info="row" v-if="row.type === 1" ref="preview" />
+                  <preview
+                    :id="row.fileId"
+                    :is-access="row.isAccess"
+                    v-if="row.type === 1"
+                    ref="preview"
+                  />
                 </div>
                 <div v-if="row.isAccess === 2" class="flex flex-center">
                   <div v-if="row.type === 2 && row.parentId === '0'">

+ 2 - 4
src/views/task/component/task.vue

@@ -118,7 +118,7 @@
               <div v-for="item in fileList" :key="item.id">
                 <div class="flex flex-center">
                   {{ item.title }}
-                  <preview :info="item" :show-action="true" />
+                  <preview :id="item.fileId" :show-action="true" />
                 </div>
               </div>
             </div>
@@ -149,7 +149,7 @@
               <div class="flex flex-justify-start flex-center">
                 {{ item.fileVO.originalFileName }}
                 ({{ item.createUserName }})
-                <preview :info="item.fileVO" :show-action="true"></preview>
+                <preview :id="item.fileVO.id" :show-action="true"></preview>
               </div>
             </div>
           </div>
@@ -301,7 +301,6 @@ export default {
   methods: {
     init() {
       this.form = this.task
-      console.log(this.task)
       if (this.task.users !== undefined) {
         this.executeUser = [...this.task.users]
       }
@@ -311,7 +310,6 @@ export default {
       }
       if (this.task.files !== undefined && this.task.files.length > 0) {
         this.fileList = this.task.files
-        console.log(this.fileList)
       }
       this.resultFileInfo()
     },