Class: EducodeSales::Project

Inherits:
ApplicationRecord show all
Defined in:
app/models/educode_sales/project.rb

Class Method Summary collapse

Class Method Details

.save_history(attr, old_value, new_value) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'app/models/educode_sales/project.rb', line 10

def self.save_history(attr, old_value, new_value)
  # old_value = St.find_by(id: old_value)&.name
  # new_value = Department.find_by(id: new_value)&.name
  case attr
  when "p_stage"
    "项目阶段由“#{old_value}”变更为“#{new_value}"
  when "p_difficulty"
    "项目难度由“#{old_value}”变更为“#{new_value}"
  when "p_special"
    "定制由“#{old_value}”变更为“#{new_value}"
  when "p_status"
    "交付由“#{old_value}”变更为“#{new_value}"
  when "p_staff_id"
    old_value = Staff.find_by(id: old_value)&.user&.real_name
    new_value = Staff.find_by(id: new_value)&.user&.real_name
    "指派人由“#{old_value}”变更为“#{new_value}"
  when "p_sale_staff_id"
    old_value = Staff.find_by(id: old_value)&.user&.real_name
    new_value = Staff.find_by(id: new_value)&.user&.real_name
    "销售经理由“#{old_value}”变更为“#{new_value}"
  when "p_course_time"
    "课程交付时间由“#{old_value}”变更为“#{new_value}"
  when "p_platform_time"
    "平台交付时间由“#{old_value}”变更为“#{new_value}"
  when "p_deploy_time"
    "现场部署时间由“#{old_value}”变更为“#{new_value}"
  when "p_accept_time"
    "实际验收时间由“#{old_value}”变更为“#{new_value}"
  when "p_pre_money_time"
    "拟定回款时间由“#{old_value}”变更为“#{new_value}"
  when "p_actual_money_time"
    "实际回款时间由“#{old_value}”变更为“#{new_value}"
  when "p_money"
    "回款由“#{old_value}”变更为“#{new_value}"
  when "p_content"
    "问题备注由“#{old_value}”变更为“#{new_value}"
  when "p_pre_accept_time"
    "预计验收时间由“#{old_value}”变更为“#{new_value}"
  else
    nil
  end
end