dev_forum
杨树林 6 years ago
parent 6e10c1c123
commit 680be1bf0a

@ -1358,23 +1358,22 @@ class Listofworks extends Component {
}else{ }else{
// window.location.href("/api"+url); // window.location.href("/api"+url);
console.log("开始下载zip文件") // console.log("开始下载zip文件")
const type='application/zip'//ZIP文件 const type='application/zip'//ZIP文件
const blob = new Blob([response.data], { type: type }) const blob = new Blob([response.data], { type: type })
const downloadElement = document.createElement('a') const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob) const href = window.URL.createObjectURL(blob)
//后台再header中传文件名 //后台再header中传文件名
console.log(Base64.decode(response.headers['content-disposition'].split('=')[1])); // console.log(Base64.decode(response.headers['content-disposition'].split('=')[1]));
const string = Base64.decode(response.headers['content-disposition'].split('=')[1]); const string = Base64.decode(response.headers['content-disposition'].split('=')[1]);
downloadElement.href = href downloadElement.href = href
var now=""; var now="";
try { try {
now = moment().year()+""+moment().month()+1+""+moment().date()+""+moment().hour()+""+moment().minute()+"" now = moment().year()+""+(moment().month()+1)+""+moment().date()+""+moment().hour()+""+moment().minute()+""
console.log("1422");
console.log(now); console.log(now);
} catch (e) { } catch (e) {
console.log("1432"); console.log("1376");
} }
downloadElement.download = string+now+".zip" downloadElement.download = string+now+".zip"
document.body.appendChild(downloadElement) document.body.appendChild(downloadElement)
@ -1389,20 +1388,6 @@ class Listofworks extends Component {
// 课堂学生成绩的导出下载 // 课堂学生成绩的导出下载
Classstudentachievement=(url)=>{ Classstudentachievement=(url)=>{
console.log("Classstudentachievement"); console.log("Classstudentachievement");
// const course_id = this.props.match.params.coursesId;
// let url = "/courses/"+course_id+"/export_member_scores_excel.xlsx";
// ,{
// params: {
// group_id: this.state.checkedValuesineinfo,
// search: this.state.searchtext,
// }
// },{responseType: 'blob'})
// 56S+5Yy65a+85biIX+iuoeeul+aAnee7tOWvvOiuujIwMTnmmKXlraPor77l,oIJfUHl0aG9u5a6e546w6YCJ5oup,.xls
// console.log(decodeURIComponent("b178a6c387c1dd2d4097b0dcaa19a043_1562205834"));
// console.log(decodeURI("b178a6c387c1dd2d4097b0dcaa19a043_1562205834"));
// console.log(Base64.decode("b178a6c387c1dd2d4097b0dcaa19a043_1562205834"));
// console.log(Base64.decode("56S-5Yy65a-85biIX-iuoeeul-aAnee7tOWvvOiuujIwMTnmmKXlraPor77loIJfUHl0aG9u5a6e546w6YCJ5oup"));
axios.get((url),{responseType: 'blob'}).then((response) => { axios.get((url),{responseType: 'blob'}).then((response) => {
console.log("1374"); console.log("1374");
console.log(response); console.log(response);
@ -1417,16 +1402,12 @@ class Listofworks extends Component {
const downloadElement = document.createElement('a') const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob) const href = window.URL.createObjectURL(blob)
//后台再header中传文件名 //后台再header中传文件名
// const name = decodeURI(response.headers['content-disposition'].split('=')[1]) // console.log("1409");
// console.log(response.headers['content-disposition'].split('=')[1]); // console.log(Base64.decode(response.headers['content-disposition'].split('=')[1]));
// console.log(name);
// console.log(decodeURIComponent(response.headers['content-disposition'].split('=')[1]));
console.log("1409");
console.log(Base64.decode(response.headers['content-disposition'].split('=')[1]));
const string = Base64.decode(response.headers['content-disposition'].split('=')[1]); const string = Base64.decode(response.headers['content-disposition'].split('=')[1]);
var now=""; var now="";
try { try {
now = moment().year()+""+moment().month()+1+""+moment().date()+""+moment().hour()+""+moment().minute()+"" now = moment().year()+""+(moment().month()+1)+""+moment().date()+""+moment().hour()+""+moment().minute()+""
console.log("1422"); console.log("1422");
console.log(now); console.log(now);
@ -1439,7 +1420,6 @@ class Listofworks extends Component {
downloadElement.click() downloadElement.click()
document.body.removeChild(downloadElement) // 下载完成移除元素 document.body.removeChild(downloadElement) // 下载完成移除元素
window.URL.revokeObjectURL(href) // 释放掉blob对象 window.URL.revokeObjectURL(href) // 释放掉blob对象
} }
}).catch((error) => { }).catch((error) => {
console.log(error) console.log(error)

@ -469,7 +469,27 @@ class ShixunStudentWork extends Component {
}else if(response.data.status&&response.data.status===-2){ }else if(response.data.status&&response.data.status===-2){
}else{ }else{
window.open("/api"+url, '_blank'); const type='application/zip'//ZIP文件
const blob = new Blob([response.data], { type: type })
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob)
//后台再header中传文件名
// console.log(Base64.decode(response.headers['content-disposition'].split('=')[1]));
const string = Base64.decode(response.headers['content-disposition'].split('=')[1]);
downloadElement.href = href
var now="";
try {
now = moment().year()+""+(moment().month()+1)+""+moment().date()+""+moment().hour()+""+moment().minute()+""
console.log(now);
} catch (e) {
console.log("1376");
}
downloadElement.download = string+now+".zip"
document.body.appendChild(downloadElement)
downloadElement.click()
document.body.removeChild(downloadElement) // 下载完成移除元素
window.URL.revokeObjectURL(href) // 释放掉blob对象
} }
}).catch((error) => { }).catch((error) => {
@ -491,7 +511,29 @@ class ShixunStudentWork extends Component {
}else if(response.data.status&&response.data.status===-2){ }else if(response.data.status&&response.data.status===-2){
}else{ }else{
window.open("/api"+url, '_blank'); const type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' //excel文件
const blob = new Blob([response.data], { type: type })
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob)
//后台再header中传文件名
// console.log("1409");
// console.log(Base64.decode(response.headers['content-disposition'].split('=')[1]));
const string = Base64.decode(response.headers['content-disposition'].split('=')[1]);
var now="";
try {
now = moment().year()+""+(moment().month()+1)+""+moment().date()+""+moment().hour()+""+moment().minute()+""
console.log("1422");
console.log(now);
} catch (e) {
console.log("1432");
}
downloadElement.href = href
downloadElement.download =string+now+".xlsx";
document.body.appendChild(downloadElement)
downloadElement.click()
document.body.removeChild(downloadElement) // 下载完成移除元素
window.URL.revokeObjectURL(href) // 释放掉blob对象
} }
}).catch((error) => { }).catch((error) => {

@ -17,6 +17,7 @@ import '../css/members.css';
import "../common/formCommon.css"; import "../common/formCommon.css";
import '../css/Courses.css'; import '../css/Courses.css';
import './style.css'; import './style.css';
import moment from "./Trainingjobsetting";
class ShixunWorkReport extends Component { class ShixunWorkReport extends Component {
@ -28,7 +29,47 @@ class ShixunWorkReport extends Component {
spinning:true spinning:true
} }
} }
// 导出实习报告批量
internshipreport = (url) => {
console.log("internshipreport");
// var homeworkid = this.props.match.params.homeworkid;
// let url = "/zip/shixun_report";
axios.get(url).then((response) => {
console.log("326");
console.log(response);
if(response.data.status&&response.data.status===-1){
}else if(response.data.status&&response.data.status===-2){
}else{
const type='application/zip'//ZIP文件
const blob = new Blob([response.data], { type: type })
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob)
//后台再header中传文件名
// console.log(Base64.decode(response.headers['content-disposition'].split('=')[1]));
const string = Base64.decode(response.headers['content-disposition'].split('=')[1]);
downloadElement.href = href
var now="";
try {
now = moment().year()+""+(moment().month()+1)+""+moment().date()+""+moment().hour()+""+moment().minute()+""
console.log(now);
} catch (e) {
console.log("1376");
}
downloadElement.download = string+now+".zip"
document.body.appendChild(downloadElement)
downloadElement.click()
document.body.removeChild(downloadElement) // 下载完成移除元素
window.URL.revokeObjectURL(href) // 释放掉blob对象
}
}).catch((error) => {
console.log(error)
});
}
componentDidMount() { componentDidMount() {
this.setState({ this.setState({
spinning:true spinning:true
@ -93,9 +134,7 @@ class ShixunWorkReport extends Component {
{/*{this.props.isAdmin()?<a className=" fr font-14 ml30 mt10 mr20 color-grey-9 ">导出实训报告数据</a>:""}*/} {/*{this.props.isAdmin()?<a className=" fr font-14 ml30 mt10 mr20 color-grey-9 ">导出实训报告数据</a>:""}*/}
{this.props.isAdmin() ? <a {this.props.isAdmin() ? <a
className="fr color-blue font-16" className="fr color-blue font-16"
href={` onClick={()=>this.internshipreport(`/zip/shixun_report?homework_common_id=${homeworkid}`)}
/api/student_works/${homeworkid}/export_shixun_work_report.pdf
`}
>导出实训报告数据</a> : ""} >导出实训报告数据</a> : ""}
</div> </div>

@ -24,6 +24,7 @@ import './style.css';
import '../css/busyWork.css' import '../css/busyWork.css'
import '../poll/pollStyle.css' import '../poll/pollStyle.css'
import moment from 'moment'; import moment from 'moment';
import 'moment/locale/zh-cn';
import Modals from "../../modals/Modals"; import Modals from "../../modals/Modals";
const RadioGroup = Radio.Group; const RadioGroup = Radio.Group;
@ -1621,7 +1622,27 @@ class Trainingjobsetting extends Component {
}else if(response.data.status&&response.data.status===-2){ }else if(response.data.status&&response.data.status===-2){
}else{ }else{
window.open("/api"+url, '_blank'); const type='application/zip'//ZIP文件
const blob = new Blob([response.data], { type: type })
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob)
//后台再header中传文件名
// console.log(Base64.decode(response.headers['content-disposition'].split('=')[1]));
const string = Base64.decode(response.headers['content-disposition'].split('=')[1]);
downloadElement.href = href
var now="";
try {
now = moment().year()+""+(moment().month()+1)+""+moment().date()+""+moment().hour()+""+moment().minute()+""
console.log(now);
} catch (e) {
console.log("1376");
}
downloadElement.download = string+now+".zip"
document.body.appendChild(downloadElement)
downloadElement.click()
document.body.removeChild(downloadElement) // 下载完成移除元素
window.URL.revokeObjectURL(href) // 释放掉blob对象
} }
}).catch((error) => { }).catch((error) => {
@ -1643,7 +1664,29 @@ class Trainingjobsetting extends Component {
}else if(response.data.status&&response.data.status===-2){ }else if(response.data.status&&response.data.status===-2){
}else{ }else{
window.open("/api"+url, '_blank'); const type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' //excel文件
const blob = new Blob([response.data], { type: type })
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob)
//后台再header中传文件名
// console.log("1409");
// console.log(Base64.decode(response.headers['content-disposition'].split('=')[1]));
const string = Base64.decode(response.headers['content-disposition'].split('=')[1]);
var now="";
try {
now = moment().year()+""+(moment().month()+1)+""+moment().date()+""+moment().hour()+""+moment().minute()+""
console.log("1422");
console.log(now);
} catch (e) {
console.log("1432");
}
downloadElement.href = href
downloadElement.download =string+now+".xlsx";
document.body.appendChild(downloadElement)
downloadElement.click()
document.body.removeChild(downloadElement) // 下载完成移除元素
window.URL.revokeObjectURL(href) // 释放掉blob对象
} }
}).catch((error) => { }).catch((error) => {

@ -23,7 +23,8 @@ import {
notification notification
} from "antd"; } from "antd";
import {Link, Switch, Route, Redirect} from 'react-router-dom'; import {Link, Switch, Route, Redirect} from 'react-router-dom';
import moment from 'moment' import moment from 'moment';
import 'moment/locale/zh-cn';
import axios from 'axios'; import axios from 'axios';
import '../css/members.css' import '../css/members.css'
import "../common/formCommon.css" import "../common/formCommon.css"
@ -332,7 +333,27 @@ class Workquestionandanswer extends Component {
}else if(response.data.status&&response.data.status===-2){ }else if(response.data.status&&response.data.status===-2){
}else{ }else{
window.open("/api"+url, '_blank'); const type='application/zip'//ZIP文件
const blob = new Blob([response.data], { type: type })
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob)
//后台再header中传文件名
// console.log(Base64.decode(response.headers['content-disposition'].split('=')[1]));
const string = Base64.decode(response.headers['content-disposition'].split('=')[1]);
downloadElement.href = href
var now="";
try {
now = moment().year()+""+(moment().month()+1)+""+moment().date()+""+moment().hour()+""+moment().minute()+""
console.log(now);
} catch (e) {
console.log("1376");
}
downloadElement.download = string+now+".zip"
document.body.appendChild(downloadElement)
downloadElement.click()
document.body.removeChild(downloadElement) // 下载完成移除元素
window.URL.revokeObjectURL(href) // 释放掉blob对象
} }
}).catch((error) => { }).catch((error) => {
@ -354,7 +375,29 @@ class Workquestionandanswer extends Component {
}else if(response.data.status&&response.data.status===-2){ }else if(response.data.status&&response.data.status===-2){
}else{ }else{
window.open("/api"+url, '_blank'); const type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' //excel文件
const blob = new Blob([response.data], { type: type })
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob)
//后台再header中传文件名
// console.log("1409");
// console.log(Base64.decode(response.headers['content-disposition'].split('=')[1]));
const string = Base64.decode(response.headers['content-disposition'].split('=')[1]);
var now="";
try {
now = moment().year()+""+(moment().month()+1)+""+moment().date()+""+moment().hour()+""+moment().minute()+""
console.log("1422");
console.log(now);
} catch (e) {
console.log("1432");
}
downloadElement.href = href
downloadElement.download =string+now+".xlsx";
document.body.appendChild(downloadElement)
downloadElement.click()
document.body.removeChild(downloadElement) // 下载完成移除元素
window.URL.revokeObjectURL(href) // 释放掉blob对象
} }
}).catch((error) => { }).catch((error) => {

Loading…
Cancel
Save