新版实训课程

dev_newshixunModel
杨树明 5 years ago
parent 011ae35867
commit 11253a8cf8

@ -32,7 +32,7 @@ module.exports = {
// See the discussion in https://github.com/facebookincubator/create-react-app/issues/343.s // See the discussion in https://github.com/facebookincubator/create-react-app/issues/343.s
// devtool: "cheap-module-eval-source-map", // devtool: "cheap-module-eval-source-map",
// 开启调试 // 开启调试
// devtool: "eval-source-map", // 开启调试 devtool: "eval-source-map", // 开启调试
// These are the "entry points" to our application. // These are the "entry points" to our application.
// This means they will be the "root" imports that are included in JS bundle. // This means they will be the "root" imports that are included in JS bundle.
// The first two entry points enable "hot" CSS and auto-refreshes for JS. // The first two entry points enable "hot" CSS and auto-refreshes for JS.

@ -19,19 +19,30 @@ class NewShixunModel extends Component{
order:'desc', order:'desc',
diff:0, diff:0,
limit:15, limit:15,
sort:"myshixuns_count"
} }
} }
componentDidMount() { componentDidMount() {
let{page,type,keyword,order,diff,limit,status}=this.state; let{page,type,keyword,order,diff,limit,status,sort}=this.state;
this.getdatalist(page,type,status,keyword,order,diff,limit) if(this.props.type==='shixuns'){
this.getdatalist(page,type,status,keyword,order,diff,limit)
}else{
this.getdatalist(page,type,undefined,keyword,order,undefined,limit,undefined,sort);
}
} }
getdatalist=(page,type,newstatus,keyword,order,diff,limit,pagetype)=>{ getdatalist=(page,type,newstatus,keyword,order,diff,limit,pagetype,sort)=>{
this.setState({ this.setState({
isspinning:true isspinning:true
}) })
let status=this.props.statustype===undefined?newstatus:'published'; let status=this.props.statustype===undefined?newstatus:'published';
let url="/shixun_lists.json" let url;
if(this.props.type==='shixuns'){
url="/shixun_lists.json";
}else{
url="/subject_lists.json";
}
axios.get(url,{params:{ axios.get(url,{params:{
page, page,
type, type,
@ -39,20 +50,21 @@ class NewShixunModel extends Component{
keyword, keyword,
order, order,
diff, diff,
limit limit,
sort
}}).then((response) => { }}).then((response) => {
if(response.data){ if(response.data){
if(pagetype===undefined){ if(pagetype===undefined){
this.setState({ this.setState({
shixun_list:response.data.shixun_list, shixun_list:response.data.shixun_list===undefined?response.data.subject_list:response.data.shixun_list,
shixuns_count:response.data.shixuns_count, shixuns_count:response.data.shixuns_count===undefined?response.data.subjects_count:response.data.shixuns_count,
Grouplist:[], Grouplist:[],
isspinning:false isspinning:false
}) })
}else if(pagetype==="pagetype"){ }else if(pagetype==="pagetype"){
this.setState({ this.setState({
shixun_list:response.data.shixun_list, shixun_list:response.data.shixun_list===undefined?response.data.subject_list:response.data.shixun_list,
shixuns_count:response.data.shixuns_count, shixuns_count:response.data.shixuns_count===undefined?response.data.subjects_count:response.data.shixuns_count,
isspinning:false isspinning:false
}) })
} }
@ -127,8 +139,13 @@ class NewShixunModel extends Component{
newallGrouplist.push({page:pageNumber,list:[]}) newallGrouplist.push({page:pageNumber,list:[]})
} }
let{type,status,keyword,order,diff,limit}=this.state; let{type,status,keyword,order,diff,limit,sort}=this.state;
this.getdatalist(pageNumber,type,status,keyword,order,diff,limit,"pagetype") if(this.props.type==='shixuns'){
this.getdatalist(pageNumber,type,status,keyword,order,diff,limit,"pagetype")
}else{
this.getdatalist(pageNumber,type,undefined,keyword,order,undefined,limit,"pagetype",sort);
}
this.setState({ this.setState({
page:pageNumber, page:pageNumber,
allGrouplist:newallGrouplist allGrouplist:newallGrouplist
@ -142,8 +159,14 @@ class NewShixunModel extends Component{
keyword:undefined, keyword:undefined,
page:1 page:1
}) })
let{status,order,diff,limit}=this.state; let{status,order,diff,limit,sort}=this.state;
this.getdatalist(1,value,status,undefined,order,diff,limit) if(this.props.type==='shixuns'){
this.getdatalist(1,value,status,undefined,order,diff,limit)
}else{
this.getdatalist(1,value,undefined,undefined,order,undefined,limit,undefined,sort)
}
} }
updatedlist=(order)=>{ updatedlist=(order)=>{
@ -205,7 +228,7 @@ class NewShixunModel extends Component{
this.setState({ this.setState({
hometypepvisible:false hometypepvisible:false
}) })
this.showNotification("请先选择实训") this.showNotification(this.props.type==='shixuns'?"请先选择实训":"请先选择课程")
return return
} }
@ -231,33 +254,64 @@ class NewShixunModel extends Component{
this.props.pathShixun(Grouplist) this.props.pathShixun(Grouplist)
return; return;
} }
let url="/courses/"+coursesId+"/homework_commons/create_shixun_homework.json"; if(this.props.type==='shixuns'){
axios.post(url, { let url="/courses/"+coursesId+"/homework_commons/create_shixun_homework.json";
category_id:this.props.category_id===null||this.props.category_id===undefined?undefined:parseInt(this.props.category_id), axios.post(url, {
shixun_ids:Grouplist, category_id:this.props.category_id===null||this.props.category_id===undefined?undefined:parseInt(this.props.category_id),
} shixun_ids:Grouplist,
).then((response) => { }
if(response.data.status===-1){ ).then((response) => {
// this.props.showNotification(response.data.message) if(response.data.status===-1){
// this.props.showNotification(response.data.message)
}else{ }else{
// this.props.courseshomeworkstart(response.data.category_id,response.data.homework_ids) // this.props.courseshomeworkstart(response.data.category_id,response.data.homework_ids)
this.showNotification("操作成功") this.showNotification("操作成功")
this.props.homeworkupdatalists(this.props.Coursename,this.props.page,this.props.order); this.props.homeworkupdatalists(this.props.Coursename,this.props.page,this.props.order);
this.props.hideNewShixunModelType() this.props.hideNewShixunModelType()
} }
this.setState({ this.setState({
hometypepvisible:false hometypepvisible:false
})
// category_id: 3
// homework_ids: (5) [9171, 9172, 9173, 9174, 9175]
}).catch((error) => {
console.log(error)
this.setState({
hometypepvisible:false
})
}) })
// category_id: 3 }else{
// homework_ids: (5) [9171, 9172, 9173, 9174, 9175] let url="/courses/"+coursesId+"/homework_commons/create_subject_homework.json";
}).catch((error) => { axios.post(url, {
console.log(error) category_id:this.props.category_id===null||this.props.category_id===undefined?undefined:parseInt(this.props.category_id),
this.setState({ subject_ids:Grouplist,
hometypepvisible:false }
).then((response) => {
if(response.data.status===-1){
// this.props.showNotification(response.data.message)
}else{
// this.props.courseshomeworkstart(response.data.category_id,response.data.homework_ids)
this.showNotification("操作成功")
this.props.homeworkupdatalists(this.props.Coursename,this.props.page,this.props.order);
this.props.hideNewShixunModelType()
}
this.setState({
hometypepvisible:false
})
// category_id: 3
// homework_ids: (5) [9171, 9172, 9173, 9174, 9175]
}).catch((error) => {
console.log(error)
this.setState({
hometypepvisible:false
})
}) })
}) }
} }
poststatus=(status)=>{ poststatus=(status)=>{
@ -268,9 +322,37 @@ class NewShixunModel extends Component{
this.getdatalist(page,type,status,keyword,order,diff,limit) this.getdatalist(page,type,status,keyword,order,diff,limit)
} }
updatepathlist=(sorts,orders)=>{
let{page,type,keyword,order,diff,limit,status,sort}=this.state;
let seartorders;
if(sort===sorts){
if(orders==="desc"){
this.setState({
sort:sorts,
order:"asc"
})
seartorders="asc"
}else{
this.setState({
sort:sorts,
order:"desc"
})
seartorders="desc"
}
}else{
this.setState({
sort:sorts,
order:"desc"
})
seartorders=orders
}
this.getdatalist(page,type,undefined,keyword,seartorders,undefined,limit,undefined,sorts)
}
render() { render() {
let {diff,Grouplist,status,shixun_list,shixuns_count,page,type,order}=this.state; let {diff,Grouplist,status,shixun_list,shixuns_count,page,type,order,sort}=this.state;
// let {visible,patheditarry}=this.props; // let {visible,patheditarry}=this.props;
// console.log(Grouplist) // console.log(Grouplist)
// console.log(allGrouplist) // console.log(allGrouplist)
@ -331,7 +413,7 @@ class NewShixunModel extends Component{
); );
console.log(shixun_list)
return( return(
<div> <div>
@ -355,7 +437,7 @@ class NewShixunModel extends Component{
closable={true} closable={true}
destroyOnClose={true} destroyOnClose={true}
onClose={()=>this.props.hideNewShixunModelType()} onClose={()=>this.props.hideNewShixunModelType()}
visible={this.props.NewShixunModelType} visible={this.props.type==='shixuns'?this.props.NewShixunModelType:this.props.shixunpath}
height={'100%'} height={'100%'}
> >
<Spin spinning={this.state.isspinning}> <Spin spinning={this.state.isspinning}>
@ -380,7 +462,7 @@ class NewShixunModel extends Component{
<Search <Search
style={{ width: "780px"}} style={{ width: "780px"}}
className="packinput" className="packinput"
placeholder="实训信息 / 院校名称 / 创建者" placeholder={this.props.type==='shixuns'?"实训信息 / 院校名称 / 创建者":"课程名称 / 院校名称 / 创建者"}
value={this.state.keyword} value={this.state.keyword}
enterButton={<span>搜索</span>} enterButton={<span>搜索</span>}
onInput={(e)=>this.setdatafunsval(e)} onInput={(e)=>this.setdatafunsval(e)}
@ -391,34 +473,50 @@ class NewShixunModel extends Component{
<div className="font-12 ml5 fl"> <div className="font-12 ml5 fl">
<span className="fl color-grey-9 mr20">已选 <span className={"color-blue"}>{Grouplist.length}</span> </span> <span className="fl color-grey-9 mr20">已选 <span className={"color-blue"}>{Grouplist.length}</span> {this.props.type==='shixuns'?'':''}</span>
<span className="fl color-grey-9 mr20"> <span className={"color-blue"}>{shixuns_count===undefined?"":shixuns_count}</span> </span> <span className="fl color-grey-9 mr20"> <span className={"color-blue"}>{shixuns_count===undefined?"":shixuns_count}</span> {this.props.type==='shixuns'?'':''}</span>
<span className="fl color-grey-9 pointer mr30"> {this.props.type==='shixuns'?"":<span className="fl color-grey-9 pointer mr30">
<a className={" color-grey-6"} onClick={()=>this.updatepathlist("shixuns_count",order)}>实训数</a>
<sapn className="relativef ml5 " >
<i className={order==="asc"&&sort==="shixuns_count"?"iconfont icon-sanjiaoxing-up font-12 ntopsj color-grey-9 color-blue":"iconfont icon-sanjiaoxing-up font-12 ntopsj color-grey-9"}></i>
<i className={order==="desc"&&sort==="shixuns_count"?"iconfont icon-sanjiaoxing-down font-12 nyslbottomsj color-grey-9 color-blue":"iconfont icon-sanjiaoxing-down font-12 nyslbottomsj color-grey-9"}></i>
</sapn>
</span>}
{this.props.type==='shixuns'?"":<span className="fl color-grey-9 pointer mr30">
<a className={" color-grey-6"} onClick={()=>this.updatepathlist("myshixuns_count",order)}>使用人数</a>
<sapn className="relativef ml5 " >
<i className={order==="asc"&&sort==="myshixuns_count"?"iconfont icon-sanjiaoxing-up font-12 ntopsj color-grey-9 color-blue":"iconfont icon-sanjiaoxing-up font-12 ntopsj color-grey-9"}></i>
<i className={order==="desc"&&sort==="myshixuns_count"?"iconfont icon-sanjiaoxing-down font-12 nyslbottomsj color-grey-9 color-blue":"iconfont icon-sanjiaoxing-down font-12 nyslbottomsj color-grey-9"}></i>
</sapn>
</span>}
{this.props.type==='shixuns'?<span className="fl color-grey-9 pointer mr30">
<a className={" color-grey-6"} onClick={()=>this.updatedlist(order)}>学习人数</a> <a className={" color-grey-6"} onClick={()=>this.updatedlist(order)}>学习人数</a>
<sapn className="relativef ml5 " > <sapn className="relativef ml5 " >
<i className={order==="asc"?"iconfont icon-sanjiaoxing-up font-12 ntopsj color-grey-9 color-blue":"iconfont icon-sanjiaoxing-up font-12 ntopsj color-grey-9"}></i> <i className={order==="asc"?"iconfont icon-sanjiaoxing-up font-12 ntopsj color-grey-9 color-blue":"iconfont icon-sanjiaoxing-up font-12 ntopsj color-grey-9"}></i>
<i className={order==="desc"?"iconfont icon-sanjiaoxing-down font-12 nyslbottomsj color-grey-9 color-blue":"iconfont icon-sanjiaoxing-down font-12 nyslbottomsj color-grey-9"}></i> <i className={order==="desc"?"iconfont icon-sanjiaoxing-down font-12 nyslbottomsj color-grey-9 color-blue":"iconfont icon-sanjiaoxing-down font-12 nyslbottomsj color-grey-9"}></i>
</sapn> </sapn>
</span> </span>:""}
{this.props.statustype===undefined?<Dropdown overlay={statusmenus}> {this.props.type==='shixuns'?this.props.statustype===undefined?<Dropdown overlay={statusmenus}>
<a className="ant-dropdown-link color-grey-6 mr20"> <a className="ant-dropdown-link color-grey-6 mr20">
{status==='all'?"发布状态":status==='published'?"已发布":status==="unpublished"?"未发布":""}<Icon type="down" className={"color-grey-6"}/> {status==='all'?"发布状态":status==='published'?"已发布":status==="unpublished"?"未发布":""}<Icon type="down" className={"color-grey-6"}/>
</a> </a>
</Dropdown>:""} </Dropdown>:"":""}
<Dropdown overlay={menus}> {this.props.type==='shixuns'? <Dropdown overlay={menus}>
<a className="ant-dropdown-link color-grey-6"> <a className="ant-dropdown-link color-grey-6">
{diff===0?"难度":diff===1?"初级":diff===2?"中级":diff===3?"高级":diff===4?"顶级":""}<Icon type="down" className={"color-grey-6"}/> {diff===0?"难度":diff===1?"初级":diff===2?"中级":diff===3?"高级":diff===4?"顶级":""}<Icon type="down" className={"color-grey-6"}/>
</a> </a>
</Dropdown> </Dropdown>:""}
</div> </div>
<div className="font-12 alltopiscright ml25 fr"> <div className="font-12 alltopiscright ml25 fr">
{/*<span className={"fr pointer color-grey-3"} onClick={()=>this.props.hideNewShixunModelType()}>返回</span>*/} {/*<span className={"fr pointer color-grey-3"} onClick={()=>this.props.hideNewShixunModelType()}>返回</span>*/}
<span className={type==="mine"?"fr topcsactive pointer color-grey-3 color-blue":"fr pointer color-grey-3"} onClick={()=>this.belongto("mine")}>我的实训</span> <span className={type==="mine"?"fr topcsactive pointer color-grey-3 color-blue":"fr pointer color-grey-3"} onClick={()=>this.belongto("mine")}>我的{this.props.type==='shixuns'?'实训':"课程"}</span>
<span className={type==="all"?"fr mr30 topcsactive pointer color-grey-3 color-blue":"fr mr30 pointer color-grey-3"} onClick={()=>this.belongto("all")}>全部实训</span> <span className={type==="all"?"fr mr30 topcsactive pointer color-grey-3 color-blue":"fr mr30 pointer color-grey-3"} onClick={()=>this.belongto("all")}>全部{this.props.type==='shixuns'?'实训':"课程"}</span>
</div> </div>
</div> </div>
@ -461,7 +559,7 @@ class NewShixunModel extends Component{
{JSON.stringify(item.description) == "{}"?"":<div className="newshixunmodelmidfont newradioStyles" dangerouslySetInnerHTML={{__html: item.description}}> {JSON.stringify(item.description) == "{}"?"":<div className="newshixunmodelmidfont newradioStyles" dangerouslySetInnerHTML={{__html: item.description}}>
</div>} </div>}
{item.challenge_names.length===0?"":<div className="newshixunmodelbotfont"> {item.challenge_names===undefined?"":item.challenge_names.length===0?"":<div className="newshixunmodelbotfont">
{item.challenge_names.map((item,key)=>{ {item.challenge_names.map((item,key)=>{
return( return(
<span>{key+1}{item}</span> <span>{key+1}{item}</span>
@ -498,7 +596,7 @@ class NewShixunModel extends Component{
</Breadcrumb> </Breadcrumb>
</div> </div>
{item.subjects.length===0?"":<Dropdown overlay={()=>this.ItsCourse(item.subjects)}> {item.subjects===undefined?"":item.subjects.length===0?"":<Dropdown overlay={()=>this.ItsCourse(item.subjects)}>
<a className="ant-dropdown-link fl ml30 newshixunfont12 color-blue" > <a className="ant-dropdown-link fl ml30 newshixunfont12 color-blue" >
所属课程<Icon className={"color-blue"} type="down" /> 所属课程<Icon className={"color-blue"} type="down" />
</a> </a>

@ -908,7 +908,8 @@ class ShixunHomework extends Component{
} }
hideNewShixunModelType=()=>{ hideNewShixunModelType=()=>{
this.setState({ this.setState({
NewShixunModelType:false NewShixunModelType:false,
shixunpath:false
}) })
} }
render(){ render(){
@ -971,6 +972,20 @@ class ShixunHomework extends Component{
statustype={'published'} statustype={'published'}
/>:""} />:""}
{/*新版实训model*/}
{shixunpath===true?<NewShixunModel
{...this.props}
{...this.state}
category_id={this.props.match.params.category_id}
type={'path'}
hideNewShixunModelType={()=>this.hideNewShixunModelType()}
coursesId={this.props.match.params.coursesId}
homeworkupdatalists={(Coursename,page,order)=>this.homeworkupdatalist(Coursename,page,order)}
Coursename={Coursename}
page={page}
order={order}
/>:""}
{/*提示*/} {/*提示*/}
{Modalstype&&Modalstype===true?<Modals {Modalstype&&Modalstype===true?<Modals
@ -1005,23 +1020,6 @@ class ShixunHomework extends Component{
getcourse_groupslist={(id)=>this.getcourse_groupslist(id)} getcourse_groupslist={(id)=>this.getcourse_groupslist(id)}
/>:""} />:""}
{/*/!*选择实训*!/*/}
{/*{shixunmodal===true?<ShixunModal*/}
{/*{...this.props}*/}
{/*{...this.state}*/}
{/*datas={datas}*/}
{/*category_id={this.props.match.params.category_id}*/}
{/*visible={shixunmodal}*/}
{/*shixunmodallist={shixunmodallist}*/}
{/*homeworkupdatalists={(Coursename,page,order)=>this.homeworkupdatalist(Coursename,page,order)}*/}
{/*hometypepvisible={hometypepvisible}*/}
{/*hidecouseShixunModal={this.hidecouseShixunModal}*/}
{/*newshixunmodallist={newshixunmodallist}*/}
{/*coursesId={this.props.match.params.coursesId}*/}
{/*courseshomeworkstart={(category_id,homework_ids)=>this.newhomeworkstart(category_id,homework_ids)}*/}
{/*funpatheditarry={(patheditarry)=>this.funpatheditarry(patheditarry)}*/}
{/*patheditarry={patheditarry}*/}
{/*/>:""}*/}
{shixunmodal===true||shixunpath===true?<style> {shixunmodal===true||shixunpath===true?<style>
{ {
@ -1032,25 +1030,7 @@ class ShixunHomework extends Component{
` `
} }
</style>:""} </style>:""}
{/*选择实训路径*/}
{shixunpath===true? <PathModal
{...this.props}
{...this.state}
datas={datas}
visible={shixunpath}
shixunmodallist={this.state.shixunpathlist}
newshixunmodallist={this.state.newshixunpathlist}
// funshixunpathlist={(search,type,loading,page)=>this.funshixunpathlist(search,type,loading,page)}
hometypepvisible={hometypepvisible}
hidecouseShixunModal={this.hidecouseShixunModal}
coursesId={this.props.match.params.coursesId}
homeworkupdatalists={(Coursename,page,order)=>this.homeworkupdatalist(Coursename,page,order)}
courseshomeworkstart={(category_id,homework_ids)=>this.newhomeworkstart(category_id,homework_ids)}
Coursename={Coursename}
page={page}
order={order}
// courseshomeworkstart={(category_id,homework_ids)=>this.newhomeworkstart(category_id,homework_ids)}
/>:""}
{/*添加目录/选择目录*/} {/*添加目录/选择目录*/}

Loading…
Cancel
Save