增加下载失败,预览失败提醒消息

This commit is contained in:
renpy 2023-07-13 18:29:56 +08:00
parent 80e81c6a50
commit 4022a3c38d
2 changed files with 76 additions and 24 deletions

View File

@ -6,29 +6,29 @@
<span style="margin-left: 10px;">return</span>
</div>
<div class="top-actions">
<div class="right-btn">
<a :href="zipSrc" :download="type" target="_blank" rel="noopener noreferrer">
<div class="right-btn" @click="downloadFile(zipSrc)">
<!-- <a :href="zipSrc" :download="type"> -->
<img class="icon-download" src="../../assets/images/web-statistics/download.png" alt="">
<span style="margin-left: 10px;">
ZIP
</span>
</a>
<!-- </a> -->
</div>
<div class="right-btn">
<a :href="fileSrc" :download="type" target="_blank" rel="noopener noreferrer">
<div class="right-btn" @click="downloadFile(fileSrc)">
<!-- <a :href="fileSrc" :download="type"> -->
<img class="icon-download" src="../../assets/images/web-statistics/download.png" alt="">
<span style="margin-left: 10px;">
TXT
</span>
</a>
<!-- </a> -->
</div>
<div class="right-btn">
<a :href="fileSrc" target="_blank" rel="noopener noreferrer">
<div class="right-btn" @click="viewFile">
<!-- <a :href="fileSrc" target="_blank"> -->
<img class="icon-view" src="../../assets/images/web-statistics/view.png" alt="">
<span style="margin-left: 10px;">
View Report
</span>
</a>
<!-- </a> -->
</div>
</div>
</div>
@ -545,7 +545,8 @@ export default {
zipSrc:""
}
},
mounted () {
mounted() {
this.getFildBlob()
this.commentText = this.allData.commentBlock && this.allData.commentBlock.text?this.allData.commentBlock.text.replace(/\n/g, "<br />"):""
this.dataSourceEnergy_G=this.allData.genergyBlock
this.dataSourceEnergy_B=this.allData.benergyBlock
@ -555,12 +556,12 @@ export default {
this.dataSourceEfficiency_BG = this.allData.bgEfficiencyBlock
this.dataSourceRoiLimits = this.allData.roiLimitsBlock
this.dataSourceRatios = this.allData.ratiosBlock
this.dataSourceSpectrum_G = this.allData.gspectrumBlock.gspectrumSubBlock
this.dataSourceSpectrumX_G = this.allData.gspectrumBlock.gspectrumSubBlock.map((item, index) => {
this.dataSourceSpectrum_G = this.allData.gspectrumBlock&&this.allData.gspectrumBlock.gspectrumSubBlock
this.dataSourceSpectrumX_G = this.allData.gspectrumBlock&&this.allData.gspectrumBlock.gspectrumSubBlock.map((item, index) => {
return index
})
this.dataSourceSpectrum_B = this.allData.bspectrumBlock.bspectrumSubBlock
this.dataSourceSpectrumX_B = this.allData.bspectrumBlock.bspectrumSubBlock.map((item, index) => {
this.dataSourceSpectrum_B = this.allData.bspectrumBlock&&this.allData.bspectrumBlock.bspectrumSubBlock
this.dataSourceSpectrumX_B = this.allData.bspectrumBlock&&this.allData.bspectrumBlock.bspectrumSubBlock.map((item, index) => {
return index
})
this.allData.histogramBlock.histogramSubBlock.forEach(item => {
@ -579,14 +580,15 @@ export default {
}
});
this.dataSourceCertificate = this.allData.certificateBlock ? this.allData.certificateBlock.certificateSubBlock : []
this.getFildBlob()
// this.getFildBlob()
},
methods: {
getFildBlob() {
console.log("afsdfasdfasdfasdfasdf");
let _this = this
let params = {
// sampleId: this.sampleId,
sampleId:"1523651"
sampleId: this.sampleId,
// sampleId:"1523651"
}
let url = "/webStatistics/radionuclideFile"
getAction(url, params).then((res) => {
@ -596,6 +598,31 @@ export default {
_this.zipSrc = window.URL.createObjectURL(blobZip)
})
},
downloadFile(src) {
if (src) {
let link = document.createElement('a')
link.href = src
link.target = '_blank'
link.download = this.type
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
} else {
this.$message.info("File download failed")
}
},
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")
}
},
getUid() {
return (Math.random()+new Date().getTime()).toString(32).slice(0,8)
},

View File

@ -6,21 +6,21 @@
<span style="margin-left: 10px;">return</span>
</div>
<div class="top-actions">
<div class="right-btn">
<a :href="fileSrc" :download="type" target="_blank" rel="noopener noreferrer">
<div class="right-btn" @click="downloadFile">
<!-- <a :href="fileSrc" :download="type" rel="noopener noreferrer"> -->
<img class="icon-download" src="../../assets/images/web-statistics/download.png" alt="">
<span style="margin-left: 10px;">
TXT
</span>
</a>
<!-- </a> -->
</div>
<div class="right-btn">
<a :href="fileSrc" target="_blank" rel="noopener noreferrer">
<div class="right-btn" @click="viewFile">
<!-- <a :href="fileSrc" target="_blank" rel="noopener noreferrer"> -->
<img class="icon-view" src="../../assets/images/web-statistics/view.png" alt="">
<span style="margin-left: 10px;">
View Report
</span>
</a>
<!-- </a> -->
</div>
</div>
</div>
@ -80,7 +80,32 @@ export default {
_this.fileText = reader.result
}
})
}
},
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 {
this.$message.info("File download failed")
}
},
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")
}
},
},
}
</script>