import React,{ Component } from "react"; import { WordsBtn } from 'educoder'; import {Tooltip,message} from 'antd'; import {Link} from 'react-router-dom'; import {getImageUrl} from 'educoder'; import axios from 'axios' import {getUrl} from 'educoder'; import moment from 'moment'; import CoursesListType from '../coursesPublic/CoursesListType'; import Showoldfiles from "../coursesPublic/Showoldfiles"; import Modals from '../../modals/Modals'; class Fileslistitem extends Component{ constructor(props){ super(props); this.state = { } } settingList=()=>{ let {discussMessage}=this.props this.setState({ discussMessageid:discussMessage.id }) this.props.Settingtypes(discussMessage.id) } showfiles=()=>{ let {discussMessage,coursesId}=this.props let file_id=discussMessage.id let url="/files/"+file_id+"/histories.json" axios.get(url,{ params:{ course_id:coursesId }, }).then((result)=>{ if(result.data.attachment_histories.length===0){ 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); // // window.location.href=result.data.url; // let url = window.URL.createObjectURL(new Blob([result.data.url])); // let link = document.createElement('a'); // link.style.display = 'none'; // link.href = url; // link.setAttribute('download',result.data.title); // document.body.appendChild(link); // link.click(); }else{ this.setState({ Showoldfiles:true, allfiles:result.data }) } // console.log(result) }).catch((error)=>{ console.log(error) }) } closaoldfilesprops=()=>{ this.setState({ Showoldfiles:false, }) } onDelete = (id) => { this.setState({ Modalstype:true, Modalstopval:"是否确认删除?", ModalCancel:this.cancelmodel, ModalSave:()=>this.savedelete(id), }) } cancelmodel=()=>{ this.setState({ Modalstype:false, Loadtype:false, Modalstopval:"", ModalCancel:"", ModalSave:"", checkBoxValues:[], }) } savedelete=(id)=>{ this.setState({ Modalstype:false, }) const cid = this.props.match.params.coursesId const url = `/files/bulk_delete.json`; axios.delete(url, { data: { course_id:cid, ids: [id], }}) .then((response) => { if (response.data.status == 0) { //Modalstopval:response.data.message, this.props.updatafiledfun() this.setState({ // Modalstype:true, // Modalstopval:"删除成功", ModalsBottomval:"", // ModalSave:this.cancelmodel, // Loadtype:true, checkBoxValues:[], checkAllValue:false }) this.props.showNotification("删除成功"); } }) .catch(function (error) { console.log(error); }); } render(){ const { checkBox, discussMessage, } = this.props; return(
{discussMessage.course_groups.map((item,key)=>{ return(
{discussMessage.author.login}
大小 {discussMessage.filesize}
下载 {discussMessage.downloads_count}
引用 {discussMessage.quotes}
{/*{moment(discussMessage.publish_time).format('YYYY-MM-DD HH:mm:ss')}*/}
{/*{moment(discussMessage.publish_time).fromNow()}*/}
{ discussMessage.publish_time===null?"":
discussMessage.is_publish===true?"":"发布于"}
{ discussMessage.publish_time===null?"":discussMessage.is_publish===true?moment(discussMessage.publish_time).fromNow():moment(discussMessage.publish_time).format('YYYY-MM-DD HH:mm')}
{this.props.isAdmin?
资源描述 :{discussMessage.description===null?"暂无描述":discussMessage.description}{/**/} {/*/!**!/*/} {/**/} {/**/} {/*/!*{this.props.isAdmin ?this.settingList()}>:""}*!/*/} {/**/}