diff --git a/app/controllers/admins/user_actions_controller.rb b/app/controllers/admins/user_actions_controller.rb index d96cdc97e..ff52d5a1a 100644 --- a/app/controllers/admins/user_actions_controller.rb +++ b/app/controllers/admins/user_actions_controller.rb @@ -6,7 +6,7 @@ class Admins::UserActionsController < Admins::BaseController @user_actions = @user_actions.where(action_type: params[:action_type]) if params[:action_type].present? keyword = params[:keyword].to_s.strip.presence if keyword - sql = 'login LIKE :keyword OR phone LIKE :keyword OR mail LIKE :keyword' + sql = 'login LIKE :keyword OR phone LIKE :keyword OR email LIKE :keyword' @user_actions = @user_actions.where(sql, keyword: "%#{keyword}%") end @user_actions = paginate @user_actions diff --git a/app/models/user_action.rb b/app/models/user_action.rb index 846c4e22c..0df146bd9 100644 --- a/app/models/user_action.rb +++ b/app/models/user_action.rb @@ -39,14 +39,6 @@ class UserAction < ApplicationRecord end end - def action_data - case action_type - when "DestroyUser" then build_mode("User") - when "DestroyProject" then build_mode("Project") - else nil - end - end - def opt_user_name if user&.id == user_id "--" @@ -55,6 +47,14 @@ class UserAction < ApplicationRecord end end + def action_info + case action_type + when "DestroyUser" then "账号:#{user&.login}
邮箱:#{user&.mail}
手机号:#{user&.phone}
昵称:#{user&.nickname}
" + when "DestroyProject" then "项目名称:#{project&.name}
项目标识:#{project&.identifier}
" + else "--" + end + end + def user action_user = if action_type == "DestroyUser" && data_bank.present? build_mode("User") @@ -63,6 +63,15 @@ class UserAction < ApplicationRecord end action_user end + + def project + action_project = if action_type == "DestroyProject" && data_bank.present? + build_mode("Project") + else + Project.find_by(id: self.action_id) + end + action_project + end def build_mode(model_name) model = model_name.constantize.new model_name.constantize.column_names.each do |col| diff --git a/app/views/admins/user_actions/_user_action_list.html.erb b/app/views/admins/user_actions/_user_action_list.html.erb index d19cdbc64..0af34be7d 100644 --- a/app/views/admins/user_actions/_user_action_list.html.erb +++ b/app/views/admins/user_actions/_user_action_list.html.erb @@ -3,11 +3,8 @@ 序号 操作类型 - 操作人 - 账号 - 邮箱 - 手机号 - 姓名 + 操作人账号 + 关联基本信息 操作时间 原因/备注 @@ -18,20 +15,12 @@ <%= list_index_no((params[:page] || 1).to_i, index) %> <%= action.action_name %> - <%= action.opt_user_name %> <%= link_to "/#{action.user&.login}", target: '_blank' do %> <%= overflow_hidden_span action.user&.login, width: 100 %> - <% end %> - - - <%= overflow_hidden_span action.user&.mail, width: 150 %> - - <%= action.user&.phone %> - - <%= link_to "/#{action.user&.login}", target: '_blank' do %> - <%= overflow_hidden_span action.user&.real_name, width: 100 %> - <% end %> + <% end %> + + <%= raw action.action_info %> <%= display_text(action.created_at&.strftime('%Y-%m-%d %H:%M')) %> <%= action.memo %>