From c813b6fd44c0f2553fc97b91212c9638a473417b Mon Sep 17 00:00:00 2001 From: caicai8 <1149225589@qq.com> Date: Mon, 10 Feb 2020 15:57:29 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9C=80=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../react/src/modules/courses/Video/Live.js | 7 +- .../src/modules/courses/Video/LiveItem.js | 42 ++++- .../src/modules/courses/Video/LiveNew.js | 144 +++++++++++++----- .../react/src/modules/courses/Video/Video.js | 6 +- .../src/modules/courses/Video/VideoIndex.js | 59 +++++-- .../react/src/modules/courses/Video/video.css | 8 +- .../user/usersInfo/video/VideoUploadList.js | 40 ++--- 7 files changed, 219 insertions(+), 87 deletions(-) diff --git a/public/react/src/modules/courses/Video/Live.js b/public/react/src/modules/courses/Video/Live.js index 71dced679..741339723 100644 --- a/public/react/src/modules/courses/Video/Live.js +++ b/public/react/src/modules/courses/Video/Live.js @@ -7,10 +7,10 @@ import './video.css'; class Live extends Component{ render(){ - const { liveData , lives , successFunc , pageSize , changePage } = this.props; + const { liveData , lives , successFunc , pageSize , changePage , page } = this.props; return( -
+
{ lives && lives.length > 0 ? @@ -20,6 +20,7 @@ class Live extends Component{ lives.map((item,key)=>{ return( pageSize &&
- changePage(page,'live')}> + changePage(page,'live')}>
}
diff --git a/public/react/src/modules/courses/Video/LiveItem.js b/public/react/src/modules/courses/Video/LiveItem.js index e709c41e6..ede737de4 100644 --- a/public/react/src/modules/courses/Video/LiveItem.js +++ b/public/react/src/modules/courses/Video/LiveItem.js @@ -1,6 +1,7 @@ import React,{ Component } from "react"; import { Switch } from 'antd'; import { getImageUrl } from 'educoder'; +import { WordsBtn } from 'educoder'; import axios from 'axios'; class LiveItem extends Component{ @@ -19,10 +20,33 @@ class LiveItem extends Component{ console.log(error); }) } + deleteLive=(id)=>{ + this.props.confirm({ + content: '是否确认删除?', + + onOk: () => { + const url = `/live_links/${id}.json`; + axios.delete(url).then(result=>{ + if(result){ + this.props.showNotification(`删除成功!`); + const { successFunc } = this.props; + successFunc && successFunc(1); + } + }).catch(error=>{ + console.log(error); + }) + }, + onCancel() { + console.log('Cancel'); + }, + }); + + } render(){ - const { item } = this.props; + const { key, item , setLiveId } = this.props; + return( -
+
{`${item.author_name}`} @@ -30,8 +54,8 @@ class LiveItem extends Component{ {item.on_status?'已开播':'未开播'} { - item.op_auth && - this.changeStatus(flag,event,item.id)}> + item.op_auth ? + this.changeStatus(flag,event,item.id)}>:"" }
@@ -45,6 +69,16 @@ class LiveItem extends Component{ 进入 }
+

+ 创建时间:{item.created_at} + { + item.op_auth ? + + setLiveId(item.id)}>编辑 + this.deleteLive(item.id)}>删除 + :"" + } +

) } diff --git a/public/react/src/modules/courses/Video/LiveNew.js b/public/react/src/modules/courses/Video/LiveNew.js index 0e3526b0f..68f784421 100644 --- a/public/react/src/modules/courses/Video/LiveNew.js +++ b/public/react/src/modules/courses/Video/LiveNew.js @@ -1,5 +1,5 @@ import React,{ Component } from "react"; -import { Modal , Form , Input } from 'antd'; +import { Modal , Form , Input , Spin } from 'antd'; import './video.css'; import axios from 'axios'; @@ -7,25 +7,83 @@ const { TextArea } = Input; class LiveNew extends Component{ + constructor(props){ + super(props); + this.state={ + isSpining:true + } + } + + componentDidUpdate=(prevState)=>{ + if(prevState && prevState.liveId !== this.props.liveId){ + this.checkType(); + } + } + + checkType=()=>{ + const { liveId } = this.props; + + if(liveId){ + const url =`/live_links/${liveId}/edit.json`; + axios.get(url).then(result=>{ + if(result){ + this.props.form.setFieldsValue({ + url:result.data.url, + description:result.data.description, + }) + } + }) + } + this.setState({ + isSpining:false + }) + } + handleSubmit=()=>{ this.props.form.validateFields((err, values) => { if(!err){ - const CourseId=this.props.match.params.coursesId; - const url = `/courses/${CourseId}/live_links.json`; - axios.post(url,{ - ...values - }).then(result=>{ - if(result){ - this.props.showNotification("添加成功!"); - const { setliveVisibel } = this.props; - setliveVisibel && setliveVisibel(false,true); - } - }).catch(error=>{ - console.log(error); - }) + const { liveId } = this.props; + if(liveId){ + // 修改 + this.updateFunc(liveId,values); + }else{ + this.creatFunc(values); + } } }) } + // 修改 + updateFunc=(id,values)=>{ + const url = `/live_links/${id}.json`; + axios.put(url,{ + ...values + }).then(result=>{ + if(result){ + this.props.showNotification("修改成功!"); + const { setliveVisibel } = this.props; + setliveVisibel && setliveVisibel(false,true); + } + }).catch(error=>{ + console.log(error); + }) + } + + // 新增 + creatFunc=(values)=>{ + const CourseId=this.props.match.params.coursesId; + const url = `/courses/${CourseId}/live_links.json`; + axios.post(url,{ + ...values + }).then(result=>{ + if(result){ + this.props.showNotification("添加成功!"); + const { setliveVisibel } = this.props; + setliveVisibel && setliveVisibel(false,true); + } + }).catch(error=>{ + console.log(error); + }) + } validateDesc= (rule, value, callback) => { if (value.length > 100) { @@ -44,8 +102,10 @@ class LiveNew extends Component{ } render(){ + const { isSpining } = this.state; const {getFieldDecorator} = this.props.form; const { visible } = this.props; + return( -
-
- - {getFieldDecorator('url', { - rules: [{required: true, message: "请输入第三方直播链接"}], - })( - - )} - - - {getFieldDecorator('description', { - rules: [{ - validator: this.validateDesc, - }], - })( -