@ -828,31 +828,30 @@ class ManagementsController < ApplicationController
@pod_num = res [ 'sum' ]
@pod_num = res [ 'sum' ]
@pod_dis = JSON . parse ( res [ 'distr' ] ) if res [ 'distr' ] . present?
@pod_dis = JSON . parse ( res [ 'distr' ] ) if res [ 'distr' ] . present?
end
end
@search = params [ :search ] # 搜索字
@keyword = params [ :keyword ] . blank? ? " u_name " : params [ :keyword ] # 根据姓名/课程名搜索
page = ( params [ 'page' ] || 1 ) . to_i
if " u_name " == @keyword
search = params [ :search ]
if @search . blank?
keyword = params [ :keyword ]
@evaluate_recods = EvaluateRecord . where ( " 0=0 " )
limit = 20
else
user_id = User . where ( " concat(lastname, firstname) like '% #{ @search } %' " )
if search
if " u_name " == keyword
@evaluate_recods = EvaluateRecord . joins ( " join users u on evaluate_records.user_id = u.id " ) . where ( " concat(u.lastname, u.firstname) like '% #{ @search } %' " )
@evaluate_recods = EvaluateRecord . joins ( " join users u on evaluate_records.user_id = u.id " ) . where ( " concat(u.lastname, u.firstname) like '% #{ @search } %' " )
# @evaluate_recods = EvaluateRecord.where(user_id: User.where("concat(lastname, firstname) like '%#{search}%'").pluck(:id))
else
@evaluate_recods = EvaluateRecord . joins ( " join user_extensions ue on evaluate_records.user_id = ue.user_id " ) . where ( " ue.school_id in (select id from schools where name like '% #{ @search } %') " )
# @evaluate_recods = EvaluateRecord.where(user_id: UserExtensions.where(school_id: School.where("name like '%#{search}%'").pluck(:id)).pluck(:user_id))
end
end
else
else
school_id = School . where ( " name like '% #{ @search } %' " ) . map ( & :id )
@evaluate_recods = EvaluateRecord . all
user_id = UserExtensions . where ( :school_id = > school_id ) . map ( & :user_id )
@evaluate_recods = EvaluateRecord . where ( :user_id = > user_id )
end
end
@evaluate_recods_count = @evaluate_recods . count
@evaluate_recods_count = @evaluate_recods . count
@page = ( params [ 'page' ] || 1 ) . to_i
@evaluate_recods_pages = Paginator . new @evaluate_recods_count , limit , page
@limit = 20
@evaluate_recods = @evaluate_recods . includes ( :shixun , :user ) . page ( page ) . per ( limit )
@is_remote = true
@evaluate_recods_pages = Paginator . new @evaluate_recods_count , @limit , @page
@offset || = @evaluate_recods_pages . offset
@evaluate_recods = paginateHelper @evaluate_recods , @limit
respond_to do | format |
respond_to do | format |
format . js
format . js
format . html
format . html
end
end
end
end