educode_sales 0.4.4 → 0.4.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 (35) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/educode_sales/businesses_controller.rb +6 -3
  3. data/app/controllers/educode_sales/plans_controller.rb +6 -2
  4. data/app/models/educode_sales/teacher.rb +12 -19
  5. data/app/views/educode_sales/activities/index.html.erb +4 -0
  6. data/app/views/educode_sales/activities/index.json.jbuilder +6 -0
  7. data/app/views/educode_sales/businesses/index.html.erb +8 -3
  8. data/app/views/educode_sales/businesses/index.json.jbuilder +7 -1
  9. data/app/views/educode_sales/operation_plans/_monthPlan.html.erb +5 -1
  10. data/app/views/educode_sales/operation_plans/_monthly.html.erb +14 -0
  11. data/app/views/educode_sales/operation_plans/_weekPlan.html.erb +5 -1
  12. data/app/views/educode_sales/operation_plans/_weekly.html.erb +14 -0
  13. data/app/views/educode_sales/operation_plans/index.json.jbuilder +10 -2
  14. data/app/views/educode_sales/operation_plans/new_monthly.html.erb +4 -2
  15. data/app/views/educode_sales/operation_plans/new_weekly.html.erb +4 -2
  16. data/app/views/educode_sales/operation_reports/index.json.jbuilder +7 -0
  17. data/app/views/educode_sales/places/index.html.erb +5 -0
  18. data/app/views/educode_sales/plans/_monthPlan.html.erb +3 -0
  19. data/app/views/educode_sales/plans/_monthly.html.erb +15 -0
  20. data/app/views/educode_sales/plans/_weekPlan.html.erb +3 -0
  21. data/app/views/educode_sales/plans/_weekly.html.erb +16 -0
  22. data/app/views/educode_sales/plans/index.json.jbuilder +4 -0
  23. data/app/views/educode_sales/plans/new_monthly.html.erb +4 -2
  24. data/app/views/educode_sales/plans/new_weekly.html.erb +4 -2
  25. data/app/views/educode_sales/sale_reports/index.json.jbuilder +7 -0
  26. data/app/views/educode_sales/sales/index.html.erb +6 -0
  27. data/app/views/educode_sales/sales/index.json.jbuilder +20 -4
  28. data/app/views/educode_sales/sales/operations.html.erb +4 -0
  29. data/app/views/educode_sales/sales/operations.json.jbuilder +12 -3
  30. data/app/views/educode_sales/teachers/index.html.erb +5 -0
  31. data/app/views/educode_sales/teachers/index.json.jbuilder +12 -2
  32. data/app/views/layouts/educode_sales/application.html.erb +1 -1
  33. data/db/migrate/20211022085324_add_teacher_used_to_teachers.rb +7 -0
  34. data/lib/educode_sales/version.rb +1 -1
  35. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bbb707c74c7909b2a42a4cc3eaf395677a436c8a210db16ba31cfb5abb0c9cdd
4
- data.tar.gz: 7c08a37d777b84396fc415076c6fa768eb0bd9dc56d9e6307451832212141a71
3
+ metadata.gz: 685592848049f4a9fbcb75c52c46eb4a1ad1ee9cf14725b44a7c79ad0e0714d1
4
+ data.tar.gz: 8b3ac5946bdb350f6bb92b79f7ab9a5ba91678e24c24ae70b06766709f84fb3d
5
5
  SHA512:
6
- metadata.gz: d96671e32dfe8e9469c6f93927cf453d86861004d123bbbc01b1118295e7827fd37a1b039ac629a51803d1132341afed7b58fb630919387251253481377d7720
7
- data.tar.gz: '0628d9062d5c4b72851dc9cbb0f997169cb395713c3e20263c7b32df369ef323c79370955dffb428b88ff33d9cb297e0ebd3720b1c6bb1f04fdeeb198fbf49ad'
6
+ metadata.gz: 14cdf1d7faa137de66574701ff7e13e76820bfed31e92960118a1407358c69134c07e51f251532e38de575064d667ab9f2c54d9299a6f59f51a150ffd1b73d83
7
+ data.tar.gz: 15b1c39abb61f478992198b04698af35cc90e1a6077b697c83d107e1d47c448fbc571436681b630e147aee10fbcb73607e0f7aae5567359e2ceeab4188959f98
@@ -47,8 +47,6 @@ module EducodeSales
47
47
  if params[:q].present? && params[:q][:mine].present?
48
48
  ids = AssignFollowUp.where(staff_id: @current_admin.id).pluck(:follow_up_id)
49
49
  ids1 = FollowUp.where(id: ids).pluck(:business_id)
50
- # ids2 = Business.where(staff_id: @current_admin.id).pluck(:id)
51
- # @businesses = Business.where(id: ids1+ids2)
52
50
  @businesses =@businesses.where("educode_sales_businesses.id in (?) or educode_sales_businesses.staff_id = ?", ids1, @current_admin.id)
53
51
  end
54
52
 
@@ -61,7 +59,12 @@ module EducodeSales
61
59
  @businesses = @businesses.joins(:department).where("departments.id in (?)", departments_ids)
62
60
  end
63
61
  if params[:q].present? && params[:q][:staff_id].present?
64
- @businesses = @businesses.where(staff_id: params[:q][:staff_id])
62
+ part_a_ids = @businesses.where("educode_sales_businesses.last_follow_up_id is null AND staff_id = ?",params[:q][:staff_id]).ids
63
+ part_b_ids = @businesses.where("educode_sales_businesses.last_follow_up_id is not null").joins("
64
+ JOIN educode_sales_follow_ups ON educode_sales_businesses.last_follow_up_id = educode_sales_follow_ups.id
65
+ ").where("educode_sales_follow_ups.staff_id = ?", params[:q][:staff_id]).pluck(:business_id)
66
+ business_ids = part_a_ids + part_b_ids
67
+ @businesses = EducodeSales::Business.where(id:business_ids)
65
68
  end
66
69
  if params[:q].present? && params[:q][:business_type].present?
67
70
  @businesses = @businesses.joins("
@@ -78,7 +78,9 @@ module EducodeSales
78
78
  else
79
79
  @weeks = [week]
80
80
  end
81
- @businesses = @current_admin.businesses.pluck(:name, :id)
81
+ ids = AssignFollowUp.where(staff_id: @current_admin.id).pluck(:follow_up_id)
82
+ ids1 = FollowUp.where(id: ids).pluck(:business_id)
83
+ @businesses =Business.where("educode_sales_businesses.id in (?) or educode_sales_businesses.staff_id = ?", ids1, @current_admin.id).pluck(:name, :id)
82
84
  render layout: false
83
85
  end
84
86
 
@@ -92,7 +94,9 @@ module EducodeSales
92
94
 
93
95
  def new_month
94
96
  @business = Business.find_by(id: params[:business_id])
95
- @businesses = @current_admin.businesses.pluck(:name, :id)
97
+ ids = AssignFollowUp.where(staff_id: @current_admin.id).pluck(:follow_up_id)
98
+ ids1 = FollowUp.where(id: ids).pluck(:business_id)
99
+ @businesses =Business.where("educode_sales_businesses.id in (?) or educode_sales_businesses.staff_id = ?", ids1, @current_admin.id).pluck(:name, :id)
96
100
  render layout: false
97
101
  end
98
102
 
@@ -13,29 +13,22 @@ module EducodeSales
13
13
  belongs_to :follow_up, class_name: 'TeacherFollow', optional: true
14
14
  validates :user_id, uniqueness: { allow_blank: true, message: '已存在老师列表'}
15
15
 
16
+ def cal_courses_count
17
+ if self.user_id.present?
18
+ Course.joins(:course_members).where(course_members: {user_id: self.user_id}).where("is_delete = 0 and role != 4 and excellent = 0 and is_hidden = 0").where("start_date is null or start_date <= '#{Date.today}'").distinct(:course_id).count
19
+ else
20
+ 0
21
+ end
22
+ end
16
23
 
17
- # def teacher_used_of_department
18
- # if user_id.present?
19
- # user_ids = User.joins(:user_extension).where(user_extensions: {department_id: self.department_id, identity: 0}).pluck(:id)
20
- # course_ids = CourseMember.where(role: "CREATOR", user_id: user_ids).pluck(:course_id)
21
- # if course_ids.present?
22
- # course_members = CourseMember.joins(course: :practice_homework_shixuns).where(course_id: course_ids).group("course_id").having("COUNT(homework_commons_shixuns.id) > 100 AND COUNT(course_members.user_id) > 20").select("COUNT(case when course_members.role !=4 then 1 END) AS count")
23
- # course_members.present? ? course_members[0]['count'] : 0
24
- # else
25
- # 0
26
- # end
27
- # else
28
- # 0
29
- # end
30
- # end
31
24
  def teacher_used_of_department
32
- user_ids = User.joins(:user_extension).where(user_extensions: {department_id: self.department_id, identity: 0}).pluck(:id)
33
- course_ids = CourseMember.where(role: "CREATOR", user_id: user_ids).pluck(:course_id)
34
- course_members = CourseMember.joins(course: :practice_homework_shixuns).where(course_id: course_ids).group("course_id").having("COUNT(homework_commons_shixuns.id) > 100 AND COUNT(course_members.user_id) > 20").select("COUNT(case when course_members.role !=4 then 1 END) AS count")
35
- course_members.present? ? course_members[0]['count'] : 0
25
+ user_ids = User.joins(:user_extension).where(user_extensions: {department_id: self.department_id, identity: 0}).pluck(:id)
26
+ course_ids = CourseMember.where(role: "CREATOR", user_id: user_ids).pluck(:course_id)
27
+ course_members = CourseMember.joins(course: :practice_homework_shixuns).where(course_id: course_ids).group("course_id").having("COUNT(homework_commons_shixuns.id) > 100 AND COUNT(course_members.user_id) > 20").select("COUNT(case when course_members.role !=4 then 1 END) AS count")
28
+ course_members.present? ? course_members[0]['count'] : 0
36
29
  end
37
30
 
38
- def students_count
31
+ def cal_students_count
39
32
  if user_id.present?
40
33
  course_ids = Course.joins(:course_members).where(course_members: {user_id: user_id}).where("is_delete = 0 and role != 4 and excellent = 0 and is_hidden = 0").where("start_date is null or start_date <= '#{Date.today}'").distinct("course_id").pluck(:course_id)
41
34
  CourseMember.where(course_id: course_ids, role: "STUDENT").count
@@ -39,12 +39,14 @@
39
39
  elem: '#activities_table',
40
40
  url: '/missions/activities',
41
41
  toolbar: '#activity_toolbar',
42
+ totalRow:true,
42
43
  defaultToolbar: [],
43
44
  cols: [
44
45
  [
45
46
  {
46
47
  field: 'id',
47
48
  title:'序号',type: 'numbers',
49
+ totalRowText:'合计',
48
50
  width: 60
49
51
  },
50
52
  {
@@ -68,11 +70,13 @@
68
70
  field: 'teachers_count',
69
71
  title: '教师数',
70
72
  width: 100,
73
+ totalRow:true,
71
74
  templet: '#teachers_count'
72
75
  },
73
76
  {
74
77
  field: 'students_count',
75
78
  title: '学生数',
79
+ totalRow:'{{ parseInt(d.TOTAL_NUMS) }}',
76
80
  width: 100
77
81
  },
78
82
  {
@@ -1,14 +1,20 @@
1
+ teachers_count = 0
1
2
  json.data do
2
3
  json.array! @activities do |d|
3
4
  json.id d.id
4
5
  json.name d.name
5
6
  json.days d.days
6
7
  json.teachers_count d.activity_teachers_count
8
+ teachers_count += d.activity_teachers_count
7
9
  json.return_rate d.return_rate
8
10
  json.students_count d.students_count || 0
9
11
  json.course_rate d.course_rate
10
12
  json.start_at d.start_at ? d.start_at.to_s(:date) : ''
11
13
  end
12
14
  end
15
+
16
+ json.totalRow do
17
+ json.teachers_count teachers_count.to_s
18
+ end
13
19
  json.code 0
14
20
  json.count @activities.total_count
@@ -115,6 +115,7 @@
115
115
  url: '/missions/businesses',
116
116
  where: {q: form.val('search_form')},
117
117
  toolbar: '#bussinessBar',
118
+ totalRow: true,//开启合并行
118
119
  defaultToolbar: [],
119
120
  cols: [
120
121
  [
@@ -122,6 +123,7 @@
122
123
  field: 'id',
123
124
  width: 60,
124
125
  title:'序号',type: 'numbers',
126
+ totalRowText: '合计',
125
127
  },
126
128
  {
127
129
  field: 'name',
@@ -141,8 +143,9 @@
141
143
  {
142
144
  field: 'follow_ups_count',
143
145
  title: '跟进',
144
- width: 60,
145
- templet: '#show_follow'
146
+ width: 100,
147
+ templet: '#show_follow',
148
+ totalRow: true,
146
149
  },
147
150
  // {
148
151
  // field: 'teachers_count',
@@ -176,13 +179,15 @@
176
179
  field: 'total_amount',
177
180
  width: 100,
178
181
  title: '总额',
182
+ totalRow: true,
179
183
  sort: true
180
184
  },
181
185
  {
182
186
  field: 'return_money',
183
187
  width: 100,
184
188
  title: '回款',
185
- sort: true
189
+ sort: true,
190
+ totalRow: true
186
191
  },
187
192
  {
188
193
  field: 'place',
@@ -1,3 +1,4 @@
1
+ follow_ups_count = 0
1
2
  json.data do
2
3
  json.array! @businesses do |d|
3
4
  json.id d.id
@@ -5,6 +6,7 @@ json.data do
5
6
  json.department d.department.name
6
7
  json.school d.department.school.name
7
8
  json.follow_ups_count d.follow_ups_count
9
+ follow_ups_count += d.follow_ups_count
8
10
  json.follow_up_id d.last_follow_up_id
9
11
  # json.teachers_count d.follow_ups.sum(:key_people_count)
10
12
  # json.teachers_count EducodeSales::FollowUp.order(created_at: :desc).find_by(business_id: d.id).present? ? EducodeSales::FollowUp.order(created_at: :desc).find_by(business_id: d.id).key_people_count : 0
@@ -15,7 +17,7 @@ json.data do
15
17
  json.total_amount d.last_follow_up&.total_amount
16
18
  json.return_money d.return_money
17
19
  json.place d.last_follow_up&.place&.name
18
- json.last_follow_person d.last_follow_up.present? ? d.last_follow_up.staff.user.real_name : ''
20
+ 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
19
21
  json.source d.source
20
22
  json.assign_follow_ups d.last_follow_up.present? ? d.last_follow_up.assign_follow_ups.pluck(:staff_id) : []
21
23
  json.current_staff_id @current_admin.id
@@ -23,6 +25,10 @@ json.data do
23
25
  json.latest_time d.last_follow_up.present? ? d.last_follow_up.created_at.to_s : ''
24
26
  end
25
27
  end
28
+
29
+ json.totalRow do
30
+ json.follow_ups_count follow_ups_count.to_s
31
+ end
26
32
  json.code 0
27
33
  json.count @businesses.total_count
28
34
  json.msg 'succcess'
@@ -77,6 +77,7 @@
77
77
  elem: '#monthPlanTable',
78
78
  url: '/missions/operation_plans?clazz=month',
79
79
  toolbar: '#monthPlanToolbar',
80
+ totalRow:true,
80
81
  defaultToolbar: [],
81
82
  cols: [
82
83
  [
@@ -84,6 +85,7 @@
84
85
  field: 'id',
85
86
  width: 80,
86
87
  title:'序号',type: 'numbers',
88
+ totalRowText:"合计",
87
89
  },
88
90
  {
89
91
  field: 'staff',
@@ -114,12 +116,14 @@
114
116
  field: 'count',
115
117
  width: 100,
116
118
  title: '跟进',
119
+ totalRow:true,
117
120
  templet: '#show_follow2'
118
121
  },
119
122
  {
120
- field: 'rate',
123
+ field: 'finish_rate',
121
124
  width: 80,
122
125
  title: '完成率',
126
+ totalRow:true,
123
127
  },
124
128
  {
125
129
  field: 'updated_at',
@@ -79,26 +79,35 @@
79
79
  url: '/missions/operation_reports?clazz=month',
80
80
  toolbar: '#monthlyToolbar',
81
81
  defaultToolbar: [],
82
+ totalRow:true,
82
83
  cols: [
83
84
  [
84
85
  {
85
86
  field: 'id',
86
87
  width: 80,
87
88
  title:'序号',type: 'numbers',
89
+ totalRowText:"合计",
88
90
  },
89
91
  {
90
92
  field: 'staff',
91
93
  width: 100,
92
94
  title: '姓名'
93
95
  },
96
+ {
97
+ field: 'month',
98
+ width: 100,
99
+ title: '月份'
100
+ },
94
101
  {
95
102
  field: 'finish_rate',
96
103
  width: 100,
97
104
  title: '完成率',
105
+ totalRow:true,
98
106
  },
99
107
  {
100
108
  field: 'client',
101
109
  width: 100,
110
+ totalRow:'{{ parseInt(d.TOTAL_NUMS) }}',
102
111
  title: '运营教师'
103
112
  },
104
113
  {
@@ -130,6 +139,11 @@
130
139
  return '<div class="star3"></div>'
131
140
  }
132
141
  },
142
+ {
143
+ field: 'created_at',
144
+ width: 300,
145
+ title: '提交时间',
146
+ },
133
147
  {
134
148
  title: '操作',
135
149
  minWidth: 220,
@@ -78,6 +78,7 @@
78
78
  elem: '#weekPlanTable1',
79
79
  url: '/missions/operation_plans?clazz=week',
80
80
  toolbar: '#weekPlanToolbar',
81
+ totalRow:true,
81
82
  defaultToolbar: [],
82
83
  cols: [
83
84
  [
@@ -85,6 +86,7 @@
85
86
  field: 'id',
86
87
  width: 80,
87
88
  title:'序号',type: 'numbers',
89
+ totalRowText:"合计",
88
90
  },
89
91
  {
90
92
  field: 'staff',
@@ -125,12 +127,14 @@
125
127
  field: 'count',
126
128
  width: 100,
127
129
  title: '跟进',
130
+ totalRow:true,
128
131
  templet: '#show_follow1'
129
132
  },
130
133
  {
131
- field: 'rate',
134
+ field: 'finish_rate',
132
135
  width: 80,
133
136
  title: '完成率',
137
+ totalRow:true,
134
138
  },
135
139
  {
136
140
  field: 'updated_at',
@@ -79,6 +79,7 @@
79
79
  elem: '#weeklyTable',
80
80
  url: '/missions/operation_reports?clazz=week',
81
81
  toolbar: '#weeklyToolbar',
82
+ totalRow:true,
82
83
  defaultToolbar: [],
83
84
  cols: [
84
85
  [
@@ -86,20 +87,28 @@
86
87
  field: 'id',
87
88
  width: 80,
88
89
  title:'序号',type: 'numbers',
90
+ totalRowText:"合计",
89
91
  },
90
92
  {
91
93
  field: 'staff',
92
94
  width: 100,
93
95
  title: '姓名'
94
96
  },
97
+ {
98
+ field: 'weekly',
99
+ width: 100,
100
+ title: '周次'
101
+ },
95
102
  {
96
103
  field: 'finish_rate',
97
104
  width: 100,
98
105
  title: '完成率',
106
+ totalRow:true,
99
107
  },
100
108
  {
101
109
  field: 'client',
102
110
  width: 100,
111
+ totalRow:'{{ parseInt(d.TOTAL_NUMS) }}',
103
112
  title: '运营教师'
104
113
  },
105
114
  {
@@ -131,6 +140,11 @@
131
140
  return '<div class="star3"></div>'
132
141
  }
133
142
  },
143
+ {
144
+ field: 'created_at',
145
+ width: 300,
146
+ title: '提交时间',
147
+ },
134
148
  {
135
149
  title: '操作',
136
150
  minWidth: 220,
@@ -1,3 +1,4 @@
1
+ counts = 0
1
2
  json.data do
2
3
  json.array! @sale_plans do |d|
3
4
  json.id d.id
@@ -9,11 +10,18 @@ json.data do
9
10
  json.week d.weekly
10
11
  json.teacher_id d.teacher_id
11
12
  json.content d.content.truncate(30)
12
- json.count d.teacher.teacher_follows_count
13
- json.rate "#{d.finish_rate}%"
13
+ count = d.teacher.teacher_follows_count
14
+ json.count count
15
+ counts += count
16
+ json.finish_rate "#{d.finish_rate}%"
14
17
  json.updated_at d.updated_at.to_s
15
18
  end
16
19
  end
17
20
 
21
+ json.totalRow do
22
+ sum = @sale_plans.inject(0) { |score, i| score + i.finish_rate}
23
+ json.finish_rate ( @sale_plans.size > 0 ? (sum.to_f / @sale_plans.size).round(2).to_s : '0' ) + '%'
24
+ json.count counts.to_s
25
+ end
18
26
  json.code 0
19
27
  json.count @sale_plans.total_count
@@ -4,7 +4,7 @@
4
4
  <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn pull-right" lay-event="add"> 添加计划</button>
5
5
  </div>
6
6
  </script>
7
- <form class="layui-form layui-form-pane" action="">
7
+ <form class="layui-form layui-form-pane" action="" style="padding-right: 20px">
8
8
  <div class="layui-form-item">
9
9
  <div class="layui-inline" style="margin:18px; font-weight: bold">
10
10
  <label>完成率:</label>
@@ -35,7 +35,9 @@
35
35
  </form>
36
36
 
37
37
  <!--表格-->
38
- <table class="layui-hide" id="newMonthlyTable" lay-filter="newMonthlyToolbar"></table>
38
+ <div style="padding: 20px">
39
+ <table class="layui-hide" id="newMonthlyTable" lay-filter="newMonthlyToolbar"></table>
40
+ </div>
39
41
 
40
42
  <script type="text/html" id="currentMonthly">
41
43
  <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="show">查看</a>
@@ -4,7 +4,7 @@
4
4
  <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn pull-right" lay-event="add"> 添加计划</button>
5
5
  </div>
6
6
  </script>
7
- <form class="layui-form layui-form-pane" action="">
7
+ <form class="layui-form layui-form-pane" action="" style="padding-right: 20px">
8
8
  <div class="layui-form-item">
9
9
  <div class="layui-inline" style="margin:18px; font-weight: bold">
10
10
  <label>完成率:</label>
@@ -35,7 +35,9 @@
35
35
  </form>
36
36
 
37
37
  <!--表格-->
38
- <table class="layui-hide" id="newWeeklyTable" lay-filter="newWeeklyToolbar"></table>
38
+ <div style="padding: 20px">
39
+ <table class="layui-hide" id="newWeeklyTable" lay-filter="newWeeklyToolbar"></table>
40
+ </div>
39
41
 
40
42
  <script type="text/html" id="currentWeekly">
41
43
  <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="show">查看</a>
@@ -11,8 +11,15 @@ json.data do
11
11
  json.level2_score d.level2_score || 0
12
12
  json.level3_score d.level3_score || 0
13
13
  json.updated_at d.updated_at.to_s
14
+ json.weekly d.weekly
15
+ json.created_at d.created_at.to_s
16
+ json.month d.month.strftime("%Y-%m")
14
17
  end
15
18
  end
16
19
 
20
+ json.totalRow do
21
+ sum = @sale_reports.inject(0) { |score, i| score + i.finish_rate}
22
+ json.finish_rate ( @sale_reports.size > 0 ? (sum.to_f / @sale_reports.size).round(2).to_s : '0' ) + '%'
23
+ end
17
24
  json.code 0
18
25
  json.count @sale_reports.total_count
@@ -34,6 +34,7 @@
34
34
  elem: '#place',
35
35
  url: '/missions/places',
36
36
  toolbar: '#toolbarDemo',
37
+ totalRow:true,
37
38
  defaultToolbar: [],
38
39
  cols: [
39
40
  [
@@ -41,6 +42,7 @@
41
42
  field: 'id',
42
43
  width: 80,
43
44
  title:'序号',type: 'numbers',
45
+ totalRowText:'合计',
44
46
  },
45
47
  {
46
48
  field: 'name',
@@ -54,16 +56,19 @@
54
56
  {
55
57
  field: 'businesses_count',
56
58
  width: 120,
59
+ totalRow:'{{ parseInt(d.TOTAL_NUMS) }}',
57
60
  title: '商机'
58
61
  },
59
62
  {
60
63
  field: 'amount',
61
64
  width: 120,
65
+ totalRow:true,
62
66
  title: '中标'
63
67
  },
64
68
  {
65
69
  field: 'return_mount',
66
70
  width: 120,
71
+ totalRow:true,
67
72
  title: '回款',
68
73
  },
69
74
  {
@@ -77,12 +77,14 @@
77
77
  url: '/missions/plans?clazz=month',
78
78
  toolbar: '#monthPlanToolbar',
79
79
  defaultToolbar: [],
80
+ totalRow:true,
80
81
  cols: [
81
82
  [
82
83
  {
83
84
  field: 'id',
84
85
  width: 80,
85
86
  title:'序号',type: 'numbers',
87
+ totalRowText:"合计",
86
88
  },
87
89
  {
88
90
  field: 'staff',
@@ -123,6 +125,7 @@
123
125
  {
124
126
  field: 'finish_rate',
125
127
  width: 100,
128
+ totalRow:true,
126
129
  title: '完成率',
127
130
  },
128
131
  {
@@ -79,30 +79,40 @@
79
79
  url: '/missions/sale_reports?clazz=month',
80
80
  toolbar: '#monthly_Toolbar',
81
81
  defaultToolbar: [],
82
+ totalRow:true,
82
83
  cols: [
83
84
  [{
84
85
  field: 'id',
85
86
  width: 60,
86
87
  title:'序号',type: 'numbers',
88
+ totalRowText:"合计",
87
89
  },
88
90
  {
89
91
  field: 'staff',
90
92
  width: 100,
91
93
  title: '姓名'
92
94
  },
95
+ {
96
+ field: 'month',
97
+ width: 100,
98
+ title: '月份'
99
+ },
93
100
  {
94
101
  field: 'finish_rate',
95
102
  width: 100,
103
+ totalRow:true,
96
104
  title: '完成率',
97
105
  },
98
106
  {
99
107
  field: 'client',
100
108
  width: 100,
109
+ totalRow:'{{ parseInt(d.TOTAL_NUMS) }}',
101
110
  title: '覆盖客户'
102
111
  },
103
112
  {
104
113
  field: 'amount',
105
114
  width: 100,
115
+ totalRow:true,
106
116
  title: '项目金额'
107
117
  },
108
118
  {
@@ -134,6 +144,11 @@
134
144
  return '<div class="star3"></div>'
135
145
  }
136
146
  },
147
+ {
148
+ field: 'created_at',
149
+ width: 300,
150
+ title: '提交时间',
151
+ },
137
152
  {
138
153
  title: '操作',
139
154
  minWidth: 220,
@@ -76,6 +76,7 @@
76
76
  elem: '#weekPlanTable',
77
77
  url: '/missions/plans?clazz=week',
78
78
  toolbar: '#weekPlanToolbar',
79
+ totalRow:true,
79
80
  defaultToolbar: [],
80
81
  cols: [
81
82
  [
@@ -83,6 +84,7 @@
83
84
  field: 'id',
84
85
  width: 80,
85
86
  title:'序号',type: 'numbers',
87
+ totalRowText: '合计'
86
88
  },
87
89
  {
88
90
  field: 'staff',
@@ -129,6 +131,7 @@
129
131
  field: 'finish_rate',
130
132
  width: 100,
131
133
  title: '完成率',
134
+ totalRow:true,
132
135
  },
133
136
  {
134
137
  field: 'updated_at',
@@ -80,31 +80,41 @@
80
80
  url: '/missions/sale_reports?clazz=week',
81
81
  toolbar: '#weeklyToolbar',
82
82
  defaultToolbar: [],
83
+ totalRow:true,
83
84
  cols: [
84
85
  [
85
86
  {
86
87
  field: 'id',
87
88
  width: 60,
88
89
  title:'序号',type: 'numbers',
90
+ totalRowText:"合计",
89
91
  },
90
92
  {
91
93
  field: 'staff',
92
94
  width: 100,
93
95
  title: '姓名'
94
96
  },
97
+ {
98
+ field: 'weekly',
99
+ width: 100,
100
+ title: '周次'
101
+ },
95
102
  {
96
103
  field: 'finish_rate',
97
104
  width: 100,
98
105
  title: '完成率',
106
+ totalRow:true,
99
107
  },
100
108
  {
101
109
  field: 'client',
102
110
  width: 100,
111
+ totalRow:'{{ parseInt(d.TOTAL_NUMS) }}',
103
112
  title: '覆盖客户'
104
113
  },
105
114
  {
106
115
  field: 'amount',
107
116
  width: 100,
117
+ totalRow:true,
108
118
  title: '项目金额'
109
119
  },
110
120
  {
@@ -135,7 +145,13 @@
135
145
  templet: function (d) {
136
146
  return '<div class="star3"></div>'
137
147
  }
148
+
138
149
  },
150
+ {
151
+ field: 'created_at',
152
+ width: 300,
153
+ title: '提交时间',
154
+ },
139
155
  {
140
156
  title: '操作',
141
157
  minWidth: 220,
@@ -15,5 +15,9 @@ json.data do
15
15
  end
16
16
  end
17
17
 
18
+ json.totalRow do
19
+ sum = @sale_plans.inject(0) { |score, i| score + i.finish_rate}
20
+ json.finish_rate ( @sale_plans.size > 0 ? (sum.to_f / @sale_plans.size).round(2).to_s : '0' ) + '%'
21
+ end
18
22
  json.code 0
19
23
  json.count @sale_plans.total_count
@@ -6,7 +6,7 @@
6
6
  <% end %>
7
7
  </div>
8
8
  </script>
9
- <form class="layui-form layui-form-pane">
9
+ <form class="layui-form layui-form-pane" style="padding-right: 20px">
10
10
  <div class="layui-form-item">
11
11
  <div class="layui-inline" style="margin:18px; font-weight: bold">
12
12
  <label>完成率:</label>
@@ -42,7 +42,9 @@
42
42
  </form>
43
43
 
44
44
  <!--表格-->
45
- <table class="layui-hide" id="newmonthlyTable" lay-filter="newmonthlyTable"></table>
45
+ <div style="padding: 20px">
46
+ <table class="layui-hide" id="newmonthlyTable" lay-filter="newmonthlyTable"></table>
47
+ </div>
46
48
  <script type="text/html" id="show_follow">
47
49
  <a href="javascript:void(0);" lay-event="show_follow" class="layui-table-link">{{ d.follow_ups_count }}</a>
48
50
  </script>
@@ -4,7 +4,7 @@
4
4
  <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn pull-right" lay-event="add"> 添加计划</button>
5
5
  </div>
6
6
  </script>
7
- <form class="layui-form layui-form-pane">
7
+ <form class="layui-form layui-form-pane" style="padding-right: 20px">
8
8
  <div class="layui-form-item">
9
9
  <div class="layui-inline" style="margin:18px; font-weight: bold">
10
10
  <label>完成率:</label>
@@ -40,7 +40,9 @@
40
40
  </form>
41
41
 
42
42
  <!--表格-->
43
- <table class="layui-hide" id="newWeeklyTable" lay-filter="newWeeklyTable"></table>
43
+ <div style="padding: 20px">
44
+ <table class="layui-hide" id="newWeeklyTable" lay-filter="newWeeklyTable"></table>
45
+ </div>
44
46
  <script type="text/html" id="show_follow">
45
47
  <a href="javascript:void(0);" lay-event="show_follow" class="layui-table-link">{{ d.follow_ups_count }}</a>
46
48
  </script>
@@ -10,8 +10,15 @@ json.data do
10
10
  json.level2_score d.level2_score || 0
11
11
  json.level3_score d.level3_score || 0
12
12
  json.updated_at d.updated_at.to_s
13
+ json.weekly d.weekly
14
+ json.created_at d.created_at.to_s
15
+ json.month d.month.strftime("%Y-%m")
13
16
  end
14
17
  end
15
18
 
19
+ json.totalRow do
20
+ sum = @sale_reports.inject(0) { |score, i| score + i.finish_rate}
21
+ json.finish_rate ( @sale_reports.size > 0 ? (sum.to_f / @sale_reports.size).round(2).to_s : '0' ) + '%'
22
+ end
16
23
  json.code 0
17
24
  json.count @sale_reports.total_count
@@ -26,10 +26,12 @@
26
26
  elem: '#table',
27
27
  url: '/missions/sales',
28
28
  cellMinWidth: 80,
29
+ totalRow:true,
29
30
  cols: [
30
31
  [{
31
32
  field: 'id',
32
33
  title:'序号',type: 'numbers',
34
+ totalRowText:'合计',
33
35
  width: 80
34
36
  }, {
35
37
  field: 'name',
@@ -42,19 +44,23 @@
42
44
  field: 'business_a',
43
45
  title: 'A类商机',
44
46
  templet: "#business_a",
47
+ totalRow:true,
45
48
  width: 120
46
49
  }, {
47
50
  field: 'business_b',
48
51
  title: 'B类商机',
49
52
  templet: "#business_b",
53
+ totalRow:true,
50
54
  width: 120
51
55
  }, {
52
56
  field: 'goal',
53
57
  title: '中标金额',
58
+ totalRow:true,
54
59
  width: 120
55
60
  }, {
56
61
  field: 'return_money',
57
62
  title: '回款',
63
+ totalRow:true,
58
64
  width: 120
59
65
  }
60
66
  ]
@@ -1,17 +1,33 @@
1
+ businesses_a_count = 0
2
+ businesses_b_count = 0
1
3
  json.data do
2
4
  json.array! @staffs do |d|
5
+ part_a_ids = EducodeSales::Business.where("educode_sales_businesses.last_follow_up_id is null AND staff_id = ?",d.id).ids
6
+ part_b_ids = EducodeSales::Business.where("educode_sales_businesses.last_follow_up_id is not null").joins("
7
+ JOIN educode_sales_follow_ups ON educode_sales_businesses.last_follow_up_id = educode_sales_follow_ups.id
8
+ ").where("educode_sales_follow_ups.staff_id = ?", d.id).pluck(:business_id)
9
+ business_ids = part_a_ids + part_b_ids
10
+ @businesses = EducodeSales::Business.where(id:business_ids)
3
11
  json.id d.id
4
12
  json.name d.user.real_name
5
13
  json.role d.role&.name
6
14
  json.area d.areas.present? ? d.areas.pluck(:name).join("、") : ''
7
- json.business_a d.businesses.joins("JOIN educode_sales_follow_ups on educode_sales_follow_ups.id = educode_sales_businesses.last_follow_up_id").where("educode_sales_follow_ups.clazz_id = ?", @a_clazz&.id).count
8
- json.business_b d.businesses.joins("JOIN educode_sales_follow_ups on educode_sales_follow_ups.id = educode_sales_businesses.last_follow_up_id").where("educode_sales_follow_ups.clazz_id = ?", @b_clazz&.id).count
9
- json.goal d.businesses.joins("JOIN educode_sales_follow_ups on educode_sales_follow_ups.id = educode_sales_businesses.last_follow_up_id").where("educode_sales_follow_ups.clazz_id != ? AND educode_sales_follow_ups.stage_id in (?)", @x, @step_ids).sum(:total_amount).round(2)
10
- json.return_money d.businesses.joins("JOIN educode_sales_follow_ups on educode_sales_follow_ups.id = educode_sales_businesses.last_follow_up_id").where("educode_sales_follow_ups.clazz_id != ?", @x).sum("educode_sales_businesses.return_money").round(2)
15
+ business_a = @businesses.joins("JOIN educode_sales_follow_ups on educode_sales_follow_ups.id = educode_sales_businesses.last_follow_up_id").where("educode_sales_follow_ups.clazz_id = ?", @a_clazz&.id).count
16
+ businesses_a_count += business_a
17
+ json.business_a business_a
18
+ business_b = @businesses.joins("JOIN educode_sales_follow_ups on educode_sales_follow_ups.id = educode_sales_businesses.last_follow_up_id").where("educode_sales_follow_ups.clazz_id = ?", @b_clazz&.id).count
19
+ businesses_b_count += business_b
20
+ json.business_b business_b
21
+ json.goal @businesses.joins("JOIN educode_sales_follow_ups on educode_sales_follow_ups.id = educode_sales_businesses.last_follow_up_id").where("educode_sales_follow_ups.clazz_id != ? AND educode_sales_follow_ups.stage_id in (?)", @x, @step_ids).sum(:total_amount).round(2)
22
+ json.return_money @businesses.joins("JOIN educode_sales_follow_ups on educode_sales_follow_ups.id = educode_sales_businesses.last_follow_up_id").where("educode_sales_follow_ups.clazz_id != ?", @x).sum("educode_sales_businesses.return_money").round(2)
11
23
  json.a_clazz_id @a_clazz&.id
12
24
  json.b_clazz_id @b_clazz&.id
13
25
  end
14
26
  end
15
27
 
28
+ json.totalRow do
29
+ json.business_a businesses_a_count.to_s
30
+ json.business_b businesses_b_count.to_s
31
+ end
16
32
  json.code 0
17
33
  json.count @staffs.total_count
@@ -32,10 +32,12 @@
32
32
  elem: '#oper_table',
33
33
  url: '/missions/sales/operations',
34
34
  defaultToolbar: [],
35
+ totalRow:true,
35
36
  cols: [
36
37
  [{
37
38
  field: 'id',
38
39
  title:'序号',type: 'numbers',
40
+ totalRowText:'合计',
39
41
  width: 80
40
42
  }, {
41
43
  field: 'name',
@@ -52,11 +54,13 @@
52
54
  field: 'schools',
53
55
  title: '跟进学校',
54
56
  templet: "#school",
57
+ totalRow:true,
55
58
  width: 120
56
59
  }, {
57
60
  field: 'departments',
58
61
  title: '跟进二级学院',
59
62
  templet: "#xschool",
63
+ totalRow:true,
60
64
  width: 120
61
65
  },
62
66
  ]
@@ -1,3 +1,5 @@
1
+ departments_count = 0
2
+ schools_count = 0
1
3
  json.data do
2
4
  json.array! @staffs do |d|
3
5
  json.id d.id
@@ -5,11 +7,18 @@ json.data do
5
7
  json.role d.role&.name
6
8
  json.job_type EducodeSales::Common.job_type_name[d.job_type]
7
9
  json.area d.areas.present? ? d.areas.pluck(:name).join("、") : ''
8
- json.departments EducodeSales::Business.joins(:last_follow_up).where("educode_sales_follow_ups.staff_id = #{d.id}").select("COUNT(educode_sales_follow_ups.staff_id) AS count")[0]&.send('count') + EducodeSales::Teacher.joins(:follow_up).where("educode_sales_teacher_follows.staff_id = #{d.id}").select("COUNT(educode_sales_teacher_follows.staff_id) AS count")[0]&.send('count') || 0
9
- json.schools EducodeSales::Business.joins(:last_follow_up, :department).where("educode_sales_follow_ups.staff_id = #{d.id}").select("COUNT(distinct(departments.school_id)) AS count")[0]['count'] + EducodeSales::Teacher.joins(:follow_up, :department).where("educode_sales_teacher_follows.staff_id = #{d.id}").select("COUNT(distinct(departments.school_id)) AS count")[0]['count']
10
-
10
+ departments = EducodeSales::Business.joins(:last_follow_up).where("educode_sales_follow_ups.staff_id = #{d.id}").select("COUNT(educode_sales_follow_ups.staff_id) AS count")[0]&.send('count') + EducodeSales::Teacher.joins(:follow_up).where("educode_sales_teacher_follows.staff_id = #{d.id}").select("COUNT(educode_sales_teacher_follows.staff_id) AS count")[0]&.send('count') || 0
11
+ json.departments departments
12
+ schools = EducodeSales::Business.joins(:last_follow_up, :department).where("educode_sales_follow_ups.staff_id = #{d.id}").select("COUNT(distinct(departments.school_id)) AS count")[0]['count'] + EducodeSales::Teacher.joins(:follow_up, :department).where("educode_sales_teacher_follows.staff_id = #{d.id}").select("COUNT(distinct(departments.school_id)) AS count")[0]['count']
13
+ json.schools schools
14
+ departments_count += departments
15
+ schools_count += schools
11
16
  end
12
17
  end
13
18
 
19
+ json.totalRow do
20
+ json.departments departments_count.to_s
21
+ json.schools schools_count.to_s
22
+ end
14
23
  json.code 0
15
24
  json.count @staffs.total_count
@@ -139,6 +139,7 @@
139
139
  url: '/missions/teachers',
140
140
  where: {q: form.val('search_form')},
141
141
  toolbar: '#toolbarDemo',
142
+ totalRow:true,
142
143
  defaultToolbar: [],
143
144
  cols: [
144
145
  [
@@ -146,6 +147,7 @@
146
147
  field: 'id',
147
148
  width: 120,
148
149
  title:'序号',type: 'numbers',
150
+ totalRowText:'合计',
149
151
  },
150
152
  {
151
153
  field: 'name',
@@ -196,6 +198,7 @@
196
198
  field: 'teacher_follows_count',
197
199
  width: 120,
198
200
  title: '跟进情况',
201
+ totalRow:true,
199
202
  templet: "#follow"
200
203
  },
201
204
  {
@@ -206,12 +209,14 @@
206
209
  {
207
210
  field: 'students',
208
211
  width: 120,
212
+ totalRow:'{{ parseInt(d.TOTAL_NUMS) }}',
209
213
  title: '学生',
210
214
  },
211
215
  {
212
216
  field: 'courses_count',
213
217
  width: 120,
214
218
  title: '课堂',
219
+ totalRow:true,
215
220
  templet: "#class"
216
221
  },
217
222
  {
@@ -1,3 +1,5 @@
1
+ teacher_follows_count = 0
2
+ courses_counts = 0
1
3
  json.data do
2
4
  json.array! @teachers do |d|
3
5
  json.id d.id
@@ -13,12 +15,20 @@ json.data do
13
15
  json.activities_count d.activity_teachers_count
14
16
  json.source EducodeSales::Common.teacher_source_name[d.source_id]
15
17
  json.attitude d.follow_up&.attitude&.name
16
- json.courses_count d.user_id ? Course.joins(:course_members).where(course_members: {user_id: d.user_id}).where("is_delete = 0 and role != 4 and excellent = 0 and is_hidden = 0").where("start_date is null or start_date <= '#{Date.today}'").distinct(:course_id).count : 0
18
+ json.courses_count d.courses_count
17
19
  json.actives d.actives
18
20
  json.students d.students_count
19
21
  json.regist_at d.user.present? ? d.user.created_on.to_s(:date) : ''
20
- json.teacher_used d.teacher_used_of_department
22
+ json.teacher_used d.teacher_used
23
+
24
+ teacher_follows_count += d.teacher_follows_count
25
+ courses_counts += d.courses_count
21
26
  end
22
27
  end
28
+
29
+ json.totalRow do
30
+ json.teacher_follows_count teacher_follows_count.to_s
31
+ json.courses_count courses_counts.to_s
32
+ end
23
33
  json.code 0
24
34
  json.count @teachers.total_count
@@ -52,7 +52,7 @@
52
52
  <dl class="layui-nav-child">
53
53
  <% if can? :trends, EducodeSales::SaleTrend %>
54
54
  <dd>
55
- <a href="/missions/sale_trends/trends" class="<%= current?('layui-this', trends_sale_trends_path) %>"><i style="padding-right: 35px"></i><%= image_tag "educode_sales/2.市场态势.png",size:"15"%><i style="font-size: 25px; padding-right: 15px"></i>市场态势</a>
55
+ <a href="/missions/sale_trends/trends" class="<%= current?('layui-this', trends_sale_trends_path) %>"><i style="padding-right: 35px"></i><%= image_tag "educode_sales/2.市场态势.png",size:"15"%><i style="font-size: 25px; padding-right: 15px"></i>销售态势</a>
56
56
  </dd>
57
57
  <% end %>
58
58
  <% if can? :sales, EducodeSales::Staff %>
@@ -0,0 +1,7 @@
1
+ class AddTeacherUsedToTeachers < ActiveRecord::Migration[5.2]
2
+ def change
3
+ add_column :educode_sales_teachers, :teacher_used, :integer, default: 0
4
+ add_column :educode_sales_teachers, :students_count, :integer, default: 0
5
+ add_column :educode_sales_teachers, :courses_count, :integer, default: 0
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module EducodeSales
2
- VERSION = '0.4.4'
2
+ VERSION = '0.4.5'
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.4.4
4
+ version: 0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - anke1460
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-20 00:00:00.000000000 Z
11
+ date: 2021-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -351,6 +351,7 @@ files:
351
351
  - db/migrate/20211009063423_add_source_businesses.rb
352
352
  - db/migrate/20211013060712_create_educode_sales_assign_follow_ups.rb
353
353
  - db/migrate/20211018054256_add_extras_to_commons.rb
354
+ - db/migrate/20211022085324_add_teacher_used_to_teachers.rb
354
355
  - lib/educode_sales.rb
355
356
  - lib/educode_sales/engine.rb
356
357
  - lib/educode_sales/version.rb