educode_sales 0.9.20 → 0.9.21

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 482f37ccd129a5ea2fab08879a380aeed531a2026aac73a42528e6ee653a9aae
4
- data.tar.gz: 27893e5d818e5bf26ec582dfed97bc1793f822fb818a5c2ec7311dea47439e13
3
+ metadata.gz: 1a49e1fe26099afa0e25a1542fe775e0433f635c3573e4f05c6ea6f3668446d5
4
+ data.tar.gz: 9a461d3ec11c8edf2e6a2a0ff5af5935e97e49f7604203cdaf1bdcc3f5e22ad8
5
5
  SHA512:
6
- metadata.gz: 0a416d26f945870f4c40587ec1fd0f89d3c661f671d5162b4643f79bdd9bc4d23d05025b07604dbc459f05e2df660f1f1898cd1c4cf6101da472586a27b265f3
7
- data.tar.gz: d45d9f2fd66387be4c58a46e072b21a80ec9b1285283a77f0cb9dbe11eb7b034ff503dae8fa01dc89422977b47315df4916c96d78f4d06224a64527eb0953bb7
6
+ metadata.gz: 535bb72b0065d1fab5ebc6e7aef7d439f8ebdc6511ad9b15fbaf464404c043d937ccb6155e171f935d5e08b5431514e1aeb2f068e96736704616a5b0c06f9ca6
7
+ data.tar.gz: 8b31c2724ce9fe79f94cd1f8a0ce91045b0833ec2524476037827587fbc708c7507886c46b76511885c425906de6c84cc1219c1b965d68d3413a01a59db32912
@@ -270,10 +270,17 @@ module EducodeSales
270
270
  last_follow.divide_amount,
271
271
  (last_follow.total_amount - last_follow.actual_amount) as divide_money,
272
272
  (last_follow.actual_amount - educode_sales_businesses.return_money) as wait_return_money,
273
- last_follow.total_amount
273
+ last_follow.total_amount,
274
+ total_follow_ups.follow_ups_count
274
275
  ").joins("
275
276
  LEFT JOIN educode_sales_follow_ups AS last_follow ON educode_sales_businesses.last_follow_up_id = last_follow.id AND last_follow.deleted_at IS NULL
276
- ").page(params[:page]).per(params[:limit])
277
+ LEFT JOIN (
278
+ SELECT COUNT(*) AS follow_ups_count, educode_sales_follow_ups.business_id
279
+ FROM educode_sales_follow_ups
280
+ WHERE educode_sales_follow_ups.deleted_at IS NULL
281
+ GROUP BY educode_sales_follow_ups.business_id
282
+ ) AS total_follow_ups ON educode_sales_businesses.id = total_follow_ups.business_id
283
+ ").includes(:users, last_follow_up: [:clazz, :assign_follow_ups]).page(params[:page]).per(params[:limit])
277
284
 
278
285
  end
279
286
 
@@ -575,6 +582,11 @@ module EducodeSales
575
582
  ids1 = FollowUp.where(id: ids).pluck(:business_id)
576
583
  @businesses =@businesses.where("educode_sales_businesses.id in (?) or educode_sales_businesses.staff_id = ?", ids1, @current_admin.id)
577
584
  end
585
+ if params[:is_follow].present?
586
+ # 关注
587
+ my_ids = BusinessRelationShip.where(user_id:@current_admin.user_id).pluck(:business_id)
588
+ @businesses = @businesses.where(id: my_ids)
589
+ end
578
590
 
579
591
  @businesses = @businesses
580
592
  if params[:name].present? && params[:name] != "(销售态势-" + @year + "-已中标商机)" && params[:name] != "(销售态势-" + @year + "-已签单商机)" && params[:name] != "(销售态势-" + @year + "-已回款商机)" && params[:name] != "(销售态势-" + @year + "-现有商机)"&& params[:name] != "(销售态势-" + @year + "-应收款商机)"
@@ -666,9 +678,17 @@ module EducodeSales
666
678
  last_follow.divide_amount,
667
679
  (last_follow.total_amount - last_follow.actual_amount) as divide_money,
668
680
  (last_follow.actual_amount - educode_sales_businesses.return_money) as wait_return_money,
669
- last_follow.total_amount").joins("
681
+ last_follow.total_amount,
682
+ total_follow_ups.follow_ups_count
683
+ ").joins("
670
684
  LEFT JOIN educode_sales_follow_ups AS last_follow ON educode_sales_businesses.last_follow_up_id = last_follow.id AND last_follow.deleted_at IS NULL
671
- ")
685
+ LEFT JOIN (
686
+ SELECT COUNT(*) AS follow_ups_count, educode_sales_follow_ups.business_id
687
+ FROM educode_sales_follow_ups
688
+ WHERE educode_sales_follow_ups.deleted_at IS NULL
689
+ GROUP BY educode_sales_follow_ups.business_id
690
+ ) AS total_follow_ups ON educode_sales_businesses.id = total_follow_ups.business_id
691
+ ").includes(last_follow_up: [:clazz, :assign_follow_ups])
672
692
  end
673
693
  end
674
694
  end
@@ -6,7 +6,7 @@ json.data do
6
6
  json.department d.department.name
7
7
  json.school d.department.school.name
8
8
  json.school_id d.department.school.id
9
- follow_ups_count = d.follow_ups.where(deleted_at: nil).size
9
+ follow_ups_count = d['follow_ups_count'] || 0
10
10
  json.follow_ups_count follow_ups_count
11
11
  json.follow_up_id d.last_follow_up_id
12
12
  json.clazz d.last_follow_up&.clazz&.name || ""
@@ -25,7 +25,7 @@ json.data do
25
25
  end
26
26
 
27
27
  json.divide_rate d.divide_rate
28
- json.divide_money d.divide_money
28
+ json.divide_money d.divide_amount
29
29
  json.budget_money d.budget_amount
30
30
  json.area d.department.school.province
31
31
  school_property = d.department.school.school_property
@@ -410,20 +410,6 @@
410
410
  sort: true,
411
411
  hide: gon.filter.budget_money
412
412
  },
413
- {
414
- field: 'divide_rate',
415
- width: 160,
416
- title: '渠道分成比例',
417
- sort: true,
418
- hide: gon.filter.divide_rate
419
- },
420
- {
421
- field: 'divide_money',
422
- width: 160,
423
- title: '渠道分成金额',
424
- sort: true,
425
- hide: gon.filter.divide_money
426
- },
427
413
  {
428
414
  field: 'total_amount',
429
415
  width: 100,
@@ -463,10 +449,24 @@
463
449
  hide: gon.filter.return_money_days
464
450
  },
465
451
  {
466
- field: 'place',
467
- width: 160,
468
- title: '渠道',
469
- hide: gon.filter.place
452
+ field: 'divide_rate',
453
+ width: 160,
454
+ title: '渠道分成比例',
455
+ sort: true,
456
+ hide: gon.filter.divide_rate
457
+ },
458
+ {
459
+ field: 'divide_money',
460
+ width: 160,
461
+ title: '渠道分成金额',
462
+ sort: true,
463
+ hide: gon.filter.divide_money
464
+ },
465
+ {
466
+ field: 'place',
467
+ width: 160,
468
+ title: '渠道',
469
+ hide: gon.filter.place
470
470
  },
471
471
  {
472
472
  field: 'sale_way',
@@ -616,10 +616,10 @@
616
616
  id = elem.data('id');
617
617
  switch (data.event) {
618
618
  case 'export_csv':
619
- export_csv();
619
+ export_bussiness('csv')
620
620
  break;
621
621
  case 'export_excel':
622
- export_excel();
622
+ export_bussiness('xls')
623
623
  break;
624
624
  case 'export_records':
625
625
  export_records();
@@ -628,8 +628,7 @@
628
628
  }
629
629
  });
630
630
  }
631
-
632
- function export_csv() {
631
+ function export_bussiness(type) {
633
632
  var data = form.val("search_form");
634
633
  var business_type = [];
635
634
  business_type_list.getValue().forEach(function(d) {
@@ -643,7 +642,6 @@
643
642
  data.business_type = business_type.toString();
644
643
  data.business_step = business_step.toString();
645
644
  layer.load(0, {});
646
- console.log(data);
647
645
  request.authPost("/missions/businesses/get_export_data", {
648
646
  name: data.name,
649
647
  area: data.area,
@@ -654,53 +652,21 @@
654
652
  invitation_at: data.invitation_at,
655
653
  place_id: data.place_id,
656
654
  select: data.select,
657
- staff_id: data.staff_id
655
+ staff_id: data.staff_id,
656
+ mine: search['clazz'] == 'me' ? true : '',
657
+ is_follow: search['clazz'] == 'followes' ? true : '',
658
658
  }, function (res) {
659
659
  console.log(res.data);
660
660
  data = res.data
661
- table.exportFile(business_table.config.id,data, 'csv');
661
+ table.exportFile(business_table.config.id,data, type);
662
662
  layer.closeAll('loading');
663
- request.get('/missions/businesses/add_export_records?type=csv', {}, function (res) {
663
+ request.get('/missions/businesses/add_export_records?type=' + type, {}, function (res) {
664
664
  })
665
665
  })
666
666
 
667
667
  }
668
- function export_excel() {
669
- var data = form.val("search_form");
670
- var business_type = [];
671
- business_type_list.getValue().forEach(function(d) {
672
- business_type.push(d.value);
673
- })
674
- var business_step = [];
675
- business_step_list.getValue().forEach(function(d) {
676
- business_step.push(d.value);
677
- })
678
- data.place_id = index_place_list.getValue('valueStr');
679
- data.business_type = business_type.toString();
680
- data.business_step = business_step.toString();
681
- layer.load(0, {});
682
- console.log(data);
683
- request.authPost("/missions/businesses/get_export_data", {
684
- name: data.name,
685
- area: data.area,
686
- business_step: data.business_step,
687
- business_type: data.business_type,
688
- date: data.date,
689
- department: data.department,
690
- invitation_at: data.invitation_at,
691
- place_id: data.place_id,
692
- select: data.select,
693
- staff_id: data.staff_id
694
- }, function (res) {
695
- console.log(res.data);
696
- data = res.data
697
- table.exportFile(business_table.config.id,data, 'xls');
698
- layer.closeAll('loading');
699
- request.get('/missions/businesses/add_export_records?type=xls', {}, function (res) {
700
- })
701
- })
702
668
 
703
- }
669
+
704
670
  function export_records() {
705
671
  var content = miniPage.getHrefContent('/missions/businesses/export_records')
706
672
  var openWH = miniPage.getOpenWidthHeight();
@@ -856,6 +822,9 @@
856
822
 
857
823
 
858
824
  var sort = {}, search = {};
825
+ <% if params[:name].present? %>
826
+ search.name = "<%= params[:name] %>";
827
+ <% end %>
859
828
  table.on('sort(businesses_table)', function (obj) {
860
829
  sort.field = obj.field;
861
830
  sort.order = obj.type;
@@ -8,7 +8,7 @@ json.data do
8
8
  json.department d.department.name
9
9
  json.school d.department.school.name
10
10
  json.school_id d.department.school.id
11
- follow_ups_count = d.follow_ups.where(deleted_at: nil).size
11
+ follow_ups_count = d['follow_ups_count'] || 0
12
12
  json.follow_ups_count follow_ups_count
13
13
  follow_count += follow_ups_count
14
14
  json.follow_up_id d.last_follow_up_id
@@ -55,7 +55,7 @@ json.data do
55
55
  json.staff_id d.staff_id
56
56
  json.latest_time d.last_follow_up.present? ? d.last_follow_up.created_at.to_s : ''
57
57
  json.self_flag (d.staff_id == @current_admin.id) || (d.last_follow_up_id.in? follow_up_ids)
58
- json.followed d.users.where(user_id:@current_admin.user.id).first ? 1 : 0
58
+ json.followed d.users.pluck(:user_id).include?(@current_admin.user.id) ? 1 : 0 # d.users.where(user_id:@current_admin.user.id).first ? 1 : 0
59
59
  end
60
60
  end
61
61
 
@@ -1,3 +1,3 @@
1
1
  module EducodeSales
2
- VERSION = '0.9.20'
2
+ VERSION = '0.9.21'
3
3
  end
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.9.20
4
+ version: 0.9.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - anke1460
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-10 00:00:00.000000000 Z
11
+ date: 2022-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails