2023-07-13 11:15:02 +08:00
|
|
|
<template>
|
|
|
|
<a-card :bordered="false" style="margin-left: 20px;height: 100%;">
|
|
|
|
<div class="detail-top">
|
|
|
|
<div class="top-back" @click="handleback">
|
2023-07-13 16:54:44 +08:00
|
|
|
<img class="icon-back" src="../../assets/images/web-statistics/return.png" alt="">
|
2023-07-13 11:15:02 +08:00
|
|
|
<span style="margin-left: 10px;">return</span>
|
|
|
|
</div>
|
|
|
|
<div class="top-actions">
|
2023-07-13 18:29:56 +08:00
|
|
|
<div class="right-btn" @click="downloadFile">
|
|
|
|
<!-- <a :href="fileSrc" :download="type" rel="noopener noreferrer"> -->
|
2023-07-13 16:54:44 +08:00
|
|
|
<img class="icon-download" src="../../assets/images/web-statistics/download.png" alt="">
|
|
|
|
<span style="margin-left: 10px;">
|
2023-07-13 11:15:02 +08:00
|
|
|
TXT
|
2023-07-13 16:54:44 +08:00
|
|
|
</span>
|
2023-07-13 18:29:56 +08:00
|
|
|
<!-- </a> -->
|
2023-07-13 11:15:02 +08:00
|
|
|
</div>
|
2023-07-13 18:29:56 +08:00
|
|
|
<div class="right-btn" @click="viewFile">
|
|
|
|
<!-- <a :href="fileSrc" target="_blank" rel="noopener noreferrer"> -->
|
2023-07-13 16:54:44 +08:00
|
|
|
<img class="icon-view" src="../../assets/images/web-statistics/view.png" alt="">
|
|
|
|
<span style="margin-left: 10px;">
|
2023-07-13 11:15:02 +08:00
|
|
|
View Report
|
2023-07-13 16:54:44 +08:00
|
|
|
</span>
|
2023-07-13 18:29:56 +08:00
|
|
|
<!-- </a> -->
|
2023-07-13 11:15:02 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="file-content">
|
|
|
|
<pre>{{ fileText }}</pre>
|
|
|
|
</div>
|
|
|
|
</a-card>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2023-07-13 16:54:44 +08:00
|
|
|
import { getAction } from '../../api/manage'
|
2023-07-13 11:15:02 +08:00
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
type: {
|
|
|
|
type: String,
|
|
|
|
default:""
|
|
|
|
},
|
|
|
|
sampleId: {
|
|
|
|
type: String,
|
|
|
|
default:""
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
fileText: "",
|
|
|
|
fileSrc:""
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted () {
|
|
|
|
this.getFildBlob();
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
handleback() {
|
|
|
|
this.$emit("back",false)
|
|
|
|
},
|
|
|
|
getFildBlob() {
|
|
|
|
let _this = this
|
2023-07-13 16:54:44 +08:00
|
|
|
let paramsRr = {
|
2023-07-13 11:15:02 +08:00
|
|
|
type: this.type,
|
|
|
|
sampleId: this.sampleId,
|
|
|
|
// type: "rrr",
|
|
|
|
// sampleId:"1523651"
|
|
|
|
}
|
2023-07-13 16:54:44 +08:00
|
|
|
let paramsSoh = {
|
|
|
|
// sohId:"11"
|
|
|
|
sohId:this.sampleId
|
|
|
|
}
|
|
|
|
let url = this.type === "soh" ? "/webStatistics/sohFile" : "/webStatistics/arFile"
|
|
|
|
let params = this.type === "soh" ? paramsSoh : paramsRr
|
|
|
|
getAction(url, params).then((res) => {
|
2023-07-14 16:52:18 +08:00
|
|
|
if (res.code && res.code==500) {
|
|
|
|
_this.fileSrc = ""
|
2023-07-28 16:04:56 +08:00
|
|
|
this.$message.warning("This operation fails. Contact your system administrator")
|
2023-07-14 16:52:18 +08:00
|
|
|
} else {
|
|
|
|
const blob = new Blob([res], { type: 'text/plain' })
|
|
|
|
_this.fileSrc = window.URL.createObjectURL(blob)
|
|
|
|
var reader = new FileReader();
|
|
|
|
reader.readAsText(blob);
|
|
|
|
reader.onload = function(){
|
|
|
|
//读取完毕后输出结果
|
|
|
|
_this.fileText = reader.result
|
|
|
|
}
|
2023-07-13 11:15:02 +08:00
|
|
|
}
|
|
|
|
})
|
2023-07-13 18:29:56 +08:00
|
|
|
},
|
|
|
|
downloadFile() {
|
|
|
|
if (this.fileSrc) {
|
|
|
|
let link = document.createElement('a')
|
|
|
|
link.href = this.fileSrc
|
|
|
|
link.target = '_blank'
|
|
|
|
link.download = this.type
|
|
|
|
document.body.appendChild(link)
|
|
|
|
link.click()
|
|
|
|
document.body.removeChild(link)
|
|
|
|
} else {
|
2023-07-14 16:52:18 +08:00
|
|
|
this.$message.warning("This operation fails. Contact your system administrator")
|
2023-07-13 18:29:56 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
viewFile() {
|
|
|
|
if (this.fileSrc) {
|
|
|
|
let link = document.createElement('a')
|
|
|
|
link.href = this.fileSrc
|
|
|
|
link.target = '_blank'
|
|
|
|
document.body.appendChild(link)
|
|
|
|
link.click()
|
|
|
|
document.body.removeChild(link)
|
|
|
|
} else {
|
|
|
|
this.$message.info("File preview failed")
|
|
|
|
}
|
|
|
|
},
|
2023-07-13 11:15:02 +08:00
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="less" scoped>
|
|
|
|
.detail-top{
|
|
|
|
width: 100%;
|
|
|
|
height: 50px;
|
|
|
|
padding: 0 10px;
|
|
|
|
background-color: rgba(12, 235, 201, 0.05);
|
|
|
|
border-top: 1px solid rgba(12, 235, 201, 0.3);
|
|
|
|
border-bottom: 1px solid rgba(12, 235, 201, 0.3);
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: space-between;
|
|
|
|
margin-bottom: 16px;
|
|
|
|
.top-back{
|
|
|
|
font-family: MicrosoftYaHei;
|
|
|
|
font-size: 16px;
|
|
|
|
font-weight: normal;
|
|
|
|
font-stretch: normal;
|
|
|
|
letter-spacing: 0px;
|
|
|
|
color: #69a19f;
|
|
|
|
cursor: pointer;
|
|
|
|
.icon-back{
|
|
|
|
width: 28px;
|
|
|
|
height: 24px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.top-actions{
|
|
|
|
.right-btn{
|
|
|
|
display: inline-block;
|
|
|
|
height: 32px;
|
|
|
|
line-height: 32px;
|
|
|
|
padding: 0 12px;
|
|
|
|
margin-left: 20px;
|
|
|
|
background-color: #1397a3;
|
2023-07-14 15:18:08 +08:00
|
|
|
cursor: pointer;
|
2023-07-13 11:15:02 +08:00
|
|
|
.icon-download{
|
|
|
|
width: 16px;
|
|
|
|
height: 19px;
|
|
|
|
}
|
|
|
|
.icon-view{
|
|
|
|
width: 15px;
|
|
|
|
height: 16px;
|
|
|
|
}
|
|
|
|
a{
|
|
|
|
color: white;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.file-content{
|
|
|
|
height: calc(100% - 66px);
|
|
|
|
border: 1px solid #1397a3;
|
|
|
|
overflow: auto;
|
|
|
|
padding: 15px;
|
|
|
|
}
|
|
|
|
</style>
|