educode_sales 0.6.8 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/educode_sales/businesses_controller.rb +191 -7
  3. data/app/controllers/educode_sales/customers_controller.rb +48 -15
  4. data/app/controllers/educode_sales/follow_ups_controller.rb +2 -2
  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 +118 -116
  10. data/app/controllers/educode_sales/staffs_controller.rb +12 -0
  11. data/app/controllers/educode_sales/teachers_controller.rb +1 -1
  12. data/app/helpers/educode_sales/follow_up_helper.rb +7 -0
  13. data/app/models/educode_sales/customer_add.rb +4 -0
  14. data/app/models/educode_sales/money_plan.rb +3 -3
  15. data/app/models/educode_sales/staff.rb +1 -0
  16. data/app/models/educode_sales/staff_school.rb +6 -0
  17. data/app/views/educode_sales/businesses/edit_plan.html.erb +4 -4
  18. data/app/views/educode_sales/businesses/export_records.json.jbuilder +1 -2
  19. data/app/views/educode_sales/businesses/get_export_data.json.jbuilder +30 -0
  20. data/app/views/educode_sales/businesses/index.html.erb +209 -100
  21. data/app/views/educode_sales/businesses/index.json.jbuilder +6 -32
  22. data/app/views/educode_sales/businesses/show_follow.html.erb +49 -8
  23. data/app/views/educode_sales/businesses/show_follow.json.jbuilder +2 -0
  24. data/app/views/educode_sales/customers/index.html.erb +30 -1
  25. data/app/views/educode_sales/customers/index.json.jbuilder +12 -0
  26. data/app/views/educode_sales/customers/new.html.erb +106 -53
  27. data/app/views/educode_sales/customers/show_follow.html.erb +1 -1
  28. data/app/views/educode_sales/follow_ups/index.json.jbuilder +1 -1
  29. data/app/views/educode_sales/follow_ups/money_plans.json.jbuilder +2 -4
  30. data/app/views/educode_sales/home/staff_schools.json.jbuilder +9 -0
  31. data/app/views/educode_sales/money_plans/index.html.erb +1 -1
  32. data/app/views/educode_sales/operation_plans/_monthPlan.html.erb +8 -3
  33. data/app/views/educode_sales/operation_plans/_monthly.html.erb +2 -2
  34. data/app/views/educode_sales/operation_plans/_weekPlan.html.erb +2 -2
  35. data/app/views/educode_sales/operation_plans/_weekly.html.erb +2 -2
  36. data/app/views/educode_sales/plans/_monthPlan.html.erb +8 -3
  37. data/app/views/educode_sales/plans/_monthly.html.erb +2 -2
  38. data/app/views/educode_sales/plans/_weekPlan.html.erb +2 -2
  39. data/app/views/educode_sales/plans/_weekly.html.erb +2 -2
  40. data/app/views/educode_sales/roles/edit.html.erb +17 -11
  41. data/app/views/educode_sales/sale_reports/audit.html.erb +2 -0
  42. data/app/views/educode_sales/sale_reports/edit.html.erb +2 -0
  43. data/app/views/educode_sales/sale_reports/show.html.erb +2 -0
  44. data/app/views/educode_sales/sale_trends/trends.html.erb +1 -1
  45. data/app/views/educode_sales/sales/index.html.erb +7 -7
  46. data/app/views/educode_sales/sales/index.json.jbuilder +1 -1
  47. data/app/views/educode_sales/staffs/edit.html.erb +46 -5
  48. data/app/views/educode_sales/staffs/index.html.erb +6 -0
  49. data/app/views/educode_sales/staffs/index.json.jbuilder +1 -0
  50. data/app/views/educode_sales/teachers/show_follow.html.erb +1 -1
  51. data/config/routes.rb +2 -0
  52. data/db/migrate/20210902064109_create_educode_sales_role_permissions.rb +5 -0
  53. data/db/migrate/20220125013811_create_educode_sales_staff_schools.rb +10 -0
  54. data/db/migrate/20220125033552_create_educode_sales_customer_adds.rb +9 -0
  55. data/lib/educode_sales/version.rb +1 -1
  56. metadata +9 -2
@@ -57,6 +57,12 @@
57
57
  <%= select_tag "area", options_for_select(EducodeSales::Common.where(clazz: 'area').pluck(:name, :id)), { include_blank: true } %>
58
58
  </div>
59
59
  </div>
60
+ <div class="layui-inline show_item" style="display:none;">
61
+ <label class="layui-form-label">所属年度</label>
62
+ <div class="layui-input-inline">
63
+ <%= select_tag "business_year", options_for_select((2015..Time.now.year).to_a.reverse, params[:business_year]), { include_blank: true } %>
64
+ </div>
65
+ </div>
60
66
  <div class="layui-inline show_item" style="display:none;">
61
67
  <label class="layui-form-label">创建时间</label>
62
68
  <div class="layui-input-inline">
@@ -88,7 +94,9 @@
88
94
  <script type="text/html" id="bussinessBar">
89
95
  <div class="layui-btn-container">
90
96
  <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>
97
+ <% if can?(:export_business, EducodeSales::Business) %>
98
+ <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" style="font-size: 12px"></i></button>
99
+ <% end %>
92
100
  <% if can? :create, EducodeSales::Business %>
93
101
  <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn pull-right" lay-event="add"> 添加商机</button>
94
102
  <% end %>
@@ -97,15 +105,37 @@
97
105
  </div>
98
106
  </script>
99
107
  <script type="text/html" id="currentTableBar">
100
- <% if can? :add_follow, EducodeSales::Business %>
108
+ <%unless !can?(:add_follow, EducodeSales::Business) && can?(:self_add_follow, EducodeSales::Business)%>
109
+ <% if can? :add_follow, EducodeSales::Business %>
110
+ <% if @current_admin.is_admin %>
111
+ <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="add_event">添加跟进记录</a>
112
+ <% else %>
113
+ {{# 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) ) {}}
114
+ <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="add_event">添加跟进记录</a>
115
+ {{# }}}
116
+ <% end %>
117
+ <% end %>
118
+ <% end %>
119
+ <%if !can?(:add_follow, EducodeSales::Business) && can?(:self_add_follow, EducodeSales::Business)%>
120
+ {{# if (d.self_flag) {}}
101
121
  <% if @current_admin.is_admin %>
102
122
  <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="add_event">添加跟进记录</a>
103
123
  <% else %>
104
124
  {{# 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
125
  <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="add_event">添加跟进记录</a>
106
126
  {{# }}}
127
+ <% end %>
128
+ {{# }}}
129
+ <% end %>
130
+ <%if can?(:update, EducodeSales::Business)%>
131
+ <%unless !can?(:update, EducodeSales::Business) && can?(:self_edit_business, EducodeSales::Business)%>
132
+ <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="edit">编辑</a>
107
133
  <% end %>
108
-
134
+ <% end %>
135
+ <%if !can?(:update, EducodeSales::Business) && can?(:self_edit_business, EducodeSales::Business)%>
136
+ {{# if (d.self_flag) {}}
137
+ <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="edit">编辑</a>
138
+ {{# }}}
109
139
  <% end %>
110
140
  <% if @more %>
111
141
  <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>
@@ -118,35 +148,45 @@
118
148
  <a href="javascript:void(0);" lay-event="show_follow" class="layui-table-link">{{ d.follow_ups_count }}</a>
119
149
  </script>
120
150
  <script type="text/html" id="school_name">
121
- <a href="<%= base_url%>/colleges/{{d.school_id}}/statistics" class="layui-table-link" target="_blank">{{ d.school }}</a>
151
+ <a href="<%= base_url%>/colleges/{{d.school_id}}/statistics" class="layui-table-link" target="_blank">{{ d.school
152
+ }}</a>
122
153
  </script>
123
154
 
124
155
 
125
156
  <script>
126
157
  layui.use(['form', 'table', 'miniPage', 'element', 'request', 'laydate', 'dropdown'], function () {
127
- var $ = layui.jquery,
128
- form = layui.form,
129
- request = layui.request,
130
- miniPage = layui.miniPage,
131
- dropdown = layui.dropdown,
132
- laydate = layui.laydate;
133
-
134
- laydate.render({
135
- elem: '#date',
136
- range: true
137
- });
138
- laydate.render({
139
- elem: '#invitation_at',
140
- range: true
141
- });
158
+ var $ = layui.jquery,
159
+ form = layui.form,
160
+ request = layui.request,
161
+ miniPage = layui.miniPage,
162
+ dropdown = layui.dropdown,
163
+ laydate = layui.laydate;
164
+
165
+ laydate.render({
166
+ elem: '#date',
167
+ range: true
168
+ });
169
+ laydate.render({
170
+ elem: '#invitation_at',
171
+ range: true
172
+ });
142
173
 
143
- var is_show = <%=params[:name].present? || params[:clazz_id].present? || params[:place_id].present? || params[:school].present? %>
144
- if(is_show){
145
- $('.follows_li').removeClass('layui-this');
146
- $('.follows_div').removeClass('layui-show');
147
- $('.businesses_list_li').addClass('layui-this');
148
- $('.businesses_list_div').addClass('layui-show');
149
- }
174
+ // function hn() {
175
+ // $("#search_bt").trigger("click");
176
+ // }
177
+ //
178
+ // $(document).ready(function () {
179
+ // window.onload = hn;
180
+ // });
181
+
182
+ var is_show =
183
+ <%=params[:name].present? || params[:clazz_id].present? || params[:place_id].present? || params[:school].present? %>
184
+ if (is_show) {
185
+ $('.follows_li').removeClass('layui-this');
186
+ $('.follows_div').removeClass('layui-show');
187
+ $('.businesses_list_li').addClass('layui-this');
188
+ $('.businesses_list_div').addClass('layui-show');
189
+ }
150
190
 
151
191
  var business_type_list = xmSelect.render({
152
192
  el: '#business_type',
@@ -200,62 +240,68 @@
200
240
  })
201
241
  }
202
242
  })
203
- index_place_list.setValue(gon.place)
204
-
205
-
206
- table = layui.table;
207
- var business_table = table.render({
208
- elem: '#businesses_table',
209
- url: '/missions/businesses',
210
- where: {q: form.val('search_form')},
211
- defaultToolbar: ['filter'],
212
- toolbar: '#bussinessBar',
213
- title: '商机数据表',
214
- totalRow: true,//开启合并行
215
- cols: [
216
- [
217
- {
218
- field: 'id',
219
- width: 60,
220
- title:'序号',type: 'numbers',
221
- totalRowText: '合计',
222
- },
223
- {
224
- field: 'name',
225
- width: 170,
226
- title: '名称',
227
- templet:'<div><span title="{{d.name}}">{{d.name}}</span></div>'
228
- },
229
- {
230
- field: 'school',
231
- width: 150,
232
- title: '单位',
233
- templet:'#school_name'
234
- },
235
- {
236
- field: 'department',
237
- width: 150,
238
- title: '部门',
239
- templet:'<div><span title="{{d.department}}">{{d.department}}</span></div>'
240
- },
241
- {
242
- field: 'follow_ups_count',
243
- title: '跟进',
244
- width: 60,
245
- templet: '#show_follow',
246
- totalRow: true,
247
- },
248
- // {
249
- // field: 'teachers_count',
250
- // width: 100,
251
- // title: '关键人',
252
- // templet: '#show_keys'
253
- // },
254
- {
255
- field: 'clazz',
256
- width: 80,
257
- title: '类型',
258
- templet:'<div><span title="{{d.clazz}}">{{d.clazz}}</span></div>'
243
+ index_place_list.setValue(gon.place)
244
+
245
+
246
+ var data = form.val("search_form");
247
+ data.business_type = <%=params[:clazz_id] %>
248
+ console.log(data);
249
+
250
+ table = layui.table;
251
+ var business_table = table.render({
252
+ elem: '#businesses_table',
253
+ url: '/missions/businesses',
254
+ where: {q: data},
255
+ defaultToolbar: ['filter'],
256
+ toolbar: '#bussinessBar',
257
+ title: '商机数据表',
258
+ totalRow: true,//开启合并行
259
+ cols: [
260
+ [
261
+ {
262
+ field: 'id',
263
+ width: 60,
264
+ title: '序号', type: 'numbers',
265
+ totalRowText: '合计',
266
+ fixed: "left"
267
+ },
268
+ {
269
+ field: 'name',
270
+ width: 170,
271
+ title: '商机名称',
272
+ templet: '<div><span title="{{d.name}}">{{d.name}}</span></div>',
273
+ fixed: 'left'
274
+ },
275
+ {
276
+ field: 'school',
277
+ width: 150,
278
+ title: '单位',
279
+ templet: '#school_name'
280
+ },
281
+ {
282
+ field: 'department',
283
+ width: 150,
284
+ title: '部门',
285
+ templet: '<div><span title="{{d.department}}">{{d.department}}</span></div>'
286
+ },
287
+ {
288
+ field: 'follow_ups_count',
289
+ title: '跟进',
290
+ width: 60,
291
+ templet: '#show_follow',
292
+ totalRow: true,
293
+ },
294
+ // {
295
+ // field: 'teachers_count',
296
+ // width: 100,
297
+ // title: '关键人',
298
+ // templet: '#show_keys'
299
+ // },
300
+ {
301
+ field: 'clazz',
302
+ width: 80,
303
+ title: '类型',
304
+ templet: '<div><span title="{{d.clazz}}">{{d.clazz}}</span></div>'
259
305
  },
260
306
  {
261
307
  field: 'stage',
@@ -332,7 +378,7 @@
332
378
  },
333
379
  {
334
380
  field: 'return_money_days',
335
- width: 120,
381
+ width: 150,
336
382
  title: '首次回款周期(天)',
337
383
  },
338
384
  {
@@ -340,9 +386,15 @@
340
386
  width: 160,
341
387
  title: '渠道',
342
388
  },
389
+ {
390
+ field: 'year',
391
+ width: 105,
392
+ title: '所属年度',
393
+ sort: true
394
+ },
343
395
  {
344
396
  title: '操作',
345
- minWidth: 170,
397
+ minWidth: 220,
346
398
  toolbar: '#currentTableBar',
347
399
  align: "center",
348
400
  fixed: 'right'
@@ -355,7 +407,7 @@
355
407
  page: true,
356
408
  skin: 'line',
357
409
  done: function (res) {
358
- exportData=res.data1;
410
+ exportData=res.data;
359
411
  console.log(exportData);
360
412
  drowpdwonRender()
361
413
  export_drowpdwonRender()
@@ -420,14 +472,76 @@
420
472
  }
421
473
 
422
474
  function export_csv() {
423
- table.exportFile(business_table.config.id,exportData, 'csv');
424
- request.get('/missions/businesses/add_export_records?type=csv', {}, function (res) {
475
+ var data = form.val("search_form");
476
+ var business_type = [];
477
+ business_type_list.getValue().forEach(function(d) {
478
+ business_type.push(d.value);
479
+ })
480
+ var business_step = [];
481
+ business_step_list.getValue().forEach(function(d) {
482
+ business_step.push(d.value);
425
483
  })
484
+ data.place_id = index_place_list.getValue('valueStr');
485
+ data.business_type = business_type.toString();
486
+ data.business_step = business_step.toString();
487
+ layer.load(0, {});
488
+ console.log(data);
489
+ request.authPost("/missions/businesses/get_export_data", {
490
+ name: data.name,
491
+ area: data.area,
492
+ business_step: data.business_step,
493
+ business_type: data.business_type,
494
+ date: data.date,
495
+ department: data.department,
496
+ invitation_at: data.invitation_at,
497
+ place_id: data.place_id,
498
+ select: data.select,
499
+ staff_id: data.staff_id
500
+ }, function (res) {
501
+ console.log(res.data);
502
+ data = res.data
503
+ table.exportFile(business_table.config.id,data, 'csv');
504
+ layer.closeAll('loading');
505
+ request.get('/missions/businesses/add_export_records?type=csv', {}, function (res) {
506
+ })
507
+ })
508
+
426
509
  }
427
510
  function export_excel() {
428
- table.exportFile(business_table.config.id,exportData, 'xls');
429
- request.get('/missions/businesses/add_export_records?type=excel', {}, function (res) {
511
+ var data = form.val("search_form");
512
+ var business_type = [];
513
+ business_type_list.getValue().forEach(function(d) {
514
+ business_type.push(d.value);
430
515
  })
516
+ var business_step = [];
517
+ business_step_list.getValue().forEach(function(d) {
518
+ business_step.push(d.value);
519
+ })
520
+ data.place_id = index_place_list.getValue('valueStr');
521
+ data.business_type = business_type.toString();
522
+ data.business_step = business_step.toString();
523
+ layer.load(0, {});
524
+ console.log(data);
525
+ request.authPost("/missions/businesses/get_export_data", {
526
+ name: data.name,
527
+ area: data.area,
528
+ business_step: data.business_step,
529
+ business_type: data.business_type,
530
+ date: data.date,
531
+ department: data.department,
532
+ invitation_at: data.invitation_at,
533
+ place_id: data.place_id,
534
+ select: data.select,
535
+ staff_id: data.staff_id
536
+ }, function (res) {
537
+ console.log(res.data);
538
+ data = res.data
539
+ table.exportFile(business_table.config.id,data, 'xls');
540
+ layer.closeAll('loading');
541
+ request.get('/missions/businesses/add_export_records?type=xls', {}, function (res) {
542
+ })
543
+ })
544
+
431
545
  }
432
546
  function export_records() {
433
547
  var content = miniPage.getHrefContent('/missions/businesses/export_records')
@@ -547,12 +661,6 @@
547
661
  });
548
662
  }
549
663
 
550
- function hn(){
551
- $("#search_bt").trigger("click");
552
- }
553
- $(document).ready(function(){
554
- window.onload=hn;
555
- });
556
664
 
557
665
 
558
666
  var sort = {}, search = {};
@@ -607,11 +715,11 @@
607
715
  return false;
608
716
  });
609
717
  form.on('submit(reset_business_search)', function (data) {
610
- var field = data.field;
611
- form.val('search_form', {
612
- name: '', department: '', staff_id: '', business_type: '', business_step: '',
613
- place_id: '', date: '', area: '', invitation_at: ''
614
- })
718
+ var field = data.field;
719
+ form.val('search_form', {
720
+ name: '', department: '', staff_id: '', business_type: '', business_step: '',
721
+ place_id: '', date: '', area: '', invitation_at: '', business_year: ''
722
+ })
615
723
  business_type_list.setValue([])
616
724
  business_step_list.setValue([])
617
725
  index_place_list.setValue([])
@@ -795,6 +903,7 @@
795
903
  layer.full(index);
796
904
  });
797
905
  } else if (obj.event === 'show_follow') {
906
+ self_flag = data.self_flag
798
907
  business_id = obj.data.id
799
908
  business_name = data.name
800
909
  content = miniPage.getHrefContent('/missions/businesses/show_follow?id=' + id);
@@ -1,3 +1,4 @@
1
+ follow_up_ids = EducodeSales::AssignFollowUp.where(staff_id: @current_admin.id).pluck(:follow_up_id)
1
2
  follow_count = 0
2
3
  json.data do
3
4
  json.array! @businesses do |d|
@@ -16,11 +17,12 @@ json.data do
16
17
  json.reception_at d.last_follow_up&.reception_at.to_s
17
18
  json.bidded_date d.last_follow_up&.bidded_date.to_s
18
19
  json.signed_date d.last_follow_up&.signed_date.to_s
20
+ json.year d.last_follow_up&.year.to_s
19
21
  json.total_amount d.last_follow_up&.total_amount
20
22
  json.actual_amount d.last_follow_up&.actual_amount
21
23
  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.wait_return_money d.wait_return_money.to_f.round(2)
25
+ 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
26
  json.place d.last_follow_up&.place&.name
25
27
  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
28
  json.source d.source
@@ -28,36 +30,8 @@ json.data do
28
30
  json.current_staff_id @current_admin.id
29
31
  json.staff_id d.staff_id
30
32
  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
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
@@ -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 %>
38
+ <% if @current_admin.is_admin %>
39
+ <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="edit">编辑</a>
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)) %>
41
+ <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="edit">编辑</a>
42
+ <% end %>
43
+ <% end %>
44
+ <% end %>
45
+
46
+ <%if !can?(:update_follow, EducodeSales::Business) && can?(:self_edit_follow, EducodeSales::Business)%>
47
+ {{# if(d.self_flag){ }}
27
48
  <% if @current_admin.is_admin %>
28
49
  <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="edit">编辑</a>
29
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)) %>
30
51
  <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="edit">编辑</a>
31
52
  <% end %>
53
+ {{# } }}
32
54
  <% end %>
33
- <% if can? :destroy_follow, EducodeSales::Business %>
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
 
@@ -45,7 +75,7 @@
45
75
  <script type="text/html" id="edit_plan">
46
76
  <a href="javascript:void(0);" lay-event="edit_plan" class="layui-table-link">{{ d.money_plans_count }}</a>
47
77
  </script>
48
- <!--未完成计划列表-->
78
+ <!--计划回款计划列表-->
49
79
  <script type="text/html" id="unfinish_table_tabar">
50
80
  <div class="layui-btn-container">
51
81
  <span class="table-label">跟进计划列表</span>
@@ -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
@@ -315,10 +355,11 @@
315
355
  layer.full(keyindex);
316
356
  });
317
357
  } else if (obj.event === 'edit_plan') {
318
- content = miniPage.getHrefContent('/missions/businesses/edit_plan');
319
- openWH = miniPage.getOpenWidthHeight();
320
358
  is_latest = obj.data.is_latest
321
359
  flag = obj.data.flag
360
+ follow_up_id = obj.data.id
361
+ content = miniPage.getHrefContent('/missions/businesses/edit_plan');
362
+ openWH = miniPage.getOpenWidthHeight();
322
363
  plan_index = layer.open({
323
364
  title: '回款计划',
324
365
  type: 1,
@@ -339,7 +380,7 @@
339
380
  }
340
381
  });
341
382
 
342
- // 未完成计划
383
+ // 计划回款计划
343
384
  table.render({
344
385
  elem: '#unfinish_table',
345
386
  url: '/missions/businesses/' + parent.business_id + "/unfinish_plans",
@@ -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