Browse Source

分数段分页显示

gzb
guozhongbo 1 year ago
parent
commit
eb3d8b6d1f
2 changed files with 44 additions and 11 deletions
  1. 43
    11
      js/scoreAnalysis/section_2_part.js
  2. 1
    0
      sections/scoreAnalysis/section_2_part.html

+ 43
- 11
js/scoreAnalysis/section_2_part.js View File

110
     var calsslist = [];
110
     var calsslist = [];
111
     var tableobj = {};
111
     var tableobj = {};
112
     var num = -1;
112
     var num = -1;
113
+    var rownum = 6;//一行七条数据
114
+    // if(s_index != 0) return
113
     $.each(xAxis_data, function (idx, item) {
115
     $.each(xAxis_data, function (idx, item) {
114
-      if ((idx + 7) % 7 == 0) {
116
+      if ((idx + rownum) % rownum == 0) {
115
         num++;
117
         num++;
116
         tableobj[num+"trHtml"] = "";
118
         tableobj[num+"trHtml"] = "";
117
         tableobj[num + "goodTableHeadTr1Html"] = '<th rowspan="2">班级</th>';
119
         tableobj[num + "goodTableHeadTr1Html"] = '<th rowspan="2">班级</th>';
134
         var rank = $.grep(classs, function (val) {
136
         var rank = $.grep(classs, function (val) {
135
           return val.rankname == item;
137
           return val.rankname == item;
136
         })[0];
138
         })[0];
137
-        if ((idx + 7) % 7 == 0) {
139
+        if ((idx + rownum) % rownum == 0) {
138
           num++;
140
           num++;
139
           if (index == 0) {
141
           if (index == 0) {
140
             tableobj[num + "trHtml"] += "<tr>";
142
             tableobj[num + "trHtml"] += "<tr>";
152
       });
154
       });
153
        
155
        
154
     })
156
     })
157
+    //计算表格高度 页面高1047 剩余高度700 表头62.5  内容27.42
158
+    var tableheight = (calsslist.length * 27.5+62.5 +15) * (num+1);
159
+    var page = {
160
+      1:"",2:"",3:""
161
+    }; //页数
155
     var table = "";
162
     var table = "";
156
-    for (var i = 0; i < num+1; i++){
157
-      table+='  <table border="1" class="my_table"><thead><tr class="goodTableHeadTr1">' +
158
-      tableobj[i+"goodTableHeadTr1Html"] + '</tr><tr class="goodTableHeadTr2">' +
159
-      tableobj[i+"goodTableHeadTr2Html"] + '</tr></thead><tbody class="goodTableTbody">' +
160
-      tableobj[i+"trHtml"] + '</tbody></table>'
163
+    var itemheight = calsslist.length * 27.5 + 62.5 + 15; //单表高度
164
+    var maxheight = 0;
165
+    for (var i = 0; i < num + 1; i++){
166
+      maxheight = itemheight * (i + 1)
167
+      var content = '  <table border="1" class="my_table"><thead><tr class="goodTableHeadTr1">' +
168
+        tableobj[i + "goodTableHeadTr1Html"] + '</tr><tr class="goodTableHeadTr2">' +
169
+        tableobj[i + "goodTableHeadTr2Html"] + '</tr></thead><tbody class="goodTableTbody">' +
170
+        tableobj[i + "trHtml"] + '</tbody></table>';
171
+      //计算剩余高度是否能显示最后一个表格
172
+      if (maxheight > 700 || 700-maxheight<itemheight) {
173
+        page[1] += content;
174
+      } else if (maxheight > 1747 || 1747-maxheight<itemheight) {
175
+        page[2] += content;
176
+      } else {
177
+        table += content;
178
+      }
179
+    }
180
+    $(".part_" + s_index + " .table_" + s_index + " ").html(table);
181
+    if (tableheight > 700) {
182
+      //添加第一页
183
+      $(".part_" + s_index).after('<div class="page_root section_2_part part_' +
184
+      s_index +
185
+        '_1"></div>')
186
+      $(".part_" + s_index + "_1").html(page[1]);
187
+    } else if (tableheight > 1747) {
188
+      //添加第二页
189
+      $(".part_" + s_index+'_1').after('<div class="page_root section_2_part part_' +
190
+      s_index +
191
+        '_2"></div>')
192
+      $(".part_" + s_index + "_2").html(page[2]);
161
     }
193
     }
162
-    $(".part_"+ s_index + " .table_"+s_index+" ").html(table);
163
   }
194
   }
164
   var parameter = $(".section_2_html_root .section_2_part_html_root").data(
195
   var parameter = $(".section_2_html_root .section_2_part_html_root").data(
165
     "page-params"
196
     "page-params"
197
       s_item.subjectname +
228
       s_item.subjectname +
198
       '分数段统计</h3><h4 class="section_title_4">3.' +
229
       '分数段统计</h3><h4 class="section_title_4">3.' +
199
       (s_index + 1) +
230
       (s_index + 1) +
200
-      '.1 各分数段分析</h4><div>当前设置分数段:<span class="curscorepart">10</span>分/段</div><div id="classPartEcharts" style="margin: 0 4mm 4mm; height: 80mm"></div><h4 h4 class="section_title_4" > 3.' +
231
+      '.1 各分数段分析</h4><div>当前设置分数段:<span class="curscorepart">10</span>分/段</div><div id="classPartEcharts" style="margin: 0 4mm 4mm; height: 80mm"></div><h4 class="section_title_4" > 3.' +
201
       (s_index + 1) +
232
       (s_index + 1) +
202
-      '.2 各班等级比例分布<z < div class="table_'+s_index+'" ></ ></div > ';
233
+      '.2 各班等级比例分布 </h4><div class="tables table_'+s_index+'" ></div ></div > ';
203
     
234
     
204
   });
235
   });
205
   $(".section_2_part_root").html(singleRootHtml);
236
   $(".section_2_part_root").html(singleRootHtml);
206
   $.each(subjectInfo, function (s_index, s_item) { 
237
   $.each(subjectInfo, function (s_index, s_item) { 
207
     $(".part_ " + s_index + " .curscorepart").text(s_item.maxscore);
238
     $(".part_ " + s_index + " .curscorepart").text(s_item.maxscore);
208
-    classscorePartEcharts(s_index,s_item);
239
+    classscorePartEcharts(s_index, s_item);
240
+    // var height = $(".part_" + s_index).height()
209
   })
241
   })
210
 });
242
 });

+ 1
- 0
sections/scoreAnalysis/section_2_part.html View File

5
     <meta http-equiv="X-UA-Compatible" content="IE=edge" />
5
     <meta http-equiv="X-UA-Compatible" content="IE=edge" />
6
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
     <title>校本PDF报告-第二章 成绩分析</title>
7
     <title>校本PDF报告-第二章 成绩分析</title>
8
+    <link rel="stylesheet" href="../../css/scoreAnalysis/section_2_part.css" />
8
   </head>
9
   </head>
9
   <body>
10
   <body>
10
     <div class="section_2_part_root">
11
     <div class="section_2_part_root">

Loading…
Cancel
Save