From 24b77c17f62d7424d7ff2b21f3537179f47f72e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Thu, 29 Aug 2019 14:52:47 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=98=E7=9B=AE=E9=A1=B5=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/modules/user/usersInfo/InfosTopics.js | 129 ++++++++---------- .../src/modules/user/usersInfo/usersInfo.css | 2 +- 2 files changed, 57 insertions(+), 74 deletions(-) diff --git a/public/react/src/modules/user/usersInfo/InfosTopics.js b/public/react/src/modules/user/usersInfo/InfosTopics.js index fc4e75a10..d7249e899 100644 --- a/public/react/src/modules/user/usersInfo/InfosTopics.js +++ b/public/react/src/modules/user/usersInfo/InfosTopics.js @@ -22,51 +22,40 @@ class InfosTopics extends Component{ sort_direction:"desc", page:1, data:undefined, - checkBoxValues:[] + checkBoxValues:[], + per_page:15 } } - componentDidMount=()=>{ + componentDidMount(){ let types=this.props.match.params.topicstype; - let { category, - course_list_id, - sort_by, - sort_direction, - page - }=this.state; - this.searchAlldata( - types, - category, - course_list_id, - sort_by, - sort_direction, - page - ) - + let { category,course_list_id,sort_by,sort_direction,page}=this.state; + this.searchAlldata(types,category,course_list_id,sort_by,sort_direction,page) } searchAlldata=(type,category,course_list_id,sort_by,sort_direction,page)=>{ let user_id=this.props.current_user&&this.props.current_user.user_id; + if(user_id!=undefined){ + let {per_page}=this.state; + let url=`/users/${user_id}/question_banks.json`; + axios.get(url,{params:{ + type, + category, + course_list_id, + sort_by, + sort_direction, + page, + per_page + } + }).then((response) => { + this.setState({ + data:response.data + }) + }).catch((error) => { + + }); + } - - let url=`/users/${user_id}/question_banks.json`; - - axios.get(url,{params:{ - type, - category, - course_list_id, - sort_by, - sort_direction, - page - } - }).then((response) => { - this.setState({ - data:response.data - }) - }).catch((error) => { - - - }); } searchCategory=(type)=>{ @@ -75,20 +64,8 @@ class InfosTopics extends Component{ }) let types=this.props.match.params.topicstype; - let { category, - course_list_id, - sort_by, - sort_direction, - page - }=this.state; - this.searchAlldata( - types, - type, - course_list_id, - sort_by, - sort_direction, - page - ) + let { category,course_list_id,sort_by,sort_direction,page}=this.state; + this.searchAlldata(types,type,course_list_id,sort_by,sort_direction,page) } searchCourselistid=(id)=>{ @@ -97,52 +74,57 @@ class InfosTopics extends Component{ }) let types=this.props.match.params.topicstype; - let { category, - course_list_id, - sort_by, - sort_direction, - page - }=this.state; - this.searchAlldata( - types, - category, - id, - sort_by, - sort_direction, - page - ) + let { category,course_list_id,sort_by,sort_direction,page}=this.state; + this.searchAlldata(types,category,id,sort_by,sort_direction,page) } onCheckBoxChange=(checkedValues)=>{ - debugger - this.setState({ - checkBoxValues:checkedValues - }) + if(checkedValues.length>15){ + this.props.showNotification("选择条数不能大于15条") + }else{ + this.setState({ + checkBoxValues:checkedValues + }) + } + } updatedlist=(updatedtype)=>{ - let {sort_by,sort_direction}=this.state; + let types=this.props.match.params.topicstype; + let { category,course_list_id,sort_by,sort_direction,page}=this.state; if(updatedtype===sort_by){ if(sort_direction==="desc"){ this.setState({ sort_direction:"asc", sort_by:updatedtype }) + this.searchAlldata(types,category,course_list_id,updatedtype,"asc",page) }else{ this.setState({ sort_direction:"desc", sort_by:updatedtype }) + this.searchAlldata(types,category,course_list_id,updatedtype,"desc",page) } }else{ this.setState({ sort_direction:"desc", sort_by:updatedtype }) + this.searchAlldata(types,category,course_list_id,updatedtype,"desc",page) } + } + changePage=(pageNumber)=>{ + let types=this.props.match.params.topicstype; + let { category,course_list_id,sort_by,sort_direction,page}=this.state; + this.searchAlldata(types,category,course_list_id,sort_by,sort_direction,pageNumber) + this.setState({ + page:pageNumber + }) } + render(){ let{ category, @@ -151,7 +133,8 @@ class InfosTopics extends Component{ data, page, sort_direction, - sort_by + sort_by, + checkBoxValues } = this.state; let categorylist=[ @@ -165,7 +148,7 @@ class InfosTopics extends Component{ let types=this.props.match.params.topicstype; - console.log(sort_by) + console.log(checkBoxValues) //types===publicly 公共 //types===personal 私有 @@ -265,7 +248,7 @@ class InfosTopics extends Component{

{data&&data.count} - 已选择 {this.state.checkBoxValues.length} + 已选择 {checkBoxValues.length} 个 (不支持跨页勾选)

@@ -286,7 +269,7 @@ class InfosTopics extends Component{ {data===undefined?:data.question_banks===undefined||data.question_banks.length===0?: - + {data.question_banks.map((item,key)=>{ return(

diff --git a/public/react/src/modules/user/usersInfo/usersInfo.css b/public/react/src/modules/user/usersInfo/usersInfo.css index f57612f77..fc1437994 100644 --- a/public/react/src/modules/user/usersInfo/usersInfo.css +++ b/public/react/src/modules/user/usersInfo/usersInfo.css @@ -295,7 +295,7 @@ } .alltopisc{ - width:141px; + width:230px; height:20px; font-size:14px; font-family:PingFangSC;