添加管理员

dev_local
cxt 6 years ago
parent c56a997403
commit 43117e7ca1

@ -1232,7 +1232,6 @@ end
school.update_attributes(:partner_id => partner.id) school.update_attributes(:partner_id => partner.id)
end end
end end
render :json => {status: 1, message: "创建成功!"}
end end
end end
@ -1279,13 +1278,18 @@ end
@partner = Partner.where(:id => params[:partner]).first @partner = Partner.where(:id => params[:partner]).first
@members = @members =
if params[:search] if params[:search]
User.where("LOWER(concat(lastname, firstname, nickname, mail)) LIKE '%#{params[:search]}%'") User.where("LOWER(concat(lastname, firstname, nickname, mail)) LIKE ?", "%#{params[:search]}%").
where(:certification => 1, :partner_id => nil)
else else
User.where(:certification => 1) User.where(:certification => 1, :partner_id => nil)
end end
@members = paginateHelper @members, 8 @total_pages = (@members.count / 10.0).ceil
@members = paginateHelper @members, 10
respond_to do |format| respond_to do |format|
format.js format.js
format.json {
render json: member_json_data(@members)
}
end end
end end
@ -1298,8 +1302,6 @@ end
user.update_attributes(partner_id: @partner.id) if !@partner.nil? && !user.nil? user.update_attributes(partner_id: @partner.id) if !@partner.nil? && !user.nil?
end end
end end
redirect_to partners_managements_path
end end
# check 部门 identifier是否重复 # check 部门 identifier是否重复
@ -4319,4 +4321,19 @@ end
book.write xls_report book.write xls_report
xls_report.string xls_report.string
end end
def member_json_data mmebers
mmebers.map do |member|
real_name = member.show_real_name
identity = member.identity
school_name = member.school_name
user_phone = member.phone || ""
member.attributes.dup.except("login", "hashed_password", "salt", "status", "mail", "experience", "grade",
"authentication", "professional_certification").merge({real_name: real_name,
identity: identity,
school_name: school_name,
user_phone: user_phone})
end
end
end end

@ -14,7 +14,7 @@
</p> </p>
<%= form_for @partner, :url => add_partner_member_managements_path,:html => {:id => 'add_partner_member_form', :remote => true, :method => :post} do |f| %> <%= form_for @partner, :url => add_partner_member_managements_path,:html => {:id => 'add_partner_member_form', :remote => true, :method => :post} do |f| %>
<input type="hidden" value="<%= @partner.id %>" name="partner"> <input type="hidden" value="<%= @partner.id %>" name="partner">
<div id="serch_user_list"> <div class="edu-back-skyblue clearfix pl10 over280" id="member_search_user_list">
<%= render :partial => "partner_member_search_list" %> <%= render :partial => "partner_member_search_list" %>
</div> </div>
<% end %> <% end %>
@ -27,14 +27,14 @@
</div> </div>
</div> </div>
<script> <script>
var i = 1; //设置当前页数 var member_i = 1; //设置当前页数
var msg_list_loading = false; var msg_list_loading = false;
$(function() { $(function() {
var totalpage = <%= @total_pages.to_i %>; //总页数,防止超过总页数继续滚动 var totalpage = <%= @total_pages.to_i %>; //总页数,防止超过总页数继续滚动
var winH = $(window).height(); //页面可视区域高度 var winH = $(window).height(); //页面可视区域高度
$("#search_user_list").scroll(function() { $("#member_search_user_list").scroll(function() {
if (i < totalpage) { // 当滚动的页数小于总页数的时候,继续加载 if (member_i < totalpage) { // 当滚动的页数小于总页数的时候,继续加载
var pageH = $(document.body).height(); var pageH = $(document.body).height();
var scrollT = $(window).scrollTop(); //滚动条top var scrollT = $(window).scrollTop(); //滚动条top
@ -42,7 +42,7 @@
console.log(aa); console.log(aa);
if ( !msg_list_loading ){ if ( !msg_list_loading ){
if (aa < 0.01 ) { if (aa < 0.01 ) {
get_schools(i+1) get_schools(member_i+1)
} }
} }
} }
@ -50,26 +50,26 @@
}); });
function get_schools(page) { function get_schools(page) {
var msg_list = $('#search_user_list'); var msg_list = $('#member_search_user_list');
if (msg_list.height() + msg_list[0].scrollTop >= msg_list[0].scrollHeight - 60) { if (msg_list.height() + msg_list[0].scrollTop >= msg_list[0].scrollHeight - 60) {
msg_list_loading = true; msg_list_loading = true;
$.getJSON("/managements/add_partner_member_box?partner=<%= @partner.id %>&search="+$("#partner_member_search").val()+"&page="+page, function(schools) { $.getJSON("/managements/add_partner_member_box?partner=<%= @partner.id %>&search="+$("#partner_member_search").val()+"&page="+page, function(members) {
if (schools) { if (members) {
msg_list_loading = false; msg_list_loading = false;
var s_html = ""; var s_html = "";
$.each(schools,function (index,array) { $.each(members,function (index,array) {
s_html = s_html+ "<p class='clearfix mt5'>" + s_html = s_html+ "<p class='clearfix'>" +
" <span class='fl with70'>" + " <span class='fl edu-txt-w90'>" +
" <span>" + " <input type='checkbox' name='partner_member[]' value='"+array["id"]+"' id='user_'"+array["id"]+"'class='magic-checkbox'>" +
" <input type='checkbox' name='school[id]' value='"+array["school"]["id"]+"' id='school_'"+array["school"]["id"]+"'class='magic-checkbox'>" + " <label for='user_'"+array["id"]+">"+array["real_name"]+"</label>" +
" <label for='school_'"+array["school"]["id"]+">"+array["school"]["name"]+"</label>" +
" </span>\n" +
" </span>\n" + " </span>\n" +
" <span class='fl with30'>"+array["school"]["province"]+"</span>" + "<span class='fl edu-txt-w90 mt5 edu-txt-center color-grey-6 pointer'>"+array["identity"]+"</span>" +
"<span class=\"fl task-hide edu-txt-w200 mt5 edu-txt-left color-grey-9\">"+array["school_name"]+"</span>" +
"<span class=\"fl edu-txt-w100 mt5 edu-txt-center color-grey-9\">"+array["user_phone"]+"</span>" +
" </p>" " </p>"
}); });
$("#search_user_list").append(s_html); $("#member_search_user_list").append(s_html);
i ++; member_i ++;
} }
}); });
} }

@ -0,0 +1,8 @@
<% partner.users.each do |user| %>
<li>
<%= image_tag(url_to_avatar(user)) %>
<a href="javascript:void(0)" class="removeImg">
<i class="iconfont icon-htmal5icon19 color-grey-9"></i>
</a>
</li>
<% end %>

@ -0,0 +1 @@
$("#partner_member_list").html("<%= j(render :partial => "partner_member_list", :locals => {partner: @partner}) %>")

@ -1,5 +1,5 @@
<% if params[:search] %> <% if params[:search] %>
$("#serch_user_list").html("<%= j(render :partial => "partner_member_search_list") %>") $("#member_search_user_list").html("<%= j(render :partial => "partner_member_search_list") %>")
<% else %> <% else %>
var html="<%= escape_javascript(render :partial => "managements/partner_addManage") %>"; var html="<%= escape_javascript(render :partial => "managements/partner_addManage") %>";
pop_box_new(html,572,500); pop_box_new(html,572,500);

@ -23,19 +23,13 @@
<div class="clearfix"> <div class="clearfix">
<span class="mr45 color-grey-9 fl">管理员</span> <span class="mr45 color-grey-9 fl">管理员</span>
<ul class="manageList"> <ul class="manageList">
<li>
<%= link_to '+', add_partner_member_box_managements_path(:partner => 1), :remote => true, :class => "addManage" %>
</li>
<% unless @current_partner.nil? %> <% unless @current_partner.nil? %>
<% @current_partner.users.each_with_index do |user, index| %> <li>
<li> <%= link_to '+', add_partner_member_box_managements_path(:partner => @current_partner.try(:id)), :remote => true, :class => "addManage" %>
<%= image_tag(url_to_avatar(user)) %> </li>
<a href="javascript:void(0)" class="removeImg"> <div id="partner_member_list" class="fl">
<i class="iconfont icon-htmal5icon19 color-grey-9"></i> <%= render :partial => "partner_member_list", :locals => {partner: @current_partner} %>
</a> </div>
</li>
<% end %>
<% end %> <% end %>
</ul> </ul>
</div> </div>

Loading…
Cancel
Save