import React, { Component } from 'react'; import {getImageUrl} from 'educoder'; import {Modal,Input,Checkbox,Tooltip,Spin,notification} from "antd"; import { DragDropContext,Draggable, Droppable} from 'react-beautiful-dnd'; import Modals from '../../modals/Modals'; import Addshixuns from './Addshixuns'; import NewShixunModel from '../../courses/coursesPublic/NewShixunModel'; import GotoQQgroup from "../../../modal/GotoQQgroup"; import '../ShixunPaths.css'; import axios from 'axios'; const $ = window.$; const Search = Input.Search; //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 ? '#dceeff' : '', // styles we need to apply on draggables ...draggableStyle, }); class DetailCardsEditAndEdit extends Component{ constructor(props){ super(props); this.state={ selectShixun:false, editPanel:true, search:"", type:0, page:1, ChooseShixunList:undefined, hometypepvisible:true, shixuns_listedit:undefined, patheditarry:[], stage_name:undefined, stage_description:undefined, stageid:undefined, Modalstype:false, Modalstopval:'', Modalsbottomval:'', delectfunvalue:undefined, ChooseShixunListshixun_list:undefined, stage_nametype:false, descriptiontype:false, Addshixunstype:false, goshowqqgtounp:false, } this.onDragEnd = this.onDragEnd.bind(this); } //选择实训弹框 AddShixunBox = () =>{ this.setState({ selectShixun:true, patheditarry:[] }) // this.changeTag(0,""); } //关闭选择实训弹框 cloasShixunBox =()=>{ this.setState({ selectShixun:false, patheditarry:[] }) } Addshixuns=()=>{ if(this.props&&this.props.current_user&&this.props.current_user.is_shixun_marker===false){ this.setgoshowqqgtounp(true); return; } this.setState({ Addshixunstype:true, }) } shixunhomeworkedit=(list)=>{ let newpatheditarry=[]; for(var i=0; i{ this.setState({ stage_name:e.target.value }) } updatastage_description=(e)=>{ //输入数据绑定 this.setState({ stage_description:e.target.value }) } clickShixunchoose=(patheditarry)=>{ let{shixuns_listedit,shixuns_listeditlist}=this.state let newshixuns_listedit=shixuns_listedit; let list=shixuns_listeditlist let url='/paths/append_to_stage.json' axios.post(url,{ shixun_id:patheditarry }).then((response) => { let newshixun_lists=response.data.shixun_lists; for(var j=0; j { console.log(error) }); } //保存 clickShixunsave=()=>{ let{stage_name,stage_description,stageid,shixuns_listeditlist}=this.state; let newstage_descriptions=stage_description; if(stage_name===""||stage_name===undefined){ this.setState({ stage_nametype:true }) return } if(newstage_descriptions!=undefined){ if(newstage_descriptions.length>300){ this.setState({ descriptiontype:true }) return } }else{ newstage_descriptions="" } let url; if(this.props.ysldetailcards===undefined){ url='/stages/'+stageid+'.json'; }else{ url=`/course_stages/${stageid}.json`; } axios.put(url, { name:stage_name, description:newstage_descriptions, shixun_id:shixuns_listeditlist }).then((response) => { // window.location.href = "/paths/" + response.data.subject_id this.setState({ stage_name:undefined, stage_description:undefined, shixuns_listeditlist:[], shixuns_listedit:undefined, stage_nametype:false, descriptiontype:false }) this.props.updatapathCardsedits() }).catch((error) => { console.log(error) }); } //删除实训 shixunslisteditdelect=(e)=>{ this.setState({ Modalstype:true, Modalstopval:'是否删除该实训?', Modalsbottomval:'', delectfunvalue:e.target.id }) } shixunslisteditdelectfun=()=>{ let{delectfunvalue}=this.state; let sum = parseInt(delectfunvalue); let {shixuns_listedit,shixuns_listeditlist} =this.state; let newshixuns_listedit=shixuns_listedit let newshixuns_listeditlist=shixuns_listeditlist newshixuns_listedit.splice(sum, 1); newshixuns_listeditlist.splice(sum, 1); this.setState({ shixuns_listedit:newshixuns_listedit, shixuns_listeditlist:newshixuns_listeditlist, Modalstype:false, Modalstopval:' ', Modalsbottomval:'', delectfunvalue:undefined }) } cardsModalcancel=()=>{ this.setState({ Modalstype:false, Modalstopval:'', Modalsbottomval:'', delectfunvalue:undefined, Addshixunstype:false }) } cardsModalsave=()=>{ this.setState({ Modalstype:false, Modalstopval:'', Modalsbottomval:'' }) } onDragStart = () => { /*...*/ }; onDragUpdate = () => { /*...*/ } onDragEnd (result) { let {shixuns_listedit,shixuns_listeditlist} =this.state; const listedit = reorder( shixuns_listedit, result.source.index, result.destination.index ); const listeditlist = reorder( shixuns_listeditlist, result.source.index, result.destination.index ); this.setState({ shixuns_listedit:listedit, shixuns_listeditlist:listeditlist }) } showNotification = (description, message = "提示", icon) => { const data = { message, description } if (icon) { data.icon = icon; } notification.open(data); } Getaddshixuns=(value,is_jupyter)=>{ let { shixuns_listeditlist, shixuns_listedit, } = this.state let newshixuns_listedit=shixuns_listedit; let list=shixuns_listeditlist let url='/paths/add_shixun_to_stage.json'; axios.post(url,{ name:value, is_jupyter:is_jupyter }).then((response) => { if(response){ if(response.data){ newshixuns_listedit.push(response.data); list.push(response.data.shixun_id); this.setState({ shixuns_listedit:newshixuns_listedit, shixuns_listeditlist:list, patheditarry:[], selectShixun:false, page:1, }) } } }).catch((error) => { console.log(error) }); } // 处理弹框 setgoshowqqgtounp=(bool)=>{ this.setState({ goshowqqgtounp:bool }) } render(){ let {selectShixun, editPanel, ChooseShixunList, type, page, search, hometypepvisible, shixuns_listedit, patheditarry, stage_name, stage_description, Modalstype, Modalstopval, Modalsbottomval, delectfunvalue, ChooseShixunListshixun_list, stage_nametype, descriptiontype, goshowqqgtounp } = this.state return(
{ goshowqqgtounp===true? this.setgoshowqqgtounp(bool)}> : "" } this.cardsModalsave():()=>this.shixunslisteditdelectfun()} > {this.state.Addshixunstype===true?this.Getaddshixuns(value,is_jupyter)} {...this.props} {...this.state} />:""} { this.props.idsum===this.props.keys&&this.props.pathCardsedittype===true?

{/**/} {/**/} {/**/} {/**/}

{/*

章节名称

*/}
*
名称不能为空
必填项

描述

描述不能超多最大限制300个字符

新建实训项目

选用实训项目

下面实训可以通过拖拽进行排序调整

{selectShixun===true?:""} {selectShixun===true?:""}
{/* 可拖拽选择实训列表*/} {shixuns_listedit===undefined?'': {(provided, snapshot) => (
{shixuns_listedit.map((item,key)=>{ return( {(provided, snapshot) => ( )} )})}
)}
} {/*
*/} {/*
*/} {/*×*/} {/*Shixun0*/} {/*
*/} {/*

frerere

*/} {/*
*/} {/*
*/} {/*
*/} {/*

*/} {/*取消*/} {/*保存*/} {/*

*/}

:''}
) } } export default DetailCardsEditAndEdit; // { // shixuns_listedit===undefined?'':shixuns_listedit.map((item,key)=>{ // return( //
// //
  • // // // // // // // // // // {this.props.idsum+1}-{key+1}  {item.shixun_name} // // // // // //
  • // //
  • // // // //
  • // //
    // ) // }) // } // // //
    // //
    // // // {ChooseShixunList && ChooseShixunList.shixuns_count} // 个实训 // //
    // this.changeTag(`${type}`,`${search}`)} // style={{width: '115%'}} // > //
    //
    //
      //
    • 实训名称
    • //
    • 使用院校
    • //
    • 使用人数
    • //
    • 评价等级
    • //
    • //
    // // // {ChooseShixunListshixun_list && ChooseShixunListshixun_list.length===0?"":
    // // { // ChooseShixunListshixun_list && ChooseShixunListshixun_list.map((item,key)=>{ // return( //
    //
  • // // // //
  • //
  • {item.school_users}
  • //
  • {item.myshixuns_count}
  • //
  • {item.preference}
  • //
  • 详情
  • //
    // ) // }) // } //
    //
    } //
    // 取消 // 确定 //
    //
    //
    //
    // //打开选择实训弹框初始化tag标签和列表 // changeTag(id,search){ // // this.setState({ // ChooseShixunListshixun_list:[], // page:1, // hometypepvisible:true // }) // let pathId=this.props.pathid; // let url='/paths/'+pathId+'/choose_subject_shixun.json?page='+1 // if(search!="" && search!=undefined){ // url+="&search="+search; // } // if(id!=0){ // url+="&type="+id; // } // axios.get(encodeURI(url)).then((result)=>{ // if(result.status===200){ // this.setState({ // ChooseShixunList:result.data, // hometypepvisible:false, // type:id, // search:search, // ChooseShixunListshixun_list:result.data.shixun_list // }) // } // }).catch((error)=>{ // console.log(error); // }) // } // contentViewScrolledit=(e)=>{ // //滑动到底判断 // const {ChooseShixunList}=this.state; // let newscrollTop=parseInt(e.currentTarget.scrollTop); // let allclientHeight=e.currentTarget.clientHeight+newscrollTop; // // if(e.currentTarget.scrollHeight-allclientHeight===0||e.currentTarget.scrollHeight-allclientHeight===1||e.currentTarget.scrollHeight-allclientHeight===-1){ // // if(ChooseShixunList.shixun_list.length===0){ // return // }else{ // this.setState({ // hometypepvisible:true // }) // // console.log("到达底部"); // // let {page,type,search,ChooseShixunListshixun_list}=this.state; // // let newpage=page+1; // // let pathId=this.props.pathid; // // let newChooseShixunListshixun_list=ChooseShixunListshixun_list; // // let url='/paths/'+pathId+'/choose_subject_shixun.json?page='+newpage // // if(search!="" && search!=undefined){ // url+="&search="+search; // } // // if(type!=0){ // url+="&type="+type; // } // axios.get(encodeURI(url)).then((result)=>{ // if(result.status===200){ // // let list =result.data.shixun_list; // // for(var i=0; i{ // console.log(error); // }) // // // } // // // // } // // }