educode_sales 1.10.59 → 1.10.70

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/educode_sales/application.js +1 -0
  3. data/app/assets/javascripts/educode_sales/functions.js +24 -0
  4. data/app/controllers/educode_sales/application_controller.rb +11 -3
  5. data/app/controllers/educode_sales/business_courses_controller.rb +19 -8
  6. data/app/controllers/educode_sales/follow_ups_controller.rb +4 -0
  7. data/app/controllers/educode_sales/plans_controller.rb +448 -124
  8. data/app/controllers/educode_sales/shixuns_controller.rb +20 -10
  9. data/app/controllers/educode_sales/subjects_controller.rb +10 -6
  10. data/app/controllers/educode_sales/teacher_follows_controller.rb +4 -0
  11. data/app/controllers/educode_sales/teachers_controller.rb +3 -0
  12. data/app/models/educode_sales/business.rb +5 -5
  13. data/app/models/educode_sales/sales_target.rb +10 -0
  14. data/app/models/educode_sales/sales_target_log.rb +11 -0
  15. data/app/views/educode_sales/business_courses/index.html.erb +1 -1
  16. data/app/views/educode_sales/business_courses/new.html.erb +2 -2
  17. data/app/views/educode_sales/businesses/_follows.html.erb +107 -100
  18. data/app/views/educode_sales/businesses/index.html.erb +6 -3
  19. data/app/views/educode_sales/businesses/index.json.jbuilder +2 -2
  20. data/app/views/educode_sales/businesses/show_follow.json.jbuilder +1 -1
  21. data/app/views/educode_sales/contracts/_follows.html.erb +75 -69
  22. data/app/views/educode_sales/contracts/_list.html.erb +283 -249
  23. data/app/views/educode_sales/contracts/index.json.jbuilder +1 -1
  24. data/app/views/educode_sales/follow_ups/index.json.jbuilder +1 -1
  25. data/app/views/educode_sales/plans/_year_execute.html.erb +294 -159
  26. data/app/views/educode_sales/plans/_year_target.html.erb +330 -215
  27. data/app/views/educode_sales/plans/index.html.erb +3 -4
  28. data/app/views/educode_sales/plans/staff_year_business.html.erb +96 -0
  29. data/app/views/educode_sales/plans/staff_year_business.json.jbuilder +22 -0
  30. data/app/views/educode_sales/plans/staff_year_target.json.jbuilder +35 -0
  31. data/app/views/educode_sales/plans/staff_year_target_log.html.erb +62 -0
  32. data/app/views/educode_sales/plans/staff_year_target_log.json.jbuilder +34 -0
  33. data/app/views/educode_sales/plans/years_all_target.json.jbuilder +5 -4
  34. data/app/views/educode_sales/sales_details/_index.html.erb +6 -3
  35. data/app/views/educode_sales/shixun_dectects/markdown.html.erb +40 -1
  36. data/app/views/educode_sales/shixuns/index.html.erb +106 -97
  37. data/app/views/educode_sales/shixuns/new.html.erb +2 -2
  38. data/app/views/educode_sales/staffs/index.json.jbuilder +1 -1
  39. data/app/views/educode_sales/subjects/index.html.erb +1 -1
  40. data/app/views/educode_sales/subjects/new.html.erb +2 -2
  41. data/app/views/educode_sales/teachers/_follows.html.erb +24 -17
  42. data/app/views/educode_sales/teachers/_index.html.erb +6 -0
  43. data/app/views/layouts/educode_sales/application.html.erb +6 -3
  44. data/config/environments/development.rb +16 -0
  45. data/config/routes.rb +7 -0
  46. data/db/migrate/20230729085359_create_educode_sales_sales_target_histories.rb +1 -1
  47. data/lib/educode_sales/version.rb +1 -1
  48. metadata +11 -2
@@ -1,7 +1,25 @@
1
1
  <%= Gon::Base.render_data %>
2
+ <style>
3
+ [lay-id="execute_table"] .layui-table-cell{
4
+ height: auto!important;
5
+ overflow: visible;
6
+ text-overflow: inherit;
7
+ white-space: normal;
8
+ }
9
+ /* 添加自定义样式规则来居中对齐表格内容 */
10
+ .layui-table-view {
11
+ text-align: center;
12
+ }
13
+ /* 自定义固定列样式 */
14
+ .custom-fixed-column {
15
+ position: sticky;
16
+ left: 0;
17
+ background-color: #f5f5f5;
18
+ }
19
+ </style>
2
20
  <div id="year_execute_wraper">
3
21
  <div class="layuimini-main min-height-table" id="year_execute_table_wraper">
4
- <form class="layui-form layui-form-pane" lay-filter="assessment_progress_form">
22
+ <form class="layui-form layui-form-pane" lay-filter="execute_form">
5
23
  <div class="layui-form-item">
6
24
  <div class="layui-inline">
7
25
  <label class="layui-form-label">人员</label>
@@ -28,21 +46,21 @@
28
46
  </div>
29
47
  </div>
30
48
  <div class="layui-inline">
31
- <button type="reset" class="layui-btn layui-btn-primary" lay-submit lay-filter="progress_resert_btn">重置
49
+ <button type="reset" class="layui-btn layui-btn-primary" lay-submit lay-filter="execute_reset_btn">重置
32
50
  </button>
33
- <button type="submit" class="layui-btn layui-btn-primary" lay-submit lay-filter="progress_search_btn">检索
51
+ <button type="submit" class="layui-btn layui-btn-primary" lay-submit lay-filter="execute_search_btn">检索
34
52
  </button>
35
53
  </div>
36
54
  </div>
37
55
  </form>
38
- <table class="layui-tab" id="finished_table" lay-filter="progressTable"></table>
56
+ <table class="layui-tab" id="execute_table" lay-filter="execute_table_filter"></table>
39
57
  </div>
40
- <script type="text/html" id="progress_Toolbar">
58
+ <script type="text/html" id="execute_table_toolbar">
41
59
  <div class="layui-btn-container">
42
- <span class="table-label">年度销售执行情况</span>
43
- <button class="layui-btn layui-btn-primary layui-btn-sm pull-right" lay-event="export"> 导出</button>
44
- <button class="layui-btn layui-btn-primary layui-btn-sm pull-right" lay-event="show_all" id="show_all"> 分类显示</button>
45
- <button class="layui-btn layui-btn-default layui-btn-sm pull-right" lay-event="show_staff" id="show_staff"> 人员显示</button>
60
+ <span class="table-label">&nbsp;</span>
61
+ <button class="layui-btn layui-btn-primary layui-btn-sm pull-right" lay-event="execute_export"> 导出</button>
62
+ <button class="layui-btn layui-btn-primary layui-btn-sm pull-right" lay-event="execute_show_all" id="execute_show_all"> 分类显示</button>
63
+ <button class="layui-btn layui-btn-default layui-btn-sm pull-right" lay-event="execute_show_staff" id="execute_show_staff"> 人员显示</button>
46
64
  </div>
47
65
  </script>
48
66
 
@@ -60,14 +78,14 @@
60
78
  dropdown = layui.dropdown;
61
79
 
62
80
 
63
- laydate.render({
81
+ var year = laydate.render({
64
82
  elem: '#assessment_year',
65
83
  type: 'year'
66
84
  });
67
85
 
68
86
  var execute_property = xmSelect.render({
69
87
  el: '#execute_property',
70
- name: 'target_property',
88
+ name: 'school_tag_id',
71
89
  data: gon.school_tags
72
90
  })
73
91
 
@@ -77,192 +95,253 @@
77
95
  data: [{value: '中标', name: '中标'}, {value: '回款', name: '回款'}, {value: '商机', name: '商机'}]
78
96
  })
79
97
  form.render();
80
- form.on('submit(progress_resert_btn)', function (data) {
98
+ form.on('submit(execute_reset_btn)', function (data) {
99
+ form.val('execute_form', {
100
+ staff_id: 0,
101
+ year: new Date().getFullYear(),
102
+ });
81
103
  execute_property.setValue([]);
82
104
  execute_clazz.setValue([]);
83
105
  return false;
84
106
  })
85
107
 
86
- table.render({
87
- elem: '#finished_table'
88
- , toolbar: '#target_progress_toolbar'
108
+ var execute_table = table.render({
109
+ elem: '#execute_table'
110
+ , toolbar: '#execute_table_toolbar'
89
111
  , totalRow: true
90
112
  , url: '/missions/plans/years_all_target'
91
113
  , page: true
92
114
  , title: "绩效考核指标完成情况" // 目前发现的作用(导出文件的文件名)
93
- , defaultToolbar: ['exports']
115
+ , defaultToolbar: ['']
94
116
  , height: 'full-200'
95
- , cols: [
96
- [ //标题栏
97
- {field: 'id', group: 'id', align: 'center', title: '序号', width: 80, totalRowText: '合计', rowspan: 3}
98
- , {field: 'name', align: 'center', title: '姓名', width: 100, rowspan: 3}
99
- , {field: 'target_clazz', align: 'center', title: '类别', width: 100, rowspan: 3}
100
- , {field: 'year_target', align: 'center', title: '年度目标', width: 100, rowspan: 3, totalRow: true}
101
- , {field: 'school_tag_name', align: 'center', title: '客户类型', width: 100, rowspan: 3}
102
- , {field: 'year_clazz_target', align: 'center', title: '分项目标', width: 100, rowspan: 3, totalRow: true}
103
- , {field: 'year_plan', title: '年度计划', width: 100, rowspan: 3, totalRow: true}
104
- , {field: 'year_finish', title: '年度完成', width: 100, rowspan: 3, totalRow: true}
105
-
106
- ,{align: 'center', title: '1月', colspan: 3}
107
- ,{align: 'center', title: '2月', colspan: 3}
108
- ,{align: 'center', title: '3月', colspan: 3}
109
- ,{align: 'center', title: '4月', colspan: 3}
110
- ,{align: 'center', title: '5月', colspan: 3}
111
- ,{align: 'center', title: '6月', colspan: 3}
112
- ,{align: 'center', title: '7月', colspan: 3}
113
- ,{align: 'center', title: '8月', colspan: 3}
114
- ,{align: 'center', title: '9月', colspan: 3}
115
- ,{align: 'center', title: '10月', colspan: 3}
116
- ,{align: 'center', title: '11月', colspan: 3}
117
- ,{align: 'center', title: '12月', colspan: 3}
117
+ , cols: [[ //标题栏
118
+ {field: 'id', group: 'id', title: '序号', rowspan: 2, align: 'center'}
119
+ , {field: 'name', title: '姓名', rowspan: 2}
120
+ , {field: 'target_clazz', title: '类别', totalRowText: '合计', rowspan: 2}
121
+ , {field: 'year_target', title: '年度目标', rowspan: 2, totalRow: true}
122
+ , {field: 'school_tag_name', title: '客户类型', rowspan: 2}
123
+ , {field: 'year_clazz_target', title: '分项目标', rowspan: 2, totalRow: true}
124
+ , {field: 'year_plan', title: '年度计划', minWidth: 70, rowspan: 2, totalRow: true, templet: function(d) {return generateExecuteColumnTemplet('plan', 0, d.year_plan, d.year_finish, d.id)}}
125
+ , {field: 'year_finish', title: '年度完成',minWidth: 70, rowspan: 2, totalRow: true, templet: function(d) {return generateExecuteColumnTemplet('finish', 0, d.year_finish, 0, d.id)}}
126
+ ,{field:"month_1", align: 'center', title: '1月', colspan: 3}
127
+ ,{field:"month_2", align: 'center', title: '2月', colspan: 3}
128
+ ,{field:"month_3", align: 'center', title: '3月', colspan: 3}
129
+ ,{field:"month_4", align: 'center', title: '4月', colspan: 3}
130
+ ,{field:"month_5", align: 'center', title: '5月', colspan: 3}
131
+ ,{field:"month_6", align: 'center', title: '6月', colspan: 3}
132
+ ,{field:"month_7", align: 'center', title: '7月', colspan: 3}
133
+ ,{field:"month_8", align: 'center', title: '8月', colspan: 3}
134
+ ,{field:"month_9", align: 'center', title: '9月', colspan: 3}
135
+ ,{field:"month_10", align: 'center', title: '10月', colspan: 3}
136
+ ,{field:"month_11", align: 'center', title: '11月', colspan: 3}
137
+ ,{field:"month_12", align: 'center', title: '12月', colspan: 3}
118
138
  ],
119
139
  [
120
- {field: 'target_1', title: '目标', width: 100, totalRow:true, hidden: true}
121
- ,{field: 'plan_1', title: '计划', width: 100, totalRow:true, hidden: true}
122
- ,{field: 'finish_1', title: '完成', width: 100, totalRow:true}
140
+ {field: 'target_1', align: 'center', title: '目标', width: 50, totalRow: true}
141
+ ,{field: 'plan_1', align: 'center', title: '计划', width: 30, totalRow:true, templet: function(d) {return generateExecuteColumnTemplet('plan', 1 , d.plan_1, d.id)}}
142
+ ,{field: 'finish_1', align: 'center', title: '完成', width: 30, totalRow:true, templet: function(d) {return generateExecuteColumnTemplet('finish', 1, d.finish_1, d.target_1, d.id)}}
123
143
 
124
- ,{field: 'target_2', title: '目标', width: 100, totalRow:true}
125
- ,{field: 'plan_2', title: '计划', width: 100, totalRow:true}
126
- ,{field: 'finish_2', title: '完成', width: 100, totalRow:true}
144
+ ,{field: 'target_2', align: 'center', title: '目标', width: 30, totalRow:true}
145
+ ,{field: 'plan_2', align: 'center', title: '计划', width: 30, totalRow:true, templet: function(d) {return generateExecuteColumnTemplet('plan', 2, d.plan_2, 0, d.id)}}
146
+ ,{field: 'finish_2', align: 'center', title: '完成', width: 30, totalRow:true, templet: function(d) {return generateExecuteColumnTemplet('finish', 2, d.finish_2, d.target_2, d.id)}}
127
147
 
128
- ,{field: 'target_3', title: '目标', width: 100, totalRow:true}
129
- ,{field: 'plan_3', title: '计划', width: 100, totalRow:true}
130
- ,{field: 'finish_3', title: '完成', width: 100, totalRow:true}
148
+ ,{field: 'target_3', align: 'center', title: '目标', width: 30, totalRow:true}
149
+ ,{field: 'plan_3', align: 'center', title: '计划', width: 30, totalRow:true, templet: function(d) {return generateExecuteColumnTemplet('plan', 3, d.plan_3, 0, d.id)}}
150
+ ,{field: 'finish_3', align: 'center', title: '完成', width: 30, totalRow:true, templet: function(d) {return generateExecuteColumnTemplet('finish', 3, d.finish_3, d.target_3, d.id)}}
131
151
 
132
- ,{field: 'target_4', title: '目标', width: 100, totalRow:true}
133
- ,{field: 'plan_4', title: '计划', width: 100, totalRow:true}
134
- ,{field: 'finish_4', title: '完成', width: 100, totalRow:true}
152
+ ,{field: 'target_4', align: 'center', title: '目标', width: 30, totalRow:true}
153
+ ,{field: 'plan_4', align: 'center', title: '计划', width: 30, totalRow:true, templet: function(d) {return generateExecuteColumnTemplet('plan', 4, d.plan_4, 0, d.id)}}
154
+ ,{field: 'finish_4', align: 'center', title: '完成', width: 30, totalRow:true, templet: function(d) {return generateExecuteColumnTemplet('finish', 4, d.finish_4, d.target_4, d.id)}}
135
155
 
136
- ,{field: 'target_5', title: '目标', width: 100, totalRow:true}
137
- ,{field: 'plan_5', title: '计划', width: 100, totalRow:true}
138
- ,{field: 'finish_5', title: '完成', width: 100, totalRow:true}
156
+ ,{field: 'target_5', align: 'center', title: '目标', width: 30, totalRow:true}
157
+ ,{field: 'plan_5', align: 'center', title: '计划', width: 30, totalRow: true, templet: function(d) {return generateExecuteColumnTemplet('plan', 5, d.plan_5, 0, d.id)}}
158
+ ,{field: 'finish_5', align: 'center', title: '完成', width: 30, totalRow: true, templet: function(d) {return generateExecuteColumnTemplet('finish', 5, d.finish_5, d.target_5, d.id)}}
139
159
 
140
- ,{field: 'target_6', title: '目标', width: 100, totalRow:true}
141
- ,{field: 'plan_6', title: '计划', width: 100, totalRow:true}
142
- ,{field: 'finish_6', title: '完成', width: 100, totalRow:true}
160
+ ,{field: 'target_6', align: 'center', title: '目标', width: 30, totalRow: true}
161
+ ,{field: 'plan_6', align: 'center', title: '计划', width: 30, totalRow: true, templet: function(d) {return generateExecuteColumnTemplet('plan', 6, d.plan_6, 0, d.id)}}
162
+ ,{field: 'finish_6', align: 'center', title: '完成', width: 30, totalRow: true, templet: function(d) {return generateExecuteColumnTemplet('finish', 6, d.finish_6, d.target_6, d.id)}}
143
163
 
144
- ,{field: 'target_7', title: '目标', width: 100, totalRow:true}
145
- ,{field: 'plan_7', title: '计划', width: 100, totalRow:true}
146
- ,{field: 'finish_7', title: '完成', width: 100, totalRow:true}
164
+ ,{field: 'target_7', align: 'center', title: '目标', width: 30, totalRow: true}
165
+ ,{field: 'plan_7', align: 'center', title: '计划', width: 30, totalRow: true, templet: function(d) {return generateExecuteColumnTemplet('plan', 7, d.plan_7, 0, d.id)}}
166
+ ,{field: 'finish_7', align: 'center', title: '完成', width: 30, totalRow: true, templet: function(d) {return generateExecuteColumnTemplet('finish', 7, d.finish_7, d.target_7, d.id)}}
147
167
 
148
- ,{field: 'target_8', title: '目标', width: 100, totalRow:true}
149
- ,{field: 'plan_8', title: '计划', width: 100, totalRow:true}
150
- ,{field: 'finish_8', title: '完成', width: 100, totalRow:true}
168
+ ,{field: 'target_8', align: 'center', title: '目标', width: 30, totalRow: true}
169
+ ,{field: 'plan_8', align: 'center', title: '计划', width: 30, totalRow: true, templet: function(d) {return generateExecuteColumnTemplet('plan', 8, d.plan_8, 0, d.id)}}
170
+ ,{field: 'finish_8', align: 'center', title: '完成', width: 30, totalRow: true, templet: function(d) {return generateExecuteColumnTemplet('finish', 8, d.finish_8, d.target_8, d.id)}}
151
171
 
152
- ,{field: 'target_9', title: '目标', width: 100, totalRow:true}
153
- ,{field: 'plan_9', title: '计划', width: 100, totalRow:true}
154
- ,{field: 'finish_9', title: '完成', width: 100, totalRow:true}
172
+ ,{field: 'target_9', align: 'center', title: '目标', width: 30, totalRow: true}
173
+ ,{field: 'plan_9', align: 'center', title: '计划', width: 30, totalRow: true, templet: function(d) {return generateExecuteColumnTemplet('plan', 9, d.plan_9, 0, d.id)}}
174
+ ,{field: 'finish_9', align: 'center', title: '完成', width: 30, totalRow: true, templet: function(d) {return generateExecuteColumnTemplet('finish', 9, d.finish_9, d.target_9, d.id)}}
155
175
 
156
- ,{field: 'target_10', title: '目标', width: 100, totalRow:true}
157
- ,{field: 'plan_10', title: '计划', width: 100, totalRow:true}
158
- ,{field: 'finish_10', title: '完成', width: 100, totalRow:true}
176
+ ,{field: 'target_10', align: 'center', title: '目标', width: 30, totalRow: true}
177
+ ,{field: 'plan_10', align: 'center', title: '计划', width: 30, totalRow: true, templet: function(d) {return generateExecuteColumnTemplet('plan', 10, d.plan_10, 0, d.id)}}
178
+ ,{field: 'finish_10', align: 'center', title: '完成', width: 30, totalRow: true, templet: function(d) {return generateExecuteColumnTemplet('finish', 10, d.finish_10, d.target_10, d.id)}}
159
179
 
160
- ,{field: 'target_11', title: '目标', width: 100, totalRow:true}
161
- ,{field: 'plan_11', title: '计划', width: 100, totalRow:true}
162
- ,{field: 'finish_11', title: '完成', width: 100, totalRow:true}
163
-
164
- ,{field: 'target_12', title: '目标', width: 100, totalRow:true}
165
- ,{field: 'plan_12', title: '计划', width: 100, totalRow:true}
166
- ,{field: 'finish_12', title: '完成', width: 100, totalRow:true}
180
+ ,{field: 'target_11', align: 'center', title: '目标', width: 30, totalRow: true}
181
+ ,{field: 'plan_11', align: 'center', title: '计划', width: 30, totalRow: true, templet: function(d) {return generateExecuteColumnTemplet('plan', 11, d.plan_11, 0, d.id)}}
182
+ ,{field: 'finish_11', align: 'center', title: '完成', width: 30, totalRow: true, templet: function(d) {return generateExecuteColumnTemplet('finish', 11, d.finish_11, d.target_11, d.id)}}
167
183
 
184
+ ,{field: 'target_12', align: 'center', title: '目标', width: 30, totalRow: true}
185
+ ,{field: 'plan_12', align: 'center', title: '计划', width: 30, totalRow: true, templet: function(d) {return generateExecuteColumnTemplet('plan', 12, d.plan_12, 0, d.id)}}
186
+ ,{field: 'finish_12', align: 'center', title: '完成', width: 30, totalRow: true, templet: function(d) {return generateExecuteColumnTemplet('finish', 12, d.finish_12, d.target_12, d.id)}}
168
187
  ]],
169
188
  done : function(res, curr, count) {
170
- var id = res.data[0]['id'];
171
- merge(res);
172
- if (!id) {
173
- $("[data-field='id']").css('display', 'none');
174
- $("[data-field='name']").css('display', 'none');
189
+ if (res.data.length === 0) return false;
190
+ executeMerge(res);
191
+ var totalYearTarget = 0;
192
+ layui.each(res.data, function(index, item) {
193
+ totalYearTarget += item.year_clazz_target;
194
+ });
195
+ var innerHtml = '<div class="layui-table-cell laytable-cell-1-0-4" align="center">' + totalYearTarget + '</div>';
196
+ layui.$('[lay-id="execute_table"] .layui-table-total td[data-field="year_target"]').html(innerHtml);
197
+ layui.$('[lay-id="execute_table"] .layui-table-total td[data-field="id"]').css('width', '10px');
198
+ if (!res.data[0]['id']) {
199
+ $("[lay-id='execute_table'] [data-field='id']").css('display', 'none');
200
+ $("[lay-id='execute_table'] [data-field='name']").css('display', 'none');
201
+ }
202
+ var currentMonth = new Date().getMonth() + 1;
203
+ for (let i = 1; i < currentMonth; i++) {
204
+ let planField = 'plan_' + i;
205
+ $(`[lay-id='execute_table'] [data-field=${planField}]`).css('display', 'none');
206
+ let th_field = 'month_' + i;
207
+ var thElement = document.querySelector(`[lay-id='execute_table'] .layui-table-header th[data-field=${th_field}]`);
208
+ if (thElement) {
209
+ var colspan = parseInt(thElement.getAttribute('colspan'));
210
+ if (!isNaN(colspan)) {
211
+ thElement.setAttribute('colspan', colspan - 1);
212
+ }
213
+ }
175
214
  }
176
- table.render('select');
215
+ for (let i = currentMonth+1; i <= 12; i++) {
216
+ let field = 'finish_' + i;
217
+ $(`[lay-id='execute_table'] [data-field=${field}]`).css('display', 'none');
218
+ let th_field = 'month_' + i;
219
+ var thElement = document.querySelector(`[lay-id='execute_table'] .layui-table-header th[data-field=${th_field}]`);
220
+ if (thElement) {
221
+ var colspan = parseInt(thElement.getAttribute('colspan'));
222
+ if (!isNaN(colspan)) {
223
+ thElement.setAttribute('colspan', colspan - 1);
224
+ }
225
+ }
226
+ }
227
+ //stickField();
177
228
  }
178
-
179
229
  });
180
- function merge(res, id) {
181
- var data = res.data;
182
- var mergeIndex = 0;//定位需要添加合并属性的行数
183
- var mark = 1; //这里涉及到简单的运算,mark是计算每次需要合并的格子数
184
- var columsName = ['id','name','target_clazz',{name:'year_target',mergeBase:'target_clazz',valueBase:'year_clazz_target'}];//需要合并的列名称
185
- var columsIndex = [0,1,2,3];//需要合并的列索引值
186
-
187
- for (var k = 0; k < columsName.length; k++) { //这里循环所有要合并的列
188
- var trArr = $(".layui-table-body>.layui-table").find("tr");//所有行
189
- for (var i = 1; i < res.data.length; i++) { //这里循环表格当前的数据
190
- var tdCurArr = trArr.eq(i).find("td").eq(columsIndex[k]);//获取当前行的当前列
191
- var tdPreArr = trArr.eq(mergeIndex).find("td").eq(columsIndex[k]);//获取相同列的第一列
192
-
193
- var opt = columsName[k];
194
- var name = opt.name;
195
- var mergeBase = opt.mergeBase;
196
- var valueBase = opt.valueBase;
197
-
198
- if(name && mergeBase){
199
- tdCurValue = parseFloat(tdPreArr[0].querySelector('.layui-table-cell').textContent) || 0;
200
- if(valueBase && !tdCurValue){
201
- tdPreArr[0].querySelector('.layui-table-cell').innerHTML = data[i-1][valueBase];
202
- }
203
-
204
- if (data[i][mergeBase] === data[i-1][mergeBase]) { //后一行的值与前一行的值做比较,相同就需要合并
205
- mark += 1;
206
- tdPreArr.each(function (a,b) {//相同列的第一列增加rowspan属性
207
- $(this).attr("rowspan", mark);
208
-
209
- var oldV = parseFloat($(this).find('.layui-table-cell').html()) || 0;
210
- var curentV = 0;
211
- if(valueBase){
212
- curentV = parseFloat(data[i][valueBase]) || 0;
213
- }else{
214
- curentV = parseFloat(data[i][name]) || 0;
215
- }
216
- var newV = oldV + curentV;
217
- $(this).find('.layui-table-cell').html(newV);
218
- });
219
- tdCurArr.each(function () {//当前行隐藏
220
- $(this).css("display", "none");
221
- });
222
- }else {
223
- mergeIndex = i;
224
- mark = 1;//一旦前后两行的值不一样了,那么需要合并的格子数mark就需要重新计算
225
- }
226
- }else{
227
- if (data[i][columsName[k]] === data[i-1][columsName[k]]) { //后一行的值与前一行的值做比较,相同就需要合并
228
- mark += 1;
229
- tdPreArr.each(function () {//相同列的第一列增加rowspan属性
230
- $(this).attr("rowspan", mark);
231
- });
232
- tdCurArr.each(function () {//当前行隐藏
233
- $(this).css("display", "none");
234
- });
235
- }else {
236
- mergeIndex = i;
237
- mark = 1;//一旦前后两行的值不一样了,那么需要合并的格子数mark就需要重新计算
238
- }
239
- }
240
- }
241
- mergeIndex = 0;
242
- mark = 1;
243
- }
244
- }
245
- table.on('toolbar(year_all_target_form)', function (obj) {
246
- search = form.val('assessment_progress_form')
230
+ function executeMerge(res) {
231
+ var data = res.data;
232
+ var mergeIndex = 0;//定位需要添加合并属性的行数
233
+ var mark = 1; //这里涉及到简单的运算,mark是计算每次需要合并的格子数
234
+ var columsName = ['id','name','target_clazz',{name:'year_target',mergeBase:'target_clazz',valueBase:'year_clazz_target'}];//需要合并的列名称
235
+ var columsIndex = [0,1,2,3];//需要合并的列索引值
236
+
237
+ for (var k = 0; k < columsName.length; k++) { //这里循环所有要合并的列
238
+ var trArr = $('[lay-id="execute_table"] .layui-table-body>.layui-table').find("tr");//所有行
239
+ for (var i = 1; i < res.data.length; i++) { //这里循环表格当前的数据
240
+ var tdCurArr = trArr.eq(i).find("td").eq(columsIndex[k]);//获取当前行的当前列
241
+ var tdPreArr = trArr.eq(mergeIndex).find("td").eq(columsIndex[k]);//获取相同列的第一列
242
+ var opt = columsName[k];
243
+ var name = opt.name;
244
+ var mergeBase = opt.mergeBase;
245
+ var valueBase = opt.valueBase;
246
+
247
+ if(name && mergeBase){
248
+ var tdCurValue = parseFloat(tdPreArr[0].querySelector('.layui-table-cell').textContent) || 0;
249
+ if(valueBase && !tdCurValue){
250
+ tdPreArr[0].querySelector('.layui-table-cell').innerHTML = data[i-1][valueBase];
251
+ }
252
+
253
+ if (data[i]['id'] === data[i-1]['id'] && data[i][mergeBase] === data[i-1][mergeBase]) { //后一行的值与前一行的值做比较,相同就需要合并
254
+ mark += 1;
255
+ tdPreArr.each(function (a,b) {//相同列的第一列增加rowspan属性
256
+ $(this).attr("rowspan", mark);
257
+ var oldV = parseFloat($(this).find('.layui-table-cell').html()) || 0;
258
+ var curentV;
259
+ if(valueBase){
260
+ curentV = parseFloat(data[i][valueBase]) || 0;
261
+ }else{
262
+ curentV = parseFloat(data[i][name]) || 0;
263
+ }
264
+ var newV = oldV + curentV;
265
+ $(this).find('.layui-table-cell').html(newV);
266
+ });
267
+ tdCurArr.each(function () {//当前行隐藏
268
+ $(this).css("display", "none");
269
+ });
270
+ }else {
271
+ mergeIndex = i;
272
+ mark = 1;//一旦前后两行的值不一样了,那么需要合并的格子数mark就需要重新计算
273
+ }
274
+ }else{
275
+ if (data[i]['id'] === data[i-1]['id'] && data[i][columsName[k]] === data[i-1][columsName[k]]) { //后一行的值与前一行的值做比较,相同就需要合并
276
+ mark += 1;
277
+ tdPreArr.each(function () {//相同列的第一列增加rowspan属性
278
+ $(this).attr("rowspan", mark);
279
+ });
280
+ tdCurArr.each(function () {//当前行隐藏
281
+ $(this).css("display", "none");
282
+ });
283
+ }else {
284
+ mergeIndex = i;
285
+ mark = 1;//一旦前后两行的值不一样了,那么需要合并的格子数mark就需要重新计算
286
+ }
287
+ }
288
+ }
289
+ mergeIndex = 0;
290
+ mark = 1;
291
+ }
292
+ }
293
+ // 在表格渲染完成后修改表格列固定方式
294
+ function stickField() {
295
+ var tableWrapper = document.querySelector('.layui-table-box');
296
+ var headerCells = tableWrapper.querySelectorAll('.layui-table-header th[data-field]');
297
+ var bodyCells = tableWrapper.querySelectorAll('.layui-table-body td[data-field]');
298
+
299
+ for (var i = 0; i < headerCells.length; i++) {
300
+ var headerCell = headerCells[i];
301
+ var field = headerCell.getAttribute('data-field');
302
+
303
+ if (field === 'id' || field === 'name') {
304
+ var columnIndex = i + 1;
305
+ var customFixedCell = tableWrapper.querySelector('.layui-table-fixed-l th:nth-child(' + columnIndex + ')');
306
+ customFixedCell.classList.add('custom-fixed-column');
307
+ }
308
+ }
309
+
310
+ for (var j = 0; j < bodyCells.length; j++) {
311
+ var bodyCell = bodyCells[j];
312
+ var field = bodyCell.getAttribute('data-field');
313
+
314
+ if (field === 'id' || field === 'name') {
315
+ var columnIndex = j + 1;
316
+ var customFixedCell = tableWrapper.querySelector('.layui-table-fixed-l td:nth-child(' + columnIndex + ')');
317
+ customFixedCell.classList.add('custom-fixed-column');
318
+ }
319
+ }
320
+ }
321
+
322
+ table.on('toolbar(execute_table_filter)', function (obj) {
323
+ search = form.val('execute_form')
247
324
  var event = obj.event;
248
325
  switch (event) {
249
- case 'show_staff':
326
+ case 'execute_show_staff':
250
327
  search.type = 'staff';
251
328
  break;
252
- case 'show_all':
329
+ case 'execute_show_all':
253
330
  search.type = 'all';
254
331
  search.staff_id = '';
255
332
  break;
256
- case 'export':
333
+ case 'execute_export':
257
334
  layer.load(0, {});
258
- request.authGet("missions/plans/years_all_target?=" + $.param({q: search}), {}, function (res) {
335
+ $ = layui.$;
336
+ console.log($.param( search))
337
+ request.authGet("missions/plans/years_all_target?=" + $.param(search), {}, function (res) {
259
338
  data = res.data
260
- table.exportFile(target_table.config.id, data, 'xls');
339
+ table.exportFile(execute_table.config.id, data, 'xls');
261
340
  layer.closeAll('loading');
262
341
  });
263
342
  break;
264
343
  }
265
- if (event === 'show_staff' || event === 'show_all') {
344
+ if (event === 'execute_show_staff' || event === 'execute_show_all') {
266
345
  loadFinishTable(search);
267
346
  var $ = layui.$;
268
347
  var buttonId = `#${event}`;
@@ -271,22 +350,78 @@
271
350
  $(buttonId).removeClass('layui-btn-primary').addClass('layui-btn-default');
272
351
  }
273
352
  });
353
+ table.on('tool(execute_table_filter)', function (obj) {
354
+ let event = obj.event; // 获取事件名
355
+ let rowData = obj.data; // 获取当前行的数据
356
+ let formVal = form.val('execute_form');
357
+ if (event !== '' && event.includes('business')) {
358
+ let params = event.split('_');
359
+ console.log(params);
360
+ _year = formVal.year;
361
+ type = params[1];
362
+ month = params[2];
363
+ staff_id = rowData.staff_id;
364
+ _target_clazz = rowData.target_clazz;
365
+ school_tag_id = rowData.school_tag_id;
366
+ let paramString = 'year=' + _year + '&month=' + month + '&staff_id=' + staff_id + '&school_tag_id=' +
367
+ school_tag_id + '&_target_clazz=' + _target_clazz + '&type=' + type;
274
368
 
275
- //loadFinishTable(form.val('assessment_progress_form'))
369
+ content = miniPage.getHrefContent('/missions/plans/staff_year_business?' + paramString);
370
+ openWH = miniPage.getOpenWidthHeight();
371
+ index = layer.open({
372
+ type: 1,
373
+ shade: 0.2,
374
+ maxmin: true,
375
+ shadeClose: true,
376
+ area: [openWH[0] + 'px', openWH[1] + 'px'],
377
+ offset: [openWH[2] + 'px', openWH[3] + 'px'],
378
+ content: content
379
+ });
380
+ $(window).on("resize", function () {
381
+ layer.full(index);
382
+ });
383
+ }
384
+ });
276
385
 
277
- form.on('submit(progress_search_btn)', function (data) {
386
+ //loadFinishTable(form.val('execute_form'))
387
+
388
+ form.on('submit(execute_search_btn)', function (data) {
278
389
  var search = data.field;
279
390
  loadFinishTable(search);
280
391
  return false;
281
392
  })
282
393
 
283
394
  function loadFinishTable(search) {
284
- table.reload('finished_table', {
395
+ table.reload('execute_table', {
285
396
  where: search,
286
397
  url: '/missions/plans/years_all_target'
287
398
  });
288
399
  }
289
400
 
401
+ function generateExecuteColumnTemplet(type, time, num = 0, target = 0, id =0) {
402
+ if (id === 0) {
403
+ if (type === 'finish' && target > num) {
404
+ return '<div style="color:red">' + num + '</div>';
405
+ } else {
406
+ return num;
407
+ }
408
+ }
409
+ let event = 'business_' + type + '_' + time;
410
+ if (num === 0) {
411
+ if (type === 'finish' && target > num) {
412
+ return '<div style="color:red">' + num + '</div>';
413
+ } else {
414
+ return 0
415
+ }
416
+ } else {
417
+ if (type === 'finish' && target > num) {
418
+ return '<div><a href="javascript:void(0);" class="layui-table-link" style="color:red" lay-event="' + event + '">' + num + '</a></div>';
419
+ } else {
420
+ return '<div><a href="javascript:void(0);" class="layui-table-link" lay-event="' + event + '">' + num + '</a></div>';
421
+ }
422
+ }
423
+ }
424
+
290
425
  })
291
426
 
292
427
  </script>