From 14d8a248d71fc607e35f87508dcb5f287f86fb04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cxxq250=E2=80=9D?= <“xxq250@qq.com”> Date: Mon, 24 Oct 2022 17:37:53 +0800 Subject: [PATCH] =?UTF-8?q?fixed=20=E8=B5=84=E8=AE=AF=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E6=8A=A5=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../platform_communicates_controller.rb | 17 ++++++++- .../platform_communicates/_list.html.erb | 3 ++ .../_users_list.html.erb | 38 +++++++++++++++++++ .../platform_communicates/show.html.erb | 32 ++++++++++++++++ .../admins/platform_communicates/show.js.erb | 1 + .../topic/applet_banners/_list.html.erb | 3 +- 6 files changed, 92 insertions(+), 2 deletions(-) create mode 100644 app/views/admins/platform_communicates/_users_list.html.erb create mode 100644 app/views/admins/platform_communicates/show.html.erb create mode 100644 app/views/admins/platform_communicates/show.js.erb 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| %> + + + + + + + + + + + <% end %> + <% else %> + <%= render 'admins/shared/no_data_for_table' %> + <% end %> + +
序号昵称邮件地址手机号码用户类型专业领域单位报名时间
<%= 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')) %>
+ +<%= 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 %>