educode_sales 0.9.69 → 0.9.71
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.
- checksums.yaml +4 -4
- data/app/controllers/educode_sales/businesses_controller.rb +16 -2
- data/app/controllers/educode_sales/customers_controller.rb +51 -14
- data/app/controllers/educode_sales/plans_controller.rb +69 -19
- data/app/controllers/educode_sales/projects_controller.rb +3 -0
- data/app/controllers/educode_sales/teachers_controller.rb +11 -1
- data/app/models/educode_sales/customer_follow.rb +1 -0
- data/app/models/educode_sales/eco_staff.rb +6 -0
- data/app/models/educode_sales/sale_plan.rb +2 -0
- data/app/views/educode_sales/businesses/index.html.erb +45 -12
- data/app/views/educode_sales/businesses/index.json.jbuilder +2 -1
- data/app/views/educode_sales/businesses/time_line.html.erb +2 -1
- data/app/views/educode_sales/customers/edit_major.html.erb +5 -1
- data/app/views/educode_sales/customers/list.html.erb +66 -23
- data/app/views/educode_sales/customers/list.json.jbuilder +22 -10
- data/app/views/educode_sales/customers/show_customer_follow.html.erb +175 -0
- data/app/views/educode_sales/customers/show_customer_follow.json.jbuilder +13 -0
- data/app/views/educode_sales/customers/show_majors.html.erb +146 -0
- data/app/views/educode_sales/plans/_yearPlan.html.erb +6 -3
- data/app/views/educode_sales/plans/business_infos.json.jbuilder +10 -4
- data/app/views/educode_sales/plans/edit_bussiness_info.html.erb +13 -8
- data/app/views/educode_sales/plans/edit_bussiness_info_extra.html.erb +16 -73
- data/app/views/educode_sales/plans/edit_year_plan.html.erb +64 -5
- data/app/views/educode_sales/plans/new_year.html.erb +51 -3
- data/app/views/educode_sales/plans/plan_business_infos.json.jbuilder +7 -0
- data/app/views/educode_sales/plans/years_plan.json.jbuilder +43 -3
- data/app/views/educode_sales/projects/detail.html.erb +10 -6
- data/app/views/educode_sales/projects/index.html.erb +38 -8
- data/app/views/educode_sales/teachers/_index.html.erb +26 -5
- data/app/views/educode_sales/teachers/edit.html.erb +10 -3
- data/app/views/educode_sales/teachers/index.json.jbuilder +8 -0
- data/config/routes.rb +3 -0
- data/db/migrate/20230414031409_add_major_educode_sales_customer_follows.rb +12 -0
- data/db/migrate/20230414035655_create_educode_sales_eco_staffs.rb +11 -0
- data/lib/educode_sales/version.rb +1 -1
- metadata +12 -8
- data/app/assets/images/educode_sales/indexlogo.png +0 -0
- data/db/migrate/20230411134203_add_realname_to_teacher.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f06396ccf8dbcf15c84aecaa042d4c444335c9ef3a09c82d5ccced165beb429a
|
4
|
+
data.tar.gz: 1bbace4be30f8d50b507d9174b40cfec77073ff74e79188443359bdf1f146281
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6034bfe4baf04919a142b18d57cdf9a8489fc9af2ec55597d36556a5ab69b6a9d1749d2c1271556a489f7d4907144e3c0b9db3769b7573cb967291fe3fb04b0b
|
7
|
+
data.tar.gz: 40edd2d1d9f49c081dad0251a573fadf67de0592755c54279d22518a80d2c3dea2777cb7d1daca05c7544f09a915078d79b3a63a9e94e4c2e025371f2a392e16
|
@@ -67,6 +67,7 @@ module EducodeSales
|
|
67
67
|
# gon.menus << { title: '添加团队建议', event: 'suggest' }
|
68
68
|
gon.menus << { title: '添加周计划', event: 'week' }
|
69
69
|
gon.menus << { title: '添加月计划', event: 'month' }
|
70
|
+
gon.menus << { title: '添加年计划', event: 'year' }
|
70
71
|
end
|
71
72
|
|
72
73
|
gon.menus << { title: '关注', event: 'following' }
|
@@ -177,8 +178,21 @@ module EducodeSales
|
|
177
178
|
@businesses = @businesses.where("educode_sales_businesses.name like ?", "%#{params[:q][:name]}%")
|
178
179
|
end
|
179
180
|
if params[:q].present? && params[:q][:department].present?
|
180
|
-
|
181
|
-
|
181
|
+
if params[:q][:department].include?("---")
|
182
|
+
# 从客户管理进来按部门显示商机
|
183
|
+
school_name, department = params[:q][:department].split("---")
|
184
|
+
if department
|
185
|
+
departments_ids = Department.joins(:school).where("schools.name = ? AND departments.name = ?", school_name, department).pluck(:id)
|
186
|
+
@businesses = @businesses.joins(:department).where("departments.id in (?)", departments_ids)
|
187
|
+
else
|
188
|
+
school = School.find_by(name: school_name)
|
189
|
+
@businesses = @businesses.where("educode_sales_businesses.school_id = ?", school&.id)
|
190
|
+
end
|
191
|
+
else
|
192
|
+
departments_ids = Department.joins(:school).where("schools.name like ?", "%#{params[:q][:department]}%").pluck(:id)
|
193
|
+
@businesses = @businesses.joins(:department).where("departments.id in (?)", departments_ids)
|
194
|
+
end
|
195
|
+
|
182
196
|
end
|
183
197
|
if params[:q].present? && params[:q][:staff_id].present?
|
184
198
|
part_a_ids = @businesses.where("educode_sales_businesses.last_follow_up_id is null AND educode_sales_businesses.staff_id = ?",params[:q][:staff_id]).ids
|
@@ -27,6 +27,11 @@ module EducodeSales
|
|
27
27
|
render layout: false
|
28
28
|
end
|
29
29
|
|
30
|
+
def show_majors
|
31
|
+
@department = Department.find(params[:id])
|
32
|
+
render layout: false
|
33
|
+
end
|
34
|
+
|
30
35
|
def update_department
|
31
36
|
department = Department.find(params[:id])
|
32
37
|
department.update(name: params[:department_name])
|
@@ -165,36 +170,41 @@ module EducodeSales
|
|
165
170
|
gon.school_tags = SchoolTag.where(for_missions: true).map { |d| {value: d.id, name: d.name } }
|
166
171
|
end
|
167
172
|
format.json do
|
173
|
+
@customers = School.from("(
|
174
|
+
SELECT schools.id, departments.id AS department_id, COUNT(department_majors.id) AS major_count
|
175
|
+
FROM schools
|
176
|
+
LEFT JOIN departments ON schools.id = departments.school_id
|
177
|
+
LEFT JOIN department_majors ON department_majors.department_id = departments.id
|
178
|
+
GROUP BY schools.id, departments.id
|
179
|
+
) AS s")
|
168
180
|
if @current_admin.is_admin?
|
169
|
-
@customers = School.all
|
181
|
+
# @customers = School.all
|
170
182
|
else
|
171
183
|
level = @current_admin.role.role_areas.find_by(clazz: '客户管理').level
|
172
184
|
case level
|
173
185
|
when '自己'
|
174
186
|
school_ids = CustomerExtension.where(customer_staff_id: @current_admin.id).pluck(:school_id)
|
175
|
-
@customers =
|
187
|
+
@customers = @customers.where(id: school_ids)
|
176
188
|
when '区域'
|
177
189
|
a_school_ids = School.where(province: @current_admin.areas.pluck(:name)).ids
|
178
190
|
b_school_ids = CustomerExtension.where(customer_staff_id: @current_admin.id).pluck(:school_id)
|
179
191
|
school_ids = a_school_ids + b_school_ids + StaffSchool.where(staff_id: @current_admin.id).pluck(:school_id)
|
180
|
-
@customers =
|
192
|
+
@customers = @customers.where(id: school_ids)
|
181
193
|
else
|
182
|
-
@customers = School.all
|
194
|
+
# @customers = School.all
|
183
195
|
end
|
184
196
|
end
|
185
197
|
|
186
198
|
@customers = @customers.select("
|
187
199
|
schools.*,
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
@customers = @customers.joins("
|
195
|
-
LEFT JOIN departments ON schools.id = departments.school_id
|
196
|
-
LEFT JOIN department_majors ON department_majors.department_id = departments.id
|
200
|
+
s.major_count,
|
201
|
+
s.department_id,
|
202
|
+
departments.name AS department_name
|
203
|
+
").joins("
|
204
|
+
JOIN schools ON s.id = schools.id
|
205
|
+
LEFT JOIN departments ON s.department_id = departments.id
|
197
206
|
")
|
207
|
+
|
198
208
|
part_a_ids = CustomerFollow.all.pluck(:school_id)
|
199
209
|
part_b_ids = Business.where(id: EducodeSales::FollowUp.pluck(:business_id)).pluck(:school_id)
|
200
210
|
ids = part_a_ids + part_b_ids + CustomerAdd.all.pluck(:school_id)
|
@@ -290,6 +300,28 @@ module EducodeSales
|
|
290
300
|
end
|
291
301
|
end
|
292
302
|
|
303
|
+
def show_customer_follow
|
304
|
+
respond_to do |format|
|
305
|
+
format.html do
|
306
|
+
@school_name = School.find(params[:id]).name
|
307
|
+
@area = School.find(params[:id]).province
|
308
|
+
@staff = EducodeSales::CustomerExtension.where(school_id: params[:id]).map { |d| d.customer_staff&.user&.real_name}.join("、")
|
309
|
+
render layout: false
|
310
|
+
end
|
311
|
+
format.json do
|
312
|
+
if params[:department_id].present?
|
313
|
+
@follow_ups = EducodeSales::CustomerFollow.where(department_id: params[:department_id])
|
314
|
+
else
|
315
|
+
@follow_ups = EducodeSales::CustomerFollow.where(school_id: params[:id])
|
316
|
+
end
|
317
|
+
|
318
|
+
@latest = @follow_ups.order(created_at: :desc).first
|
319
|
+
@follow_ups = @follow_ups.order("created_at desc")
|
320
|
+
@follow_ups = @follow_ups.page(params[:page]).per(params[:limit])
|
321
|
+
end
|
322
|
+
end
|
323
|
+
end
|
324
|
+
|
293
325
|
def show_department
|
294
326
|
@departments = School.find(params[:id]).departments
|
295
327
|
@departments = @departments.order("created_at desc")
|
@@ -392,8 +424,13 @@ module EducodeSales
|
|
392
424
|
def update
|
393
425
|
@school = School.find(params[:id])
|
394
426
|
if params[:department_id].present?
|
395
|
-
department = @school.departments.
|
427
|
+
department = @school.departments.find_by(id: params[:department_id])
|
428
|
+
if department
|
429
|
+
department.update(name: params[:department])
|
430
|
+
department.department_majors.find_by(id: params[:major_id])&.update(name: params[:major]) if params[:major_id].present?
|
431
|
+
end
|
396
432
|
end
|
433
|
+
|
397
434
|
|
398
435
|
ActiveRecord::Base.transaction do
|
399
436
|
property = SchoolProperty.find_or_create_by!(project_985: params[:project_985].present? ? 1 : 0,
|
@@ -82,7 +82,7 @@ module EducodeSales
|
|
82
82
|
|
83
83
|
def create_business_info
|
84
84
|
business = Business.find_by(id: params[:business_id])
|
85
|
-
info = @current_admin.business_infos.
|
85
|
+
info = @current_admin.business_infos.find_or_initialize_by(year: params[:year], business_id: business.id, clazz: params[:clazz])
|
86
86
|
if info.save
|
87
87
|
render_success
|
88
88
|
else
|
@@ -104,7 +104,7 @@ module EducodeSales
|
|
104
104
|
end
|
105
105
|
business_ids = EducodeSales::AssignFollowUp.joins(:follow_up).where(staff_id: @current_admin.id).pluck :business_id
|
106
106
|
@businesses = Business.includes(:department, :last_follow_up).where("educode_sales_businesses.id in (?) or educode_sales_businesses.staff_id = ?", business_ids, @current_admin.id).order(created_at: :desc)
|
107
|
-
@businesses = @businesses.map { |b| [b.name + "(
|
107
|
+
@businesses = @businesses.map { |b| [b.name + "(#{b.department&.school&.name} #{b.department&.name})" + "---" + "最新跟进:" + (b.last_follow_up.present? ? b.last_follow_up.created_at.to_s : b.created_at.to_s), b.id] }
|
108
108
|
render layout: false
|
109
109
|
end
|
110
110
|
|
@@ -132,18 +132,36 @@ module EducodeSales
|
|
132
132
|
@business = Business.find_by(id: params[:business_id])
|
133
133
|
business_ids = EducodeSales::AssignFollowUp.joins(:follow_up).where(staff_id: @current_admin.id).pluck :business_id
|
134
134
|
@businesses =Business.includes(:department, :last_follow_up).where("educode_sales_businesses.id in (?) or educode_sales_businesses.staff_id = ?", business_ids, @current_admin.id).order(created_at: :desc)
|
135
|
-
@businesses = @businesses.map { |b| [b.name + "(
|
135
|
+
@businesses = @businesses.map { |b| [b.name + "(#{b.department&.school&.name} #{b.department&.name})" + "---" + "最新跟进:" + (b.last_follow_up.present? ? b.last_follow_up.created_at.to_s : b.created_at.to_s), b.id] }
|
136
136
|
render layout: false
|
137
137
|
end
|
138
138
|
|
139
139
|
def new_year
|
140
|
+
@business = Business.find_by(id: params[:business_id])
|
140
141
|
business_ids = EducodeSales::AssignFollowUp.joins(:follow_up).where(staff_id: @current_admin.id).pluck :business_id
|
141
142
|
@businesses =Business.includes(:department, :last_follow_up).where("educode_sales_businesses.id in (?) or educode_sales_businesses.staff_id = ?", business_ids, @current_admin.id).order(created_at: :desc)
|
142
|
-
@businesses = @businesses.map { |b| [b.name + "(
|
143
|
+
@businesses = @businesses.map { |b| [ b.name + "(#{b.department&.school&.name} #{b.department&.name})" + "---" + "最新跟进:" + (b.last_follow_up.present? ? b.last_follow_up.created_at.to_s : b.created_at.to_s), b.id] }
|
143
144
|
@clazz = EducodeSales::SalePlan::CLAZZ_NAME
|
144
145
|
render layout: false
|
145
146
|
end
|
146
147
|
|
148
|
+
# 暂时不用
|
149
|
+
def staff_businesses
|
150
|
+
if params[:q].present?
|
151
|
+
business_ids = EducodeSales::AssignFollowUp.joins(:follow_up).where(staff_id: @current_admin.id).pluck :business_id
|
152
|
+
@businesses = Business.includes(:department, :last_follow_up).where("educode_sales_businesses.id in (?) or educode_sales_businesses.staff_id = ?", business_ids, @current_admin.id)
|
153
|
+
if params[:q].present?
|
154
|
+
@businesses = @businesses.where("educode_sales_businesses.name like ?", "%#{params[:q]}%")
|
155
|
+
else
|
156
|
+
@businesses = @businesses.limit(10)
|
157
|
+
end
|
158
|
+
@businesses = @businesses.order(created_at: :desc)
|
159
|
+
|
160
|
+
@businesses = @businesses.map { |b| {name: b.name + "(#{b.department&.school&.name} #{b.department&.name})" + "---" + "最新跟进:" + (b.last_follow_up.present? ? b.last_follow_up.created_at.to_s : b.created_at.to_s), value: b.id} }
|
161
|
+
render json: { data: @businesses, code: 0, msg: "success" }
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
147
165
|
def new_monthly
|
148
166
|
d = @current_admin
|
149
167
|
area_ids = EducodeSales::Common.where(clazz: 'area').ids.sort.to_s
|
@@ -232,6 +250,7 @@ module EducodeSales
|
|
232
250
|
EducodeSales::Recycle.create(source: d, deleter_id: @current_admin.id)
|
233
251
|
end
|
234
252
|
sale_plans.update_all(deleted_at: Time.now)
|
253
|
+
sale_plans.business_infos.delete_all
|
235
254
|
render_success
|
236
255
|
else
|
237
256
|
sale_plan = SalePlan.find(params[:id])
|
@@ -282,30 +301,46 @@ module EducodeSales
|
|
282
301
|
end
|
283
302
|
|
284
303
|
def years_plan
|
304
|
+
@sale_plans = SalePlan.from("(
|
305
|
+
SELECT SUM(last_follow.budget_amount) AS budget_amounts, educode_sales_sale_plans.*, ss.annual,
|
306
|
+
SUM(IF(educode_sales_sale_plans.clazz = 1 AND educode_sales_business_infos.plan_sign_on IS NOT NULL, last_follow.budget_amount, 0)) AS clazz_1,
|
307
|
+
SUM(IF(educode_sales_sale_plans.clazz = 18 and plan_bid_on IS NOT NULL, last_follow.budget_amount, 0)) AS clazz_18,
|
308
|
+
|
309
|
+
(SUM(IF(educode_sales_sale_plans.clazz = 2 AND prepayment_plan_on IS NOT NULL AND check_fee_plan_on IS NOT NULL AND qa_plan_on IS NOT NULL, prepayment_amount, 0)) +
|
310
|
+
SUM(IF(educode_sales_sale_plans.clazz = 2 AND prepayment_plan_on IS NOT NULL AND check_fee_plan_on IS NOT NULL AND qa_plan_on IS NOT NULL, check_fee, 0)) +
|
311
|
+
SUM(IF(educode_sales_sale_plans.clazz = 2 AND prepayment_plan_on IS NOT NULL AND check_fee_plan_on IS NOT NULL AND qa_plan_on IS NOT NULL, qa_amount, 0)) ) AS clazz_2,
|
312
|
+
SUM(IF(educode_sales_sale_plans.clazz = 7, last_follow.budget_amount, 0)) AS clazz_7,
|
313
|
+
|
314
|
+
SUM(IF(last_follow.bidded_date IS NOT NULL, last_follow.actual_amount, 0)) AS finish_bid,
|
315
|
+
SUM(IF(last_follow.signed_date IS NOT NULL, last_follow.actual_amount, 0)) AS finish_sign,
|
316
|
+
SUM(educode_sales_businesses.return_money) AS finish_return_money
|
317
|
+
|
318
|
+
FROM educode_sales_sale_plans
|
319
|
+
JOIN educode_sales_businesses ON educode_sales_businesses.id = educode_sales_sale_plans.business_id
|
320
|
+
LEFT JOIN educode_sales_business_infos ON educode_sales_business_infos.sale_plan_id = educode_sales_sale_plans.id
|
321
|
+
LEFT JOIN educode_sales_follow_ups AS last_follow ON educode_sales_businesses.last_follow_up_id = last_follow.id AND last_follow.deleted_at IS NULL
|
322
|
+
LEFT JOIN educode_sales_assessments_settings AS ss ON ss.staff_id = educode_sales_sale_plans.staff_id
|
323
|
+
AND YEAR(ss.assessment_year) = educode_sales_sale_plans.year AND ss.assessment = educode_sales_sale_plans.clazz
|
324
|
+
WHERE educode_sales_sale_plans.deleted_at IS NULL
|
325
|
+
GROUP BY educode_sales_sale_plans.staff_id, educode_sales_sale_plans.clazz, educode_sales_sale_plans.year
|
326
|
+
) AS educode_sales_sale_plans
|
327
|
+
")
|
285
328
|
if @current_admin.is_admin?
|
286
|
-
@sale_plans = SalePlan
|
329
|
+
# @sale_plans = SalePlan
|
287
330
|
else
|
288
331
|
level = @current_admin.role.role_areas.find_by(clazz: '销售计划').level
|
289
332
|
case level
|
290
333
|
when '自己'
|
291
|
-
@sale_plans =
|
334
|
+
@sale_plans = @sale_plans.where(staff_id: @current_admin.id)
|
292
335
|
when '区域'
|
293
336
|
staff_ids = Staff.joins(user: [user_extension: [department: :school]]).where("schools.province in (?)", @current_admin.areas.pluck(:name)).pluck(:id)
|
294
337
|
business_ids = Business.where(school_id: StaffSchool.where(staff_id: @current_admin.id).pluck(:school_id)).pluck(:id)
|
295
|
-
@sale_plans =
|
338
|
+
@sale_plans = @sale_plans.where("educode_sales_sale_plans.staff_id in (?) OR educode_sales_sale_plans.staff_id = ? OR educode_sales_sale_plans.business_id in (?)", staff_ids, @current_admin.id,business_ids)
|
296
339
|
else
|
297
|
-
@sale_plans = SalePlan
|
340
|
+
# @sale_plans = SalePlan
|
298
341
|
end
|
299
342
|
end
|
300
343
|
@sale_plans = @sale_plans.where.not(year: nil)
|
301
|
-
@sale_plans = @sale_plans.select("SUM(last_follow.budget_amount) AS budget_amounts, educode_sales_sale_plans.*, ss.annual")
|
302
|
-
@sale_plans = @sale_plans.joins("
|
303
|
-
JOIN educode_sales_businesses ON educode_sales_businesses.id = educode_sales_sale_plans.business_id
|
304
|
-
LEFT JOIN educode_sales_follow_ups AS last_follow ON educode_sales_businesses.last_follow_up_id = last_follow.id AND last_follow.deleted_at IS NULL
|
305
|
-
LEFT JOIN educode_sales_assessments_settings AS ss ON ss.staff_id = educode_sales_sale_plans.staff_id
|
306
|
-
AND YEAR(ss.assessment_year) = educode_sales_sale_plans.year AND ss.assessment = educode_sales_sale_plans.clazz")
|
307
|
-
|
308
|
-
@sale_plans = @sale_plans.group("educode_sales_sale_plans.staff_id, clazz, year")
|
309
344
|
|
310
345
|
@sale_plans = @sale_plans.where(deleted_at: nil)
|
311
346
|
|
@@ -345,12 +380,26 @@ module EducodeSales
|
|
345
380
|
end
|
346
381
|
|
347
382
|
def edit_bussiness_info_extra
|
348
|
-
@business_info =
|
383
|
+
@business_info = EducodeSales::BusinessInfo.find(params[:id])
|
349
384
|
render layout: false
|
350
385
|
end
|
351
386
|
|
352
387
|
def plan_business_infos
|
353
|
-
|
388
|
+
if params[:q] && params[:q][:year_search].present?
|
389
|
+
@data = EducodeSales::BusinessInfo.where(year: params[:q][:year_search], staff_id: params[:staff_id])
|
390
|
+
else
|
391
|
+
@data = EducodeSales::BusinessInfo.where(year: params[:year], staff_id: params[:staff_id])
|
392
|
+
end
|
393
|
+
|
394
|
+
@data = @data.where.not(sale_plan_id: nil)
|
395
|
+
|
396
|
+
if params[:q] && params[:q][:clazz].present?
|
397
|
+
@data = @data.where(clazz: params[:q][:clazz])
|
398
|
+
end
|
399
|
+
|
400
|
+
if params[:q] && params[:q][:department].present?
|
401
|
+
@data = @data.joins(business: [department: :school]).where("schools.name like ?", "%#{params[:q][:department]}%")
|
402
|
+
end
|
354
403
|
|
355
404
|
if params[:sort].present? && params[:sort][:field]
|
356
405
|
@data = @data.order("#{params[:sort][:field]} #{params[:sort][:order]}")
|
@@ -370,7 +419,7 @@ module EducodeSales
|
|
370
419
|
end
|
371
420
|
|
372
421
|
def update_business_info_extra
|
373
|
-
business_info =
|
422
|
+
business_info = EducodeSales::BusinessInfo.find(params[:id])
|
374
423
|
if business_info.update(update_business_info_extra_params)
|
375
424
|
render_success
|
376
425
|
else
|
@@ -392,6 +441,7 @@ module EducodeSales
|
|
392
441
|
end
|
393
442
|
|
394
443
|
def edit_year_plan
|
444
|
+
@clazz = EducodeSales::SalePlan::CLAZZ_NAME
|
395
445
|
render layout: false
|
396
446
|
end
|
397
447
|
|
@@ -143,6 +143,9 @@ module EducodeSales
|
|
143
143
|
if params[:q].present? && params[:q][:p_staff_id].present?
|
144
144
|
@businesses = @businesses.where(p_staff_id: params[:q][:p_staff_id])
|
145
145
|
end
|
146
|
+
if params[:q].present? && params[:q][:p_sale_staff_id].present?
|
147
|
+
@businesses = @businesses.where(p_sale_staff_id: params[:q][:p_sale_staff_id])
|
148
|
+
end
|
146
149
|
if params[:q].present? && params[:q][:p_special].present?
|
147
150
|
@businesses = @businesses.where(p_special: "#{params[:q][:p_special]}")
|
148
151
|
end
|
@@ -28,6 +28,7 @@ module EducodeSales
|
|
28
28
|
else
|
29
29
|
@staff_manage = Staff.none
|
30
30
|
end
|
31
|
+
|
31
32
|
@follow_upers = Staff.includes(:user).map { |d| [d.user.real_name, d.id]}
|
32
33
|
@staffs = Staff.includes(:user).where(job_type: common.id).map { |d| [d.user.real_name, d.id]}
|
33
34
|
@more = can?(:create, EducodeSales::OperationPlan) || can?(:update, EducodeSales::Teacher) || can?(:destroy, EducodeSales::Teacher)
|
@@ -45,10 +46,16 @@ module EducodeSales
|
|
45
46
|
end
|
46
47
|
format.json do
|
47
48
|
@staff_manages = {}
|
49
|
+
@sales_manages = {}
|
48
50
|
role = EducodeSales::Role.find_by(name: '生态经理')
|
49
51
|
EducodeSales::Common.joins(market_areas: :staff).includes(market_areas: :staff).where(clazz: '区域').where("educode_sales_staffs.role_id = #{role.id}").each do |d|
|
50
52
|
@staff_manages[d.name] = d.market_areas.map { |d| d.staff&.user&.real_name }.uniq.compact
|
51
53
|
end if role
|
54
|
+
|
55
|
+
sales_common = EducodeSales::Common.find_by(clazz: 'staff_type', name: '销售')
|
56
|
+
EducodeSales::Common.joins(market_areas: :staff).includes(market_areas: :staff).where(clazz: '区域').where("educode_sales_staffs.job_type = ?", sales_common.id).each do |d|
|
57
|
+
@sales_manages[d.name] = d.market_areas.map { |d| d.staff&.user&.real_name }.uniq.compact
|
58
|
+
end
|
52
59
|
|
53
60
|
if @current_admin.is_admin?
|
54
61
|
@teachers = Teacher
|
@@ -85,6 +92,9 @@ module EducodeSales
|
|
85
92
|
if params[:q].present? && params[:q][:name].present?
|
86
93
|
@teachers = @teachers.where("educode_sales_teachers.name like ?", "%#{params[:q][:name]}%")
|
87
94
|
end
|
95
|
+
if params[:q].present? && params[:q][:realname].present?
|
96
|
+
@teachers = @teachers.where("educode_sales_teachers.realname like ?", "%#{params[:q][:realname]}%")
|
97
|
+
end
|
88
98
|
if params[:q].present? && params[:q][:professional_title].present?
|
89
99
|
@teachers = @teachers.where("educode_sales_teachers.professional_title = ?", "#{params[:q][:professional_title]}")
|
90
100
|
end
|
@@ -393,7 +403,7 @@ module EducodeSales
|
|
393
403
|
|
394
404
|
private
|
395
405
|
def teacher_params
|
396
|
-
params.permit(:name, :professional_title, :job, :source_id, :wechat, :mobile)
|
406
|
+
params.permit(:name, :professional_title, :job, :source_id, :wechat, :mobile, :realname)
|
397
407
|
end
|
398
408
|
|
399
409
|
def load_teacher
|
@@ -390,12 +390,6 @@
|
|
390
390
|
fixed: 'left',
|
391
391
|
hide: gon.filter.name
|
392
392
|
},
|
393
|
-
{
|
394
|
-
field: 'area',
|
395
|
-
width: 100,
|
396
|
-
title: '地域',
|
397
|
-
hide: gon.filter.area
|
398
|
-
},
|
399
393
|
{
|
400
394
|
field: 'school',
|
401
395
|
width: 150,
|
@@ -403,12 +397,6 @@
|
|
403
397
|
templet: '#school_name',
|
404
398
|
hide: gon.filter.school
|
405
399
|
},
|
406
|
-
{
|
407
|
-
field: 'property',
|
408
|
-
width: 150,
|
409
|
-
title: '客户类型',
|
410
|
-
hide: gon.filter.property
|
411
|
-
},
|
412
400
|
{
|
413
401
|
field: 'department',
|
414
402
|
width: 150,
|
@@ -421,6 +409,18 @@
|
|
421
409
|
width: 160,
|
422
410
|
title: '专业',
|
423
411
|
},
|
412
|
+
{
|
413
|
+
field: 'area',
|
414
|
+
width: 100,
|
415
|
+
title: '地域',
|
416
|
+
hide: gon.filter.area
|
417
|
+
},
|
418
|
+
{
|
419
|
+
field: 'property',
|
420
|
+
width: 150,
|
421
|
+
title: '客户类型',
|
422
|
+
hide: gon.filter.property
|
423
|
+
},
|
424
424
|
{
|
425
425
|
field: 'follow_ups_count',
|
426
426
|
title: '跟进',
|
@@ -528,6 +528,14 @@
|
|
528
528
|
sort: true,
|
529
529
|
hide: gon.filter.o_business_deployment
|
530
530
|
},
|
531
|
+
{
|
532
|
+
field: 'p_deploy_time',
|
533
|
+
width: 150,
|
534
|
+
title: '部署时间',
|
535
|
+
sort: true,
|
536
|
+
hide: gon.filter.p_deploy_time
|
537
|
+
},
|
538
|
+
|
531
539
|
{
|
532
540
|
field: 'budget_amount',
|
533
541
|
width: 105,
|
@@ -697,6 +705,9 @@
|
|
697
705
|
case 'month':
|
698
706
|
month(id);
|
699
707
|
break;
|
708
|
+
case 'year':
|
709
|
+
year(id);
|
710
|
+
break;
|
700
711
|
case 'edit':
|
701
712
|
edit(id);
|
702
713
|
break;
|
@@ -729,6 +740,9 @@
|
|
729
740
|
case 'month':
|
730
741
|
month(id);
|
731
742
|
break;
|
743
|
+
case 'year':
|
744
|
+
year(id);
|
745
|
+
break;
|
732
746
|
case 'edit':
|
733
747
|
edit(id);
|
734
748
|
break;
|
@@ -853,6 +867,25 @@
|
|
853
867
|
layer.full(sindex);
|
854
868
|
});
|
855
869
|
}
|
870
|
+
|
871
|
+
function year(id) {
|
872
|
+
var content = miniPage.getHrefContent('/missions/plans/new_year?business_id=' + id);
|
873
|
+
var openWH = miniPage.getOpenWidthHeight();
|
874
|
+
|
875
|
+
yindex = layer.open({
|
876
|
+
title: '添加年计划',
|
877
|
+
type: 1,
|
878
|
+
shade: 0.2,
|
879
|
+
maxmin: true,
|
880
|
+
shadeClose: true,
|
881
|
+
area: [openWH[0] + 'px', openWH[1] + 'px'],
|
882
|
+
offset: [openWH[2] + 'px', openWH[3] + 'px'],
|
883
|
+
content: content
|
884
|
+
});
|
885
|
+
$(window).on("resize", function () {
|
886
|
+
layer.full(sindex);
|
887
|
+
});
|
888
|
+
}
|
856
889
|
function following(id) {
|
857
890
|
$.ajax({
|
858
891
|
type: "get",
|
@@ -67,7 +67,8 @@ json.data do
|
|
67
67
|
json.latest_time d.last_follow_up.present? ? d.last_follow_up.created_at.to_s : ''
|
68
68
|
json.self_flag (d.staff_id == @current_admin.id) || (d.last_follow_up_id.in? follow_up_ids)
|
69
69
|
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
|
70
|
-
|
70
|
+
json.p_deploy_time d.p_deploy_time
|
71
|
+
end
|
71
72
|
end
|
72
73
|
|
73
74
|
json.totalRow do
|
@@ -8,14 +8,17 @@
|
|
8
8
|
</div>
|
9
9
|
</div>
|
10
10
|
<br>
|
11
|
+
<% if @department.present? %>
|
11
12
|
<div class="layui-inline">
|
12
13
|
<label class="layui-form-label">部门:</label>
|
13
14
|
<div class="layui-input-block" style="width: 500px;">
|
14
15
|
<input type="text" name="department" value="<%= @department&.name %>" placeholder="请输入部门" autocomplete="off" class="layui-input">
|
15
|
-
<%= hidden_field_tag "department_id",
|
16
|
+
<%= hidden_field_tag "department_id", @department.id %>
|
16
17
|
</div>
|
17
18
|
</div>
|
18
19
|
<br>
|
20
|
+
<% end %>
|
21
|
+
<% if @major.present? %>
|
19
22
|
<div class="layui-inline">
|
20
23
|
<label class="layui-form-label">专业:</label>
|
21
24
|
<div class="layui-input-block" style="width: 500px;">
|
@@ -24,6 +27,7 @@
|
|
24
27
|
</div>
|
25
28
|
</div>
|
26
29
|
<br>
|
30
|
+
<% end %>
|
27
31
|
<div class="layui-inline city_input">
|
28
32
|
<label class="layui-form-label ">省:</label>
|
29
33
|
<div class="layui-input-block" style="width: 500px;">
|