educode_sales 0.9.44 → 0.9.45

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: e3b8eeaf96172e79bdd5ecd470826d1b1509e27aa51650992fea9573124c03a8
4
- data.tar.gz: 448e73b86222666fa76163427cacf66d25dcb3afff0186dac870da2096f701ec
3
+ metadata.gz: 490547dd6002957fc97b49d5944e48b43476036a6f9090689c457ebdf0ad2167
4
+ data.tar.gz: e82a58a5dfdc42d2ad607f6c702a643ed3a91227a42771fdada0034b823340e9
5
5
  SHA512:
6
- metadata.gz: d33d493129ce919f40d3ba640312a2b32b8965e269f013c9fac9cd8972576fd5cae0ce6c3099c691ff5b993263f36f61ab2f2f5298c6051c51df74c4c4d6c5dd
7
- data.tar.gz: ab38c5526bec3b5eae9b4109b705298f8a5b8a2d932845bf70fc1b45b0d29ef9395b3d6865b840703bda9184b754ebc6411efee484d78160ea3b74dda998977b
6
+ metadata.gz: 42827e0c0a5c605af5bd4ecd2dd4dd82faed892a6697d3c8c684c6d4dd4a3c96e9c67e94e7fe20eedd68c6545dad6ab5a8e66b02f39a3f2048fa8afa0b994f0c
7
+ data.tar.gz: 25005c073e6b4f7bf406d6950907a3fe2a95fb68a14d45ade420a663a31d29795292e168614e61501f48c08e53d8b888ba72adac3fffb05bd299b0121d7a7237
@@ -128,7 +128,11 @@ module EducodeSales
128
128
  @customers = @customers.where(id: school_ids)
129
129
  end
130
130
 
131
- @customers = @customers.order(id: :desc).page(params[:page]).per(params[:limit])
131
+ if params[:page].present?
132
+ @customers = @customers.order(id: :desc).page(params[:page]).per(params[:limit])
133
+ else
134
+ @customers = @customers.order(id: :desc)
135
+ end
132
136
  end
133
137
  end
134
138
  end
@@ -213,6 +217,36 @@ module EducodeSales
213
217
  render layout: false
214
218
  end
215
219
 
220
+ def batch_update_school_tags
221
+ xlsx = Roo::Spreadsheet.open(params[:file])
222
+ ods = xlsx.sheet(0)
223
+ rows = ods.last_row - 1
224
+ i = 0
225
+ school_tag_hash = SchoolTag.where(for_missions: true).pluck(:name, :id).to_h
226
+ rows.times do |r| #行数
227
+ i += 1
228
+ next unless ods.row(r+1)[0]
229
+ school = School.find_by(name: ods.row(r+1)[0].to_s.strip)
230
+ school_list = EducodeSales::CustomerAdd::SCHOOL_LIST.invert
231
+ if school
232
+ property_names = ods.row(r+1)[2].to_s.strip
233
+ tags = []
234
+ if property_names
235
+ property_names.gsub("、", " ").gsub(",", " ").split(" ").each do |tag|
236
+ if school_tag_hash[tag]
237
+ tags << SchoolTagMiddle.find_or_initialize_by(school_id: school.id, school_tag_id: school_tag_hash[tag])
238
+ end
239
+ end
240
+ end
241
+ school.school_tag_middles = tags
242
+ end
243
+ end
244
+
245
+ SchoolTagMiddle.where(school_id: nil).delete_all
246
+
247
+ render json: { succcess: true}
248
+ end
249
+
216
250
  def update
217
251
  @school = School.find(params[:id])
218
252
  ActiveRecord::Base.transaction do
@@ -236,20 +270,11 @@ module EducodeSales
236
270
  #保存学校标签
237
271
 
238
272
  keys = %w[regular_college junior_college secondary_school military_school other mid_school ele_school enterprise]
239
- names = {
240
- "regular_college" => "本科院校",
241
- "junior_college" => "高职院校",
242
- "secondary_school" => "中职院校",
243
- "military_school" => "军事院校",
244
- "other" => "其他",
245
- "mid_school" => "中学",
246
- "ele_school" => "小学",
247
- "enterprise" => "企业"
248
- }
273
+ names = EducodeSales::CustomerAdd::SCHOOL_LIST
249
274
  property.attributes.each do |key, value|
250
275
  next unless key.in?(keys)
251
276
  next unless value.to_s == "true"
252
- school_tag = SchoolTag.find_by_name(names[key])
277
+ school_tag = SchoolTag.find_by(name: names[key], for_missions: true)
253
278
  if school_tag.present?
254
279
  SchoolTagMiddle.create(school_id: @school.id, school_tag_id: school_tag.id)
255
280
  end
@@ -1,4 +1,15 @@
1
1
  module EducodeSales
2
2
  class CustomerAdd < ApplicationRecord
3
+
4
+ SCHOOL_LIST = {
5
+ "regular_college" => "本科院校",
6
+ "junior_college" => "高职院校",
7
+ "secondary_school" => "中职院校",
8
+ "military_school" => "军事院校",
9
+ "other" => "其他",
10
+ "mid_school" => "中学",
11
+ "ele_school" => "小学",
12
+ "enterprise" => "企业"
13
+ }
3
14
  end
4
15
  end
@@ -45,6 +45,12 @@
45
45
  <script type="text/html" id="toolbarDemo">
46
46
  <div class="layui-btn-container">
47
47
  <span class="table-label">客户列表</span>
48
+ <% if can? :export, EducodeSales::Customer %>
49
+ <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn pull-right" lay-event="export">导出</button>
50
+ <% end %>
51
+ <% if can? :modify_school_tag, EducodeSales::Customer %>
52
+ <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn pull-right" id="modify_customer">批量修改客户类型</button>
53
+ <% end %>
48
54
  <% if can? :create, EducodeSales::Customer %>
49
55
  <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn pull-right" lay-event="add">添加客户</button>
50
56
  <% end %>
@@ -83,10 +89,11 @@
83
89
 
84
90
 
85
91
  <script>
86
- layui.use(['form', 'table', 'miniPage', 'element', 'request', 'laydate'], function () {
92
+ layui.use(['form', 'table', 'miniPage', 'element', 'request', 'laydate', 'upload'], function () {
87
93
  var $ = layui.jquery,
88
94
  form = layui.form,
89
95
  request = layui.request,
96
+ upload = layui.upload,
90
97
  dropdown = layui.dropdown,
91
98
  miniPage = layui.miniPage,
92
99
  laydate = layui.laydate;
@@ -114,12 +121,13 @@
114
121
  });
115
122
 
116
123
  table = layui.table;
117
- table.render({
124
+ var customer_table = table.render({
118
125
  elem: '#customers_table',
119
126
  url: '/missions/customers',
120
127
  where: {q: form.val('search_teachers')},
121
128
  toolbar: '#toolbarDemo',
122
129
  // totalRow:true,
130
+ title: '客户列表',
123
131
  defaultToolbar: ['filter'],
124
132
  cols: [
125
133
  [
@@ -186,6 +194,11 @@
186
194
  limit: 20,
187
195
  limits: [10, 15, 20, 30, 40, 50, 60, 70, 80, 90],
188
196
  page: true,
197
+ done: function() {
198
+ if ($('#modify_customer').length > 0) {
199
+ uploadCustomer();
200
+ }
201
+ }
189
202
  });
190
203
 
191
204
  //监听表格复选框选择
@@ -349,6 +362,22 @@
349
362
  $(window).on("resize", function () {
350
363
  layer.full(index);
351
364
  });
365
+ } else if (obj.event == 'export') {
366
+ layer.load(0, {});
367
+ var data = form.val("search_teachers");
368
+ var property = [];
369
+ property_list.getValue().forEach(function (d) {
370
+ property.push(d.value);
371
+ })
372
+ data.property = property.toString();
373
+ request.authGet("/missions/customers?=" + $.param({q:data}), {
374
+ }, function (res) {
375
+ data = res.data
376
+ table.exportFile(customer_table.config.id, data, 'xls');
377
+ layer.closeAll('loading');
378
+ })
379
+ } else if (obj.event == 'modify_customer') {
380
+
352
381
  }
353
382
  });
354
383
 
@@ -503,11 +532,53 @@
503
532
  }
504
533
  });
505
534
 
535
+ function uploadCustomer() {
536
+ upload.render({
537
+ elem: '#modify_customer'
538
+ ,url: '/missions/customers/batch_update_school_tags'
539
+ ,accept: 'file' //普通文件
540
+ ,acceptMime: 'application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,application/vnd.ms-excel'
541
+ ,headers: {
542
+ 'X-CSRF-Token': $('meta[name=csrf-token]').attr('content')
543
+ }
544
+ ,before: function(obj){
545
+ layer.load();
546
+ }
547
+ ,done: function(res){
548
+ layer.msg('导入成功');
549
+ table.reload('customers_table');
550
+ layer.closeAll('loading'); //关闭loading
551
+ }
552
+ ,error: function(index, upload){
553
+ table.reload('file');
554
+ layer.closeAll('loading'); //关闭loading
555
+ layer.alert('导入失败,请检查文件格式')
556
+ layer.close(parent.import_index)
557
+ }
558
+ });
559
+ }
560
+ if ($('#modify_customer').length > 0) {
561
+ var uploadTip;
562
+ $(document).on('mouseenter', '#modify_customer', function() {
563
+ uploadTip = layer.tips("<p style='color:#000;'>" + "导入Excel文件可批量修改客户性质。表格格式:客户名称 区域 性质。格式按导出的客户列表格式导入" + "</p>",
564
+ this,
565
+ {
566
+ tips:[1,'#f2f2f2'],
567
+ time:0,
568
+ area: 'auto',
569
+ maxWidth:500
570
+ });
571
+ })
572
+
573
+ $(document).on('mouseleave', '#modify_customer', function() {
574
+ layer.close(uploadTip);
575
+ })
576
+ }
577
+
506
578
  });
507
579
  </script>
508
580
  <style>
509
581
  .layui-table-tool-temp {
510
- padding-right: 30px;
511
- !important;
582
+ padding-right: 30px; !important;
512
583
  }
513
584
  </style>
@@ -37,4 +37,6 @@ json.data do
37
37
  end
38
38
 
39
39
  json.code 0
40
- json.count @customers.total_count
40
+ if params[:page].present?
41
+ json.count @customers.total_count
42
+ end
@@ -13,7 +13,7 @@
13
13
  <div class="layui-input-block">
14
14
  <%= select_tag "role_id",
15
15
  options_for_select(EducodeSales::Role.pluck(:name, :id),
16
- @staff.role_id), { 'lay-filter': 'role_id' } %>
16
+ @staff.role_id), { 'lay-filter': 'role_id', include_blank: true } %>
17
17
  </div>
18
18
  </div>
19
19
  <div class="layui-form-item">
@@ -21,7 +21,7 @@
21
21
  <div class="layui-input-block">
22
22
  <%= select_tag "job_type",
23
23
  options_for_select(@staff_types,
24
- @staff.job_type), { 'lay-filter': 'job_type' } %>
24
+ @staff.job_type), { 'lay-filter': 'job_type', include_blank: true } %>
25
25
  </div>
26
26
  </div>
27
27
  <div class="layui-form-item">
data/config/routes.rb CHANGED
@@ -37,6 +37,7 @@ EducodeSales::Engine.routes.draw do
37
37
  get :new_department
38
38
  get :edit_department
39
39
  get :give
40
+ post :batch_update_school_tags
40
41
  end
41
42
 
42
43
  member do
@@ -49,6 +49,9 @@ class CreateEducodeSalesRolePermissions < ActiveRecord::Migration[5.2]
49
49
  EducodeSales::Permission.create(name: '编辑跟进记录', subject: 'Customer', action: 'update_follow', clazz: 'customer')
50
50
  EducodeSales::Permission.create(name: '删除跟进记录', subject: 'Customer', action: 'destroy_follow', clazz: 'customer')
51
51
 
52
+ EducodeSales::Permission.create(name: '导出', subject: 'Customer', action: 'export', clazz: 'customer')
53
+ EducodeSales::Permission.create(name: '批量导入修改客户类型', subject: 'Customer', action: 'modify_school_tag', clazz: 'customer')
54
+
52
55
 
53
56
  EducodeSales::Permission.create(name: '查看数据', subject: 'SaleTrend', action: 'trends', clazz: 'market')
54
57
  EducodeSales::Permission.create(name: '编辑目标', subject: 'SaleTrend', action: 'sale_trends', clazz: 'market')
@@ -1,3 +1,3 @@
1
1
  module EducodeSales
2
- VERSION = '0.9.44'
2
+ VERSION = '0.9.45'
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.44
4
+ version: 0.9.45
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-02-11 00:00:00.000000000 Z
11
+ date: 2023-02-12 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
@@ -502,7 +501,7 @@ homepage: https://www.educoder.net
502
501
  licenses:
503
502
  - MIT
504
503
  metadata: {}
505
- post_install_message:
504
+ post_install_message:
506
505
  rdoc_options: []
507
506
  require_paths:
508
507
  - lib
@@ -517,8 +516,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
517
516
  - !ruby/object:Gem::Version
518
517
  version: '0'
519
518
  requirements: []
520
- rubygems_version: 3.0.9
521
- signing_key:
519
+ rubygems_version: 3.0.0
520
+ signing_key:
522
521
  specification_version: 4
523
522
  summary: Summary of EducodeSales.
524
523
  test_files: []