dev_forum
杨树林 5 years ago
parent a7e6972e76
commit a033d5c406

@ -1353,11 +1353,15 @@ class Listofworks extends Component {
var blob = new Blob([response.data])
var downloadElement = document.createElement('a');
var href = window.URL.createObjectURL(blob); //创建下载的链接
let filename = response.headers.get('Content-Disposition');
if (filename) {
filename = filename.match(/\"(.*)\"/)[1]; //提取文件名
downloadElement.href = href;
downloadElement.download = '实习报告.pdf'; //下载后文件名
downloadElement.download = filename; //下载后文件名
document.body.appendChild(downloadElement);
downloadElement.click(); //点击下载
document.body.removeChild(downloadElement); //下载完成移除元素
}
window.URL.revokeObjectURL(href); //释放掉blob对象
}).catch((error) => {
console.log(error)
@ -1377,15 +1381,31 @@ class Listofworks extends Component {
},{responseType: 'blob'}).then((response) => {
console.log("1306");
console.log(response);
// if (response.status == 200) {
// let url = window.URL.createObjectURL(new Blob([response.data]))
// let link = document.createElement('a')
// link.style.display = 'none'
// link.href = url
// link.setAttribute('download', fileName) // 自定义下载文件名如exemple.txt
// document.body.appendChild(link)
// link.click()
// }
var blob = new Blob([response.data])
var downloadElement = document.createElement('a');
var href = window.URL.createObjectURL(blob); //创建下载的链接
let filename = response.headers.get('Content-Disposition');
if (filename) {
filename = filename.match(/\"(.*)\"/)[1]; //提取文件名
downloadElement.href = href;
downloadElement.download = '课堂学生成绩.xlsx'; //下载后文件名
downloadElement.download = filename; //下载后文件名
document.body.appendChild(downloadElement);
downloadElement.click(); //点击下载
document.body.removeChild(downloadElement); //下载完成移除元素
}
window.URL.revokeObjectURL(href); //释放掉blob对象
}).catch((error) => {
console.log(error)
});

@ -1616,14 +1616,26 @@ class Trainingjobsetting extends Component {
params: {
homework_common_id: homeworkid,
}
}).then((response) => {
console.log("1593");
},{responseType: 'blob'}).then((response) => {
console.log("326");
console.log(response);
var blob = new Blob([response.data])
var downloadElement = document.createElement('a');
var href = window.URL.createObjectURL(blob); //创建下载的链接
let filename = response.headers.get('Content-Disposition');
if (filename) {
filename = filename.match(/\"(.*)\"/)[1]; //提取文件名
downloadElement.href = href;
downloadElement.download = filename; //下载后文件名
document.body.appendChild(downloadElement);
downloadElement.click(); //点击下载
document.body.removeChild(downloadElement); //下载完成移除元素
}
window.URL.revokeObjectURL(href); //释放掉blob对象
}).catch((error) => {
console.log(error)
});
}
// 课堂学生成绩的导出下载
@ -1631,9 +1643,22 @@ class Trainingjobsetting extends Component {
console.log("Classstudentachievement");
const course_id = this.props.match.params.coursesId;
let url = "/courses/" + course_id + "/export_member_scores_excel.xlsx";
axios.get(url).then((response) => {
console.log("1607");
axios.get((url),{responseType: 'blob'}).then((response) => {
console.log("339");
console.log(response);
var blob = new Blob([response.data])
var downloadElement = document.createElement('a');
var href = window.URL.createObjectURL(blob); //创建下载的链接
let filename = response.headers.get('Content-Disposition');
if (filename) {
filename = filename.match(/\"(.*)\"/)[1]; //提取文件名
downloadElement.href = href;
downloadElement.download = filename; //下载后文件名
document.body.appendChild(downloadElement);
downloadElement.click(); //点击下载
document.body.removeChild(downloadElement); //下载完成移除元素
}
window.URL.revokeObjectURL(href); //释放掉blob对象
}).catch((error) => {
console.log(error)

@ -327,9 +327,22 @@ class Workquestionandanswer extends Component {
params: {
homework_common_id: homeworkid,
}
}).then((response) => {
},{responseType: 'blob'}).then((response) => {
console.log("326");
console.log(response);
var blob = new Blob([response.data])
var downloadElement = document.createElement('a');
var href = window.URL.createObjectURL(blob); //创建下载的链接
let filename = response.headers.get('Content-Disposition');
if (filename) {
filename = filename.match(/\"(.*)\"/)[1]; //提取文件名
downloadElement.href = href;
downloadElement.download = filename; //下载后文件名
document.body.appendChild(downloadElement);
downloadElement.click(); //点击下载
document.body.removeChild(downloadElement); //下载完成移除元素
}
window.URL.revokeObjectURL(href); //释放掉blob对象
}).catch((error) => {
console.log(error)
@ -341,9 +354,22 @@ class Workquestionandanswer extends Component {
console.log("Classstudentachievement");
const course_id = this.props.match.params.coursesId;
let url = "/courses/" + course_id + "/export_member_scores_excel.xlsx";
axios.get(url).then((response) => {
axios.get((url),{responseType: 'blob'}).then((response) => {
console.log("339");
console.log(response);
var blob = new Blob([response.data])
var downloadElement = document.createElement('a');
var href = window.URL.createObjectURL(blob); //创建下载的链接
let filename = response.headers.get('Content-Disposition');
if (filename) {
filename = filename.match(/\"(.*)\"/)[1]; //提取文件名
downloadElement.href = href;
downloadElement.download = filename; //下载后文件名
document.body.appendChild(downloadElement);
downloadElement.click(); //点击下载
document.body.removeChild(downloadElement); //下载完成移除元素
}
window.URL.revokeObjectURL(href); //释放掉blob对象
}).catch((error) => {
console.log(error)

Loading…
Cancel
Save