ecloud_sso
jingquan huang 5 years ago
commit b249ff8247

@ -19,7 +19,7 @@ class SubjectsController < ApplicationController
def index
subjects = Weapps::SubjectQuery.call(current_laboratory, params)
@subject_count = subjects.map(&:id).size
@subjects = paginate subjects
@subjects = paginate subjects.includes(:shixuns, :repertoire)
end
def show

@ -8,7 +8,7 @@ class Weapps::SubjectQuery < ApplicationQuery
end
def call
subjects = @current_laboratory.subjects.unhidden.publiced.show_moblied
subjects = @current_laboratory.subjects.unhidden.publiced
# 课程体系的过滤
if params[:sub_discipline_id].present?
@ -19,8 +19,8 @@ class Weapps::SubjectQuery < ApplicationQuery
subjects = subjects.joins(:sub_discipline_containers).where(sub_discipline_containers: {container_type: "Subject"})
end
subjects = subjects.left_joins(:shixuns).select('subjects.id, subjects.name, subjects.excellent, subjects.stages_count, subjects.status, subjects.homepage_show,
subjects.shixuns_count, subjects.updated_at, IFNULL(sum(shixuns.myshixuns_count), 0) myshixuns_count')
subjects = subjects.left_joins(:shixuns, :repertoire).select('subjects.id, subjects.name, subjects.excellent, subjects.stages_count, subjects.status, subjects.homepage_show,
subjects.shixuns_count, subjects.repertoire_id, subjects.updated_at, IFNULL(sum(shixuns.myshixuns_count), 0) myshixuns_count')
.group('subjects.id').order("subjects.homepage_show #{sort_type}, #{order_type} #{sort_type}")
subjects
end

@ -1,9 +1,5 @@
json.subjects @subjects do |subject|
json.(subject, :id, :excellent, :name, :stages_count, :shixuns_count)
json.myshixuns_count subject.myshixuns_count
json.challenges_count subject.subject_challenge_count
json.image_url url_to_avatar(subject)
json.allow_visit subject.status > 1 || User.current.manager_of_subject?(subject) || User.current.admin?
json.subjects do
json.partial! 'subject', locals: {subjects: @subjects}
end
json.total_count @subject_count
json.total_count @total_count

@ -1,6 +1,6 @@
import React, { Component } from 'react';
import axios from 'axios';
import {Input} from 'antd';
import {Dropdown,Menu} from 'antd';
import {getImageUrl} from 'educoder';
import PathCard from "./ShixunPathCard";
import UpgradeModals from '../modals/UpgradeModals';
@ -18,59 +18,49 @@ class ShixunPathSearch extends Component{
page:1,
pathList:null,
sortList:'',
total_count:0
total_count:0,
sort:"desc",
limit:16,
discipline_id:undefined,
sub_discipline_id:undefined
}
}
//切换列表状态
changeStatus=(value)=>{
this.setState(
{
pathList:null
}
)
let {select,search}=this.state;
let {discipline_id,sub_discipline_id }=this.state;
this.setState({
order:value,
page:1
})
this.getList(value,select,search,1);
}
//搜索输入
inputSearchValue=(e)=>{
this.setState({
search:e.target.value,
page:1
})
}
//搜索
searchValue=(e)=>{
let {order,select,search}=this.state;
this.setState({
page:1
})
this.getList(order,select,search,1 );
this.getList(value,discipline_id,sub_discipline_id,1);
}
//选择页数
onChange=(pageNumber)=> {
let {order,select,search}=this.state;
let { order,discipline_id,sub_discipline_id }=this.state;
this.setState({
page:pageNumber
})
this.getList(order,select,search,pageNumber);
this.getList(order,discipline_id,sub_discipline_id,pageNumber);
}
//顶部分类
changeSelect=(tag_id)=>{
this.setState(
{
pathList:null
}
)
let { order,search }=this.state;
changeSelect=(e,tag_id,sum)=>{
this.setState({
select:tag_id
order:"updated_at",
discipline_id:tag_id,
page:1,
sub_discipline_id:undefined
})
this.getList( order,tag_id,search,1 );
let { order }=this.state;
this.getList(order,tag_id,undefined,1 );
e.stopPropagation();
}
@ -85,31 +75,41 @@ class ShixunPathSearch extends Component{
}).catch((error)=>{
console.log(error);
})
this.getdisciplines()
let { order,discipline_id,sub_discipline_id,page }=this.state;
this.getList(order,discipline_id,sub_discipline_id,page );
let { order,select,search,page }=this.state;
this.getList(order,select,search,page );
}
getdisciplines=()=>{
let url='/disciplines.json';
axios.get(url,{params:{
source:"subject"
}}).then((result)=>{
if(result.status==200){
// console.log(result.data.disciplines)
this.setState({
sortList:result.data.disciplines
})
}
}).catch((error)=>{
console.log(error);
})
}
getList=(order,select,search,page )=>{
getList=(order,discipline_id,sub_discipline_id,page )=>{
let url='/paths.json';
// '?order='+order+'&page='+page;
// if(select!=""){
// url+='&select='+select;
// }
// if(search!=""){
// url+='&search='+search;
// }
axios.get(url,{params:{
order:order,
sort:"desc",
limit:16,
order:order,
page:page,
select:select,
// search:search
discipline_id:discipline_id,
sub_discipline_id:sub_discipline_id
}}).then((result)=>{
if(result.status==200){
this.setState({
sortList:result.data.tags,
pathList:result.data.subjects,
total_count:result.data.total_count
})
@ -119,11 +119,6 @@ class ShixunPathSearch extends Component{
})
}
setHistoryFun=(url)=>{
this.props.history.push(url)
}
//头部获取是否已经登录了
getUser=(url,type)=>{
if(this.props.checkIfLogin()===false){
@ -140,9 +135,41 @@ class ShixunPathSearch extends Component{
}
}
getshixunchildValues=(e,id,item)=>{
this.setState({
discipline_id:item.id,
sub_discipline_id:id,
})
let { order,page }=this.state;
this.getList(order,item.id,id,page );
e.stopPropagation();
}
getmenu=(list,item)=>{
return(
<Menu>
<Menu.Item>
<div className="mt5 subshaicontent-part">
<div className="sub-Item clearfix">
{
list.map((tag,e)=>{
return(
<a className={parseInt(this.state.sub_discipline_id)===tag.id?"shixun_repertoire mr20 color-blue":"shixun_repertoire mr20"}
key={e} id={tag.id} name={tag.id} rel="subshaicontent" onClick={(e)=>this.getshixunchildValues(e,tag.id,item)}>{tag.name}</a>
)
})
}
</div>
</div>
</Menu.Item>
</Menu>
)
}
render() {
let { order,sortList,search,page,total_count,select }=this.state;
let { order,sortList,search,page,total_count,discipline_id }=this.state;
let pathstype=false;
if(this.props&&this.props.mygetHelmetapi!=null){
let paths="/paths";
@ -156,8 +183,8 @@ class ShixunPathSearch extends Component{
})
}
// console.log(this.props)
return (
return (
<div>
{this.state.updata===undefined?"":<UpgradeModals
{...this.state}
@ -178,6 +205,17 @@ class ShixunPathSearch extends Component{
background-position: center;
background-repeat: no-repeat;
}
.ant-dropdown-menu{
max-width:1000px;
}
.ant-dropdown-menu-item, .ant-dropdown-menu-submenu-title{
white-space: normal !important;
line-height: 28px !important;
}
.ant-dropdown-menu-item:hover, .ant-dropdown-menu-submenu-title:hover{
background-color: #fff !important;
}
a{text-decoration:none !important;}
`
}
</style>
@ -185,11 +223,15 @@ class ShixunPathSearch extends Component{
<div className="pathImg"></div>
<div className="edu-back-white padding20 pathIndexNav">
<ul className="educontent clearfix">
<li className={select > 0 ? "" : "active"}><a onClick={()=>this.changeSelect(null)}>全部</a></li>
<li className={discipline_id > 0 ? "" : "active"}><a onClick={(e)=>this.changeSelect(e,undefined)}>全部</a></li>
{
sortList && sortList.map((item,key)=>{
return(
<li className={select == `${item.tag_id}` ? "active" : ""}><a value={item.tag_id} onClick={()=>this.changeSelect(`${item.tag_id}`)}>{item.tag_name}</a></li>
<li className={discipline_id == `${item.id}` ? "active" : ""} onClick={(e)=>this.changeSelect(e,`${item.id}`,item.sub_disciplines.length)} key={key}>
<Dropdown disabled={item.sub_disciplines.length===0} overlay={()=>this.getmenu(item.sub_disciplines,item)} placement="bottomCenter">
<a value={item.id}>{item.name}</a>
</Dropdown>
</li>
)
})
}
@ -200,7 +242,7 @@ class ShixunPathSearch extends Component{
{/*<a href="javascript:void(0)" className={ order == "publish_time" ? "fl mr20 font-16 bestChoose active" : "fl mr20 font-16 bestChoose"} onClick={ () => this.changeStatus("publish_time")}>全部</a>*/}
{/*<a href="javascript:void(0)" className={ order == "mine" ? "fl mr20 font-16 bestChoose active" : "fl mr20 font-16 bestChoose"} onClick={ () => this.changeStatus("mine")}>我的</a>*/}
<span className={ order == "updated_at" ? "active" : ""} onClick={ () => this.changeStatus("updated_at")}>最新</span>
<span className={ order == "myshixun_count" ? "active" : ""} onClick={ () => this.changeStatus("myshixun_count")}>最热</span>
<span className={ order == "myshixuns_count" ? "active" : ""} onClick={ () => this.changeStatus("myshixuns_count")}>最热</span>
{this.props.user&&this.props.user.main_site===false?"":this.props.Headertop===undefined?"":<a className={ "fr font-16 bestChoose color-blue" } onClick={(url)=>this.getUser("/paths/new")}>+新建实践课程</a>}
{this.props.user&&this.props.user.main_site===true?"":this.props.Headertop===undefined?"":
pathstype===true?"":this.props.user&&this.props.user.admin===true||this.props.user&&this.props.user.is_teacher===true||this.props.user&&this.props.user.business===true?<a className={ "fr font-16 bestChoose color-blue" } onClick={(url)=>this.getUser("/paths/new")}>+新建实践课程</a>:""
@ -229,6 +271,3 @@ class ShixunPathSearch extends Component{
}
}
export default ShixunPathSearch;
// <Pagination showQuickJumper defaultCurrent={page} current={page} pageSize={16} total={total_count} onChange={this.onChange} />

@ -211,7 +211,7 @@ class ShixunCardList extends Component {
})
}
console.log(this.props.middleshixundata.search_tags)
return (
<div className="educontent mt20">
<div className="clearfix">

@ -237,7 +237,7 @@ render() {
{
shixunhoverData.map((item,key)=>{
return(
<Dropdown overlay={overlaymenu(item.sub_repertoires,item.id)} key={key} placement= {item.id<4?"bottomRight":item.id>=8?"bottomLeft":"bottomCenter"}>
<Dropdown overlay={overlaymenu(item.sub_repertoires,item.id)} key={key} placement={item.id<4?"bottomRight":item.id>=8?"bottomLeft":"bottomCenter"}>
<li key={key} className={parseInt(shixunsearchAllvalue)===item.id?"shaiItem shixun_repertoire active":"shaiItem shixun_repertoire"} value={item.id} onClick={this.shixunsearchAll}>
{item.name}
</li>

Loading…
Cancel
Save