educode_sales 0.9.29 → 0.9.31

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: f0916e70d7b1d843bcfc73d0cb46bae0d2ea24607af4370e949c0794e6ad5c5a
4
- data.tar.gz: dd6dfbdae1de1ad91a5a6d525dea33a5bccfdfebc90a3b0317c2e7c9cc7df2b4
3
+ metadata.gz: e90cfebc689f75a8729f824db95f6dd3fe8a6c1c2f97edfec4d7d8ac8c6ad17d
4
+ data.tar.gz: b517a994b1be4ac595f8c8664526d1ba0eb7785c60df9ddb0373348cde0b4a5f
5
5
  SHA512:
6
- metadata.gz: a3df0e9c3f3da1c7b13042101fd8df450d99177c6eaeba578bfd041d808e183d74d61a3ac5940f45edc43eba732a7a6db42096f22e811e8b19d86f166e32a54b
7
- data.tar.gz: 428c1bbf876168570b6f763ee70d6415db15b05c2b3a94985f7ba81721b16690eee0f0278a813e8c21cf028b3a0f1488e358f7622d9d101c08c6c01ffd244485
6
+ metadata.gz: 4169878b95d9f6ab1f53165587e783b7a85f8be05295187b7f070466bad23645b5c2801d49827265337004a60fa8380bf2fae9f15a345e2a7f188cfc3bc46c7c
7
+ data.tar.gz: 7050ecd4233c2ae9b835542187b57f82a3ad305fb008f0e6ef31fc3beeab367862fcad099b8c6c7b108f4b708863dfed3dea5c1d3238cd6390dd84474becaae2
@@ -264,11 +264,11 @@ module EducodeSales
264
264
  (last_follow.total_amount - last_follow.actual_amount) as divide_money,
265
265
  (last_follow.actual_amount - educode_sales_businesses.return_money) as wait_return_money,
266
266
  last_follow.total_amount,
267
- total_follow_ups.follow_ups_count
267
+ total_follow_ups.follow_ups_counts
268
268
  ").joins("
269
269
  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
270
270
  LEFT JOIN (
271
- SELECT COUNT(*) AS follow_ups_count, educode_sales_follow_ups.business_id
271
+ SELECT COUNT(*) AS follow_ups_counts, educode_sales_follow_ups.business_id
272
272
  FROM educode_sales_follow_ups
273
273
  WHERE educode_sales_follow_ups.deleted_at IS NULL
274
274
  GROUP BY educode_sales_follow_ups.business_id
@@ -321,6 +321,14 @@ module EducodeSales
321
321
  business = Business.find(params[:id])
322
322
  department = Department.find(params[:department_id])
323
323
  if business.update(name: params[:name], department_id: department.id, source: params[:source], school_id: department.school_id)
324
+ if params[:merge_business_ids].present?
325
+ merge_business = Business.where(id: params[:merge_business_ids].split(","))
326
+ merge_business.each do |b|
327
+ b.follow_ups.update_all(origin_business_id: b.id, business_id: business.id)
328
+ b.update(deleted_at: Time.now)
329
+ end
330
+ business.update(follow_ups_count: EducodeSales::FollowUp.where(business_id: business.id).size)
331
+ end
324
332
  render_success
325
333
  else
326
334
  render_failure business
@@ -691,6 +699,10 @@ module EducodeSales
691
699
  end
692
700
  end
693
701
 
702
+ def search
703
+ @business = Business.where.not(id: params[:id]).order("created_at desc")
704
+ @business = @business.where("educode_sales_businesses.name like ?", "%#{params[:q]}%").limit(30) if params[:q].present?
705
+ end
694
706
 
695
707
  private
696
708
 
@@ -117,7 +117,8 @@ module EducodeSales
117
117
  when "week" #按周
118
118
  if params[:date_week].present?
119
119
  date = params[:date_week].split(" - ")
120
- dates = (date[0].to_date..date[1].to_date).map { |d| d.strftime("%Y-%W") }.uniq
120
+ # 年初第一天周数是0会导致周数重复计算
121
+ dates = (date[0].to_date..date[1].to_date).map { |d| d.strftime("%Y-%W") }.uniq.select { |d| d.split("-")[1] != '00' }
121
122
  @follow_count_data = business_followup_charts(dates, names, x_business_ids, SaleTrend::COLORS, date, "%Y%u") do |dates|
122
123
  dates.map { |date|
123
124
  d = date.split("-")
@@ -190,6 +191,9 @@ module EducodeSales
190
191
  when "month" #按月
191
192
  if params[:goal_date_month].present?
192
193
  date = params[:goal_date_month].split(" - ")
194
+ date[0] = (date[0] + "-01").to_date.to_s
195
+ date[1] = (date[1] + "-01").to_date.end_of_month.to_s
196
+
193
197
  dates = ((date[0] + "-01").to_date..(date[1] + "-01").to_date).map { |d| d.strftime("%Y-%m") }.uniq
194
198
  @goal_count_data = month_sale_chart(dates, sale_names, SaleTrend::COLORS, x, stage_ids, s_stage_ids, count_type, date)
195
199
  else
@@ -414,11 +418,9 @@ module EducodeSales
414
418
 
415
419
 
416
420
  def month_sale_chart(dates, names, colors, x, stage_ids, s_stage_ids, count_type, range)
417
- begin_at = range[0].split("-")
418
- end_at = range[1].split("-")
421
+ begin_at = range[0]
422
+ end_at = range[1]
419
423
 
420
- begin_at = DateTime.new begin_at[0].to_i, begin_at[1].to_i
421
- end_at = DateTime.new end_at[0].to_i, end_at[1].to_i
422
424
  data_1 = EducodeSales::Business.joins(:last_follow_up).
423
425
  where("educode_sales_follow_ups.clazz_id != ?", x).
424
426
  where("educode_sales_follow_ups.stage_id IN (?)", stage_ids).
@@ -531,8 +533,8 @@ module EducodeSales
531
533
  def year_sale_chart(dates, names, colors, x, stage_ids, s_stage_ids, count_type, range)
532
534
  begin_at = range[0].split("-")
533
535
  end_at = range[1].split("-")
534
- begin_at = DateTime.new(begin_at[0].to_i).beginning_of_year
535
- end_at = DateTime.new(end_at[0].to_i).end_of_year
536
+ begin_at = DateTime.new(begin_at[0].to_i).beginning_of_year.to_date.to_s
537
+ end_at = DateTime.new(end_at[0].to_i).end_of_year.to_date.to_s
536
538
 
537
539
  data_1 = EducodeSales::Business.joins(:last_follow_up).
538
540
  where("educode_sales_follow_ups.clazz_id != ?", x).
@@ -29,7 +29,7 @@ module EducodeSales
29
29
 
30
30
  def self.include_types(type)
31
31
  {
32
- '1' => %w[a_class b_class c_class d_class e_class o_class],
32
+ '1' => %w[a_class b_class c_class d_class e_class],
33
33
  'a' => ['a_class'],
34
34
  'b' => ['b_class'],
35
35
  }[type]
@@ -63,5 +63,9 @@ module EducodeSales
63
63
  nil
64
64
  end
65
65
  end
66
+
67
+ def is_enabled
68
+ expired_at.present? && enabled_at.present? && expired_at > Time.now && enabled_at < Time.now
69
+ end
66
70
  end
67
71
  end
@@ -22,6 +22,17 @@
22
22
  <div class="layui-inline" style="padding-top: 20px">
23
23
  <p style="padding-left: 40px">请填写提供本商机的人名(如‘张明’);如果为非头歌用户,请增加单位信息(如‘张明,华为公司’)</p>
24
24
  </div>
25
+ <% if can?(:merge_business, EducodeSales::Business) %>
26
+ <div class="layui-inline-block" style="padding-top: 20px">
27
+ <label class="layui-form-label ">合并商机</label>
28
+ <div class="layui-input-inline" style="width: 300px">
29
+ <div class="layui-input-block confirm-select" id="merge_business" style="width: 300px; margin-left: 0px"></div>
30
+ </div>
31
+ <div class="layui-inline" style="padding-top: 10px">
32
+ <p style="padding-left: 40px">选择的商机及其下的跟进记录将会合并到该编辑的商机中</p>
33
+ </div>
34
+ </div>
35
+ <% end %>
25
36
  <div class="layui-form-item m-t-20">
26
37
  <div class="layui-input-block">
27
38
  <button class="layui-btn layui-btn-normal" lay-submit lay-filter="edit_business">提交</button>
@@ -30,12 +41,13 @@
30
41
  </div>
31
42
  </div>
32
43
  <script>
33
- layui.use(['form', 'table', 'upload', 'layer', 'laytpl', 'request', 'selectInput'], function () {
44
+ layui.use(['form', 'table', 'upload', 'layer', 'laytpl', 'request', 'selectInput', 'xmSelect'], function () {
34
45
  var form = layui.form,
35
46
  layer = layui.layer,
36
47
  table = layui.table,
37
48
  laytpl = layui.laytpl,
38
49
  request = layui.request,
50
+ xmSelect = layui.xmSelect,
39
51
  $ = layui.$;
40
52
  selectInput = layui.selectInput;
41
53
 
@@ -64,6 +76,20 @@
64
76
  }
65
77
  });
66
78
 
79
+ var merge_business_select = xmSelect.render({
80
+ el: '#merge_business',
81
+ filterable: true,
82
+ name: 'merge_business_ids',
83
+ remoteSearch: true,
84
+ remoteMethod: function(val, cb, show){
85
+ request.get('missions/businesses/search?id=' + parent.id + "&q=" + val, {},
86
+ function(res) {
87
+ cb(res.data)
88
+ })
89
+ },
90
+ data: []
91
+ })
92
+
67
93
  // 当前弹出层,防止ID被覆盖
68
94
  var parentIndex = layer.index;
69
95
 
@@ -76,7 +102,8 @@
76
102
  request.authPut("missions/businesses/" + parent.id, {
77
103
  department_id: department.getValue() || department_id,
78
104
  name: data.field.name,
79
- source: data.field.source
105
+ source: data.field.source,
106
+ merge_business_ids: data.field.merge_business_ids,
80
107
  }, function (res) {
81
108
  if (res.success == false) {
82
109
  layer.alert(res.msg)
@@ -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_count'] || 0
11
+ follow_ups_count = d['follow_ups_counts'] || 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
@@ -0,0 +1,6 @@
1
+ json.data do
2
+ json.array! @business do |d|
3
+ json.value d.id
4
+ json.name d.name
5
+ end
6
+ end
@@ -54,11 +54,11 @@
54
54
  function renderTable(chart_data) {
55
55
  var labels = [];
56
56
  fields = [
57
- {field: 'col0', title: '姓名', width:100}
57
+ {field: 'col0', title: '姓名', width:100, totalRowText: '合计:'}
58
58
  ];
59
59
  chart_data.labels.forEach(function(d, i) {
60
60
  labels.push(d);
61
- fields.push({title: d.split("(").join("<br/>").replace(")", ""), field: 'col' + (i + 1), width:160, align: 'center'})
61
+ fields.push({title: d.split("(").join("<br/>").replace(")", ""), field: 'col' + (i + 1), width:180, align: 'center', sort: true, totalRow: '{{ parseInt(d.TOTAL_NUMS) }}'})
62
62
  })
63
63
  var table_data = [];
64
64
  chart_data.datasets.forEach(function(d, i) {
@@ -78,6 +78,7 @@
78
78
  url: '',
79
79
  limit: 1000,
80
80
  page: false,
81
+ totalRow: true,
81
82
  data: table_data,
82
83
  cols: [fields]
83
84
  });
@@ -94,6 +94,11 @@
94
94
  title: '监管学校',
95
95
  templet:'<div><span title="{{d.schools}}">{{d.schools}}</span></div>'
96
96
  },
97
+ {
98
+ field: 'enabled',
99
+ width: 120,
100
+ title: '状态'
101
+ },
97
102
  {
98
103
  field: 'month',
99
104
  width: 120,
@@ -9,6 +9,7 @@ json.data do
9
9
  json.month d.month
10
10
  json.enabled_at d.enabled_at ? d.enabled_at.to_s(:date) : ''
11
11
  json.expired_at d.enabled_at ? "#{d.enabled_at.to_s(:date)}-#{d.expired_at.to_s(:date)}" : ''
12
+ json.enabled d.is_enabled ? '启用' : '禁用'
12
13
  if d.areas.present?
13
14
  if d.areas.ids.sort.to_s == area_ids
14
15
  json.area '全国'
data/config/routes.rb CHANGED
@@ -107,6 +107,7 @@ EducodeSales::Engine.routes.draw do
107
107
  get :following_businesses
108
108
  get :followed
109
109
  get :daily_paper
110
+ get :search
110
111
  end
111
112
 
112
113
  member do
@@ -28,6 +28,8 @@ class CreateEducodeSalesRolePermissions < ActiveRecord::Migration[5.2]
28
28
  EducodeSales::Permission.create(name: '添加跟进记录(本人商机)', subject: 'Business', action: 'self_add_follow', clazz: 'business', position: '8')
29
29
  EducodeSales::Permission.create(name: '编辑跟进记录(本人创建)', subject: 'Business', action: 'self_edit_follow', clazz: 'business', position: '9')
30
30
  EducodeSales::Permission.create(name: '删除跟进记录(本人创建)', subject: 'Business', action: 'self_delete_follow', clazz: 'business', position: '10')
31
+
32
+ EducodeSales::Permission.create(name: '合并商机', subject: 'Business', action: 'merge_business', clazz: 'business', position: '12')
31
33
  #回款管理权限
32
34
  EducodeSales::Permission.create(name: '查看回款列表', subject: 'MoneyPlan', action: 'read', clazz: 'money_plan', position: '15')
33
35
 
@@ -0,0 +1,6 @@
1
+ class AddOriginBusinessIdToFollowUps < ActiveRecord::Migration[5.2]
2
+ def change
3
+ add_column :educode_sales_follow_ups, :origin_business_id, :integer
4
+ add_column :educode_sales_sale_plans, :origin_business_id, :integer
5
+ end
6
+ end
@@ -1,3 +1,3 @@
1
1
  module EducodeSales
2
- VERSION = '0.9.29'
2
+ VERSION = '0.9.31'
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.29
4
+ version: 0.9.31
5
5
  platform: ruby
6
6
  authors:
7
7
  - anke1460
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-06 00:00:00.000000000 Z
11
+ date: 2023-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -105,7 +105,6 @@ files:
105
105
  - app/assets/images/educode_sales/icon-login.png
106
106
  - app/assets/images/educode_sales/icon.png
107
107
  - app/assets/images/educode_sales/indexLogo.png
108
- - app/assets/images/educode_sales/indexlogo.png
109
108
  - app/assets/images/educode_sales/loading-0.gif
110
109
  - app/assets/images/educode_sales/loading-1.gif
111
110
  - app/assets/images/educode_sales/loading-2.gif
@@ -250,6 +249,7 @@ files:
250
249
  - app/views/educode_sales/businesses/index.json.jbuilder
251
250
  - app/views/educode_sales/businesses/new.html.erb
252
251
  - app/views/educode_sales/businesses/new_follow_record.html.erb
252
+ - app/views/educode_sales/businesses/search.json.jbuilder
253
253
  - app/views/educode_sales/businesses/show_follow.html.erb
254
254
  - app/views/educode_sales/businesses/show_follow.json.jbuilder
255
255
  - app/views/educode_sales/businesses/show_follow_record.html.erb
@@ -483,6 +483,7 @@ files:
483
483
  - db/migrate/20220923084102_create_table_to_busines_number_recoreds.rb
484
484
  - db/migrate/20221025094655_delete_business_number.rb
485
485
  - db/migrate/20221107122147_change_divide_rate_follow_ups.rb
486
+ - db/migrate/20230115080730_add_origin_business_id_to_follow_ups.rb
486
487
  - lib/educode_sales.rb
487
488
  - lib/educode_sales/engine.rb
488
489
  - lib/educode_sales/version.rb
@@ -491,7 +492,7 @@ homepage: https://www.educoder.net
491
492
  licenses:
492
493
  - MIT
493
494
  metadata: {}
494
- post_install_message:
495
+ post_install_message:
495
496
  rdoc_options: []
496
497
  require_paths:
497
498
  - lib
@@ -506,8 +507,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
506
507
  - !ruby/object:Gem::Version
507
508
  version: '0'
508
509
  requirements: []
509
- rubygems_version: 3.0.9
510
- signing_key:
510
+ rubygems_version: 3.0.0
511
+ signing_key:
511
512
  specification_version: 4
512
513
  summary: Summary of EducodeSales.
513
514
  test_files: []