dev_winse
杨树明 6 years ago
parent 9a0c4fa20b
commit 8f453c4ebd

@ -38,30 +38,13 @@ class Fileslistitem extends Component{
}).then((result)=>{
if(result.data.attachment_histories.length===0){
if(result.data.is_pdf===true){
this.props.ShowOnlinePdf(result.data.url)
//预览pdf
// axios({
// method:'get',
// url:result.data.url,
// responseType: 'arraybuffer',
// }).then((result)=>{
// var binaryData = [];
// binaryData.push(result.data);
// this.url =window.URL.createObjectURL(new Blob(binaryData, {type:"application/pdf"}));
// window.open(this.url);
// })
}else{
let link = document.createElement('a');
document.body.appendChild(link);
link.href =result.data.url;
link.download = result.data.title;
//兼容火狐浏览器
let evt = document.createEvent("MouseEvents");
evt.initEvent("click", false, false);
link.dispatchEvent(evt);
document.body.removeChild(link);
}
// if(result.data.is_pdf===true){
// this.props.ShowOnlinePdf(result.data.url)
// //预览pdf
// }else{
//
// }
this.props.DownloadFileA(result.data.title,result.data.url)
}else{
this.setState({
Showoldfiles:true,
@ -146,9 +129,7 @@ class Fileslistitem extends Component{
const { checkBox,
discussMessage,
} = this.props;
return(
<div className="graduateTopicList boardsList">

@ -43,16 +43,6 @@ class Showoldfiles extends Component{
}
showfiless=(url)=>{
// axios({
// method:'get',
// url:url,
// responseType: 'arraybuffer',
// }).then((result)=>{
// var binaryData = [];
// binaryData.push(result.data);
// this.url =window.URL.createObjectURL(new Blob(binaryData, {type:"application/pdf"}));
// window.open(this.url);
// })
this.props.ShowOnlinePdf(url)
}
render(){
@ -188,10 +178,11 @@ class Showoldfiles extends Component{
<div className="clearfix edu-txt-center lineh-40 bor-bottom-greyE" id={allfiles.id}>
<li className="fl fontlefts">
{allfiles.is_pdf===false?
<a className={"isabox"} href={allfiles.url} >{allfiles.title}</a>:
<a className={"isabox"} onClick={()=>this.showfiless(allfiles.url)} >{allfiles.title}</a>
}
<a className={"isabox"} href={allfiles.url} >{allfiles.title}</a>
{/*{allfiles.is_pdf===false?*/}
{/*<a className={"isabox"} href={allfiles.url} >{allfiles.title}</a>:*/}
{/*<a className={"isabox"} onClick={()=>this.showfiless(allfiles.url)} >{allfiles.title}</a>*/}
{/*}*/}
<span className={"newcolor-orange fl"}>当前版本</span>
</li>
@ -207,11 +198,11 @@ class Showoldfiles extends Component{
<div className="clearfix edu-txt-center lineh-40 bor-bottom-greyE" id={item.id} key={key}>
<li className="fl fontlefts">
{item.is_pdf===false?
<a className={"isabox"} href={item.url}>{item.title}</a>:
<a className={"isabox"} onClick={()=>this.showfiless(item.url)} >{item.title}</a>
}
<a className={"isabox"} href={item.url}>{item.title}</a>
{/*{item.is_pdf===false?*/}
{/*<a className={"isabox"} href={item.url}>{item.title}</a>:*/}
{/*<a className={"isabox"} onClick={()=>this.showfiless(item.url)} >{item.title}</a>*/}
{/*}*/}
</li>
<li className="fl filesves ">

@ -334,6 +334,17 @@ export function TPMIndexHOC(WrappedComponent) {
window.open(this.url);
})
}
DownloadFileA=(title,url)=>{
let link = document.createElement('a');
document.body.appendChild(link);
link.href =url;
link.download = title;
//兼容火狐浏览器
let evt = document.createEvent("MouseEvents");
evt.initEvent("click", false, false);
link.dispatchEvent(evt);
document.body.removeChild(link);
}
render() {
let{Headertop,Footerdown, isRender, AccountProfiletype}=this.state;
const common = {
@ -351,7 +362,8 @@ export function TPMIndexHOC(WrappedComponent) {
checkIfLogin: this.checkIfLogin,
showProfileCompleteDialog: this.showProfileCompleteDialog,
checkIfProfileCompleted: this.checkIfProfileCompleted,
ShowOnlinePdf:(url)=>this.ShowOnlinePdf(url)
ShowOnlinePdf:(url)=>this.ShowOnlinePdf(url),
DownloadFileA:(title,url)=>this.DownloadFileA(title,url),
}
return (
<div>

Loading…
Cancel
Save