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(