educode_sales 0.6.7 → 0.7.1

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 (36) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/educode_sales/businesses_controller.rb +185 -6
  3. data/app/controllers/educode_sales/customers_controller.rb +48 -15
  4. data/app/controllers/educode_sales/follow_ups_controller.rb +1 -1
  5. data/app/controllers/educode_sales/home_controller.rb +6 -0
  6. data/app/controllers/educode_sales/money_plans_controller.rb +3 -3
  7. data/app/controllers/educode_sales/operation_plans_controller.rb +4 -1
  8. data/app/controllers/educode_sales/plans_controller.rb +2 -1
  9. data/app/controllers/educode_sales/sale_trends_controller.rb +4 -2
  10. data/app/controllers/educode_sales/staffs_controller.rb +31 -0
  11. data/app/controllers/educode_sales/teachers_controller.rb +1 -1
  12. data/app/models/educode_sales/customer_add.rb +4 -0
  13. data/app/models/educode_sales/staff.rb +1 -0
  14. data/app/models/educode_sales/staff_school.rb +6 -0
  15. data/app/views/educode_sales/businesses/get_export_data.json.jbuilder +30 -0
  16. data/app/views/educode_sales/businesses/index.html.erb +103 -10
  17. data/app/views/educode_sales/businesses/index.json.jbuilder +9 -35
  18. data/app/views/educode_sales/businesses/show_follow.html.erb +44 -4
  19. data/app/views/educode_sales/businesses/show_follow.json.jbuilder +2 -0
  20. data/app/views/educode_sales/customers/index.html.erb +30 -1
  21. data/app/views/educode_sales/customers/index.json.jbuilder +12 -0
  22. data/app/views/educode_sales/customers/new.html.erb +106 -53
  23. data/app/views/educode_sales/home/staff_schools.json.jbuilder +9 -0
  24. data/app/views/educode_sales/roles/edit.html.erb +17 -11
  25. data/app/views/educode_sales/sale_trends/trends.html.erb +1 -1
  26. data/app/views/educode_sales/sales/index.json.jbuilder +1 -1
  27. data/app/views/educode_sales/staffs/edit.html.erb +46 -5
  28. data/app/views/educode_sales/staffs/index.html.erb +74 -2
  29. data/app/views/educode_sales/staffs/index.json.jbuilder +1 -0
  30. data/config/routes.rb +2 -0
  31. data/db/migrate/20210902064109_create_educode_sales_role_permissions.rb +5 -0
  32. data/db/migrate/20220121060006_create_educode_sales_business_export_records.rb +10 -0
  33. data/db/migrate/20220125013811_create_educode_sales_staff_schools.rb +10 -0
  34. data/db/migrate/20220125033552_create_educode_sales_customer_adds.rb +9 -0
  35. data/lib/educode_sales/version.rb +1 -1
  36. metadata +9 -2
@@ -88,7 +88,9 @@
88
88
  <script type="text/html" id="bussinessBar">
89
89
  <div class="layui-btn-container">
90
90
  <span class="table-label">商机列表</span>
91
- <a class="layui-btn-xs 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></a>
91
+ <% if can?(:export_business, EducodeSales::Business) %>
92
+ <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>
93
+ <% end %>
92
94
  <% if can? :create, EducodeSales::Business %>
93
95
  <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn pull-right" lay-event="add"> 添加商机</button>
94
96
  <% end %>
@@ -97,15 +99,37 @@
97
99
  </div>
98
100
  </script>
99
101
  <script type="text/html" id="currentTableBar">
100
- <% if can? :add_follow, EducodeSales::Business %>
102
+ <%unless !can?(:add_follow, EducodeSales::Business) && can?(:self_add_follow, EducodeSales::Business)%>
103
+ <% if can? :add_follow, EducodeSales::Business %>
104
+ <% if @current_admin.is_admin %>
105
+ <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="add_event">添加跟进记录</a>
106
+ <% else %>
107
+ {{# if ( d.assign_follow_ups.length > 0 && d.assign_follow_ups.indexOf(d.current_staff_id) >=0 || (d.assign_follow_ups.length == 0) || (d.current_staff_id == d.staff_id) ) {}}
108
+ <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="add_event">添加跟进记录</a>
109
+ {{# }}}
110
+ <% end %>
111
+ <% end %>
112
+ <% end %>
113
+ <%if !can?(:add_follow, EducodeSales::Business) && can?(:self_add_follow, EducodeSales::Business)%>
114
+ {{# if (d.self_flag) {}}
101
115
  <% if @current_admin.is_admin %>
102
116
  <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="add_event">添加跟进记录</a>
103
117
  <% else %>
104
118
  {{# if ( d.assign_follow_ups.length > 0 && d.assign_follow_ups.indexOf(d.current_staff_id) >=0 || (d.assign_follow_ups.length == 0) || (d.current_staff_id == d.staff_id) ) {}}
105
119
  <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="add_event">添加跟进记录</a>
106
120
  {{# }}}
121
+ <% end %>
122
+ {{# }}}
107
123
  <% end %>
108
-
124
+ <%if can?(:update, EducodeSales::Business)%>
125
+ <%unless !can?(:update, EducodeSales::Business) && can?(:self_edit_business, EducodeSales::Business)%>
126
+ <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="edit">编辑</a>
127
+ <% end %>
128
+ <% end %>
129
+ <%if !can?(:update, EducodeSales::Business) && can?(:self_edit_business, EducodeSales::Business)%>
130
+ {{# if (d.self_flag) {}}
131
+ <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="edit">编辑</a>
132
+ {{# }}}
109
133
  <% end %>
110
134
  <% if @more %>
111
135
  <a class="layui-btn-xs data-count-edit more-btn" data-name={{d.name}} data-id={{d.id}}>更多<i class="layui-icon layui-icon-down layui-nav-more"></i></a>
@@ -332,7 +356,7 @@
332
356
  },
333
357
  {
334
358
  field: 'return_money_days',
335
- width: 120,
359
+ width: 150,
336
360
  title: '首次回款周期(天)',
337
361
  },
338
362
  {
@@ -340,9 +364,15 @@
340
364
  width: 160,
341
365
  title: '渠道',
342
366
  },
367
+ {
368
+ field: 'year',
369
+ width: 105,
370
+ title: '所属年度',
371
+ sort: true
372
+ },
343
373
  {
344
374
  title: '操作',
345
- minWidth: 170,
375
+ minWidth: 220,
346
376
  toolbar: '#currentTableBar',
347
377
  align: "center",
348
378
  fixed: 'right'
@@ -355,7 +385,7 @@
355
385
  page: true,
356
386
  skin: 'line',
357
387
  done: function (res) {
358
- exportData=res.data1;
388
+ exportData=res.data;
359
389
  console.log(exportData);
360
390
  drowpdwonRender()
361
391
  export_drowpdwonRender()
@@ -420,14 +450,76 @@
420
450
  }
421
451
 
422
452
  function export_csv() {
423
- table.exportFile(business_table.config.id,exportData, 'csv');
424
- request.get('/missions/businesses/add_export_records?type=csv', {}, function (res) {
453
+ var data = form.val("search_form");
454
+ var business_type = [];
455
+ business_type_list.getValue().forEach(function(d) {
456
+ business_type.push(d.value);
457
+ })
458
+ var business_step = [];
459
+ business_step_list.getValue().forEach(function(d) {
460
+ business_step.push(d.value);
425
461
  })
462
+ data.place_id = index_place_list.getValue('valueStr');
463
+ data.business_type = business_type.toString();
464
+ data.business_step = business_step.toString();
465
+ layer.load(0, {});
466
+ console.log(data);
467
+ request.authPost("/missions/businesses/get_export_data", {
468
+ name: data.name,
469
+ area: data.area,
470
+ business_step: data.business_step,
471
+ business_type: data.business_type,
472
+ date: data.date,
473
+ department: data.department,
474
+ invitation_at: data.invitation_at,
475
+ place_id: data.place_id,
476
+ select: data.select,
477
+ staff_id: data.staff_id
478
+ }, function (res) {
479
+ console.log(res.data);
480
+ data = res.data
481
+ table.exportFile(business_table.config.id,data, 'csv');
482
+ layer.closeAll('loading');
483
+ request.get('/missions/businesses/add_export_records?type=csv', {}, function (res) {
484
+ })
485
+ })
486
+
426
487
  }
427
488
  function export_excel() {
428
- table.exportFile(business_table.config.id,exportData, 'xls');
429
- request.get('/missions/businesses/add_export_records?type=excel', {}, function (res) {
489
+ var data = form.val("search_form");
490
+ var business_type = [];
491
+ business_type_list.getValue().forEach(function(d) {
492
+ business_type.push(d.value);
430
493
  })
494
+ var business_step = [];
495
+ business_step_list.getValue().forEach(function(d) {
496
+ business_step.push(d.value);
497
+ })
498
+ data.place_id = index_place_list.getValue('valueStr');
499
+ data.business_type = business_type.toString();
500
+ data.business_step = business_step.toString();
501
+ layer.load(0, {});
502
+ console.log(data);
503
+ request.authPost("/missions/businesses/get_export_data", {
504
+ name: data.name,
505
+ area: data.area,
506
+ business_step: data.business_step,
507
+ business_type: data.business_type,
508
+ date: data.date,
509
+ department: data.department,
510
+ invitation_at: data.invitation_at,
511
+ place_id: data.place_id,
512
+ select: data.select,
513
+ staff_id: data.staff_id
514
+ }, function (res) {
515
+ console.log(res.data);
516
+ data = res.data
517
+ table.exportFile(business_table.config.id,data, 'xls');
518
+ layer.closeAll('loading');
519
+ request.get('/missions/businesses/add_export_records?type=xls', {}, function (res) {
520
+ })
521
+ })
522
+
431
523
  }
432
524
  function export_records() {
433
525
  var content = miniPage.getHrefContent('/missions/businesses/export_records')
@@ -795,6 +887,7 @@
795
887
  layer.full(index);
796
888
  });
797
889
  } else if (obj.event === 'show_follow') {
890
+ self_flag = data.self_flag
798
891
  business_id = obj.data.id
799
892
  business_name = data.name
800
893
  content = miniPage.getHrefContent('/missions/businesses/show_follow?id=' + id);
@@ -1,4 +1,5 @@
1
- follow_ups_count = 0
1
+ follow_up_ids = EducodeSales::AssignFollowUp.where(staff_id: @current_admin.id).pluck(:follow_up_id)
2
+ follow_count = 0
2
3
  json.data do
3
4
  json.array! @businesses do |d|
4
5
  json.id d.id
@@ -6,8 +7,9 @@ json.data do
6
7
  json.department d.department.name
7
8
  json.school d.department.school.name
8
9
  json.school_id d.department.school.id
9
- json.follow_ups_count d.follow_ups.where(deleted_at: nil).size
10
- follow_ups_count += d.follow_ups_count
10
+ follow_ups_count = d.follow_ups.where(deleted_at: nil).size
11
+ json.follow_ups_count follow_ups_count
12
+ follow_count += follow_ups_count
11
13
  json.follow_up_id d.last_follow_up_id
12
14
  json.clazz d.last_follow_up&.clazz&.name || ""
13
15
  json.stage d.last_follow_up&.stage&.name
@@ -15,6 +17,7 @@ json.data do
15
17
  json.reception_at d.last_follow_up&.reception_at.to_s
16
18
  json.bidded_date d.last_follow_up&.bidded_date.to_s
17
19
  json.signed_date d.last_follow_up&.signed_date.to_s
20
+ json.year d.last_follow_up&.year.to_s
18
21
  json.total_amount d.last_follow_up&.total_amount
19
22
  json.actual_amount d.last_follow_up&.actual_amount
20
23
  json.return_money d.return_money
@@ -27,41 +30,12 @@ json.data do
27
30
  json.current_staff_id @current_admin.id
28
31
  json.staff_id d.staff_id
29
32
  json.latest_time d.last_follow_up.present? ? d.last_follow_up.created_at.to_s : ''
30
- end
31
- end
32
- json.data1 do
33
- json.array! @businesses_exports do |d|
34
- json.id d.id
35
- json.name d.name
36
- json.department d.department.name
37
- json.school d.department.school.name
38
- json.school_id d.department.school.id
39
- json.follow_ups_count d.follow_ups.where(deleted_at: nil).size
40
- follow_ups_count += d.follow_ups_count
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
48
- json.total_amount d.last_follow_up&.total_amount
49
- json.actual_amount d.last_follow_up&.actual_amount
50
- json.return_money d.return_money
51
- json.wait_return_money d.wait_return_money.to_i.round(2)
52
- 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 : ''
53
- json.place d.last_follow_up&.place&.name
54
- 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
55
- json.source d.source
56
- json.assign_follow_ups d.last_follow_up.present? ? d.last_follow_up.assign_follow_ups.pluck(:staff_id) : []
57
- json.current_staff_id @current_admin.id
58
- json.staff_id d.staff_id
59
- json.latest_time d.last_follow_up.present? ? d.last_follow_up.created_at.to_s : ''
60
- end
33
+ json.self_flag (d.staff_id == @current_admin.id) || (d.last_follow_up_id.in? follow_up_ids)
34
+ end
61
35
  end
62
36
 
63
37
  json.totalRow do
64
- json.follow_ups_count follow_ups_count.to_s
38
+ json.follow_ups_count follow_count.to_i.to_s
65
39
  end
66
40
  json.code 0
67
41
  json.count @businesses.total_count
@@ -2,13 +2,22 @@
2
2
  <div class="layui-btn-container">
3
3
  <span class="table-label">跟进记录</span>
4
4
  <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn pull-right" lay-event="time_line"> 时间线视图>></button>
5
- <% if can? :add_follow, EducodeSales::Business %>
5
+ <%unless !can?(:add_follow, EducodeSales::Business) && can?(:self_add_follow, EducodeSales::Business)%>
6
+ <% if can? :add_follow, EducodeSales::Business %>
6
7
  <% if @current_admin.is_admin %>
7
8
  <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn pull-right" lay-event="add"> 添加跟进记录</button>
8
9
  <% elsif @business.staff_id == @current_admin.id || @business.last_follow_up.nil? || @business.last_follow_up.assign_follow_ups.blank? || (@business.last_follow_up.assign_follow_ups.pluck(:staff_id).include?(@current_admin.id)) %>
9
10
  <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn pull-right" lay-event="add"> 添加跟进记录</button>
10
11
  <% end %>
11
12
  <% end %>
13
+ <% end %>
14
+ <%if !can?(:add_follow, EducodeSales::Business) && can?(:self_add_follow, EducodeSales::Business)%>
15
+ <% if @current_admin.is_admin %>
16
+ <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn pull-right add_follow" lay-event="add"> 添加跟进记录</button>
17
+ <% elsif @business.staff_id == @current_admin.id || @business.last_follow_up.nil? || @business.last_follow_up.assign_follow_ups.blank? || (@business.last_follow_up.assign_follow_ups.pluck(:staff_id).include?(@current_admin.id)) %>
18
+ <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn pull-right add_follow" lay-event="add"> 添加跟进记录</button>
19
+ <% end %>
20
+ <% end %>
12
21
  <span class="table-label pull-right" style="padding-right: 20px">温馨提示:仅可以在24小时之内,编辑/删除最新的跟进记录</span>
13
22
  </div>
14
23
  </script>
@@ -23,16 +32,37 @@
23
32
  <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="show">查看</a>
24
33
  <% end %>
25
34
  {{# if(d.is_latest && d.flag){ }}
26
- <% if can? :update_follow, EducodeSales::Business %>
35
+
36
+ <%unless !can?(:update_follow, EducodeSales::Business) && can?(:self_edit_follow, EducodeSales::Business)%>
37
+ <% if can? :update_follow, EducodeSales::Business %>
27
38
  <% if @current_admin.is_admin %>
28
39
  <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="edit">编辑</a>
29
40
  <% elsif @business.staff_id == @current_admin.id || @business.last_follow_up.nil? || @business.last_follow_up.assign_follow_ups.blank? || (@business.last_follow_up.assign_follow_ups.pluck(:staff_id).include?(@current_admin.id)) %>
30
41
  <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="edit">编辑</a>
31
42
  <% end %>
32
43
  <% end %>
33
- <% if can? :destroy_follow, EducodeSales::Business %>
44
+ <% end %>
45
+
46
+ <%if !can?(:update_follow, EducodeSales::Business) && can?(:self_edit_follow, EducodeSales::Business)%>
47
+ {{# if(d.self_flag){ }}
48
+ <% if @current_admin.is_admin %>
49
+ <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="edit">编辑</a>
50
+ <% elsif @business.staff_id == @current_admin.id || @business.last_follow_up.nil? || @business.last_follow_up.assign_follow_ups.blank? || (@business.last_follow_up.assign_follow_ups.pluck(:staff_id).include?(@current_admin.id)) %>
51
+ <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="edit">编辑</a>
52
+ <% end %>
53
+ {{# } }}
54
+ <% end %>
55
+
56
+ <%unless !can?(:destroy_follow, EducodeSales::Business) && can?(:self_delete_follow, EducodeSales::Business)%>
57
+ <% if can? :destroy_follow, EducodeSales::Business %>
34
58
  <a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="delete">删除</a>
35
59
  <% end %>
60
+ <% end %>
61
+ <%if !can?(:destroy_follow, EducodeSales::Business) && can?(:self_delete_follow, EducodeSales::Business)%>
62
+ {{# if(d.self_flag){ }}
63
+ <a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="delete">删除</a>
64
+ {{# } }}
65
+ <% end %>
36
66
  {{# } }}
37
67
  </script>
38
68
 
@@ -166,9 +196,15 @@
166
196
 
167
197
  {
168
198
  field: 'place',
169
- width: 400,
199
+ width: 120,
170
200
  title: '渠道',
171
201
  },
202
+ {
203
+ field: 'year',
204
+ width: 120,
205
+ title: '所属年度',
206
+ sort: true
207
+ },
172
208
  {
173
209
  title: '操作',
174
210
  minWidth: 200,
@@ -201,6 +237,10 @@
201
237
  });
202
238
  })
203
239
 
240
+ if(!parent.self_flag){
241
+ $('.add_follow').addClass("layui-hide");
242
+ }
243
+
204
244
  table.on('toolbar(sale_plan_follow_table)', function (obj) {
205
245
  if (obj.event === 'add') { // 监听添加操作
206
246
  business_id = parent.business_id
@@ -19,6 +19,8 @@ json.data do
19
19
  json.is_latest d.id == @latest&.id
20
20
  json.flag d.created_at.present? ? (Time.now - d.created_at).to_f/3600 < 24 : false
21
21
  json.description d.description
22
+ json.year d.year
23
+ json.self_flag d.staff_id == @current_admin.id
22
24
  end
23
25
  end
24
26
 
@@ -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
@@ -122,6 +140,7 @@
122
140
  {
123
141
  field: 'name',
124
142
  title: '客户名称',
143
+ width: 150,
125
144
  templet: "#name"
126
145
  },
127
146
  {
@@ -129,6 +148,10 @@
129
148
  width: 100,
130
149
  title: '区域',
131
150
  },
151
+ {
152
+ field: 'property',
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-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="企业">
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
- data.field.province = $("#province option:selected").text(); //获取选中的项
342
- data.field.city = $("#city option:selected").text(); //获取选中的项
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) {
@@ -0,0 +1,9 @@
1
+ json.data do
2
+ json.array! @schools do |d|
3
+ json.value d.id
4
+ json.name "#{d.name}-#{d.province}"
5
+ end
6
+ end
7
+ json.count @schools.size
8
+ json.code 0
9
+ json.msg "success"