|
|
@ -1,85 +1,85 @@
|
|
|
|
import React,{ Component } from "react";
|
|
|
|
import React, { Component } from "react";
|
|
|
|
import { Radio , Modal } from 'antd';
|
|
|
|
import { Radio, Modal } from 'antd';
|
|
|
|
import './video.css';
|
|
|
|
import './video.css';
|
|
|
|
import axios from 'axios';
|
|
|
|
import axios from 'axios';
|
|
|
|
class MoveBox extends Component{
|
|
|
|
class MoveBox extends Component {
|
|
|
|
constructor(props){
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
super(props);
|
|
|
|
this.state={
|
|
|
|
this.state = {
|
|
|
|
data:undefined,
|
|
|
|
data: undefined,
|
|
|
|
selectSubId:undefined
|
|
|
|
selectSubId: undefined
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
componentDidUpdate=(prevProps)=>{
|
|
|
|
componentDidUpdate = (prevProps) => {
|
|
|
|
if(this.props.id && this.props.visible && this.props.id !== prevProps.id){
|
|
|
|
if (this.props.id && this.props.visible && this.props.id !== prevProps.id) {
|
|
|
|
this.getSubList(this.props.mainId);
|
|
|
|
this.getSubList(this.props.mainId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
getSubList=(id)=>{
|
|
|
|
getSubList = (id) => {
|
|
|
|
const url = `/course_modules/${id}.json`;
|
|
|
|
const url = `/course_modules/${id}.json`;
|
|
|
|
axios.get(url).then(result=>{
|
|
|
|
axios.get(url).then(result => {
|
|
|
|
if(result){
|
|
|
|
if (result) {
|
|
|
|
let list = result.data.course_module && result.data.course_module.course_second_categories;
|
|
|
|
let list = result.data.course_module && result.data.course_module.course_second_categories;
|
|
|
|
let defaultId = list.length>0 ? list[0].id : undefined;
|
|
|
|
let defaultId = list.length > 0 ? list[0].id : undefined;
|
|
|
|
this.setState({
|
|
|
|
this.setState({
|
|
|
|
data:result.data.course_module,
|
|
|
|
data: result.data.course_module,
|
|
|
|
selectSubId:defaultId
|
|
|
|
selectSubId: defaultId
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}).catch(error=>{
|
|
|
|
}).catch(error => {
|
|
|
|
console.log(error);
|
|
|
|
console.log(error);
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cancelMove=()=>{
|
|
|
|
cancelMove = () => {
|
|
|
|
const { setMoveVisible } = this.props;
|
|
|
|
const { setMoveVisible } = this.props;
|
|
|
|
setMoveVisible && setMoveVisible(false);
|
|
|
|
setMoveVisible && setMoveVisible(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 选择子目录
|
|
|
|
// 选择子目录
|
|
|
|
selectSub=(e)=>{
|
|
|
|
selectSub = (e) => {
|
|
|
|
this.setState({
|
|
|
|
this.setState({
|
|
|
|
selectSubId:e.target.value
|
|
|
|
selectSubId: e.target.value
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
handleSubmit=()=>{
|
|
|
|
handleSubmit = () => {
|
|
|
|
const CourseId = this.props.match.params.coursesId;
|
|
|
|
const CourseId = this.props.match.params.coursesId;
|
|
|
|
const { id } = this.props;
|
|
|
|
const { id } = this.props;
|
|
|
|
const { selectSubId } = this.state;
|
|
|
|
const { selectSubId } = this.state;
|
|
|
|
const url = `/courses/${CourseId}/move_to_category.json`;
|
|
|
|
const url = `/courses/${CourseId}/move_to_category.json`;
|
|
|
|
axios.post(url,{
|
|
|
|
axios.post(url, {
|
|
|
|
video_ids:[id],
|
|
|
|
video_ids: [id],
|
|
|
|
new_category_id:selectSubId
|
|
|
|
new_category_id: selectSubId
|
|
|
|
}).then(result=>{
|
|
|
|
}).then(result => {
|
|
|
|
|
|
|
|
|
|
|
|
if(result){
|
|
|
|
if (result) {
|
|
|
|
|
|
|
|
|
|
|
|
const { setMoveVisible , successFunc , updataleftNavfun} = this.props;
|
|
|
|
const { setMoveVisible, successFunc, updataleftNavfun } = this.props;
|
|
|
|
updataleftNavfun && updataleftNavfun();
|
|
|
|
updataleftNavfun && updataleftNavfun();
|
|
|
|
setMoveVisible && setMoveVisible(false);
|
|
|
|
setMoveVisible && setMoveVisible(false);
|
|
|
|
successFunc && successFunc();
|
|
|
|
successFunc && successFunc();
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
this.props.showNotification(result.data.message);
|
|
|
|
this.props.showNotification(result.data.message);
|
|
|
|
}catch (e) {
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}).catch(error=>{
|
|
|
|
}).catch(error => {
|
|
|
|
console.log(error);
|
|
|
|
console.log(error);
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
render(){
|
|
|
|
render() {
|
|
|
|
const { visible , id } = this.props;
|
|
|
|
const { visible, id } = this.props;
|
|
|
|
const { data , selectSubId } = this.state;
|
|
|
|
const { data, selectSubId } = this.state;
|
|
|
|
|
|
|
|
|
|
|
|
let list = data && data.course_second_categories && data.course_second_categories.length>0?data.course_second_categories:undefined;
|
|
|
|
let list = data && data.course_second_categories && data.course_second_categories.length > 0 ? data.course_second_categories : undefined;
|
|
|
|
|
|
|
|
|
|
|
|
return(
|
|
|
|
return (
|
|
|
|
<Modal
|
|
|
|
<Modal
|
|
|
|
visible={visible}
|
|
|
|
visible={visible}
|
|
|
|
width="560px"
|
|
|
|
width="560px"
|
|
|
@ -116,8 +116,8 @@ class MoveBox extends Component{
|
|
|
|
</style>
|
|
|
|
</style>
|
|
|
|
<Radio.Group onChange={this.selectSub} value={selectSubId}>
|
|
|
|
<Radio.Group onChange={this.selectSub} value={selectSubId}>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
list && list.map((item,key)=>{
|
|
|
|
list && list.map((item, key) => {
|
|
|
|
return(
|
|
|
|
return (
|
|
|
|
<Radio value={item.id} key={item.id}>
|
|
|
|
<Radio value={item.id} key={item.id}>
|
|
|
|
{item.name}
|
|
|
|
{item.name}
|
|
|
|
</Radio>
|
|
|
|
</Radio>
|
|
|
|