hjm 5 years ago
commit 09a3e14dd0

@ -28,16 +28,24 @@ class Fileslistitem extends Component{
this.props.Settingtypes(discussMessage.id) this.props.Settingtypes(discussMessage.id)
} }
downloadfiles=(url,name)=>{ downloadfiles=(url)=>{
const aLink = document.createElement('a'); axios.get((url),{responseType: 'blob'}).then((response) => {
aLink.style.display='none'; const blob = new Blob([response.data]);
console.log(name) const downloadElement = document.createElement('a');
aLink.setAttribute('download',name) const href = window.URL.createObjectURL(blob);
aLink.href = url; // const string = Base64.decode(response.headers['content-disposition'].split('=')[1]);
document.body.appendChild(aLink); const string = response.headers['content-disposition'].split('=')[1];
aLink.click(); downloadElement.href = href;
// document.body.removeChild(aLink); downloadElement.download = string;
document.body.appendChild(downloadElement);
downloadElement.click();
document.body.removeChild(downloadElement) ;// 下载完成移除元素
window.URL.revokeObjectURL(href) // 释放掉blob对象
}).catch((error) => {
console.log(error)
});
} }
showfiles=(value)=>{ showfiles=(value)=>{
let {discussMessage,coursesId}=this.props let {discussMessage,coursesId}=this.props
let file_id=discussMessage.id let file_id=discussMessage.id
@ -47,16 +55,14 @@ class Fileslistitem extends Component{
course_id:coursesId course_id:coursesId
}, },
}).then((result)=>{ }).then((result)=>{
if(result.data.attachment_histories.length===0){ if(result.data.attachment_histories.length===0){
this.downloadfiles(result.data.url,result.data.title) this.downloadfiles(result.data.url)
}else{ }else{
this.setState({ this.setState({
Showoldfiles:true, Showoldfiles:true,
allfiles:result.data allfiles:result.data
}) })
} }
}).catch((error)=>{ }).catch((error)=>{
console.log(error) console.log(error)
}) })
@ -208,15 +214,19 @@ class Fileslistitem extends Component{
} }
{ {
this.props.isNotMember ? this.props.isNotMember===true?
discussMessage.is_lock === true ?
<span className="fl mt3 font-16 font-bd color-dark maxwidth580">{discussMessage.title}</span> <span className="fl mt3 font-16 font-bd color-dark maxwidth580">{discussMessage.title}</span>
:"" :<a
onClick={()=>this.showfiles(discussMessage.title)}
title={discussMessage.title}
className="fl mt3 font-16 font-bd color-dark maxwidth580">{discussMessage.title}</a>:""
} }
{ {
discussMessage.is_lock === true ? discussMessage.is_lock === true ?
<Tooltip title={ this.props.isNotMember?"私有属性,非课堂成员不能访问":"私有属性"} placement="bottom"> <Tooltip title={ this.props.isNotMember===true?"私有属性,非课堂成员不能访问":"私有属性"} placement="bottom">
<i className="iconfont icon-guansuo color-grey-c ml10 font-16 fl mt4"></i> <i className="iconfont icon-guansuo color-grey-c ml10 font-16 fl mt4"></i>
</Tooltip> </Tooltip>
:"" :""

@ -107,9 +107,9 @@ class ExerciseListItem extends Component{
} }
{ {
this.props.isNotMember()? this.props.isNotMember()? item.lock_status === 0 ?
<span className="fl mt3 font-16 font-bd color-dark comnonwidth580" title={item.exercise_name}>{item.exercise_name}</span> <span className="fl mt3 font-16 font-bd color-dark comnonwidth580" title={item.exercise_name}>{item.exercise_name}</span>
:"" : <a className="fl font-16 font-bd mt2 color-grey-3 task-hide comnonwidth580" title={item.exercise_name} href={`/courses/${coursesId}/exercises/${item.id}/student_exercise_list?tab=0`}>{item.exercise_name}</a>:""
} }
{ {

@ -229,15 +229,17 @@ class GraduateTaskItem extends Component{
} }
{ {
this.props.isNotMember? this.props.isNotMember===true?this.props.discussMessage.private_icon===true?
<span className="fl mt3 font-16 font-bd color-dark maxwidth580" title={discussMessage.name}>{discussMessage.name}</span> <span className="fl mt3 font-16 font-bd color-dark maxwidth580" title={discussMessage.name}>{discussMessage.name}</span>
:"" :<a href={"/courses/"+coursesId+"/graduation_tasks/"+categoryid+"/"+taskid+"/list"}
title={discussMessage.name}
className="fl mt3 font-16 font-bd color-dark maxwidth580">{discussMessage.name}</a>:""
} }
{ {
this.props.discussMessage.private_icon===true? this.props.discussMessage.private_icon===true?
<Tooltip title={ this.props.isNotMember?"私有属性,非课堂成员不能访问":"私有属性"} placement="bottom"> <Tooltip title={ this.props.isNotMember===true?"私有属性,非课堂成员不能访问":"私有属性"} placement="bottom">
<i className="iconfont icon-guansuo color-grey-c ml10 font-16 fl mt4"></i> <i className="iconfont icon-guansuo color-grey-c ml10 font-16 fl mt4"></i>
</Tooltip> </Tooltip>
: :

@ -3,8 +3,7 @@ import axios from 'axios';
// 导出实习报告批量zip 、xlsx 类型 // 导出实习报告批量zip 、xlsx 类型
export function Internshipreportsy (url,struy,types,stingtype){ export function Internshipreportsy (url,struy,types,stingtype,response){
axios.get((url),{responseType: 'blob'}).then((response) => {
const blob = new Blob([response.data], { type: stingtype }); const blob = new Blob([response.data], { type: stingtype });
const downloadElement = document.createElement('a'); const downloadElement = document.createElement('a');
const href = window.URL.createObjectURL(blob); const href = window.URL.createObjectURL(blob);
@ -15,7 +14,4 @@ export function Internshipreportsy (url,struy,types,stingtype){
downloadElement.click(); downloadElement.click();
document.body.removeChild(downloadElement) ;// 下载完成移除元素 document.body.removeChild(downloadElement) ;// 下载完成移除元素
window.URL.revokeObjectURL(href) // 释放掉blob对象 window.URL.revokeObjectURL(href) // 释放掉blob对象
}).catch((error) => {
console.log(error)
});
} }

@ -1355,11 +1355,11 @@ class Listofworks extends Component {
}else if(response.data.status&&response.data.status===-2){ }else if(response.data.status&&response.data.status===-2){
}else { }else {
if(type === 1){ // if(type === 1){
Internshipreportsy(url,struy,".zip",'application/zip'); // Internshipreportsy(url,struy,".zip",'application/zip');
}else{ // }else{
Internshipreportsy(url,struy,".xlsx",'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); Internshipreportsy(url,struy,".xlsx",'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',response);
} // }
} }
} }
}).catch((error) => { }).catch((error) => {

@ -304,15 +304,16 @@ class ShixunhomeWorkItem extends Component{
} }
{ {
this.props.isNotMember? this.props.isNotMember===true? this.props.discussMessage.private_icon===true?
<span className="fl mt3 font-16 font-bd color-dark maxwidth580">{discussMessage.name}</span> <span className="fl mt3 font-16 font-bd color-dark maxwidth580">{discussMessage.name}</span>
:"" : <Link to={`/courses/${this.props.match.params.coursesId}/${this.state.shixuntypes}/${discussMessage.homework_id}/openlist`}
className="fl mt3 font-16 font-bd color-dark maxwidth580">{discussMessage.name}</Link>:""
} }
{ {
this.props.discussMessage.private_icon===true? this.props.discussMessage.private_icon===true?
<Tooltip title={ this.props.isNotMember?"私有属性,非课堂成员不能访问":"私有属性"} placement="bottom"> <Tooltip title={ this.props.isNotMember===true?"私有属性,非课堂成员不能访问":"私有属性"} placement="bottom">
<i className="iconfont icon-guansuo color-grey-c ml10 font-16 fl mt4"></i> <i className="iconfont icon-guansuo color-grey-c ml10 font-16 fl mt4"></i>
</Tooltip> </Tooltip>
: :

Loading…
Cancel
Save