cqf
2022-05-21 9bfc581627fc8475fda5bac423a5b76ea4f00df5
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,7 @@
<script>
    import Titlename from "../../components/Titlename/index.vue";
    import {sendDangerNext, getDangerDetails, getWfRecordList} from "@/api/sgyhpczl/recheckCancellationNumber";
    import {downloadFile} from "@/api/sgyhpczl/fileUtils";
    export default {
        components: {Titlename},
@@ -465,7 +467,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>