操作记录记录显示调整

This commit is contained in:
xxq250 2024-09-27 11:11:53 +08:00
parent 80828d85d7
commit 4329f9dbf0
3 changed files with 23 additions and 25 deletions

View File

@ -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

View File

@ -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}<br/>邮箱:#{user&.mail}<br/>手机号:#{user&.phone}<br/>昵称:#{user&.nickname}<br/>"
when "DestroyProject" then "项目名称:#{project&.name}<br/>项目标识:#{project&.identifier}<br/>"
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|

View File

@ -3,11 +3,8 @@
<tr>
<th width="5%" class="text-center">序号</th>
<th width="10%">操作类型</th>
<th width="10%" title="--本人操作,有名称为管理员操作">操作人</th>
<th width="10%" class="text-left">账号</th>
<th width="15%" class="text-left">邮箱</th>
<th width="10%" class="text-left">手机号</th>
<th width="10%" class="text-left">姓名</th>
<th width="10%" class="text-left">操作人账号</th>
<th width="25%" class="text-left">关联基本信息</th>
<th width="15%">操作时间</th>
<th width="35%">原因/备注</th>
</tr>
@ -18,20 +15,12 @@
<tr class="user-item-<%= action.user&.id %>">
<td class="text-center"><%= list_index_no((params[:page] || 1).to_i, index) %></td>
<td><%= action.action_name %></td>
<td><%= action.opt_user_name %></td>
<td>
<%= link_to "/#{action.user&.login}", target: '_blank' do %>
<%= overflow_hidden_span action.user&.login, width: 100 %>
<% end %>
</td>
<td class="text-left">
<%= overflow_hidden_span action.user&.mail, width: 150 %>
</td>
<td><%= action.user&.phone %></td>
<td class="text-left">
<%= link_to "/#{action.user&.login}", target: '_blank' do %>
<%= overflow_hidden_span action.user&.real_name, width: 100 %>
<% end %>
<% end %></td>
<td>
<%= raw action.action_info %>
</td>
<td><%= display_text(action.created_at&.strftime('%Y-%m-%d %H:%M')) %></td>
<td><%= action.memo %></td>