智慧校园考试-班级报告
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

section_6.js 6.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. $(function () {
  2. function initbadexamEcharts (list) {
  3. var itemStyle = {
  4. normal: {
  5. label: {
  6. show: true, //开启显示数值
  7. position: "top" //数值在上方显示
  8. }
  9. }
  10. };
  11. var num = [],
  12. xAxis_data = [];
  13. var curlegend = ["违纪人数"];
  14. var curclass = {
  15. num: 0,
  16. classname: ""
  17. };
  18. $.each(list.wjsjkm, function (idx, item) {
  19. if (item.num > curclass.num) {
  20. curclass = {
  21. num: item.num,
  22. classname: item.subjectname
  23. };
  24. }
  25. num.push(item.num);
  26. xAxis_data.push(item.subjectname);
  27. });
  28. $(".section_6 .subjectbadexamMaxNum").text(curclass.classname);
  29. var curseries = [
  30. {
  31. name: "违纪人数",
  32. type: "bar",
  33. barWidth: $.UnitUtil.mm2px(5),
  34. // 柱状图最小高度
  35. barMinHeight: $.UnitUtil.mm2px(2),
  36. barGap: 0,
  37. data: num,
  38. itemStyle: itemStyle
  39. }
  40. ];
  41. var option = {
  42. animation: false,
  43. color: ["#5C99FF", "#FF5F56", "#5EC5C8", "#f1982b"],
  44. title: {
  45. text: "人",
  46. x: "left",
  47. y: "top",
  48. textStyle: {
  49. color: "#5F6E82",
  50. fontSize: $.UnitUtil.mm2px(3),
  51. fontWeight: 500
  52. }
  53. },
  54. legend: {
  55. itemWidth: $.UnitUtil.mm2px(2),
  56. itemHeight: $.UnitUtil.mm2px(2),
  57. top: "bottom",
  58. data: curlegend
  59. },
  60. grid: {
  61. top: $.UnitUtil.mm2px(10),
  62. left: 0,
  63. right: 0,
  64. bottom: $.UnitUtil.mm2px(8),
  65. containLabel: true
  66. },
  67. xAxis: [
  68. {
  69. type: "category",
  70. data: xAxis_data,
  71. axisLabel: {
  72. color: "#5F6E82" //更改坐标轴文字颜色
  73. },
  74. axisTick: {
  75. alignWithLabel: true
  76. },
  77. boundaryGap: true,
  78. triggerEvent: true,
  79. axisLine: {
  80. show: true, //是否显示轴线
  81. lineStyle: {
  82. color: "#DADADA" //刻度线的颜色
  83. }
  84. }
  85. }
  86. ],
  87. yAxis: [
  88. {
  89. type: "value",
  90. axisTick: {
  91. show: false //刻度
  92. },
  93. axisLine: {
  94. show: false, //是否显示轴线
  95. lineStyle: {
  96. color: "#DADADA" //刻度线的颜色
  97. }
  98. },
  99. splitLine: {
  100. //网格线
  101. lineStyle: {
  102. type: "dotted" //设置网格线类型 dotted:虚线 solid:实线
  103. },
  104. show: true //隐藏或显示
  105. },
  106. axisLabel: {
  107. color: "#5F6E82" //更改坐标轴文字颜色
  108. }
  109. }
  110. ],
  111. series: curseries
  112. };
  113. var myEcharts = echarts.init(
  114. document.querySelector(".section_6 #badexamEcharts")
  115. );
  116. myEcharts.clear();
  117. myEcharts.setOption(option);
  118. showbadexamable(list);
  119. }
  120. function showbadexamable(list) {
  121. var table = {},
  122. goodTableHeadTr1Html =
  123. '<th colspan="2">考试信息</th><th colspan="' +
  124. list.wjsjkm.length +
  125. '">科目信息</th>',
  126. goodTableHeadTr2Html = "<th>姓名</th><th>账号</th>",
  127. trHtml = "";
  128. var surplusheight = pageheight - $(".section_6 .violationheight").height(); //本页剩余高度
  129. var henght = 62.46,
  130. row = 27.42; //表头62.46 一行高27.42
  131. var pagedaba = {
  132. 0: ""
  133. },
  134. page = 0;
  135. var maxstu = {
  136. num: 0,
  137. username: ""
  138. };
  139. var pagesheight = {
  140. 0: 0
  141. };
  142. $.each(list.wjsjkm, function (idx, item) {
  143. goodTableHeadTr2Html += "<th>" + item.subjectname + "</th>";
  144. });
  145. $.each(list.wjsj, function (idx, item) {
  146. if (
  147. page == 0 &&
  148. (henght >= surplusheight || surplusheight - henght <= row)
  149. ) {
  150. // 加第一页
  151. page++;
  152. henght = 62.46;
  153. pagedaba[page] = "";
  154. }
  155. if (page != 0 && (henght >= pageheight || pageheight - henght <= row)) {
  156. page++;
  157. henght = 62.46;
  158. pagedaba[page] = "";
  159. }
  160. henght += row;
  161. pagesheight[page] = henght;
  162. item.subjectjson = item.subjectjson ? JSON.parse(item.subjectjson) : [];
  163. var subject_num = {};
  164. pagedaba[page] +=
  165. "<tr><td>" + item.username + "</td><td>" + item.loginname + "</td>";
  166. var num = 0;
  167. $.each(item.subjectjson, function (idx, item) {
  168. num += item.num;
  169. subject_num[item.subjectid] = item.num || 0;
  170. });
  171. if (num > maxstu.num) {
  172. maxstu = {
  173. num: num,
  174. username: item.username
  175. };
  176. } else if (num == maxstu.num) {
  177. maxstu.username += "、" + item.username;
  178. }
  179. $.each(list.wjkm, function (idx, item) {
  180. pagedaba[page] += "<td>" + (subject_num[item.subjectid] || 0) + "</td>";
  181. });
  182. });
  183. //高度 89
  184. var isadd = true;
  185. var maxstuhtml =
  186. '<div class="echarts_result"><div>上图统计结果表示:</div><div class="echarts_result_content"><span class="dot bg_5699FF"></span>违纪试卷最多的学生:' +
  187. maxstu.username +
  188. "</div></div>";
  189. for (var i = 0; i <= page; i++) {
  190. table[i] =
  191. '<table border="1" class="my_table"><thead><tr class="goodTableHeadTr1">' +
  192. goodTableHeadTr1Html +
  193. '</tr><tr class="goodTableHeadTr2">' +
  194. goodTableHeadTr2Html +
  195. '</tr></thead><tbody class="goodTableTbody">' +
  196. pagedaba[i] +
  197. "</tbody></table>";
  198. if (i != 0) {
  199. //添加分页
  200. $(".page_" + (i - 1) + ".section_6").after(
  201. '<div class="page_root section_6' + " page_" + i + '"></div>'
  202. );
  203. $(".page_root.section_6" + ".page_" + i).html(table[i]);
  204. }
  205. //添加表格结果数据
  206. if (i == 0 && surplusheight - pagesheight[i] >= 89) {
  207. isadd = false;
  208. $(".section_6 .stubadexamtable").after(
  209. '<div class="echarts_result resultdata"></div>'
  210. );
  211. $(".echarts_result.resultdata").html(maxstuhtml);
  212. } else if (i != 0 && pageheight - pagesheight[i] >= 89) {
  213. isadd = false;
  214. $(".page_" + i + ".section_6 .my_table").after(
  215. '<div class="page_' + (i + 1) + ' my_result"></div>'
  216. );
  217. $(".page_" + (i + 1) + ".my_result").html(maxstuhtml);
  218. }
  219. }
  220. $(".section_6 .stubadexamtable").html(table[0]);
  221. //添加至新页
  222. if (isadd) {
  223. $(".page_" + page).after(
  224. '<div class="page_root section_6 page_' + (page + 1) + '"></div>'
  225. );
  226. $(".page_" + (page + 1) + "").html(maxstuhtml);
  227. }
  228. }
  229. var parameter = $(".section_6_html_root").data("page-params");
  230. parameter = JSON.parse(parameter);
  231. initbadexamEcharts(parameter);
  232. });