lsc 6 mesi fa
parent
commit
d02aeac98c

+ 1 - 0
src/assets/download.svg

@@ -0,0 +1 @@
+<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1743055825751" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2673" width="16" height="16" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M544.256 605.184l244.224-244.224a31.744 31.744 0 0 1 45.056 45.056l-295.424 295.424a36.864 36.864 0 0 1-51.2 0L190.464 406.528a31.744 31.744 0 1 1 45.056-45.056l244.224 244.224V111.104a32.256 32.256 0 1 1 64 0zM153.6 902.656a32.256 32.256 0 0 1 0-64h716.8a32.256 32.256 0 0 1 0 64z" fill="#5A5A68" p-id="2674"></path></svg>

+ 1 - 0
src/assets/download2.svg

@@ -0,0 +1 @@
+<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1743055825751" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2673" width="16" height="16" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M544.256 605.184l244.224-244.224a31.744 31.744 0 0 1 45.056 45.056l-295.424 295.424a36.864 36.864 0 0 1-51.2 0L190.464 406.528a31.744 31.744 0 1 1 45.056-45.056l244.224 244.224V111.104a32.256 32.256 0 1 1 64 0zM153.6 902.656a32.256 32.256 0 0 1 0-64h716.8a32.256 32.256 0 0 1 0 64z" fill="#487FFF" p-id="2674"></path></svg>

+ 1 - 1
src/common/axios.config.js

@@ -83,7 +83,7 @@ axios.interceptors.response.use((res) => {
 //返回一个Promise(发送post请求)
 function post(url, params, source) {
     return new Promise((resolve, reject) => {
-        axios.post(url, params, source ? { cancelToken: source.token } : '')
+        axios.post(url, params, source ? { cancelToken: source.token, responseType: source.responseType } : '')
             .then(response => {
                 resolve(response);
             }, err => {

+ 40 - 0
src/components/pages/knowledge/fileBox.vue

@@ -191,6 +191,16 @@
                          alt="">
                         <span :class="isHover2 ? 'lookHp2' : 'lookHp1'">查看</span>
                       </div>
+                      <div class="btnBh" 
+                      @click="downloadFile(scope.row)"
+                        @mouseover="isHover3 = true"
+                        :disabled="scope.row.ingestionStatus == 'failed'"
+                        @mouseleave="isHover3 = false">
+                        <img 
+                        :src="isHover3 ? download2 : download" 
+                         alt="">
+                        <span :class="isHover3 ? 'lookHp2' : 'lookHp1'">下载</span>
+                      </div>
                     </div>
                     <div style="background-color: #e7e7e7;width: 100%;height: .5px;margin: 5px 0;"></div>
                     <div class="BtnHPDel">
@@ -260,6 +270,8 @@ import look1 from '../../../assets/look1.svg';
 import look2 from '../../../assets/look2.svg';
 import tqList2 from '../../../assets/tqList2.svg';
 import tqList from '../../../assets/tqList.svg';
+import download from '../../../assets/download.svg';
+import download2 from '../../../assets/download2.svg';
 
 
 import wVideo from "../test/file/wVideo.vue";
@@ -318,8 +330,11 @@ export default {
       look2:look2,
       tqList2:tqList2,
       tqList:tqList,
+      download: download,
+      download2: download2,
       isHover:false,
       isHover2:false,
+      isHover3:false,
       isLoading: false,
       proVisible: false,
       stype: 2,
@@ -629,6 +644,30 @@ export default {
 
       this.$refs.checkDialog.openG(row.documentid);
     },
+    downloadFile(row) {
+      let params = {
+        documentid: row.documentid,
+        filename: row.name,
+      };
+      // 使用axios发送GET请求下载文件
+      this.ajax.post(`${this.$store.state.fileApi}downloadFile2`, [params],{responseType: 'blob'}).then(response => {
+        const url = window.URL.createObjectURL(new Blob([response.data]));
+        const link = document.createElement('a');
+        link.href = url;
+        link.setAttribute('download', row.name); // 设置下载文件名
+        document.body.appendChild(link);
+        link.click();
+        link.remove();
+        this.$message({
+          message: "下载成功",
+          type: "success"
+        });
+      }).catch(err => {
+        this.$message.error("下载失败");
+        console.error(err);
+      });
+    },
+
     extractFile(row) {
       if (row.ingestionStatus != "success") return this.$message.info('文件未上传成功,点击刷新查看实时状态')
       
@@ -1273,6 +1312,7 @@ export default {
   cursor: pointer;
   border-radius: 6px;
   padding: 5px 8px;
+  align-items: center;
 }
 </style>
 

+ 39 - 2
src/components/pages/knowledge/folderFileBox.vue

@@ -216,7 +216,16 @@
                           alt="">
                         <span :class="isHover3 ? 'lookHp2' : 'lookHp1'">移除</span>
                       </div>
-
+                      <div class="btnBh" 
+                      @click="downloadFile(scope.row)"
+                        @mouseover="isHover4 = true"
+                        :disabled="scope.row.ingestionStatus == 'failed'"
+                        @mouseleave="isHover4 = false">
+                        <img 
+                        :src="isHover4 ? download2 : download" 
+                         alt="">
+                        <span :class="isHover4 ? 'lookHp2' : 'lookHp1'">下载</span>
+                      </div>
                     <!-- <el-button
                       type="primary"
                       size="small"
@@ -294,7 +303,8 @@ import tqList2 from '../../../assets/tqList2.svg';
 import tqList from '../../../assets/tqList.svg';
 import yichu from '../../../assets/yichu.svg';
 import yichu2 from '../../../assets/yichu2.svg';
-
+import download from '../../../assets/download.svg';
+import download2 from '../../../assets/download2.svg';
 
 import wVideo from "../test/file/wVideo.vue";
 import wpdf from "../test/file/wPdf2.vue";
@@ -353,9 +363,12 @@ export default {
       tqList:tqList,
       yichu:yichu,
       yichu2:yichu2,
+      download: download,
+      download2: download2,
       isHover:false,
       isHover2:false,
       isHover3:false,
+      isHover4:false,
 
       
       isLoading: false,
@@ -709,6 +722,30 @@ export default {
 
       this.$refs.checkDialog.openG(row.documentid);
     },
+    downloadFile(row) {
+      let params = {
+        documentid: row.documentid,
+        filename: row.name,
+      };
+      // 使用axios发送GET请求下载文件
+      this.ajax.post(`${this.$store.state.fileApi}downloadFile2`, [params],{responseType: 'blob'}).then(response => {
+        const url = window.URL.createObjectURL(new Blob([response.data]));
+        const link = document.createElement('a');
+        link.href = url;
+        link.setAttribute('download', row.name); // 设置下载文件名
+        document.body.appendChild(link);
+        link.click();
+        link.remove();
+        this.$message({
+          message: "下载成功",
+          type: "success"
+        });
+      }).catch(err => {
+        this.$message.error("下载失败");
+        console.error(err);
+      });
+    },
+
     extractFile(row) {
       if (row.ingestionStatus != "success") return this.$message.info('文件未上传成功,点击刷新查看实时状态')