educode_sales 0.6.8 → 0.6.9
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 +181 -3
- data/app/controllers/educode_sales/customers_controller.rb +47 -14
- data/app/controllers/educode_sales/home_controller.rb +6 -0
- data/app/controllers/educode_sales/sale_trends_controller.rb +4 -2
- data/app/controllers/educode_sales/staffs_controller.rb +10 -0
- data/app/models/educode_sales/customer_add.rb +4 -0
- data/app/models/educode_sales/staff.rb +1 -0
- data/app/models/educode_sales/staff_school.rb +6 -0
- data/app/views/educode_sales/businesses/get_export_data.json.jbuilder +30 -0
- data/app/views/educode_sales/businesses/index.html.erb +74 -7
- data/app/views/educode_sales/businesses/index.json.jbuilder +1 -29
- data/app/views/educode_sales/customers/index.html.erb +30 -1
- data/app/views/educode_sales/customers/index.json.jbuilder +12 -0
- data/app/views/educode_sales/customers/new.html.erb +106 -53
- data/app/views/educode_sales/home/staff_schools.json.jbuilder +9 -0
- data/app/views/educode_sales/roles/edit.html.erb +10 -4
- data/app/views/educode_sales/sale_trends/trends.html.erb +1 -1
- data/app/views/educode_sales/sales/index.json.jbuilder +1 -1
- data/app/views/educode_sales/staffs/edit.html.erb +45 -0
- data/config/routes.rb +2 -0
- data/db/migrate/20220125013811_create_educode_sales_staff_schools.rb +10 -0
- data/db/migrate/20220125033552_create_educode_sales_customer_adds.rb +9 -0
- data/lib/educode_sales/version.rb +1 -1
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: adf1decc8062d60eb1c994f86443c226fbfe87df6f26979d1aaabc383afcc7e4
|
4
|
+
data.tar.gz: 5caca5f6b198d0da54fbff9130afec3a89ad783419d8963c092c88410e86648e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a889734085111c320d172c56d375336c1837e3eb6e978870992e35729078cb4faf16f79afc4ec7215757fb6a20a70e231d5b946625a8bb801e2e28d6719dc5b0
|
7
|
+
data.tar.gz: 0bac8b724cd76f787fa9b16105d705621afbaa62b8a928b8e7bd20433bce4404f04428d6c3f172d04a9ecb8768d52307647145b85ac9c5778ed7602520d2c7b4
|
@@ -200,7 +200,7 @@ module EducodeSales
|
|
200
200
|
|
201
201
|
@business_count = @businesses.count
|
202
202
|
|
203
|
-
@
|
203
|
+
@businesses = @businesses.select("
|
204
204
|
educode_sales_businesses.*,
|
205
205
|
last_follow.invitation_at,
|
206
206
|
last_follow.reception_at,
|
@@ -211,9 +211,8 @@ module EducodeSales
|
|
211
211
|
(last_follow.actual_amount - educode_sales_businesses.return_money) as wait_return_money,
|
212
212
|
last_follow.total_amount").joins("
|
213
213
|
LEFT JOIN educode_sales_follow_ups AS last_follow ON educode_sales_businesses.last_follow_up_id = last_follow.id
|
214
|
-
")
|
214
|
+
").page(params[:page]).per(params[:limit])
|
215
215
|
|
216
|
-
@businesses = @businesses_exports.page(params[:page]).per(params[:limit])
|
217
216
|
end
|
218
217
|
end
|
219
218
|
end
|
@@ -388,6 +387,185 @@ module EducodeSales
|
|
388
387
|
end
|
389
388
|
end
|
390
389
|
|
390
|
+
def get_export_data
|
391
|
+
respond_to do |format|
|
392
|
+
format.html do
|
393
|
+
end
|
394
|
+
format.json do
|
395
|
+
if @current_admin.is_admin?
|
396
|
+
@businesses = Business
|
397
|
+
else
|
398
|
+
level = @current_admin.role.role_areas.find_by(clazz: '商机管理').level
|
399
|
+
case level
|
400
|
+
when '自己'
|
401
|
+
business_ids = Business.joins(last_follow_up: :assign_follow_ups).where("educode_sales_assign_follow_ups.staff_id = ?", @current_admin.id).pluck(:id)
|
402
|
+
@businesses = Business.where("educode_sales_businesses.staff_id = ? OR educode_sales_businesses.id in (?)", @current_admin.id, business_ids)
|
403
|
+
when '区域'
|
404
|
+
school_ids = School.where(province: @current_admin.areas.pluck(:name)).pluck(:id)
|
405
|
+
business_ids = Business.joins(last_follow_up: :assign_follow_ups).where("educode_sales_assign_follow_ups.staff_id = ?", @current_admin.id).pluck(:id)
|
406
|
+
@businesses = Business.joins("JOIN departments ON educode_sales_businesses.department_id = departments.id").where("departments.school_id in (?) OR educode_sales_businesses.staff_id = #{@current_admin.id} OR educode_sales_businesses.id in (?)", school_ids, business_ids)
|
407
|
+
else
|
408
|
+
@businesses = Business
|
409
|
+
end
|
410
|
+
end
|
411
|
+
|
412
|
+
if params[:name].present?
|
413
|
+
@year = params[:name].split("-")[1].present? ? params[:name].split("-")[1] : ''
|
414
|
+
end
|
415
|
+
|
416
|
+
if params[:name].present? && params[:name] == "(销售态势-" + @year + "-现有商机)"
|
417
|
+
ids = Common.where(extras: %w[a_class b_class c_class d_class e_class o_class]).pluck(:id)
|
418
|
+
if @year == '全部'
|
419
|
+
@businesses = @businesses.joins("
|
420
|
+
JOIN educode_sales_follow_ups ON educode_sales_businesses.last_follow_up_id = educode_sales_follow_ups.id
|
421
|
+
").where("educode_sales_follow_ups.clazz_id in (?)",ids)
|
422
|
+
else
|
423
|
+
@businesses = @businesses.joins("
|
424
|
+
JOIN educode_sales_follow_ups ON educode_sales_businesses.last_follow_up_id = educode_sales_follow_ups.id
|
425
|
+
").where("educode_sales_follow_ups.clazz_id in (?)",ids).where("educode_sales_follow_ups.year = ?",@year)
|
426
|
+
end
|
427
|
+
|
428
|
+
end
|
429
|
+
|
430
|
+
if params[:name].present? && params[:name] == "(销售态势-" + @year + "-已中标商机)"
|
431
|
+
stage_ids = Common.where(clazz: '商机阶段', name: ['已中标','已签单','已验收','回款中', '服务中','已结束']).pluck(:id)
|
432
|
+
if @year == '全部'
|
433
|
+
@businesses = @businesses.joins("
|
434
|
+
JOIN educode_sales_follow_ups ON educode_sales_businesses.last_follow_up_id = educode_sales_follow_ups.id
|
435
|
+
").where("educode_sales_follow_ups.stage_id IN (?)",stage_ids)
|
436
|
+
else
|
437
|
+
@businesses = @businesses.joins("
|
438
|
+
JOIN educode_sales_follow_ups ON educode_sales_businesses.last_follow_up_id = educode_sales_follow_ups.id
|
439
|
+
").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)
|
440
|
+
end
|
441
|
+
|
442
|
+
end
|
443
|
+
|
444
|
+
if params[:name].present? && params[:name] == "(销售态势-" + @year + "-已签单商机)"
|
445
|
+
s_stage_ids = Common.where(clazz: '商机阶段', name: ['已签单','已验收','回款中', '服务中','已结束']).pluck(:id)
|
446
|
+
if @year == '全部'
|
447
|
+
@businesses = @businesses.joins("
|
448
|
+
JOIN educode_sales_follow_ups ON educode_sales_businesses.last_follow_up_id = educode_sales_follow_ups.id
|
449
|
+
").where("educode_sales_follow_ups.stage_id IN (?)",s_stage_ids)
|
450
|
+
else
|
451
|
+
@businesses = @businesses.joins("
|
452
|
+
JOIN educode_sales_follow_ups ON educode_sales_businesses.last_follow_up_id = educode_sales_follow_ups.id
|
453
|
+
").where("educode_sales_follow_ups.signed_date > ? AND educode_sales_follow_ups.signed_date < ? AND educode_sales_follow_ups.stage_id IN (?)", "#{@year}-01-01", "#{@year}-12-31", s_stage_ids)
|
454
|
+
end
|
455
|
+
end
|
456
|
+
|
457
|
+
if params[:name].present? && params[:name] == "(销售态势-" + @year + "-已回款商机)"
|
458
|
+
x_id = Common.find_by(extras: EducodeSales::Common::XTYPE)&.id
|
459
|
+
year_time = "#{@year}-01-01 00:00:00"
|
460
|
+
year_over_time = "#{@year}-12-31 23:59:59"
|
461
|
+
if @year == '全部'
|
462
|
+
@businesses = @businesses.joins(follow_ups: :money_plans).where("educode_sales_follow_ups.clazz_id != ?", x_id).where.not("educode_sales_money_plans.clazz!= ?", 1).distinct
|
463
|
+
else
|
464
|
+
@businesses = @businesses.joins(follow_ups: :money_plans).where("educode_sales_follow_ups.clazz_id != ?", x_id).where.not("educode_sales_money_plans.clazz!= ?", 1).where("educode_sales_money_plans.date_at >= ? AND educode_sales_money_plans.date_at <= ? ", year_time, year_over_time).distinct
|
465
|
+
end
|
466
|
+
end
|
467
|
+
|
468
|
+
if params[:all].present?
|
469
|
+
@businesses = @businesses
|
470
|
+
end
|
471
|
+
|
472
|
+
if params[:mine].present?
|
473
|
+
ids = AssignFollowUp.where(staff_id: @current_admin.id).pluck(:follow_up_id)
|
474
|
+
ids1 = FollowUp.where(id: ids).pluck(:business_id)
|
475
|
+
@businesses =@businesses.where("educode_sales_businesses.id in (?) or educode_sales_businesses.staff_id = ?", ids1, @current_admin.id)
|
476
|
+
end
|
477
|
+
|
478
|
+
@businesses = @businesses
|
479
|
+
if params[:name].present? && params[:name] != "(销售态势-" + @year + "-已中标商机)" && params[:name] != "(销售态势-" + @year + "-已签单商机)" && params[:name] != "(销售态势-" + @year + "-已回款商机)" && params[:name] != "(销售态势-" + @year + "-现有商机)"
|
480
|
+
@businesses = @businesses.where("educode_sales_businesses.name like ?", "%#{params[:name]}%")
|
481
|
+
end
|
482
|
+
if params[:department].present?
|
483
|
+
departments_ids = Department.joins(:school).where("schools.name like ?", "%#{params[:department]}%").pluck(:id)
|
484
|
+
@businesses = @businesses.joins(:department).where("departments.id in (?)", departments_ids)
|
485
|
+
end
|
486
|
+
if params[:staff_id].present?
|
487
|
+
part_a_ids = @businesses.where("educode_sales_businesses.last_follow_up_id is null AND educode_sales_businesses.staff_id = ?",params[:staff_id]).ids
|
488
|
+
part_b_ids = @businesses.where("educode_sales_businesses.last_follow_up_id is not null").joins("
|
489
|
+
JOIN educode_sales_follow_ups ON educode_sales_businesses.last_follow_up_id = educode_sales_follow_ups.id
|
490
|
+
").where("educode_sales_follow_ups.staff_id = ?", params[:staff_id]).ids
|
491
|
+
business_ids = part_a_ids + part_b_ids
|
492
|
+
@businesses = EducodeSales::Business.where(id:business_ids)
|
493
|
+
end
|
494
|
+
if params[:business_type].present?
|
495
|
+
@businesses = @businesses.joins("
|
496
|
+
JOIN educode_sales_follow_ups ON educode_sales_businesses.last_follow_up_id = educode_sales_follow_ups.id
|
497
|
+
").where("educode_sales_follow_ups.clazz_id in (?)", params[:business_type].split(",").map(&:to_i))
|
498
|
+
end
|
499
|
+
if params[:business_step].present?
|
500
|
+
@businesses = @businesses.joins("
|
501
|
+
JOIN educode_sales_follow_ups ON educode_sales_businesses.last_follow_up_id = educode_sales_follow_ups.id
|
502
|
+
").where("educode_sales_follow_ups.stage_id in (?)", params[:business_step].split(",").map(&:to_i))
|
503
|
+
end
|
504
|
+
if params[:place_id].present?
|
505
|
+
@businesses = @businesses.joins("
|
506
|
+
JOIN educode_sales_follow_ups ON educode_sales_businesses.last_follow_up_id = educode_sales_follow_ups.id
|
507
|
+
").where("educode_sales_follow_ups.place_id = ?", params[:place_id])
|
508
|
+
end
|
509
|
+
|
510
|
+
if params[:area].present?
|
511
|
+
p = EducodeSales::Common.find(params[:area]).name
|
512
|
+
if @current_admin.is_admin?
|
513
|
+
@businesses = @businesses.joins("
|
514
|
+
JOIN departments ON educode_sales_businesses.department_id = departments.id
|
515
|
+
JOIN schools ON departments.school_id = schools.id
|
516
|
+
").where("province = ?", p)
|
517
|
+
else
|
518
|
+
level = @current_admin.role.role_areas.find_by(clazz: '商机管理').level
|
519
|
+
if level == "区域"
|
520
|
+
@businesses = @businesses.joins("
|
521
|
+
JOIN schools ON departments.school_id = schools.id
|
522
|
+
").where("province = ?", p)
|
523
|
+
else
|
524
|
+
@businesses = @businesses.joins("
|
525
|
+
JOIN departments ON educode_sales_businesses.department_id = departments.id
|
526
|
+
JOIN schools ON departments.school_id = schools.id
|
527
|
+
").where("province = ?", p)
|
528
|
+
end
|
529
|
+
end
|
530
|
+
end
|
531
|
+
|
532
|
+
if params[:date].present?
|
533
|
+
date = params[:date].split(" - ")
|
534
|
+
@businesses = @businesses.where("educode_sales_businesses.created_at > ? AND educode_sales_businesses.created_at < ?", date[0], date[1] + '23:59:59')
|
535
|
+
end
|
536
|
+
|
537
|
+
if params[:invitation_at].present?
|
538
|
+
date = params[:invitation_at].split(" - ")
|
539
|
+
@businesses = @businesses.joins("
|
540
|
+
JOIN educode_sales_follow_ups ON educode_sales_businesses.last_follow_up_id = educode_sales_follow_ups.id
|
541
|
+
").where("educode_sales_follow_ups.invitation_at > ? AND educode_sales_follow_ups.invitation_at < ?", date[0] + '00:00:00', date[1] + '23:59:59')
|
542
|
+
end
|
543
|
+
|
544
|
+
if params[:sort].present? && params[:sort][:field]
|
545
|
+
@businesses = @businesses.order("#{params[:sort][:field]} #{params[:sort][:order]}")
|
546
|
+
else
|
547
|
+
@businesses = @businesses.order("educode_sales_businesses.created_at desc")
|
548
|
+
end
|
549
|
+
|
550
|
+
@business_count = @businesses.count
|
551
|
+
|
552
|
+
@businesses = @businesses.select("
|
553
|
+
educode_sales_businesses.*,
|
554
|
+
last_follow.invitation_at,
|
555
|
+
last_follow.reception_at,
|
556
|
+
last_follow.bidded_date,
|
557
|
+
last_follow.signed_date,
|
558
|
+
last_follow.created_at as latest_time,
|
559
|
+
last_follow.actual_amount,
|
560
|
+
(last_follow.actual_amount - educode_sales_businesses.return_money) as wait_return_money,
|
561
|
+
last_follow.total_amount").joins("
|
562
|
+
LEFT JOIN educode_sales_follow_ups AS last_follow ON educode_sales_businesses.last_follow_up_id = last_follow.id
|
563
|
+
")
|
564
|
+
|
565
|
+
end
|
566
|
+
end
|
567
|
+
end
|
568
|
+
|
391
569
|
private
|
392
570
|
|
393
571
|
def load_business
|
@@ -57,7 +57,10 @@ module EducodeSales
|
|
57
57
|
@customers = School.all
|
58
58
|
end
|
59
59
|
end
|
60
|
-
|
60
|
+
part_a_ids = CustomerFollow.all.pluck(:school_id)
|
61
|
+
part_b_ids = Business.where(id: EducodeSales::FollowUp.pluck(:business_id)).pluck(:school_id)
|
62
|
+
ids = part_a_ids + part_b_ids + CustomerAdd.all.pluck(:school_id)
|
63
|
+
@customers = @customers.where(id: ids)
|
61
64
|
if params[:q].present? && params[:q][:name].present?
|
62
65
|
@customers = @customers.where("schools.name like ?", "%#{params[:q][:name]}%")
|
63
66
|
end
|
@@ -68,6 +71,30 @@ module EducodeSales
|
|
68
71
|
school_ids = EducodeSales::CustomerExtension.where(customer_staff_id: params[:q][:staff_id]).pluck(:school_id)
|
69
72
|
@customers = @customers.where(id: school_ids)
|
70
73
|
end
|
74
|
+
if params[:q].present? && params[:q][:property].present?
|
75
|
+
school_property_ids = []
|
76
|
+
property = params[:q][:property].split(",").map(&:to_i)
|
77
|
+
property.each do |p|
|
78
|
+
case p
|
79
|
+
when 0
|
80
|
+
school_property_ids += SchoolProperty.where( project_985: true ).ids
|
81
|
+
when 1
|
82
|
+
school_property_ids += SchoolProperty.where( project_211: true ).ids
|
83
|
+
when 2
|
84
|
+
school_property_ids += SchoolProperty.where( regular_college: true ).ids
|
85
|
+
when 3
|
86
|
+
school_property_ids += SchoolProperty.where( junior_college: true ).ids
|
87
|
+
when 4
|
88
|
+
school_property_ids += SchoolProperty.where( secondary_school: true ).ids
|
89
|
+
when 5
|
90
|
+
school_property_ids += SchoolProperty.where( military_school: true ).ids
|
91
|
+
when 6
|
92
|
+
school_property_ids += SchoolProperty.where( enterprise: true ).ids
|
93
|
+
else
|
94
|
+
end
|
95
|
+
end
|
96
|
+
@customers = @customers.where(school_property_id: school_property_ids)
|
97
|
+
end
|
71
98
|
|
72
99
|
if params[:q].present? && params[:q][:date].present?
|
73
100
|
ids = EducodeSales::CustomerFollow.all.pluck(:school_id)
|
@@ -149,20 +176,26 @@ module EducodeSales
|
|
149
176
|
render layout: false
|
150
177
|
end
|
151
178
|
|
179
|
+
# def create
|
180
|
+
# ActiveRecord::Base.transaction do
|
181
|
+
# property = SchoolProperty.find_or_create_by!(project_985: params[:project_985].present? ? 1 : 0,
|
182
|
+
# project_211: params[:project_211].present? ? 1 : 0,
|
183
|
+
# regular_college: params[:regular_college].present? ? 1 : 0,
|
184
|
+
# junior_college: params[:junior_college].present? ? 1 : 0,
|
185
|
+
# secondary_school: params[:secondary_school].present? ? 1 : 0,
|
186
|
+
# military_school: params[:military_school].present? ? 1 : 0,
|
187
|
+
# enterprise: params[:enterprise].present? ? 1 : 0)
|
188
|
+
# @school = School.new
|
189
|
+
# @school.attributes = school_params
|
190
|
+
# @school.school_property = property
|
191
|
+
# @school.save!
|
192
|
+
# EducodeSales::CustomerExtension.create(customer_staff_id: @current_admin.id, school_id: @school.id)
|
193
|
+
# end
|
194
|
+
# render_success
|
195
|
+
# end
|
152
196
|
def create
|
153
|
-
|
154
|
-
|
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
|
-
EducodeSales::CustomerExtension.create(customer_staff_id: @current_admin.id, school_id: @school.id)
|
197
|
+
params[:school_ids].each do |d|
|
198
|
+
CustomerAdd.create(school_id: d)
|
166
199
|
end
|
167
200
|
render_success
|
168
201
|
end
|
@@ -57,6 +57,12 @@ module EducodeSales
|
|
57
57
|
@staffs = @staffs.where(is_admin: false).where.not(id: @current_admin.id).where(job_type: common.id).page(params[:page]).per(10)
|
58
58
|
end
|
59
59
|
end
|
60
|
+
def staff_schools
|
61
|
+
@schools = School.all
|
62
|
+
if params[:q].present?
|
63
|
+
@schools = @schools.where("name like :q OR province like :q",q: "%#{params[:q]}%").page(params[:page]).per(10)
|
64
|
+
end
|
65
|
+
end
|
60
66
|
|
61
67
|
def sales_place
|
62
68
|
@places = EducodeSales::Place
|
@@ -162,10 +162,12 @@ module EducodeSales
|
|
162
162
|
when 'diy'
|
163
163
|
if params[:customer_date].present?
|
164
164
|
date = params[:customer_date].split(" - ")
|
165
|
-
begin_time = date[0]
|
166
|
-
end_time = date[1]
|
165
|
+
begin_time = date[0] + "00:00:00"
|
166
|
+
end_time = date[1] + "23:59:59"
|
167
167
|
end
|
168
168
|
end
|
169
|
+
100.times{p begin_time}
|
170
|
+
100.times{p end_time}
|
169
171
|
common = Common.find_by(clazz: 'staff_type', name: '销售')
|
170
172
|
staff_names = Staff.joins(:user).where(job_type: common.id).map { |d| d.user.real_name}
|
171
173
|
staff_ids = Staff.joins(:user).where(job_type: common.id).pluck(:id)
|
@@ -46,6 +46,10 @@ module EducodeSales
|
|
46
46
|
@staff = Staff.find(params[:id])
|
47
47
|
gon.area_ids = @staff.area_ids
|
48
48
|
gon.areas = Common.where(clazz: 'area').map { |d| { value: d.id, title: d.name } } #.unshift({value: -1, title: '全国'})
|
49
|
+
gon.school_ids = @staff.staff_schools.ids
|
50
|
+
gon.schools = @staff.staff_schools.pluck(:school_id).map { |d| { value: d, name: "#{School.find(d)&.name}-#{School.find(d)&.province}" } } #.unshift({value: -1, title: '全国'})
|
51
|
+
# gon.school_ids = School.all.ids
|
52
|
+
# gon.schools = School.all.first(100).map { |d| { value: d.id, title: d.name } } #.unshift({value: -1, title: '全国'})
|
49
53
|
@staff_types = Common.where(clazz: 'staff_type').pluck(:name, :id)
|
50
54
|
render layout: false
|
51
55
|
end
|
@@ -77,6 +81,12 @@ module EducodeSales
|
|
77
81
|
commons << Common.find(d)
|
78
82
|
end
|
79
83
|
staff.areas = commons
|
84
|
+
if params[:school_ids].present?
|
85
|
+
staff.staff_schools.destroy_all
|
86
|
+
params[:school_ids].each do |d|
|
87
|
+
staff.staff_schools.create(school_id: d)
|
88
|
+
end
|
89
|
+
end
|
80
90
|
if staff.save
|
81
91
|
render_success
|
82
92
|
else
|
@@ -14,6 +14,7 @@ module EducodeSales
|
|
14
14
|
has_many :businesses, dependent: :destroy
|
15
15
|
has_many :activities, dependent: :destroy
|
16
16
|
has_many :sale_plans, dependent: :destroy
|
17
|
+
has_many :staff_schools, dependent: :destroy
|
17
18
|
|
18
19
|
has_many :areas, through: :market_areas
|
19
20
|
validates :user_id, uniqueness: { message: '已存在' }
|
@@ -0,0 +1,30 @@
|
|
1
|
+
json.data do
|
2
|
+
json.array! @businesses do |d|
|
3
|
+
json.id d.id
|
4
|
+
json.name d.name
|
5
|
+
json.department d.department.name
|
6
|
+
json.school d.department.school.name
|
7
|
+
json.school_id d.department.school.id
|
8
|
+
follow_ups_count = d.follow_ups.where(deleted_at: nil).size
|
9
|
+
json.follow_ups_count follow_ups_count
|
10
|
+
json.follow_up_id d.last_follow_up_id
|
11
|
+
json.clazz d.last_follow_up&.clazz&.name || ""
|
12
|
+
json.stage d.last_follow_up&.stage&.name
|
13
|
+
json.invitation_at d.last_follow_up&.invitation_at.to_s
|
14
|
+
json.reception_at d.last_follow_up&.reception_at.to_s
|
15
|
+
json.bidded_date d.last_follow_up&.bidded_date.to_s
|
16
|
+
json.signed_date d.last_follow_up&.signed_date.to_s
|
17
|
+
json.total_amount d.last_follow_up&.total_amount
|
18
|
+
json.actual_amount d.last_follow_up&.actual_amount
|
19
|
+
json.return_money d.return_money
|
20
|
+
json.wait_return_money d.wait_return_money.to_i.round(2)
|
21
|
+
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 : ''
|
22
|
+
json.place d.last_follow_up&.place&.name
|
23
|
+
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
|
24
|
+
json.source d.source
|
25
|
+
json.assign_follow_ups d.last_follow_up.present? ? d.last_follow_up.assign_follow_ups.pluck(:staff_id) : []
|
26
|
+
json.current_staff_id @current_admin.id
|
27
|
+
json.staff_id d.staff_id
|
28
|
+
json.latest_time d.last_follow_up.present? ? d.last_follow_up.created_at.to_s : ''
|
29
|
+
end
|
30
|
+
end
|
@@ -88,7 +88,7 @@
|
|
88
88
|
<script type="text/html" id="bussinessBar">
|
89
89
|
<div class="layui-btn-container">
|
90
90
|
<span class="table-label">商机列表</span>
|
91
|
-
<
|
91
|
+
<button class="layui-btn layui-btn-primary layui-border-green layui-btn-sm data-count-edit export_more-btn pull-right" style="color: #0000FF;" data-name="export" data-id="export">导出<i class="layui-icon layui-icon-down layui-nav-more"></i></button>
|
92
92
|
<% if can? :create, EducodeSales::Business %>
|
93
93
|
<button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn pull-right" lay-event="add"> 添加商机</button>
|
94
94
|
<% end %>
|
@@ -332,7 +332,7 @@
|
|
332
332
|
},
|
333
333
|
{
|
334
334
|
field: 'return_money_days',
|
335
|
-
width:
|
335
|
+
width: 150,
|
336
336
|
title: '首次回款周期(天)',
|
337
337
|
},
|
338
338
|
{
|
@@ -340,6 +340,11 @@
|
|
340
340
|
width: 160,
|
341
341
|
title: '渠道',
|
342
342
|
},
|
343
|
+
{
|
344
|
+
field: 'year',
|
345
|
+
width: 105,
|
346
|
+
title: '所属年度',
|
347
|
+
},
|
343
348
|
{
|
344
349
|
title: '操作',
|
345
350
|
minWidth: 170,
|
@@ -355,7 +360,7 @@
|
|
355
360
|
page: true,
|
356
361
|
skin: 'line',
|
357
362
|
done: function (res) {
|
358
|
-
exportData=res.
|
363
|
+
exportData=res.data;
|
359
364
|
console.log(exportData);
|
360
365
|
drowpdwonRender()
|
361
366
|
export_drowpdwonRender()
|
@@ -420,14 +425,76 @@
|
|
420
425
|
}
|
421
426
|
|
422
427
|
function export_csv() {
|
423
|
-
|
424
|
-
|
428
|
+
var data = form.val("search_form");
|
429
|
+
var business_type = [];
|
430
|
+
business_type_list.getValue().forEach(function(d) {
|
431
|
+
business_type.push(d.value);
|
432
|
+
})
|
433
|
+
var business_step = [];
|
434
|
+
business_step_list.getValue().forEach(function(d) {
|
435
|
+
business_step.push(d.value);
|
436
|
+
})
|
437
|
+
data.place_id = index_place_list.getValue('valueStr');
|
438
|
+
data.business_type = business_type.toString();
|
439
|
+
data.business_step = business_step.toString();
|
440
|
+
layer.load(0, {});
|
441
|
+
console.log(data);
|
442
|
+
request.authPost("/missions/businesses/get_export_data", {
|
443
|
+
name: data.name,
|
444
|
+
area: data.area,
|
445
|
+
business_step: data.business_step,
|
446
|
+
business_type: data.business_type,
|
447
|
+
date: data.date,
|
448
|
+
department: data.department,
|
449
|
+
invitation_at: data.invitation_at,
|
450
|
+
place_id: data.place_id,
|
451
|
+
select: data.select,
|
452
|
+
staff_id: data.staff_id
|
453
|
+
}, function (res) {
|
454
|
+
console.log(res.data);
|
455
|
+
data = res.data
|
456
|
+
table.exportFile(business_table.config.id,data, 'csv');
|
457
|
+
layer.closeAll('loading');
|
458
|
+
request.get('/missions/businesses/add_export_records?type=csv', {}, function (res) {
|
459
|
+
})
|
425
460
|
})
|
461
|
+
|
426
462
|
}
|
427
463
|
function export_excel() {
|
428
|
-
|
429
|
-
|
464
|
+
var data = form.val("search_form");
|
465
|
+
var business_type = [];
|
466
|
+
business_type_list.getValue().forEach(function(d) {
|
467
|
+
business_type.push(d.value);
|
468
|
+
})
|
469
|
+
var business_step = [];
|
470
|
+
business_step_list.getValue().forEach(function(d) {
|
471
|
+
business_step.push(d.value);
|
430
472
|
})
|
473
|
+
data.place_id = index_place_list.getValue('valueStr');
|
474
|
+
data.business_type = business_type.toString();
|
475
|
+
data.business_step = business_step.toString();
|
476
|
+
layer.load(0, {});
|
477
|
+
console.log(data);
|
478
|
+
request.authPost("/missions/businesses/get_export_data", {
|
479
|
+
name: data.name,
|
480
|
+
area: data.area,
|
481
|
+
business_step: data.business_step,
|
482
|
+
business_type: data.business_type,
|
483
|
+
date: data.date,
|
484
|
+
department: data.department,
|
485
|
+
invitation_at: data.invitation_at,
|
486
|
+
place_id: data.place_id,
|
487
|
+
select: data.select,
|
488
|
+
staff_id: data.staff_id
|
489
|
+
}, function (res) {
|
490
|
+
console.log(res.data);
|
491
|
+
data = res.data
|
492
|
+
table.exportFile(business_table.config.id,data, 'xls');
|
493
|
+
layer.closeAll('loading');
|
494
|
+
request.get('/missions/businesses/add_export_records?type=xls', {}, function (res) {
|
495
|
+
})
|
496
|
+
})
|
497
|
+
|
431
498
|
}
|
432
499
|
function export_records() {
|
433
500
|
var content = miniPage.getHrefContent('/missions/businesses/export_records')
|
@@ -16,35 +16,7 @@ json.data do
|
|
16
16
|
json.reception_at d.last_follow_up&.reception_at.to_s
|
17
17
|
json.bidded_date d.last_follow_up&.bidded_date.to_s
|
18
18
|
json.signed_date d.last_follow_up&.signed_date.to_s
|
19
|
-
json.
|
20
|
-
json.actual_amount d.last_follow_up&.actual_amount
|
21
|
-
json.return_money d.return_money
|
22
|
-
json.wait_return_money d.wait_return_money.to_i.round(2)
|
23
|
-
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 : ''
|
24
|
-
json.place d.last_follow_up&.place&.name
|
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
|
26
|
-
json.source d.source
|
27
|
-
json.assign_follow_ups d.last_follow_up.present? ? d.last_follow_up.assign_follow_ups.pluck(:staff_id) : []
|
28
|
-
json.current_staff_id @current_admin.id
|
29
|
-
json.staff_id d.staff_id
|
30
|
-
json.latest_time d.last_follow_up.present? ? d.last_follow_up.created_at.to_s : ''
|
31
|
-
end
|
32
|
-
end
|
33
|
-
json.data1 do
|
34
|
-
json.array! @businesses_exports do |d|
|
35
|
-
json.id d.id
|
36
|
-
json.name d.name
|
37
|
-
json.department d.department.name
|
38
|
-
json.school d.department.school.name
|
39
|
-
json.school_id d.department.school.id
|
40
|
-
json.follow_ups_count d.follow_ups.where(deleted_at: nil).size
|
41
|
-
json.follow_up_id d.last_follow_up_id
|
42
|
-
json.clazz d.last_follow_up&.clazz&.name || ""
|
43
|
-
json.stage d.last_follow_up&.stage&.name
|
44
|
-
json.invitation_at d.last_follow_up&.invitation_at.to_s
|
45
|
-
json.reception_at d.last_follow_up&.reception_at.to_s
|
46
|
-
json.bidded_date d.last_follow_up&.bidded_date.to_s
|
47
|
-
json.signed_date d.last_follow_up&.signed_date.to_s
|
19
|
+
json.year d.last_follow_up&.year.to_s
|
48
20
|
json.total_amount d.last_follow_up&.total_amount
|
49
21
|
json.actual_amount d.last_follow_up&.actual_amount
|
50
22
|
json.return_money d.return_money
|
@@ -25,7 +25,12 @@
|
|
25
25
|
<!-- <input type="text" class="layui-input" id="date" name="date" placeholder=" - ">-->
|
26
26
|
<!-- </div>-->
|
27
27
|
<!-- </div>-->
|
28
|
-
|
28
|
+
<div class="layui-inline">
|
29
|
+
<label class="layui-form-label">性质</label>
|
30
|
+
<div class="layui-input-inline">
|
31
|
+
<div id="property" style="width: 190px;"></div>
|
32
|
+
</div>
|
33
|
+
</div>
|
29
34
|
<div class="layui-inline">
|
30
35
|
<button type="reset" class="layui-btn layui-btn-primary" lay-submit lay-filter="reset_business_search">重置
|
31
36
|
</button>
|
@@ -94,6 +99,19 @@
|
|
94
99
|
// window.onload=hn;
|
95
100
|
// });
|
96
101
|
|
102
|
+
var property_list = xmSelect.render({
|
103
|
+
el: '#property',
|
104
|
+
data: [
|
105
|
+
{value: 0, name: '985工程'},
|
106
|
+
{value: 1, name: '211工程'},
|
107
|
+
{value: 2, name: '本科院校'},
|
108
|
+
{value: 3, name: '大专院校'},
|
109
|
+
{value: 4, name: '中专学校'},
|
110
|
+
{value: 5, name: '军事院校'},
|
111
|
+
{value: 6, name: '企业'}
|
112
|
+
]
|
113
|
+
})
|
114
|
+
|
97
115
|
laydate.render({
|
98
116
|
elem: '#date',
|
99
117
|
range: true
|
@@ -129,6 +147,11 @@
|
|
129
147
|
width: 100,
|
130
148
|
title: '区域',
|
131
149
|
},
|
150
|
+
{
|
151
|
+
field: 'property',
|
152
|
+
width: 200,
|
153
|
+
title: '性质',
|
154
|
+
},
|
132
155
|
{
|
133
156
|
field: 'department',
|
134
157
|
width: 100,
|
@@ -238,6 +261,11 @@
|
|
238
261
|
|
239
262
|
// 监听搜索操作
|
240
263
|
form.on('submit(search_teachers)', function (data) {
|
264
|
+
var property = [];
|
265
|
+
property_list.getValue().forEach(function(d) {
|
266
|
+
property.push(d.value);
|
267
|
+
})
|
268
|
+
data.field.property = property.toString();
|
241
269
|
search = data.field
|
242
270
|
table.reload('customers_table', {
|
243
271
|
page: {
|
@@ -263,6 +291,7 @@
|
|
263
291
|
assist: "",
|
264
292
|
teacher_source: ""
|
265
293
|
});
|
294
|
+
property_list.setValue([])
|
266
295
|
return false;
|
267
296
|
});
|
268
297
|
/**
|
@@ -14,6 +14,18 @@ json.data do
|
|
14
14
|
json.id d.id
|
15
15
|
json.name d.name
|
16
16
|
json.area d.province
|
17
|
+
school_property = d.school_property
|
18
|
+
property = []
|
19
|
+
if school_property.present?
|
20
|
+
property << '985工程' if school_property.project_985
|
21
|
+
property << '211工程' if school_property.project_211
|
22
|
+
property << '本科院校' if school_property.regular_college
|
23
|
+
property << '大专院校' if school_property.junior_college
|
24
|
+
property << '中专学校' if school_property.secondary_school
|
25
|
+
property << '军事院校' if school_property.military_school
|
26
|
+
property << '企业' if school_property.enterprise
|
27
|
+
end
|
28
|
+
json.property property.join("、")
|
17
29
|
json.department d.departments.size
|
18
30
|
json.business EducodeSales::Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", x).where("educode_sales_businesses.school_id = ?", d.id).size
|
19
31
|
json.follow follow_ups.size + customer_follows.size
|
@@ -1,53 +1,67 @@
|
|
1
|
+
<!--<form class="layui-form layuimini-form" id="custom_data" data-required="true" action="">-->
|
2
|
+
<!-- <div class="layui-form-item" style="padding: 25px">-->
|
3
|
+
<!-- <div class="layui-inline">-->
|
4
|
+
<!-- <label class="layui-form-label required">客户:</label>-->
|
5
|
+
<!-- <div class="layui-input-block" style="width: 500px;">-->
|
6
|
+
<!-- <input type="text" name="name" lay-verify="required" placeholder="请输入客户" autocomplete="off"-->
|
7
|
+
<!-- class="layui-input" id="inputFocus">-->
|
8
|
+
<!-- </div>-->
|
9
|
+
<!-- </div>-->
|
10
|
+
<!-- <br>-->
|
11
|
+
<!-- <div class="layui-inline city_input">-->
|
12
|
+
<!-- <label class="layui-form-label ">省:</label>-->
|
13
|
+
<!-- <div class="layui-input-block" style="width: 500px;">-->
|
14
|
+
<!-- <select id="province" class="province layui-input"></select>-->
|
15
|
+
<!-- </div>-->
|
16
|
+
<!-- </div>-->
|
17
|
+
<!-- <br>-->
|
18
|
+
<!-- <div class="layui-inline city_input">-->
|
19
|
+
<!-- <label class="layui-form-label ">市:</label>-->
|
20
|
+
<!-- <div class="layui-input-block" style="width: 500px;">-->
|
21
|
+
<!-- <select id="city" class="city layui-input"></select>-->
|
22
|
+
<!-- </div>-->
|
23
|
+
<!-- </div>-->
|
24
|
+
<!-- <br>-->
|
25
|
+
<!-- <div class="layui-inline">-->
|
26
|
+
<!-- <label class="layui-form-label ">地址:</label>-->
|
27
|
+
<!-- <div class="layui-input-block" style="width: 500px;">-->
|
28
|
+
<!-- <input type="text" name="address" autocomplete="off"-->
|
29
|
+
<!-- class="layui-input" placeholder="请输入地址" >-->
|
30
|
+
<!-- </div>-->
|
31
|
+
<!-- </div>-->
|
32
|
+
<!-- <br>-->
|
33
|
+
<!-- <div class="layui-form-item">-->
|
34
|
+
<!-- <label class="layui-form-label">学校性质:</label>-->
|
35
|
+
<!-- <div class="layui-input-block">-->
|
36
|
+
<!-- <input type="checkbox" name="project_985" lay-skin="primary" value="1" title="985工程">-->
|
37
|
+
<!-- <input type="checkbox" name="project_211" lay-skin="primary" value="1" title="211工程" >-->
|
38
|
+
<!-- <input type="checkbox" name="regular_college" lay-skin="primary" value="1" title="本科院校">-->
|
39
|
+
<!-- </div>-->
|
40
|
+
<!-- </div>-->
|
41
|
+
<!-- <div class="layui-form-item">-->
|
42
|
+
<!-- <div class="layui-input-block">-->
|
43
|
+
<!-- <input type="checkbox" name="junior_college" lay-skin="primary" value="1" title="大专院校">-->
|
44
|
+
<!-- <input type="checkbox" name="secondary_school" lay-skin="primary" value="1" title="中专院校" >-->
|
45
|
+
<!-- <input type="checkbox" name="military_school" lay-skin="primary" value="1" title="军事院校">-->
|
46
|
+
<!-- </div>-->
|
47
|
+
<!-- </div>-->
|
48
|
+
<!-- <div class="layui-form-item">-->
|
49
|
+
<!-- <div class="layui-input-block">-->
|
50
|
+
<!-- <input type="checkbox" name="enterprise" lay-skin="primary" value="1" title="企业">-->
|
51
|
+
<!-- </div>-->
|
52
|
+
<!-- </div>-->
|
53
|
+
<!-- <div class="layui-inline" style="padding-left: 120px">-->
|
54
|
+
<!-- <button type="submit" class="layui-btn layui-btn-normal" lay-submit lay-filter="data-reset-btn">提交-->
|
55
|
+
<!-- </button>-->
|
56
|
+
<!-- </div>-->
|
57
|
+
<!-- </div>-->
|
58
|
+
<!--</form>-->
|
1
59
|
<form class="layui-form layuimini-form" id="custom_data" data-required="true" action="">
|
2
60
|
<div class="layui-form-item" style="padding: 25px">
|
3
|
-
<div class="layui-
|
4
|
-
<label class="layui-form-label
|
5
|
-
<div class="layui-input-
|
6
|
-
<
|
7
|
-
class="layui-input" id="inputFocus">
|
8
|
-
</div>
|
9
|
-
</div>
|
10
|
-
<br>
|
11
|
-
<div class="layui-inline city_input">
|
12
|
-
<label class="layui-form-label ">省:</label>
|
13
|
-
<div class="layui-input-block" style="width: 500px;">
|
14
|
-
<select id="province" class="province layui-input"></select>
|
15
|
-
</div>
|
16
|
-
</div>
|
17
|
-
<br>
|
18
|
-
<div class="layui-inline city_input">
|
19
|
-
<label class="layui-form-label ">市:</label>
|
20
|
-
<div class="layui-input-block" style="width: 500px;">
|
21
|
-
<select id="city" class="city layui-input"></select>
|
22
|
-
</div>
|
23
|
-
</div>
|
24
|
-
<br>
|
25
|
-
<div class="layui-inline">
|
26
|
-
<label class="layui-form-label ">地址:</label>
|
27
|
-
<div class="layui-input-block" style="width: 500px;">
|
28
|
-
<input type="text" name="address" autocomplete="off"
|
29
|
-
class="layui-input" placeholder="请输入地址" >
|
30
|
-
</div>
|
31
|
-
</div>
|
32
|
-
<br>
|
33
|
-
<div class="layui-form-item">
|
34
|
-
<label class="layui-form-label">学校性质:</label>
|
35
|
-
<div class="layui-input-block">
|
36
|
-
<input type="checkbox" name="project_985" lay-skin="primary" value="1" title="985工程">
|
37
|
-
<input type="checkbox" name="project_211" lay-skin="primary" value="1" title="211工程" >
|
38
|
-
<input type="checkbox" name="regular_college" lay-skin="primary" value="1" title="本科院校">
|
39
|
-
</div>
|
40
|
-
</div>
|
41
|
-
<div class="layui-form-item">
|
42
|
-
<div class="layui-input-block">
|
43
|
-
<input type="checkbox" name="junior_college" lay-skin="primary" value="1" title="大专院校">
|
44
|
-
<input type="checkbox" name="secondary_school" lay-skin="primary" value="1" title="中专院校" >
|
45
|
-
<input type="checkbox" name="military_school" lay-skin="primary" value="1" title="军事院校">
|
46
|
-
</div>
|
47
|
-
</div>
|
48
|
-
<div class="layui-form-item">
|
49
|
-
<div class="layui-input-block">
|
50
|
-
<input type="checkbox" name="enterprise" lay-skin="primary" value="1" title="企业">
|
61
|
+
<div class="layui-form-item" >
|
62
|
+
<label class="layui-form-label">学校</label>
|
63
|
+
<div class="layui-input-inline" style="">
|
64
|
+
<div id="edit_assign_follow" style="width: 1140px;"></div>
|
51
65
|
</div>
|
52
66
|
</div>
|
53
67
|
<div class="layui-inline" style="padding-left: 120px">
|
@@ -56,10 +70,7 @@
|
|
56
70
|
</div>
|
57
71
|
</div>
|
58
72
|
</form>
|
59
|
-
|
60
|
-
|
61
73
|
<script>
|
62
|
-
document.getElementById("inputFocus").focus();
|
63
74
|
|
64
75
|
layui.use(['form', 'table', 'upload', 'laytpl', 'request', 'selectInput', 'transfer'], function () {
|
65
76
|
var form = layui.form,
|
@@ -75,6 +86,39 @@
|
|
75
86
|
// 当前弹出层,防止ID被覆盖
|
76
87
|
var parentIndex = layer.index;
|
77
88
|
|
89
|
+
var sales_list = xmSelect.render({
|
90
|
+
el: '#edit_assign_follow',
|
91
|
+
remoteSearch: true,
|
92
|
+
autoRow: true,
|
93
|
+
// clickClose: true,
|
94
|
+
delay: 1000,
|
95
|
+
tips: '支持名称/省份搜索,请至少输入一个字符',
|
96
|
+
searchTips: '支持名称/省份搜索,请至少输入一个字符',
|
97
|
+
paging: true,
|
98
|
+
pageRemote: true,
|
99
|
+
filterable: true,
|
100
|
+
remoteMethod: function (val, cb, show, pageIndex) {
|
101
|
+
if(!val){
|
102
|
+
return cb([]);
|
103
|
+
}
|
104
|
+
$.ajax( '/missions/staff_schools', {
|
105
|
+
method: 'get',
|
106
|
+
data: {
|
107
|
+
q: val,
|
108
|
+
page: pageIndex
|
109
|
+
},
|
110
|
+
dataType: 'json',
|
111
|
+
success: function (res) {
|
112
|
+
var data = res.data;
|
113
|
+
if (res.code == 0) {
|
114
|
+
cb(res.data, res.count);
|
115
|
+
} else {
|
116
|
+
layer.msg(res.msg, {time: 2000, icon: 2, shade: 0.01});
|
117
|
+
}
|
118
|
+
}
|
119
|
+
})
|
120
|
+
}
|
121
|
+
})
|
78
122
|
|
79
123
|
var dataCustom = [
|
80
124
|
{
|
@@ -338,8 +382,17 @@
|
|
338
382
|
});
|
339
383
|
//监听提交
|
340
384
|
form.on('submit(data-reset-btn)', function (data) {
|
341
|
-
|
342
|
-
|
385
|
+
var schools = [];
|
386
|
+
sales_list.getValue().forEach(function(d) {
|
387
|
+
schools.push(d.value);
|
388
|
+
})
|
389
|
+
if (schools.length == 0) {
|
390
|
+
layer.alert("请选择学校");
|
391
|
+
return false;
|
392
|
+
}
|
393
|
+
data.field['school_ids'] = schools;
|
394
|
+
// data.field.province = $("#province option:selected").text(); //获取选中的项
|
395
|
+
// data.field.city = $("#city option:selected").text(); //获取选中的项
|
343
396
|
console.log(data.field);
|
344
397
|
request.authPost("missions/customers", data.field, function (res) {
|
345
398
|
if (res.success === false) {
|
@@ -3,9 +3,9 @@
|
|
3
3
|
<li class="layui-this">操作权限</li>
|
4
4
|
<li>数据浏览权限</li>
|
5
5
|
</ul>
|
6
|
-
<div class="layui-tab-content">
|
7
|
-
<div class="layui-tab-item layui-show">
|
8
|
-
<form class="layui-form
|
6
|
+
<div class="layui-tab-content caozuo">
|
7
|
+
<div class="layui-tab-item layui-show" style="height: 800px;!important;">
|
8
|
+
<form class="layui-form " action="">
|
9
9
|
<% id = 0 %>
|
10
10
|
<% EducodeSales::Permission.all.order(position: :asc).group_by{ |d| d.clazz}.each do |k, d| %>
|
11
11
|
<div class="layui-form-item">
|
@@ -139,4 +139,10 @@
|
|
139
139
|
})
|
140
140
|
//…
|
141
141
|
});
|
142
|
-
</script>
|
142
|
+
</script>
|
143
|
+
<style>
|
144
|
+
.caozuo .layui-tab-item {
|
145
|
+
width: 100% !important;
|
146
|
+
height: 900px !important;
|
147
|
+
}
|
148
|
+
</style>
|
@@ -621,7 +621,7 @@
|
|
621
621
|
});
|
622
622
|
$(".customer_bt").click(function () {
|
623
623
|
layer.load(0, {});
|
624
|
-
$.get('/missions/sale_trends/trends.json?customer_count_type=' + $("#customer_count_type").val() + '&customer_time_range=' + $("#customer_time_range").val()).done(function(res) {
|
624
|
+
$.get('/missions/sale_trends/trends.json?customer_count_type=' + $("#customer_count_type").val() + '&customer_time_range=' + $("#customer_time_range").val() + '&customer_date=' + $("#customer_date").val()).done(function(res) {
|
625
625
|
layer.closeAll('loading');
|
626
626
|
var data4 = res.data4;
|
627
627
|
myChart4.data = data4
|
@@ -60,7 +60,7 @@ json.data do
|
|
60
60
|
json.school_count school_count
|
61
61
|
follow_school_count = (EducodeSales::CustomerFollow.where(staff_id: d.id).where("created_at >= ? AND created_at <= ?", "#{@year}-01-01 00:00:00", "#{@year}-12-31 23:59:59").pluck(:school_id) + EducodeSales::Business.where(id: EducodeSales::FollowUp.where("created_at >= ? AND created_at <= ?", "#{@year}-01-01 00:00:00", "#{@year}-12-31 23:59:59").where(staff_id: d.id).pluck(:business_id).uniq).pluck(:school_id)).uniq.size
|
62
62
|
json.follow_school_count follow_school_count
|
63
|
-
json.follow_school_counts EducodeSales::CustomerFollow.where(staff_id: d.id).where("created_at >= ? AND created_at <= ?", "#{@year}-01-01", "#{@year}-12-31").size + EducodeSales::FollowUp.where(staff_id: d.id).where("created_at >= ? AND created_at <= ?", "#{@year}-01-01", "#{@year}-12-31").size
|
63
|
+
json.follow_school_counts EducodeSales::CustomerFollow.where(staff_id: d.id).where("created_at >= ? AND created_at <= ?", "#{@year}-01-01 00:00:00", "#{@year}-12-31 23:59:59").size + EducodeSales::FollowUp.where(staff_id: d.id).where("created_at >= ? AND created_at <= ?", "#{@year}-01-01 00:00:00", "#{@year}-12-31 23:59:59").size
|
64
64
|
follow_school_rate = (follow_school_count!=0 ? school_count.to_f * 100 / follow_school_count : 0).round(2)
|
65
65
|
json.follow_school_rate follow_school_rate.to_s + '%'
|
66
66
|
follow_department_rate = (follow_school_count!=0 ? school_count.to_f * 110 / follow_school_count : 0).round(2)
|
@@ -30,6 +30,12 @@
|
|
30
30
|
<div id="area" class="demo-transfer"></div>
|
31
31
|
</div>
|
32
32
|
</div>
|
33
|
+
<div class="layui-form-item" >
|
34
|
+
<label class="layui-form-label">监管学校</label>
|
35
|
+
<div class="layui-input-inline" style="">
|
36
|
+
<div id="edit_assign_follow" style="width: 1140px;"></div>
|
37
|
+
</div>
|
38
|
+
</div>
|
33
39
|
<div class="layui-form-item">
|
34
40
|
<label class="layui-form-label required">生效日期</label>
|
35
41
|
<div class="layui-input-block">
|
@@ -85,6 +91,40 @@
|
|
85
91
|
return false
|
86
92
|
}
|
87
93
|
})
|
94
|
+
var sales_list = xmSelect.render({
|
95
|
+
el: '#edit_assign_follow',
|
96
|
+
remoteSearch: true,
|
97
|
+
autoRow: true,
|
98
|
+
// clickClose: true,
|
99
|
+
delay: 1000,
|
100
|
+
tips: '支持名称/省份搜索,请至少输入一个字符',
|
101
|
+
searchTips: '支持名称/省份搜索,请至少输入一个字符',
|
102
|
+
paging: true,
|
103
|
+
pageRemote: true,
|
104
|
+
filterable: true,
|
105
|
+
remoteMethod: function (val, cb, show, pageIndex) {
|
106
|
+
if(!val){
|
107
|
+
return cb([]);
|
108
|
+
}
|
109
|
+
$.ajax( '/missions/staff_schools', {
|
110
|
+
method: 'get',
|
111
|
+
data: {
|
112
|
+
q: val,
|
113
|
+
page: pageIndex
|
114
|
+
},
|
115
|
+
dataType: 'json',
|
116
|
+
success: function (res) {
|
117
|
+
var data = res.data;
|
118
|
+
if (res.code == 0) {
|
119
|
+
cb(res.data, res.count);
|
120
|
+
} else {
|
121
|
+
layer.msg(res.msg, {time: 2000, icon: 2, shade: 0.01});
|
122
|
+
}
|
123
|
+
}
|
124
|
+
})
|
125
|
+
}
|
126
|
+
})
|
127
|
+
sales_list.setValue(gon.schools)
|
88
128
|
|
89
129
|
//监听提交
|
90
130
|
form.on('submit(saveBtn)', function (data) {
|
@@ -92,10 +132,15 @@
|
|
92
132
|
layui.each(transfer.getData('area_list'), function (i, v) {
|
93
133
|
area_ids.push(v.value)
|
94
134
|
})
|
135
|
+
var schools = [];
|
136
|
+
sales_list.getValue().forEach(function(d) {
|
137
|
+
schools.push(d.value);
|
138
|
+
})
|
95
139
|
if (area_ids.length == 0) {
|
96
140
|
layer.alert("请选择负责区域");
|
97
141
|
return false;
|
98
142
|
}
|
143
|
+
data.field['school_ids'] = schools;
|
99
144
|
data.field['area_ids'] = area_ids;
|
100
145
|
request.authPut("missions/staffs/" + parent.staff_id, data.field, function (res) {
|
101
146
|
console.log(res.success == false)
|
data/config/routes.rb
CHANGED
@@ -12,6 +12,7 @@ EducodeSales::Engine.routes.draw do
|
|
12
12
|
get :no_permission, to: "home#no_permission"
|
13
13
|
get :sales_staff, to: "home#sales_staff"
|
14
14
|
get :sales_place, to: "home#sales_place"
|
15
|
+
get :staff_schools, to: "home#staff_schools"
|
15
16
|
|
16
17
|
resources :sessions do
|
17
18
|
end
|
@@ -83,6 +84,7 @@ EducodeSales::Engine.routes.draw do
|
|
83
84
|
resources :businesses do
|
84
85
|
collection do
|
85
86
|
get :export_records
|
87
|
+
post :get_export_data
|
86
88
|
get :add_export_records
|
87
89
|
get :show_keys
|
88
90
|
get :add_keys
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: educode_sales
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- anke1460
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-01-
|
11
|
+
date: 2022-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -181,6 +181,7 @@ files:
|
|
181
181
|
- app/models/educode_sales/common.rb
|
182
182
|
- app/models/educode_sales/course_subject.rb
|
183
183
|
- app/models/educode_sales/customer.rb
|
184
|
+
- app/models/educode_sales/customer_add.rb
|
184
185
|
- app/models/educode_sales/customer_extension.rb
|
185
186
|
- app/models/educode_sales/customer_follow.rb
|
186
187
|
- app/models/educode_sales/follow_up.rb
|
@@ -201,6 +202,7 @@ files:
|
|
201
202
|
- app/models/educode_sales/sale_report.rb
|
202
203
|
- app/models/educode_sales/sale_trend.rb
|
203
204
|
- app/models/educode_sales/staff.rb
|
205
|
+
- app/models/educode_sales/staff_school.rb
|
204
206
|
- app/models/educode_sales/teacher.rb
|
205
207
|
- app/models/educode_sales/teacher_assign_follow.rb
|
206
208
|
- app/models/educode_sales/teacher_follow.rb
|
@@ -216,6 +218,7 @@ files:
|
|
216
218
|
- app/views/educode_sales/businesses/export_records.html.erb
|
217
219
|
- app/views/educode_sales/businesses/export_records.json.jbuilder
|
218
220
|
- app/views/educode_sales/businesses/file.html.erb
|
221
|
+
- app/views/educode_sales/businesses/get_export_data.json.jbuilder
|
219
222
|
- app/views/educode_sales/businesses/index.html.erb
|
220
223
|
- app/views/educode_sales/businesses/index.json.jbuilder
|
221
224
|
- app/views/educode_sales/businesses/new.html.erb
|
@@ -257,6 +260,7 @@ files:
|
|
257
260
|
- app/views/educode_sales/home/search_operation_teacher.json.jbuilder
|
258
261
|
- app/views/educode_sales/home/search_teacher.json.jbuilder
|
259
262
|
- app/views/educode_sales/home/search_users.json.jbuilder
|
263
|
+
- app/views/educode_sales/home/staff_schools.json.jbuilder
|
260
264
|
- app/views/educode_sales/home/statistics.html.erb
|
261
265
|
- app/views/educode_sales/money_plans/index.html.erb
|
262
266
|
- app/views/educode_sales/money_plans/index.json.jbuilder
|
@@ -415,6 +419,8 @@ files:
|
|
415
419
|
- db/migrate/20211220102720_add_position_to_commons.rb
|
416
420
|
- db/migrate/20211221075146_add_school_id_to_educode_sales_businesses.rb
|
417
421
|
- db/migrate/20220121060006_create_educode_sales_business_export_records.rb
|
422
|
+
- db/migrate/20220125013811_create_educode_sales_staff_schools.rb
|
423
|
+
- db/migrate/20220125033552_create_educode_sales_customer_adds.rb
|
418
424
|
- lib/educode_sales.rb
|
419
425
|
- lib/educode_sales/engine.rb
|
420
426
|
- lib/educode_sales/version.rb
|