educode_sales 0.6.1 → 0.6.5

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 (53) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/educode_sales/money_plans.png +0 -0
  3. data/app/controllers/educode_sales/businesses_controller.rb +29 -8
  4. data/app/controllers/educode_sales/customers_controller.rb +45 -34
  5. data/app/controllers/educode_sales/follow_ups_controller.rb +1 -1
  6. data/app/controllers/educode_sales/money_plans_controller.rb +65 -0
  7. data/app/controllers/educode_sales/places_controller.rb +5 -1
  8. data/app/controllers/educode_sales/roles_controller.rb +4 -1
  9. data/app/controllers/educode_sales/sale_trends_controller.rb +44 -1
  10. data/app/controllers/educode_sales/staffs_controller.rb +3 -4
  11. data/app/controllers/educode_sales/teachers_controller.rb +13 -2
  12. data/app/models/educode_sales/permission.rb +3 -2
  13. data/app/models/educode_sales/role_area.rb +1 -0
  14. data/app/views/educode_sales/businesses/_follows.html.erb +18 -15
  15. data/app/views/educode_sales/businesses/edit.html.erb +3 -0
  16. data/app/views/educode_sales/businesses/edit_follow_record.html.erb +11 -2
  17. data/app/views/educode_sales/businesses/file.html.erb +8 -4
  18. data/app/views/educode_sales/businesses/index.html.erb +117 -26
  19. data/app/views/educode_sales/businesses/index.json.jbuilder +4 -2
  20. data/app/views/educode_sales/businesses/new_follow_record.html.erb +7 -2
  21. data/app/views/educode_sales/businesses/show_follow.html.erb +2 -1
  22. data/app/views/educode_sales/businesses/time_line.html.erb +1 -1
  23. data/app/views/educode_sales/customers/edit.html.erb +735 -22
  24. data/app/views/educode_sales/customers/edit_follow_record.html.erb +1 -1
  25. data/app/views/educode_sales/customers/index.html.erb +17 -18
  26. data/app/views/educode_sales/customers/index.json.jbuilder +3 -3
  27. data/app/views/educode_sales/customers/new.html.erb +713 -27
  28. data/app/views/educode_sales/customers/new_follow_record.html.erb +1 -1
  29. data/app/views/educode_sales/customers/show_follow.html.erb +1 -1
  30. data/app/views/educode_sales/customers/show_follow_record.html.erb +3 -3
  31. data/app/views/educode_sales/follow_ups/index.json.jbuilder +1 -0
  32. data/app/views/educode_sales/money_plans/index.html.erb +222 -0
  33. data/app/views/educode_sales/money_plans/index.json.jbuilder +21 -0
  34. data/app/views/educode_sales/places/index.html.erb +80 -2
  35. data/app/views/educode_sales/places/index.json.jbuilder +3 -1
  36. data/app/views/educode_sales/plans/_monthPlan.html.erb +2 -1
  37. data/app/views/educode_sales/plans/_weekPlan.html.erb +2 -1
  38. data/app/views/educode_sales/recycles/business.json.jbuilder +2 -2
  39. data/app/views/educode_sales/roles/edit.html.erb +9 -1
  40. data/app/views/educode_sales/sale_trends/trends.html.erb +93 -13
  41. data/app/views/educode_sales/sale_trends/trends.json.jbuilder +3 -14
  42. data/app/views/educode_sales/sales/index.html.erb +25 -17
  43. data/app/views/educode_sales/sales/index.json.jbuilder +17 -7
  44. data/app/views/educode_sales/sales/operations.json.jbuilder +2 -2
  45. data/app/views/educode_sales/teachers/index.html.erb +19 -18
  46. data/app/views/educode_sales/teachers/index.json.jbuilder +1 -1
  47. data/app/views/layouts/educode_sales/application.html.erb +13 -2
  48. data/config/routes.rb +2 -0
  49. data/db/migrate/20210902064109_create_educode_sales_role_permissions.rb +8 -0
  50. data/db/migrate/20211220102720_add_position_to_commons.rb +12 -0
  51. data/db/migrate/20211221075146_add_school_id_to_educode_sales_businesses.rb +8 -0
  52. data/lib/educode_sales/version.rb +1 -1
  53. metadata +8 -2
@@ -12,7 +12,7 @@
12
12
  <%= select_tag "department_id",options_for_select(@school.departments.pluck(:name, :id)), { include_blank: true}%>
13
13
  </div>
14
14
  </div>
15
- <div class="layui-form-item " style="padding-left: 110px">
15
+ <div class="layui-form-item " style="padding-left: 150px">
16
16
  <button type="submit" class="layui-btn layui-btn-normal" lay-submit lay-filter="add_follow_up">提交
17
17
  </button>
18
18
  </div>
@@ -393,7 +393,7 @@
393
393
  content = miniPage.getHrefContent('/missions/customers/edit_follow_record?id=' + data.id);
394
394
  openWH = miniPage.getOpenWidthHeight();
395
395
  editFollowIndex = layer.open({
396
- title: '编辑',
396
+ title: '编辑跟进记录',
397
397
  type: 1,
398
398
  shade: 0.2,
399
399
  maxmin: true,
@@ -1,10 +1,10 @@
1
1
  <h1 class="text-center" style="padding: 25px"><%=@school.name %></h1>
2
2
  <form class="layui-form form-value" action="">
3
3
  <div class="layui-form-item" style="padding: 25px">
4
- <div class="layui-inline">
4
+ <div class="layui-form-item layui-form-text">
5
5
  <label class="layui-form-label">跟进内容:</label>
6
- <div class="layui-input-inline">
7
- <span><%= @follow_up.content%></span>
6
+ <div class="layui-input-block" style="padding-right: 20px;">
7
+ <pre><%= @follow_up.content %></pre>
8
8
  </div>
9
9
  </div>
10
10
  <br>
@@ -7,6 +7,7 @@ json.data do
7
7
  json.description d.description
8
8
  json.advise d.advise
9
9
  json.school d.business.department.school.name
10
+ json.school_id d.business.department.school.id
10
11
  json.created_at d.created_at.to_s
11
12
  json.business d.business.name
12
13
  json.business_id d.business.id
@@ -0,0 +1,222 @@
1
+ <div style="margin: 10px 10px 10px 10px">
2
+ <form class="layui-form layui-form-pane" lay-filter="search_teachers">
3
+ <div class="layui-form-item">
4
+ <div class="layui-inline">
5
+ <label class="layui-form-label">所属商机</label>
6
+ <div class="layui-input-inline">
7
+ <input type="text" name="business" autocomplete="off" class="layui-input">
8
+ </div>
9
+ </div>
10
+ <div class="layui-inline">
11
+ <label class="layui-form-label">单位</label>
12
+ <div class="layui-input-inline">
13
+ <input type="text" name="school" autocomplete="off" class="layui-input">
14
+ </div>
15
+ </div>
16
+ <div class="layui-inline">
17
+ <label class="layui-form-label">负责人</label>
18
+ <div class="layui-input-inline">
19
+ <%= select_tag "staff_id", options_for_select(@staffs, params[:staff_id]), { 'lay-filter': 'staff_id', include_blank: true } %>
20
+ </div>
21
+ </div>
22
+ <div class="layui-inline">
23
+ <label class="layui-form-label">状态</label>
24
+ <div class="layui-input-inline">
25
+ <%= select_tag "clazz", options_for_select(['已完成','未完成']), { include_blank: true } %>
26
+ </div>
27
+ </div>
28
+ <div class="layui-inline">
29
+ <label class="layui-form-label">回款时间</label>
30
+ <div class="layui-input-inline">
31
+ <input type="text" class="layui-input" id="date" name="date" placeholder=" - ">
32
+ </div>
33
+ </div>
34
+ <div class="layui-inline">
35
+ <button type="reset" class="layui-btn layui-btn-primary" lay-submit lay-filter="reset_business_search">重置
36
+ </button>
37
+ <button type="submit" class="layui-btn layui-btn-primary" id="search_bt" lay-submit lay-filter="search_teachers">搜 索
38
+ </button>
39
+ </div>
40
+ </div>
41
+ </form>
42
+ </div>
43
+
44
+ <script type="text/html" id="toolbarDemo">
45
+ <div class="layui-btn-container">
46
+ <span class="table-label">回款列表</span>
47
+ </div>
48
+ </script>
49
+
50
+ <table class="layui-hide" id="place" lay-filter="place"></table>
51
+
52
+ <script type="text/html" id="currentTableBar">
53
+ </script>
54
+ <script type="text/html" id="business">
55
+ <a href="javascript:void(0);" lay-event="business" class="layui-table-link">{{ d.business }}</a>
56
+ </script>
57
+
58
+ <script type="text/html" id="school">
59
+ <a href="<%= base_url%>/colleges/{{d.school_id}}/statistics" class="layui-table-link" target="_blank">{{ d.school }}</a>
60
+ </script>
61
+
62
+ <script>
63
+ layui.use(['form', 'table', 'miniPage', 'element', 'request'], function () {
64
+ var $ = layui.jquery,
65
+ form = layui.form,
66
+ table = layui.table,
67
+ request = layui.request,
68
+ miniPage = layui.miniPage;
69
+ laydate = layui.laydate;
70
+
71
+
72
+ laydate.render({
73
+ elem: '#date',
74
+ range: true
75
+ });
76
+
77
+ table.render({
78
+ elem: '#place',
79
+ url: '/missions/money_plans',
80
+ toolbar: '#toolbarDemo',
81
+ totalRow: true,
82
+ defaultToolbar: ['filter'],
83
+ initSort: {
84
+ field: 'date_at' //排序字段,对应 cols 设定的各字段名
85
+ ,type: 'desc' //排序方式 asc: 升序、desc: 降序、null: 默认排序
86
+ },
87
+ cols: [
88
+ [
89
+ {
90
+ field: 'id',
91
+ width: 80,
92
+ title:'序号',type: 'numbers',
93
+ totalRowText:'本页/总计'
94
+ },
95
+ {
96
+ field: 'date_at',
97
+ width: 120,
98
+ sort: true,
99
+ title: '回款时间'
100
+ },
101
+ {
102
+ field: 'amount',
103
+ width: 200,
104
+ sort: true,
105
+ totalRow:true,
106
+ title: '回款金额',
107
+ },
108
+ {
109
+ field: 'clazz',
110
+ width: 100,
111
+ title: '状态',
112
+ },
113
+ {
114
+ field: 'business',
115
+ title: '所属商机',
116
+ templet: "#business",
117
+
118
+ },
119
+ {
120
+ field: 'school',
121
+ title: '单位',
122
+ templet: "#school",
123
+ },
124
+ {
125
+ field: 'staff',
126
+ width: 90,
127
+ title: '负责人',
128
+ },
129
+ ]
130
+ ],
131
+ limit: 20,
132
+ limits: [10,15,20,30,40,50,60,70,80,90],
133
+ page: true
134
+ });
135
+
136
+ var sort = {}, search = {};
137
+ table.on('sort(place)', function (obj) {
138
+ sort.field = obj.field;
139
+ sort.order = obj.type;
140
+ table.reload('place', {
141
+ initSort: obj,
142
+ where: {
143
+ sort: sort,
144
+ q: search
145
+ }
146
+ });
147
+ })
148
+
149
+ // 监听搜索操作
150
+ form.on('submit(search_teachers)', function (data) {
151
+ search = data.field
152
+ table.reload('place', {
153
+ page: {
154
+ curr: 1
155
+ },
156
+ where: {q: search, sort: sort}
157
+ }, 'data');
158
+ return false;
159
+ });
160
+
161
+ form.on('submit(reset_business_search)', function (data) {
162
+ var field = data.field;
163
+ form.val('search_teachers', {
164
+ area: "",
165
+ date: "",
166
+ staff_id: "",
167
+ clazz: "",
168
+ professional_title: "",
169
+ school: "",
170
+ business: ""
171
+ });
172
+ return false;
173
+ });
174
+
175
+ table.on('tool(place)', function (obj) {
176
+ var data = obj.data;
177
+ id = data.id
178
+ if (obj.event === 'add_event') { // 监听添加操作
179
+ var content = miniPage.getHrefContent('/missions/businesses/show_follow_record?follow_up_id=' + data.id);
180
+ var openWH = miniPage.getOpenWidthHeight();
181
+ show_index = layer.open({
182
+ title: '查看商机跟进记录',
183
+ type: 1,
184
+ shade: 0.2,
185
+ maxmin: true,
186
+ shadeClose: true,
187
+ area: [openWH[0] + 'px', openWH[1] + 'px'],
188
+ offset: [openWH[2] + 'px', openWH[3] + 'px'],
189
+ content: content
190
+ });
191
+ $(window).on("resize", function () {
192
+ layer.full(index);
193
+ });
194
+ } else if (obj.event === 'business') {
195
+ console.log(data);
196
+ business_id = data.business_id
197
+ business_name = data.business
198
+ content = miniPage.getHrefContent('/missions/businesses/show_follow?id=' + data.business_id);
199
+ openWH = miniPage.getOpenWidthHeight();
200
+ index = layer.open({
201
+ title: '商机列表/' + data.business + '的跟进记录',
202
+ type: 1,
203
+ shade: 0.2,
204
+ maxmin: true,
205
+ shadeClose: true,
206
+ area: [openWH[0] + 'px', openWH[1] + 'px'],
207
+ offset: [openWH[2] + 'px', openWH[3] + 'px'],
208
+ content: content
209
+ });
210
+ $(window).on("resize", function () {
211
+ layer.full(index);
212
+ });
213
+ }
214
+ });
215
+
216
+ });
217
+ </script>
218
+ <style>
219
+ .layui-table-tool-temp{
220
+ padding-right: 0px; !important;
221
+ }
222
+ </style>
@@ -0,0 +1,21 @@
1
+ total_amount = 0
2
+ json.data do
3
+ json.array! @money_plans do |d|
4
+ json.id d.id
5
+ json.date_at d.date_at.to_s(:date)
6
+ json.amount d.amount
7
+ total_amount += d.amount
8
+ json.clazz d.clazz
9
+ json.business d.follow_up.business.name
10
+ json.business_id d.follow_up.business.id
11
+ json.school School.find(d.follow_up.business.school_id).name
12
+ json.school_id School.find(d.follow_up.business.school_id).id
13
+ json.staff d.staff.user.real_name
14
+ end
15
+ end
16
+
17
+ json.totalRow do
18
+ json.amount total_amount.round(2).to_s + '/' + @total_amount.round(2).to_s
19
+ end
20
+ json.code 0
21
+ json.count @money_plans.total_count
@@ -1,3 +1,22 @@
1
+ <div style="margin: 10px 10px 10px 10px">
2
+ <form class="layui-form layui-form-pane" lay-filter="search_teachers">
3
+ <div class="layui-form-item">
4
+ <div class="layui-inline">
5
+ <label class="layui-form-label">渠道名称</label>
6
+ <div class="layui-input-inline">
7
+ <input type="text" name="name" autocomplete="off" class="layui-input">
8
+ </div>
9
+ </div>
10
+ <div class="layui-inline">
11
+ <button type="reset" class="layui-btn layui-btn-primary" lay-submit lay-filter="reset_business_search">重置
12
+ </button>
13
+ <button type="submit" class="layui-btn layui-btn-primary" id="search_bt" lay-submit lay-filter="search_teachers">搜 索
14
+ </button>
15
+ </div>
16
+ </div>
17
+ </form>
18
+ </div>
19
+
1
20
  <script type="text/html" id="toolbarDemo">
2
21
  <div class="layui-btn-container">
3
22
  <span class="table-label">渠道列表</span>
@@ -35,6 +54,51 @@
35
54
  request = layui.request,
36
55
  miniPage = layui.miniPage;
37
56
 
57
+
58
+
59
+ var sort = {}, search = {};
60
+ table.on('sort(place)', function (obj) {
61
+ sort.field = obj.field;
62
+ sort.order = obj.type;
63
+ table.reload('place', {
64
+ initSort: obj,
65
+ where: {
66
+ sort: sort,
67
+ q: search
68
+ }
69
+ });
70
+ })
71
+
72
+ // 监听搜索操作
73
+ form.on('submit(search_teachers)', function (data) {
74
+ search = data.field
75
+ table.reload('place', {
76
+ page: {
77
+ curr: 1
78
+ },
79
+ where: {q: search, sort: sort}
80
+ }, 'data');
81
+ return false;
82
+ });
83
+
84
+ form.on('submit(reset_business_search)', function (data) {
85
+ var field = data.field;
86
+ form.val('search_teachers', {
87
+ area: "",
88
+ date: "",
89
+ attitude: "",
90
+ name: "",
91
+ professional_title: "",
92
+ regist_at: "",
93
+ staff_id: "",
94
+ status: "",
95
+ school: "",
96
+ assist: "",
97
+ teacher_source: ""
98
+ });
99
+ return false;
100
+ });
101
+
38
102
  table.render({
39
103
  elem: '#place',
40
104
  url: '/missions/places',
@@ -67,12 +131,26 @@
67
131
  templet: "#business_a",
68
132
 
69
133
  },
134
+ // {
135
+ // field: 'amount',
136
+ // width: 120,
137
+ // totalRow:true,
138
+ // sort: true,
139
+ // title: '中标金额'
140
+ // },
141
+ {
142
+ field: 'total_amount',
143
+ width: 120,
144
+ totalRow:true,
145
+ sort: true,
146
+ title: '项目总额'
147
+ },
70
148
  {
71
- field: 'amount',
149
+ field: 'divide_amount',
72
150
  width: 120,
73
151
  totalRow:true,
74
152
  sort: true,
75
- title: '中标金额'
153
+ title: '渠道分成'
76
154
  },
77
155
  {
78
156
  field: 'return_mount',
@@ -17,7 +17,9 @@ json.data do
17
17
  business_count = EducodeSales::Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", @x).where("educode_sales_follow_ups.place_id = #{d.id}").count
18
18
  json.businesses_count business_count
19
19
  all_businesses_count += business_count
20
- json.amount EducodeSales::Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", @x).where("educode_sales_follow_ups.place_id = #{d.id} AND educode_sales_follow_ups.stage_id IN (?)", @stage_ids).sum("actual_amount - divide_amount").round(2)
20
+ # json.amount EducodeSales::Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", @x).where("educode_sales_follow_ups.place_id = #{d.id} AND educode_sales_follow_ups.stage_id IN (?)", @stage_ids).sum("actual_amount - divide_amount").round(2)
21
+ json.total_amount EducodeSales::Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", @x).where("educode_sales_follow_ups.place_id = #{d.id} AND educode_sales_follow_ups.stage_id IN (?)", @stage_ids).sum("actual_amount").round(2)
22
+ json.divide_amount EducodeSales::Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", @x).where("educode_sales_follow_ups.place_id = #{d.id} AND educode_sales_follow_ups.stage_id IN (?)", @stage_ids).sum("divide_amount").round(2)
21
23
  json.return_mount EducodeSales::Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", @x).where("educode_sales_follow_ups.place_id = #{d.id}").sum(:return_money).round(2)
22
24
  end
23
25
  end
@@ -249,7 +249,8 @@
249
249
  });
250
250
  return false;
251
251
  } else if (obj.event === 'show_follow') {
252
- id = data.business_id
252
+ business_id = obj.data.business_id
253
+ id = data.business_id
253
254
  content = miniPage.getHrefContent('/missions/businesses/show_follow?id=' + data.business_id);
254
255
  openWH = miniPage.getOpenWidthHeight();
255
256
  index = layer.open({
@@ -265,7 +265,8 @@
265
265
  });
266
266
  return false;
267
267
  } else if (obj.event === 'show_follow') {
268
- id = data.business_id
268
+ business_id = obj.data.business_id
269
+ // business_name = data.name
269
270
  content = miniPage.getHrefContent('/missions/businesses/show_follow?id=' + data.business_id);
270
271
  openWH = miniPage.getOpenWidthHeight();
271
272
  index = layer.open({
@@ -5,8 +5,8 @@ json.data do
5
5
  json.name business.name
6
6
  json.school business.department.school.name
7
7
  json.department business.department.name
8
- json.last_follow_person business.last_follow_up.present? ? business.last_follow_up.staff.user.real_name : EducodeSales::Staff.find(business.staff_id).user.real_name
9
- json.latest_time business.last_follow_up.present? ? business.last_follow_up.created_at.to_s : business.created_at.to_s
8
+ json.last_follow_person business.last_follow_up_id.present? ? EducodeSales::FollowUp.unscoped.find(business.last_follow_up_id).staff.user.real_name : EducodeSales::Staff.find(business.staff_id).user.real_name
9
+ json.latest_time business.last_follow_up_id.present? ? EducodeSales::FollowUp.unscoped.find(business.last_follow_up_id).created_at.to_s : business.created_at.to_s
10
10
  json.deleter EducodeSales::Staff.find(d.deleter_id).user.real_name
11
11
  json.delete_time d.created_at.to_s
12
12
  end
@@ -7,7 +7,7 @@
7
7
  <div class="layui-tab-item layui-show">
8
8
  <form class="layui-form line" action="">
9
9
  <% id = 0 %>
10
- <% EducodeSales::Permission.all.group_by{ |d| d.clazz}.each do |k, d| %>
10
+ <% EducodeSales::Permission.all.order(position: :asc).group_by{ |d| d.clazz}.each do |k, d| %>
11
11
  <div class="layui-form-item">
12
12
  <label class="layui-form-label"><%= k %></label>
13
13
  <div class="layui-input-block">
@@ -36,6 +36,14 @@
36
36
  <%= radio_button_tag("business", "全部", @areas.include?("商机管理-全部"), {title: '全部列表', id: 3}) %>
37
37
  </div>
38
38
  </div>
39
+ <div class="layui-form-item" style="border-top: 1px solid #ddd;">
40
+ <label class="layui-form-label">回款管理</label>
41
+ <div class="layui-input-block">
42
+ <%= radio_button_tag("money_plan", "自己", @areas.include?("回款管理-自己"), {title: '本人负责列表', id: 16}) %>
43
+ <%= radio_button_tag("money_plan", "区域", @areas.include?("回款管理-区域"), {title: '本人负责区域列表', id: 17}) %>
44
+ <%= radio_button_tag("money_plan", "全部", @areas.include?("回款管理-全部"), {title: '全部列表', id: 18}) %>
45
+ </div>
46
+ </div>
39
47
  <div class="layui-form-item">
40
48
  <label class="layui-form-label">客户管理</label>
41
49
  <div class="layui-input-block">
@@ -220,7 +220,7 @@
220
220
  </div>
221
221
  </div>
222
222
  <div class="layui-inline">
223
- <button type="submit" id="search_bt" class=" follow_count_bt layui-btn layui-btn-primary" lay-submit lay-filter="search_bussiness">确定
223
+ <button type="button" id="search_bt" class=" follow_count_bt layui-btn layui-btn-primary" lay-submit lay-filter="search_bussiness">确定
224
224
  </button>
225
225
  </div>
226
226
  </div>
@@ -261,7 +261,7 @@
261
261
  </div>
262
262
  </div>
263
263
  <div class="layui-inline">
264
- <button type="submit" id="search_bt" class="follow_count_bt layui-btn layui-btn-primary" lay-submit lay-filter="search_bussiness">确定
264
+ <button type="button" id="search_bt" class="goal_count_bt layui-btn layui-btn-primary" lay-submit lay-filter="search_bussiness">确定
265
265
  </button>
266
266
  </div>
267
267
  </div>
@@ -272,6 +272,41 @@
272
272
 
273
273
  </div>
274
274
  </div>
275
+ <br>
276
+ <br>
277
+ <div class="layui-tab layui-tab-card " id="销售额分析" lay-filter="test1">
278
+ <ul class="layui-tab-title">
279
+ <li class="layui-this">商机区域分布</li>
280
+ </ul>
281
+ <div class="layui-tab-content" style="padding-right: 50px">
282
+ <div class="layui-tab-item layui-show" style="padding-left: 20px">
283
+ <div style="margin: 10px 10px 10px 10px">
284
+ <form class="layui-form layui-form-pane" lay-filter="search_form">
285
+ <div class="layui-form-item">
286
+ <div class="layui-inline m-t-10">
287
+ <label class="layui-form-label">维度</label>
288
+ <div class="layui-input-inline">
289
+ <%= select_tag "business_count_type", options_for_select([['按商机总额统计','money'],['按商机数量统计','count']],params[:goal_count_range]), {'lay-filter': 'goal_count'}%>
290
+ </div>
291
+ </div>
292
+ <div class="layui-inline m-t-10">
293
+ <label class="layui-form-label">商机类型</label>
294
+ <div class="layui-input-inline">
295
+ <%= select_tag "business_type", options_for_select(EducodeSales::Common.where(clazz: 'business_type').where.not(extras: "x_class").pluck(:name, :id), params[:clazz_id]), { 'lay-filter': 'clazz_id', include_blank: true } %>
296
+ </div>
297
+ </div>
298
+ <div class="layui-inline">
299
+ <button type="button" id="search_bt" class="business_bt layui-btn layui-btn-primary" lay-submit lay-filter="business_chart">确定
300
+ </button>
301
+ </div>
302
+ </div>
303
+ </form>
304
+ </div>
305
+ <canvas id="myChart3" width="960" height="200"></canvas>
306
+ </div>
307
+
308
+ </div>
309
+ </div>
275
310
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/chart.js@2.9.1/dist/Chart.min.css">
276
311
  <script src="https://cdn.jsdelivr.net/npm/chart.js@2.9.1/dist/Chart.min.js"></script>
277
312
  <script>
@@ -294,17 +329,6 @@
294
329
  var element = layui.element;
295
330
  laydate = layui.laydate;
296
331
 
297
- $(document).ready(function () {
298
- $(".follow_count_bt").click(function () {
299
- layer.msg("图表绘制中...", {
300
- offset:['40%','46%']
301
- })
302
- layer.load(0, {});
303
- setTimeout(function () {
304
- layer.closeAll('loading');
305
- }, 3000);
306
- });
307
- });
308
332
  if(follow_type == "day"){
309
333
  $(".year").addClass('layui-hide')
310
334
  $(".month").addClass('layui-hide')
@@ -498,5 +522,61 @@
498
522
  data: <%=raw @goal_count_data.to_json %>,
499
523
  options: opt
500
524
  });
525
+
526
+ var ctx = document.getElementById('myChart3');
527
+ var myChart3 = new Chart(ctx, {
528
+ type: 'bar',
529
+ data: <%=raw @business_data.to_json %>,
530
+ options: opt
531
+ });
532
+
533
+ $(document).ready(function () {
534
+ $(".follow_count_bt").click(function () {
535
+ layer.load(0, {});
536
+ $.get('/missions/sale_trends/trends.json?follow_count_range=' + $("#follow_count_range").val() + '&date_month=' + $("#date_month").val() + '&date_week=' + $("#date_week").val() + '&date_year=' + $("#date_year").val() + '&date=' + $("#date").val()).done(function(res) {
537
+ layer.closeAll('loading');
538
+ var data1 = res.data1;
539
+ var ctx = document.getElementById('myChart');
540
+ var myChart = new Chart(ctx, {
541
+ type: 'line',
542
+ data: data1,
543
+ options: {
544
+ elements: {
545
+ line: {
546
+ tension: 0
547
+ }
548
+ }
549
+ }
550
+ });
551
+ });
552
+ });
553
+ $(".goal_count_bt").click(function () {
554
+ layer.load(0, {});
555
+ $.get('/missions/sale_trends/trends.json?count_type=' + $("#count_type").val() + '&goal_count_range=' + $("#goal_count_range").val() + '&goal_date_month=' + $("#goal_date_month").val() + '&goal_date_year=' + $("#goal_date_year").val()).done(function(res) {
556
+ layer.closeAll('loading');
557
+ var data2 = res.data2;
558
+ var ctx = document.getElementById('myChart2');
559
+ var myChart2 = new Chart(ctx, {
560
+ type: 'bar',
561
+ data: data2,
562
+ options: opt
563
+ });
564
+ });
565
+ });
566
+ $(".business_bt").click(function () {
567
+ layer.load(0, {});
568
+ $.get('/missions/sale_trends/trends.json?business_count_type=' + $("#business_count_type").val() + '&business_type=' + $("#business_type").val()).done(function(res) {
569
+ layer.closeAll('loading');
570
+ var data3 = res.data3;
571
+ var ctx = document.getElementById('myChart3');
572
+ var myChart3 = new Chart(ctx, {
573
+ type: 'bar',
574
+ data: data3,
575
+ options: opt
576
+ });
577
+ });
578
+ });
579
+ });
580
+
501
581
  })
502
582
  </script>
@@ -1,14 +1,3 @@
1
- my_array = [1,2,3,4,5]
2
- json.data do
3
- json.labels my_array
4
- json.datasets do
5
- json.array! [1,2] do |d|
6
- json.label '人名'
7
- json.backgroundColor "#fff"
8
- json.borderColor "#36A2EB"
9
- json.pointBackgroundColor "#36A2EB"
10
- json.pointBorderColor "#fff"
11
- json.data my_array
12
- end
13
- end
14
- end
1
+ json.data1 @follow_count_data
2
+ json.data2 @goal_count_data
3
+ json.data3 @business_data