educode_sales 0.9.66 → 0.9.67

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 (26) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/educode_sales/activities_controller.rb +72 -4
  3. data/app/controllers/educode_sales/businesses_controller.rb +82 -1
  4. data/app/models/educode_sales/activity.rb +17 -4
  5. data/app/models/educode_sales/activity_follow_up.rb +13 -0
  6. data/app/models/educode_sales/activity_staff.rb +1 -1
  7. data/app/models/educode_sales/business.rb +3 -0
  8. data/app/models/educode_sales/business_level.rb +11 -0
  9. data/app/models/educode_sales/business_watch.rb +6 -0
  10. data/app/views/educode_sales/activities/_follows.html.erb +208 -0
  11. data/app/views/educode_sales/activities/_index.html.erb +418 -0
  12. data/app/views/educode_sales/activities/edit.html.erb +99 -0
  13. data/app/views/educode_sales/activities/follow_ups.json.jbuilder +19 -0
  14. data/app/views/educode_sales/activities/index.html.erb +13 -349
  15. data/app/views/educode_sales/activities/index.json.jbuilder +9 -1
  16. data/app/views/educode_sales/activities/new.html.erb +80 -0
  17. data/app/views/educode_sales/activities/new_follow_up.html.erb +56 -0
  18. data/app/views/educode_sales/businesses/edit.html.erb +48 -6
  19. data/app/views/educode_sales/businesses/index.html.erb +10 -0
  20. data/app/views/educode_sales/businesses/no_permission.html.erb +2 -0
  21. data/config/routes.rb +3 -0
  22. data/db/migrate/20230329135141_create_educode_sales_business_watches.rb +17 -0
  23. data/db/migrate/20230330141213_create_educode_sales_activity_follow_ups.rb +25 -0
  24. data/lib/educode_sales/version.rb +1 -1
  25. metadata +15 -6
  26. data/app/assets/images/educode_sales/indexlogo.png +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c77ba5bbfa29534697eba58c7d999ffbe0834fb358aae6b3e923278e5f16475e
4
- data.tar.gz: 78b061d50d1bd7bff1e58e2dfdc4bcf23ac85661980324dfce85b0dd961d8dac
3
+ metadata.gz: 5df645421c2aa112db563a37427dc4371924632bbca76efa21b74acec0911793
4
+ data.tar.gz: bcc515a472ec5c92f66b9bb833dcfe4ca4e2330634df6bfb0b9b058501a90f90
5
5
  SHA512:
6
- metadata.gz: 4567e920c14a07085963ca478f9629def13a74ab78e5d0f1c8a9559e5c32f9e1e2ebed39bef4396a1f3d1e5e6e8b42ea5dd18128c8be6275b5c91430d59b32f2
7
- data.tar.gz: dc98da54f8926781094902266a9eeaae2e0d1f6cab8837c27795bccab0d031da4946f19246baefdd11534af288a9afc37aa3e4ecf865a22d7d0a6a499870b809
6
+ metadata.gz: ee2b4439e08af8c4ca6810fc5fe5ef04d0d410c38a6bc32c8ca3bdcc0caea46e1ce3ac29b178c2c632f5edddd5190046f47e00605a1c33496e7e7a4c9aeb7c89
7
+ data.tar.gz: 41c923fe3dd2dd68df2c141add67467fd52b1ffc5bc5ac36a010272cb38b75d1cab760f6e136b24d32c22642dee5f19f84da10c279d9b22d12eb728e4b66d4e9
@@ -16,6 +16,10 @@ module EducodeSales
16
16
  if params[:q][:clazz_id].present?
17
17
  @activities = @activities.where(clazz_id: params[:q][:clazz_id])
18
18
  end
19
+
20
+ if params[:q][:state_id].present?
21
+ @activities = @activities.where(state_id: params[:q][:state_id])
22
+ end
19
23
 
20
24
  if params[:q][:name].present?
21
25
  @activities = @activities.where("educode_sales_activities.name like ?", "%#{params[:q][:name]}%")
@@ -48,18 +52,24 @@ module EducodeSales
48
52
 
49
53
  def edit
50
54
  @activity = Activity.find(params[:id])
55
+ @clazz = ['全国会议', '区域会议', '单校会议', '国赛', '省赛', '夏令营']
51
56
  manage_ids = @activity.manages.pluck(:staff_id)
52
57
  assist_ids = @activity.assists.pluck(:staff_id)
53
58
  gon.staff_manage = Staff.all.map { |d| {name: d.user&.real_name, value: d.id, selected: manage_ids.include?(d.id)}}
54
59
  gon.assists = Staff.all.map { |d| {name: d.user&.real_name, value: d.id, selected: assist_ids.include?(d.id)}}
55
60
  gon.experts = @activity.experts.map { |d| {name: d.name, value: d.user_id || d.name, selected: true}}
61
+
62
+ gon.invitation_list = @activity.invitations.map { |d| {name: d.name, value: d.user_id || d.name, selected: true}}
63
+
64
+ sale_id = @activity.sales_id || @activity.staff_id
65
+
66
+ gon.sales_manage = Staff.all.map { |d| {name: d.user&.real_name, value: d.id, selected: d.id == sale_id }}
56
67
  render layout: false
57
68
  end
58
69
 
59
70
  def create
60
71
  activity = @current_admin.activities.new(activity_params)
61
-
62
- # render_success
72
+ activity.sales_id = @current_admin.id
63
73
  if activity.save
64
74
  params[:staff_manage_id].each do |d|
65
75
  EducodeSales::ActivityStaff.create(staff_id: d, clazz_id: 'manage', activity_id: activity.id)
@@ -75,6 +85,14 @@ module EducodeSales
75
85
  EducodeSales::ActivityStaff.create(name: d[1], clazz_id: 'expert', activity_id: activity.id)
76
86
  end
77
87
  end
88
+ params[:invitation_ids].each do |d|
89
+ if d[0].to_i > 0
90
+ u = User.find(d[0].to_i)
91
+ EducodeSales::ActivityStaff.create(name: u.real_name, clazz_id: 'invitation', user_id: d[0].to_i, activity_id: activity.id)
92
+ else
93
+ EducodeSales::ActivityStaff.create(name: d[1], clazz_id: 'invitation', activity_id: activity.id)
94
+ end
95
+ end
78
96
  if params[:attachment_id].present?
79
97
  attachment = @current_admin.user.attachments.find(params[:attachment_id])
80
98
  attachment.container = activity
@@ -88,10 +106,22 @@ module EducodeSales
88
106
 
89
107
  def update
90
108
  activity = Activity.find(params[:id])
91
- activity.assign_attributes(name: params[:name], start_at: params[:start_at], days: params[:days])
109
+ activity.assign_attributes(
110
+ state_id: params[:state_id],
111
+ name: params[:name],
112
+ start_at: params[:start_at], days: params[:days],
113
+ sponsor: params[:sponsor],
114
+ linkman: params[:linkman],
115
+ phone: params[:phone],
116
+ scale: params[:scale],
117
+ address: params[:address],
118
+ meeting_form: params[:meeting_form],
119
+ sales_id: params[:sales_id] || @current_admin.id
120
+ )
92
121
  manages = []
93
122
  experts = []
94
123
  assists = []
124
+ invitations = []
95
125
  params[:staff_manage_id].each do |d|
96
126
  manages << EducodeSales::ActivityStaff.find_or_initialize_by(staff_id: d, clazz_id: 'manage', activity_id: activity.id)
97
127
  end
@@ -107,9 +137,18 @@ module EducodeSales
107
137
  experts << EducodeSales::ActivityStaff.find_or_initialize_by(name: d[1], clazz_id: 'expert', activity_id: activity.id)
108
138
  end
109
139
  end
140
+ params[:invitation_ids].each do |d|
141
+ if d[0].to_i > 0
142
+ u = User.find(d[0].to_i)
143
+ invitations << EducodeSales::ActivityStaff.find_or_initialize_by(name: u.real_name, clazz_id: 'invitation', user_id: d[0].to_i, activity_id: activity.id)
144
+ else
145
+ invitations << EducodeSales::ActivityStaff.find_or_initialize_by(name: d[1], clazz_id: 'invitation', activity_id: activity.id)
146
+ end
147
+ end
110
148
  activity.manages = manages
111
149
  activity.assists = assists
112
150
  activity.experts = experts
151
+ activity.invitations = invitations
113
152
 
114
153
  if params[:attachment_id].present?
115
154
  if activity.attachment&.id && activity.attachment&.id != params[:attachment_id].to_i
@@ -163,10 +202,39 @@ module EducodeSales
163
202
  end
164
203
  end
165
204
 
205
+ def new_follow_up
206
+ @activity = Activity.find(params[:id])
207
+ render layout: false
208
+ end
209
+
210
+ def follow_up
211
+ activity = Activity.find(params[:id])
212
+ follow_up = EducodeSales::ActivityFollowUp.new(activity_id: activity.id, staff_id: @current_admin.id, description: params[:description], info_id: params[:info_id])
213
+ if follow_up.save
214
+ activity.last_follow_up_id = follow_up.id
215
+ activity.save
216
+ render_success
217
+ else
218
+ render_failure follow_up
219
+ end
220
+
221
+ end
222
+
223
+ def follow_ups
224
+ @data = ActivityFollowUp.includes(:staff, activity: :staff)
225
+
226
+ if params[:sort].present? && params[:sort][:field]
227
+ @data = @data.order("#{params[:sort][:field]} #{params[:sort][:order]}")
228
+ else
229
+ @data = @data.order("created_at desc")
230
+ end
231
+ @data = @data.distinct.page(params[:page]).per(params[:limit])
232
+ end
233
+
166
234
  private
167
235
 
168
236
  def activity_params
169
- params.permit(:name, :start_at, :days, :staff_assist_id, :staff_manage_id, :clazz_id, :expert)
237
+ params.permit(:name, :start_at, :days, :staff_assist_id, :staff_manage_id, :clazz_id, :expert, :state_id, :sponsor, :linkman, :phone, :scale, :address, :meeting_form)
170
238
  end
171
239
 
172
240
  end
@@ -297,6 +297,24 @@ module EducodeSales
297
297
 
298
298
  @business_count = @businesses.distinct.count
299
299
  # mysql -select
300
+ watch_sql = " "
301
+ unless @current_admin.is_admin?
302
+ # 保密和战略商机,只有自己,指定人员或管理员才有权限查看
303
+ watch_sql = " LEFT JOIN educode_sales_business_watches ON educode_sales_business_watches.business_id = educode_sales_businesses.id
304
+ LEFT JOIN educode_sales_business_levels ON educode_sales_business_levels.business_id = educode_sales_businesses.id"
305
+ @businesses = @businesses.where("educode_sales_business_levels.id IS NULL OR (educode_sales_business_levels.id IS NOT NULL AND educode_sales_businesses.staff_id = #{@current_admin.id}) OR educode_sales_business_levels.level_id NOT IN (1,2) OR (educode_sales_business_levels.level_id IN (1, 2) AND educode_sales_business_watches.staff_id = #{@current_admin.id})")
306
+ end
307
+ if params[:q][:level_id].present?
308
+
309
+ if @current_admin.is_admin?
310
+ watch_sql = " JOIN educode_sales_business_levels ON educode_sales_business_levels.business_id = educode_sales_businesses.id"
311
+ @businesses = @businesses.where("educode_sales_business_levels.level_id = ?", params[:q][:level_id])
312
+ else
313
+ watch_sql = " JOIN educode_sales_business_watches ON educode_sales_business_watches.business_id = educode_sales_businesses.id
314
+ JOIN educode_sales_business_levels ON educode_sales_business_levels.business_id = educode_sales_businesses.id AND educode_sales_business_levels.level_id = #{params[:q][:level_id].to_i}"
315
+ @businesses = @businesses.where("(educode_sales_businesses.staff_id = #{@current_admin.id}) OR educode_sales_business_levels.level_id NOT IN (1,2) OR (educode_sales_business_levels.level_id IN (1, 2) AND educode_sales_business_watches.staff_id = #{@current_admin.id})" )
316
+ end
317
+ end
300
318
  @businesses = @businesses.select("
301
319
  distinct
302
320
  educode_sales_businesses.*,
@@ -326,6 +344,7 @@ module EducodeSales
326
344
  WHERE educode_sales_follow_ups.deleted_at IS NULL
327
345
  GROUP BY educode_sales_follow_ups.business_id
328
346
  ) AS total_follow_ups ON educode_sales_businesses.id = total_follow_ups.business_id
347
+ #{watch_sql}
329
348
  ").includes(:users, last_follow_up: [:clazz, :assign_follow_ups]).page(params[:page]).per(params[:limit])
330
349
 
331
350
  end
@@ -369,6 +388,13 @@ module EducodeSales
369
388
 
370
389
  def edit
371
390
  @business = Business.find(params[:id])
391
+ levels = @business.business_levels.pluck(:level_id)
392
+ staff_ids = @business.business_watches.pluck(:staff_id)
393
+
394
+ gon.is_secret = levels.include?("保密型") || levels.include?("战略型")
395
+
396
+ gon.levels = EducodeSales::BusinessLevel.level_ids.keys.map { |d| {name: d, value: d, selected: levels.include?(d)}}
397
+ gon.watche_ids = Staff.all.map { |d| {name: d.user&.real_name, value: d.id, selected: staff_ids.include?(d.id)}}
372
398
  gon.department = {value: @business.department_id, name: "#{@business.department.school.name}-#{@business.department.name}"}
373
399
  gon.value = @business.department_id
374
400
  render layout: false
@@ -377,6 +403,26 @@ module EducodeSales
377
403
  def update
378
404
  business = Business.find(params[:id])
379
405
  department = Department.find(params[:department_id])
406
+ if @current_admin.is_admin?
407
+ if params[:level_ids]
408
+ levels = []
409
+ params[:level_ids].split(",").each do |d|
410
+ levels << business.business_levels.find_or_initialize_by(level_id: d)
411
+ end
412
+ business.business_levels = levels
413
+
414
+ if params[:watch_ids].blank? || !params[:level_ids].split(",").include?('保密型') && !params[:level_ids].split(",").include?('战略型')
415
+ business.business_watches.destroy_all
416
+ else
417
+ staffs = []
418
+ params[:watch_ids].split(",").each do |d|
419
+ staffs << business.business_watches.find_or_initialize_by(staff_id: d)
420
+ end
421
+ business.business_watches = staffs
422
+ end
423
+ end
424
+ end
425
+
380
426
  if business.update(name: params[:name], department_id: department.id, source: params[:source], school_id: department.school_id)
381
427
  if params[:merge_business_ids].present?
382
428
  merge_business = Business.where(id: params[:merge_business_ids].split(","))
@@ -457,6 +503,16 @@ module EducodeSales
457
503
  load_business
458
504
  respond_to do |format|
459
505
  format.html do
506
+ unless @current_admin.is_admin?
507
+ levels = @business.business_levels.pluck(:level_id)
508
+ staff_ids = @business.business_watches.pluck(:staff_id)
509
+
510
+ if levels.include?("保密型") || levels.include?("战略型")
511
+ if !staff_ids.include?(@current_admin.id) && @business.staff_id != @current_admin.id && @business.last_follow_up&.staff_id != @current_admin.id
512
+ return render "no_permission", layout: false
513
+ end
514
+ end
515
+ end
460
516
  render layout: false
461
517
  end
462
518
  format.json do
@@ -499,8 +555,22 @@ module EducodeSales
499
555
  def show_follow_record
500
556
  follow_up_id = params[:follow_up_id]
501
557
  @follow_up = FollowUp.find(follow_up_id)
558
+
559
+ @business = Business.find(@follow_up.business_id)
560
+ # 保密商机限制查看
561
+ unless @current_admin.is_admin?
562
+ levels = @business.business_levels.pluck(:level_id)
563
+ staff_ids = @business.business_watches.pluck(:staff_id)
564
+
565
+ if levels.include?("保密型") || levels.include?("战略型")
566
+ if !staff_ids.include?(@current_admin.id) && @business.staff_id != @current_admin.id && @business.last_follow_up&.staff_id != @current_admin.id
567
+ return render "no_permission", layout: false
568
+ end
569
+ end
570
+ end
571
+
502
572
  id = @follow_up.id
503
- @follow_ups = Business.find(@follow_up.business_id).follow_ups
573
+ @follow_ups = @business.follow_ups
504
574
  ids = @follow_ups.ids
505
575
  size = ids.size
506
576
  ids = ids.reverse
@@ -546,6 +616,17 @@ module EducodeSales
546
616
  @business = Business.find(params[:business_id])
547
617
  respond_to do |format|
548
618
  format.html do
619
+ # 保密商机限制查看
620
+ unless @current_admin.is_admin?
621
+ levels = @business.business_levels.pluck(:level_id)
622
+ staff_ids = @business.business_watches.pluck(:staff_id)
623
+
624
+ if levels.include?("保密型") || levels.include?("战略型")
625
+ if !staff_ids.include?(@current_admin.id) && @business.staff_id != @current_admin.id && @business.last_follow_up&.staff_id != @current_admin.id
626
+ return render "no_permission", layout: false
627
+ end
628
+ end
629
+ end
549
630
  @follow_ups = @business.follow_ups.order(created_at: :desc)
550
631
  @latest = @follow_ups.present? ? @follow_ups[0] : nil
551
632
  render layout: false
@@ -3,13 +3,26 @@ module EducodeSales
3
3
  belongs_to :staff
4
4
  has_many :activity_teachers, dependent: :destroy
5
5
  has_many :teachers, through: :activity_teachers, dependent: :restrict_with_exception
6
- has_many :manages, -> {where("educode_sales_activity_staffs.clazz_id = 0")}, dependent: :destroy, class_name: 'ActivityStaff'
7
- has_many :assists, -> {where("educode_sales_activity_staffs.clazz_id = 1")}, dependent: :destroy, class_name: 'ActivityStaff'
8
- has_many :experts , -> {where("educode_sales_activity_staffs.clazz_id = 2")}, dependent: :destroy, class_name: 'ActivityStaff'
9
- has_many :activity_staffs
6
+ has_many :manages, -> {where("educode_sales_activity_staffs.clazz_id = 0")}, dependent: :destroy, class_name: 'ActivityStaff'
7
+ has_many :assists, -> {where("educode_sales_activity_staffs.clazz_id = 1")}, dependent: :destroy, class_name: 'ActivityStaff'
8
+ has_many :experts , -> {where("educode_sales_activity_staffs.clazz_id = 2")}, dependent: :destroy, class_name: 'ActivityStaff'
9
+ has_many :invitations , -> {where("educode_sales_activity_staffs.clazz_id = 3")}, dependent: :destroy, class_name: 'ActivityStaff'
10
+
11
+ has_many :activity_staffs, dependent: :destroy
12
+ has_many :activity_follow_ups, dependent: :destroy
13
+
14
+ belongs_to :sales, class_name: 'Staff', optional: true
10
15
 
11
16
  has_one :attachment, as: :container, dependent: :destroy
12
17
 
13
18
  enum clazz_id: ['全国会议', '区域会议', '单校会议', '国赛', '省赛', '夏令营']
19
+ enum state_id: {
20
+ '策划中': 1,
21
+ '筹备中': 2,
22
+ '实施中': 3,
23
+ '已结束': 4,
24
+ '已撤销': 5,
25
+ '已推迟': 6
26
+ }
14
27
  end
15
28
  end
@@ -0,0 +1,13 @@
1
+ module EducodeSales
2
+ class ActivityFollowUp < ApplicationRecord
3
+ belongs_to :staff
4
+ belongs_to :activity
5
+
6
+ enum info_id: {
7
+ '': nil,
8
+ '跟进信息': 1,
9
+ '团队建议': 2,
10
+ '评价': 3,
11
+ }
12
+ end
13
+ end
@@ -4,6 +4,6 @@ module EducodeSales
4
4
  belongs_to :staff, optional: true
5
5
  belongs_to :user, optional: true
6
6
 
7
- enum clazz_id: ['manage', 'assist', 'expert']
7
+ enum clazz_id: ['manage', 'assist', 'expert', 'invitation']
8
8
  end
9
9
  end
@@ -11,6 +11,8 @@ module EducodeSales
11
11
  has_many :sale_plans
12
12
  has_many :follow_ups
13
13
  has_many :business_clazz_changes
14
+ has_many :business_levels, dependent: :destroy
15
+ has_many :business_watches, dependent: :destroy
14
16
 
15
17
  #关联关注
16
18
  has_many :users,:class_name => 'EducodeSales::BusinessRelationShip',foreign_key: 'business_id',:dependent => :destroy
@@ -18,6 +20,7 @@ module EducodeSales
18
20
  #每次查询时 默认的查询条件
19
21
  default_scope -> {where(deleted_at: nil)}
20
22
 
23
+
21
24
  def soft_destroy(user_id)
22
25
  self.update(deleted_at: Time.now, state_id: 2)
23
26
  self.sale_plans.each do |d|
@@ -0,0 +1,11 @@
1
+ module EducodeSales
2
+ class BusinessLevel < ApplicationRecord
3
+ belongs_to :business
4
+
5
+ enum level_id: {
6
+ '保密型': 1,
7
+ '战略型': 2
8
+ }
9
+ end
10
+ end
11
+
@@ -0,0 +1,6 @@
1
+ module EducodeSales
2
+ class BusinessWatch < ApplicationRecord
3
+ belongs_to :business
4
+ belongs_to :staff
5
+ end
6
+ end
@@ -0,0 +1,208 @@
1
+ <div style="margin: 10px 10px 10px 10px">
2
+ <form class="layui-form layui-form-pane" lay-filter="search_follows">
3
+ <div class="layui-form-item">
4
+ <div class="layui-inline">
5
+ <label class="layui-form-label">活动名称</label>
6
+ <div class="layui-input-inline">
7
+ <input type="text" name="name" class="layui-input">
8
+ </div>
9
+ </div>
10
+ <div class="layui-inline">
11
+ <label class="layui-form-label">最新进展</label>
12
+ <div class="layui-input-inline">
13
+ <input type="text" name="description" class="layui-input">
14
+ </div>
15
+ </div>
16
+ <div class="layui-inline">
17
+ <label class="layui-form-label">销售经理</label>
18
+ <div class="layui-input-inline">
19
+ <%= select_tag "sales_id", options_for_select(EducodeSales::Staff.all.map{|d| [d.user&.real_name, d.id]}), { include_blank: true } %>
20
+ </div>
21
+ </div>
22
+
23
+ <div class="layui-inline">
24
+ <button type="reset" class="layui-btn layui-btn-primary" lay-submit lay-filter="reset_follows_search">重置
25
+ </button>
26
+ <button type="submit" class="layui-btn layui-btn-primary" lay-submit lay-filter="search_follows">搜 索
27
+ </button>
28
+ </div>
29
+ </div>
30
+ </form>
31
+ </div>
32
+ <div class="">
33
+ <table class="layui-hide" id="activity_followp_table" style="min-height: 300px;" lay-filter="activity_followp_table"></table>
34
+ </div>
35
+ <script type="text/html" id="currentTableBar_follows">
36
+ <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="detail">详情</a>
37
+ </script>
38
+ <script type="text/html" id="teacher_name">
39
+ {{# if (d.login) { }}
40
+ <a href="<%= base_url%>/users/{{d.login}}" class="layui-table-link" target="_blank">{{ d.teacher }}</a>
41
+ {{# } else {}}
42
+ <a href="javascript:;" class="">{{ d.teacher }}</a>
43
+ {{# }}}
44
+ </script>
45
+ <script type="text/html" id="school">
46
+ <a href="<%= base_url%>/colleges/{{d.school_id}}/statistics" class="layui-table-link" target="_blank">{{ d.school }}</a>
47
+ </script>
48
+
49
+
50
+ <script>
51
+ layui.use(['form', 'table', 'miniPage', 'element', 'request', 'laydate'], function () {
52
+ var $ = layui.jquery,
53
+ form = layui.form,
54
+ request = layui.request,
55
+ dropdown = layui.dropdown,
56
+ miniPage = layui.miniPage,
57
+ laydate = layui.laydate;
58
+
59
+ var laydate = layui.laydate;
60
+
61
+ laydate.render({
62
+ elem: '#follows_date',
63
+ range: true
64
+ });
65
+
66
+ table = layui.table;
67
+ table.render({
68
+ elem: '#activity_followp_table',
69
+ url: '/missions/activities/follow_ups',
70
+ defaultToolbar: ['filter'],
71
+ initSort: {
72
+ field: 'created_at' ,type: 'desc' //排序方式 asc: 升序、desc: 降序、null: 默认排序
73
+ },
74
+ cols: [
75
+ [
76
+ {
77
+ field: 'id',
78
+ width: 60,
79
+ title:'序号',type: 'numbers',
80
+ },
81
+ {
82
+ field: 'description',
83
+ title: '最新进展',
84
+ width: 300,
85
+ templet:'<div><span title="{{d.description}}">{{d.description}}</span></div>'
86
+ },
87
+ {
88
+ width: 120,
89
+ title: '活动名称',
90
+ field: 'name'
91
+ },
92
+ {
93
+ field: 'state_id',
94
+ width: 150,
95
+ title: '活动状态',
96
+ },
97
+ {
98
+ field: 'staff',
99
+ width: 150,
100
+ title: '销售经理',
101
+ },
102
+ {
103
+ field: 'staff_manage',
104
+ title: '生态经理',
105
+ width: 150,
106
+ },
107
+ {
108
+ field: 'info_id',
109
+ width: 160,
110
+ title: '信息类型',
111
+ },
112
+ {
113
+ field: 'follow_up',
114
+ width: 120,
115
+ title: '最新跟进人',
116
+ },
117
+ {
118
+ field: 'created_at',
119
+ width: 180,
120
+ title: '跟进时间',
121
+ sort: true,
122
+ },
123
+ {
124
+ field: 'advise',
125
+ width: 120,
126
+ title: '团队建议',
127
+ templet:'<div><span title="{{d.advise}}">{{d.advise}}</span></div>'
128
+ },
129
+ // {
130
+ // title: '操作',
131
+ // width: 80,
132
+ // toolbar: '#currentTableBar_follows',
133
+ // align: "center",
134
+ // fixed: 'right'
135
+ // }
136
+ ]
137
+ ],
138
+ limit: 20,
139
+ page: true,
140
+ limits: [10,15,20,30,40,50,60,70,80,90]
141
+ });
142
+
143
+ var sort = {}, search = {};
144
+ table.on('sort(activity_followp_table)', function (obj) {
145
+ sort.field = obj.field;
146
+ sort.order = obj.type;
147
+ table.reload('activity_followp_table', {
148
+ initSort: obj,
149
+ where: {
150
+ sort: sort,
151
+ q: search
152
+ }
153
+ });
154
+ })
155
+
156
+ // 监听搜索操作
157
+ form.on('submit(search_follows)', function (data) {
158
+ search = data.field
159
+ table.reload('activity_followp_table', {
160
+ page: {
161
+ curr: 1
162
+ },
163
+ where: {q: search, sort: sort}
164
+ }, 'data');
165
+
166
+ return false;
167
+ });
168
+
169
+ form.on('submit(reset_follows_search)', function (data) {
170
+ var field = data.field;
171
+ form.val('search_follows', {
172
+ name: "",
173
+ description: "",
174
+ staff_id: ""
175
+ })
176
+ return false;
177
+ });
178
+
179
+
180
+ table.on('tool(activity_followp_table)', function (obj) {
181
+ var data = obj.data;
182
+ id = data.teacher_id;
183
+ if (obj.event === 'detail') { // 监听添加操作
184
+ content = miniPage.getHrefContent('/missions/teachers/show_follow?id=' + data.teacher_id);
185
+ openWH = miniPage.getOpenWidthHeight();
186
+ index = layer.open({
187
+ title: '跟进记录',
188
+ type: 1,
189
+ shade: 0.2,
190
+ maxmin: true,
191
+ shadeClose: true,
192
+ area: [openWH[0] + 'px', openWH[1] + 'px'],
193
+ offset: [openWH[2] + 'px', openWH[3] + 'px'],
194
+ content: content
195
+ });
196
+ $(window).on("resize", function () {
197
+ layer.full(index);
198
+ });
199
+ }
200
+ });
201
+
202
+ });
203
+ </script>
204
+ <style>
205
+ .layui-table-tool-temp{
206
+ padding-right: 30px; !important;
207
+ }
208
+ </style>