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

This commit is contained in:
renpy 2023-07-13 18:29:56 +08:00 committed by orgin
parent 464b5ff3af
commit 0bc99a61fc
2 changed files with 76 additions and 24 deletions

View File

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

View File

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