import React, { Component } from "react";
import { Link } from "react-router-dom";
import axios from 'axios';
import { Checkbox, Modal, Input, Tooltip, notification, Popover, Dropdown, Menu, TreeSelect } from 'antd';
import { DragDropContext, Draggable, Droppable } from 'react-beautiful-dnd';
import Modals from '../../modals/Modals';
import { on, off, trigger } from 'educoder';
import './MainLeftNav.css';
import MyEduChapterupdate from './MyEduChapterupdate';
const CheckboxGroup = Checkbox.Group;


let navidtype = true;
const { SubMenu } = Menu;
const { TreeNode } = TreeSelect;

//a little function to help us with reordering the result
const reorder = (list, startIndex, endIndex) => {
  // console.log(list)
  // console.log(startIndex)
  // console.log(endIndex)
  let newlist = list;
  const result = Array.from(newlist);
  const [removed] = result.splice(startIndex, 1);
  result.splice(endIndex, 0, removed);

  return result;
};

// const getItemStyle = (isDragging, draggableStyle) => ({
//   // change background colour if dragging
//   background: isDragging?'#f1f1f1': '',
//   // styles we need to apply on draggables
//   ...draggableStyle,
// });


class Coursesleftnav extends Component {
  constructor(props) {
    super(props);
    this.state = {
      index: 1,
      addGroup: true,
      navid: undefined,
      sandiantype: undefined,
      twosandiantype: undefined,
      addCheckboxGroup: [],
      Navmodalname: "",
      Navmodalnametype: false,
      Navmodaltypename: "",
      setnavid: "",
      NavmodalValue: "",
      ModalsType: false,
      Modalstopval: "",
      loadtype: false,
      selectnavid: false,
      newselectnavid: undefined,
      positiontype: undefined,
      toopvisible: false,
      toopvisibleindex: undefined,
      toopvisibleindexs: undefined,
      sandiantypes: undefined,
      antIcon: false,
      chapterupdate: false,

      successFunc: undefined,

      //用来判断 是不是资源点击进入的
      Navmodalziyname: '',
      treeData: undefined,
      //默认为0主目录
      parentid: 0,
      //判断3级目录是否显示三个点
      sanshow: '',
      sansandiantype: undefined,
      //新增参数判断打开关闭 默认关闭
      showPreson: false,
      //获取资源id 判断是否选中的事资源来判控
      treeDataid: '',
      //默认值
      treedefaultValue: '',
      dropdownStyleshow: '',
      treeDataname: ''
    }
  }


  // updataleftNav=()=>{
  //
  //   let id=this.props.match.params.coursesId;
  //   let url ="/courses/"+id+"/left_banner.json"
  //   axios.get(url).then((response) => {
  //     if(response!=undefined){
  //       if(response.data&&response.data){
  //         this.setState({
  //           course_modules:response.data.course_modules,
  //           hidden_modules:response.data.hidden_modules,
  //           is_teacher:response.data.is_teacher,
  //         })
  //         this.locationNav(response.data.course_modules)
  //       }
  //     }
  //
  //   })
  // }

  // locationNav=(list)=>{
  //   let filesId=this.props.match.params.Id;
  //   let url=this.props.location.pathname;
  //   var lists=list;
  //
  //
  //   lists.forEach((item,index)=>{
  //     if(item.second_category!=undefined&&item.second_category.length!=0){
  //       item.second_category.forEach((iem,key)=>{
  //         if( parseInt(filesId)===iem.category_id||parseInt(filesId)===item.id){
  //           this.setState({
  //             indexs:index,
  //             url:url
  //           })
  //         }
  //       })
  //     }
  //
  //     if(this.props.match.url===item.category_url){
  //       this.props.coursesidsfun(item.id)
  //     }
  //   })
  //
  // }

  // setcoursesidsfun=()=>{
  //   // let {course_modules} =this.props;
  //   // let lists=course_modules;
  //   // let url=this.props.location.pathname;
  //   // lists.forEach((item,index)=>{
  //   //   if(item.second_category!=undefined&&item.second_category.length!=0){
  //   //     item.second_category.forEach((iem,key)=>{
  //   //       if(url===iem.second_category_url){
  //   //         this.props.coursesidsfun(item.id,"child")
  //   //       }
  //   //     })
  //   //   }
  //   //
  //   //   if(url===item.category_url){
  //   //     this.props.coursesidsfun(item.id,"node")
  //   //   }
  //   // })
  //   // this.props.updataleftNavfun()
  // }

  componentWillUnmount() {
    off('boardAdd', this.boardAddListener)
    off('boardRename', this.boardRenameListener)
    off('groupAdd', this.groupAddListener)
    off('groupRename', this.groupRenameListener)
    off('attachmentAddlog', this.attachmentAddlog)
    off('flieseditDir', this.flieseditDir)
    off('shixun_homeworkadd', this.addshixunchild)
    off('editshixunname', this.editshixunchild)
    off('editshixunmainname', this.editshixunmainname)
    off('videoAdd', this.addVideo)
    off('editVideo', this.editVideo)
    off('addcommon_homeworks', this.addcommon_homeworks)
    off('editcommon_homeworks', this.editcommon_homeworks)
  }
  addshixunchild = (e, data) => {
    this.Navmodalnames(e, 1, "shixun_homework", data);
  }
  editshixunchild = (e, data) => {
    this.Navmodalnames(e, 4, "editSecondname", data.id, data.name);
  }
  addcommon_homeworks = (e, data) => {
    this.Navmodalnames(e, 1, "common_homework", data);
  }
  editcommon_homeworks = (e, data) => {
    this.Navmodalnames(e, 4, "editSecondname", data.id, data.name);
  }
  editshixunmainname = (e, data) => {
    this.Navmodalnames(e, 3, "editname", data.id, data.name);
  }
  boardAddListener = (e, data) => {
    this.Navmodalnames(e, 6, "board", data);
  }
  addVideo = (e, id) => {
    this.Navmodalnames(e, 1, "video", id);
  }
  editVideo = (e, data) => {
    this.setState({
      successFunc: data.update
    })
    this.Navmodalnames(e, 4, "editSecondname", data.id, data.name);
  }
  boardRenameListener = (e, data) => {
    this.Navmodalnames(e, 7, "editSecondname", data.category_id, data.category_name);
  }
  groupAddListener = (e, data) => {
    this.Navmodalnames(e, 2, "course_group", data);
  }
  groupRenameListener = (e, data) => {
    this.Navmodalnames(e, 5, "editSecondname", data.id, data.name);
  }
  attachmentAddlog = (e, data) => {
    this.Navmodalnames(e, 1, "attachment", data.id, data.name, data.coursesecondcategoryid, data.coursesecondcategoryid === undefined ? false : true);
  }
  flieseditDir = (e, data) => {
    this.Navmodalnames(e, 4, "editSecondname", data.id, data.name);
  }

  componentDidMount() {

    this.setState({
      url: this.props.match.url
    })
    on('boardAdd', this.boardAddListener);
    on('boardRename', this.boardRenameListener);
    on('groupAdd', this.groupAddListener);
    on('groupRename', this.groupRenameListener);
    on('attachmentAddlog', this.attachmentAddlog);
    on('flieseditDir', this.flieseditDir);
    on('shixun_homeworkadd', this.addshixunchild);
    on('editshixunname', this.editshixunchild);
    on('editshixunmainname', this.editshixunmainname);
    on('videoAdd', this.addVideo);
    on('editVideo', this.editVideo)
    on('addcommon_homeworks', this.addcommon_homeworks)
    on('editcommon_homeworks', this.editcommon_homeworks)

    let courstype = this.props.match.url;
    courstype = courstype.split('/');

    courstype = courstype[3];

    const query = this.props.location.search;

    // const type = query.split('?type=');
    let category_id;
    if (courstype === "board") {
      category_id = parseInt(this.props.match.params.boardId);
    } else {
      category_id = parseInt(this.props.match.params.category_id);
    }


    // console.log(category_id)

    if (query === "") {
      this.setState({
        navid: 0,
        positiontype: courstype,
        selectnavid: false,
        newselectnavid: parseInt(category_id),
      })
    } else {
      if (isNaN(category_id)) {
        this.setState({
          positiontype: courstype,
          newselectnavid: parseInt(category_id),
          selectnavid: false,
        })
      } else {
        this.setState({
          positiontype: courstype,
          newselectnavid: parseInt(category_id),
          selectnavid: false,
        })
      }

    }

    if (navidtype === false) {
      navidtype = true
    }
    this.props.updataleftNavfun()
  }

  componentDidUpdate = (prevProps) => {
    if (prevProps != this.props) {
      let courstype = this.props.match.url;
      courstype = courstype.split('/');
      courstype = courstype[3];
      const query = this.props.location.search;
      let category_id;
      if (courstype === "board") {
        category_id = parseInt(this.props.match.params.boardId);
      } else {
        category_id = parseInt(this.props.match.params.category_id);
      }
      if (query === "") {
        this.setState({
          positiontype: courstype,
        })
      } else {
        if (isNaN(category_id)) {
          this.setState({
            positiontype: courstype,
          })
        } else {
          this.setState({
            positiontype: courstype,
          })
        }

      }
    }
  }

  //请求接口获取资源列表数据
  getatahcment() {
    let coursesId = this.props.match.params.coursesId;
    let url = "/courses/" + coursesId + "/attahcment_category_list.json";
    axios.get(url, {
      params: {
        no_child: true,
      }

    }).then((response) => {
      if (response != undefined) {
        if (response.data && response.data) {
          if (response.data.status != 401) {

            let tr = response.data.course_modules;
            this.setState({
              treeData: tr
            })
            tr.map((iem, index) => {
              this.setState({
                treeDataid: iem.value,
                treeDataname: iem.title
              })
            })
          }
        }

      }
    })
  }

  setnavid = (e, key, id, type, url) => {
    // this.props.getleftNavid && this.props.getleftNavid(key,type);
    //   let {selectnavid,navid}=this.state;
    //
    //   if(navidtype===true&&selectnavid===false){
    //
    //       if(navid===key){
    //         this.setState({
    //           navid:"",
    //           selectnavid:false,
    //           newselectnavid:id
    //         })
    //       }else{
    //         this.setState({
    //           navid:key,
    //           positiontype:type,
    //           selectnavid:false,
    //           newselectnavid:id
    //         })
    //       }
    //   }else{
    //     // console.log(navidtype)
    //     // console.log(selectnavid)
    //     this.setState({
    //       navid:"",
    //       selectnavid:false,
    //       newselectnavid:id
    //     })
    //   }
    //
    // this.props.updataleftNavfun();
    // this.props.history.replace( url );
    // e.stopPropagation();//阻止冒泡
    this.selectnavid(e, key, id, type, url)
  }

  selectnavid = (e, key, id, type, urls, index) => {

    let { url } = this.state;
    if (urls != url) {
      this.props.updataleftNavfun();
      this.props.history.replace(urls);
    } else {

      if (key === this.props.indexs) {
        this.props.unlocationNavfun(undefined)
      } else {
        this.props.updataleftNavfun();
        this.props.unlocationNavfun(key)
        this.props.history.replace(urls);
      }
    }
    this.setState({
      selectnavid: true,
      newselectnavid: id,
      url: urls,
      indexs: index
    })
    // this.props.history.replace(urls);
    try {
      if (this.props.myinex === true) {
        this.props.Callhomedirectoryornot(true);

      }
    } catch (e) {

    }

    e.stopPropagation();//阻止冒泡

  }
  selectnavids = (e, key, id, type, urls, index, santype) => {

    this.setState({
      selectnavid: true,
      newselectnavid: id,
      url: urls,
      indexs: index
    })
    this.props.updataleftNavfun();
    this.props.history.replace(urls);
    try {
      if (this.props.myinex === true) {
        this.props.Callhomedirectoryornot(true);

      }
    } catch (e) {

    }
    e.stopPropagation();//阻止冒泡
  }


  twosandianshow = (e, key, type) => {

    // console.log("twosandianshow");
    // console.log(key);
    this.setState({
      toopvisibleindexs: key,
      twosandiantype: key,
      toopvisible: false,
      toopvisibleindex: undefined,
      twosandiantypes: type
    })
    e.stopPropagation();//阻止冒泡
  }

  sansandianshow = (e, key, type, name) => {

    // console.log("twosandianshow");
    // console.log(key);
    this.setState({
      toopvisibleindexs: key,
      sansandiantype: key,
      toopvisible: false,
      sanshow: name,
      toopvisibleindex: undefined,
      twosandiantypes: type
    })
    e.stopPropagation();//阻止冒泡
  }


  twosandianshowys = (e, key, type) => {
    // console.log("twosandianshow");
    // console.log(key);
    // console.log(type);
    this.setState({
      toopvisibleindexs: key,
    })
    e.stopPropagation();//阻止冒泡
  }

  sansandianshowys = (e, key, type) => {
    // console.log("twosandianshow");
    // console.log(key);
    // console.log(type);
    this.setState({
      toopvisibleindexs: key,
    })
    e.stopPropagation();//阻止冒泡
  }

  twosandianshowyss = (e, key, type) => {
    // console.log("twosandianshow");
    // console.log(key);
    // console.log(type);
    this.setState({
      toopvisibleindexs: undefined,
    })
    e.stopPropagation();//阻止冒泡
  }

  sansandianshowyss = (e, key, type) => {
    // console.log("twosandianshow");
    // console.log(key);
    // console.log(type);
    this.setState({
      toopvisibleindexs: undefined,
    })
    e.stopPropagation();//阻止冒泡
  }

  twosandianhide = (e, index, type) => {
    // console.log(index)
    this.setState({
      toopvisibleindexs: undefined,
      twosandiantype: undefined,
      twosandiantypenum: undefined,
      toopvisible: true,
      toopvisibleindex: index,
      twosandiantypes: type
    })
    e.stopPropagation();//阻止冒泡
  }

  sansandianhide = (e, index, type) => {
    // console.log(index)
    this.setState({
      toopvisibleindexs: undefined,
      sansandiantype: undefined,
      twosandiantypenum: undefined,
      toopvisible: true,
      sanshow: '',
      toopvisibleindex: index,
      twosandiantypes: type
    })
    e.stopPropagation();//阻止冒泡
  }

  twosandianhideys = (e, index, type) => {
    // console.log(index)
    this.setState({
      toopvisibleindexs: undefined,
    })
    e.stopPropagation();//阻止冒泡
  }

  //置顶
  editSetup = (e, id) => {
    e.stopPropagation();//阻止冒泡
    navidtype = false
    this.setState({
      navid: undefined,
      sandiantype: undefined,
      twosandiantype: undefined,
      sansandiantype: undefined,


    })

    let url = "/course_modules/" + id + "/sticky_module.json"
    axios.get(url).then((result) => {
      navidtype = true
      this.props.updataleftNavfun();
    }).catch((error) => {
      navidtype = true
    })
  }

  //隐藏
  edithiddens = (id) => {

    navidtype = false
    this.setState({
      navid: undefined,
      sandiantype: undefined,
      twosandiantype: undefined,
      sansandiantype: undefined,
      ModalsType: false
    })

    let url = "/course_modules/" + id + "/hidden_module.json"
    axios.get(url).then((result) => {
      navidtype = true
      this.props.updataleftNavfun();
      // console.log(this.props)
      let list = this.props.course_modules;
      for (var i = 0; i < list.length; i++) {
        if (list[i].id != id) {
          this.props.history.push(list[i].category_url)
          return
        }
      }
    }).catch((error) => {
      navidtype = true
    })
  }



  edithidden = (e, id) => {
    e.stopPropagation();//阻止冒泡
    let { course_modules } = this.props;

    if (course_modules.length > 1) {
      this.setState({
        ModalsType: true,
        Modalstopval: "隐藏后将不再显示此模块，",
        ModalsBottomval: "后续可在课堂设置中重新勾选模块恢复显示",
        ModalSave: () => this.edithiddens(id),
        loadtype: false
      })
    } else {
      this.setState({
        ModalsType: true,
        Modalstopval: "您不能隐藏所有课堂模块，请至少保留",
        ModalsBottomval: "其中一个模块。",
        loadtype: false,
        ModalSave: () => this.cannerNavmoda(),
      })
    }

  }

  Navmodalnames = (e, id, type, setnavid, name, towid, showPreson) => {
    e.stopPropagation();//阻止冒泡
    this.getatahcment()
    navidtype = false
    if (id === 1 || id === 2 || id === 6) {
      this.setState({
        Navmodalname: id === 2 ? "新建分班" : "新建目录",
        Navtitles: id === 2 ? "分班名称" : "目录名称",
        Navplaceholder: "请输入名称，最大限制60个字符",
        Navmodalnametype: true,
        Navmodaltypename: id,
        Navmodalziyname: name,
        treedefaultValue: towid,
        showPreson: showPreson,
        setnavid: setnavid,
        parentid: towid,
        NavmodalValue: ""
      })
    } else if (id === 3 || id === 4 || id === 5 || id === 7) {

      this.setState({
        Navmodalname: id === 5 ? "分班重命名" : "目录重命名",
        Navtitles: id === 5 ? "分班名称" : "目录名称",
        Navplaceholder: "请输入名称，最大限制60个字符",
        Navmodalnametype: true,
        Navmodaltypename: id,
        setnavid: setnavid,
        treedefaultValue: towid,
        showPreson: showPreson,
        Navmodalziyname: '',
        parentid: towid,
        NavmodalValue: name
      })

    }


  }

  cannerNavmoda = () => {
    this.setState({
      Navmodalnametype: false,
      NavmodalValuetype: false,
      ModalsType: false
    })
    navidtype = true
  }
  setNavmodalValue = (e) => {
    this.setState({
      NavmodalValue: e.target.value
    })
  }

  updasaveNavmoda = (message) => {
    this.props.updataleftNavfun();
    // this.setState({
    //   ModalsType:true,
    //   Modalstopval:message,
    //   loadtype:true,
    //   NavmodalValue:""
    // })
    navidtype = true;
    const { successFunc } = this.state;
    successFunc && successFunc(1);
  }

  saveNavmodapost = (url, value, positiontype, coursesId, type) => {
    console.log(positiontype)
    axios.post(url,
      {
        name: value,
        parent_id: this.state.parentid
      }).then((result) => {
        if (result != undefined) {
          if (result.data.status === 0) {

            notification.open({
              message: "提示",
              description: result.data.message
            });

            if (positiontype === "common_homeworks" || positiontype === "common_homework" || positiontype === "group_homeworks" || positiontype === "group_homework") {
              if (type === true) {
                this.updasaveNavmoda()
                trigger('updateNavSuccess')
              } else {
                this.updasaveNavmoda()
                if (positiontype === "common_homeworks") {
                  this.props.history.push(`/classrooms/${coursesId}/common_homework/${result.data.category_id}`);
                }
                if (positiontype === "group_homeworks") {
                  this.props.history.push(`/classrooms/${coursesId}/group_homework/${result.data.category_id}`);
                }

              }
              return
            }

            if (positiontype === "shixun_homeworks" || positiontype === "shixun_homework") {
              if (type === true) {
                this.updasaveNavmoda()
                trigger('shixun')
              } else {
                this.updasaveNavmoda()
                this.props.history.push(`/classrooms/${coursesId}/shixun_homework/${result.data.category_id}`);

              }
              return
            }

            if (positiontype === "files" || positiontype === "file") {
              if (type === true) {
                this.updasaveNavmoda()
                trigger('files')
              } else {
                this.updasaveNavmoda()
                this.props.history.push(`/classrooms/${coursesId}/file/${result.data.category_id}`);
              }
              return
            }

            if (positiontype === "boards") {
              this.updasaveNavmoda()
              trigger('updateNavSuccess')
              this.props.history.push(`/classrooms/${coursesId}/boards/${result.data.category_id}`);
              return
            }

            if (positiontype != "course_groups" && positiontype != "shixun_homeworks" && positiontype != "shixun_homework") {
              this.updasaveNavmoda()
              return
            }

            if (positiontype === "course_groups") {
              this.props.updataleftNavfun();
              this.props.history.push(`/classrooms/${coursesId}/course_groups/${result.data.group_id}`);
              return
            }

          }
        }
      }).catch((error) => {
        console.log(error)
      })
  }
  saveboardpost = (url, value) => {
    axios.put(url,
      { name: value }).then((result) => {
        if (result != undefined) {
          if (result.data.status === 0) {
            this.updasaveNavmoda()
            trigger('updateNavSuccess')

            notification.open({
              message: "提示",
              description: result.data.message
            });
          }
        }
      }).catch((error) => {
        console.log(error)
      })
  }

  saveNavmoda = () => {
    let { Navmodaltypename, setnavid, NavmodalValue } = this.state;
    let id = setnavid;

    if (Navmodaltypename === 5 && NavmodalValue === "未分班" || Navmodaltypename === 2 && NavmodalValue === "未分班") {
      this.setState({
        NavmodalValuetype: true,
        NavmodalValues: "名称不能和未分班一样"
      })
      return
    }

    if (NavmodalValue === "") {
      this.setState({
        NavmodalValuetype: true,
        NavmodalValues: "名称不能为空"
      })
      return
    } else if (NavmodalValue.length > 60) {
      this.setState({
        NavmodalValuetype: true,
        NavmodalValues: "名称不能超过60个字"
      })
      return
    }

    if (Navmodaltypename === 1) {
      let url = "/course_modules/" + id + "/add_second_category.json"
      this.saveNavmodapost(url, NavmodalValue, this.state.positiontype, this.props.match.params.coursesId)

    } else if (Navmodaltypename === 2) {

      let newid = this.props.match.params.coursesId;
      let url = "/courses/" + newid + "/course_groups.json";
      this.saveNavmodapost(url, NavmodalValue, this.state.positiontype, this.props.match.params.coursesId)

    } else if (Navmodaltypename === 3) {

      let url = "/course_modules/" + id + "/rename_module.json"
      this.saveNavmodapost(url, NavmodalValue, this.state.positiontype, null, true)

    } else if (Navmodaltypename === 4) {

      let url = "/course_second_categories/" + id + "/rename_category.json";
      this.saveNavmodapost(url, NavmodalValue, this.state.positiontype, null, true)

    } else if (Navmodaltypename === 5) {

      let url = "/course_groups/" + id + "/rename_group.json";
      this.saveNavmodapost(url, NavmodalValue)

    } else if (Navmodaltypename === 6) {

      let newid = this.props.match.params.coursesId;
      let url = "/courses/" + newid + "/boards.json";
      this.saveNavmodapost(url, NavmodalValue, this.state.positiontype, this.props.match.params.coursesId)

    } else if (Navmodaltypename === 7) {

      let url = "/boards/" + id + ".json";
      this.saveboardpost(url, NavmodalValue)

    }

    this.setState({
      Navmodalnametype: false
    })
  }




  updatadeleteSecondary = (url) => {
    this.props.updataleftNavfun();
    this.setState({
      ModalsType: false,
      Modalstopval: "",
      loadtype: false,
      antIcon: false
    })
    notification.open({
      message: "删除成功",
    });

    this.props.history.replace(url);

    //  window.location.href = url;
  }

  deletenavchilds = (url, mainurl) => {

    this.setState({
      antIcon: true
    })
    axios.delete(url).then((result) => {
      if (result.data.status === 0) {
        this.updatadeleteSecondary(mainurl || result.data.right_url);
        this.setState({
          antIcon: false
        })
      }
    }).catch((error) => {
      console.log(error)
    })
  }
  deleteSecondary = (e, type, id, mainurl) => {
    e.stopPropagation();//阻止冒泡
    if (type === 1) {
      let url = "/course_second_categories/" + id + ".json"
      this.setState({
        loadtype: false,
        ModalsType: true,
        Modalstopval: "该目录下的内容将被移动到父目录,",
        ModalsBottomval: "是否确认删除?",
        ModalSave: () => this.deletenavchilds(url, mainurl)
      })
    } else if (type === 2) {
      let url = "/course_groups/" + id + ".json"
      this.setState({
        ModalsType: true,
        Modalstopval: "该分班的学生将被移动到“未分班”,",
        ModalsBottomval: "是否确认删除?",
        ModalSave: () => this.deletenavchilds(url),
        loadtype: false
      })
    } else if (type === 3) {
      let url = "/boards/" + id + ".json"
      this.setState({
        ModalsType: true,
        Modalstopval: "该目录下的内容将被移动到父目录,",
        ModalsBottomval: "是否确认删除?",
        ModalSave: () => this.deletenavchilds(url, mainurl),
        loadtype: false
      })
    }

  }
  tronChange = (value) => {

    console.log(this.state.dropdownStyleshow)

    this.setState({
      parentid: this.state.treeDataid === value ? 0 : value,
      dropdownStyleshow: 'none'

    })

  }
  tronclick = () => {
    this.setState({
      dropdownStyleshow: 'inline-block'
    })

  }

  droppablepost = (url, list) => {
    axios.post(url, { position: list }).then((result) => {
      if (result != undefined) {
        // this.updasaveNavmoda(result.data.message)
        this.updasaveNavmoda()
        //
        notification.open({
          message: "提示",
          description: result.data.message
        });
      }
    }).catch((error) => {
      console.log(error)
    })
  }

  onDragEnd = (result) => {
    // console.log(result)
    // let {course_modules}=this.props;
    // let newcourse_modules=course_modules;
    // let newid=this.props.match.params.coursesId;
    // let list=[];
    // let positionlist=[];
    // for(var i=0; i<newcourse_modules.length;i++){
    //   if(newcourse_modules[i].type===result.source.droppableId){
    //     list=newcourse_modules[i].second_category
    //   }
    // }
    // const newlist = reorder(
    //   list,
    //   result.source.index,
    //   result.destination.index
    // );
    //
    // for(var z=0; z<newlist.length; z++){
    //   positionlist.push(newlist[z].position)
    // }
    //
    // for(var i=0; i<newcourse_modules.length;i++){
    //   if(newcourse_modules[i].type===result.source.droppableId){
    //     newcourse_modules[i].second_category=newlist
    //   }
    // }
    //
    // this.setState({
    //   course_modules:newcourse_modules
    // })

    if (result.source.droppableId === "shixun_homework" || result.source.droppableId === "graduation" || result.source.droppableId === "attachment") {

      let url = "/course_second_categories/" + result.draggableId + "/move_category.json";
      if (result.destination.index != null) {
        this.droppablepost(url, result.destination.index + 1)
      }
    } else if (result.source.droppableId === "board") {

      let url = "/boards/" + result.draggableId + "/move_category.json";
      if (result.destination.index != null) {
        this.droppablepost(url, result.destination.index + 1)
      }
    } else if (result.source.droppableId === "course_group") {
      if (result.draggableId != 1) {
        let url = "/course_groups/" + result.draggableId + "/move_category.json";
        if (result.destination.index != null) {
          this.droppablepost(url, result.destination.index + 1)
        }
      }
    }

  }


  hidesandian = (e, key) => {
    this.setState({
      sandiantypes: undefined
    })
    e.stopPropagation();//阻止冒泡
  }

  showsandian = (e, key) => {
    this.setState({
      sandiantypes: key
    })
    e.stopPropagation();//阻止冒泡
  }


  showsandians = (e, key, urls, num, id, type, index) => {
    let { url } = this.state;
    if (key === this.props.indexs) {

      this.props.unlocationNavfun(undefined)
    } else {
      this.props.updataleftNavfun();
      this.props.unlocationNavfun(key)
    }
    if (urls != url) {
      this.props.updataleftNavfun();
    }
    this.setState({
      selectnavid: true,
      newselectnavid: id,
      url: urls,
      indexs: index
    })
    try {
      if (this.props.myinex === true) {
        this.props.Callhomedirectoryornot(true);
      }
    } catch (e) {

    }
    this.props.history.replace(urls);
    e.stopPropagation();//阻止冒泡
  }

  maincontent = (item, key) => {
    return (<div className={"sandianbox"}>
      {/*公告栏*/}
      {/*作业*/}
      {item.type === "shixun_homework" ? <div onClick={e => this.Navmodalnames(e, 1, "shixun_homework", item.id)}>新建目录</div> : ""}
      {/* 普通作业 */}
      {item.type === "common_homework" ? <div onClick={e => this.Navmodalnames(e, 1, "common_homeworks", item.id)}>新建目录</div> : ""}
      {/*/!* 分组作业 *!/*/}
      {item.type === "group_homework" ? <div onClick={e => this.Navmodalnames(e, 1, "group_homeworks", item.id)}>新建目录</div> : ""}
      {/*资源*/}
      {item.type === "attachment" ? <div onClick={e => this.Navmodalnames(e, 1, "attachment", item.id, "资源")}>新建目录</div> : ""}
      {/* 视频 */}
      {item.type === "video" ? <div onClick={e => this.Navmodalnames(e, 1, "video", item.id)}>新建目录</div> : ""}
      {/*毕业设计*/}
      {/*{item.type==="graduation"?<div onClick={()=>this.Navmodalnames(1,"attachment",item.id)}>添加目录</div>:""}*/}
      {/*讨论区*/}
      {item.type === "board" ? this.props.current_user && this.props.current_user.course_is_end === true ? "" : <div onClick={e => this.Navmodalnames(e, 6, "board", item.main_id)}>新建目录</div> : ""}
      {/*分班*/}
      {item.type === "course_group" ? this.props.current_user && this.props.current_user.course_is_end === true ? "" : <div onClick={e => this.Navmodalnames(e, 2, "course_group", item.id)}>新建分班</div> : ""}
      {/*分班*/}
      {/*{item.type==="course_group"? :""}*/}
      <div onClick={e => this.Navmodalnames(e, 3, "editname", item.id, item.name)}>重命名</div>
      {/*online_learning*/}
      {/*{*/}
      {/*  this.props.isClassManagement()===true?*/}
      {/*    (*/}
      {/*      item.type==="online_learning"?*/}
      {/*        <div onClick={e=>this.Chapterediting(e,item.id,item.url)}>章节编辑</div>*/}
      {/*      :""*/}
      {/*    )*/}
      {/*    :""}*/}
      <div onClick={e => this.edithidden(e, item.id)}>隐藏</div>
      <div onClick={e => this.editSetup(e, item.id)}>置顶</div>
    </div>)
  }
  content = (item, iem, index, san) => {
    let { twosandiantypes, twosandiantypenum } = this.state;
    return (item.type === "graduation" ? "" : <div className={item.type === twosandiantypes && twosandiantypenum === index ? "sandianboxs" : "sandianboxs"} >
      {/*作业/资源*/}
      {item.type === "attachment" && san !== 'san' ? <div onClick={e => this.Navmodalnames(e, 1, "attachment", item.id, "资源", iem.category_id, true)}>新建目录</div> : ""}
      {item.type === "shixun_homework" || item.type === "attachment" || item.type === "graduation" || item.type === "common_homework" || item.type === "group_homework" ? <div onClick={e => this.Navmodalnames(e, 4, "editSecondname", iem.category_id, iem.category_name)}>重命名</div> : ""}
      {item.type === "shixun_homework" || item.type === "attachment" || item.type === "common_homework" || item.type === "group_homework" ? <div onClick={e => this.deleteSecondary(e, 1, iem.category_id)}>删除</div> : ""}
      {/*分班*/}
      {item.type === "course_group" ? <div onClick={e => this.Navmodalnames(e, 5, "editSecondname", iem.category_id, iem.category_name)}>重命名</div> : ""}
      {item.type === "course_group" ? <div onClick={e => this.deleteSecondary(e, 2, iem.category_id)}>删除</div> : ""}
      {/*讨论区*/}
      {item.type === "board" ? <div onClick={e => this.Navmodalnames(e, 7, "editSecondname", iem.category_id, iem.category_name)}>重命名</div> : ""}
      {item.type === "board" ? <div onClick={e => this.deleteSecondary(e, 3, iem.category_id, item.category_url)}>删除</div> : ""}
      {/*视频*/}
      {item.type === "video" ? <div onClick={e => this.Navmodalnames(e, 4, "editSecondname", iem.category_id, iem.category_name)}>重命名</div> : ""}
      {item.type === "video" ? <div onClick={e => this.deleteSecondary(e, 1, iem.category_id, item.category_url)}>删除</div> : ""}
    </div>)
  };

  //章节编辑
  Chapterediting = (e, id, url) => {
    e.stopPropagation();//阻止冒泡
    //页面刷新
    this.setState({
      chapterupdate: true,
    })
  };
  setchapterupdatefalse = () => {
    this.setState({
      chapterupdate: false,
    })
  }
  render() {

    let {
      twosandiantype,
      Navmodalname,
      Navmodalnametype,
      NavmodalValue,
      ModalsType,
      Modalstopval,
      ModalsBottomval,
      ModalSave,
      loadtype,
      twosandiantypes,
      toopvisibleindexs,
      sansandiantype
    } = this.state;

    let { course_modules, hidden_modules, is_teacher } = this.props;
    // console.log(this.props.location.pathname)
    // // console.log(item.category_url)
    // console.log(this.props.location.pathname)

    // console.log("778");
    // console.log("CoursesLeftNav");
    // console.log(course_modules);




    return (

      <ul className="mb10 newedu-class-leftnav">

        <Modals
          modalsType={ModalsType}
          modalsTopval={Modalstopval}
          modalsBottomval={ModalsBottomval}
          modalSave={ModalSave}
          modalCancel={this.cannerNavmoda}
          loadtype={loadtype}
          antIcon={this.state.antIcon}
        >
        </Modals>

        {/*{*/}
        {/*  this.state.chapterupdate===true?*/}
        {/*    <div>*/}
        {/*      <style>*/}
        {/*        {*/}
        {/*          `*/}
        {/*      .ant-modal-body{*/}
        {/*         padding-left: 33px !important;*/}
        {/*         padding-right: 33px !important;*/}
        {/*         padding-top: 27px !important;*/}
        {/*         padding-bottom: 21px !important;*/}
        {/*        }*/}
        {/*    `*/}
        {/*        }*/}
        {/*      </style>*/}
        {/*    <MyEduChapterupdate  {...this.props} {...this.state} chapterupdate={this.state.chapterupdate} setchapterupdatefalse={this.setchapterupdatefalse}>*/}
        {/*    </MyEduChapterupdate>*/}
        {/*    </div>*/}
        {/*    :*/}
        {/*    ""*/}
        {/*}*/}

        <style>
          {
            `
              body {
                  width: calc(100%) !important;
							}
              `
          }
        </style>
        <Modal
          keyboard={false}
          title={Navmodalname}
          visible={Navmodalnametype}
          className={"Navmodal"}
          closable={false}
          footer={null}
          destroyOnClose={true}
          centered={true}
        >
          <div>
            {this.state.Navmodalziyname === "资源" ? <div className="df" style={{ marginBottom: 50 }}>
              <div className={"fl mt5"} id="ddd">上级目录：</div>

              <TreeSelect
                className={"input-flex-35 greyInput fl"}
                style={{ width: 300, color: '#000000' }}
                getPopupContainer={() => document.getElementById('ddd')}
                dropdownClassName={{ display: this.state.dropdownStyleshow }}
                treeData={this.state.treeData}
                placeholder={this.state.treeDataname}
                disabled={this.state.showPreson}
                defaultValue={this.state.treedefaultValue}
                treeDefaultExpandAll
                onChange={this.tronChange}
                onClick={this.tronclick}
              />
            </div> : ''}

            <div className="df" >
              <div className={"fl mt5"}  >{this.state.Navtitles}：</div>
              <Input placeholder={this.state.Navplaceholder}
                className={"input-flex-35 greyInput fl"}
                maxLength="60"
                value={NavmodalValue}
                onInput={this.setNavmodalValue}
              />
            </div>
          </div>
          <style>
            {
              `
							 	.ml70{
    							margin-left: 70px;
							 	}
							 	`
            }
          </style>

          {this.state.NavmodalValuetype === true ? <span className={"ml70 color-red"}>
            {this.state.NavmodalValues}
          </span> : ""}
          <div className={this.state.NavmodalValuetype === true ? "clearfix mt20 edu-txt-center" : "clearfix mt50 edu-txt-center"}>
            <a className="task-btn mr30" onClick={this.cannerNavmoda}>取消</a>
            <a className="task-btn task-btn-orange" onClick={this.saveNavmoda}>确定</a>
          </div>
        </Modal>
        <style>
          {`
              // .activity-left-name{
              //    width: 100%;
              //   }
                .droppableul{
                  max-height: 500px;
                  overflow-y:auto;
                  overflow-x:hidden;
                }

                .mr13{
                margin-right:13px;
                }
             `}
        </style>
        {is_teacher === true ?
          course_modules === undefined ? "" : course_modules.map((item, key) => {
            return (
              <div key={key} 	>
                <a>
                  <li title={item.name.length < 7 ? "" : item.name} onClick={(e) => this.showsandians(e, key, item.category_url, 1, item.id, item.type)} className={this.props.mainurl === item.category_url && this.props.location.pathname === item.category_url ? "liactive" : "clearfix active"} onMouseLeave={(e) => this.hidesandian(e, key)} onMouseEnter={(e) => this.showsandian(e, key)}>
                    <a onClick={(e) => this.showsandians(e, key, item.category_url, 1, item.id, item.type)} className={item.second_category === undefined ? "fl ml20 pd0" : item.second_category.length === 0 ? "fl ml20 pd0" : this.state.sandiantypes === key ? "fl ml20 pd0 ebebeb" : "fl ml20 pd0"}>
                      {
                        item.type === "announcement" ? <i className={this.props.location.pathname === item.category_url ? "color-blue iconfont icon-xiaoxi1 mr10 fl" : "iconfont icon-xiaoxi1 mr10 fl"}></i> :
                          item.type === "online_learning" ? <i className={this.props.location.pathname === item.category_url ? "color-blue iconfont icon-kecheng mr10 fl font-16" : "iconfont icon-kecheng mr10 fl font-16"}></i> :
                            item.type === "shixun_homework" ? <i className={this.props.location.pathname === item.category_url ? "color-blue iconfont icon-daima mr10 fl" : "iconfont icon-daima mr10 fl"}></i> :
                              item.type === "common_homework" ? <i className={this.props.location.pathname === item.category_url ? "color-blue iconfont icon-putongzuoye mr10 fl" : "iconfont icon-putongzuoye mr10 fl"}></i> :
                                item.type === "group_homework" ? <i className={this.props.location.pathname === item.category_url ? "color-blue iconfont icon-fenzuzuoye mr10 fl" : "iconfont icon-fenzuzuoye mr10 fl"}></i> :
                                  item.type === "graduation" ? <i className={this.props.location.pathname === item.category_url ? "color-blue iconfont icon-biyezhuanhuan mr10 fl" : "iconfont icon-biyezhuanhuan mr10 fl"}></i> :
                                    item.type === "exercise" ? <i className={this.props.location.pathname === item.category_url ? "color-blue iconfont icon-shijuan mr10 fl" : "iconfont icon-shijuan mr10 fl"}></i> :
                                      item.type === "poll" ? <i className={this.props.location.pathname === item.category_url ? "color-blue iconfont icon-wenjuan mr10 fl" : "iconfont icon-wenjuan mr10 fl"}></i> :
                                        item.type === "attachment" ? <i className={this.props.location.pathname === item.category_url ? "color-blue iconfont icon-ziyuan mr10 fl" : "iconfont icon-ziyuan mr10 fl"}  ></i> :
                                          item.type === "board" ? <i className={this.props.location.pathname === item.category_url ? "color-blue iconfont icon-taolun mr10 fl" : "iconfont icon-taolun mr10 fl"}  ></i> :
                                            item.type === "course_group" ? <i className={this.props.location.pathname === item.category_url ? "color-blue iconfont icon-fenban mr10 fl" : "iconfont icon-fenban mr10 fl"}  ></i> :
                                              item.type === "statistics" ? <i className={this.props.location.pathname === item.category_url ? "color-blue iconfont icon-tongji mr10 fl" : "iconfont icon-tongji mr10 fl"}  ></i> :
                                                item.type === "attendance" ? <i className={this.props.location.pathname === item.category_url ? "color-blue iconfont icon-qiandao-1 mr10 fl" : "iconfont icon-qiandao-1 mr10 fl"}  ></i> :
                                                  item.type === "video" ? <i className={this.props.location.pathname === item.category_url ? "color-blue iconfont icon-bofang2 mr10 fl" : "iconfont icon-bofang2 mr10 fl"}  ></i> : ""
                      }

                      {/*||this.props.location.pathname===this.state.url&&key===this.state.indexs*/}

                      <span className={this.props.location.pathname === item.category_url ? "color-blue task-hide activity-left-name" : "task-hide activity-left-name"}
                        onClick={(e) => this.selectnavid(e, key, item.id, item.type, item.category_url)}
                      >{item.name}</span>

                      {/*className={sandiantype===undefined?item.task_count===0?"fr mr10 colortransparent":"fr mr10 color999 font-14":sandiantype===key?"none":item.task_count===0?"none":"fr mr10 color999 font-14"}*/}
                      <span className={this.state.sandiantypes === key ? "none" : this.props.location.pathname === item.category_url ? "color-blue fr mr25 font-14" : "fr mr25 color999 font-14"} >{item.task_count === 0 ? "" : item.task_count}</span>
                      {/*<i className={this.state.sandiantypes===key?"iconfont icon-sandian mr5 fr color999":"none"} onMouseEnter={(e)=>this.sandianshow(e,key)}></i>  */}

                      {this.state.sandiantypes === key ? <Popover placement="right" content={this.maincontent(item, key)} trigger="hover" key={key}>

                        <i className={"iconfont icon-sandian mr20 fr color999"}></i>

                      </Popover> : ""}
                    </a>
                  </li>

                  {/*下拉列表*/}

                  {/* 可拖拽选择实训列表*/}
                  {/*className={this.props.location.pathname===item.category_url||this.props.location.pathname===this.state.url&&key===this.state.indexs?"TabsWarps":"TabsWarps"}*/}
                  {
                    <DragDropContext onDragEnd={this.onDragEnd} >
                      <Droppable droppableId={item.type}>
                        {(provided, snapshot) => (
                          <ul
                            ref={provided.innerRef}
                            {...provided.droppableProps}
                            className={"droppableul"}
                            style={{ display: key === this.props.indexs ? "" : "none" }}
                          >
                            {item.second_category === undefined ? "" : item.second_category.map((iem, index) => {
                              if (item.type === "course_group") {
                                if (iem.category_name === "未分班") {
                                  if (iem.category_count === 0) {
                                    return
                                  }
                                }
                              }
                              // console.log(iem.category_name);
                              // console.log(iem.category_name.length);
                              return (
                                <Draggable
                                  key={'id' + index}
                                  draggableId={iem.category_id === 0 ? index + 1 : iem.category_id}
                                  index={index}
                                  className={"TabsWarps"}
                                >
                                  {(provided, snapshot) => (
                                    <Tooltip placement="bottom" title={"拖拽二级菜单调整顺序"}
                                      key={index}
                                      // visible={toopvisible===true&&toopvisibleindex===iem.category_id?true:false}
                                      visible={false}
                                    >
                                      {/*"/classrooms/"+this.props.match.params.coursesId+"/"+item.type+"/"+iem.category_type+"/"+iem.category_id*/}
                                      <a className={"Draggablelichild"} key={index}>
                                        <li className="clearfix width93 Draggableli" key={index} onClick={(e) => this.selectnavids(e, key, iem.category_id, item.type + "child", iem.second_category_url, key, 'san')} onMouseLeave={(e) => this.twosandianhide(e, index, item.type)} onMouseEnter={(e) => this.twosandianshow(e, index, item.type)}
                                          key={index}
                                          ref={provided.innerRef}
                                          {...provided.draggableProps}
                                          {...provided.dragHandleProps}
                                        // title={iem.category_name.length<10?"":iem.category_name}
                                        >
                                          <a className="fl pl46 pd0  Draggablelichild">
                                            <span className={this.props.location.pathname === iem.second_category_url ? "color-blue fl ml38 maxwidth170 task-hide  Draggablelichild" : "fl ml38 maxwidth170 task-hide  Draggablelichild"} onMouseEnter={(e) => this.twosandianshowys(e, index, item.type)}>{iem.category_name}</span>

                                            <span className={twosandiantype === undefined ? this.props.location.pathname === iem.second_category_url ? "fr mr20 color-blue Draggablelichild font-14" : "fr mr20 color999  Draggablelichild font-14" : item.type === twosandiantypes && twosandiantype === index && iem.category_id != 0 ? "none" : this.props.location.pathname === iem.second_category_url ? "fr mr20 color-blue Draggablelichild font-14" : "fr mr20 color999  Draggablelichild font-14"} >{iem.category_count === 0 ? "" : iem.category_count}</span>

                                            {item.type === twosandiantypes && twosandiantype === index ?
                                              iem.category_id === 0 ? "" :
                                                iem.category_type === "graduation_topics" || iem.category_type === "graduation_tasks" ?
                                                  (
                                                    iem.category_name && iem.category_name.length < 13 ?
                                                      <span className={"fr mr20 color999  Draggablelichild font-14"} >{iem.category_count === 0 ? "" : iem.category_count}</span>
                                                      :
                                                      <Tooltip placement="right" key={index} title={iem.category_name} visible={toopvisibleindexs === undefined ? false : toopvisibleindexs === index ? true : false}>
                                                        <span className={"fr mr20 color999  Draggablelichild font-14"} >{iem.category_count === 0 ? "" : iem.category_count}</span>
                                                      </Tooltip>
                                                  )
                                                  :
                                                  (
                                                    iem.category_name && iem.category_name.length < 13 ?
                                                      <Popover placement="right" content={this.content(item, iem, index)} trigger="hover" key={index} onMouseEnter={(e) => this.twosandianshowyss(e)}>
                                                        <i className={"iconfont icon-sandian fr color999 mr15 Draggablelichild"}></i>
                                                      </Popover>
                                                      :
                                                      <Tooltip placement="right" key={index} title={iem.category_name} visible={toopvisibleindexs === undefined ? false : toopvisibleindexs === index ? true : false}>
                                                        <Popover placement="right" content={this.content(item, iem, index)} trigger="hover" key={index} onMouseEnter={(e) => this.twosandianshowyss(e)}>
                                                          <i className={"iconfont icon-sandian fr color999 mr15 Draggablelichild"}></i>
                                                        </Popover>
                                                      </Tooltip>
                                                  )
                                              : ""}
                                          </a>
                                          {provided.placeholder}

                                        </li>

                                      </a>
                                      {
                                        iem.third_category === undefined ? "" : iem.third_category.map((itt, index) => {
                                          if (itt.category_type !== "attachment") {
                                            return

                                          }
                                          return (
                                            <div onClick={this.getatahcment} style={{ display: this.state.newselectnavid === undefined ? 'none' : itt.parent_id === this.state.newselectnavid ? 'block' : 'none' }}>
                                              {/*"/classrooms/"+this.props.match.params.coursesId+"/"+item.type+"/"+iem.category_type+"/"+iem.category_id*/}
                                              <a className={"Draggablelichild"} key={index}>
                                                <li className="clearfix width93 Draggableli" key={index} onClick={(e) => this.selectnavids(e, key, itt.parent_id, item.type + "child", itt.second_category_url, key)} onMouseLeave={(e) => this.sansandianhide(e, index, item.type)} onMouseEnter={(e) => this.sansandianshow(e, index, item.type, itt.category_name)}
                                                  key={index}
                                                  ref={provided.innerRef}
                                                  {...provided.draggableProps}
                                                  {...provided.dragHandleProps}
                                                // title={iem.category_name.length<10?"":iem.category_name}
                                                >
                                                  <a className="fl pl46 pd0  Draggablelichild">
                                                    <span style={{ marginLeft: 15 }} className={this.props.location.pathname === itt.second_category_url ? "color-blue fl ml38 maxwidth155 task-hide  Draggablelichild" : "fl ml38 maxwidth155 task-hide  Draggablelichild"} onMouseEnter={(e) => this.sansandianshowys(e, index, item.type)}>{itt.category_name}</span>

                                                    <span className={sansandiantype === undefined ? this.props.location.pathname === itt.second_category_url ? "fr mr20 color-blue Draggablelichild font-14" : "fr mr20 color999  Draggablelichild font-14" : item.type === twosandiantypes && sansandiantype === index && itt.category_id != 0 ? "none" : this.props.location.pathname === itt.second_category_url ? "fr mr20 color-blue Draggablelichild font-14" : "fr mr20 color999  Draggablelichild font-14"} >{itt.category_count === 0 ? "" : itt.category_count}</span>

                                                    {iem.category_type === twosandiantypes && sansandiantype === index ?
                                                      itt.category_name !== this.state.sanshow ? "" :
                                                        (
                                                          itt.category_name && itt.category_name.length < 13 ?
                                                            <Popover placement="right" content={this.content(item, itt, index, 'san')} trigger="hover" key={index} onMouseEnter={(e) => this.sansandianshowyss(e)}>
                                                              <i className={"iconfont icon-sandian fr color999 mr15 Draggablelichild"}></i>
                                                            </Popover>
                                                            :
                                                            <Tooltip placement="right" key={index} title={itt.category_name} visible={toopvisibleindexs === undefined ? false : toopvisibleindexs === index ? true : false}>
                                                              <Popover placement="right" content={this.content(item, itt, index, 'san')} trigger="hover" key={index} onMouseEnter={(e) => this.sansandianshowyss(e)}>
                                                                <i className={"iconfont icon-sandian fr color999 mr15 Draggablelichild"}></i>
                                                              </Popover>
                                                            </Tooltip>
                                                        )
                                                      : ""}
                                                  </a>
                                                </li>

                                              </a>
                                            </div>
                                          )
                                        })


                                      }
                                    </Tooltip>
                                  )}
                                </Draggable>
                              )
                            })}
                          </ul>
                        )}
                      </Droppable>
                    </DragDropContext>
                  }
                </a>

              </div>
            )
          })

          : course_modules === undefined ? "" : course_modules.map((item, key) => {

            return (
              <div key={key}>
                {/*<Tooltip placement="bottom" title={"点击空白处展开二级菜单，点击模块名字跳转到对应模块"}>*/}
                <a>

                  <li className={this.props.mainurl === item.category_url && this.props.location.pathname === item.category_url ? "liactive" : "clearfix active"}
                    onClick={(e) => this.setnavid(e, key, item.id, item.type, item.category_url)} onMouseEnter={(e) => this.showsandian(e, key)}
                    title={item.name.length < 7 ? "" : item.name}
                  >
                    <a className={item.second_category === undefined ? "fl ml20 pd0" : item.second_category.length === 0 ? "fl ml20 pd0" : this.state.sandiantypes === key ? "fl ml20 pd0 ebebeb" : "fl ml20 pd0"}>
                      {
                        item.type === "announcement" ? <i className={this.props.location.pathname === item.category_url ? "color-blue iconfont icon-xiaoxi1 mr10 fl" : "iconfont icon-xiaoxi1 mr10 fl"}></i> :
                          item.type === "online_learning" ? <i className={this.props.location.pathname === item.category_url ? "color-blue iconfont icon-kecheng mr10 fl font-16" : "iconfont icon-kecheng mr10 fl font-16"}></i> :
                            item.type === "shixun_homework" ? <i className={this.props.location.pathname === item.category_url ? "color-blue iconfont icon-daima mr10 fl" : "iconfont icon-daima mr10 fl"}></i> :
                              item.type === "common_homework" ? <i className={this.props.location.pathname === item.category_url ? "color-blue iconfont icon-putongzuoye mr10 fl" : "iconfont icon-putongzuoye mr10 fl"}></i> :
                                item.type === "group_homework" ? <i className={this.props.location.pathname === item.category_url ? "color-blue iconfont icon-fenzuzuoye mr10 fl" : "iconfont icon-fenzuzuoye mr10 fl"}></i> :
                                  item.type === "graduation" ? <i className={this.props.location.pathname === item.category_url ? "color-blue iconfont icon-biyezhuanhuan mr10 fl" : "iconfont icon-biyezhuanhuan mr10 fl"}></i> :
                                    item.type === "exercise" ? <i className={this.props.location.pathname === item.category_url ? "color-blue iconfont icon-shijuan mr10 fl" : "iconfont icon-shijuan mr10 fl"}></i> :
                                      item.type === "poll" ? <i className={this.props.location.pathname === item.category_url ? "color-blue iconfont icon-wenjuan mr10 fl" : "iconfont icon-wenjuan mr10 fl"}></i> :
                                        item.type === "attachment" ? <i className={this.props.location.pathname === item.category_url ? "color-blue iconfont icon-ziyuan mr10 fl" : "iconfont icon-ziyuan mr10 fl"}  ></i> :
                                          item.type === "board" ? <i className={this.props.location.pathname === item.category_url ? "color-blue iconfont icon-taolun mr10 fl" : "iconfont icon-taolun mr10 fl"}  ></i> :
                                            item.type === "course_group" ? <i className={this.props.location.pathname === item.category_url ? "color-blue iconfont icon-fenban mr10 fl" : "iconfont icon-fenban mr10 fl"}  ></i> :
                                              item.type === "attendance" ? <i className={this.props.location.pathname === item.category_url ? "color-blue iconfont icon-qiandao-1 mr10 fl" : "iconfont icon-qiandao-1 mr10 fl"}  ></i> :
                                                item.type === "video" ? <i className={this.props.location.pathname === item.category_url ? "color-blue iconfont icon-bofang2 mr10 fl" : "iconfont icon-bofang2 mr10 fl"}  ></i> :
                                                  item.type === "statistics" ? <i className={this.props.location.pathname === item.category_url ? "color-blue iconfont icon-tongji mr10 fl" : "iconfont icon-tongji mr10 fl"}  ></i> : ""
                      }

                      <span className={this.props.location.pathname === item.category_url ? "color-blue task-hide activity-left-name" : "task-hide activity-left-name"} onClick={(e) => this.selectnavid(e, key, item.id, item.type, item.category_url)}>{item.name}</span>
                      <span className={this.props.location.pathname === item.category_url ? "color-blue fr mr20 font-14" : "fr mr20 color999 font-14"}>{item.task_count === 0 ? "" : item.task_count}</span>

                    </a>
                  </li>
                </a>

                <ul style={{ display: key === this.props.indexs ? "" : "none" }} className="droppableul">

                  {
                    item.second_category === undefined ? "" : item.second_category.map((iem, index) => {
                      if (item.type === "course_group") {
                        if (iem.category_name === "未分班") {
                          if (iem.category_count === 0) {
                            return
                          }
                        }
                      }
                      // console.log(iem.category_name);
                      // console.log(iem.category_name.length);一开始是10 显示是13
                      return (
                        <a >
                          {/*title={iem.category_name.length<10?"":iem.category_name}*/}

                          <li className="clearfix Draggableli" key={index} style={{ width: '244px' }}  >
                            {
                              iem.category_name && iem.category_name.length < 13 ?
                                <a className="fl pl46 pd0 Draggablelichild" onClick={(e) => this.selectnavids(e, key, iem.category_id, item.type + "child", iem.second_category_url, key)} >
                                  {/*<span className="fl ml38 maxwidth170 task-hide">{iem.category_name}</span>*/}
                                  {/*{iem.category_name.length<10?"":*/}
                                  {/*  iem.category_name}*/}
                                  <span className={this.props.location.pathname === iem.second_category_url ? "color-blue fl ml38 maxwidth170 task-hide  Draggablelichild" : "fl ml38 maxwidth170 task-hide  Draggablelichild"}>{iem.category_name}</span>
                                  <span className={twosandiantype === undefined ? this.props.location.pathname === iem.second_category_url ? "fr mr20 color-blue font-14" : "fr mr20 color999 font-14" : twosandiantype === index && item.type != "graduation" ? "none" : this.props.location.pathname === iem.second_category_url ? "fr mr20 color-blue font-14" : "fr mr20 color999 font-14"}>{iem.category_count === 0 ? "" : iem.category_count}</span>
                                </a>
                                :
                                <Tooltip placement="right" key={index} title={iem.category_name}>
                                  <a className="fl pl46 pd0 Draggablelichild" onClick={(e) => this.selectnavids(e, key, iem.category_id, item.type + "child", iem.second_category_url, key)} >
                                    {/*<span className="fl ml38 maxwidth170 task-hide">{iem.category_name}</span>*/}
                                    {/*{iem.category_name.length<10?"":*/}
                                    {/*  iem.category_name}*/}
                                    <span className={this.props.location.pathname === iem.second_category_url ? "color-blue fl ml38 maxwidth170 task-hide  Draggablelichild" : "fl ml38 maxwidth170 task-hide  Draggablelichild"}>{iem.category_name}</span>
                                    <span className={twosandiantype === undefined ? this.props.location.pathname === iem.second_category_url ? "fr mr20 color-blue font-14" : "fr mr20 color999 font-14" : twosandiantype === index && item.type != "graduation" ? "none" : this.props.location.pathname === iem.second_category_url ? "fr mr20 color-blue font-14" : "fr mr20 color999 font-14"}>{iem.category_count === 0 ? "" : iem.category_count}</span>
                                  </a>
                                </Tooltip>

                            }
                          </li>
                          {
                            iem.third_category === undefined ? "" : iem.third_category.map((itt, index) => {
                              if (itt.category_type !== "attachment") {
                                return

                              }
                              return (
                                <div onClick={this.getatahcment} style={{ display: this.state.newselectnavid === undefined ? 'none' : itt.parent_id === this.state.newselectnavid ? 'block' : 'none' }}>
                                  {/*"/classrooms/"+this.props.match.params.coursesId+"/"+item.type+"/"+iem.category_type+"/"+iem.category_id*/}
                                  <a className={"Draggablelichild"} key={index}>
                                    <li className="clearfix width93 Draggableli" key={index} onClick={(e) => this.selectnavids(e, key, itt.parent_id, item.type + "child", itt.second_category_url, key)} onMouseLeave={(e) => this.sansandianhide(e, index, item.type)} onMouseEnter={(e) => this.sansandianshow(e, index, item.type, itt.category_name)}
                                      key={index}


                                    // title={iem.category_name.length<10?"":iem.category_name}
                                    >
                                      <a className="fl pl46 pd0  Draggablelichild">
                                        <span style={{ marginLeft: 15 }} className={this.props.location.pathname === itt.second_category_url ? "color-blue fl ml38 maxwidth155 task-hide  Draggablelichild" : "fl ml38 maxwidth155 task-hide  Draggablelichild"} onMouseEnter={(e) => this.sansandianshowys(e, index, item.type)}>{itt.category_name}</span>

                                        <span className={sansandiantype === undefined ? this.props.location.pathname === itt.second_category_url ? "fr mr20 color-blue Draggablelichild font-14" : "fr mr20 color999  Draggablelichild font-14" : item.type === twosandiantypes && sansandiantype === index && itt.category_id != 0 ? "none" : this.props.location.pathname === itt.second_category_url ? "fr mr20 color-blue Draggablelichild font-14" : "fr mr20 color999  Draggablelichild font-14"} >{itt.category_count === 0 ? "" : itt.category_count}</span>

                                        {iem.category_type === twosandiantypes && sansandiantype === index ?
                                          itt.category_name !== this.state.sanshow ? "" :
                                            (
                                              itt.category_name && itt.category_name.length < 13 ?
                                                ''
                                                :
                                                <Tooltip placement="right" key={index} title={itt.category_name} visible={toopvisibleindexs === undefined ? false : toopvisibleindexs === index ? true : false}>

                                                </Tooltip>
                                            )
                                          : ""}
                                      </a>
                                    </li>

                                  </a>
                                </div>
                              )
                            })


                          }
                        </a>

                      )
                    })
                  }
                </ul>

              </div>
            )
          })
        }

      </ul>


    )
  }
}
export default Coursesleftnav;


