From 4823030923005aaa85c41ffc715a79619ee251ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Thu, 6 Feb 2020 17:19:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E8=A7=86=E9=A2=91=E5=9C=B0?= =?UTF-8?q?=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/courses/Resource/Fileslistitem.js | 518 ++++++++++-------- .../courses/coursesPublic/Showoldfiles.js | 31 +- 2 files changed, 325 insertions(+), 224 deletions(-) diff --git a/public/react/src/modules/courses/Resource/Fileslistitem.js b/public/react/src/modules/courses/Resource/Fileslistitem.js index e7e31baab..d6f4ec7a1 100644 --- a/public/react/src/modules/courses/Resource/Fileslistitem.js +++ b/public/react/src/modules/courses/Resource/Fileslistitem.js @@ -1,102 +1,152 @@ import React,{ Component } from "react"; -import { WordsBtn } from 'educoder'; -import {Tooltip,message} from 'antd'; +import { WordsBtn,ActionBtn,getUrl } from 'educoder'; +import {Tooltip,message,Input, Button} from 'antd'; import {Link} from 'react-router-dom'; -import {getImageUrl} from 'educoder'; import axios from 'axios' -import {getUrl} from 'educoder'; +import {} from 'educoder'; import moment from 'moment' import CoursesListType from '../coursesPublic/CoursesListType'; import Showoldfiles from "../coursesPublic/Showoldfiles"; import Modals from '../../modals/Modals'; - +import HeadlessModal from '../../user/usersInfo/common/HeadlessModal' +import ClipboardJS from 'clipboard' +import '../../user/usersInfo/video/InfosVideo.css' +let _clipboard = null; +let getUrls=getUrl(); 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=(list)=>{ - if(this.props.checkIfLogin()===false){ - this.props.showLoginDialog() - return - } - // if(this.props.checkIfProfileCompleted()===false){ - // this.setState({ - // AccountProfiletype:true - // }) - // return - // } - // if(this.props.checkIfProfessionalCertification()===false){ - // this.props.showProfileCompleteDialog() - // return - // } - - if(list.is_history_file===false){ - // this.props.DownloadFileA(list.title,list.url) - //window.location.href=list.url; - window.open(list.url, '_blank'); + constructor(props){ + super(props); + this.state = { + videoModalObj:false, + file_url:"", + } + } + setVisible=(bool)=>{ + this.setState({ + videoModalObj:bool + }) + } + + settingList=()=>{ + let {discussMessage}=this.props + + this.setState({ + discussMessageid:discussMessage.id + }) + this.props.Settingtypes(discussMessage.id) + } + + showfiles=(list)=>{ + // console.log("showfiles"); + // console.log(list); + + if(this.props.checkIfLogin()===false){ + this.props.showLoginDialog() + return + } + // if(this.props.checkIfProfileCompleted()===false){ + // this.setState({ + // AccountProfiletype:true + // }) + // return + // } + // if(this.props.checkIfProfessionalCertification()===false){ + // this.props.showProfileCompleteDialog() + // return + // } + + if(list.is_history_file===false){ + // this.props.DownloadFileA(list.title,list.url) + //window.location.href=list.url; + if(list.content_type){ + if(list.content_type==="video/mp4"){ + this.setState({ + videoModalObj:true, + file_url:getUrls+list.url+'?file_name='+list.title, + }) + return + }else{ + window.open(list.url, '_blank'); + } + }else{ - 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){ - // if(result.data.is_pdf===true){ - // this.props.ShowOnlinePdf(result.data.url) - // //预览pdf - // }else{ - // - // } - // this.props.DownloadFileA(result.data.title,result.data.url) - window.open(list.url, '_blank'); + window.open(list.url, '_blank'); + } + }else{ + 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){ + // if(result.data.is_pdf===true){ + // this.props.ShowOnlinePdf(result.data.url) + // //预览pdf + // }else{ + // + // } + // this.props.DownloadFileA(result.data.title,result.data.url) + if(list.content_type){ + if(list.content_type==="video/mp4"){ + this.setState({ + videoModalObj:true, + file_url:getUrls+list.url+'?file_name='+list.title, + }) + return + }else{ + window.open(list.url, '_blank'); + } + }else{ - this.setState({ - Showoldfiles:true, - allfiles:result.data - }) + window.open(list.url, '_blank'); } - }).catch((error)=>{ - console.log(error) - }) - } + }else{ + this.setState({ + Showoldfiles:true, + allfiles:result.data + }) + } - } - closaoldfilesprops=()=>{ - this.setState({ - Showoldfiles:false, - }) - } + }).catch((error)=>{ + console.log(error) + }) + } - onDelete = (id) => { + } + + closaoldfilesprops=()=>{ + this.setState({ + Showoldfiles:false, + }) + } + Clicktobroadcastthevideo=(bool,url)=>{ this.setState({ - Modalstype:true, - Modalstopval:"是否确认删除?", - ModalCancel:this.cancelmodel, - ModalSave:()=>this.savedelete(id), - }) + videoModalObj:bool, + file_url:getUrls+url, + }) + } - } + + + + onDelete = (id) => { + + this.setState({ + Modalstype:true, + Modalstopval:"是否确认删除?", + ModalCancel:this.cancelmodel, + ModalSave:()=>this.savedelete(id), + }) + + } cancelmodel=()=>{ @@ -111,6 +161,17 @@ class Fileslistitem extends Component{ } + copyurls =()=>{ + //复制网络链接 + setTimeout(() => { + if (!_clipboard) { + _clipboard = new ClipboardJS('.copybtn'); + _clipboard.on('success', (e) => { + this.props.showNotification("复制成功"); + }); + } + }, 200) + } savedelete=(id)=>{ this.setState({ @@ -145,37 +206,61 @@ class Fileslistitem extends Component{ .catch(function (error) { console.log(error); }); - } - - eventStop = (event) =>{ - event.stopPropagation() - } + } + + eventStop = (event) =>{ + event.stopPropagation() + } render(){ + const {videoModalObj,file_url}=this.state + const { checkBox, + discussMessage,index + } = this.props; + + return( +
*/} - {/*{discussMessage.course_groups.map((item,key)=>{*/} - {/*return(*/} - {/*
+ } + + {/*资源分班*/} + {/*{discussMessage.course_groups.length===0?"":*/} + {/*
*/} + {/*{discussMessage.course_groups.map((item,key)=>{*/} + {/*return(*/} + {/*
{discussMessage.author.name}
大小 {discussMessage.filesize}
下载 {discussMessage.downloads_count}
- {/*引用 {discussMessage.quotes}*/}
-
+ {/*引用 {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')}
+ {/*{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')}
- {discussMessage&&discussMessage.category_name===null?"":this.props.child===false?
- - 资源描述 :{discussMessage.description===null?"暂无描述":discussMessage.description} - {/**/} - {/*/!**!/*/} - {/**/} - - {/**/} - {/*/!*{this.props.isAdmin ?this.settingList()}>:""}*!/*/} - {/**/} -
- - -