删除客户

dev_local
cxt 6 years ago
parent 30a5b1a4e6
commit 096dd01b8a

@ -23,7 +23,7 @@ class CooperatesController < ApplicationController
def find_partner
@partner = Partner.find_by_id(params[:id])
render_404 if @partner.nil? || @partner.status == -1
render_404 if @partner.nil?
rescue ActiveRecord::RecordNotFound
render_404
end

@ -1251,6 +1251,15 @@ end
end
end
def delete_customers
if params[:customer]
customer = Customer.where(id: params[:customer]).first
@current_partner = customer.partner
customer.school.update_attributes(:customer_id => nil)
customer.destroy if customer && @current_partner
end
end
def all_partners
@search = params[:search]
@province = params[:province]

@ -0,0 +1,20 @@
<li class="clearfix tableHead">
<span>序号</span>
<span>客户名称</span>
<span><a href="<%= customers_list_managements_path(:partner_id => @current_partner.try(:id)) %>"
data-remote="true" class="color-blue">+添加</a></span>
<span>添加时间</span>
</li>
<% @current_partner.try(:customers).try(:each) do |customer| %>
<li>
<span><%= customer.school.id %></span>
<span class="task-hide"><%= customer.school.name %></span>
<span>
<a href="javascript:void(0)" onclick="delete_confirm_box_2('<%= delete_customers_managements_path(customer: customer.id) %>',
'确定要删除该客户吗')" class="color-grey-9">删除</a>
</span>
<span>
<%= format_time customer.created_at %>
</span>
</li>
<% end %>

@ -0,0 +1 @@
$("#partner_customer_list").html("<%= j(render :partial => "partner_customer_list") %>")

@ -33,27 +33,8 @@
</ul>
</div>
</div>
<div class="tableList">
<li class="clearfix tableHead">
<span>序号</span>
<span>客户名称</span>
<span><a href="<%= customers_list_managements_path(:partner_id => @current_partner.try(:id)) %>"
data-remote="true" class="color-blue">+添加</a></span>
<span>添加时间</span>
</li>
<% @current_partner.try(:customers).try(:each) do |customer| %>
<li>
<span><%= customer.school.id %></span>
<span class="task-hide"><%= customer.school.name %></span>
<span>
<a href="javascript:void(0)" class="color-grey-9">删除</a>
</span>
<span>
<%= format_time customer.created_at %>
</span>
</li>
<% end %>
<div class="tableList" id="partner_customer_list">
<%= render :partial => "partner_customer_list" %>
</div>
</div>
</div>

@ -713,6 +713,7 @@ RedmineApp::Application.routes.draw do ## oauth相关
post 'delete_subject_level'
post 'update_level_for_subject'
post :add_customers
delete :delete_customers
get :customers_list
end
end

Loading…
Cancel
Save