weirenchun 2 лет назад
Родитель
Сommit
37ad6d6726
2 измененных файлов с 61 добавлено и 4 удалено
  1. 4 0
      src/api/project/index.js
  2. 57 4
      src/views/resource/component/preview.vue

+ 4 - 0
src/api/project/index.js

@@ -135,6 +135,10 @@ export default {
     // 历史数据文件夹列表
     return fetch('/blade-project-manage-v2/folder/v2/history', params)
   },
+  fileHistory(params) {
+    // 历史数据文件列表
+    return fetch('/blade-project-manage-v2/folder/v2/file-history', params)
+  },
   folderRemove(params) {
     // 删除文件夹
     return fetch('/blade-project-manage-v2/folder/v2/remove', params, 'post')

+ 57 - 4
src/views/resource/component/preview.vue

@@ -40,6 +40,24 @@
             :ids="id"
             v-if="isAccess === 2"
           />
+          <el-button
+            class="ml-20"
+            type="primary"
+            @click="moreDetail"
+            v-if="liButton"
+            >文件历史
+          </el-button>
+          <el-drawer v-model="liShow" :size="600">
+            <div
+              class="flex ml-10"
+              v-for="item in fileHistoryList"
+              @click="newDetail(item)"
+            >
+              <div class="mt-10">{{ item.coverUser }}</div>
+              <div class="ml-20 mt-10">在{{ item.createTime }}上传,</div>
+              <div class="ml-20 mt-10">编码{{ item.fileVO.md5 }}</div>
+            </div>
+          </el-drawer>
         </div>
       </div>
     </el-drawer>
@@ -78,11 +96,25 @@ export default {
       default: null
     }
   },
+  watch: {
+    id: {
+      handler(val) {
+        if (val != null) {
+          this.fileId = val
+        }
+      },
+      immediate: true
+    }
+  },
   data() {
     return {
+      fileId: '',
+      liButton: false,
+      liShow: false,
       show: false,
       data: null,
       preList: [],
+      fileHistoryList: [1, 2, 3],
       showImage: false,
       watermarkOptions: {
         content: 'watermark',
@@ -94,18 +126,34 @@ export default {
     }
   },
   methods: {
+    newDetail(item) {
+      this.fileId = item.fileVO.id
+      this.detail()
+    },
     detail() {
-      if (Number(this.id, 10).toString() === 'NaN') {
+      //先判断是否存在历史列表
+      this.$api.project
+        .fileHistory({ fileId: this.fileId, current: 1, size: 100 })
+        .then(res => {
+          if (res.code === 200) {
+            console.log(res)
+            if (res.data.total > 0) {
+              this.liButton = true
+              this.fileHistoryList = res.data.records
+            }
+          }
+        })
+      if (Number(this.fileId, 10).toString() === 'NaN') {
         console.log('yyyy')
         // 如果id 不是数字开头,即mongo 62开头的id,查看文章详情
-        this.$api.resource.fileDetail(this.id).then(res => {
+        this.$api.resource.fileDetail(this.fileId).then(res => {
           if (res.code === 200) {
             this.data = res.data
             this.show = true
           }
         })
       } else {
-        this.$api.resource.fileInfo({ id: this.id }).then(res => {
+        this.$api.resource.fileInfo({ id: this.fileId }).then(res => {
           if (res.code === 200) {
             const tmp = res.data
             if (api.offices.includes(tmp.suffix)) {
@@ -119,14 +167,19 @@ export default {
         })
       }
     },
+    moreDetail() {
+      //显示侧边
+      this.liShow = true
+    },
     openByFile() {
-      this.$api.resource.fileDetailByFile(this.id).then(res => {
+      this.$api.resource.fileDetailByFile(this.fileId).then(res => {
         if (res.code === 200) {
           this.data = res.data
           this.show = true
         }
       })
     },
+    moreClick() {},
     async downloadClick() {
       const link = document.createElement('a')
       link.href = this.data.url