diff --git a/app/controllers/admins/platform_communicates_controller.rb b/app/controllers/admins/platform_communicates_controller.rb
index aa545559e..7b0acb637 100644
--- a/app/controllers/admins/platform_communicates_controller.rb
+++ b/app/controllers/admins/platform_communicates_controller.rb
@@ -1,5 +1,5 @@
class Admins::PlatformCommunicatesController < Admins::BaseController
- before_action :get_communicate, only: [:edit, :update, :destroy]
+ before_action :get_communicate, only: [:edit, :update, :destroy, :show]
def index
sort_by = PlatformCommunicate.column_names.include?(params[:sort_by]) ? params[:sort_by] : 'order_index'
sort_direction = %w(desc asc).include?(params[:sort_direction]) ? params[:sort_direction] : 'desc'
@@ -8,6 +8,21 @@ class Admins::PlatformCommunicatesController < Admins::BaseController
@communicates = kaminari_paginate(communicates)
end
+ def show
+ watchers = @communicate.watchers
+ if params[:search].present?
+ like_sql = 'users.lastname LIKE :keyword OR users.nickname LIKE :keyword OR users.mail LIKE :keyword OR users.phone LIKE :keyword OR users.login LIKE :keyword OR users.company_name LIKE :keyword'
+ watchers = watchers.left_joins(:user).where(like_sql, keyword: "%#{params[:search]}%")
+ end
+ if params[:user_type].present?
+ watchers = watchers.left_joins(:user).where("users.user_type = ?", params[:user_type])
+ end
+ if params[:professional_field].present?
+ watchers = watchers.left_joins(:user).where("users.professional_field = ?", params[:professional_field])
+ end
+ @watchers = kaminari_paginate watchers
+ end
+
def new
@communicate = PlatformCommunicate.new
end
diff --git a/app/views/admins/platform_communicates/_list.html.erb b/app/views/admins/platform_communicates/_list.html.erb
index 1833f5ade..f47adca69 100644
--- a/app/views/admins/platform_communicates/_list.html.erb
+++ b/app/views/admins/platform_communicates/_list.html.erb
@@ -7,6 +7,7 @@
帖子ID |
标签 |
排序等级 |
+ 报名数 |
操作 |
@@ -20,9 +21,11 @@
<%= c.fake_id %> |
<%= c.tag_field %> |
<%= c.order_index %> |
+ <%= c.tag_field.to_s.include?("活动") ? link_to(c.watchers_count, "/admins/platform_communicates/#{c.id}") : "--"%> |
<%= link_to "编辑", edit_admins_platform_communicate_path(c), remote: true, class: "action" %>
<%= link_to "删除", admins_platform_communicate_path(c), method: :delete, data:{confirm: "确认删除的吗?"}, class: "action" %>
+ <%= c.tag_field.to_s.include?("活动") ? link_to("查看报名", "/admins/platform_communicates/#{c.id}") : ""%>
|
<% end %>
diff --git a/app/views/admins/platform_communicates/_users_list.html.erb b/app/views/admins/platform_communicates/_users_list.html.erb
new file mode 100644
index 000000000..4ab4f6cea
--- /dev/null
+++ b/app/views/admins/platform_communicates/_users_list.html.erb
@@ -0,0 +1,38 @@
+
+
+
+ | 序号 |
+ 昵称 |
+ 邮件地址 |
+ 手机号码 |
+ 用户类型 |
+ 专业领域 |
+ 单位 |
+ 报名时间 |
+
+
+
+ <% if watchers.present? %>
+ <% watchers.each_with_index do |watch, index| %>
+
+ | <%= list_index_no((params[:page] || 1).to_i, index) %> |
+
+ <%= link_to "/#{watch.user.login}", target: '_blank' do %>
+ <%= overflow_hidden_span watch.user.real_name, width: 100 %>
+ <% end %>
+ |
+ <%= overflow_hidden_span display_text(watch.user.mail), width: 150 %> |
+ <%= overflow_hidden_span display_text(watch.user.phone), width: 100 %> |
+ <%= watch.user.try(:user_type).blank? ? "" : ["事业单位", "企业单位", "科研人员", "高校教师", "高校学生", "程序员", "其他"][user.try(:user_type).to_i] %> |
+ <%= watch.user.try(:professional_field).blank? ? "" : "#{Site.dict_str("professional_field", "#{user.professional_field}")}" %> |
+ <%= watch.user.try(:company_name) %> |
+ <%= display_text(watch.created_at&.strftime('%Y-%m-%d %H:%M')) %> |
+
+ <% end %>
+ <% else %>
+ <%= render 'admins/shared/no_data_for_table' %>
+ <% end %>
+
+
+
+<%= render partial: 'admins/shared/paginate', locals: { objects: watchers } %>
diff --git a/app/views/admins/platform_communicates/show.html.erb b/app/views/admins/platform_communicates/show.html.erb
new file mode 100644
index 000000000..75ff19923
--- /dev/null
+++ b/app/views/admins/platform_communicates/show.html.erb
@@ -0,0 +1,32 @@
+
+
+
+ <%= form_tag(admins_platform_communicate_path(@communicate), method: :get, class: 'form-inline search-form flex-1', remote: true) do %>
+
+
+ <% user_type_options = [['全部', ''], ['事业单位', 0], ['企业单位', 1], ['科研人员', 2], ['高校教师', 3], ['高校学生', 4], ['程序员', 5], ['其他', 6]] %>
+ <%= select_tag(:user_type, options_for_select(user_type_options), class: 'form-control') %>
+
+
+
+ <% user_type_options = [['全部', '']] + Site.get_dict_data("professional_field").pluck(:name,:value)%>
+ <%= select_tag(:professional_field, options_for_select(user_type_options), class: 'form-control') %>
+
+ <%= text_field_tag(:search, params[:search], class: 'form-control col-12 col-md-2 mr-3', placeholder: '用户姓名/Email/手机号/单位') %>
+ <%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %>
+
+ <% end %>
+ <%= link_to "新增", new_admins_platform_communicate_path, remote: true, class: "btn btn-primary pull-right", "data-disabled-with":"...新增" %>
+
+
+
+ <%= render partial: 'admins/platform_communicates/users_list', locals: { watchers: @watchers } %>
+
+
+
diff --git a/app/views/admins/platform_communicates/show.js.erb b/app/views/admins/platform_communicates/show.js.erb
new file mode 100644
index 000000000..d91d605ed
--- /dev/null
+++ b/app/views/admins/platform_communicates/show.js.erb
@@ -0,0 +1 @@
+$('.users-list-container').html("<%= j( render partial: 'admins/platform_communicates/users_list', locals: { watchers: @watchers } ) %>");
\ No newline at end of file
diff --git a/app/views/admins/topic/applet_banners/_list.html.erb b/app/views/admins/topic/applet_banners/_list.html.erb
index 00d5fd595..f67a2196c 100644
--- a/app/views/admins/topic/applet_banners/_list.html.erb
+++ b/app/views/admins/topic/applet_banners/_list.html.erb
@@ -17,7 +17,8 @@
<%= list_index_no((params[:page] || 1).to_i, index) %> |
<%= banner.title %> |
 |
- <%= banner.url %> |
+
+ <%= banner.url %> |
<%= ["首页","竞赛"][Topic.locations[banner.location]] %> |
<%= banner.order_index %> |
|