Browse Source

异常拦截

master
suyanyan 2 months ago
parent
commit
a498da7206
1 changed files with 29 additions and 19 deletions
  1. +29
    -19
      SafeCampus.WEB/src/views/violation/analysis/index.vue

+ 29
- 19
SafeCampus.WEB/src/views/violation/analysis/index.vue View File

@@ -93,25 +93,35 @@ const onTimeSubmit = ()=>{
startTime: timeForm.dateArr[0],
endTime: timeForm.dateArr[1],
}).then((res:any) => {
console.log(res,"....UTF-8''");
const filename:any = ref()
filename.value = window.decodeURI(res.headers["content-disposition"].split("=")[2]);
filename.value = filename.value.slice(7,-1)
let blobUrl = window.URL.createObjectURL(res.data);
const a = document.createElement('a');
a.style.display = 'none';
a.setAttribute("target", "_blank");
a.download = filename.value
a.href = blobUrl;
a.click();
a.remove();
ElMessage({
message: '导出成功',
type: 'success'
});
closeTime();
});
if(res.headers['content-disposition']){
const filename:any = ref()
filename.value = window.decodeURI(res.headers["content-disposition"].split("=")[2]);
filename.value = filename.value.slice(7,-1)
let blobUrl = window.URL.createObjectURL(res.data);
const a = document.createElement('a');
a.style.display = 'none';
a.setAttribute("target", "_blank");
a.download = filename.value
a.href = blobUrl;
a.click();
a.remove();
ElMessage({
message: '导出成功',
type: 'success'
});
closeTime();
}else{
const fileReader:any = new FileReader()
fileReader.readAsText(new Blob([res.data], { type: 'application/octet-stream' }), 'utf-8')
fileReader.onload = () => {
const result = JSON.parse(fileReader.result)
ElMessage({
message: result.msg,
type: 'error'
});
}
}
})
} else {
return false;


Loading…
Cancel
Save