From d3e7923f5cc188da720ba9c3d6a536ae82e46f3c Mon Sep 17 00:00:00 2001
From: lyfO_o <764716047@qq.com>
Date: 星期四, 09 六月 2022 10:00:24 +0800
Subject: [PATCH] 删除

---
 src/views/dangerDetails/dnagerDetails.vue |   86 ++++++++++++++++++++++++++++++++++--------
 1 files changed, 69 insertions(+), 17 deletions(-)

diff --git a/src/views/dangerDetails/dnagerDetails.vue b/src/views/dangerDetails/dnagerDetails.vue
index 26a7a4c..0d8d558 100644
--- a/src/views/dangerDetails/dnagerDetails.vue
+++ b/src/views/dangerDetails/dnagerDetails.vue
@@ -295,10 +295,11 @@
                                         >
                                         <template slot-scope="scope">
                                             <span size="medium">{{ scope.row.content }}</span>
-                                            <a v-for="item in scope.row.realFileName"
-                                               :href="scope.row.url+'/'+item">
-                                                {{ item.split("fileName=")[1] }}
-                                            </a>
+                                            <span v-for="item in scope.row.realFileName">
+                                                <el-link  type="primary" @click="downloadFile(subFile(item))">
+                                                    {{subFile(item)}}
+                                                </el-link>
+                                            </span>
                                         </template>
                                     </el-table-column>
                                     <el-table-column
@@ -331,6 +332,8 @@
 <script>
     import Titlename from "../../components/Titlename/index.vue";
     import {sendDangerNext, getDangerDetails, getWfRecordList} from "@/api/sgyhpczl/recheckCancellationNumber";
+    import {downloadFile} from "@/api/sgyhpczl/fileUtils";
+    import {self_info} from "../../api/sgyhpczl/hiddenDangerManagement";
 
     export default {
         components: {Titlename},
@@ -380,18 +383,34 @@
         },
         methods: {
             getDangerDetails() {
-                getDangerDetails(this.$route.query.id).then(res => {
-                    var data = res.data;
-                    if (data.ok) {
-                        this.ruleForm = data.data;
-                        this.ruleForm.url = process.env.BASE_API;
-                        this.ruleForm.callback_branch= data.data.check_main_branch
-                        //this.ruleForm.ispass=0
-                        this.sendDataForm.id = this.ruleForm.id
-                    } else {
-                        this.$message({type: 'error', message: "数据查询失败,请重试!", duration: 3000})
-                    }
-                })
+                if(this.$route.query.route!=null && this.$route.query.route == '/hiddenDangerManagement'){
+                    self_info(this.$route.query.id).then(res => {
+                        var data = res.data;
+                        if (data.ok) {
+                            this.ruleForm = data.data;
+                            this.ruleForm.url = process.env.BASE_API;
+                            this.ruleForm.callback_branch= data.data.check_main_branch
+                            //this.ruleForm.ispass=0
+                            this.sendDataForm.id = this.ruleForm.id
+                        } else {
+                            this.$message({type: 'error', message: "数据查询失败,请重试!", duration: 3000})
+                        }
+                    })
+                }else{
+                    getDangerDetails(this.$route.query.id).then(res => {
+                        var data = res.data;
+                        if (data.ok) {
+                            this.ruleForm = data.data;
+                            this.ruleForm.url = process.env.BASE_API;
+                            this.ruleForm.callback_branch= data.data.check_main_branch
+                            //this.ruleForm.ispass=0
+                            this.sendDataForm.id = this.ruleForm.id
+                        } else {
+                            this.$message({type: 'error', message: "数据查询失败,请重试!", duration: 3000})
+                        }
+                    })
+                }
+
             },
             getWfRecordList() {
                 getWfRecordList(this.$route.query.id).then(res => {
@@ -465,7 +484,40 @@
                         path:"/hiddenDangerRectification"
                     })
                 }
-            }
+            },
+            subFile(fileName){
+                return  fileName.substring(fileName.indexOf("fileName=")+9)
+            },
+            downloadFile(path){
+                let params = {
+                    type: 0,
+                    fileName: path,
+                };
+                downloadFile(params).then((res) => {
+                    if(res.data.type=='text/json'){
+                        const reader  = new FileReader();
+                        reader.readAsText(res.data, 'utf-8');
+                        reader.onload = e => {
+                            this.$message({
+                                type: "error",
+                                message: JSON.parse(reader.result).msg,
+                                duration: 3000,
+                            });
+                        }
+                    } else {
+                        let blob = new Blob([res.data], {type: 'application/octet-stream'})
+                        console.log(blob)
+                        let blobUrl = window.URL.createObjectURL(blob)
+                        let downloadElement = document.createElement('a')
+                        downloadElement.href = blobUrl
+                        downloadElement.download = path
+                        document.body.appendChild(downloadElement)
+                        downloadElement.click()
+                        document.body.removeChild(downloadElement)
+                        window.URL.revokeObjectURL(blobUrl)
+                    }
+                });
+            },
         }
     }
 </script>

--
Gitblit v1.9.2