瀏覽代碼

分数段分页显示

gzb
guozhongbo 1 年之前
父節點
當前提交
eb3d8b6d1f
共有 2 個文件被更改,包括 44 次插入11 次删除
  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 查看文件

@@ -110,8 +110,10 @@ $(function () {
110 110
     var calsslist = [];
111 111
     var tableobj = {};
112 112
     var num = -1;
113
+    var rownum = 6;//一行七条数据
114
+    // if(s_index != 0) return
113 115
     $.each(xAxis_data, function (idx, item) {
114
-      if ((idx + 7) % 7 == 0) {
116
+      if ((idx + rownum) % rownum == 0) {
115 117
         num++;
116 118
         tableobj[num+"trHtml"] = "";
117 119
         tableobj[num + "goodTableHeadTr1Html"] = '<th rowspan="2">班级</th>';
@@ -134,7 +136,7 @@ $(function () {
134 136
         var rank = $.grep(classs, function (val) {
135 137
           return val.rankname == item;
136 138
         })[0];
137
-        if ((idx + 7) % 7 == 0) {
139
+        if ((idx + rownum) % rownum == 0) {
138 140
           num++;
139 141
           if (index == 0) {
140 142
             tableobj[num + "trHtml"] += "<tr>";
@@ -152,14 +154,43 @@ $(function () {
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 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 195
   var parameter = $(".section_2_html_root .section_2_part_html_root").data(
165 196
     "page-params"
@@ -197,14 +228,15 @@ $(function () {
197 228
       s_item.subjectname +
198 229
       '分数段统计</h3><h4 class="section_title_4">3.' +
199 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 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 236
   $(".section_2_part_root").html(singleRootHtml);
206 237
   $.each(subjectInfo, function (s_index, s_item) { 
207 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 查看文件

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

Loading…
取消
儲存