添加客户

dev_local
daiao 6 years ago
parent 611b059e6a
commit 29caae1c36

@ -1197,20 +1197,21 @@ end
def customers_list def customers_list
@search = params[:search] @search = params[:search]
@province = params[:province] @province = params[:province]
partner_id = params[:partner] partner_id = params[:partner_id]
@partner = Partner.find partner_id @partner = Partner.find partner_id
@customers = @partner.customers @customers = @partner.customers
customer_id = @customers.present? ? @customers.map(&:id).join(",") : -1 if @customers.present?
@schools = School.where("partner_id != ? and customer_id not in(#{customer_id})", @partner.id) @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] if params[:search]
@schools = @schools.where("name like ?", "%#{@search}%") @schools = @schools.where("name like ?", "%#{@search}%")
end end
if params[:province] if params[:province] && params[:province] != '0'
@schools = @schools.where("province like ?", "%#{@province}%") @schools = @schools.where("province like ?", "%#{@province}%")
end end
@limit = 10 @limit = 10
@page = params[:page] || 1 @page = params[:page] || 1
@schools_count = @schools.count @schools_count = @schools.count

@ -1,9 +1,9 @@
<div class="task-popup" style="width: 572px;"> <div class="task-popup" style="width: 572px;">
<div class="task-popup-title clearfix">添加合作伙伴</div> <div class="task-popup-title clearfix">添加客户</div>
<div class="task_popup_con"> <div class="task_popup_con">
<div class="clearfix mb5 df"> <div class="clearfix mb5 df">
<div class="flex1"> <div class="flex1">
<%= render partial: "managements/partner_search_form" %> <%= render partial: "managements/customers_search_form" %>
</div> </div>
<a href="javascript:void(0);" onclick="$('#partners_search_form').submit()" class="white-btn mt6 edu-blueback-btn fl ml15 mt55">搜索</a> <a href="javascript:void(0);" onclick="$('#partners_search_form').submit()" class="white-btn mt6 edu-blueback-btn fl ml15 mt55">搜索</a>
</div> </div>
@ -12,7 +12,7 @@
<span class="fl ml25">单位</span> <span class="fl ml25">单位</span>
<span class="fr with30">地区</span> <span class="fr with30">地区</span>
</p> </p>
<div class="edu-back-skyblue clearfix pl10 over280" id="search_user_list"> <div class="edu-back-skyblue clearfix pl10 over280" id="search_customers_list">
<%= render :partial => "partners_list" %> <%= render :partial => "partners_list" %>
</div> </div>
<p class="clearfix" style="height: 20px;"><span class="fl lineh-20 none color-red" id="checkNotice"></span></p> <p class="clearfix" style="height: 20px;"><span class="fl lineh-20 none color-red" id="checkNotice"></span></p>
@ -32,7 +32,7 @@
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() { $("#search_customers_list").scroll(function() {
if (i < totalpage) { // 当滚动的页数小于总页数的时候,继续加载 if (i < totalpage) { // 当滚动的页数小于总页数的时候,继续加载
var pageH = $(document.body).height(); var pageH = $(document.body).height();
@ -50,10 +50,10 @@
}); });
function get_schools(page) { 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) { if (msg_list.height() + msg_list[0].scrollTop >= msg_list[0].scrollHeight - 60) {
msg_list_loading = true; 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) { if (schools) {
msg_list_loading = false; msg_list_loading = false;
var s_html = ""; var s_html = "";
@ -68,7 +68,7 @@
" <span class='fl with30'>"+array["school"]["province"]+"</span>" + " <span class='fl with30'>"+array["school"]["province"]+"</span>" +
" </p>" " </p>"
}); });
$("#search_user_list").append(s_html); $("#search_customers_list").append(s_html);
i ++; i ++;
} }
}); });
@ -90,7 +90,7 @@
success: function (e) { success: function (e) {
if(e.status === 1){ if(e.status === 1){
hideModal(); hideModal();
window.location.href = "<%= partners_managements_path %>"; window.location.href = "<%= partners_managements_path(partner: @partner.id) %>";
} }
} }
}) })

@ -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| %>
<div class="df">
<span class="fl lineh-35">地区:</span>
<select placeholder="请选择地区" name="province" id="partner_province" class="flex1"></select>
</div>
<div class="df mt15">
<span class="fl lineh-35">单位:</span>
<input type="text" class="input-flex-35" name="search" placeholder="请输入单位关键字" id="partner_name_search"/>
</div>
<% end %>
<script>
$(function () {
unitDownOption();
showprovince("partner_province");
})
</script>

@ -1,5 +1,5 @@
<% if params[:search] %> <% if params[:search] %>
$("#search_user_list").html("<%= j(render :partial => "partners_list") %>") $("#search_customers_list").html("<%= j(render :partial => "partners_list") %>")
<% else %> <% else %>
var html="<%= escape_javascript(render :partial => "managements/customer_addUnit",locals: {all_path: customers_list_managements_path}) %>"; var html="<%= escape_javascript(render :partial => "managements/customer_addUnit",locals: {all_path: customers_list_managements_path}) %>";
pop_box_new(html,572,500); pop_box_new(html,572,500);

@ -44,7 +44,7 @@
<li class="clearfix tableHead"> <li class="clearfix tableHead">
<span>序号</span> <span>序号</span>
<span>客户名称</span> <span>客户名称</span>
<span><a href="<%= customers_list_managements_path(:partner => @current_partner.try(:id)) %>" <span><a href="<%= customers_list_managements_path(:partner_id => @current_partner.try(:id)) %>"
data-remote="true" class="color-blue">+添加</a></span> data-remote="true" class="color-blue">+添加</a></span>
<span>添加时间</span> <span>添加时间</span>
</li> </li>

Loading…
Cancel
Save