From 885ace98a9983ce68a2c4f12d03fc7fe2f4c9fbb Mon Sep 17 00:00:00 2001
From: cxt <853663049@qq.com>
Date: Thu, 4 Apr 2019 17:46:57 +0800
Subject: [PATCH] =?UTF-8?q?=E6=90=9C=E7=B4=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/managements_controller.rb | 12 ++++--
app/views/managements/_partner_list.html.erb | 5 +++
.../managements/_partner_main_div.html.erb | 25 +++++++++++++
app/views/managements/partners.html.erb | 37 +++----------------
app/views/managements/partners.js.erb | 2 +
5 files changed, 46 insertions(+), 35 deletions(-)
create mode 100644 app/views/managements/_partner_list.html.erb
create mode 100644 app/views/managements/_partner_main_div.html.erb
create mode 100644 app/views/managements/partners.js.erb
diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb
index 8afb2340..13f408c2 100644
--- a/app/controllers/managements_controller.rb
+++ b/app/controllers/managements_controller.rb
@@ -1184,8 +1184,11 @@ end
def partners
@menu_type = 6
@sub_type = 3
- @partners = Partner.includes(:school).order("partners.created_at desc")
- @partners = @partners.where("concat(schools.name) like ? ", "%#{params[:search]}%") unless params[:search].blank?
+ if params[:search].blank?
+ @partners = Partner.includes(:school).order("partners.created_at desc")
+ else
+ @partners = Partner.where("name like ? ", "%#{params[:search]}%").includes(:school).order("partners.created_at desc")
+ end
@current_partner = nil
if params[:partner]
@@ -1194,8 +1197,9 @@ end
@current_partner = @partners[0] if @partners.size > 0
end
- @partners.each do |part|
- part.active = "active" if part.id == @current_partner.id
+ respond_to do |format|
+ format.js
+ format.html
end
end
diff --git a/app/views/managements/_partner_list.html.erb b/app/views/managements/_partner_list.html.erb
new file mode 100644
index 00000000..c73dd1ff
--- /dev/null
+++ b/app/views/managements/_partner_list.html.erb
@@ -0,0 +1,5 @@
+<% @partners.each_with_index do |partner,index| %>
+
+ <%= link_to "#{partner.name}", partners_managements_path(:partner => partner), :class => "#{partner.id == @current_partner.id ? 'active' : ''}" %>
+
+<% end %>
\ No newline at end of file
diff --git a/app/views/managements/_partner_main_div.html.erb b/app/views/managements/_partner_main_div.html.erb
new file mode 100644
index 00000000..53a58e88
--- /dev/null
+++ b/app/views/managements/_partner_main_div.html.erb
@@ -0,0 +1,25 @@
+<% if @current_partner.present? %>
+
+
+
+
+
添加时间<%= format_time @current_partner.try(:created_at) %>
+
+
管理员
+
+ -
+ <%= link_to '+', add_partner_member_box_managements_path(:partner => @current_partner.try(:id)), :remote => true, :class => "addManage" %>
+
+
+ <%= render :partial => "partner_member_list", :locals => {partner: @current_partner} %>
+
+
+
+
+
+ <%= render :partial => "partner_customer_list" %>
+
+
+
+
+<% end %>
\ No newline at end of file
diff --git a/app/views/managements/partners.html.erb b/app/views/managements/partners.html.erb
index 89c25a9f..ad3af6df 100644
--- a/app/views/managements/partners.html.erb
+++ b/app/views/managements/partners.html.erb
@@ -7,39 +7,14 @@
<%= link_to "+添加",all_partners_managements_path,remote:true,class:"color-blue addOperation" %>
-
- <% @partners.each_with_index do |partner,index| %>
- -
- <%= link_to "#{partner.name}", partners_managements_path(:partner => partner), :class => "#{partner.active}" %>
-
- <% end %>
+
+ <%= render :partial => "partner_list" %>
- <% if @current_partner.present? %>
-
-
-
-
-
添加时间<%= format_time @current_partner.try(:created_at) %>
-
-
管理员
-
- -
- <%= link_to '+', add_partner_member_box_managements_path(:partner => @current_partner.try(:id)), :remote => true, :class => "addManage" %>
-
-
- <%= render :partial => "partner_member_list", :locals => {partner: @current_partner} %>
-
-
-
-
-
- <%= render :partial => "partner_customer_list" %>
-
-
-
-
- <% end %>
+
+
+ <%= render :partial => "partner_main_div" %>
+
diff --git a/app/views/managements/partners.js.erb b/app/views/managements/partners.js.erb
new file mode 100644
index 00000000..0906f4e6
--- /dev/null
+++ b/app/views/managements/partners.js.erb
@@ -0,0 +1,2 @@
+$("#partner_list").html("<%= j(render :partial => "partner_list") %>");
+$("#partner_main_div").html("<%= j(render :partial => "partner_main_div") %>");
\ No newline at end of file