新增:操作日志类型

This commit is contained in:
2024-08-20 15:56:40 +08:00
parent f1a79d926c
commit b7aa1e51b3
10 changed files with 968 additions and 6 deletions

View File

@@ -82,6 +82,371 @@ class Journal < ApplicationRecord
end
end
def pm_operate_content
content = ""
detail = self.journal_details.take
case detail.property
when 'requirement'
case detail.prop_key
when 'status_id'
old_value = IssueStatus.find_by_id(detail.old_value)&.name
new_value = IssueStatus.find_by_id(detail.value)&.name
content += "将状态"
if old_value.nil? || old_value.blank?
content += "设置为<b>#{new_value}</b>"
else
new_value = "未设置" if new_value.blank?
content += "由<b>#{old_value}</b>更改为<b>#{new_value}</b>"
end
content.gsub!('新增', '待评审')
content.gsub!('正在解决', '进行中')
content.gsub!('已解决', '已完成')
content.gsub!('关闭', '已关闭')
content.gsub!('拒绝', '已拒绝')
return content
when 'root_id'
old_value = Issue.find_by_id(detail.old_value)&.subject
new_value = Issue.find_by_id(detail.value)&.subject
if old_value.nil? || old_value.blank?
content += "关联了父需求<b><#{new_value}></b>"
else
if new_value.nil? || new_value.blank?
content += "取消了关联的父需求<b><#{old_value}></b>"
else
content += "将关联的父需求由<b><#{old_value}></b>更改为<b><#{new_value}></b>"
end
end
return content
when 'leaf_issue'
old_value = Issue.where(id: detail.old_value.to_s.split(",")).map{|i| "<#{i.subject}>"}.join("")
new_value = Issue.where(id: detail.value.to_s.split(",")).map{|i| "<#{i.subject}>"}.join("")
if old_value.nil? || old_value.blank?
content += "新建了子需求<b>#{new_value}</b>"
else
if new_value.nil? || new_value.blank?
content += "删除了关联的子需求<b>#{old_value}</b>"
else
content += "新建了子需求<b>#{new_value}</b>"
end
end
return content
when 'tag_leaf_issue'
old_value = Issue.where(id: detail.old_value.to_s.split(",")).map{|i| "<#{i.subject}>"}.join("")
new_value = Issue.where(id: detail.value.to_s.split(",")).map{|i| "<#{i.subject}>"}.join("")
if old_value.nil? || old_value.blank?
content += "关联了子需求<b>#{new_value}</b>"
else
if new_value.nil? || new_value.blank?
content += "取消了关联的子需求<b>#{old_value}</b>"
else
content += "关联了子需求<b>#{new_value}</b>"
end
end
return content
else
return "创建了需求"
end
when 'task'
case detail.prop_key
when 'status_id'
old_value = IssueStatus.find_by_id(detail.old_value)&.name
new_value = IssueStatus.find_by_id(detail.value)&.name
content += "将状态"
if old_value.nil? || old_value.blank?
content += "设置为<b>#{new_value}</b>"
else
new_value = "未设置" if new_value.blank?
content += "由<b>#{old_value}</b>更改为<b>#{new_value}</b>"
end
content.gsub!('新增', '待处理')
content.gsub!('正在解决', '进行中')
content.gsub!('已解决', '已完成')
content.gsub!('关闭', '已关闭')
content.gsub!('拒绝', '已拒绝')
return content
when 'root_id'
old_value = Issue.find_by_id(detail.old_value)&.subject
new_value = Issue.find_by_id(detail.value)&.subject
if old_value.nil? || old_value.blank?
content += "关联了父任务<b><#{new_value}></b>"
else
if new_value.nil? || new_value.blank?
content += "取消了关联的父任务<b><#{old_value}></b>"
else
content += "将关联的父任务由<b><#{old_value}></b>更改为<b><#{new_value}></b>"
end
end
return content
when 'leaf_issue'
old_value = Issue.where(id: detail.old_value.to_s.split(",")).map{|i| "<#{i.subject}>"}.join("")
new_value = Issue.where(id: detail.value.to_s.split(",")).map{|i| "<#{i.subject}>"}.join("")
if old_value.nil? || old_value.blank?
content += "新建了子任务<b>#{new_value}</b>"
else
if new_value.nil? || new_value.blank?
content += "删除了关联的子任务<b>#{old_value}</b>"
else
content += "新建了子任务<b>#{new_value}</b>"
end
end
return content
when 'tag_leaf_issue'
old_value = Issue.where(id: detail.old_value.to_s.split(",")).map{|i| "<#{i.subject}>"}.join("")
new_value = Issue.where(id: detail.value.to_s.split(",")).map{|i| "<#{i.subject}>"}.join("")
if old_value.nil? || old_value.blank?
content += "关联了子任务<b>#{new_value}</b>"
else
if new_value.nil? || new_value.blank?
content += "取消了关联的子任务<b>#{old_value}</b>"
else
content += "关联了子任务<b>#{new_value}</b>"
end
end
return content
else
return "创建了任务"
end
when 'bug'
case detail.prop_key
when 'status_id'
old_value = IssueStatus.find_by_id(detail.old_value)&.name
new_value = IssueStatus.find_by_id(detail.value)&.name
content += "将状态"
if old_value.nil? || old_value.blank?
content += "设置为<b>#{new_value}</b>"
else
new_value = "未设置" if new_value.blank?
content += "由<b>#{old_value}</b>更改为<b>#{new_value}</b>"
end
content.gsub!('新增', '待修复')
content.gsub!('正在解决', '修复中')
content.gsub!('已解决', '已修复')
content.gsub!('关闭', '已关闭')
content.gsub!('拒绝', '已拒绝')
return content
when 'root_id'
old_value = Issue.find_by_id(detail.old_value)&.subject
new_value = Issue.find_by_id(detail.value)&.subject
if old_value.nil? || old_value.blank?
content += "关联了父缺陷<b><#{new_value}></b>"
else
if new_value.nil? || new_value.blank?
content += "取消了关联的父缺陷<b><#{old_value}></b>"
else
content += "将关联的父缺陷由<b><#{old_value}></b>更改为<b><#{new_value}></b>"
end
end
return content
when 'leaf_issue'
old_value = Issue.where(id: detail.old_value.to_s.split(",")).map{|i| "<#{i.subject}>"}.join("")
new_value = Issue.where(id: detail.value.to_s.split(",")).map{|i| "<#{i.subject}>"}.join("")
if old_value.nil? || old_value.blank?
content += "新建了子缺陷<b>#{new_value}</b>"
else
if new_value.nil? || new_value.blank?
content += "删除了关联的子缺陷<b>#{old_value}</b>"
else
content += "新建了子缺陷<b>#{new_value}</b>"
end
end
return content
when 'tag_leaf_issue'
old_value = Issue.where(id: detail.old_value.to_s.split(",")).map{|i| "<#{i.subject}>"}.join("")
new_value = Issue.where(id: detail.value.to_s.split(",")).map{|i| "<#{i.subject}>"}.join("")
if old_value.nil? || old_value.blank?
content += "关联了子缺陷<b>#{new_value}</b>"
else
if new_value.nil? || new_value.blank?
content += "取消了关联的子缺陷<b>#{old_value}</b>"
else
content += "关联了子缺陷<b>#{new_value}</b>"
end
end
return content
else
return "创建了缺陷"
end
when 'attr'
case detail.prop_key
when 'subject'
return "修改了<b>标题</b>"
when 'description'
return "修改了<b>正文</b>"
when 'priority_id'
old_value = IssuePriority.find_by_id(detail.old_value)&.name
new_value = IssuePriority.find_by_id(detail.value)&.name
if old_value.nil? || old_value.blank?
content += "将优先级设置为<b>#{new_value}</b>"
else
new_value = "未设置" if new_value.blank?
content += "将优先级由<b>#{old_value}</b>更改为<b>#{new_value}</b>"
end
return content
when 'pm_issue_type'
old_value = detail.old_value
new_value = detail.value
if old_value.nil? || old_value.blank?
content += "将工作项类型设置为<b>#{new_value}</b>"
else
new_value = "未设置" if new_value.blank?
content += "将工作项类型由<b>#{old_value}</b>更改为<b>#{new_value}</b>"
end
content.gsub!('1', '需求')
content.gsub!('2', '任务')
content.gsub!('3', '缺陷')
return content
when 'pm_sprint_id'
old_value = detail.old_value
new_value = detail.value
if old_value.nil? || old_value.blank?
content += "添加了关联迭代"
else
if new_value.nil? || new_value.blank?
content += "将关联迭代更改为<b>未设置</b>"
else
content += "变更了关联迭代"
end
end
return content
when 'project_id'
old_value = Project.find_by_id(detail.old_value)&.name
new_value = Project.find_by_id(detail.value)&.name
if old_value.nil? || old_value.blank?
content += "添加关联代码库<b>#{new_value}</b>"
else
if new_value.nil? || new_value.blank?
content += "将关联代码库更改为<b>未设置</b>"
else
content += "将关联代码库由<b>#{old_value}</b>改为<b>#{new_value}</b>"
end
end
return content
when 'branch_name'
old_value = detail.old_value
new_value = detail.value
if old_value.nil? || old_value.blank?
content += "添加关联分支<b>#{new_value}</b>"
else
if new_value.nil? || new_value.blank?
content += "将关联分支更改为<b>未设置</b>"
else
content += "将关联分支由<b>#{old_value}</b>改为<b>#{new_value}</b>"
end
end
return content
when 'start_date'
old_value = detail.old_value
new_value = detail.value
if old_value.nil? || old_value.blank?
content += "添加开始时间<b>#{new_value}</b>"
else
if new_value.nil? || new_value.blank?
content += "将开始时间更改为<b>未设置</b>"
else
content += "将开始时间由<b>#{old_value}</b>改为<b>#{new_value}</b>"
end
end
return content
when 'due_date'
old_value = detail.old_value
new_value = detail.value
if old_value.nil? || old_value.blank?
content += "添加结束时间<b>#{new_value}</b>"
else
if new_value.nil? || new_value.blank?
content += "将结束时间更改为<b>未设置</b>"
else
content += "将结束时间由<b>#{old_value}</b>改为<b>#{new_value}</b>"
end
end
return content
when 'time_scale'
old_value = detail.old_value
new_value = detail.value
if old_value.nil? || old_value.blank?
content += "添加预估工时<b>#{new_value}</b>"
else
if new_value.nil? || new_value.blank?
content += "将预估工时更改为<b>未设置</b>"
else
content += "将预估工时由<b>#{old_value}</b>改为<b>#{new_value}</b>"
end
end
return content
end
when 'attachment'
old_value = detail.old_value.to_s
new_value = detail.value.to_s
if old_value.nil? || old_value.blank?
content += "上传了附件"
else
if new_value.nil? || new_value.blank?
content += "删除了附件"
else
content += "上传了附件"
end
end
return content
when 'assigner'
old_value = User.where(id: detail.old_value.split(",")).map{|u| u.real_name}.join("")
new_value = User.where(id: detail.value.split(",")).map{|u| u.real_name}.join("")
if old_value.nil? || old_value.blank?
content += "添加负责人<b>#{new_value}</b>"
else
if new_value.nil? || new_value.blank?
content += "将负责人更改为<b>未设置</b>"
else
content += "将负责人由<b>#{old_value}</b>更改为<b>#{new_value}</b>"
end
end
return content
when 'issue_tag'
old_value = IssueTag.where(id: detail.old_value.split(",")).pluck(:name).join("")
new_value = IssueTag.where(id: detail.value.split(",")).pluck(:name).join("")
if old_value.nil? || old_value.blank?
content += "添加标记<b>#{new_value}</b>"
else
if new_value.nil? || new_value.blank?
content += "将标记更改为<b>未设置</b>"
else
content += "将标记由<b>#{old_value}</b>更改为<b>#{new_value}</b>"
end
end
return content
when 'link_issue'
old_value = Issue.where(id: detail.old_value.to_s.split(",")).map{|i| "[#{i.pm_issue_type}]-<#{i.subject}>"}.join("")
new_value = Issue.where(id: detail.value.to_s.split(",")).map{|i| "[#{i.pm_issue_type}]-<#{i.subject}>"}.join("")
if old_value.nil? || old_value.blank?
content += "关联了工作项<b>#{new_value}</b>"
else
if new_value.nil? || new_value.blank?
content += "取消了关联的工作项<b>#{old_value}</b>"
else
content += "关联了工作项<b>#{new_value}</b>"
end
end
content.gsub!('1', "需求")
content.gsub!('2', "任务")
content.gsub!('3', "缺陷")
return content
when 'tag_link_issue'
old_value = Issue.where(id: detail.old_value.to_s.split(",")).map{|i| "[#{i.pm_issue_type}]-<#{i.subject}>"}.join("")
new_value = Issue.where(id: detail.value.to_s.split(",")).map{|i| "[#{i.pm_issue_type}]-<#{i.subject}>"}.join("")
if old_value.nil? || old_value.blank?
content += "新建了关联的工作项<b>#{new_value}</b>"
else
if new_value.nil? || new_value.blank?
content += "删除了关联的工作项<b>#{old_value}</b>"
else
content += "新建了关联的工作项<b>#{new_value}</b>"
end
end
return content
end
end
def operate_content
content = ""
detail = self.journal_details.take