diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index 61b353cb..f571b47c 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -1197,20 +1197,21 @@ end def customers_list @search = params[:search] @province = params[:province] - partner_id = params[:partner] + partner_id = params[:partner_id] @partner = Partner.find partner_id @customers = @partner.customers - customer_id = @customers.present? ? @customers.map(&:id).join(",") : -1 - @schools = School.where("partner_id != ? and customer_id not in(#{customer_id})", @partner.id) - + if @customers.present? + @schools = School.where("(partner_id != ? or partner_id is NULL) and (customer_id is NULL or customer_id not in(#{@customers.map(&:id).join(",")}))", @partner.id) + else + @schools = School.where("partner_id != ? or partner_id is NULL", @partner.id) + end if params[:search] @schools = @schools.where("name like ?", "%#{@search}%") end - if params[:province] + if params[:province] && params[:province] != '0' @schools = @schools.where("province like ?", "%#{@province}%") end - @limit = 10 @page = params[:page] || 1 @schools_count = @schools.count diff --git a/app/views/managements/_customer_addUnit.html.erb b/app/views/managements/_customer_addUnit.html.erb index 17f31b47..28ff3f36 100644 --- a/app/views/managements/_customer_addUnit.html.erb +++ b/app/views/managements/_customer_addUnit.html.erb @@ -1,9 +1,9 @@
-
添加合作伙伴
+
添加客户
- <%= render partial: "managements/partner_search_form" %> + <%= render partial: "managements/customers_search_form" %>
搜索
@@ -12,7 +12,7 @@ 单位 地区

-
+
<%= render :partial => "partners_list" %>

@@ -32,7 +32,7 @@ var totalpage = <%= @total_pages.to_i %>; //总页数,防止超过总页数继续滚动 var winH = $(window).height(); //页面可视区域高度 - $("#search_user_list").scroll(function() { + $("#search_customers_list").scroll(function() { if (i < totalpage) { // 当滚动的页数小于总页数的时候,继续加载 var pageH = $(document.body).height(); @@ -50,10 +50,10 @@ }); function get_schools(page) { - var msg_list = $('#search_user_list'); + var msg_list = $('#search_customers_list'); if (msg_list.height() + msg_list[0].scrollTop >= msg_list[0].scrollHeight - 60) { msg_list_loading = true; - $.getJSON("<%= all_path %>?page="+page, function(schools) { + $.getJSON("<%= all_path %>?partner_id=<%= @partner.id %>page="+page+"&search="+$("#partner_name_search").val()+"&province="+$("#partner_province").val(), function(schools) { if (schools) { msg_list_loading = false; var s_html = ""; @@ -68,7 +68,7 @@ " "+array["school"]["province"]+"" + "

" }); - $("#search_user_list").append(s_html); + $("#search_customers_list").append(s_html); i ++; } }); @@ -90,7 +90,7 @@ success: function (e) { if(e.status === 1){ hideModal(); - window.location.href = "<%= partners_managements_path %>"; + window.location.href = "<%= partners_managements_path(partner: @partner.id) %>"; } } }) diff --git a/app/views/managements/_customers_search_form.html.erb b/app/views/managements/_customers_search_form.html.erb new file mode 100644 index 00000000..28c7ece0 --- /dev/null +++ b/app/views/managements/_customers_search_form.html.erb @@ -0,0 +1,19 @@ +<%= form_for "", :url => {:controller=> 'managements', :action => 'customers_list', :partner_id => @partner.id}, :html => {:id => 'partners_search_form'}, :method => "get", :remote => true do |f| %> +
+ 地区: + +
+
+ 单位: + +
+ +<% end %> + + \ No newline at end of file diff --git a/app/views/managements/customers_list.js.erb b/app/views/managements/customers_list.js.erb index 5068df4f..b112b613 100644 --- a/app/views/managements/customers_list.js.erb +++ b/app/views/managements/customers_list.js.erb @@ -1,5 +1,5 @@ <% if params[:search] %> - $("#search_user_list").html("<%= j(render :partial => "partners_list") %>") + $("#search_customers_list").html("<%= j(render :partial => "partners_list") %>") <% else %> var html="<%= escape_javascript(render :partial => "managements/customer_addUnit",locals: {all_path: customers_list_managements_path}) %>"; pop_box_new(html,572,500); diff --git a/app/views/managements/partners.html.erb b/app/views/managements/partners.html.erb index 7eeb80a0..e53a20ee 100644 --- a/app/views/managements/partners.html.erb +++ b/app/views/managements/partners.html.erb @@ -44,7 +44,7 @@
  • 序号 客户名称 - +添加 添加时间