智慧校园考试-班级报告
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_4.js 6.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. $(function () {
  2. function initviolationEcharts(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.wjkm, 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_4 .subjectviolationMaxNum").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($(".section_4 #violationEcharts")[0]);
  114. myEcharts.clear();
  115. myEcharts.setOption(option);
  116. showviolationtable(list);
  117. }
  118. function showviolationtable(list) {
  119. var table = {},
  120. goodTableHeadTr1Html =
  121. '<th colspan="2">考试信息</th><th colspan="' +
  122. list.wjkm.length +
  123. '">科目信息</th>',
  124. goodTableHeadTr2Html = "<th>姓名</th><th>账号</th>",
  125. trHtml = "";
  126. var surplusheight = pageheight - $(".section_4 .violationheight").height(); //本页剩余高度
  127. var henght = 62.46,
  128. row = 27.42; //表头62.46 一行高27.42
  129. var pagedaba = {
  130. 0: ""
  131. },
  132. page = 0;
  133. var maxstu = {
  134. num: 0,
  135. username: ""
  136. };
  137. var pagesheight = {
  138. 0: 0
  139. };
  140. $.each(list.wjkm, function (idx, item) {
  141. goodTableHeadTr2Html += "<th>" + item.subjectname + "</th>";
  142. });
  143. $.each(list.wjfx, function (idx, item) {
  144. if (
  145. page == 0 &&
  146. (henght >= surplusheight || surplusheight - henght <= row)
  147. ) {
  148. // 加第一页
  149. page++;
  150. henght = 62.46;
  151. pagedaba[page] = "";
  152. }
  153. if (page != 0 && (henght >= pageheight || pageheight - henght <= row)) {
  154. page++;
  155. henght = 62.46;
  156. pagedaba[page] = "";
  157. }
  158. henght += row;
  159. pagesheight[page] = henght;
  160. item.subjectjson = item.subjectjson ? JSON.parse(item.subjectjson) : [];
  161. var subject_num = {};
  162. pagedaba[page] +=
  163. "<tr><td>" + item.username + "</td><td>" + item.loginname + "</td>";
  164. var num = 0;
  165. $.each(item.subjectjson, function (idx, item) {
  166. num += item.num;
  167. subject_num[item.subjectid] = item.num || 0;
  168. });
  169. if (num > maxstu.num) {
  170. maxstu = {
  171. num: num,
  172. username: item.username
  173. };
  174. } else if (num == maxstu.num) {
  175. maxstu.username += "、" + item.username;
  176. }
  177. $.each(list.wjkm, function (idx, item) {
  178. pagedaba[page] += "<td>" + (subject_num[item.subjectid] || 0) + "</td>";
  179. });
  180. });
  181. //高度 89
  182. var isadd = true;
  183. var maxstuhtml =
  184. '<div class="echarts_result"><div>上图统计结果表示:</div><div class="echarts_result_content"><span class="dot bg_5699FF"></span>违纪行为最多的学生:' +
  185. maxstu.username +
  186. "</div></div>";
  187. for (var i = 0; i <= page; i++) {
  188. table[i] =
  189. '<table border="1" class="my_table"><thead><tr class="goodTableHeadTr1">' +
  190. goodTableHeadTr1Html +
  191. '</tr><tr class="goodTableHeadTr2">' +
  192. goodTableHeadTr2Html +
  193. '</tr></thead><tbody class="goodTableTbody">' +
  194. pagedaba[i] +
  195. "</tbody></table>";
  196. if (i != 0) {
  197. //添加分页
  198. $(".page_" + (i - 1) + ".section_4").after(
  199. '<div class="page_root section_4' + " page_" + i + '"></div>'
  200. );
  201. $(".page_root.section_4" + ".page_" + i).html(table[i]);
  202. }
  203. //添加表格结果数据
  204. if (i == 0 && surplusheight - pagesheight[i] >= 89) {
  205. isadd = false;
  206. $(".section_4 .stuViolationtable").after(
  207. '<div class="echarts_result resultdata"></div>'
  208. );
  209. $(".echarts_result.resultdata").html(maxstuhtml);
  210. } else if (i != 0 && pageheight - pagesheight[i] >= 89) {
  211. isadd = false;
  212. $(".page_" + i + ".section_4 .my_table").after(
  213. '<div class="page_' + (i + 1) + ' my_result"></div>'
  214. );
  215. $(".page_" + (i + 1) + ".my_result").html(maxstuhtml);
  216. }
  217. }
  218. $(".section_4 .stuViolationtable").html(table[0]);
  219. //添加至新页
  220. if (isadd) {
  221. $(".page_" + page).after(
  222. '<div class="page_root section_4 page_' + (page + 1) + '"></div>'
  223. );
  224. $(".page_" + (page + 1) + "").html(maxstuhtml);
  225. }
  226. }
  227. var parameter = $(".section_4_html_root").data("page-params");
  228. parameter = JSON.parse(parameter);
  229. initviolationEcharts(parameter);
  230. });