超级管理员的用户列表增加“最后登录”,“创建时间”排序
This commit is contained in:
parent
b9100d3d7c
commit
0da01c5a33
|
|
@ -9,19 +9,21 @@ class ManagementsController < ApplicationController
|
|||
|
||||
# 0 全部;1 活动的; 2 已注册; 3 锁定
|
||||
def users
|
||||
status = params[:user_status].nil? ? 0 : params[:user_status].to_i
|
||||
status = params[:user_status].nil? ? 0 : params[:user_status].to_i
|
||||
@us_order = params[:us_order].blank? ? "desc" : params[:us_order] # 排序
|
||||
@order_key = params[:order_key].blank? ? "created_on" : params[:order_key] # 排序关键字
|
||||
condition = (params[:research_condition].nil? || params[:research_condition] == "name") ? "concat(lastname, firstname)" : params[:research_condition]
|
||||
if 0 == status
|
||||
if params[:research_condition] == "phone" && params[:research_contents].blank?
|
||||
@users = User.order("created_on desc").all
|
||||
@users = User.order("#{@order_key} #{@us_order}").all
|
||||
else
|
||||
@users = User.where("#{condition} like '%#{params[:research_contents]}%'").order("created_on desc").all
|
||||
@users = User.where("#{condition} like '%#{params[:research_contents]}%'").order("#{@order_key} #{@us_order}").all
|
||||
end
|
||||
else
|
||||
if params[:research_condition] == "phone" && params[:research_contents].blank?
|
||||
@users = User.where(:status => status).order("created_on desc").all
|
||||
@users = User.where(:status => status).order("#{@order_key} #{@us_order}").all
|
||||
else
|
||||
@users = User.where("status = #{status} and #{condition} like '%#{params[:research_contents]}%'").order("created_on desc").all
|
||||
@users = User.where("status = #{status} and #{condition} like '%#{params[:research_contents]}%'").order("#{@order_key} #{@us_order}").all
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -33,8 +35,8 @@ class ManagementsController < ApplicationController
|
|||
@users = paginateHelper @users, @limit
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.js
|
||||
format.html
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@
|
|||
<th>邮件地址</th>
|
||||
<th>手机号码</th>
|
||||
<th>单位</th>
|
||||
<th><a href="javascript:void(0);">创建于<i class="fa fa-long-arrow-down ml5 color-blue"></i></a></th>
|
||||
<th>最后登录</th>
|
||||
<th><a href="javascript:void(0);" id="user_create_order">创建于<i class="fa <%= @order_key == "created_on" ? (@us_order == "desc" ? "fa-long-arrow-down" : "fa-long-arrow-up") : "" %> ml5 color-blue"></i></a></th>
|
||||
<th><a href="javascript:void(0);" id="user_last_order">最后登录<i class="fa <%= @order_key == "last_login_on" ? (@us_order == "desc" ? "fa-long-arrow-down" : "fa-long-arrow-up") : "" %> ml5 color-blue"></i></a></th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
|
@ -44,4 +44,43 @@
|
|||
<div class="cl"></div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<script>
|
||||
// 按照创建时间排序
|
||||
// order -> 表示排序方式; user_status research_condition research_contents -> 当时搜索的状态
|
||||
$("#user_create_order").on("click", function(){
|
||||
var icon = $("#user_create_order").find("i");
|
||||
if(icon.hasClass("fa-long-arrow-down") || icon.hasClass("fa-long-arrow-up")){
|
||||
var order = $("#user_create_order").find(".fa-long-arrow-down").length > 0 ? "asc" : "desc";
|
||||
}else{
|
||||
var order = "desc"
|
||||
}
|
||||
var user_status = $("input[name='user_status']").val();
|
||||
var research_condition = $("input[name='research_condition']").val();
|
||||
var research_contents = $("input[name='research_contents']").val();
|
||||
$.ajax({
|
||||
url: "<%= users_managements_path %>",
|
||||
type: "post",
|
||||
dataType: "script",
|
||||
data: {us_order : order, order_key: "created_on", user_status:user_status, research_condition:research_condition, research_contents:research_contents}
|
||||
});
|
||||
});
|
||||
// 按最后登录时间排序
|
||||
$("#user_last_order").on("click", function(){
|
||||
var icon = $("#user_last_order").find("i");
|
||||
if(icon.hasClass("fa-long-arrow-down") || icon.hasClass("fa-long-arrow-up")){
|
||||
var order = $("#user_last_order").find(".fa-long-arrow-down").length > 0 ? "asc" : "desc";
|
||||
}else{
|
||||
var order = "desc"
|
||||
}
|
||||
var user_status = $("input[name='user_status']").val();
|
||||
var research_condition = $("input[name='research_condition']").val();
|
||||
var research_contents = $("input[name='research_contents']").val();
|
||||
$.ajax({
|
||||
url: "<%= users_managements_path %>",
|
||||
type: "post",
|
||||
dataType: "script",
|
||||
data: {us_order : order, order_key: "last_login_on", user_status:user_status, research_condition:research_condition, research_contents:research_contents}
|
||||
});
|
||||
})
|
||||
</script>
|
||||
Loading…
Reference in New Issue