educode_sales 0.7.4 → 0.7.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 (43) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/images/educode_sales/assessment.png +0 -0
  3. data/app/controllers/educode_sales/assessments_controller.rb +490 -0
  4. data/app/controllers/educode_sales/businesses_controller.rb +2 -3
  5. data/app/controllers/educode_sales/customers_controller.rb +3 -0
  6. data/app/controllers/educode_sales/home_controller.rb +4 -3
  7. data/app/controllers/educode_sales/money_plans_controller.rb +2 -0
  8. data/app/controllers/educode_sales/plans_controller.rb +1 -0
  9. data/app/controllers/educode_sales/roles_controller.rb +4 -1
  10. data/app/controllers/educode_sales/sessions_controller.rb +2 -1
  11. data/app/helpers/educode_sales/application_helper.rb +61 -0
  12. data/app/helpers/educode_sales/assessments_help.rb +52 -0
  13. data/app/models/educode_sales/assessments_setting.rb +28 -0
  14. data/app/models/educode_sales/business.rb +2 -1
  15. data/app/models/educode_sales/follow_up.rb +1 -1
  16. data/app/models/educode_sales/money_plan.rb +1 -0
  17. data/app/models/educode_sales/permission.rb +2 -1
  18. data/app/models/educode_sales/role_area.rb +2 -1
  19. data/app/views/educode_sales/assessments/_progress.html.erb +433 -0
  20. data/app/views/educode_sales/assessments/_setup.html.erb +331 -0
  21. data/app/views/educode_sales/assessments/edit.html.erb +238 -0
  22. data/app/views/educode_sales/assessments/get_export_data.json.jbuilder +197 -0
  23. data/app/views/educode_sales/assessments/index.html.erb +63 -0
  24. data/app/views/educode_sales/assessments/index.json.jbuilder +26 -0
  25. data/app/views/educode_sales/assessments/new.html.erb +310 -0
  26. data/app/views/educode_sales/assessments/progress.json.jbuilder +372 -0
  27. data/app/views/educode_sales/businesses/index.html.erb +1 -1
  28. data/app/views/educode_sales/businesses/new_follow_record.html.erb +8 -8
  29. data/app/views/educode_sales/places/index.html.erb +5 -3
  30. data/app/views/educode_sales/plans/_monthPlan.html.erb +3 -1
  31. data/app/views/educode_sales/plans/new_month.html.erb +2 -0
  32. data/app/views/educode_sales/plans/new_week.html.erb +5 -1
  33. data/app/views/educode_sales/roles/edit.html.erb +26 -18
  34. data/app/views/educode_sales/sale_reports/index.json.jbuilder +1 -0
  35. data/app/views/layouts/educode_sales/application.html.erb +12 -12
  36. data/app/views/layouts/educode_sales/login.html.erb +1 -1
  37. data/config/routes.rb +11 -0
  38. data/db/migrate/20210902064109_create_educode_sales_role_permissions.rb +9 -1
  39. data/db/migrate/20220402020233_create_educode_sales_assessments_settings.rb +27 -0
  40. data/db/migrate/20220411021641_add_new_column_assessments_settings.rb +20 -0
  41. data/db/migrate/20220413090940_add_september_progress_to_assessment_settings.rb +5 -0
  42. data/lib/educode_sales/version.rb +1 -1
  43. metadata +17 -2
@@ -52,5 +52,66 @@ module EducodeSales
52
52
  end
53
53
  end
54
54
 
55
+
56
+ # 完成率completion_rate
57
+ def completion_rate(setting,progress)
58
+ if setting.to_i == 0
59
+ '100%'
60
+ else
61
+ (progress.to_f/setting.to_f*100).round(2).to_s + "%"
62
+ end
63
+
64
+ end
65
+
66
+ # 签单金额 得分规则
67
+ def signed_amount_score(setting,progress)
68
+ progress.to_f >= setting.to_f || setting.to_i == 0 ? 40:(progress.to_f/setting.to_f*40).round(2)
69
+ end
70
+
71
+ # 回款金额 得分规则
72
+ def collection_amount_score(setting,progress)
73
+ (progress.to_i >= setting.to_i) || (setting.to_i == 0) ? 20:(progress.to_f/setting.to_f*20).round(2)
74
+ end
75
+
76
+
77
+ # 拜访量 得分规则
78
+ def visits_score(d)
79
+ d.to_i > 30 ? 20:0
80
+ end
81
+
82
+
83
+ #新增商机数 得分规则
84
+ def add_businesses_score(staff_id,start_time,end_time)
85
+ if @current_admin.is_admin?
86
+ @businesses = Business
87
+ else
88
+ level = @current_admin.role.role_areas.find_by(clazz: '商机管理').level
89
+ case level
90
+ when '自己'
91
+ # Business.joins(Business字段: :表的名称)----> Business表(belongs_to) Business字段关联的表(has_many) Business字段关联的表在关联的表(belongs_to)
92
+ business_ids = Business.joins(last_follow_up: :assign_follow_ups).where("educode_sales_assign_follow_ups.staff_id = ?", @current_admin.id).pluck(:id)
93
+ @businesses = Business.where("educode_sales_businesses.staff_id = ? OR educode_sales_businesses.id in (?)", @current_admin.id, business_ids)
94
+ when '区域'
95
+ school_ids = School.where(province: @current_admin.areas.pluck(:name)).pluck(:id) + StaffSchool.where(staff_id: @current_admin.id).pluck(:school_id)
96
+ business_ids = Business.joins(last_follow_up: :assign_follow_ups).where("educode_sales_assign_follow_ups.staff_id = ?", @current_admin.id).pluck(:id)
97
+ @businesses = Business.joins("JOIN departments ON educode_sales_businesses.department_id = departments.id").where("departments.school_id in (?) OR educode_sales_businesses.staff_id = #{@current_admin.id} OR educode_sales_businesses.id in (?)", school_ids, business_ids)
98
+ else
99
+ @businesses = Business
100
+ end
101
+ end
102
+
103
+ ids_a_b = Common.where(extras: %w[a_class b_class ]).pluck(:id)
104
+ ids_c_d = Common.where(extras: %w[c_class d_class]).pluck(:id)
105
+ @businesses_a_b_count = @businesses.joins("JOIN educode_sales_follow_ups ON educode_sales_businesses.last_follow_up_id = educode_sales_follow_ups.id").where("educode_sales_follow_ups.clazz_id in (?)",ids_a_b)
106
+ .where("educode_sales_businesses.staff_id = ?",staff_id)
107
+ .where("educode_sales_businesses.created_at >= ? and educode_sales_businesses.created_at <= ?", "#{@assessment_year}-#{start_time} 00:00:00".to_date,
108
+ "#{@assessment_year}-#{end_time} 23:59:00".to_date)
109
+ @businesses_c_d_count = @businesses.joins("JOIN educode_sales_follow_ups ON educode_sales_businesses.last_follow_up_id = educode_sales_follow_ups.id").where("educode_sales_follow_ups.clazz_id in (?)",ids_c_d)
110
+ .where("educode_sales_businesses.staff_id = ?",staff_id)
111
+ .where("educode_sales_businesses.created_at >= ? and educode_sales_businesses.created_at <= ?", "#{@assessment_year}-#{start_time} 00:00:00".to_date,
112
+ "#{@assessment_year}-#{end_time} 23:59:00".to_date)
113
+ @businesses_a_b_count.count.to_i*10 + @businesses_c_d_count.count.to_i*5
114
+ end
115
+
55
116
  end
56
117
  end
@@ -0,0 +1,52 @@
1
+
2
+
3
+ module EducodeSales
4
+ module AssessmentsHelper
5
+
6
+
7
+ # def business_score
8
+ # if @current_admin.is_admin?
9
+ # @businesses = Business
10
+ # else
11
+ # level = @current_admin.role.role_areas.find_by(clazz: '商机管理').level
12
+ # case level
13
+ # when '自己'
14
+ # # Business.joins(Business字段: :表的名称)----> Business表(belongs_to) Business字段关联的表(has_many) Business字段关联的表在关联的表(belongs_to)
15
+ # business_ids = Business.joins(last_follow_up: :assign_follow_ups).where("educode_sales_assign_follow_ups.staff_id = ?", @current_admin.id).pluck(:id)
16
+ # @businesses = Business.where("educode_sales_businesses.staff_id = ? OR educode_sales_businesses.id in (?)", @current_admin.id, business_ids)
17
+ # when '区域'
18
+ # school_ids = School.where(province: @current_admin.areas.pluck(:name)).pluck(:id) + StaffSchool.where(staff_id: @current_admin.id).pluck(:school_id)
19
+ # business_ids = Business.joins(last_follow_up: :assign_follow_ups).where("educode_sales_assign_follow_ups.staff_id = ?", @current_admin.id).pluck(:id)
20
+ # @businesses = Business.joins("JOIN departments ON educode_sales_businesses.department_id = departments.id").where("departments.school_id in (?) OR educode_sales_businesses.staff_id = #{@current_admin.id} OR educode_sales_businesses.id in (?)", school_ids, business_ids)
21
+ # else
22
+ # @businesses = Business
23
+ # end
24
+ # end
25
+
26
+ # @businesses = @businesses.where("follow_ups_count > ?", '0').where("educode_sales_businesses.created_at >= ? and educode_sales_businesses.created_at <= ?", "#{@assessment_year}-01-01 00:00:00".to_date,"#{@assessment_year}-12-31 23:59:00".to_date)
27
+ # @businesses = @businesses.where(staff_id: d_staff_id)
28
+ # # 2.销售人员新增的商机数量,过滤E、O、X类商机,包含:ABCD类商机; 上面有连接follow_up表
29
+ # ids = Common.where(extras: %w[a_class b_class c_class d_claass]).pluck(:id) # 数组[1,5,2,15]
30
+ # @businesses = @businesses.joins("JOIN educode_sales_follow_ups ON educode_sales_businesses.last_follow_up_id = educode_sales_follow_ups.id").where("educode_sales_follow_ups.clazz_id in (?) ",ids)
31
+ # # 先把staff写死
32
+ # # @businesses = @businesses.where(staff_id: d_staff_id)
33
+ # case time
34
+ # when '1'
35
+ # @businesses = @businesses.where("educode_sales_businesses.created_at >= ? and educode_sales_businesses.created <= ?", "#{@assessment_year}-01-01 00:00:00".to_date,"#{@assessment_year}-12-31 23:59:00".to_date)
36
+ # when '2'
37
+ # when '3'
38
+ # when '4'
39
+ # when '5'
40
+ # when '6'
41
+ # when '7'
42
+ # when '8'
43
+ # when '9'
44
+ # when '10'
45
+ # when '11'
46
+ # when '12'
47
+ # end
48
+
49
+ # end
50
+
51
+ end
52
+ end
@@ -0,0 +1,28 @@
1
+ module EducodeSales
2
+ class AssessmentsSetting < ApplicationRecord
3
+ # belongs_to :educode_sales_staff, :class_name => 'EducodeSales::Staff'
4
+ belongs_to :staff
5
+ belongs_to :user
6
+
7
+
8
+ # todo 签单金额 : assessment_id(1)
9
+ # todo 回款金额 : assessment_id(2)
10
+ # todo 拜访量 : assessment_id(3)
11
+ # todo 新增商机数 : assessment_id(4)
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
26
+ end
27
+ end
28
+
@@ -3,11 +3,12 @@ module EducodeSales
3
3
 
4
4
  belongs_to :staff
5
5
  belongs_to :department
6
- belongs_to :last_follow_up, class_name: 'FollowUp', optional: true
6
+ belongs_to :last_follow_up, class_name: 'FollowUp', optional: true # 允许last_follow_up_id字段中的数为nil
7
7
 
8
8
  has_many :sale_plans
9
9
  has_many :follow_ups
10
10
 
11
+ #每次查询时 默认的查询条件
11
12
  default_scope -> {where(deleted_at: nil)}
12
13
 
13
14
  def soft_destroy(user_id)
@@ -1,7 +1,7 @@
1
1
  module EducodeSales
2
2
  class FollowUp < ApplicationRecord
3
3
  include ::Deletable
4
- belongs_to :business, counter_cache: true
4
+ belongs_to :business, counter_cache: true # counter_cache(自动计算 business对应follow_up表中对应的个数)
5
5
  belongs_to :place, optional: true
6
6
  has_many :money_plans
7
7
  has_many :key_person
@@ -3,6 +3,7 @@ module EducodeSales
3
3
  belongs_to :staff
4
4
  belongs_to :follow_up, counter_cache: true
5
5
 
6
+ # todo 1 :实际回款 0:计划回款
6
7
  enum clazz: ['计划回款', '实际回款']
7
8
 
8
9
  after_save :update_return_money
@@ -12,7 +12,8 @@ module EducodeSales
12
12
  '活动运营': 'activity',
13
13
  '运营计划': 'operation_plan',
14
14
  '客户管理': 'customer',
15
- '回款管理': 'money_plan'
15
+ '回款管理': 'money_plan',
16
+ '绩效考核': 'assessments_setting'
16
17
  }
17
18
  end
18
19
  end
@@ -9,7 +9,8 @@ module EducodeSales
9
9
  '教师运营': 'Teacher',
10
10
  '运营计划': 'Operation',
11
11
  '客户管理': 'Customer',
12
- '回款管理': 'MoneyPlan'
12
+ '回款管理': 'MoneyPlan',
13
+ '绩效考核': 'AssessmentsSetting',
13
14
  }
14
15
  end
15
16
  end
@@ -0,0 +1,433 @@
1
+ <script type="text/html" id="progress_Toolbar">
2
+ <div class="layui-btn-container">
3
+ <span class="table-label">指标完成情况</span>
4
+ <% if can?(:export_result, EducodeSales::AssessmentsSetting) %>
5
+ <button class="layui-btn layui-btn-primary layui-border-green layui-btn-sm data-count-edit export_more-btn pull-right" style="color: #0000FF;" data-name="export" data-id="export">
6
+ 导出<i class="layui-icon layui-icon-down layui-nav-more" style="font-size: 12px"></i></button>
7
+ <%end %>
8
+ </div>
9
+ </script>
10
+ <!--搜索-->
11
+ <div class="layuimini-main min-height-table" id="monthly_table_wraper">
12
+ <form class="layui-form layui-form-pane" lay-filter="assessment_progress_form">
13
+ <div class="layui-form-item">
14
+ <div class="layui-inline">
15
+ <label class="layui-form-label">考核年度</label>
16
+ <div class="layui-input-inline">
17
+ <input type="text" class="layui-input" id="assessment_year" autocomplete="off" name="assessment_year" value="2022">
18
+ </div>
19
+ </div>
20
+ <div class="layui-inline">
21
+ <label class="layui-form-label">考核指标</label>
22
+ <div class="layui-input-inline">
23
+ <select class="layui-select" name="assessment_id" >
24
+ <option value="1" selected >签单金额</option>
25
+ <option value="2">回款金额</option>
26
+ <option value="3">拜访量</option>
27
+ <option value="4">新增商机数</option>
28
+ </select>
29
+ </div>
30
+ </div>
31
+ <div class="layui-inline">
32
+ <label class="layui-form-label">人员</label>
33
+ <div class="layui-input-inline large-select">
34
+ <%= select_tag "staff_id", options_for_select(@staffs), { id: 'weekly_staff_id', include_blank: true} %>
35
+ </div>
36
+ </div>
37
+ <div class="layui-inline">
38
+ <button type="reset" class="layui-btn layui-btn-primary" lay-submit lay-filter="progress_resert_btn">重置
39
+ </button>
40
+ <button type="submit" class="layui-btn layui-btn-primary" lay-submit lay-filter="progress_search_btn">检索
41
+ </button>
42
+ </div>
43
+ </div>
44
+ </form>
45
+
46
+ <!--表格-->
47
+ <table class="layui-hide" id="progressTable" style="min-height: 600px;" lay-filter="progressTable"></table>
48
+
49
+
50
+
51
+
52
+ </div>
53
+
54
+
55
+
56
+
57
+ <script>
58
+ layui.use(['form', 'table', 'miniPage', 'element', 'rate', 'laydate', 'request'], function () {
59
+
60
+
61
+
62
+
63
+ var $ = layui.jquery,
64
+ form = layui.form,
65
+ laydate = layui.laydate,
66
+ request = layui.request,
67
+ table = layui.table,
68
+ rate = layui.rate,
69
+ miniPage = layui.miniPage;
70
+ dropdown = layui.dropdown;
71
+
72
+ laydate.render({
73
+ elem: '#assessment_year',
74
+ type: 'year'
75
+ });
76
+
77
+
78
+
79
+ var progress_table = table.render({
80
+ elem: '#progressTable'
81
+ ,url: '/missions/assessments/progress'
82
+ ,toolbar: '#progress_Toolbar'
83
+ ,totalRow:true
84
+ ,defaultToolbar: ['filter']
85
+ // ,limit: 10
86
+ ,limits: [10,15,20,30,40,50,60,70,80,90]
87
+ ,limit: 10
88
+ ,page: true
89
+ ,cols:[
90
+ [ //标题栏
91
+ { title: '序号', width: 80, rowspan: 2,type:'numbers',fixed:'left',sort: true,} //rowspan即纵向跨越的单元格数
92
+ ,{field: 'name', title: '考核人员', width: 80, rowspan: 2,fixed:'left'}
93
+ ,{align: 'center', title: '全年', colspan: 5} //colspan即横跨的单元格数,这种情况下不用设置field和width
94
+ ,{align: 'center', title: '第1季度', colspan: 5} //colspan即横跨的单元格数,这种情况下不用设置field和width
95
+ ,{align: 'center', title: '1月', colspan: 5} //colspan即横跨的单元格数,这种情况下不用设置field和width
96
+ ,{align: 'center', title: '2月', colspan: 5} //colspan即横跨的单元格数,这种情况下不用设置field和width
97
+ ,{align: 'center', title: '3月', colspan: 5} //colspan即横跨的单元格数,这种情况下不用设置field和width
98
+ ,{align: 'center', title: '第2季度', colspan: 5} //colspan即横跨的单元格数,这种情况下不用设置field和width
99
+ ,{align: 'center', title: '4月', colspan: 5} //colspan即横跨的单元格数,这种情况下不用设置field和width
100
+ ,{align: 'center', title: '5月', colspan: 5} //colspan即横跨的单元格数,这种情况下不用设置field和width
101
+ ,{align: 'center', title: '6月', colspan: 5} //colspan即横跨的单元格数,这种情况下不用设置field和width
102
+ ,{align: 'center', title: '第3季度', colspan: 5} //colspan即横跨的单元格数,这种情况下不用设置field和width
103
+ ,{align: 'center', title: '7月', colspan: 5} //colspan即横跨的单元格数,这种情况下不用设置field和width
104
+ ,{align: 'center', title: '8月', colspan: 5} //colspan即横跨的单元格数,这种情况下不用设置field和width
105
+ ,{align: 'center', title: '9月', colspan: 5} //colspan即横跨的单元格数,这种情况下不用设置field和width
106
+ ,{align: 'center', title: '第4季度', colspan: 5} //colspan即横跨的单元格数,这种情况下不用设置field和width
107
+ ,{align: 'center', title: '10月', colspan: 5} //colspan即横跨的单元格数,这种情况下不用设置field和width
108
+ ,{align: 'center', title: '11月', colspan: 5} //colspan即横跨的单元格数,这种情况下不用设置field和width
109
+ ,{align: 'center', title: '12月', colspan: 5} //colspan即横跨的单元格数,这种情况下不用设置field和width
110
+ ],
111
+ [
112
+ {field: 'annual', title: '目标', width: 80}
113
+ ,{field: 'annual_progress', title: '完成', width: 80}
114
+ ,{field: 'annual_dif', title: '差额', width: 80}
115
+ ,{field: 'annual_rate', title: '完成率', width:80}
116
+ ,{field: 'annual_score', title: '得分', width: 80}
117
+ ,{field: 'first_quarter', title: '目标', width: 80}
118
+ ,{field: 'first_quarter_progress', title: '完成', width: 80}
119
+ ,{field: 'first_quarter_dif', title: '差额', width: 80}
120
+ ,{field: 'first_quarter_rate', title: '完成率', width:80}
121
+ ,{field: 'first_quarter_score', title: '得分', width: 80}
122
+ ,{field: 'january', title: '目标', width: 80}
123
+ ,{field: 'january_progress', title: '完成', width: 80}
124
+ ,{field: 'january_dif', title: '差额', width: 80}
125
+ ,{field: 'january_rate', title: '完成率', width:80}
126
+ ,{field: 'january_score', title: '得分', width: 80}
127
+ ,{field: 'february', title: '目标', width: 80}
128
+ ,{field: 'february_progress', title: '完成', width: 80}
129
+ ,{field: 'february_dif', title: '差额', width: 80}
130
+ ,{field: 'february_rate', title: '完成率', width:80}
131
+ ,{field: 'february_score', title: '得分', width: 80}
132
+ ,{field: 'march', title: '目标', width: 80}
133
+ ,{field: 'march_progress', title: '完成', width: 80}
134
+ ,{field: 'march_dif', title: '差额', width: 80}
135
+ ,{field: 'march_rate', title: '完成率', width:80}
136
+ ,{field: 'march_score', title: '得分', width: 80}
137
+ ,{field: 'second_quarter', title: '目标', width: 80}
138
+ ,{field: 'second_quarter_progress', title: '完成', width: 80}
139
+ ,{field: 'second_quarter_dif', title: '差额', width: 80}
140
+ ,{field: 'second_quarter_rate', title: '完成率', width:80}
141
+ ,{field: 'second_quarter_score', title: '得分', width: 80}
142
+ ,{field: 'april', title: '目标', width: 80}
143
+ ,{field: 'april_progress', title: '完成', width: 80}
144
+ ,{field: 'april_dif', title: '差额', width: 80}
145
+ ,{field: 'april_rate', title: '完成率', width:80}
146
+ ,{field: 'april_score', title: '得分', width: 80}
147
+ ,{field: 'may', title: '目标', width: 80}
148
+ ,{field: 'may_progress', title: '完成', width: 80}
149
+ ,{field: 'may_dif', title: '差额', width: 80}
150
+ ,{field: 'may_rate', title: '完成率', width:80}
151
+ ,{field: 'may_score', title: '得分', width: 80}
152
+ ,{field: 'june', title: '目标', width: 80}
153
+ ,{field: 'june_progress', title: '完成', width: 80}
154
+ ,{field: 'june_dif', title: '差额', width: 80}
155
+ ,{field: 'june_rate', title: '完成率', width:80}
156
+ ,{field: 'june_score', title: '得分', width: 80}
157
+ ,{field: 'third_quarter', title: '目标', width: 80}
158
+ ,{field: 'third_quarter_progress', title: '完成', width: 80}
159
+ ,{field: 'third_quarter_dif', title: '差额', width: 80}
160
+ ,{field: 'third_quarter_rate', title: '完成率', width:80}
161
+ ,{field: 'third_quarter_score', title: '得分', width: 80}
162
+ ,{field: 'july', title: '目标', width: 80}
163
+ ,{field: 'july_progress', title: '完成', width: 80}
164
+ ,{field: 'july_dif', title: '差额', width: 80}
165
+ ,{field: 'july_rate', title: '完成率', width:80}
166
+ ,{field: 'july_score', title: '得分', width: 80}
167
+ ,{field: 'august', title: '目标', width: 80}
168
+ ,{field: 'august_progress', title: '完成', width: 80}
169
+ ,{field: 'august_dif', title: '差额', width: 80}
170
+ ,{field: 'august_rate', title: '完成率', width:80}
171
+ ,{field: 'august_score', title: '得分', width: 80}
172
+ ,{field: 'september', title: '目标', width: 80}
173
+ ,{field: 'september_progress', title: '完成', width: 80}
174
+ ,{field: 'september_dif', title: '差额', width: 80}
175
+ ,{field: 'september_rate', title: '完成率', width:80}
176
+ ,{field: 'september_score', title: '得分', width: 80}
177
+ ,{field: 'fourth_quarter', title: '目标', width: 80}
178
+ ,{field: 'fourth_quarter_progress', title: '完成', width: 80}
179
+ ,{field: 'fourth_quarter_dif', title: '差额', width: 80}
180
+ ,{field: 'fourth_quarter_rate', title: '完成率', width:80}
181
+ ,{field: 'fourth_quarter_score', title: '得分', width: 80}
182
+ ,{field: 'october', title: '目标', width: 80}
183
+ ,{field: 'october_progress', title: '完成', width: 80}
184
+ ,{field: 'october_dif', title: '差额', width: 80}
185
+ ,{field: 'october_rate', title: '完成率', width:80}
186
+ ,{field: 'october_score', title: '得分', width: 80}
187
+ ,{field: 'november', title: '目标', width: 80}
188
+ ,{field: 'november_progress', title: '完成', width: 80}
189
+ ,{field: 'november_dif', title: '差额', width: 80}
190
+ ,{field: 'november_rate', title: '完成率', width:80}
191
+ ,{field: 'november_score', title: '得分', width: 80}
192
+ ,{field: 'december', title: '目标', width: 80}
193
+ ,{field: 'december_progress', title: '完成', width: 80}
194
+ ,{field: 'december_dif', title: '差额', width: 80}
195
+ ,{field: 'december_rate', title: '完成率', width:80}
196
+ ,{field: 'december_score', title: '得分', width: 80}
197
+ ]]
198
+ ,parseData: function(res){ //将原始数据解析成 table 组件所规定的数据,res为从url中get到的数据
199
+ var result;
200
+ if(this.page.curr){
201
+ result = res.data.slice(this.limit*(this.page.curr-1),this.limit*this.page.curr);
202
+ }
203
+ else{
204
+ result=res.data.slice(0,this.limit);
205
+ }
206
+ var length =0;
207
+ for (var ever in res.data){
208
+ length++
209
+ }
210
+ return {
211
+ "code": 0, //解析接口状态
212
+ "msg": res.msg, //解析提示文本
213
+ "count": length, //解析数据长度
214
+ "data": result //解析数据列表
215
+ };
216
+ }
217
+ ,done: function (res) {
218
+ export_drowpdwonRender()
219
+ }
220
+ });
221
+
222
+ // 这个注意一下 直接html请求的后端中直接拿取gon.export_menus数据
223
+ // 使用dropdown模块
224
+ var export_dropmenu = gon.export_menus;
225
+ export_drowpdwonRender = function() {
226
+ dropdown.render({
227
+ elem: '.export_more-btn',
228
+ data: export_dropmenu,
229
+ click: function(data, othis){
230
+ var elem = $(this.elem);
231
+ id = elem.data('id');
232
+ switch (data.event) {
233
+ case 'export_csv':
234
+ export_csv();
235
+ break;
236
+ case 'export_excel':
237
+ export_excel();
238
+ break;
239
+
240
+ }
241
+ }
242
+ });
243
+ }
244
+
245
+ function export_csv() {
246
+ var data = form.val("assessment_progress_form");
247
+ request.authPost("/missions/assessments/get_export_data", {
248
+ // 这个请求注意一下 除了会发送自定义的数据 还会发送一些数据(在自定义数据外面增加一个hash)--注意有意思
249
+ assessment_year: data.assessment_year,
250
+ assessment_id: data.assessment_id,
251
+ staff_id: data.staff_id,
252
+ // select: data.select, //有点东西
253
+ }, function (res) {
254
+ data = res.data
255
+ table.exportFile(progress_table.config.id,data, 'csv');
256
+ layer.closeAll('loading');
257
+ })
258
+
259
+ }
260
+ function export_excel() {
261
+ var data = form.val("assessment_progress_form");
262
+ request.authPost("/missions/businesses/get_export_data", {
263
+ assessment_year: data.assessment_year,
264
+ assessment_id: data.assessment_id,
265
+ staff_id: data.staff_id,
266
+ }, function (res) {
267
+ data = res.data
268
+ table.exportFile(progress_table.config.id,data, 'xls');
269
+ layer.closeAll('loading');
270
+ })
271
+
272
+ }
273
+
274
+
275
+
276
+ var sort = {},
277
+ search = {};
278
+ table.on('sort(progressTable)', function (obj) {
279
+ sort.field = obj.field;
280
+ sort.order = obj.type;
281
+ table.reload('progressTable', {
282
+ initSort: obj,
283
+ where: {
284
+ sort: sort,
285
+ q: search
286
+ }
287
+ });
288
+ })
289
+
290
+ // 监听搜索操作
291
+ form.on('submit(progress_search_btn)', function (data) {
292
+ search = data.field
293
+ table.reload('progressTable', {
294
+ page: {
295
+ curr: 1
296
+ },
297
+ where: {
298
+ q: search,
299
+ sort: sort
300
+ }
301
+ }, 'data');
302
+
303
+ return false;
304
+ });
305
+
306
+ form.on('submit(progress_resert_btn)', function (data) {
307
+ var field = data.field;
308
+ console.log("--------------------")
309
+ console.log(gon.export_menus)
310
+ form.val('assessment_progress_form', {
311
+ staff_id: '',
312
+ assessment_year: '2022',
313
+ assessment_id: '签单金额',
314
+ })
315
+ return false;
316
+ });
317
+
318
+
319
+
320
+
321
+
322
+
323
+
324
+
325
+
326
+
327
+
328
+
329
+
330
+
331
+
332
+
333
+
334
+
335
+
336
+
337
+
338
+ /**
339
+ * toolbar事件监听
340
+ */
341
+ // table.on('toolbar(progressTable)', function (obj) {
342
+ // if (obj.event === 'add') { // 监听添加操作
343
+ // var content = miniPage.getHrefContent('/missions/plans/new_monthly');
344
+ // var openWH = miniPage.getOpenWidthHeight();
345
+ // sindex = layer.open({
346
+ // title: '添加月报',
347
+ // type: 1,
348
+ // shade: 0.2,
349
+ // maxmin: true,
350
+ // shadeClose: true,
351
+ // area: [openWH[0] + 'px', openWH[1] + 'px'],
352
+ // offset: [openWH[2] + 'px', openWH[3] + 'px'],
353
+ // content: content,
354
+ // success: function (layero, index) {
355
+ // // 重新渲染弹层中的下拉选择框select
356
+ // form.render('select');
357
+ // }
358
+ // });
359
+ // $(window).on("resize", function () {
360
+ // layer.full(sindex);
361
+ // });
362
+ // }
363
+ // });
364
+
365
+ // table.on('tool(progressTable)', function (obj) {
366
+ // var data = obj.data;
367
+ // if (obj.event === 'edit') {
368
+ // var content = miniPage.getHrefContent('/missions/sale_reports/' + data.id + "/edit");
369
+ // var openWH = miniPage.getOpenWidthHeight();
370
+ // from_edit_monthly = true
371
+ // sindex = layer.open({
372
+ // title: '编辑月报',
373
+ // type: 1,
374
+ // shade: 0.2,
375
+ // maxmin: true,
376
+ // shadeClose: true,
377
+ // area: [openWH[0] + 'px', openWH[1] + 'px'],
378
+ // offset: [openWH[2] + 'px', openWH[3] + 'px'],
379
+ // content: content,
380
+ // });
381
+ // $(window).on("resize", function () {
382
+ // layer.full(sindex);
383
+ // });
384
+ // return false;
385
+ // } else if (obj.event === 'delete') {
386
+ // layer.confirm('确定删除ID为' + data.id + " 的月报", function (index) {
387
+ // request.delete('missions/sale_reports/' + data.id, {}, function (res) {
388
+ // layer.close(index);
389
+ // table.reload("progressTable")
390
+ // })
391
+ // });
392
+ // } else if (obj.event === 'show') {
393
+ // content = miniPage.getHrefContent('/missions/sale_reports/' + data.id);
394
+ // openWH = miniPage.getOpenWidthHeight();
395
+ // index = layer.open({
396
+ // title: '查看月报',
397
+ // type: 1,
398
+ // shade: 0.2,
399
+ // maxmin: true,
400
+ // shadeClose: true,
401
+ // area: [openWH[0] + 'px', openWH[1] + 'px'],
402
+ // offset: [openWH[2] + 'px', openWH[3] + 'px'],
403
+ // content: content,
404
+ // });
405
+ // $(window).on("resize", function () {
406
+ // layer.full(index);
407
+ // });
408
+ // return false;
409
+ // } else if (obj.event === 'audit') {
410
+ // content = miniPage.getHrefContent('/missions/sale_reports/' + data.id + "/audit");
411
+ // openWH = miniPage.getOpenWidthHeight();
412
+ // from_source = 'monthly';
413
+ // report_id = data.id;
414
+ // sindex = layer.open({
415
+ // title: '审查'+ data.staff +'的月报',
416
+ // type: 1,
417
+ // shade: 0.2,
418
+ // maxmin: true,
419
+ // shadeClose: true,
420
+ // area: [openWH[0] + 'px', openWH[1] + 'px'],
421
+ // offset: [openWH[2] + 'px', openWH[3] + 'px'],
422
+ // content: content,
423
+ // });
424
+ // $(window).on("resize", function () {
425
+ // layer.full(sindex);
426
+ // });
427
+ // return false;
428
+ // }
429
+ // });
430
+
431
+ });
432
+ </script>
433
+