educode_sales 0.8.4 → 0.8.7

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 (25) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/educode_sales/table2excel.js +2759 -0
  3. data/app/assets/stylesheets/educode_sales/layuimini.css +1 -1
  4. data/app/controllers/educode_sales/assessments_controller.rb +38 -17
  5. data/app/controllers/educode_sales/businesses_controller.rb +3 -3
  6. data/app/helpers/educode_sales/application_helper.rb +1 -1
  7. data/app/models/educode_sales/business.rb +0 -5
  8. data/app/models/educode_sales/staff.rb +1 -1
  9. data/app/views/educode_sales/assessments/_progress.html.erb +214 -146
  10. data/app/views/educode_sales/assessments/_setup.html.erb +108 -34
  11. data/app/views/educode_sales/assessments/edit.html.erb +53 -45
  12. data/app/views/educode_sales/assessments/index.html.erb +17 -5
  13. data/app/views/educode_sales/assessments/index.json.jbuilder +17 -17
  14. data/app/views/educode_sales/assessments/new.html.erb +113 -114
  15. data/app/views/educode_sales/assessments/progress.json.jbuilder +52 -52
  16. data/app/views/educode_sales/businesses/index.html.erb +6 -9
  17. data/app/views/educode_sales/businesses/new.html.erb +1 -4
  18. data/app/views/educode_sales/businesses/new_follow_record.html.erb +4 -4
  19. data/app/views/educode_sales/businesses/show_follow_record.html.erb +2 -1
  20. data/app/views/educode_sales/customers/edit_follow_record.html.erb +0 -2
  21. data/app/views/educode_sales/places/index.html.erb +1 -1
  22. data/db/migrate/20220523023609_update_assessment_month_column_to_assessment_settings.rb +9 -0
  23. data/db/migrate/20220523101628_update_column_to_follow_ups.rb +8 -0
  24. data/lib/educode_sales/version.rb +1 -1
  25. metadata +5 -2
@@ -37,7 +37,7 @@
37
37
  .layui-layout-admin .layui-nav-tree .layui-nav-child dd.layui-this,
38
38
  .layui-layout-admin .layui-nav-tree .layui-nav-child dd.layui-this a {
39
39
  background-color: #1aa094 !important;
40
- } */
40
+ }
41
41
 
42
42
 
43
43
  /**头部样式 */
@@ -26,11 +26,23 @@ module EducodeSales
26
26
  end
27
27
  end
28
28
  format.json do
29
- @year2 = params[:q]&[:assessment_year] || '2022'
30
- p @year2
31
- @year = params[:q].present? && params[:q][:assessment_year].present? ? params[:q][:assessment_year]:'2022'
29
+ if @current_admin.is_admin?
30
+ @assessments = AssessmentsSetting.all
31
+ else
32
+ level = @current_admin.role.role_areas.find_by(clazz: '绩效考核').level
33
+ case level
34
+ when '自己'
35
+ @assessments = AssessmentsSetting.where(staff_id: @current_admin.id)
36
+ when '区域'
37
+ @staffs = EducodeSales::Staff.joins(:areas).where("educode_sales_commons.id in (?)", @current_admin.areas.pluck(:id)).distinct
38
+ @assessments = EducodeSales::AssessmentsSetting.where(staff_id: @staffs.select(:id))
39
+ else
40
+ @assessments = AssessmentsSetting.all
41
+ end
42
+ end
43
+ @year = params[:q].present? && params[:q][:assessment_year].present? ? params[:q][:assessment_year]:Time.now.year
32
44
  @assessments_id = params[:q].present? && params[:q][:assessment_id].present? ? params[:q][:assessment_id]: '1'
33
- @assessments = AssessmentsSetting.where("assessment_year >= ? and assessment_year <= ?", "#{@year}-01-01 00:00:00".to_date, "#{@year}-12-31 23:59:00".to_date)
45
+ @assessments = @assessments.where("assessment_year >= ? and assessment_year <= ?", "#{@year}-01-01 00:00:00".to_date, "#{@year}-12-31 23:59:00".to_date)
34
46
  @assessments = @assessments.where(assessment: @assessments_id).order("updated_at desc")
35
47
  if params[:q].present? && params[:q][:staff_id].present?
36
48
  @assessments = @assessments.where(staff_id: params[:q][:staff_id]).order("updated_at desc")
@@ -98,16 +110,11 @@ module EducodeSales
98
110
  end
99
111
  end
100
112
 
101
-
102
-
103
-
104
113
  # 导出数据
105
114
  def get_export_data
106
115
  p 'get_export_data'
107
116
  end
108
117
 
109
-
110
-
111
118
  # 考核完成情况
112
119
  def progress
113
120
  p 'progress'
@@ -116,11 +123,25 @@ module EducodeSales
116
123
 
117
124
 
118
125
  def progress_or_get_export_data
126
+ if @current_admin.is_admin?
127
+ @assessments = AssessmentsSetting.all
128
+ else
129
+ level = @current_admin.role.role_areas.find_by(clazz: '绩效考核').level
130
+ case level
131
+ when '自己'
132
+ @assessments = AssessmentsSetting.where(staff_id: @current_admin.id)
133
+ when '区域'
134
+ @staffs = EducodeSales::Staff.joins(:areas).where("educode_sales_commons.id in (?)", @current_admin.areas.pluck(:id)).distinct
135
+ @assessments = EducodeSales::AssessmentsSetting.where(staff_id: @staffs.select(:id))
136
+ else
137
+ @assessments = AssessmentsSetting.all
138
+ end
139
+ end
119
140
  # common = Common.find_by(clazz: 'staff_type', name: '销售')
120
141
  # @staff_ids = Staff.joins(:user).where(job_type: common.id).pluck(:id)
121
142
  @assessment_id = params[:q].present? && params[:q][:assessment_id].present? ? params[:q][:assessment_id]:'1'
122
143
  @assessment_year = params[:q].present? && params[:q][:assessment_year].present? ? params[:q][:assessment_year] : Time.now.year
123
- @assessments =AssessmentsSetting.where(assessment: @assessment_id)
144
+ @assessments =@assessments.where(assessment: @assessment_id)
124
145
  .where("assessment_year >= ? and assessment_year <= ?", "#{@assessment_year}-01-01 00:00:00".to_date, "#{@assessment_year}-12-31 23:59:00".to_date)
125
146
  .order("created_at desc")
126
147
  if @assessments.present?
@@ -170,7 +191,7 @@ module EducodeSales
170
191
  data_count=[]
171
192
  data_list = FollowUp.joins("JOIN educode_sales_businesses ON educode_sales_businesses.last_follow_up_id = educode_sales_follow_ups.id")
172
193
  .where("educode_sales_businesses.id in (?)",businesses.pluck(:id)).map do |m|
173
- {value: m.actual_amount.to_i, date:m.signed_date.to_s[5..6].to_i}
194
+ {value: m.actual_amount.to_f, date:m.signed_date.to_s[5..6].to_i}
174
195
  end
175
196
  count_data(data_list,data_count) # 统计数据
176
197
  update_assessments_progress(data_count,d) # 批量更新assessment数据 事物 一个commit
@@ -203,7 +224,7 @@ module EducodeSales
203
224
  @staff_ids.each do |d|
204
225
  data_count = []
205
226
  data_list = @money_plans.where(staff_id: d).map do |m|
206
- {date:m.date_at.to_s[5..6].to_i, value:m.amount.to_i}
227
+ {date:m.date_at.to_s[5..6].to_i, value:m.amount.to_f}
207
228
  end
208
229
  count_data(data_list,data_count)
209
230
  update_assessments_progress(data_count, d)
@@ -304,11 +325,11 @@ module EducodeSales
304
325
 
305
326
  # 更新assessments_settings表中数据
306
327
  def update_assessments_progress(data_count,staff_id)
307
- data_count[12] = data_count[0].to_i + data_count[1].to_i + data_count[2].to_i
308
- data_count[13] = data_count[3].to_i + data_count[4].to_i + data_count[5].to_i
309
- data_count[14] = data_count[6].to_i + data_count[7].to_i + data_count[8].to_i
310
- data_count[15] = data_count[9].to_i + data_count[10].to_i + data_count[11].to_i
311
- data_count[16] = data_count[12].to_i + data_count[13].to_i + data_count[14].to_i + data_count[15].to_i
328
+ data_count[12] = data_count[0].to_f + data_count[1].to_f + data_count[2].to_f
329
+ data_count[13] = data_count[3].to_f + data_count[4].to_f + data_count[5].to_f
330
+ data_count[14] = data_count[6].to_f + data_count[7].to_f + data_count[8].to_f
331
+ data_count[15] = data_count[9].to_f + data_count[10].to_f + data_count[11].to_f
332
+ data_count[16] = data_count[12].to_f + data_count[13].to_f + data_count[14].to_f + data_count[15].to_f
312
333
  # 开启事物 处理 批量修改数据
313
334
  assessments = @assessments.where(staff_id: staff_id)
314
335
  assessments.update(annual_progress: data_count[16], first_quarter_progress: data_count[12], second_quarter_progress: data_count[13], third_quarter_progress: data_count[14], fourth_quarter_progress: data_count[15],
@@ -597,10 +597,10 @@ module EducodeSales
597
597
  last_follow.total_amount").joins("
598
598
  LEFT JOIN educode_sales_follow_ups AS last_follow ON educode_sales_businesses.last_follow_up_id = last_follow.id
599
599
  ")
600
-
601
600
  end
602
601
  end
603
602
  end
603
+
604
604
  #关注接口
605
605
  def following
606
606
  if brs=follow_business(@current_admin.user_id,params[:business_id])
@@ -642,7 +642,7 @@ module EducodeSales
642
642
  end
643
643
 
644
644
  def followed
645
- if brs=follow_business(@current_admin.user_id,params[:business_id])
645
+ if follow_business(@current_admin.user_id,params[:business_id])
646
646
  render json: {msg:'确定取消关注?'}
647
647
  else
648
648
  render json: {msg:'确定关注?'}
@@ -664,7 +664,7 @@ module EducodeSales
664
664
  EduSetting.get(name)
665
665
  end
666
666
 
667
- def follow_business(user_id,business_id)
667
+ def follow_business(user_id,business_id)
668
668
  BusinessRelationShip.where(user_id:user_id,business_id:business_id).first
669
669
  end
670
670
  end
@@ -55,7 +55,7 @@ module EducodeSales
55
55
 
56
56
  # 完成率completion_rate
57
57
  def completion_rate(setting,progress)
58
- if setting.to_i == 0 || progress.to_i >= setting.to_i
58
+ if setting.to_i == 0
59
59
  '100%'
60
60
  else
61
61
  (progress.to_f/setting.to_f*100).round(2).to_s + "%"
@@ -23,10 +23,5 @@ module EducodeSales
23
23
  self.follow_ups.update_all(deleted_at: Time.now)
24
24
  EducodeSales::Recycle.create(source: self, deleter_id: user_id)
25
25
  end
26
-
27
-
28
-
29
-
30
-
31
26
  end
32
27
  end
@@ -3,7 +3,6 @@ module EducodeSales
3
3
  belongs_to :user
4
4
  belongs_to :role, optional: true
5
5
 
6
- has_many :market_areas, dependent: :destroy
7
6
  has_many :follow_ups, dependent: :destroy
8
7
  has_many :operation_plans, dependent: :destroy
9
8
  has_many :operation_reports, dependent: :destroy
@@ -16,6 +15,7 @@ module EducodeSales
16
15
  has_many :sale_plans, dependent: :destroy
17
16
  has_many :staff_schools, dependent: :destroy
18
17
 
18
+ has_many :market_areas, dependent: :destroy
19
19
  has_many :areas, through: :market_areas
20
20
  validates :user_id, uniqueness: { message: '已存在' }
21
21
 
@@ -1,12 +1,3 @@
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
1
  <!--搜索-->
11
2
  <div class="layuimini-main min-height-table" id="monthly_table_wraper">
12
3
  <form class="layui-form layui-form-pane" lay-filter="assessment_progress_form">
@@ -29,7 +20,7 @@
29
20
  </div>
30
21
  </div>
31
22
  <div class="layui-inline">
32
- <label class="layui-form-label">人员</label>
23
+ <label class="layui-form-label">考核人员</label>
33
24
  <div class="layui-input-inline large-select">
34
25
  <%= select_tag "staff_id", options_for_select(@staffs), { id: 'weekly_staff_id', include_blank: true} %>
35
26
  </div>
@@ -44,21 +35,202 @@
44
35
  </form>
45
36
 
46
37
  <!--表格-->
47
- <table class="layui-hide" id="progressTable" style="min-height: 600px;" lay-filter="progressTable"></table>
48
-
49
-
50
-
38
+ <table class="layui-tab " id="progressTable" lay-filter="progressTable"></table>
39
+ </div>
51
40
 
41
+ <!--隐藏导出用的table-->
42
+ <div class="layui-hide">
43
+ <table class="layui-table" lay-data="{height:315, url: '/missions/assessments/progress' }" id="export-table" lay-filter="export-table">
44
+ <thead>
45
+ <tr>
46
+ <th lay-data="{width:80, type:'numbers' ,sort: true}" rowspan="2">序号</th>
47
+ <th lay-data="{field:'name', width:120}" rowspan="2">考核人员</th>
48
+ <th lay-data="{align:'center'}" colspan="5">全年</th>
49
+ <th lay-data="{align:'center'}" colspan="5">第1季度</th>
50
+ <th lay-data="{align:'center'}" colspan="5">1月</th>
51
+ <th lay-data="{align:'center'}" colspan="5">2月</th>
52
+ <th lay-data="{align:'center'}" colspan="5">3月</th>
53
+ <th lay-data="{align:'center'}" colspan="5">第2季度</th>
54
+ <th lay-data="{align:'center'}" colspan="5">4月</th>
55
+ <th lay-data="{align:'center'}" colspan="5">5月</th>
56
+ <th lay-data="{align:'center'}" colspan="5">6月</th>
57
+ <th lay-data="{align:'center'}" colspan="5">第3季度</th>
58
+ <th lay-data="{align:'center'}" colspan="5">7月</th>
59
+ <th lay-data="{align:'center'}" colspan="5">8月</th>
60
+ <th lay-data="{align:'center'}" colspan="5">9月</th>
61
+ <th lay-data="{align:'center'}" colspan="5">第4季度</th>
62
+ <th lay-data="{align:'center'}" colspan="5">10月</th>
63
+ <th lay-data="{align:'center'}" colspan="5">11月</th>
64
+ <th lay-data="{align:'center'}" colspan="5">12月</th>
65
+ </tr>
66
+ <tr>
67
+ <th lay-data="{field:'annual', width:80}">目标</th>
68
+ <th lay-data="{field:'annual_progress', width:80}">完成</th>
69
+ <th lay-data="{field:'annual_dif', width:80}">差额</th>
70
+ <th lay-data="{field:'annual_rate', width:80}">完成率</th>
71
+ <th lay-data="{field:'annual_score', width:80}">得分</th>
72
+
73
+ <th lay-data="{field:'first_quarter', width:80}">目标</th>
74
+ <th lay-data="{field:'first_quarter_progress', width:80}">完成</th>
75
+ <th lay-data="{field:'first_quarter_dif', width:80}">差额</th>
76
+ <th lay-data="{field:'first_quarter_rate', width:80}">完成率</th>
77
+ <th lay-data="{field:'first_quarter_score', width:80}">得分</th>
78
+
79
+ <th lay-data="{field:'january', width:80}">目标</th>
80
+ <th lay-data="{field:'january_progress', width:80}">完成</th>
81
+ <th lay-data="{field:'january_dif', width:80}">差额</th>
82
+ <th lay-data="{field:'january_rate', width:80}">完成率</th>
83
+ <th lay-data="{field:'january_score', width:80}">得分</th>
84
+
85
+ <th lay-data="{field:'february', width:80}">目标</th>
86
+ <th lay-data="{field:'february_progress', width:80}">完成</th>
87
+ <th lay-data="{field:'february_dif', width:80}">差额</th>
88
+ <th lay-data="{field:'february_rate', width:80}">完成率</th>
89
+ <th lay-data="{field:'february_score', width:80}">得分</th>
90
+
91
+ <th lay-data="{field:'march', width:80}">目标</th>
92
+ <th lay-data="{field:'march_progress', width:80}">完成</th>
93
+ <th lay-data="{field:'march_dif', width:80}">差额</th>
94
+ <th lay-data="{field:'march_rate', width:80}">完成率</th>
95
+ <th lay-data="{field:'march_score', width:80}">得分</th>
96
+
97
+ <th lay-data="{field:'second_quarter', width:80}">目标</th>
98
+ <th lay-data="{field:'second_quarter_progress', width:80}">完成</th>
99
+ <th lay-data="{field:'second_quarter_dif', width:80}">差额</th>
100
+ <th lay-data="{field:'second_quarter_rate', width:80}">完成率</th>
101
+ <th lay-data="{field:'second_quarter_score', width:80}">得分</th>
102
+
103
+ <th lay-data="{field:'april', width:80}">目标</th>
104
+ <th lay-data="{field:'april_progress', width:80}">完成</th>
105
+ <th lay-data="{field:'april_dif', width:80}">差额</th>
106
+ <th lay-data="{field:'april_rate', width:80}">完成率</th>
107
+ <th lay-data="{field:'april_score', width:80}">得分</th>
108
+
109
+ <th lay-data="{field:'may', width:80}">目标</th>
110
+ <th lay-data="{field:'may_progress', width:80}">完成</th>
111
+ <th lay-data="{field:'may_dif', width:80}">差额</th>
112
+ <th lay-data="{field:'may_rate', width:80}">完成率</th>
113
+ <th lay-data="{field:'may_score', width:80}">得分</th>
114
+
115
+ <th lay-data="{field:'june', width:80}">目标</th>
116
+ <th lay-data="{field:'june_progress', width:80}">完成</th>
117
+ <th lay-data="{field:'june_dif', width:80}">差额</th>
118
+ <th lay-data="{field:'june_rate', width:80}">完成率</th>
119
+ <th lay-data="{field:'june_score', width:80}">得分</th>
120
+
121
+ <th lay-data="{field:'third_quarter', width:80}">目标</th>
122
+ <th lay-data="{field:'third_quarter_progress', width:80}">完成</th>
123
+ <th lay-data="{field:'third_quarter_dif', width:80}">差额</th>
124
+ <th lay-data="{field:'third_quarter_rate', width:80}">完成率</th>
125
+ <th lay-data="{field:'third_quarter_score', width:80}">得分</th>
126
+
127
+ <th lay-data="{field:'july', width:80}">目标</th>
128
+ <th lay-data="{field:'july_progress', width:80}">完成</th>
129
+ <th lay-data="{field:'july_dif', width:80}">差额</th>
130
+ <th lay-data="{field:'july_rate', width:80}">完成率</th>
131
+ <th lay-data="{field:'july_score', width:80}">得分</th>
132
+
133
+ <th lay-data="{field:'august', width:80}">目标</th>
134
+ <th lay-data="{field:'august_progress', width:80}">完成</th>
135
+ <th lay-data="{field:'august_dif', width:80}">差额</th>
136
+ <th lay-data="{field:'august_rate', width:80}">完成率</th>
137
+ <th lay-data="{field:'august_score', width:80}">得分</th>
138
+
139
+ <th lay-data="{field:'september', width:80}">目标</th>
140
+ <th lay-data="{field:'september_progress', width:80}">完成</th>
141
+ <th lay-data="{field:'september_dif', width:80}">差额</th>
142
+ <th lay-data="{field:'september_rate', width:80}">完成率</th>
143
+ <th lay-data="{field:'september_score', width:80}">得分</th>
144
+
145
+ <th lay-data="{field:'fourth_quarter', width:80}">目标</th>
146
+ <th lay-data="{field:'fourth_quarter_progress', width:80}">完成</th>
147
+ <th lay-data="{field:'fourth_quarter_dif', width:80}">差额</th>
148
+ <th lay-data="{field:'fourth_quarter_rate', width:80}">完成率</th>
149
+ <th lay-data="{field:'fourth_quarter_score', width:80}">得分</th>
150
+
151
+ <th lay-data="{field:'october', width:80}">目标</th>
152
+ <th lay-data="{field:'october_progress', width:80}">完成</th>
153
+ <th lay-data="{field:'october_dif', width:80}">差额</th>
154
+ <th lay-data="{field:'october_rate', width:80}">完成率</th>
155
+ <th lay-data="{field:'october_score', width:80}">得分</th>
156
+
157
+ <th lay-data="{field:'november', width:80}">目标</th>
158
+ <th lay-data="{field:'november_progress', width:80}">完成</th>
159
+ <th lay-data="{field:'november_dif', width:80}">差额</th>
160
+ <th lay-data="{field:'november_rate', width:80}">完成率</th>
161
+ <th lay-data="{field:'november_score', width:80}">得分</th>
162
+
163
+ <th lay-data="{field:'december', width:80}">目标</th>
164
+ <th lay-data="{field:'december_progress', width:80}">完成</th>
165
+ <th lay-data="{field:'december_dif', width:80}">差额</th>
166
+ <th lay-data="{field:'december_rate', width:80}">完成率</th>
167
+ <th lay-data="{field:'december_score', width:80}">得分</th>
168
+
169
+ </tr>
170
+ </thead>
171
+ </table>
52
172
  </div>
53
173
 
54
174
 
175
+ <script src="educode_sales/table2excel.js"></script>
176
+ <script type="text/html" id="progress_Toolbar">
177
+ <div class="layui-btn-container">
178
+ <span class="table-label">指标完成情况</span>
179
+ <% if can?(:export_result, EducodeSales::AssessmentsSetting) %>
180
+ <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">
181
+ 导出<i class="layui-icon layui-icon-down layui-nav-more" style="font-size: 12px"></i></button>
182
+ <%end %>
183
+ </div>
184
+ </script>
55
185
 
56
186
 
57
187
  <script>
58
- layui.use(['form', 'table', 'miniPage', 'element', 'rate', 'laydate', 'request'], function () {
188
+ var $=layui.jquery
189
+ var demo = function() {
190
+ let header_tr = $("#export-table").next().find(".layui-table-header").find("tr");
191
+ let body_tr = $("#export-table").next().find(".layui-table-body").find("tr");
192
+ let header_html = "";
193
+ let body_html = "";
194
+ // 获取表头html,包括单元格的合并
195
+ $.each(header_tr,function (i,tr) {
196
+ let header_th = $(tr).find("th");
197
+ header_html += "<tr>";
198
+ $.each(header_th,function (j,th) {
199
+ let rowspan_num = $(th).attr("rowspan");// 行合并数
200
+ let colspan_num = $(th).attr("colspan");// 列合并数
201
+ if (rowspan_num && !colspan_num){// 只有行合并时
202
+ header_html += '<th rowspan= "'+ rowspan_num +'">';
203
+ } else if (colspan_num && !rowspan_num){// 只有列合并时
204
+ header_html += '<th colspan= "'+ colspan_num +'">';
205
+ } else if (rowspan_num && colspan_num){// 行列合并均有时
206
+ header_html += '<th rowspan= "'+ rowspan_num +'" colspan="'+ colspan_num +'">';
207
+ } else {// 没有发生单元格合并
208
+ header_html += '<th>';
209
+ }
210
+ header_html += $(th).children().children().text() + '</th>';// 获取表头名称并拼接th标签
211
+ console.log(header_html)
212
+ })
213
+ header_html += '</tr>';
214
+ })
215
+ // 获取表格body数据
216
+ $.each(body_tr,function (i,tr) {
217
+ let body_td = $(tr).find("td");
218
+ body_html += '<tr>';
219
+ $.each(body_td,function (j,td) {
220
+ body_html += '<td>' + $(td).children().text() + '</td>';
221
+ })
222
+ body_html += '</tr>';
223
+ })
224
+ $("#export-table tr").remove();// 清除之前的doom结构
225
+ $("#export-table").append(header_html).append(body_html);
226
+ $("#export-table").hide();
227
+ }
59
228
 
229
+ </script>
60
230
 
61
231
 
232
+ <script>
233
+ layui.use(['form', 'table', 'miniPage', 'element', 'rate', 'laydate', 'request'], function () {
62
234
 
63
235
  var $ = layui.jquery,
64
236
  form = layui.form,
@@ -69,6 +241,7 @@
69
241
  miniPage = layui.miniPage;
70
242
  dropdown = layui.dropdown;
71
243
 
244
+
72
245
  laydate.render({
73
246
  elem: '#assessment_year',
74
247
  type: 'year'
@@ -83,13 +256,12 @@
83
256
  ,totalRow:true
84
257
  ,title: "绩效考核指标完成情况" // 目前发现的作用(导出文件的文件名)
85
258
  ,defaultToolbar: ['filter']
86
- // ,limit: 10
87
259
  ,limits: [10,15,20,30,40,50,60,70,80,90]
88
260
  ,limit: 10
89
261
  ,page: true
90
262
  ,cols:[
91
263
  [ //标题栏
92
- { title: '序号', width: 80, rowspan: 2,type:'numbers',fixed:'left',sort: true,} //rowspan即纵向跨越的单元格数
264
+ { title: '序号', width: 80, rowspan: 2,type:'numbers',fixed:'left',} //rowspan即纵向跨越的单元格数
93
265
  ,{field: 'name', title: '考核人员', width: 120, rowspan: 2,fixed:'left'}
94
266
  ,{align: 'center', title: '全年', colspan: 5} //colspan即横跨的单元格数,这种情况下不用设置field和width
95
267
  ,{align: 'center', title: '第1季度', colspan: 5} //colspan即横跨的单元格数,这种情况下不用设置field和width
@@ -104,10 +276,10 @@
104
276
  ,{align: 'center', title: '7月', colspan: 5} //colspan即横跨的单元格数,这种情况下不用设置field和width
105
277
  ,{align: 'center', title: '8月', colspan: 5} //colspan即横跨的单元格数,这种情况下不用设置field和width
106
278
  ,{align: 'center', title: '9月', colspan: 5} //colspan即横跨的单元格数,这种情况下不用设置field和width
107
- ,{align: 'center', title: '第4季度', colspan: 5} //colspan即横跨的单元格数,这种情况下不用设置field和width
108
- ,{align: 'center', title: '10月', colspan: 5} //colspan即横跨的单元格数,这种情况下不用设置field和width
109
- ,{align: 'center', title: '11月', colspan: 5} //colspan即横跨的单元格数,这种情况下不用设置field和width
110
- ,{align: 'center', title: '12月', colspan: 5} //colspan即横跨的单元格数,这种情况下不用设置field和width
279
+ ,{align: 'center', title: '第4季度', colspan: 5}
280
+ ,{align: 'center', title: '10月', colspan: 5}
281
+ ,{align: 'center', title: '11月', colspan: 5}
282
+ ,{align: 'center', title: '12月', colspan: 5}
111
283
  ],
112
284
  [
113
285
  {field: 'annual', title: '目标', width: 80}
@@ -260,17 +432,17 @@
260
432
  })
261
433
 
262
434
  }
435
+
263
436
  function export_excel() {
264
- var data = form.val("assessment_progress_form");
265
- request.authPost("/missions/assessments/get_export_data", {
266
- assessment_year: data.assessment_year,
267
- assessment_id: data.assessment_id,
268
- staff_id: data.staff_id,
269
- }, function (res) {
270
- data = res.data;
271
- table.exportFile(progress_table.config.id,data, 'xls');
272
- layer.closeAll('loading');
273
- })
437
+ demo()
438
+ let table2excel = new Table2Excel();
439
+ /**
440
+ * 此处的show()是为了避免table2excel将hide属性带入excel中
441
+ * 导致下载后的excel中所有数据被隐藏
442
+ */
443
+ $('#export-table').show();
444
+ table2excel.export($('#export-table'), "指标完成情况");
445
+ $('#export-table').hide();
274
446
 
275
447
  }
276
448
 
@@ -302,13 +474,20 @@
302
474
  sort: sort
303
475
  }
304
476
  }, 'data');
305
-
477
+ // 导出table中的数据也要reload
478
+ table.reload('export-table', {
479
+ page: {
480
+ curr: 1
481
+ },
482
+ where: {
483
+ q: search,
484
+ sort: sort
485
+ }
486
+ })
306
487
  return false;
307
488
  });
308
489
 
309
490
  form.on('submit(progress_resert_btn)', function (data) {
310
- var field = data.field;
311
- console.log("--------------------")
312
491
  console.log(gon.export_menus)
313
492
  form.val('assessment_progress_form', {
314
493
  staff_id: '',
@@ -319,118 +498,7 @@
319
498
  });
320
499
 
321
500
 
322
-
323
-
324
-
325
-
326
-
327
-
328
-
329
-
330
-
331
-
332
-
333
-
334
-
335
-
336
-
337
-
338
-
339
-
340
-
341
- /**
342
- * toolbar事件监听
343
- */
344
- // table.on('toolbar(progressTable)', function (obj) {
345
- // if (obj.event === 'add') { // 监听添加操作
346
- // var content = miniPage.getHrefContent('/missions/plans/new_monthly');
347
- // var openWH = miniPage.getOpenWidthHeight();
348
- // sindex = layer.open({
349
- // title: '添加月报',
350
- // type: 1,
351
- // shade: 0.2,
352
- // maxmin: true,
353
- // shadeClose: true,
354
- // area: [openWH[0] + 'px', openWH[1] + 'px'],
355
- // offset: [openWH[2] + 'px', openWH[3] + 'px'],
356
- // content: content,
357
- // success: function (layero, index) {
358
- // // 重新渲染弹层中的下拉选择框select
359
- // form.render('select');
360
- // }
361
- // });
362
- // $(window).on("resize", function () {
363
- // layer.full(sindex);
364
- // });
365
- // }
366
- // });
367
-
368
- // table.on('tool(progressTable)', function (obj) {
369
- // var data = obj.data;
370
- // if (obj.event === 'edit') {
371
- // var content = miniPage.getHrefContent('/missions/sale_reports/' + data.id + "/edit");
372
- // var openWH = miniPage.getOpenWidthHeight();
373
- // from_edit_monthly = true
374
- // sindex = layer.open({
375
- // title: '编辑月报',
376
- // type: 1,
377
- // shade: 0.2,
378
- // maxmin: true,
379
- // shadeClose: true,
380
- // area: [openWH[0] + 'px', openWH[1] + 'px'],
381
- // offset: [openWH[2] + 'px', openWH[3] + 'px'],
382
- // content: content,
383
- // });
384
- // $(window).on("resize", function () {
385
- // layer.full(sindex);
386
- // });
387
- // return false;
388
- // } else if (obj.event === 'delete') {
389
- // layer.confirm('确定删除ID为' + data.id + " 的月报", function (index) {
390
- // request.delete('missions/sale_reports/' + data.id, {}, function (res) {
391
- // layer.close(index);
392
- // table.reload("progressTable")
393
- // })
394
- // });
395
- // } else if (obj.event === 'show') {
396
- // content = miniPage.getHrefContent('/missions/sale_reports/' + data.id);
397
- // openWH = miniPage.getOpenWidthHeight();
398
- // index = layer.open({
399
- // title: '查看月报',
400
- // type: 1,
401
- // shade: 0.2,
402
- // maxmin: true,
403
- // shadeClose: true,
404
- // area: [openWH[0] + 'px', openWH[1] + 'px'],
405
- // offset: [openWH[2] + 'px', openWH[3] + 'px'],
406
- // content: content,
407
- // });
408
- // $(window).on("resize", function () {
409
- // layer.full(index);
410
- // });
411
- // return false;
412
- // } else if (obj.event === 'audit') {
413
- // content = miniPage.getHrefContent('/missions/sale_reports/' + data.id + "/audit");
414
- // openWH = miniPage.getOpenWidthHeight();
415
- // from_source = 'monthly';
416
- // report_id = data.id;
417
- // sindex = layer.open({
418
- // title: '审查'+ data.staff +'的月报',
419
- // type: 1,
420
- // shade: 0.2,
421
- // maxmin: true,
422
- // shadeClose: true,
423
- // area: [openWH[0] + 'px', openWH[1] + 'px'],
424
- // offset: [openWH[2] + 'px', openWH[3] + 'px'],
425
- // content: content,
426
- // });
427
- // $(window).on("resize", function () {
428
- // layer.full(sindex);
429
- // });
430
- // return false;
431
- // }
432
- // });
433
-
434
501
  });
435
502
  </script>
436
503
 
504
+