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