educode_sales 0.5.8 → 0.6.2

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 (57) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/educode_sales//345/256/242/346/210/267/347/256/241/347/220/206.png +0 -0
  3. data/app/controllers/educode_sales/businesses_controller.rb +4 -2
  4. data/app/controllers/educode_sales/customer_extensions_controller.rb +17 -0
  5. data/app/controllers/educode_sales/customer_follows_controller.rb +41 -0
  6. data/app/controllers/educode_sales/customers_controller.rb +204 -0
  7. data/app/controllers/educode_sales/places_controller.rb +5 -1
  8. data/app/controllers/educode_sales/roles_controller.rb +4 -1
  9. data/app/controllers/educode_sales/sale_trends_controller.rb +16 -1
  10. data/app/controllers/educode_sales/teachers_controller.rb +13 -2
  11. data/app/models/educode_sales/customer.rb +4 -0
  12. data/app/models/educode_sales/customer_extension.rb +7 -0
  13. data/app/models/educode_sales/customer_follow.rb +5 -0
  14. data/app/models/educode_sales/permission.rb +3 -2
  15. data/app/models/educode_sales/role_area.rb +1 -0
  16. data/app/views/educode_sales/businesses/_follows.html.erb +10 -4
  17. data/app/views/educode_sales/businesses/edit_follow_record.html.erb +2 -2
  18. data/app/views/educode_sales/businesses/index.html.erb +25 -18
  19. data/app/views/educode_sales/businesses/index.json.jbuilder +1 -0
  20. data/app/views/educode_sales/businesses/new.html.erb +3 -0
  21. data/app/views/educode_sales/businesses/new_follow_record.html.erb +2 -2
  22. data/app/views/educode_sales/businesses/show_follow.html.erb +7 -2
  23. data/app/views/educode_sales/businesses/show_follow.json.jbuilder +1 -0
  24. data/app/views/educode_sales/businesses/time_line.html.erb +1 -1
  25. data/app/views/educode_sales/customers/edit.html.erb +94 -0
  26. data/app/views/educode_sales/customers/edit_department.html.erb +54 -0
  27. data/app/views/educode_sales/customers/edit_follow_record.html.erb +50 -0
  28. data/app/views/educode_sales/customers/give.html.erb +51 -0
  29. data/app/views/educode_sales/customers/index.html.erb +493 -0
  30. data/app/views/educode_sales/customers/index.json.jbuilder +24 -0
  31. data/app/views/educode_sales/customers/new.html.erb +96 -0
  32. data/app/views/educode_sales/customers/new_department.html.erb +56 -0
  33. data/app/views/educode_sales/customers/new_follow_record.html.erb +54 -0
  34. data/app/views/educode_sales/customers/show_department.json.jbuilder +13 -0
  35. data/app/views/educode_sales/customers/show_follow.html.erb +442 -0
  36. data/app/views/educode_sales/customers/show_follow.json.jbuilder +13 -0
  37. data/app/views/educode_sales/customers/show_follow_record.html.erb +18 -0
  38. data/app/views/educode_sales/follow_ups/index.json.jbuilder +1 -0
  39. data/app/views/educode_sales/places/index.html.erb +64 -0
  40. data/app/views/educode_sales/places/index.json.jbuilder +1 -1
  41. data/app/views/educode_sales/roles/edit.html.erb +9 -1
  42. data/app/views/educode_sales/sale_trends/trends.html.erb +20 -0
  43. data/app/views/educode_sales/sales/index.html.erb +63 -21
  44. data/app/views/educode_sales/sales/index.json.jbuilder +32 -5
  45. data/app/views/educode_sales/teachers/index.html.erb +4 -11
  46. data/app/views/educode_sales/teachers/index.json.jbuilder +3 -3
  47. data/app/views/educode_sales/teachers/show_follow.html.erb +10 -5
  48. data/app/views/educode_sales/teachers/show_follow.json.jbuilder +1 -0
  49. data/app/views/layouts/educode_sales/application.html.erb +8 -1
  50. data/config/routes.rb +25 -0
  51. data/db/migrate/20210902064109_create_educode_sales_role_permissions.rb +15 -0
  52. data/db/migrate/20211214100803_create_customer_extensions.rb +9 -0
  53. data/db/migrate/20211215025029_create_educode_sales_customer_follows.rb +12 -0
  54. data/db/migrate/20211220102720_add_position_to_commons.rb +12 -0
  55. data/db/migrate/20211221075146_add_school_id_to_educode_sales_businesses.rb +8 -0
  56. data/lib/educode_sales/version.rb +1 -1
  57. metadata +26 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cb7ba8647915177726d6f9f525ea700b0e7ca469bf8ff7460d27a8d3e5204c28
4
- data.tar.gz: d56bb7b39f7f44dc59b2d733ae60af4d3aee9135f8ee60e0721a5723bf20fc7a
3
+ metadata.gz: 97a73ea8470e60cc322017425b3af50411105d237ae981f490aef1df1cd2816f
4
+ data.tar.gz: 3711b02d39d60076344835b00d1ff44fc152d30a0671eee314096cb817f720f0
5
5
  SHA512:
6
- metadata.gz: 7b2d57743dbf47151f106931393b6e4e9671a8bba6b8393e3769954ddb8a82cb914c85ee926c16595ec546f2e7826a569590d6d9589d12d67d0858a77c2effc6
7
- data.tar.gz: 96d8209f672ee5118f30da45bb672db2139f9890148c0bfff46873df59329d8aa5b1c9e1763e7c063048e994f03399706fd8e850a8502e8cd8d08bcae3e44dc0
6
+ metadata.gz: 30dda9e9c18079954c459b90f623735b7c286d8a8c0fb6c42ab32464289bdd8133f87d39d938d8d20979b5eb944b65362910d1edf675f32e82c62cefc3ebfdf5
7
+ data.tar.gz: 73f820c375a6035995ddcbae380fd39fd07d7db4b2d53e27637c3e6c955371b1a7fe4d4e4ed7649544090501ad2c2aefba4ce02dd6adb9a0778d7313429ba354
@@ -35,6 +35,7 @@ module EducodeSales
35
35
  @staffs = Staff.joins(:user).where(job_type: common.id).map { |d| [d.user.real_name, d.id]}
36
36
  @more = can?(:create, EducodeSales::SalePlan) || can?(:update, EducodeSales::Business) || can?(:destroy, EducodeSales::Business)
37
37
  gon.menus = []
38
+ gon.place = params[:place_id].present? ? [{ value: params[:place_id], name: EducodeSales::Place.find(params[:place_id]).name }] : []
38
39
  if can?(:create, EducodeSales::SalePlan)
39
40
  gon.menus << { title: '添加周计划', event: 'week' }
40
41
  gon.menus << { title: '添加月计划', event: 'month' }
@@ -190,6 +191,7 @@ module EducodeSales
190
191
  last_follow.reception_at,
191
192
  last_follow.bidded_date,
192
193
  last_follow.signed_date,
194
+ last_follow.created_at as latest_time,
193
195
  last_follow.actual_amount,
194
196
  last_follow.total_amount").joins("
195
197
  LEFT JOIN educode_sales_follow_ups AS last_follow ON educode_sales_businesses.last_follow_up_id = last_follow.id
@@ -200,7 +202,7 @@ module EducodeSales
200
202
 
201
203
  def create
202
204
  department = Department.find(params[:department_id])
203
- business = @current_admin.businesses.build(name: params[:name], department_id: department.id, source: params[:source])
205
+ business = @current_admin.businesses.build(name: params[:name], department_id: department.id, source: params[:source], school_id: department.school_id)
204
206
  if business.save
205
207
  render_success
206
208
  else
@@ -222,7 +224,7 @@ module EducodeSales
222
224
  def update
223
225
  business = Business.find(params[:id])
224
226
  department = Department.find(params[:department_id])
225
- if business.update(name: params[:name], department_id: department.id, source: params[:source])
227
+ if business.update(name: params[:name], department_id: department.id, source: params[:source], school_id: department.school_id)
226
228
  render_success
227
229
  else
228
230
  render_failure business
@@ -0,0 +1,17 @@
1
+ require_dependency "educode_sales/application_controller"
2
+
3
+ module EducodeSales
4
+ class CustomerExtensionsController < ApplicationController
5
+
6
+ def create
7
+ params[:school_ids].each do |d|
8
+ if EducodeSales::CustomerExtension.find_by(school_id: d).present?
9
+ EducodeSales::CustomerExtension.find_by(school_id: d).update(customer_staff_id: params[:staff_id])
10
+ else
11
+ EducodeSales::CustomerExtension.create(customer_staff_id: params[:staff_id], school_id: d)
12
+ end
13
+ end
14
+ render_success
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,41 @@
1
+ require_dependency "educode_sales/application_controller"
2
+
3
+ module EducodeSales
4
+ class CustomerFollowsController < ApplicationController
5
+ def create
6
+ follow_up = EducodeSales::CustomerFollow.new(follow_up_params)
7
+ follow_up.staff = @current_admin
8
+ if follow_up.save
9
+ render_success
10
+ else
11
+ render_failure follow_up
12
+ end
13
+ end
14
+
15
+ def destroy
16
+ follow_up = CustomerFollow.find(params[:id])
17
+ if follow_up.destroy
18
+ render_success
19
+ else
20
+ render_failure follow_up
21
+ end
22
+ end
23
+
24
+ def update
25
+ follow_up = CustomerFollow.find(params[:id])
26
+ follow_up.assign_attributes(follow_up_params)
27
+ if follow_up.save
28
+ render_success
29
+ else
30
+ render_failure follow_up
31
+ end
32
+ end
33
+
34
+ private
35
+
36
+ def follow_up_params
37
+ params.permit(:school_id, :department_id, :content)
38
+ end
39
+
40
+ end
41
+ end
@@ -0,0 +1,204 @@
1
+ require_dependency "educode_sales/application_controller"
2
+
3
+ module EducodeSales
4
+ class CustomersController < ApplicationController
5
+
6
+ def new_department
7
+ render layout: false
8
+ end
9
+ def create_department
10
+ department_name = params[:department_name].to_s.strip
11
+ school = School.find(params[:school_id])
12
+
13
+ return render_failure('部门名称重复') if school.departments.exists?(name: department_name)
14
+
15
+ ActiveRecord::Base.transaction do
16
+ department = school.departments.create!(name: department_name, is_auth: 1)
17
+ ApplyAddDepartment.create!(school_id: school.id, status: 1, name: department.name,
18
+ department_id: department.id, user_id: current_user.id)
19
+ end
20
+
21
+ render_success
22
+ end
23
+
24
+ def edit_department
25
+ @department = Department.find(params[:id])
26
+ render layout: false
27
+ end
28
+ def update_department
29
+ department = Department.find(params[:id])
30
+ department.update(name: params[:department_name])
31
+ render_success
32
+ end
33
+
34
+
35
+ def index
36
+ authorize! :read, Customer
37
+ respond_to do |format|
38
+ format.html do
39
+ common = Common.find_by(clazz: 'staff_type', name: '销售')
40
+ @staffs = Staff.joins(:user).where(job_type: common.id).map { |d| [d.user.real_name, d.id]}
41
+ end
42
+ format.json do
43
+ if @current_admin.is_admin?
44
+ @customers = School.all
45
+ else
46
+ level = @current_admin.role.role_areas.find_by(clazz: '客户管理').level
47
+ case level
48
+ when '自己'
49
+ school_ids = CustomerExtension.where(customer_staff_id: @current_admin.id).pluck(:school_id)
50
+ @customers = School.where(id: school_ids)
51
+ when '区域'
52
+ a_school_ids = School.where(province: @current_admin.areas.pluck(:name)).ids
53
+ b_school_ids = CustomerExtension.where(customer_staff_id: @current_admin.id).pluck(:school_id)
54
+ school_ids = a_school_ids + b_school_ids
55
+ @customers = School.where(id: school_ids)
56
+ else
57
+ @customers = School.all
58
+ end
59
+ end
60
+
61
+ if params[:q].present? && params[:q][:name].present?
62
+ @customers = @customers.where("schools.name like ?", "%#{params[:q][:name]}%")
63
+ end
64
+ if params[:q].present? && params[:q][:area].present?
65
+ @customers = @customers.where("schools.province = ?", "#{params[:q][:area]}")
66
+ end
67
+ if params[:q].present? && params[:q][:staff_id].present?
68
+ school_ids = EducodeSales::CustomerExtension.where(customer_staff_id: params[:q][:staff_id]).pluck(:school_id)
69
+ @customers = @customers.where(id: school_ids)
70
+ end
71
+
72
+ if params[:q].present? && params[:q][:date].present?
73
+ ids = EducodeSales::CustomerFollow.all.pluck(:school_id)
74
+ @customers = @customers.where(id: ids)
75
+ school_ids =[]
76
+ date = params[:q][:date].split(" - ")
77
+ @customers.each do |d|
78
+ business_ids = EducodeSales::Business.where(school_id: d.id).ids
79
+ follow_ups = EducodeSales::FollowUp.where(business_id: business_ids)
80
+ customer_follows = EducodeSales::CustomerFollow.where(school_id: d.id)
81
+ next if follow_ups.blank? && customer_follows.blank?
82
+ a_last_follow_time = follow_ups.last&.created_at&.to_s
83
+ b_last_follow_time = customer_follows.last&.created_at&.to_s
84
+ if a_last_follow_time.present? && b_last_follow_time.present?
85
+ last_follow_time = ((a_last_follow_time < b_last_follow_time) ? b_last_follow_time : a_last_follow_time)
86
+ else
87
+ last_follow_time = (a_last_follow_time || b_last_follow_time)
88
+ end
89
+ if last_follow_time.present? && last_follow_time > date[0] && last_follow_time < date[1]
90
+ school_ids << d.id
91
+ end
92
+ end
93
+ @customers = @customers.where(id: school_ids)
94
+ end
95
+
96
+ @customers = @customers.order(id: :desc).page(params[:page]).per(params[:limit])
97
+ end
98
+ end
99
+ end
100
+
101
+ def give
102
+ common = Common.find_by(clazz: 'staff_type', name: '销售')
103
+ @staffs = Staff.joins(:user).where(job_type: common.id).map { |d| [d.user.real_name, d.id]}
104
+ render layout: false
105
+ end
106
+
107
+ def show_follow
108
+ respond_to do |format|
109
+ format.html do
110
+ @school_name = School.find(params[:id]).name
111
+ @area = School.find(params[:id]).province
112
+ @staff = EducodeSales::CustomerExtension.find_by(school_id: params[:id])&.customer_staff&.user&.real_name
113
+ render layout: false
114
+ end
115
+ format.json do
116
+ @follow_ups = EducodeSales::CustomerFollow.where(school_id: params[:id])
117
+ @latest = @follow_ups.order(created_at: :desc).first
118
+ @follow_ups = @follow_ups.order("created_at desc")
119
+ @follow_ups = @follow_ups.page(params[:page]).per(params[:limit])
120
+ end
121
+ end
122
+ end
123
+
124
+ def show_department
125
+ @departments = School.find(params[:id]).departments
126
+ @departments = @departments.order("created_at desc")
127
+ @departments = @departments.page(params[:page]).per(params[:limit])
128
+ end
129
+
130
+
131
+ def new_follow_record
132
+ @school = School.find(params[:id])
133
+ render layout: false
134
+ end
135
+
136
+ def show_follow_record
137
+ @follow_up = EducodeSales::CustomerFollow.find(params[:id])
138
+ @school = School.find(@follow_up.school_id)
139
+ render layout: false
140
+ end
141
+
142
+ def edit_follow_record
143
+ @follow_up = EducodeSales::CustomerFollow.find(params[:id])
144
+ @school = School.find(@follow_up.school_id)
145
+ render layout: false
146
+ end
147
+
148
+ def new
149
+ render layout: false
150
+ end
151
+
152
+ def create
153
+ ActiveRecord::Base.transaction do
154
+ property = SchoolProperty.find_or_create_by!(project_985: params[:project_985].present? ? 1 : 0,
155
+ project_211: params[:project_211].present? ? 1 : 0,
156
+ regular_college: params[:regular_college].present? ? 1 : 0,
157
+ junior_college: params[:junior_college].present? ? 1 : 0,
158
+ secondary_school: params[:secondary_school].present? ? 1 : 0,
159
+ military_school: params[:military_school].present? ? 1 : 0,
160
+ enterprise: params[:enterprise].present? ? 1 : 0)
161
+ @school = School.new
162
+ @school.attributes = school_params
163
+ @school.school_property = property
164
+ @school.save!
165
+ end
166
+ render_success
167
+ end
168
+
169
+ def edit
170
+ @school = School.find(params[:id])
171
+ @school_property = @school.school_property
172
+ render layout: false
173
+ end
174
+
175
+ def update
176
+ @school = School.find(params[:id])
177
+ ActiveRecord::Base.transaction do
178
+ property = SchoolProperty.find_or_create_by!(project_985: params[:project_985].present? ? 1 : 0,
179
+ project_211: params[:project_211].present? ? 1 : 0,
180
+ regular_college: params[:regular_college].present? ? 1 : 0,
181
+ junior_college: params[:junior_college].present? ? 1 : 0,
182
+ secondary_school: params[:secondary_school].present? ? 1 : 0,
183
+ military_school: params[:military_school].present? ? 1 : 0,
184
+ enterprise: params[:enterprise].present? ? 1 : 0)
185
+ @school.attributes = school_params
186
+ @school.school_property = property
187
+ @school.save!
188
+ end
189
+ render_success
190
+ end
191
+
192
+ private
193
+
194
+
195
+ def school_property_params
196
+ params.permit(:project_985, :project_211, :regular_college, :junior_college, :secondary_school, :military_school, :enterprise)
197
+ end
198
+
199
+ def school_params
200
+ params.permit(:name, :province, :city, :address)
201
+ end
202
+
203
+ end
204
+ end
@@ -8,7 +8,11 @@ module EducodeSales
8
8
  format.html do
9
9
  end
10
10
  format.json do
11
- @places = Place.page(params[:page]).per(params[:limit])
11
+ @places = EducodeSales::Place.all
12
+ if params[:q].present? && params[:q][:name].present?
13
+ @places = @places.where("name like ?", "%#{params[:q][:name]}%")
14
+ end
15
+ @places = @places.page(params[:page]).per(params[:limit])
12
16
  @x = Common.find_by(extras: EducodeSales::Common::XTYPE)&.id
13
17
  @stage_ids = Common.where(clazz: '商机阶段', name: ['已中标','已签单','已验收','回款中', '服务中','已结束']).pluck(:id)
14
18
  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' }])
19
+ role.role_areas.build([{ clazz: 'Business' }, { clazz: 'SalePlan' }, { clazz: 'Teacher' }, { clazz: 'Operation' }, {clazz:'Customer'}])
20
20
  if role.save
21
21
  render_success
22
22
  else
@@ -78,6 +78,9 @@ module EducodeSales
78
78
  role.role_areas.find_by(clazz: 'Operation').update(level: params[:operation])
79
79
  role.role_areas.find_by(clazz: 'SalePlan').update(level: params[:sale_plan])
80
80
  role.role_areas.find_by(clazz: 'Teacher').update(level: params[:teacher])
81
+ r = role.role_areas.find_or_initialize_by(clazz: 'Customer')
82
+ r.level = params[:customer]
83
+ r.save
81
84
  render_success
82
85
  end
83
86
 
@@ -13,7 +13,7 @@ module EducodeSales
13
13
  x = Common.find_by(extras: EducodeSales::Common::XTYPE)&.id
14
14
  o = Common.find_by(extras: EducodeSales::Common::OTYPE)&.id
15
15
  @sale_trend = SaleTrend.find_or_create_by(year: @year)
16
- @business_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ? AND educode_sales_follow_ups.clazz_id != ?", x, o).sum(:total_amount).round(2)
16
+ @business_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", x).sum(:total_amount).round(2)
17
17
  stage_ids = Common.where(clazz: '商机阶段', name: ['已中标','已签单','已验收','回款中', '服务中','已结束']).pluck(:id)
18
18
  @goal_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", x).where("educode_sales_follow_ups.bidded_date >= ? AND educode_sales_follow_ups.bidded_date <= ? AND educode_sales_follow_ups.stage_id IN (?)", "#{@year}-01-01", "#{@year}-12-31", stage_ids).sum(:total_amount).round(2)
19
19
  @actual_goal_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", x).where("educode_sales_follow_ups.bidded_date >= ? AND educode_sales_follow_ups.bidded_date <= ? AND educode_sales_follow_ups.stage_id IN (?)", "#{@year}-01-01", "#{@year}-12-31", stage_ids).sum(:actual_amount).round(2)
@@ -72,6 +72,21 @@ module EducodeSales
72
72
  end
73
73
  end
74
74
 
75
+ #商机区域分布图表
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
+ }
89
+
75
90
 
76
91
  # 已中标图表
77
92
  goal_default_dates = ("#{Time.now.year}-01".."#{Time.now.year}-#{Time.now.month}").to_a
@@ -113,10 +113,21 @@ module EducodeSales
113
113
  @teachers = @teachers.where("educode_sales_teachers.created_at > ? AND educode_sales_teachers.created_at < ?", date[0], date[1])
114
114
  end
115
115
 
116
- @teachers = @teachers.order("educode_sales_teachers.created_at desc").page(params[:page]).per(params[:limit])
116
+ @teachers = @teachers.select("
117
+ educode_sales_teachers.*,
118
+ users.created_on,
119
+ users.last_login_on").joins("
120
+ LEFT JOIN users ON educode_sales_teachers.user_id = users.id
121
+ ")
122
+ if params[:sort].present? && params[:sort][:field]
123
+ @teachers = @teachers.order("#{params[:sort][:field]} #{params[:sort][:order]}")
124
+ else
125
+ @teachers = @teachers.order("educode_sales_teachers.created_at desc")
126
+ end
127
+ @teachers = @teachers.page(params[:page]).per(params[:limit])
128
+ end
117
129
 
118
130
  end
119
- end
120
131
  end
121
132
 
122
133
  def import
@@ -0,0 +1,4 @@
1
+ module EducodeSales
2
+ class Customer < ApplicationRecord
3
+ end
4
+ end
@@ -0,0 +1,7 @@
1
+ module EducodeSales
2
+ class CustomerExtension < ApplicationRecord
3
+ belongs_to :customer_staff, class_name: 'Staff', optional: true
4
+ belongs_to :school
5
+
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ module EducodeSales
2
+ class CustomerFollow < ApplicationRecord
3
+ belongs_to :staff
4
+ end
5
+ end
@@ -1,7 +1,7 @@
1
1
  module EducodeSales
2
2
  class Permission < ApplicationRecord
3
3
  enum clazz: {
4
- '市场态势': 'market',
4
+ '销售态势': 'market',
5
5
  '销售分工': 'sale_job',
6
6
  '商机管理': 'business',
7
7
  '渠道管理': 'place',
@@ -10,7 +10,8 @@ module EducodeSales
10
10
  '运营分工': 'operation_job',
11
11
  '教师运营': 'teacher',
12
12
  '活动运营': 'activity',
13
- '运营计划': 'operation_plan'
13
+ '运营计划': 'operation_plan',
14
+ '客户管理': 'customer'
14
15
  }
15
16
  end
16
17
  end
@@ -8,6 +8,7 @@ module EducodeSales
8
8
  '销售计划': 'SalePlan',
9
9
  '教师运营': 'Teacher',
10
10
  '运营计划': 'Operation',
11
+ '客户管理': 'Customer',
11
12
  }
12
13
  end
13
14
  end
@@ -55,6 +55,9 @@
55
55
  <script type="text/html" id="business">
56
56
  <a href="javascript:void(0);" lay-event="business" class="layui-table-link">{{ d.business }}</a>
57
57
  </script>
58
+ <script type="text/html" id="school">
59
+ <a href="<%= base_url%>/colleges/{{d.school_id}}/statistics" class="layui-table-link" target="_blank">{{ d.school }}</a>
60
+ </script>
58
61
 
59
62
 
60
63
  <script>
@@ -98,7 +101,7 @@
98
101
  },
99
102
  {
100
103
  field: 'advise',
101
- width: 170,
104
+ width: 120,
102
105
  title: '团队建议',
103
106
  templet:'<div><span title="{{d.advise}}">{{d.advise}}</span></div>'
104
107
  },
@@ -122,14 +125,15 @@
122
125
  },
123
126
  {
124
127
  field: 'business',
125
- width: 150,
128
+ width: 120,
126
129
  title: '所属商机',
127
130
  templet:'#business'
128
131
  },
129
132
  {
130
133
  field: 'school',
131
- width: 150,
134
+ width: 120,
132
135
  title: '单位',
136
+ templet:'#school'
133
137
  },
134
138
  {
135
139
  field: 'staff',
@@ -138,9 +142,11 @@
138
142
  },
139
143
  {
140
144
  field: 'created_at',
141
- width: 170,
145
+ width: 120,
142
146
  title: '跟进时间',
143
147
  sort: true,
148
+ templet:'<div><span title="{{d.created_at}}">{{d.created_at}}</span></div>'
149
+
144
150
  },
145
151
  {
146
152
  title: '操作',
@@ -91,9 +91,9 @@
91
91
  </div>
92
92
  <div class="layui-form-item">
93
93
  <div class="layui-inline">
94
- <label class="layui-form-label">所属年度</label>
94
+ <label class="layui-form-label required">所属年度</label>
95
95
  <div class="layui-input-inline">
96
- <input type="text" class="layui-input" name="year" autocomplete="off" id="edit_year"
96
+ <input type="text" class="layui-input" name="year" lay-verify="required" autocomplete="off" id="edit_year"
97
97
  value="<%= @follow_up&.year%>"
98
98
  placeholder="请选择年度"> </div>
99
99
  </div>
@@ -18,12 +18,13 @@
18
18
  <label class="layui-form-label">商机名称</label>
19
19
  <div class="layui-input-inline">
20
20
  <input type="text" name="name" autocomplete="off" class="layui-input" value="<%=params[:name] %>">
21
+ <input type="text" style="display: none" name="place_id" autocomplete="off" class="layui-input" value="<%=params[:place_id] %>">
21
22
  </div>
22
23
  </div>
23
24
  <div class="layui-inline">
24
25
  <label class="layui-form-label">单位</label>
25
26
  <div class="layui-input-inline">
26
- <input type="text" name="department" autocomplete="off" class="layui-input">
27
+ <input type="text" name="department" autocomplete="off" value="<%=params[:school] %>" class="layui-input">
27
28
  </div>
28
29
  </div>
29
30
  <div class="layui-inline">
@@ -107,6 +108,9 @@
107
108
  <script type="text/html" id="show_follow">
108
109
  <a href="javascript:void(0);" lay-event="show_follow" class="layui-table-link">{{ d.follow_ups_count }}</a>
109
110
  </script>
111
+ <script type="text/html" id="school_name">
112
+ <a href="<%= base_url%>/colleges/{{d.school_id}}/statistics" class="layui-table-link" target="_blank">{{ d.school }}</a>
113
+ </script>
110
114
 
111
115
 
112
116
  <script>
@@ -123,7 +127,7 @@
123
127
  range: true
124
128
  });
125
129
 
126
- var is_show = <%=params[:name].present? || params[:clazz_id].present? %>
130
+ var is_show = <%=params[:name].present? || params[:clazz_id].present? || params[:place_id].present? || params[:school].present? %>
127
131
  if(is_show){
128
132
  $('.follows_li').removeClass('layui-this');
129
133
  $('.follows_div').removeClass('layui-show');
@@ -174,6 +178,7 @@
174
178
  })
175
179
  }
176
180
  })
181
+ index_place_list.setValue(gon.place)
177
182
 
178
183
 
179
184
  table = layui.table;
@@ -202,7 +207,7 @@
202
207
  field: 'school',
203
208
  width: 150,
204
209
  title: '单位',
205
- templet:'<div><span title="{{d.school}}">{{d.school}}</span></div>'
210
+ templet:'#school_name'
206
211
  },
207
212
  {
208
213
  field: 'department',
@@ -234,6 +239,22 @@
234
239
  width: 90,
235
240
  title: '阶段'
236
241
  },
242
+ {
243
+ field: 'source',
244
+ width: 90,
245
+ title: '商机来源'
246
+ },
247
+ {
248
+ field: 'last_follow_person',
249
+ width: 100,
250
+ title: '最新跟进人'
251
+ },
252
+ {
253
+ field: 'latest_time',
254
+ width: 200,
255
+ title: '最新跟进时间',
256
+ sort: true
257
+ },
237
258
  {
238
259
  field: 'invitation_at',
239
260
  width: 105,
@@ -284,21 +305,6 @@
284
305
  width: 160,
285
306
  title: '渠道',
286
307
  },
287
- {
288
- field: 'source',
289
- width: 90,
290
- title: '商机来源'
291
- },
292
- {
293
- field: 'last_follow_person',
294
- width: 100,
295
- title: '最新跟进人'
296
- },
297
- {
298
- field: 'latest_time',
299
- width: 200,
300
- title: '最新跟进时间'
301
- },
302
308
  {
303
309
  title: '操作',
304
310
  minWidth: 170,
@@ -389,6 +395,7 @@
389
395
  });
390
396
  }
391
397
  function time_line(id,name) {
398
+ business_id = id
392
399
  var content = miniPage.getHrefContent('/missions/businesses/time_line?business_id=' + id);
393
400
  var openWH = miniPage.getOpenWidthHeight();
394
401
  sindex = layer.open({
@@ -5,6 +5,7 @@ json.data do
5
5
  json.name d.name
6
6
  json.department d.department.name
7
7
  json.school d.department.school.name
8
+ json.school_id d.department.school.id
8
9
  json.follow_ups_count d.follow_ups_count
9
10
  follow_ups_count += d.follow_ups_count
10
11
  json.follow_up_id d.last_follow_up_id
@@ -10,6 +10,9 @@
10
10
  <label class="layui-form-label required">单位部门</label>
11
11
  <div class="layui-input-block" id="add_department" style="width: 300px;"></div>
12
12
  </div>
13
+ <div class="layui-inline" >
14
+ <a href="/missions/customers" style=" color: #0000FF">添加单位/部门</a>
15
+ </div>
13
16
  <br>
14
17
  <div class="layui-inline" style="padding-top: 20px">
15
18
  <label class="layui-form-label ">商机来源</label>
@@ -97,9 +97,9 @@
97
97
  </div>
98
98
  <div class="layui-form-item">
99
99
  <div class="layui-inline">
100
- <label class="layui-form-label">所属年度</label>
100
+ <label class="layui-form-label required">所属年度</label>
101
101
  <div class="layui-input-inline">
102
- <input type="text" class="layui-input" name="year" autocomplete="off" id="year"
102
+ <input type="text" class="layui-input" name="year" autocomplete="off" lay-verify="required" id="year"
103
103
  value="<%= @last_follow_up&.year%>"
104
104
  placeholder="请选择年度"> </div>
105
105
  </div>