educode_sales 0.9.73 → 0.9.74

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/educode_sales/contracts_controller.rb +309 -0
  3. data/app/controllers/educode_sales/follow_ups_controller.rb +1 -1
  4. data/app/controllers/educode_sales/home_controller.rb +7 -0
  5. data/app/controllers/educode_sales/ideas_controller.rb +146 -76
  6. data/app/controllers/educode_sales/roles_controller.rb +2 -1
  7. data/app/controllers/educode_sales/upload_files_controller.rb +3 -0
  8. data/app/models/educode_sales/assign_staff.rb +6 -0
  9. data/app/models/educode_sales/contract_date_list.rb +6 -0
  10. data/app/models/educode_sales/follow_up.rb +6 -0
  11. data/app/models/educode_sales/idea.rb +16 -5
  12. data/app/models/educode_sales/idea_follow.rb +11 -0
  13. data/app/models/educode_sales/permission.rb +2 -1
  14. data/app/models/educode_sales/role_area.rb +2 -1
  15. data/app/views/educode_sales/businesses/_contract_list.html.erb +160 -0
  16. data/app/views/educode_sales/contracts/_follows.html.erb +323 -0
  17. data/app/views/educode_sales/contracts/_list.html.erb +596 -0
  18. data/app/views/educode_sales/contracts/follow_ups.json.jbuilder +23 -0
  19. data/app/views/educode_sales/contracts/index.html.erb +50 -0
  20. data/app/views/educode_sales/contracts/index.json.jbuilder +74 -0
  21. data/app/views/educode_sales/contracts/list.js.erb +1 -0
  22. data/app/views/educode_sales/contracts/new_follow_up.html.erb +671 -0
  23. data/app/views/educode_sales/home/staff_business.json.jbuilder +9 -0
  24. data/app/views/educode_sales/idea_recycles/detail.html.erb +4 -4
  25. data/app/views/educode_sales/idea_recycles/index.html.erb +5 -5
  26. data/app/views/educode_sales/ideas/_follows.html.erb +258 -0
  27. data/app/views/educode_sales/ideas/_index.html.erb +544 -0
  28. data/app/views/educode_sales/ideas/detail.html.erb +7 -7
  29. data/app/views/educode_sales/ideas/edit.html.erb +77 -15
  30. data/app/views/educode_sales/ideas/files.html.erb +157 -0
  31. data/app/views/educode_sales/ideas/files.json.jbuilder +13 -0
  32. data/app/views/educode_sales/ideas/follow_ups.json.jbuilder +14 -0
  33. data/app/views/educode_sales/ideas/index.html.erb +12 -353
  34. data/app/views/educode_sales/ideas/index.json.jbuilder +7 -1
  35. data/app/views/educode_sales/ideas/new.html.erb +81 -25
  36. data/app/views/educode_sales/ideas/new_follow_up.html.erb +105 -0
  37. data/app/views/educode_sales/ideas/search_new.html.erb +1 -1
  38. data/app/views/educode_sales/ideas/show_schools.html.erb +84 -0
  39. data/app/views/educode_sales/ideas/show_schools.json.jbuilder +12 -0
  40. data/app/views/educode_sales/ideas/show_teachers.html.erb +372 -0
  41. data/app/views/educode_sales/ideas/upload_file.html.erb +43 -0
  42. data/app/views/educode_sales/projects/detail.html.erb +1 -1
  43. data/app/views/educode_sales/projects/edit.html.erb +1 -1
  44. data/app/views/educode_sales/roles/edit.html.erb +16 -0
  45. data/app/views/layouts/educode_sales/application.html.erb +5 -5
  46. data/config/routes.rb +19 -0
  47. data/db/migrate/20230227061043_create_educode_sales_ideas.rb +2 -2
  48. data/db/migrate/20230430023424_add_plan_signed_date_to_follow_ups.rb +21 -0
  49. data/db/migrate/20230430040332_create_educode_sales_contract_date_lists.rb +15 -0
  50. data/db/migrate/20230430104708_create_idea_follows.rb +25 -0
  51. data/db/migrate/20230430121335_add_permissions_for_ideas.rb +16 -0
  52. data/db/migrate/20230430134710_create_educode_sales_assign_staffs.rb +11 -0
  53. data/lib/educode_sales/version.rb +1 -1
  54. metadata +30 -2
@@ -0,0 +1,74 @@
1
+ follow_up_ids = EducodeSales::AssignFollowUp.where(staff_id: @current_admin.id).pluck(:follow_up_id)
2
+ follow_count = 0
3
+ json.data do
4
+ json.array! @businesses do |d|
5
+ json.id d.id
6
+ json.number d.number
7
+ json.name d.name
8
+ json.department d.department&.name
9
+ json.school d.department&.school&.name
10
+ json.school_id d.department&.school_id
11
+ follow_ups_count = d['follow_ups_counts'] || 0
12
+ json.follow_ups_count follow_ups_count
13
+ follow_count += follow_ups_count
14
+ json.follow_up_id d.last_follow_up_id
15
+ json.clazz d.clazz&.name || ""
16
+ json.extras_clazz d.clazz&.extras
17
+ json.clazz_changed d.last_follow_up&.clazz_changed || false
18
+ json.stage d.last_follow_up&.stage&.name
19
+ json.invitation_at d.last_follow_up&.invitation_at.to_s
20
+ json.reception_at d.last_follow_up&.reception_at.to_s
21
+ json.bidded_date d.last_follow_up&.bidded_date.to_s
22
+ json.signed_date d.last_follow_up&.signed_date.to_s
23
+ json.advise d.last_follow_up&.advise.to_s
24
+ json.o_business_deployment EducodeSales::FollowUp::BUSINESS_DEPLOYMENT[1..-1].to_h.invert[d.last_follow_up&.o_business_deployment]
25
+ json.service_end_time d.last_follow_up&.service_start_time.to_s + "-" + d.last_follow_up&.service_end_time.to_s
26
+ json.created_at d.created_at.to_s
27
+ json.no_followup_days (d['latest_time'] ? DateTime.parse(Time.now.strftime("%Y-%m-%d")) - DateTime.parse(d['latest_time'].strftime("%Y-%m-%d")) : DateTime.parse(Time.now.strftime("%Y-%m-%d")) - DateTime.parse(d.created_at.strftime("%Y-%m-%d"))).to_i
28
+
29
+ json.staff_manages d.last_follow_up&.assign_follow_ups.present? ? (d.last_follow_up.assign_follow_ups.map{ |d| d.staff.user.real_name}.join("、")) : d.staff&.user&.real_name
30
+ json.divide_rate d.divide_rate
31
+ json.divide_money d.divide_amount.to_f.round(2)
32
+ json.budget_amount d.budget_amount.to_f.round(2) #d.follow_ups.where(stage_id: @budget_stage_ids).order("created_at desc").first&.total_amount&.round(2) || 0
33
+ json.area d.department&.school&.province
34
+
35
+ json.majors d.department&.department_majors&.pluck(:name).present? ? d.department&.department_majors&.pluck(:name).join(",") : ""
36
+
37
+ json.keys_person_count d.last_follow_up.present? ? EducodeSales::KeyPerson.where("follow_up_id = #{d.last_follow_up.id}").count : 0
38
+
39
+
40
+ if d.department&.school
41
+ json.property d.department.school.school_tags.where(for_missions: true).pluck(:name).join("、")
42
+ else
43
+ json.property ''
44
+ end
45
+ json.delete_reason d.delete_reason
46
+ json.state_id d.state_id
47
+ json.sale_way d.last_follow_up&.place&.name.present? ? '渠道' : '直销'
48
+ json.year d.last_follow_up&.year.to_s
49
+ json.total_amount d.last_follow_up&.total_amount.to_f.round(2)
50
+ json.actual_amount d.last_follow_up&.actual_amount.to_f.round(2)
51
+ json.return_money d.return_money
52
+ json.wait_return_money d.wait_return_money.to_f.round(2)
53
+ json.return_money_days d.last_follow_up&.reception_at.present? && d.last_follow_up.money_plans.where(clazz: '实际回款').present? ? (d.last_follow_up.money_plans.where(clazz: '实际回款').order(created_at: :asc).first.date_at.to_s(:date).to_date - d.last_follow_up&.reception_at).to_i : ''
54
+ json.place d.last_follow_up&.place&.name
55
+ json.last_follow_person d.last_follow_up.present? ? d.last_follow_up.staff&.user&.real_name : d.staff&.user&.real_name
56
+ json.source d.source
57
+ json.assign_follow_ups d.last_follow_up.present? ? d.last_follow_up.assign_follow_ups.pluck(:staff_id) : []
58
+
59
+ json.assign_staffs d.last_follow_up&.assign_staffs.present? ? (d.last_follow_up.assign_staffs.map{ |d| d.staff.user.real_name}.join("、")) : ''
60
+ json.current_staff_id @current_admin.id
61
+ json.staff_id d.staff_id
62
+ json.latest_time d.last_follow_up.present? ? d.last_follow_up.created_at.to_s : ''
63
+ json.self_flag (d.staff_id == @current_admin.id) || (d.last_follow_up_id.in? follow_up_ids)
64
+ json.followed d.users.pluck(:user_id).include?(@current_admin.user.id) ? 1 : 0 # d.users.where(user_id:@current_admin.user.id).first ? 1 : 0
65
+ json.p_deploy_time d.p_deploy_time
66
+ end
67
+ end
68
+
69
+ json.totalRow do
70
+ json.follow_ups_count follow_count.to_i.to_s
71
+ end
72
+ json.code 0
73
+ json.count @businesses.total_count
74
+ json.msg 'succcess'
@@ -0,0 +1 @@
1
+ $("#contract_list_wraper").html("<%= j render 'list' %>");