cqf
2022-05-21 9bfc581627fc8475fda5bac423a5b76ea4f00df5
src/views/Issuedbysuperiors/superiorsSend.vue
@@ -296,10 +296,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
@@ -387,7 +388,7 @@
import {getDangerDetails, getWfRecordList} from "@/api/sgyhpczl/recheckCancellationNumber";
import {company_next_step_do} from "@/api/sgyhpczl/Issuedbysuperiors";
import {getUserInfo} from "@/api/sgyhpczl/hiddenDangerManagement";
import {downloadFile} from "@/api/sgyhpczl/fileUtils";
export default {
    components: {Titlename},
@@ -497,7 +498,40 @@
            this.$router.push({
                path: "/recheckCancellationNumber"
            })
        }
        },
        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>