From 11253a8cf83367b40134bdbf4dea3bf713dc3985 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Fri, 27 Sep 2019 14:40:53 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=96=B0=E7=89=88=E5=AE=9E=E8=AE=AD?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/config/webpack.config.dev.js | 2 +- .../courses/coursesPublic/NewShixunModel.js | 204 +++++++++++++----- .../courses/shixunHomework/shixunHomework.js | 54 ++--- 3 files changed, 169 insertions(+), 91 deletions(-) diff --git a/public/react/config/webpack.config.dev.js b/public/react/config/webpack.config.dev.js index aabcd8fb7..e504d2fb6 100644 --- a/public/react/config/webpack.config.dev.js +++ b/public/react/config/webpack.config.dev.js @@ -32,7 +32,7 @@ module.exports = { // See the discussion in https://github.com/facebookincubator/create-react-app/issues/343.s // devtool: "cheap-module-eval-source-map", // 开启调试 - // devtool: "eval-source-map", // 开启调试 + devtool: "eval-source-map", // 开启调试 // These are the "entry points" to our application. // 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. diff --git a/public/react/src/modules/courses/coursesPublic/NewShixunModel.js b/public/react/src/modules/courses/coursesPublic/NewShixunModel.js index bae89a7ba..e3c90c7eb 100644 --- a/public/react/src/modules/courses/coursesPublic/NewShixunModel.js +++ b/public/react/src/modules/courses/coursesPublic/NewShixunModel.js @@ -19,19 +19,30 @@ class NewShixunModel extends Component{ order:'desc', diff:0, limit:15, + sort:"myshixuns_count" } } componentDidMount() { - let{page,type,keyword,order,diff,limit,status}=this.state; - this.getdatalist(page,type,status,keyword,order,diff,limit) + let{page,type,keyword,order,diff,limit,status,sort}=this.state; + 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({ isspinning:true }) 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:{ page, type, @@ -39,20 +50,21 @@ class NewShixunModel extends Component{ keyword, order, diff, - limit + limit, + sort }}).then((response) => { if(response.data){ if(pagetype===undefined){ this.setState({ - shixun_list:response.data.shixun_list, - shixuns_count:response.data.shixuns_count, + shixun_list:response.data.shixun_list===undefined?response.data.subject_list:response.data.shixun_list, + shixuns_count:response.data.shixuns_count===undefined?response.data.subjects_count:response.data.shixuns_count, Grouplist:[], isspinning:false }) }else if(pagetype==="pagetype"){ this.setState({ - shixun_list:response.data.shixun_list, - shixuns_count:response.data.shixuns_count, + shixun_list:response.data.shixun_list===undefined?response.data.subject_list:response.data.shixun_list, + shixuns_count:response.data.shixuns_count===undefined?response.data.subjects_count:response.data.shixuns_count, isspinning:false }) } @@ -127,8 +139,13 @@ class NewShixunModel extends Component{ newallGrouplist.push({page:pageNumber,list:[]}) } - let{type,status,keyword,order,diff,limit}=this.state; - this.getdatalist(pageNumber,type,status,keyword,order,diff,limit,"pagetype") + let{type,status,keyword,order,diff,limit,sort}=this.state; + 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({ page:pageNumber, allGrouplist:newallGrouplist @@ -142,8 +159,14 @@ class NewShixunModel extends Component{ keyword:undefined, page:1 }) - let{status,order,diff,limit}=this.state; - this.getdatalist(1,value,status,undefined,order,diff,limit) + let{status,order,diff,limit,sort}=this.state; + 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)=>{ @@ -205,7 +228,7 @@ class NewShixunModel extends Component{ this.setState({ hometypepvisible:false }) - this.showNotification("请先选择实训") + this.showNotification(this.props.type==='shixuns'?"请先选择实训":"请先选择课程") return } @@ -231,33 +254,64 @@ class NewShixunModel extends Component{ this.props.pathShixun(Grouplist) return; } - let url="/courses/"+coursesId+"/homework_commons/create_shixun_homework.json"; - axios.post(url, { - 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){ - // this.props.showNotification(response.data.message) + if(this.props.type==='shixuns'){ + let url="/courses/"+coursesId+"/homework_commons/create_shixun_homework.json"; + axios.post(url, { + 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){ + // 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() + }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 + } + this.setState({ + 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 - // homework_ids: (5) [9171, 9172, 9173, 9174, 9175] - }).catch((error) => { - console.log(error) - this.setState({ - hometypepvisible:false + }else{ + let url="/courses/"+coursesId+"/homework_commons/create_subject_homework.json"; + axios.post(url, { + category_id:this.props.category_id===null||this.props.category_id===undefined?undefined:parseInt(this.props.category_id), + subject_ids:Grouplist, + } + ).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)=>{ @@ -268,9 +322,37 @@ class NewShixunModel extends Component{ 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() { - 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; // console.log(Grouplist) // console.log(allGrouplist) @@ -331,7 +413,7 @@ class NewShixunModel extends Component{ ); - + console.log(shixun_list) return(
@@ -355,7 +437,7 @@ class NewShixunModel extends Component{ closable={true} destroyOnClose={true} onClose={()=>this.props.hideNewShixunModelType()} - visible={this.props.NewShixunModelType} + visible={this.props.type==='shixuns'?this.props.NewShixunModelType:this.props.shixunpath} height={'100%'} > @@ -380,7 +462,7 @@ class NewShixunModel extends Component{ 搜索} onInput={(e)=>this.setdatafunsval(e)} @@ -391,34 +473,50 @@ class NewShixunModel extends Component{
- 已选 {Grouplist.length} 个实训 - {shixuns_count===undefined?"":shixuns_count} 个实训 + 已选 {Grouplist.length} 个{this.props.type==='shixuns'?'实训':'课程'} + {shixuns_count===undefined?"":shixuns_count} 个{this.props.type==='shixuns'?'实训':'课程'} - + {this.props.type==='shixuns'?"": + this.updatepathlist("shixuns_count",order)}>实训数 + + + + + } + + {this.props.type==='shixuns'?"": + this.updatepathlist("myshixuns_count",order)}>使用人数 + + + + + } + + {this.props.type==='shixuns'? this.updatedlist(order)}>学习人数 - + :""} - {this.props.statustype===undefined? + {this.props.type==='shixuns'?this.props.statustype===undefined? {status==='all'?"发布状态":status==='published'?"已发布":status==="unpublished"?"未发布":""} - :""} + :"":""} - + {this.props.type==='shixuns'? {diff===0?"难度":diff===1?"初级":diff===2?"中级":diff===3?"高级":diff===4?"顶级":""} - + :""}
{/*this.props.hideNewShixunModelType()}>返回*/} - this.belongto("mine")}>我的实训 - this.belongto("all")}>全部实训 + this.belongto("mine")}>我的{this.props.type==='shixuns'?'实训':"课程"} + this.belongto("all")}>全部{this.props.type==='shixuns'?'实训':"课程"}
@@ -461,7 +559,7 @@ class NewShixunModel extends Component{ {JSON.stringify(item.description) == "{}"?"":
} - {item.challenge_names.length===0?"":
+ {item.challenge_names===undefined?"":item.challenge_names.length===0?"":
{item.challenge_names.map((item,key)=>{ return( 第{key+1}关:{item} @@ -498,7 +596,7 @@ class NewShixunModel extends Component{
- {item.subjects.length===0?"":this.ItsCourse(item.subjects)}> + {item.subjects===undefined?"":item.subjects.length===0?"":this.ItsCourse(item.subjects)}> 所属课程 diff --git a/public/react/src/modules/courses/shixunHomework/shixunHomework.js b/public/react/src/modules/courses/shixunHomework/shixunHomework.js index 5298baffc..c15a19f8f 100644 --- a/public/react/src/modules/courses/shixunHomework/shixunHomework.js +++ b/public/react/src/modules/courses/shixunHomework/shixunHomework.js @@ -908,7 +908,8 @@ class ShixunHomework extends Component{ } hideNewShixunModelType=()=>{ this.setState({ - NewShixunModelType:false + NewShixunModelType:false, + shixunpath:false }) } render(){ @@ -971,6 +972,20 @@ class ShixunHomework extends Component{ statustype={'published'} />:""} + {/*新版实训model*/} + {shixunpath===true?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?this.getcourse_groupslist(id)} />:""} - {/*/!*选择实训*!/*/} - {/*{shixunmodal===true?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?:""} - {/*选择实训路径*/} - {shixunpath===true? 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)} - />:""} + {/*添加目录/选择目录*/} From f9d576bbc8abc3247529886e6e8513ae443ab177 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Fri, 27 Sep 2019 14:43:44 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../react/src/modules/courses/coursesPublic/NewShixunModel.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/react/src/modules/courses/coursesPublic/NewShixunModel.js b/public/react/src/modules/courses/coursesPublic/NewShixunModel.js index e3c90c7eb..062390f1e 100644 --- a/public/react/src/modules/courses/coursesPublic/NewShixunModel.js +++ b/public/react/src/modules/courses/coursesPublic/NewShixunModel.js @@ -269,7 +269,7 @@ class NewShixunModel extends Component{ this.showNotification("操作成功") this.props.homeworkupdatalists(this.props.Coursename,this.props.page,this.props.order); this.props.hideNewShixunModelType() - + this.props.updataleftNavfun() } this.setState({ hometypepvisible:false @@ -297,7 +297,7 @@ class NewShixunModel extends Component{ this.showNotification("操作成功") this.props.homeworkupdatalists(this.props.Coursename,this.props.page,this.props.order); this.props.hideNewShixunModelType() - + this.props.updataleftNavfun() } this.setState({ hometypepvisible:false