From 29caae1c36d6138995ea17ba8d83a8ef159c0071 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 4 Apr 2019 15:38:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AE=A2=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/managements_controller.rb | 13 +++++++------ .../managements/_customer_addUnit.html.erb | 16 ++++++++-------- .../_customers_search_form.html.erb | 19 +++++++++++++++++++ app/views/managements/customers_list.js.erb | 2 +- app/views/managements/partners.html.erb | 2 +- 5 files changed, 36 insertions(+), 16 deletions(-) create mode 100644 app/views/managements/_customers_search_form.html.erb 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 @@
@@ -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| %> +