educode_sales 1.10.24 → 1.10.25

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: 3b89143c3577e56b16967098a24f73fe1b7d3b1a0906047bb1b70a5f403442d2
4
- data.tar.gz: 75cfa41097af3a67fc4e74d0a64203cc34d2e551bee15097a5c310b5e78382d4
3
+ metadata.gz: 96a6775767542fb19b07af8d6e33230a59840d0de8cebe92fce6d415a6709b98
4
+ data.tar.gz: b67442d07ea5b753f6f617553b43685916ab979e30d6a6b5574aadd7ed3dfdcd
5
5
  SHA512:
6
- metadata.gz: 14a3554944e927b9536e035ddd17906aa836f48c5715cf8f6966a986af517cd8fb9e37847d26fae97ffd2b2f7e596ecf3104f1ac43069ff7290c2561ed9dbae1
7
- data.tar.gz: 125797df83bf24579f5c5100649aa47659580c84968bc9d06edb309c6ae2274095c809142905f065f856370afa6112920a5a6eff12dcf62eca52c7b09f0d4bf5
6
+ metadata.gz: 91d38ed9783a320d29546f6143ffc1e9db8583a05730b698993456b0d4038c59530d26d77b9d64519a85078166aec0fb49d29145d5c7fa60c129de4dcb40e9f1
7
+ data.tar.gz: 229ad3617584f13d20d2bdf058855519858dd856afeff9fda580bf0abb3d3041bb57613896ebd6d28ef8f7c3ccd8dbdc3d51000981ae201f2c461cf7a1aab54a
@@ -158,10 +158,15 @@ module EducodeSales
158
158
  end
159
159
 
160
160
  # 更新对应的计划完成度
161
- if follow_up.bidded_date.present? && follow_up.bidded_date.strftime('%W') == Time.now.strftime('%W')
161
+ if follow_up.bidded_date.present?
162
162
  staff_manage_ids = @business&.last_follow_up&.assign_follow_ups.present? ? @business.last_follow_up.assign_follow_ups.pluck(:staff_id) : [@business.staff_id]
163
163
  common_id = EducodeSales::Common.find_by(clazz: '计划类型', name: '中标计划')&.id
164
- EducodeSales::SalePlan.where(month: Time.now.beginning_of_month, business: @business, staff_id: staff_manage_ids, finish_rate: 0, common_id: common_id).update_all(finish_rate: 100)
164
+ if follow_up.bidded_date.strftime('%W') == Time.now.strftime('%W')
165
+ EducodeSales::SalePlan.where(month: Time.now.beginning_of_month, weekly: Time.now.strftime('%W').to_i, business: @business, staff_id: staff_manage_ids, finish_rate: 0, common_id: common_id).update_all(finish_rate: 100)
166
+ end
167
+ if follow_up.bidded_date.strftime('%Y-%m') == Time.now.strftime('%Y-%m')
168
+ EducodeSales::SalePlan.where(month: Time.now.beginning_of_month, weekly: nil, business: @business, staff_id: staff_manage_ids, finish_rate: 0, common_id: common_id).update_all(finish_rate: 100)
169
+ end
165
170
  end
166
171
 
167
172
 
@@ -0,0 +1,146 @@
1
+ require_dependency "educode_sales/application_controller"
2
+
3
+ module EducodeSales
4
+ class IdeaFollowsController < ApplicationController
5
+ def create
6
+ load_teacher
7
+ follow_up = @teacher.teacher_follows.build(follow_up_params)
8
+ follow_up.staff = @current_admin
9
+ if @teacher.user_id.present?
10
+ course_ids = CourseMember.joins(:course).where(user_id: @teacher.user_id, courses: { is_delete: 0 }).where.not(role: 4).pluck(:course_id)
11
+ follow_up.course_shixuns_count = CourseMember.joins(course: :practice_homework_shixuns).where(course_id: course_ids).pluck(:shixun_id).uniq.count
12
+ follow_up.shixuns_count = ShixunMember.where(user_id: @teacher.user_id).count
13
+ follow_up.students_count = CourseMember.where(course_id: course_ids, role: 4).count
14
+ follow_up.evaluates_count = Course.where(id: course_ids).inject(0) { |i, d| i += d.evaluate_count }
15
+ follow_up.courses_count = course_ids.size
16
+ end
17
+ if follow_up.save
18
+ @teacher.update(follow_up_id: follow_up.id, followup_at: Time.now)
19
+ render_success
20
+ else
21
+ render_failure follow_up
22
+ end
23
+ end
24
+
25
+ def destroy
26
+ follow_up = IdeaFollow.find(params[:id])
27
+ if follow_up.destroy
28
+ render_success
29
+ else
30
+ render_failure follow_up
31
+ end
32
+ end
33
+
34
+ def update
35
+ # follow_up = IdeaFollow.new(idea_id: idea.id, staff_id: @current_admin.id, money: params[:money], content: params[:content], status: params[:status], advise: params[:advise], sale_staff_id: params[:sale_staff_id], idea_staff_id: params[:idea_staff_id])
36
+
37
+ follow_up = IdeaFollow.find(params[:id])
38
+ follow_up.money = params[:money]
39
+ follow_up.content = params[:content]
40
+ follow_up.status = params[:status]
41
+ follow_up.advise = params[:advise]
42
+ follow_up.sale_staff_id = params[:sale_staff_id]
43
+ follow_up.idea_staff_id = params[:idea_staff_id]
44
+ if follow_up.save
45
+ render_success
46
+ else
47
+ render_failure follow_up
48
+ end
49
+ end
50
+
51
+ def index
52
+ @staff_manages = {}
53
+ role = EducodeSales::Role.find_by(name: '生态经理')
54
+ EducodeSales::Common.joins(market_areas: :staff).includes(market_areas: :staff).where(clazz: '区域').where("educode_sales_staffs.role_id = #{role.id}").each do |d|
55
+ @staff_manages[d.name] = d.market_areas.map { |d| d.staff&.name }.uniq.compact
56
+ end if role
57
+
58
+ if @current_admin.is_admin?
59
+ @follow_ups = TeacherFollow.all
60
+ else
61
+ level = @current_admin.role.role_areas.find_by(clazz: '教师运营').level
62
+ case level
63
+ when '自己'
64
+ @follow_ups = TeacherFollow.where(staff_id: @current_admin.id)
65
+ when '区域'
66
+ school_ids = School.where(province: @current_admin.areas.pluck(:name)).pluck(:id)
67
+ teacher_ids = EducodeSales::Teacher.joins("JOIN departments ON educode_sales_teachers.department_id = departments.id").where("departments.school_id in (?) OR educode_sales_teachers.staff_id = #{@current_admin.id}", school_ids).pluck(:id)
68
+ @follow_ups = TeacherFollow.where(teacher_id: teacher_ids)
69
+ else
70
+ @follow_ups = TeacherFollow.all
71
+ end
72
+ end
73
+ if params[:q].present? && params[:q][:name].present?
74
+ @follow_ups = @follow_ups.joins(:teacher).where("educode_sales_teachers.name LIKE ?", "%#{params[:q][:name]}%")
75
+ end
76
+
77
+ if params[:q].present? && params[:q][:staff_id].present?
78
+ staff = Staff.find(params[:q][:staff_id])
79
+ school_ids = School.where(province: staff.areas.pluck(:name)).pluck(:id)
80
+ teacher_ids = EducodeSales::Teacher.joins("JOIN departments ON educode_sales_teachers.department_id = departments.id").where("departments.school_id in (?)", school_ids).pluck(:id)
81
+ @follow_ups = @follow_ups.where(teacher_id: teacher_ids)
82
+ end
83
+
84
+ if params[:q].present? && params[:q][:department].present?
85
+ departments_ids = Department.joins(:school).where("schools.name like ?", "%#{params[:q][:department]}%").pluck(:id)
86
+ @follow_ups = @follow_ups.joins(:teacher).where("department_id in (?)", departments_ids)
87
+ end
88
+
89
+ if params[:q].present? && params[:q][:area].present?
90
+ p = EducodeSales::Common.find(params[:q][:area]).name
91
+ # if @current_admin.is_admin?
92
+ @follow_ups = @follow_ups.joins(:teacher).joins("
93
+ JOIN departments ON educode_sales_teachers.department_id = departments.id
94
+ JOIN schools ON departments.school_id = schools.id
95
+ ").where("province = ?", p)
96
+ # else
97
+ # level = @current_admin.role.role_areas.find_by(clazz: '教师运营').level
98
+ # if level == "区域"
99
+ # school_ids = School.where(province: @current_admin.areas.pluck(:name)).pluck(:id)
100
+ # @follow_ups = @follow_ups.joins(:teacher).joins("
101
+ # JOIN departments ON educode_sales_teachers.department_id = departments.id
102
+ # JOIN schools ON departments.school_id = schools.id
103
+ # ").where("province = ? AND departments.school_id in (?)", p, school_ids)
104
+ # else
105
+ # @follow_ups = @follow_ups.joins(:teacher).joins("
106
+ # JOIN departments ON educode_sales_teachers.department_id = departments.id
107
+ # JOIN schools ON departments.school_id = schools.id
108
+ # ").where("province = ?", p)
109
+ # end
110
+ # end
111
+ end
112
+
113
+ if params[:q].present? && params[:q][:attitude_id].present?
114
+ @follow_ups = @follow_ups.where("educode_sales_teacher_follows.attitude_id = ?", "#{params[:q][:attitude_id]}")
115
+ end
116
+
117
+ if params[:q].present? && params[:q][:description].present?
118
+ @follow_ups = @follow_ups.where("educode_sales_teacher_follows.description LIKE ?", "%#{params[:q][:description]}%")
119
+ end
120
+
121
+ if params[:q].present? && params[:q][:follows_date].present?
122
+ date = params[:q][:follows_date].split(" - ")
123
+ @follow_ups = @follow_ups.where("educode_sales_teacher_follows.created_at > ? AND educode_sales_teacher_follows.created_at < ?", date[0], date[1] + ' 23:59:59')
124
+ end
125
+
126
+ @follow_ups = @follow_ups.includes(:teacher, :attitude, :staff)
127
+ if params[:sort].present? && params[:sort][:field]
128
+ @follow_ups = @follow_ups.order("#{params[:sort][:field]} #{params[:sort][:order]}")
129
+ else
130
+ @follow_ups = @follow_ups.order("educode_sales_teacher_follows.created_at desc")
131
+ end
132
+ @follow_ups = @follow_ups.page(params[:page]).per(params[:limit])
133
+ end
134
+
135
+ private
136
+
137
+ def load_teacher
138
+ @teacher = Teacher.find(params[:teacher_id])
139
+ end
140
+
141
+ def follow_up_params
142
+ params.permit(:attitude_id, :follow_id, :course_plan_id, :course_build_id, :description, :advise, :is_contact)
143
+ end
144
+
145
+ end
146
+ end
@@ -221,6 +221,43 @@ module EducodeSales
221
221
  render layout: false
222
222
  end
223
223
 
224
+ def show_follow
225
+ @idea_follow = IdeaFollow.find(params[:id])
226
+ staffs = Staff.where.not(role_id: 11).includes(:user)
227
+ gon.sale_staffs = staffs.map { |d| { name: d.user.real_name, value: d.id, selected: d.id == @idea_follow.sale_staff_id } }
228
+ gon.idea_staffs = staffs.map { |d| { name: d.user.real_name, value: d.id, selected: d.id == @idea_follow.idea_staff_id } }
229
+ respond_to do |format|
230
+ format.html do
231
+ render layout: false
232
+ end
233
+ format.json do
234
+ end
235
+ end
236
+ end
237
+
238
+ def follow_list
239
+ @idea = Idea.find(params[:id])
240
+ respond_to do |format|
241
+ format.html do
242
+ render layout: false
243
+ end
244
+ format.json do
245
+ @follow_ups = @idea.idea_follows.includes(:staff, :sale_staff, :idea_staff).order(id: :desc)
246
+ @latest = @follow_ups.order(id: :desc).first
247
+ @follow_ups = @follow_ups.page(params[:page]).per(params[:limit])
248
+ end
249
+ end
250
+ end
251
+
252
+ def edit_follow_record
253
+ @idea_follow = IdeaFollow.find(params[:id])
254
+ @idea = @idea_follow.idea
255
+ staffs = Staff.where.not(role_id: 11).includes(:user)
256
+ gon.sale_staffs = staffs.map { |d| { name: d.user.real_name, value: d.id, selected: d.id == @idea_follow.sale_staff_id } }
257
+ gon.idea_staffs = staffs.map { |d| { name: d.user.real_name, value: d.id, selected: d.id == @idea_follow.idea_staff_id } }
258
+ render layout: false
259
+ end
260
+
224
261
  def follow_up
225
262
  idea = Idea.find(params[:id])
226
263
  follow_up = IdeaFollow.new(idea_id: idea.id, staff_id: @current_admin.id, money: params[:money], content: params[:content], status: params[:status], advise: params[:advise], sale_staff_id: params[:sale_staff_id], idea_staff_id: params[:idea_staff_id])
@@ -54,6 +54,7 @@
54
54
  <% if can? :advise, EducodeSales::Idea %>
55
55
  <a class="layui-btn layui-btn-default layui-btn-xs data-count-edit" lay-event="advise">团队建议</a>
56
56
  <% end %>
57
+ <a class="layui-btn layui-btn-default layui-btn-xs data-count-edit" lay-event="detail">详情</a>
57
58
  </script>
58
59
 
59
60
  <script>
@@ -195,9 +196,9 @@
195
196
 
196
197
  table.on('tool(activity_followp_table)', function (obj) {
197
198
  var data = obj.data;
198
- id = data.teacher_id;
199
+ idea_id = data.idea_id;
199
200
  if (obj.event === 'detail') { // 监听添加操作
200
- content = miniPage.getHrefContent('/missions/teachers/show_follow?id=' + data.teacher_id);
201
+ var content = miniPage.getHrefContent('/missions/ideas/show_follow?id=' + data.id);
201
202
  openWH = miniPage.getOpenWidthHeight();
202
203
  index = layer.open({
203
204
  title: '跟进记录',
@@ -132,14 +132,18 @@
132
132
  {{# } }}
133
133
  </script>
134
134
 
135
+ <script type="text/html" id="follow">
136
+ <a href="javascript:void(0);" lay-event="follow" class="layui-table-link">{{ d.idea_follows_count }}</a>
137
+ </script>
138
+
135
139
  <script>
136
140
  layui.use(['form', 'table', 'miniPage', 'element', 'request', 'laydate'], function () {
137
141
  var $ = layui.jquery,
138
- form = layui.form,
139
- request = layui.request,
140
- dropdown = layui.dropdown,
141
- miniPage = layui.miniPage,
142
- laydate = layui.laydate;
142
+ form = layui.form,
143
+ request = layui.request,
144
+ dropdown = layui.dropdown,
145
+ miniPage = layui.miniPage,
146
+ laydate = layui.laydate;
143
147
 
144
148
  var laydate = layui.laydate;
145
149
 
@@ -175,6 +179,11 @@
175
179
  title: '销售经理',
176
180
  width: 100
177
181
  },
182
+ {
183
+ field: 'assist_staffs',
184
+ title: '协助人',
185
+ width: 200
186
+ },
178
187
  {
179
188
  field: 'status',
180
189
  width: 100,
@@ -195,6 +204,7 @@
195
204
  field: 'idea_follows_count',
196
205
  width: 100,
197
206
  title: '跟进',
207
+ templet: '#follow',
198
208
  },
199
209
  {
200
210
  field: 'f_staff',
@@ -553,6 +563,26 @@
553
563
  layer.close(index)
554
564
  }
555
565
  });
566
+ } else if (obj.event === 'follow') {
567
+ content = miniPage.getHrefContent('/missions/ideas/follow_list?id=' + data.id);
568
+ openWH = miniPage.getOpenWidthHeight();
569
+ index = layer.open({
570
+ title: '跟进记录',
571
+ type: 1,
572
+ shade: 0.2,
573
+ maxmin: true,
574
+ shadeClose: true,
575
+ area: [openWH[0] + 'px', openWH[1] + 'px'],
576
+ offset: [openWH[2] + 'px', openWH[3] + 'px'],
577
+ content: content,
578
+ success: function (layero, index) {
579
+ // 重新渲染弹层中的下拉选择框select
580
+ // form.render('select');
581
+ }
582
+ });
583
+ $(window).on("resize", function () {
584
+ layer.full(index);
585
+ });
556
586
  } else if (obj.event === 'idea_edit') { // 监听添加操作
557
587
  var content = miniPage.getHrefContent('/missions/ideas/' + id + '/edit');
558
588
  var openWH = miniPage.getOpenWidthHeight();
@@ -1,48 +1,59 @@
1
- <form class="layui-form " action="">
1
+ <%= Gon::Base.render_data %>
2
+ <div class="layui-form layuimini-form">
2
3
  <div class="layui-form-item" style="padding: 25px">
3
- <div class="layui-inline">
4
- <label class="layui-form-label">教师态度</label>
5
- <div class="layui-input-inline">
6
- <%= select_tag "attitude_id",options_for_select(EducodeSales::Common.where(clazz: "teacher_attitude").pluck(:name, :id), @follow_up.attitude_id)%>
7
- </div>
4
+ <div class="layui-row">
5
+ <h2 style="padding-left: 25px">跟进</h2>
8
6
  </div>
9
- <div class="layui-inline">
10
- <label class="layui-form-label">开课计划</label>
11
- <div class="layui-input-inline">
12
- <%= select_tag "course_plan_id",options_for_select(EducodeSales::Common.where(clazz: "course_plan").pluck(:name, :id), @follow_up.course_plan_id)%>
7
+ <div class="layui-row" style="padding-top: 15px">
8
+ <div class="layui-col-md6">
9
+ <labeL class="layui-form-label required">销售经理:</labeL>
10
+ <div class="layui-input-block">
11
+ <div id="new_sale_staff_id"></div>
12
+ </div>
13
+ </div>
14
+ <div class="layui-col-md6">
15
+ <labeL class="layui-form-label">方案经理:</labeL>
16
+ <div class="layui-input-block">
17
+ <div id="new_idea_staff_id"></div>
18
+ </div>
13
19
  </div>
14
20
  </div>
15
- <br>
16
- <div class="layui-inline">
17
- <label class="layui-form-label">课堂建设</label>
18
- <div class="layui-input-inline">
19
- <%= select_tag "course_build_id",options_for_select(EducodeSales::Common.where(clazz: "course_build").pluck(:name, :id), @follow_up.course_build_id)%>
21
+ <div class="layui-row" style="padding-top: 15px">
22
+ <div class="layui-col-md6">
23
+ <labeL class="layui-form-label">预算:</labeL>
24
+ <div class="layui-input-block">
25
+ <input type="number" name="money" autocomplete="off" placeholder="请输入硬件规模" value="<%= @idea_follow&.money %>" class="layui-input">
26
+ </div>
27
+ </div>
28
+ <div class="layui-col-md6">
29
+ <labeL class="layui-form-label">状态:</labeL>
30
+ <div class="layui-input-block">
31
+ <%= select_tag "status", options_for_select(EducodeSales::IdeaFollow.statuses.keys, @idea_follow&.status), { 'lay-filter': 'status', include_blank: false } %>
32
+ </div>
20
33
  </div>
21
34
  </div>
22
- <div class="layui-inline">
23
- <label class="layui-form-label">跟进手段</label>
24
- <div class="layui-input-inline">
25
- <%= select_tag "follow_id",options_for_select(EducodeSales::Common.where(clazz: "contact").pluck(:name, :id), @follow_up.follow_id)%>
35
+ <div class="layui-row" style="padding-top: 15px">
36
+ <labeL class="layui-form-label">团队建议:</labeL>
37
+ <div class="layui-input-block">
38
+ <textarea name="content" placeholder="团队建议" class="layui-textarea"><%= @idea_follow&.content.to_s %></textarea>
26
39
  </div>
27
40
  </div>
28
- <br>
29
- <div class="layui-form-item layui-form-text">
30
- <label class="layui-form-label">跟进小结</label>
41
+ <div class="layui-row" style="padding-top: 15px">
42
+ <labeL class="layui-form-label">最新进展:</labeL>
31
43
  <div class="layui-input-block">
32
- <textarea name="description" placeholder="此处可以填写:
33
- 1、教师关注的痛点问题;
34
- 2、教师关注的教学项目、教学成果类型;
35
- 3、其他个性化需求,以及应对情况说明;
36
- 4、目前态度的产生原因等。
37
- " class="layui-textarea"><%= @follow_up.description %></textarea>
44
+ <textarea name="content" placeholder="团队建议" class="layui-textarea"><%= @idea_follow&.content.to_s %></textarea>
38
45
  </div>
39
46
  </div>
40
- <div class="layui-inline" style="padding-left: 50px">
41
- <button type="submit" class="layui-btn layui-btn-normal" lay-submit lay-filter="edit_follow_up">提交
42
- </button>
47
+ <div class="layui-row" style="padding-top: 30px; float: left">
48
+ <div class="layui-input-block">
49
+ <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn_follow">确认保存</button>
50
+ </div>
43
51
  </div>
44
52
  </div>
45
- </form>
53
+ </div>
54
+
55
+
56
+
46
57
 
47
58
  <script>
48
59
  layui.use(['form', 'table', 'upload', 'layer', 'laytpl', 'request', 'laydate'], function () {
@@ -54,34 +65,41 @@
54
65
  laydate = layui.laydate,
55
66
  $ = layui.$;
56
67
 
57
- // laydate.render({
58
- // elem: '#invitation_at_add'
59
- // })
60
- //
61
- // laydate.render({
62
- // elem: '#reception_at_add'
63
- // });
64
-
65
68
  form.render();
66
69
 
67
- form.on('submit(edit_follow_up)', function (data) {
68
- request.authPut("missions/teacher_follows/<%= @follow_up.id%>", data.field, function (res) {
70
+
71
+ var staff_list = xmSelect.render({
72
+ el: '#new_idea_staff_id',
73
+ data: gon.idea_staffs,
74
+ filterable: true,
75
+ radio: true,
76
+ })
77
+ var sale_staff_list = xmSelect.render({
78
+ el: '#new_sale_staff_id',
79
+ data: gon.sale_staffs,
80
+ filterable: true,
81
+ radio: true,
82
+ })
83
+
84
+
85
+ //监听提交
86
+ form.on('submit(saveBtn_follow)', function (data) {
87
+ data.field.idea_staff_id = staff_list.getValue('valueStr');
88
+ data.field.sale_staff_id = sale_staff_list.getValue('valueStr');
89
+ request.authPut("missions/idea_follows/<%= @idea_follow.id%>", data.field, function (res) {
69
90
  if (res.success == false) {
70
91
  layer.alert(res.msg)
71
92
  } else {
72
93
  layer.close(parent.edit_index1);
73
94
  parent.layer.close(parent.layer.getFrameIndex(window.name))
74
- parent.table.reload('followTable')
75
- parent.table.reload('teachers_table')
76
- parent.table.reload('weekPlanTable1')
77
- parent.table.reload('monthPlanTable')
78
- parent.table.reload('sale_plan_follow_table')
95
+ table.reload('activity_followp_table')
96
+ table.reload('ideas_table')
97
+ table.reload('sale_plan_follow_table')
79
98
  }
80
99
  })
81
-
82
-
83
100
  return false;
84
101
  });
85
102
 
103
+
86
104
  });
87
105
  </script>