educode_sales 0.6.2 → 0.6.6

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 (45) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/educode_sales/money_plans.png +0 -0
  3. data/app/controllers/educode_sales/businesses_controller.rb +26 -6
  4. data/app/controllers/educode_sales/customers_controller.rb +1 -0
  5. data/app/controllers/educode_sales/follow_ups_controller.rb +1 -1
  6. data/app/controllers/educode_sales/money_plans_controller.rb +65 -0
  7. data/app/controllers/educode_sales/roles_controller.rb +4 -1
  8. data/app/controllers/educode_sales/sale_trends_controller.rb +40 -12
  9. data/app/controllers/educode_sales/staffs_controller.rb +3 -4
  10. data/app/models/educode_sales/permission.rb +2 -1
  11. data/app/models/educode_sales/role_area.rb +1 -0
  12. data/app/views/educode_sales/businesses/_follows.html.erb +15 -15
  13. data/app/views/educode_sales/businesses/edit.html.erb +3 -0
  14. data/app/views/educode_sales/businesses/edit_follow_record.html.erb +12 -3
  15. data/app/views/educode_sales/businesses/file.html.erb +8 -4
  16. data/app/views/educode_sales/businesses/index.html.erb +57 -11
  17. data/app/views/educode_sales/businesses/index.json.jbuilder +3 -2
  18. data/app/views/educode_sales/businesses/new_follow_record.html.erb +6 -2
  19. data/app/views/educode_sales/businesses/show_follow.html.erb +1 -0
  20. data/app/views/educode_sales/customers/edit.html.erb +695 -16
  21. data/app/views/educode_sales/customers/edit_follow_record.html.erb +1 -1
  22. data/app/views/educode_sales/customers/index.html.erb +6 -7
  23. data/app/views/educode_sales/customers/index.json.jbuilder +2 -1
  24. data/app/views/educode_sales/customers/new.html.erb +696 -17
  25. data/app/views/educode_sales/customers/new_follow_record.html.erb +1 -1
  26. data/app/views/educode_sales/customers/show_follow.html.erb +1 -1
  27. data/app/views/educode_sales/money_plans/index.html.erb +222 -0
  28. data/app/views/educode_sales/money_plans/index.json.jbuilder +21 -0
  29. data/app/views/educode_sales/places/index.html.erb +16 -2
  30. data/app/views/educode_sales/places/index.json.jbuilder +3 -1
  31. data/app/views/educode_sales/plans/_monthPlan.html.erb +2 -1
  32. data/app/views/educode_sales/plans/_weekPlan.html.erb +2 -1
  33. data/app/views/educode_sales/recycles/business.json.jbuilder +2 -2
  34. data/app/views/educode_sales/roles/edit.html.erb +8 -0
  35. data/app/views/educode_sales/sale_trends/trends.html.erb +73 -13
  36. data/app/views/educode_sales/sale_trends/trends.json.jbuilder +3 -14
  37. data/app/views/educode_sales/sales/index.html.erb +18 -16
  38. data/app/views/educode_sales/sales/index.json.jbuilder +4 -4
  39. data/app/views/educode_sales/sales/operations.json.jbuilder +2 -2
  40. data/app/views/educode_sales/teachers/index.html.erb +15 -7
  41. data/app/views/layouts/educode_sales/application.html.erb +18 -2
  42. data/config/routes.rb +2 -0
  43. data/db/migrate/20210902064109_create_educode_sales_role_permissions.rb +8 -0
  44. data/lib/educode_sales/version.rb +1 -1
  45. metadata +6 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 97a73ea8470e60cc322017425b3af50411105d237ae981f490aef1df1cd2816f
4
- data.tar.gz: 3711b02d39d60076344835b00d1ff44fc152d30a0671eee314096cb817f720f0
3
+ metadata.gz: 10da162d2ac59ca7795046ebe7239e9c3b64851c4b0ea8fb519eaf0667cd78bf
4
+ data.tar.gz: faf089944ea187641184a31781c809597ca0327eb3b9af8a553391c4d07366b3
5
5
  SHA512:
6
- metadata.gz: 30dda9e9c18079954c459b90f623735b7c286d8a8c0fb6c42ab32464289bdd8133f87d39d938d8d20979b5eb944b65362910d1edf675f32e82c62cefc3ebfdf5
7
- data.tar.gz: 73f820c375a6035995ddcbae380fd39fd07d7db4b2d53e27637c3e6c955371b1a7fe4d4e4ed7649544090501ad2c2aefba4ce02dd6adb9a0778d7313429ba354
6
+ metadata.gz: 17fe4f762532aa69ab8f29e5c9c7f23aca27f0c22ac38fd7570d6a435039dd2a5b344db15104c2e15de9f0032a7e30f2b3c135cad7385bbb961cb3dd7e6eb167
7
+ data.tar.gz: 69fba60e0c97e2c9fbb1debf1ce4a1fab27527260ee87696b7d5861fa0c0ec6deb500efaa1eeafdebdaa3f19a0713e9ddb64c11317a608850c199e7a4bde78ec
@@ -33,15 +33,25 @@ module EducodeSales
33
33
  format.html do
34
34
  common = Common.find_by(clazz: 'staff_type', name: '销售')
35
35
  @staffs = Staff.joins(:user).where(job_type: common.id).map { |d| [d.user.real_name, d.id]}
36
- @more = can?(:create, EducodeSales::SalePlan) || can?(:update, EducodeSales::Business) || can?(:destroy, EducodeSales::Business)
36
+ # @more = can?(:create, EducodeSales::SalePlan) || can?(:update, EducodeSales::Business) || can?(:destroy, EducodeSales::Business) || can?(:show_file, EducodeSales::Business)
37
+ @more = true
37
38
  gon.menus = []
38
39
  gon.place = params[:place_id].present? ? [{ value: params[:place_id], name: EducodeSales::Place.find(params[:place_id]).name }] : []
40
+ gon.business_type = Common.where(clazz: 'business_type').map do |d|
41
+ {value: d.id, name: d.name}
42
+ end
43
+ gon.type = params[:clazz_id].present? ? [{ value: params[:clazz_id], name: Common.find(params[:clazz_id]).name }] : []
44
+ gon.business_step = Common.where(clazz: 'business_step').map do |d|
45
+ {value: d.id, name: d.name}
46
+ end
39
47
  if can?(:create, EducodeSales::SalePlan)
40
48
  gon.menus << { title: '添加周计划', event: 'week' }
41
49
  gon.menus << { title: '添加月计划', event: 'month' }
42
50
  end
43
51
  gon.menus << { title: '跟进时间线', event: 'time_line' }
44
- gon.menus << { title: '附件管理', event: 'file' }
52
+ if can?(:show_file, EducodeSales::Business)
53
+ gon.menus << { title: '附件管理', event: 'file' }
54
+ end
45
55
  if can?(:update, EducodeSales::Business)
46
56
  gon.menus << { title: '编辑', event: 'edit' }
47
57
  end
@@ -76,7 +86,9 @@ module EducodeSales
76
86
  b_id = Common.find_by(extras: EducodeSales::Common::BTYPE)&.id
77
87
  c_id = Common.find_by(extras: EducodeSales::Common::CTYPE)&.id
78
88
  d_id = Common.find_by(extras: EducodeSales::Common::DTYPE)&.id
79
- ids = [a_id ,b_id ,c_id ,d_id]
89
+ e_id = Common.find_by(extras: EducodeSales::Common::ETYPE)&.id
90
+ o_id = Common.find_by(extras: EducodeSales::Common::OTYPE)&.id
91
+ ids = [a_id ,b_id ,c_id ,d_id ,e_id ,o_id]
80
92
  @businesses = @businesses.joins("
81
93
  JOIN educode_sales_follow_ups ON educode_sales_businesses.last_follow_up_id = educode_sales_follow_ups.id
82
94
  ").where("educode_sales_follow_ups.clazz_id in (?)",ids)
@@ -135,12 +147,12 @@ module EducodeSales
135
147
  if params[:q].present? && params[:q][:business_type].present?
136
148
  @businesses = @businesses.joins("
137
149
  JOIN educode_sales_follow_ups ON educode_sales_businesses.last_follow_up_id = educode_sales_follow_ups.id
138
- ").where("educode_sales_follow_ups.clazz_id = ?", params[:q][:business_type])
150
+ ").where("educode_sales_follow_ups.clazz_id in (?)", params[:q][:business_type].split(",").map(&:to_i))
139
151
  end
140
152
  if params[:q].present? && params[:q][:business_step].present?
141
153
  @businesses = @businesses.joins("
142
154
  JOIN educode_sales_follow_ups ON educode_sales_businesses.last_follow_up_id = educode_sales_follow_ups.id
143
- ").where("educode_sales_follow_ups.stage_id = ?", params[:q][:business_step])
155
+ ").where("educode_sales_follow_ups.stage_id in (?)", params[:q][:business_step].split(",").map(&:to_i))
144
156
  end
145
157
  if params[:q].present? && params[:q][:place_id].present?
146
158
  @businesses = @businesses.joins("
@@ -172,7 +184,14 @@ module EducodeSales
172
184
 
173
185
  if params[:q].present? && params[:q][:date].present?
174
186
  date = params[:q][:date].split(" - ")
175
- @businesses = @businesses.where("educode_sales_businesses.created_at > ? AND educode_sales_businesses.created_at < ?", date[0], date[1])
187
+ @businesses = @businesses.where("educode_sales_businesses.created_at > ? AND educode_sales_businesses.created_at < ?", date[0], date[1] + '23:59:59')
188
+ end
189
+
190
+ if params[:q].present? && params[:q][:invitation_at].present?
191
+ date = params[:q][:invitation_at].split(" - ")
192
+ @businesses = @businesses.joins("
193
+ JOIN educode_sales_follow_ups ON educode_sales_businesses.last_follow_up_id = educode_sales_follow_ups.id
194
+ ").where("educode_sales_follow_ups.invitation_at > ? AND educode_sales_follow_ups.invitation_at < ?", date[0] + '00:00:00', date[1] + '23:59:59')
176
195
  end
177
196
 
178
197
  if params[:sort].present? && params[:sort][:field]
@@ -193,6 +212,7 @@ module EducodeSales
193
212
  last_follow.signed_date,
194
213
  last_follow.created_at as latest_time,
195
214
  last_follow.actual_amount,
215
+ (last_follow.actual_amount - educode_sales_businesses.return_money) as wait_return_money,
196
216
  last_follow.total_amount").joins("
197
217
  LEFT JOIN educode_sales_follow_ups AS last_follow ON educode_sales_businesses.last_follow_up_id = last_follow.id
198
218
  ").page(params[:page]).per(params[:limit])
@@ -162,6 +162,7 @@ module EducodeSales
162
162
  @school.attributes = school_params
163
163
  @school.school_property = property
164
164
  @school.save!
165
+ EducodeSales::CustomerExtension.create(customer_staff_id: @current_admin.id, school_id: @school.id)
165
166
  end
166
167
  render_success
167
168
  end
@@ -34,7 +34,7 @@ module EducodeSales
34
34
  end
35
35
  if params[:q].present? && params[:q][:follows_date].present?
36
36
  date = params[:q][:follows_date].split(" - ")
37
- @follow_ups = @follow_ups.where("educode_sales_follow_ups.created_at > ? AND educode_sales_follow_ups.created_at < ?", date[0], date[1])
37
+ @follow_ups = @follow_ups.where("educode_sales_follow_ups.created_at > ? AND educode_sales_follow_ups.created_at < ?", date[0], date[1] + '23:59:59')
38
38
  end
39
39
  if params[:q].present? && params[:q][:staff_id].present?
40
40
  @follow_ups = @follow_ups.where(staff_id: params[:q][:staff_id])
@@ -0,0 +1,65 @@
1
+ require_dependency "educode_sales/application_controller"
2
+
3
+ module EducodeSales
4
+ class MoneyPlansController < ApplicationController
5
+
6
+ def index
7
+ follow_up_ids = Business.pluck(:last_follow_up_id)
8
+ authorize! :read, MoneyPlan
9
+ respond_to do |format|
10
+ format.html do
11
+ common = Common.find_by(clazz: 'staff_type', name: '销售')
12
+ @staffs = Staff.joins(:user).where(job_type: common.id).map { |d| [d.user.real_name, d.id]}
13
+ end
14
+ format.json do
15
+ x_id = Common.find_by(extras: EducodeSales::Common::XTYPE)&.id
16
+ if @current_admin.is_admin?
17
+ @money_plans = MoneyPlan.joins(:follow_up).where("educode_sales_follow_ups.clazz_id != ?", x_id).where(follow_up_id: follow_up_ids)
18
+ else
19
+ level = @current_admin.role.role_areas.find_by(clazz: '回款管理').level
20
+ case level
21
+ when '自己'
22
+ @money_plans = MoneyPlan.joins(:follow_up).where("educode_sales_follow_ups.clazz_id != ?", x_id).where(follow_up_id: follow_up_ids).where(staff_id: @current_admin.staff_id)
23
+ when '区域'
24
+ a_ids = MoneyPlan.where(follow_up_id: follow_up_ids).where(staff_id: @current_admin.staff_id).ids
25
+ school_ids = School.where(province: @current_admin.areas.pluck(:name)).pluck(:id)
26
+ b_ids = Business.where(school_id: school_ids).pluck(:last_follow_up_id)
27
+ ids = a_ids + b_ids
28
+ @money_plans = MoneyPlan.joins(:follow_up).where("educode_sales_follow_ups.clazz_id != ?", x_id).where(id: ids)
29
+ else
30
+ @money_plans = MoneyPlan.joins(:follow_up).where("educode_sales_follow_ups.clazz_id != ?", x_id).where(follow_up_id: follow_up_ids)
31
+ end
32
+ end
33
+
34
+ if params[:q].present? && params[:q][:business].present?
35
+ follow_up_ids = Business.where("name like ?", "%#{params[:q][:business]}%").pluck(:last_follow_up_id)
36
+ @money_plans = @money_plans.where(follow_up_id: follow_up_ids)
37
+ end
38
+ if params[:q].present? && params[:q][:school].present?
39
+ school_ids = School.where("name like ?", "%#{params[:q][:school]}%").pluck(:id)
40
+ follow_up_ids = Business.where(school_id: school_ids).pluck(:last_follow_up_id)
41
+ @money_plans = @money_plans.where(follow_up_id: follow_up_ids)
42
+ end
43
+ if params[:q].present? && params[:q][:staff_id].present?
44
+ @money_plans = @money_plans.where(staff_id: params[:q][:staff_id])
45
+ end
46
+ if params[:q].present? && params[:q][:clazz].present?
47
+ @money_plans = @money_plans.where(clazz: params[:q][:clazz])
48
+ end
49
+ if params[:q].present? && params[:q][:date].present?
50
+ date = params[:q][:date].split(" - ")
51
+ @money_plans = @money_plans.where("educode_sales_money_plans.date_at >= ? AND educode_sales_money_plans.date_at < ?", date[0], date[1] + '23:59:59')
52
+ end
53
+
54
+ if params[:sort].present? && params[:sort][:field]
55
+ @money_plans = @money_plans.order("#{params[:sort][:field]} #{params[:sort][:order]}")
56
+ else
57
+ @money_plans = @money_plans.order(date_at: :desc)
58
+ end
59
+ @total_amount = @money_plans.sum(:amount)
60
+ @money_plans = @money_plans.page(params[:page]).per(params[:limit])
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
@@ -16,7 +16,7 @@ module EducodeSales
16
16
 
17
17
  def create
18
18
  role = Role.new(name: params[:name])
19
- role.role_areas.build([{ clazz: 'Business' }, { clazz: 'SalePlan' }, { clazz: 'Teacher' }, { clazz: 'Operation' }, {clazz:'Customer'}])
19
+ role.role_areas.build([{ clazz: 'Business' }, { clazz: 'SalePlan' }, { clazz: 'Teacher' }, { clazz: 'Operation' }, {clazz:'Customer'}, {clazz:'MoneyPlan'}])
20
20
  if role.save
21
21
  render_success
22
22
  else
@@ -81,6 +81,9 @@ module EducodeSales
81
81
  r = role.role_areas.find_or_initialize_by(clazz: 'Customer')
82
82
  r.level = params[:customer]
83
83
  r.save
84
+ r = role.role_areas.find_or_initialize_by(clazz: 'MoneyPlan')
85
+ r.level = params[:money_plan]
86
+ r.save
84
87
  render_success
85
88
  end
86
89
 
@@ -74,18 +74,46 @@ module EducodeSales
74
74
 
75
75
  #商机区域分布图表
76
76
  provinces = EducodeSales::Common.where(clazz: 'area').pluck(:name)
77
- @business_data = {
78
- labels: provinces,
79
- datasets:[
80
- {
81
- label: "商机总额",
82
- data: provinces.map{|province| Business.joins(:last_follow_up).where("educode_sales_businesses.department_id in (?)", School.joins(:departments).where(province: province).pluck("departments.id")).where("educode_sales_follow_ups.clazz_id != ?", x).sum(:total_amount).round(2)},
83
- backgroundColor: colors[0],
84
- borderColor: colors[0],
85
- borderWidth: 1
86
- }
87
- ]
88
- }
77
+ if params[:business_count_type] == 'money' || params[:business_count_type].blank?
78
+ @business_data = {
79
+ labels: provinces,
80
+ datasets:[
81
+ {
82
+ label: "商机总额",
83
+ data: provinces.map{|province|
84
+ if params[:business_type].blank?
85
+ Business.joins(:last_follow_up).where("educode_sales_businesses.department_id in (?)", School.joins(:departments).where(province: province).pluck("departments.id")).where("educode_sales_follow_ups.clazz_id != ?", x).sum(:total_amount).round(2)
86
+ else
87
+ Business.joins(:last_follow_up).where("educode_sales_businesses.department_id in (?)", School.joins(:departments).where(province: province).pluck("departments.id")).where("educode_sales_follow_ups.clazz_id = ?", params[:business_type]).sum(:total_amount).round(2)
88
+ end
89
+ },
90
+ backgroundColor: colors[0],
91
+ borderColor: colors[0],
92
+ borderWidth: 1
93
+ }
94
+ ]
95
+ }
96
+ else
97
+ @business_data = {
98
+ labels: provinces,
99
+ datasets:[
100
+ {
101
+ label: "商机数量",
102
+ data: provinces.map{|province|
103
+ if params[:business_type].blank?
104
+ Business.joins(:last_follow_up).where("educode_sales_businesses.department_id in (?)", School.joins(:departments).where(province: province).pluck("departments.id")).where("educode_sales_follow_ups.clazz_id != ?", x).count
105
+ else
106
+ Business.joins(:last_follow_up).where("educode_sales_businesses.department_id in (?)", School.joins(:departments).where(province: province).pluck("departments.id")).where("educode_sales_follow_ups.clazz_id = ?", params[:business_type]).count
107
+ end
108
+ },
109
+ backgroundColor: colors[0],
110
+ borderColor: colors[0],
111
+ borderWidth: 1
112
+ }
113
+ ]
114
+ }
115
+ end
116
+
89
117
 
90
118
 
91
119
  # 已中标图表
@@ -67,14 +67,13 @@ module EducodeSales
67
67
 
68
68
  def follow_up_schools
69
69
  staff = Staff.find(params[:id])
70
- # @schools = EducodeSales::Business.joins(:last_follow_up, :department).where("educode_sales_follow_ups.staff_id = #{staff.id}").group("school_id").select("school_id, max(educode_sales_follow_ups.updated_at) AS updated_at").page(params[:page]).per(params[:limit])
71
- @schools = EducodeSales::Teacher.joins(:follow_up, :department).where("educode_sales_teacher_follows.staff_id = #{staff.id}").group("school_id").select("school_id, max(educode_sales_teacher_follows.updated_at) AS updated_at")+EducodeSales::Business.joins(:last_follow_up, :department).where("educode_sales_follow_ups.staff_id = #{staff.id}").group("school_id").select("school_id, max(educode_sales_follow_ups.updated_at) AS updated_at")
72
- @count = EducodeSales::Business.joins(:last_follow_up, :department).where("educode_sales_follow_ups.staff_id = #{staff.id}").group("school_id").count
70
+ @schools = EducodeSales::Teacher.joins(:follow_up, :department).where("educode_sales_teacher_follows.staff_id = #{staff.id}").group("departments.school_id").select("departments.school_id, max(educode_sales_teacher_follows.updated_at) AS updated_at") + EducodeSales::Business.joins(:follow_ups, :department).where("educode_sales_follow_ups.staff_id = #{staff.id}").group("departments.school_id").select("departments.school_id, max(educode_sales_follow_ups.updated_at) AS updated_at")
71
+ @count = EducodeSales::Business.joins(:follow_ups, :department).where("educode_sales_follow_ups.staff_id = #{staff.id}").group("departments.school_id").count
73
72
  end
74
73
 
75
74
  def follow_up_departments
76
75
  staff = Staff.find(params[:id])
77
- @schools = EducodeSales::Business.joins(:last_follow_up, [department: :school]).where("educode_sales_follow_ups.staff_id = #{staff.id}").select("departments.name, schools.name AS school, educode_sales_follow_ups.updated_at")+EducodeSales::Teacher.joins(:follow_up, [department: :school]).where("educode_sales_teacher_follows.staff_id = #{staff.id}").select("departments.name, schools.name AS school, educode_sales_teacher_follows.updated_at")
76
+ @schools = (EducodeSales::Business.joins(:follow_ups, [department: :school]).where("educode_sales_follow_ups.staff_id = #{staff.id}").select("departments.id, departments.name, schools.name AS school, educode_sales_follow_ups.updated_at") + EducodeSales::Teacher.joins(:follow_up, [department: :school]).where("educode_sales_teacher_follows.staff_id = #{staff.id}").select("departments.id, departments.name, schools.name AS school, educode_sales_teacher_follows.updated_at")).uniq{|s| s.id}
78
77
  end
79
78
 
80
79
 
@@ -11,7 +11,8 @@ module EducodeSales
11
11
  '教师运营': 'teacher',
12
12
  '活动运营': 'activity',
13
13
  '运营计划': 'operation_plan',
14
- '客户管理': 'customer'
14
+ '客户管理': 'customer',
15
+ '回款管理': 'money_plan'
15
16
  }
16
17
  end
17
18
  end
@@ -9,6 +9,7 @@ module EducodeSales
9
9
  '教师运营': 'Teacher',
10
10
  '运营计划': 'Operation',
11
11
  '客户管理': 'Customer',
12
+ '回款管理': 'MoneyPlan'
12
13
  }
13
14
  end
14
15
  end
@@ -100,10 +100,16 @@
100
100
  templet:'<div><span title="{{d.description}}">{{d.description}}</span></div>'
101
101
  },
102
102
  {
103
- field: 'advise',
103
+ field: 'business',
104
104
  width: 120,
105
- title: '团队建议',
106
- templet:'<div><span title="{{d.advise}}">{{d.advise}}</span></div>'
105
+ title: '所属商机',
106
+ templet:'#business'
107
+ },
108
+ {
109
+ field: 'school',
110
+ width: 120,
111
+ title: '单位',
112
+ templet:'#school'
107
113
  },
108
114
  {
109
115
  field: 'clazz',
@@ -117,24 +123,18 @@
117
123
  width: 90,
118
124
  templet:'<div><span title="{{d.stage}}">{{d.stage}}</span></div>'
119
125
  },
126
+ {
127
+ field: 'advise',
128
+ width: 120,
129
+ title: '团队建议',
130
+ templet:'<div><span title="{{d.advise}}">{{d.advise}}</span></div>'
131
+ },
120
132
  {
121
133
  field: 'key_people',
122
134
  width: 90,
123
135
  title: '关键人',
124
136
  templet:'<div><span title="{{d.key_people}}">{{d.key_people}}</span></div>'
125
137
  },
126
- {
127
- field: 'business',
128
- width: 120,
129
- title: '所属商机',
130
- templet:'#business'
131
- },
132
- {
133
- field: 'school',
134
- width: 120,
135
- title: '单位',
136
- templet:'#school'
137
- },
138
138
  {
139
139
  field: 'staff',
140
140
  width: 90,
@@ -11,6 +11,9 @@
11
11
  <label class="layui-form-label required">单位部门</label>
12
12
  <div class="layui-input-block" id="department" style="width: 300px;"></div>
13
13
  </div>
14
+ <div class="layui-inline" >
15
+ <a href="/missions/customers" style=" color: #0000FF">添加单位/部门</a>
16
+ </div>
14
17
  <br>
15
18
  <div class="layui-inline" style="padding-top: 20px">
16
19
  <label class="layui-form-label ">商机来源</label>
@@ -69,12 +69,14 @@
69
69
  <div class="layui-input-inline">
70
70
  <input name="total_amount" type="number" class="layui-input" value="<%= @follow_up.total_amount %>">
71
71
  </div>
72
- </div>
72
+ 客户采购支出的费用。总额的生命历程:1.在最初阶段,是商机的预算总额;2.在挂网阶段,是项目的挂网预算总额;3.在中标阶段,是项目的中标总额。 </div>
73
+ <br>
73
74
  <div class="layui-inline">
74
75
  <label class="layui-form-label">合同额(万)</label>
75
76
  <div class="layui-input-inline">
76
77
  <input name="actual_amount" type="number" class="layui-input" placeholder="本单位的签单金额" value="<%= @follow_up.actual_amount %>">
77
78
  </div>
79
+ 客户签给头歌的费用。合同额的生命历程:1.在中标之前,合同额都是0;2.在中标之后,实际与头歌签合同的金额。
78
80
  </div>
79
81
  <br>
80
82
  <div class="layui-inline place_select">
@@ -82,7 +84,9 @@
82
84
  <div class="layui-input-inline" style="z-index: 101">
83
85
  <div id="edit_place" style="width: 190px;"></div>
84
86
  </div>
87
+ 总额里,渠道拿到的部分。
85
88
  </div>
89
+ <br>
86
90
  <div class="layui-inline">
87
91
  <label class="layui-form-label">渠道分成(万)</label>
88
92
  <div class="layui-input-inline">
@@ -95,14 +99,19 @@
95
99
  <div class="layui-input-inline">
96
100
  <input type="text" class="layui-input" name="year" lay-verify="required" autocomplete="off" id="edit_year"
97
101
  value="<%= @follow_up&.year%>"
98
- placeholder="请选择年度"> </div>
102
+ placeholder="请选择年度">
103
+ </div>
99
104
  </div>
100
105
  </div>
101
106
  <div class="layui-form-item">
102
107
  <label class="layui-form-label">指定跟进人</label>
103
- <div class="layui-input-inline">
108
+ <div class="layui-input-inline" style="z-index: 102">
104
109
  <div id="edit_assign_follow" style="width: 512px;"></div>
105
110
  </div>
111
+ <div class="layui-inline" style="padding: 9px 15px">
112
+ <label class="layui-form-label" style="padding-left: 220px"></label>
113
+ 指定跟进人和商机创建者,同时拥有对该商机的管理权限
114
+ </div>
106
115
  </div>
107
116
  <div class="layui-form-item layui-form-text">
108
117
  <label class="layui-form-label required">最新进展</label>
@@ -2,9 +2,9 @@
2
2
  <script type="text/html" id="toolbarDemo">
3
3
  <div class="layui-btn-container">
4
4
  <span class="table-label">附件信息</span>
5
- <%# if can? :create, EducodeSales::file %>
5
+ <% if can? :upload_file, EducodeSales::Business %>
6
6
  <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn pull-right" lay-event="upload_file">上传文件</button>
7
- <%# end %>
7
+ <% end %>
8
8
  </div>
9
9
  </script>
10
10
 
@@ -12,8 +12,12 @@
12
12
 
13
13
  <script type="text/html" id="currentTableBar_file">
14
14
  <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="preview">预览</a>
15
- <a href="/missions/upload_files/download?id={{d.id}}" class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="download">下载</a>
16
- <a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="delete">删除</a>
15
+ <% if can? :download_file, EducodeSales::Business %>
16
+ <a href="/missions/upload_files/download?id={{d.id}}" class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="download">下载</a>
17
+ <% end %>
18
+ <% if can? :delete_file, EducodeSales::Business %>
19
+ <a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="delete">删除</a>
20
+ <% end %>
17
21
  </script>
18
22
 
19
23
  <script type="text/html" id="showchance">
@@ -28,46 +28,54 @@
28
28
  </div>
29
29
  </div>
30
30
  <div class="layui-inline">
31
- <label class="layui-form-label">销售人员</label>
31
+ <label class="layui-form-label">最新跟进人</label>
32
32
  <div class="layui-input-inline">
33
33
  <%= select_tag "staff_id", options_for_select(@staffs, params[:staff_id]), { 'lay-filter': 'staff_id', include_blank: true } %>
34
34
  </div>
35
35
  </div>
36
- <div class="layui-inline">
36
+ <div class="layui-inline show_item" style="display:none;">
37
37
  <label class="layui-form-label">项目类型</label>
38
38
  <div class="layui-input-inline">
39
- <%= select_tag "business_type", options_for_select(EducodeSales::Common.where(clazz: 'business_type').pluck(:name, :id), params[:clazz_id]), { 'lay-filter': 'clazz_id', include_blank: true } %>
39
+ <div id="business_type" style="width: 190px;"></div>
40
40
  </div>
41
41
  </div>
42
- <div class="layui-inline">
42
+ <div class="layui-inline show_item" style="display:none;">
43
43
  <label class="layui-form-label">项目阶段</label>
44
44
  <div class="layui-input-inline">
45
- <%= select_tag "business_step", options_for_select(EducodeSales::Common.where(clazz: 'business_step').pluck(:name, :id)), { include_blank: true } %>
45
+ <div id="business_step" style="width: 190px;"></div>
46
46
  </div>
47
47
  </div>
48
- <div class="layui-inline">
48
+ <div class="layui-inline show_item" style="display:none;">
49
49
  <label class="layui-form-label">渠道名称</label>
50
50
  <div class="layui-input-inline">
51
51
  <div id="index_place" style="width: 190px;"></div>
52
52
  </div>
53
53
  </div>
54
- <div class="layui-inline">
54
+ <div class="layui-inline show_item" style="display:none;">
55
55
  <label class="layui-form-label">区域</label>
56
56
  <div class="layui-input-inline">
57
57
  <%= select_tag "area", options_for_select(EducodeSales::Common.where(clazz: 'area').pluck(:name, :id)), { include_blank: true } %>
58
58
  </div>
59
59
  </div>
60
- <div class="layui-inline">
61
- <label class="layui-form-label">起止时间</label>
60
+ <div class="layui-inline show_item" style="display:none;">
61
+ <label class="layui-form-label">创建时间</label>
62
62
  <div class="layui-input-inline">
63
63
  <input type="text" class="layui-input" id="date" name="date" placeholder=" - ">
64
64
  </div>
65
65
  </div>
66
+ <div class="layui-inline show_item" style="display:none;">
67
+ <label class="layui-form-label">招标时间</label>
68
+ <div class="layui-input-inline">
69
+ <input type="text" class="layui-input" id="invitation_at" name="invitation_at" placeholder=" - ">
70
+ </div>
71
+ </div>
66
72
  <div class="layui-inline">
67
73
  <button type="reset" class="layui-btn layui-btn-primary" lay-submit lay-filter="reset_business_search">重置
68
74
  </button>
69
75
  <button type="submit" id="search_bt" class="layui-btn layui-btn-primary" lay-submit lay-filter="search_bussiness">搜索
70
76
  </button>
77
+ <a style="padding-left: 20px;color: #0000FF" href="javascript:;" type="submit" class="" lay-submit lay-filter="show_hide">展开/收起
78
+ </a>
71
79
  </div>
72
80
  </div>
73
81
  </form>
@@ -126,6 +134,10 @@
126
134
  elem: '#date',
127
135
  range: true
128
136
  });
137
+ laydate.render({
138
+ elem: '#invitation_at',
139
+ range: true
140
+ });
129
141
 
130
142
  var is_show = <%=params[:name].present? || params[:clazz_id].present? || params[:place_id].present? || params[:school].present? %>
131
143
  if(is_show){
@@ -135,6 +147,15 @@
135
147
  $('.businesses_list_div').addClass('layui-show');
136
148
  }
137
149
 
150
+ var business_type_list = xmSelect.render({
151
+ el: '#business_type',
152
+ data: gon.business_type
153
+ })
154
+ business_type_list.setValue(gon.type)
155
+ var business_step_list = xmSelect.render({
156
+ el: '#business_step',
157
+ data: gon.business_step
158
+ })
138
159
  var index_place_list = xmSelect.render({
139
160
  el: '#index_place',
140
161
  model: {
@@ -300,6 +321,13 @@
300
321
  sort: true,
301
322
  totalRow: true
302
323
  },
324
+ {
325
+ field: 'wait_return_money',
326
+ width: 100,
327
+ title: '待回款',
328
+ sort: true,
329
+ totalRow: true
330
+ },
303
331
  {
304
332
  field: 'place',
305
333
  width: 160,
@@ -481,7 +509,17 @@
481
509
 
482
510
  // 监听搜索操作
483
511
  form.on('submit(search_bussiness)', function (data) {
512
+ var business_type = [];
513
+ business_type_list.getValue().forEach(function(d) {
514
+ business_type.push(d.value);
515
+ })
516
+ var business_step = [];
517
+ business_step_list.getValue().forEach(function(d) {
518
+ business_step.push(d.value);
519
+ })
484
520
  data.field.place_id = index_place_list.getValue('valueStr');
521
+ data.field.business_type = business_type.toString();
522
+ data.field.business_step = business_step.toString();
485
523
  search = data.field
486
524
  console.log(search);
487
525
  table.reload('businesses_table', {
@@ -503,13 +541,21 @@
503
541
  return false;
504
542
  });
505
543
 
544
+ form.on('submit(show_hide)', function (data) {
545
+ $(".show_item").toggle()
546
+ return false;
547
+ });
506
548
  form.on('submit(reset_business_search)', function (data) {
507
549
  var field = data.field;
508
550
  form.val('search_form', {
509
551
  name: '', department: '', staff_id: '', business_type: '', business_step: '',
510
- place_id: '', date: '', area: ''
552
+ place_id: '', date: '', area: '', invitation_at: ''
511
553
  })
512
- return false;
554
+ business_type_list.setValue([])
555
+ business_step_list.setValue([])
556
+ index_place_list.setValue([])
557
+
558
+ return false;
513
559
  });
514
560
 
515
561
  table.on('toolbar(businesses_table)', function (obj) {
@@ -6,7 +6,7 @@ json.data do
6
6
  json.department d.department.name
7
7
  json.school d.department.school.name
8
8
  json.school_id d.department.school.id
9
- json.follow_ups_count d.follow_ups_count
9
+ json.follow_ups_count d.follow_ups.where(deleted_at: nil).size
10
10
  follow_ups_count += d.follow_ups_count
11
11
  json.follow_up_id d.last_follow_up_id
12
12
  # json.teachers_count d.follow_ups.sum(:key_people_count)
@@ -20,13 +20,14 @@ json.data do
20
20
  json.total_amount d.last_follow_up&.total_amount
21
21
  json.actual_amount d.last_follow_up&.actual_amount
22
22
  json.return_money d.return_money
23
+ json.wait_return_money d.wait_return_money.to_i.round(2)
23
24
  json.place d.last_follow_up&.place&.name
24
25
  json.last_follow_person d.last_follow_up.present? ? d.last_follow_up.staff.user.real_name : EducodeSales::Staff.find(d.staff_id).user.real_name
25
26
  json.source d.source
26
27
  json.assign_follow_ups d.last_follow_up.present? ? d.last_follow_up.assign_follow_ups.pluck(:staff_id) : []
27
28
  json.current_staff_id @current_admin.id
28
29
  json.staff_id d.staff_id
29
- json.latest_time d.last_follow_up.present? ? d.last_follow_up.created_at.to_s : d.created_at.to_s
30
+ json.latest_time d.last_follow_up.present? ? d.last_follow_up.created_at.to_s : ''
30
31
  end
31
32
  end
32
33