接口错误信息提示文案调整,下载预览接口错误消息文案调整

This commit is contained in:
renpy 2023-07-14 16:52:18 +08:00
parent c985ffa6f3
commit b841f8cf6a
23 changed files with 65 additions and 56 deletions

View File

@ -14,7 +14,7 @@
</span> </span>
<!-- </a> --> <!-- </a> -->
</div> </div>
<div class="right-btn" @click="downloadFile(fileSrc)"> <div class="right-btn" @click="downloadFile">
<!-- <a :href="fileSrc" :download="type"> --> <!-- <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;">
@ -584,7 +584,6 @@ export default {
}, },
methods: { methods: {
getFildBlob() { getFildBlob() {
console.log("afsdfasdfasdfasdfasdf");
let _this = this let _this = this
let params = { let params = {
sampleId: this.sampleId, sampleId: this.sampleId,
@ -592,39 +591,45 @@ export default {
} }
let url = "/webStatistics/radionuclideFile" let url = "/webStatistics/radionuclideFile"
getAction(url, params).then((res) => { getAction(url, params).then((res) => {
const blob = new Blob([res], { type: 'text/plain' }) if (res.code&&res.code==500) {
const blobZip = new Blob([res], { type: 'application/zip' }) _this.fileSrc = ""
_this.fileSrc = window.URL.createObjectURL(blob) } else {
_this.zipSrc = window.URL.createObjectURL(blobZip) const blob = new Blob([res], { type: 'text/plain' })
_this.fileSrc = window.URL.createObjectURL(blob)
}
}) })
}, },
downloadFile(src) { downloadFile() {
if (src) { if (this.fileSrc) {
let link = document.createElement('a') let link = document.createElement('a')
link.href = src link.href = this.fileSrc
link.target = '_blank' link.target = '_blank'
link.download = this.type link.download = this.type
document.body.appendChild(link) document.body.appendChild(link)
link.click() link.click()
document.body.removeChild(link) document.body.removeChild(link)
} else { } else {
this.$message.info("File download failed") this.$message.warning("This operation fails. Contact your system administrator")
} }
}, },
downloadZip() { downloadZip() {
getAction('/webStatistics/radionuclideFile',{ getAction('/webStatistics/radionuclideFile',{
sampleId: this.sampleId, sampleId: this.sampleId,
}).then(async res =>{ }).then(async res => {
const arrayBufferView = new Uint8Array(res) if (res.code&&res.code==500) {
const zip = new JSZip() this.$message.warning("This operation fails. Contact your system administrator")
const blob = new Blob([res], { type: 'text/plain' }) } else {
// saveAs(blob, 'files.txt'); const arrayBufferView = new Uint8Array(res)
// ZIP const zip = new JSZip()
zip.file(`${this.type}.txt`, blob, { binary: true }); const blob = new Blob([res], { type: 'text/plain' })
// ZIP // saveAs(blob, 'files.txt');
const zipContent = await zip.generateAsync({ type: 'blob' }); // ZIP
// ZIP zip.file(`${this.type}.txt`, blob, { binary: true });
saveAs(zipContent, this.type); // ZIP
const zipContent = await zip.generateAsync({ type: 'blob' });
// ZIP
saveAs(zipContent, this.type);
}
}) })
}, },
viewFile() { viewFile() {

View File

@ -71,13 +71,17 @@ export default {
let url = this.type === "soh" ? "/webStatistics/sohFile" : "/webStatistics/arFile" let url = this.type === "soh" ? "/webStatistics/sohFile" : "/webStatistics/arFile"
let params = this.type === "soh" ? paramsSoh : paramsRr let params = this.type === "soh" ? paramsSoh : paramsRr
getAction(url, params).then((res) => { getAction(url, params).then((res) => {
const blob = new Blob([res], { type: 'text/plain' }) if (res.code && res.code==500) {
_this.fileSrc = window.URL.createObjectURL(blob) _this.fileSrc = ""
var reader = new FileReader(); } else {
reader.readAsText(blob); const blob = new Blob([res], { type: 'text/plain' })
reader.onload = function(){ _this.fileSrc = window.URL.createObjectURL(blob)
// var reader = new FileReader();
_this.fileText = reader.result reader.readAsText(blob);
reader.onload = function(){
//
_this.fileText = reader.result
}
} }
}) })
}, },
@ -91,7 +95,7 @@ export default {
link.click() link.click()
document.body.removeChild(link) document.body.removeChild(link)
} else { } else {
this.$message.info("File download failed") this.$message.warning("This operation fails. Contact your system administrator")
} }
}, },
viewFile() { viewFile() {

View File

@ -138,7 +138,7 @@ export default {
this.ipagination.total = res.result.total this.ipagination.total = res.result.total
this.dataSource = res.result.records this.dataSource = res.result.records
} else { } else {
this.$message.warning(res.message) this.$message.warning("This operation fails. Contact your system administrator")
} }
}) })
} else { } else {

View File

@ -89,7 +89,7 @@ export default {
this.stationList=[] this.stationList=[]
} }
} else { } else {
this.$message.warning(res.message) this.$message.warning("This operation fails. Contact your system administrator")
} }
}) })

View File

@ -84,7 +84,7 @@ export default {
this.stationList=[] this.stationList=[]
} }
} else { } else {
this.$message.warning(res.message) this.$message.warning("This operation fails. Contact your system administrator")
} }
}) })
}, },

View File

@ -84,7 +84,7 @@ export default {
this.stationList=[] this.stationList=[]
} }
} else { } else {
this.$message.warning(res.message) this.$message.warning("This operation fails. Contact your system administrator")
} }
}) })
}, },

View File

@ -85,7 +85,7 @@ export default {
this.stationList=[] this.stationList=[]
} }
} else { } else {
this.$message.warning(res.message) this.$message.warning("This operation fails. Contact your system administrator")
} }
}) })
}, },

View File

@ -85,7 +85,7 @@ export default {
this.stationList=[] this.stationList=[]
} }
} else { } else {
this.$message.warning(res.message) this.$message.warning("This operation fails. Contact your system administrator")
} }
}) })
}, },

View File

@ -89,7 +89,7 @@ export default {
this.stationList=[] this.stationList=[]
} }
} else { } else {
this.$message.warning(res.message) this.$message.warning("This operation fails. Contact your system administrator")
} }
}) })
}, },

View File

@ -84,7 +84,7 @@ export default {
this.stationList=[] this.stationList=[]
} }
} else { } else {
this.$message.warning(res.message) this.$message.warning("This operation fails. Contact your system administrator")
} }
}) })
}, },

View File

@ -84,7 +84,7 @@ export default {
this.stationList=[] this.stationList=[]
} }
} else { } else {
this.$message.warning(res.message) this.$message.warning("This operation fails. Contact your system administrator")
} }
}) })
}, },

View File

@ -85,7 +85,7 @@ export default {
this.stationList=[] this.stationList=[]
} }
} else { } else {
this.$message.warning(res.message) this.$message.warning("This operation fails. Contact your system administrator")
} }
}) })
}, },

View File

@ -85,7 +85,7 @@ export default {
this.stationList=[] this.stationList=[]
} }
} else { } else {
this.$message.warning(res.message) this.$message.warning("This operation fails. Contact your system administrator")
} }
}) })
}, },

View File

@ -152,7 +152,7 @@ export default {
this.ipagination.total = res.result.total this.ipagination.total = res.result.total
this.dataSource = res.result.records this.dataSource = res.result.records
} else { } else {
this.$message.warning(res.message) this.$message.warning("This operation fails. Contact your system administrator")
} }
}) })
}, },
@ -164,7 +164,7 @@ export default {
this.detailJson = JSON.parse(JSON.stringify(this.detailJson)) this.detailJson = JSON.parse(JSON.stringify(this.detailJson))
this.isDetail = true this.isDetail = true
} else { } else {
this.$message.warning(res.message) this.$message.warning("This operation fails. Contact your system administrator")
} }
}) })
}, },
@ -180,7 +180,7 @@ export default {
this.stationList=[] this.stationList=[]
} }
} else { } else {
this.$message.warning(res.message) this.$message.warning("This operation fails. Contact your system administrator")
} }
}) })
}, },

View File

@ -89,7 +89,7 @@ export default {
this.stationList=[] this.stationList=[]
} }
} else { } else {
this.$message.warning(res.message) this.$message.warning("This operation fails. Contact your system administrator")
} }
}) })
}, },

View File

@ -84,7 +84,7 @@ export default {
this.stationList=[] this.stationList=[]
} }
} else { } else {
this.$message.warning(res.message) this.$message.warning("This operation fails. Contact your system administrator")
} }
}) })
}, },

View File

@ -84,7 +84,7 @@ export default {
this.stationList=[] this.stationList=[]
} }
} else { } else {
this.$message.warning(res.message) this.$message.warning("This operation fails. Contact your system administrator")
} }
}) })
}, },

View File

@ -85,7 +85,7 @@ export default {
this.stationList=[] this.stationList=[]
} }
} else { } else {
this.$message.warning(res.message) this.$message.warning("This operation fails. Contact your system administrator")
} }
}) })
}, },

View File

@ -85,7 +85,7 @@ export default {
this.stationList=[] this.stationList=[]
} }
} else { } else {
this.$message.warning(res.message) this.$message.warning("This operation fails. Contact your system administrator")
} }
}) })
}, },

View File

@ -127,7 +127,7 @@ export default {
this.ipagination.total = res.result.total this.ipagination.total = res.result.total
this.dataSource = res.result.records this.dataSource = res.result.records
} else { } else {
this.$message.warning(res.message) this.$message.warning("This operation fails. Contact your system administrator")
} }
}) })
} else { } else {
@ -143,7 +143,7 @@ export default {
this.stationList=[] this.stationList=[]
} }
} else { } else {
this.$message.warning(res.message) this.$message.warning("This operation fails. Contact your system administrator")
} }
}) })
}, },

View File

@ -138,7 +138,7 @@ export default {
this.ipagination.total = res.result.total this.ipagination.total = res.result.total
this.dataSource = res.result.records this.dataSource = res.result.records
} else { } else {
this.$message.warning(res.message) this.$message.warning("This operation fails. Contact your system administrator")
} }
}) })
} else { } else {
@ -154,7 +154,7 @@ export default {
this.stationList=[] this.stationList=[]
} }
} else { } else {
this.$message.warning(res.message) this.$message.warning("This operation fails. Contact your system administrator")
} }
}) })
}, },

View File

@ -138,7 +138,7 @@ export default {
this.ipagination.total = res.result.total this.ipagination.total = res.result.total
this.dataSource = res.result.records this.dataSource = res.result.records
} else { } else {
this.$message.warning(res.message) this.$message.warning("This operation fails. Contact your system administrator")
} }
}) })
} else { } else {
@ -158,7 +158,7 @@ export default {
this.stationList=[] this.stationList=[]
} }
} else { } else {
this.$message.warning(res.message) this.$message.warning("This operation fails. Contact your system administrator")
} }
}) })
}, },

View File

@ -138,7 +138,7 @@ export default {
this.ipagination.total = res.result.total this.ipagination.total = res.result.total
this.dataSource = res.result.records this.dataSource = res.result.records
} else { } else {
this.$message.warning(res.message) this.$message.warning("This operation fails. Contact your system administrator")
} }
}) })
} else { } else {
@ -158,7 +158,7 @@ export default {
this.stationList=[] this.stationList=[]
} }
} else { } else {
this.$message.warning(res.message) this.$message.warning("This operation fails. Contact your system administrator")
} }
}) })
}, },