|
|
|
@ -28,16 +28,24 @@ class Fileslistitem extends Component{
|
|
|
|
|
this.props.Settingtypes(discussMessage.id)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
downloadfiles=(url,name)=>{
|
|
|
|
|
const aLink = document.createElement('a');
|
|
|
|
|
aLink.style.display='none';
|
|
|
|
|
console.log(name)
|
|
|
|
|
aLink.setAttribute('download',name)
|
|
|
|
|
aLink.href = url;
|
|
|
|
|
document.body.appendChild(aLink);
|
|
|
|
|
aLink.click();
|
|
|
|
|
// document.body.removeChild(aLink);
|
|
|
|
|
downloadfiles=(url)=>{
|
|
|
|
|
axios.get((url),{responseType: 'blob'}).then((response) => {
|
|
|
|
|
const blob = new Blob([response.data]);
|
|
|
|
|
const downloadElement = document.createElement('a');
|
|
|
|
|
const href = window.URL.createObjectURL(blob);
|
|
|
|
|
// const string = Base64.decode(response.headers['content-disposition'].split('=')[1]);
|
|
|
|
|
const string = response.headers['content-disposition'].split('=')[1];
|
|
|
|
|
downloadElement.href = href;
|
|
|
|
|
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)=>{
|
|
|
|
|
let {discussMessage,coursesId}=this.props
|
|
|
|
|
let file_id=discussMessage.id
|
|
|
|
@ -47,16 +55,14 @@ class Fileslistitem extends Component{
|
|
|
|
|
course_id:coursesId
|
|
|
|
|
},
|
|
|
|
|
}).then((result)=>{
|
|
|
|
|
|
|
|
|
|
if(result.data.attachment_histories.length===0){
|
|
|
|
|
this.downloadfiles(result.data.url,result.data.title)
|
|
|
|
|
this.downloadfiles(result.data.url)
|
|
|
|
|
}else{
|
|
|
|
|
this.setState({
|
|
|
|
|
Showoldfiles:true,
|
|
|
|
|
allfiles:result.data
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}).catch((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>
|
|
|
|
|
:""
|
|
|
|
|
}
|
|
|
|
|
:<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 ?
|
|
|
|
|
<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>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
:""
|
|
|
|
|