educode_sales 0.2.9 → 0.3.0

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
  SHA1:
3
- metadata.gz: adac2dac455b86334fc478e4f84454fe0596f15b
4
- data.tar.gz: ab4d5c46df6d081c3b193f94aba90d6f644bb35e
3
+ metadata.gz: 2a5096eaa908019932cbddf41165f340d93ee6e1
4
+ data.tar.gz: 23d6bbd33db8cf4e9a7ebcd675f930b502ae14f6
5
5
  SHA512:
6
- metadata.gz: d6c23010d60071f32bad83b9ae20e8ffe767e06120db34992faef60d58aca8f1f1e1b690b0421ecf54cd35fd126948c8dad429aa1e386af64aad7b8ca6522482
7
- data.tar.gz: 0a863555c19683cc7516bf77468df8cc296af577d8e7a87d5f2fc588005b2f4c59325062d617ae70af64929060cf9f1328b80a0ee70af5c196574dbd24743f84
6
+ metadata.gz: 6c30ed5b195123de8a120d43d76e7b26a4dedaeb6211e1a09cc75bd28132456b4eed0f6e0ffc0af3bd0ca1915ea3ec3ca1275ae9da70702601b8bed7b05103f0
7
+ data.tar.gz: bcb870fe68cc291d0e3c1fcf46f3bc2d6ca05858670cdffd5ae3788e47a18a03e92a80baec0ce5ea1ad7d15ee268ffc9fa6eb0362231601cc5122f314b42b39c
@@ -20,7 +20,7 @@ module EducodeSales
20
20
  when '自己'
21
21
  @sale_plans = OperationPlan.where(staff_id: @current_admin.id)
22
22
  when '区域'
23
- staff_ids = Staff.joins(department: :school).where("school.province in ?", staff.areas.pluck(:name)).pluck(:id)
23
+ staff_ids = Staff.joins(department: :school).where("school.province in ?", @current_admin.areas.pluck(:name)).pluck(:id)
24
24
  @sale_plans = OperationPlan.where("staff_id in ?", staff_ids)
25
25
  else
26
26
  @sale_plans = OperationPlan
@@ -117,7 +117,16 @@ module EducodeSales
117
117
 
118
118
  def edit_week
119
119
  @teacher = Teacher.find_by(id: params[:teacher_id])
120
- @teachers = @current_admin.teachers.where(is_key: 0).pluck(:name, :id)
120
+ level = @current_admin.is_admin? ? '全部' : @current_admin.role.role_areas.find_by(clazz: '运营计划').level
121
+ if level == '自己'
122
+ @teachers = @current_admin.teachers.where(is_key: 0).pluck(:name, :id)
123
+ elsif level == '区域'
124
+ school_ids = School.where(province: @current_admin.areas.pluck(:name)).pluck(:id)
125
+ @teachers = Teacher.joins("JOIN departments ON educode_sales_teachers.department_id = departments.id").where(is_key: false).where("departments.school_id in (?) OR educode_sales_teachers.staff_id = #{@current_admin.id}", school_ids)
126
+ else
127
+ @teachers = Teacher.where(is_key: 0).pluck(:name, :id)
128
+ end
129
+
121
130
  @sale_plan = OperationPlan.find(params[:id])
122
131
  if @sale_plan.weekly.present?
123
132
  week = Time.now.strftime('%W').to_i
@@ -145,7 +154,15 @@ module EducodeSales
145
154
 
146
155
  def edit_month
147
156
  @teacher = Teacher.find_by(id: params[:teacher_id])
148
- @teachers = @current_admin.teachers.where(is_key: 0).pluck(:name, :id)
157
+ level = @current_admin.is_admin? ? '全部' : @current_admin.role.role_areas.find_by(clazz: '运营计划').level
158
+ if level == '自己'
159
+ @teachers = @current_admin.teachers.where(is_key: 0).pluck(:name, :id)
160
+ elsif level == '区域'
161
+ school_ids = School.where(province: @current_admin.areas.pluck(:name)).pluck(:id)
162
+ @teachers = Teacher.joins("JOIN departments ON educode_sales_teachers.department_id = departments.id").where(is_key: false).where("departments.school_id in (?) OR educode_sales_teachers.staff_id = #{@current_admin.id}", school_ids)
163
+ else
164
+ @teachers = Teacher.where(is_key: 0).pluck(:name, :id)
165
+ end
149
166
  @sale_plan = OperationPlan.find(params[:id])
150
167
  @months = [Time.now.strftime("%Y-%m"), Time.now.months_ago(1).strftime("%Y-%m")]
151
168
  @months << @sale_plan.month.strftime("%Y-%m")
@@ -23,7 +23,7 @@ module EducodeSales
23
23
  end
24
24
 
25
25
  def destroy
26
- follow_up = @current_admin.teacher_follows.find(params[:id])
26
+ follow_up = TeacherFollow.find(params[:id])
27
27
  if follow_up.destroy
28
28
  render_success
29
29
  else
@@ -32,7 +32,7 @@ module EducodeSales
32
32
  end
33
33
 
34
34
  def update
35
- follow_up = @current_admin.teacher_follows.find(params[:id])
35
+ follow_up = TeacherFollow.find(params[:id])
36
36
  follow_up.assign_attributes(follow_up_params)
37
37
  # follow_up.profit_amount = follow_up.actual_amount * (100-follow_up.divide_rate.to_i) * 0.01 if follow_up.actual_amount
38
38
  if follow_up.save
@@ -15,8 +15,7 @@ json.data do
15
15
  json.total_amount d.last_follow_up&.total_amount
16
16
  json.return_money d.return_money
17
17
  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 : ''
19
-
18
+ json.last_follow_person d.last_follow_up.present? ? d.last_follow_up.staff.user.real_name : ''
20
19
  end
21
20
  end
22
21
  json.code 0
@@ -129,12 +129,12 @@
129
129
  },
130
130
  {
131
131
  field: 'rate',
132
- width: 100,
132
+ width: 80,
133
133
  title: '完成率',
134
134
  },
135
135
  {
136
136
  field: 'updated_at',
137
- width: 150,
137
+ width: 170,
138
138
  title: '更新时间',
139
139
  sort: true,
140
140
  },
@@ -11,9 +11,7 @@
11
11
  <div class="layui-inline">
12
12
  <label class="layui-form-label">教师</label>
13
13
  <div class="layui-input-inline">
14
- <%#= select_tag "teacher_id", options_for_select(@teachers, @sale_plan.teacher_id), class: 'required' %>
15
- <%= select_tag "teacher_id", options_for_select(@teachers), class: 'required' %>
16
-
14
+ <%= select_tag "teacher_id", options_for_select(@teachers, @sale_plan.teacher_id), class: 'required' %>
17
15
  </div>
18
16
  </div>
19
17
  <div class="layui-form-item layui-form-text">
@@ -19,9 +19,7 @@
19
19
  <div class="layui-inline">
20
20
  <label class="layui-form-label">教师</label>
21
21
  <div class="layui-input-inline">
22
- <%#= select_tag "teacher_id", options_for_select(@teachers, @sale_plan.teacher_id), class: 'required' %>
23
- <%= select_tag "teacher_id", options_for_select(@teachers), class: 'required' %>
24
-
22
+ <%= select_tag "teacher_id", options_for_select(@teachers, @sale_plan.teacher_id), class: 'required' %>
25
23
  </div>
26
24
  </div>
27
25
  <div class="layui-form-item layui-form-text">
@@ -1,3 +1,3 @@
1
1
  module EducodeSales
2
- VERSION = '0.2.9'
2
+ VERSION = '0.3.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: educode_sales
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - anke1460