diff --git a/public/react/src/modules/courses/Resource/index.js b/public/react/src/modules/courses/Resource/index.js index 3bcc9c6b8..d5b3b5ad2 100644 --- a/public/react/src/modules/courses/Resource/index.js +++ b/public/react/src/modules/courses/Resource/index.js @@ -28,7 +28,7 @@ class Fileslists extends Component{ pagesize: 15, tagname:undefined, search:undefined, - sort:undefined, + sort:"desc", sorttype:"created_on", coursesecondcategoryid:undefined, filesId:undefined, @@ -49,16 +49,19 @@ class Fileslists extends Component{ checkBoxValues:[], checkAllValue:false }) + if(this.props.match.params.main_id){ - this.seactall(); this.setState({ child:false, + sort:"desc" }) + this.seactall(undefined,"desc"); }else if(this.props.match.params.Id){ - this.seactall(parseInt(this.props.match.params.Id),1) this.setState({ child:true, + sort:"desc" }) + this.seactall(parseInt(this.props.match.params.Id),"desc") } this.updadatalist(); on('updateNavSuccess', this.updateNavSuccess) @@ -66,13 +69,14 @@ class Fileslists extends Component{ } updateNavSuccess=()=>{ + let{sort}=this.state; this.setState({ isSpin:true }) if(this.props.match.params.main_id){ - this.seactall(); + this.seactall(undefined,sort); }else if(this.props.match.params.Id){ - this.seactall(parseInt(this.props.match.params.Id),1) + this.seactall(parseInt(this.props.match.params.Id),sort) } } componentDidUpdate = (prevProps) => { @@ -85,8 +89,9 @@ class Fileslists extends Component{ if(this.props.match.params.main_id!=undefined){ this.setState({ child:false, + sort:"desc" }) - this.seactall(); + this.seactall(undefined,"desc"); } } if(prevProps.match.params.Id != this.props.match.params.Id){ @@ -98,8 +103,9 @@ class Fileslists extends Component{ if(this.props.match.params.Id!=undefined){ this.setState({ child:true, + sort:"desc" }) - this.seactall(parseInt(this.props.match.params.Id),1) + this.seactall(parseInt(this.props.match.params.Id),"desc") } } } @@ -138,29 +144,42 @@ class Fileslists extends Component{ } updatafiled=()=>{ + let{sort}=this.state; if(this.props.match.params.main_id){ - this.seactall(); + this.seactall(undefined,sort); }else if(this.props.match.params.Id){ - this.seactall(parseInt(this.props.match.params.Id),1) + this.seactall(parseInt(this.props.match.params.Id),sort) } } - seactall=(coursesecondcategoryid,type)=>{ + seactall=(coursesecondcategoryid,sort)=>{ this.setState({ coursesecondcategoryid:coursesecondcategoryid, isSpin:true }) - let{pagesize,page,tagname,searchValue,sort,sorttype}=this.state; + let{pagesize,page,tagname,searchValue,sorttype}=this.state; this.getfileslist(pagesize,page,tagname,searchValue,sort,sorttype,coursesecondcategoryid); } onSortTypeChange=(sorttype)=>{ - let{pagesize,page,tagname,searchValue,sort,coursesecondcategoryid}=this.state; - this.setState({ - sorttype:sorttype - }) - this.getfileslist(pagesize,page,tagname,searchValue,sort,sorttype,coursesecondcategoryid); + let{pagesize,page,tagname,searchValue,sort,coursesecondcategoryid,}=this.state; + let newsort="desc"; + if(sort==="desc"){ + this.setState({ + sorttype:sorttype, + sort:"asc" + }) + newsort="asc" + }else{ + this.setState({ + sorttype:sorttype, + sort:"desc" + }) + newsort="desc" + } + + this.getfileslist(pagesize,page,tagname,searchValue,newsort,sorttype,coursesecondcategoryid); } getfileslist=(pagesize,page,tagname,searchValue,sort,sorttype,coursesecondcategoryid)=>{ @@ -176,7 +195,7 @@ class Fileslists extends Component{ page:page, tag_name:tagname, search:searchValue, - sort:sort, + sort:sort==="desc"?0:1, sort_type:sorttype, course_second_category_id:id } @@ -353,7 +372,7 @@ class Fileslists extends Component{ Modalstype:false, }) - let {checkBoxValues} = this.state; + let {checkBoxValues,sort} = this.state; const cid = this.props.match.params.coursesId; let url="/files/bulk_public.json"; @@ -363,7 +382,7 @@ class Fileslists extends Component{ }) .then((response) => { if (response.data.status == 0) { - this.seactall(); + this.updatafiled() //:response.data.message this.props.showNotification("更新成功"); this.setState({ @@ -680,7 +699,8 @@ class Fileslists extends Component{ shixunmodal, course_is_public, filesId, - child + child, + sort } = this.state; let category_id= this.props.match.params.category_id; @@ -753,7 +773,7 @@ class Fileslists extends Component{ patheditarry={this.state.patheditarry} coursesecondcategoryid={this.state.coursesecondcategoryid} hidecouseShixunModal={this.hidecouseShixunModal} - setupdate={(id)=>this.seactall(id)} + setupdate={(id)=>this.seactall(id,sort)} attachmentId={this.state.coursesecondcategoryid} />:""} @@ -768,7 +788,7 @@ class Fileslists extends Component{ Savesname={"确认"} Cancel={this.Cancelvisible} categoryid={category_id} - setupdate={(id)=>this.seactall(id)} + setupdate={(id)=>this.seactall(id,sort)} has_course_groups={this.state.has_course_groups} attachmentId={this.state.coursesecondcategoryid} />:""} @@ -779,7 +799,7 @@ class Fileslists extends Component{ Settingtype={Settingtype} discussMessageid={discussMessageid} course_id={this.props.match.params.coursesId} - setupdate={(id)=>this.seactall(id)} + setupdate={(id)=>this.seactall(id,sort)} Cancel={this.Cancelvisible} has_course_groups={this.state.has_course_groups} attachmentId={this.state.coursesecondcategoryid} @@ -896,16 +916,24 @@ class Fileslists extends Component{ :""} - - {this.props.isAdmin()||this.props.isStudent()?
  • - {sorttype === 'created_on' ? '更新时间排序':sorttype === 'downloads' ?'下载次数排序':'引用次数排序'} - - + + {this.props.isAdmin()||this.props.isStudent()?
  • this.onSortTypeChange('created_on')}> + 更新时间 + + + +
  • :""}