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 '../ShixunPaths.css'; import axios from 'axios'; import NewShixunModel from '../../courses/coursesPublic/NewShixunModel'; 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 DetailCardsEditAndAdd extends Component{ constructor(props){ super(props); this.state={ selectShixun:false, editPanel:false, search:"", type:0, page:1, ChooseShixunList:undefined, hometypepvisible:true, shixuns_listedit:[], shixuns_listeditlist:[], patheditarry:[], stage_descriptions:undefined, stage_names:undefined, delectfunvalue:undefined, Modalstype:false, Modalstopval:"", Modalsbottomval:"", ChooseShixunListshixun_list:undefined, stage_nametype:false, descriptiontype:false } this.onDragEnd = this.onDragEnd.bind(this); } //选择实训弹框 AddShixunBox = () =>{ this.setState({ selectShixun:true, patheditarry:[], }) // this.changeTag(0,""); } //关闭选择实训弹框 cloasShixunBox =()=>{ this.setState({ selectShixun:false, patheditarry:[] }) } showNotification = (description, message = "提示", icon) => { const data = { message, description } if (icon) { data.icon = icon; } notification.open(data); } clickShixunchoose=(patheditarry)=>{ let{shixuns_listeditlist,shixuns_listedit}=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) => { if(response){ if(response.data){ let newshixun_lists=response.data.shixun_lists; for(var j=0; j { console.log(error) }); } //点击新建阶段 addStage=()=>{ this.props.editeditbuttomtypes(); this.setState({ editPanel:true }) } //取消新建阶段 cancelAddState = () =>{ this.setState({ editPanel:false, stage_names:undefined, stage_descriptions:undefined, shixuns_listeditlist:[], shixuns_listedit:[] }) this.props.getPathCardsLists(); } searchNameInput=(e)=>{ this.setState({ search:e.target.value }) } //勾选实训 shixunhomeworkedit=(list)=>{ let newpatheditarry=[]; for(var i=0; i{ this.setState({ stage_names:e.target.value }) } updatastage_descriptions=(e)=>{ this.setState({ stage_descriptions:e.target.value }) } //删除实训 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 }) this.setState({ Modalstype:false, Modalstopval:'', Modalsbottomval:'', delectfunvalue:undefined }) } cardsModalcancel=()=>{ this.setState({ Modalstype:false, Modalstopval:'', Modalsbottomval:'', delectfunvalue:undefined }) } //保存 clickShixunsaves=()=>{ let{stage_names,stage_descriptions,shixuns_listeditlist}=this.state; let newstage_descriptions=stage_descriptions; if(stage_names===""||stage_names===undefined){ this.setState({ stage_nametype:true }) return }else{ this.setState({ stage_nametype:false }) } if(newstage_descriptions!=undefined){ if(newstage_descriptions.length>300){ this.setState({ descriptiontype:true }) return } }else{ newstage_descriptions="" } let pathId=this.props.pathid; let url; if(this.props.ysldetailcards===undefined){ url='/stages.json?subject_id='+pathId; }else{ url=`/courses/${this.props.coursesId}/course_stages.json`; } axios.post(url, { name:stage_names, description:newstage_descriptions, shixun_id:shixuns_listeditlist }).then((response) => { // window.location.href = "/paths/" + response.data.subject_id this.props.getPathCardsLists(); this.cancelAddState(); this.setState({ stage_nametype:false, descriptiontype:false }) }).catch((error) => { console.log(error) }); } 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 }) } render(){ let {selectShixun, editPanel, ChooseShixunList, type, page, search, hometypepvisible, stage_descriptions, stage_names, shixuns_listedit, delectfunvalue, Modalstype, Modalstopval, Modalsbottomval, ChooseShixunListshixun_list, stage_nametype, descriptiontype} = this.state return(
{ editPanel &&

第{this.props.sum}部分 {/**/}

章节名称

*
名称不能为空
必填项

描述

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

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

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

frerere

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

} {this.props.detailInfoList===undefined?"":this.props.detailInfoList.allow_statistics===true?editPanel===false?
+点击新建阶段(选择1至多个实训项目,组成一个阶段)
:'':''} {this.props.detailInfoList===undefined&&this.props.isAdmin()&&editPanel===false?
+点击新建阶段(选择1至多个实训项目,组成一个阶段)
:''}
) } } export default DetailCardsEditAndAdd; // // // //
// //
// // // {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}
  • //
  • 详情
  • //
    // ) // }) // } //
    //
    } //
    // 取消 // 确定 //
    //
    //
    //
    // contentViewScrolladd=(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{ // // console.log("到达底部"); // this.setState({ // hometypepvisible:true // }) // let pathId=this.props.pathid; // let {search,page,type,ChooseShixunListshixun_list}=this.state; // let newpage=page+1; // 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); // }) // // } // // } // // } // // //打开选择实训弹框初始化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, // ChooseShixunListshixun_list:result.data.shixun_list // }) // } // }).catch((error)=>{ // console.log(error); // }) // }