123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204 |
- $(function () {
- function initviolationEcharts(list) {
- var itemStyle = {
- normal: {
- label: {
- show: true, //开启显示数值
- position: "top" //数值在上方显示
- }
- }
- };
- var num = [],
- xAxis_data = [];
- var curlegend = ["违纪人数"];
- var curclass = {
- num: 0,
- classname: ""
- };
- $.each(list.wjkm, function (idx, item) {
- if (item.num > curclass.num) {
- curclass = {
- num: item.num,
- classname: item.subjectname
- };
- }
- num.push(item.num);
- xAxis_data.push(item.subjectname);
- });
- $(".section_4 .subjectviolationMaxNum").text(curclass.classname);
- var curseries = [
- {
- name: "违纪人数",
- type: "bar",
- barWidth: $.UnitUtil.mm2px(5),
- // 柱状图最小高度
- barMinHeight: $.UnitUtil.mm2px(2),
- barGap: 0,
- data: num,
- itemStyle: itemStyle
- }
- ];
- var option = {
- animation: false,
- color: ["#5C99FF", "#FF5F56", "#5EC5C8", "#f1982b"],
- title: {
- text: "人",
- x: "left",
- y: "top",
- textStyle: {
- color: "#5F6E82",
- fontSize: $.UnitUtil.mm2px(3),
- fontWeight: 500
- }
- },
- legend: {
- itemWidth: $.UnitUtil.mm2px(2),
- itemHeight: $.UnitUtil.mm2px(2),
- top: "bottom",
- data: curlegend
- },
- grid: {
- top: $.UnitUtil.mm2px(10),
- left: 0,
- right: 0,
- bottom: $.UnitUtil.mm2px(8),
- containLabel: true
- },
- xAxis: [
- {
- type: "category",
- data: xAxis_data,
- axisLabel: {
- color: "#5F6E82" //更改坐标轴文字颜色
- },
- axisTick: {
- alignWithLabel: true
- },
- boundaryGap: true,
- triggerEvent: true,
- axisLine: {
- show: true, //是否显示轴线
- lineStyle: {
- color: "#DADADA" //刻度线的颜色
- }
- }
- }
- ],
- yAxis: [
- {
- type: "value",
- axisTick: {
- show: false //刻度
- },
- axisLine: {
- show: false, //是否显示轴线
- lineStyle: {
- color: "#DADADA" //刻度线的颜色
- }
- },
- splitLine: {
- //网格线
- lineStyle: {
- type: "dotted" //设置网格线类型 dotted:虚线 solid:实线
- },
- show: true //隐藏或显示
- },
- axisLabel: {
- color: "#5F6E82" //更改坐标轴文字颜色
- }
- }
- ],
- series: curseries
- };
- var myEcharts = echarts.init(
- document.querySelector(".section_4 #violationEcharts")
- );
- myEcharts.clear();
- myEcharts.setOption(option);
- showviolationtable(list);
- }
-
- function showviolationtable(list) {
- var table = {},
- goodTableHeadTr1Html =
- '<th colspan="2">考试信息</th><th colspan="' +
- list.wjkm.length +
- '">科目信息</th>',
- goodTableHeadTr2Html = "<th>姓名</th><th>账号</th>",
- trHtml = "";
- var surplusheight = pageheight - ($(".section_4 .violationheight").height()); //本页剩余高度
- var henght = 62.5; //表头62.5 一行高27.5
- var pagedaba = {
- 0: ""
- }, page = 0;
- var maxstu = {
- num: 0,
- username:""
- }
- var pagesheight = {
- 0:0
- }
- $.each(list.wjkm, function (idx, item) {
- goodTableHeadTr2Html += "<th>" + item.subjectname + "</th>";
- });
- $.each(list.wjfx, function (idx, item) {
- henght += 27.5;
- pagesheight[page] = 62.5+henght;
- if (page == 0 && (henght > surplusheight || surplusheight - henght < 27.5)) {
- // 加第一页
- page++
- henght = 0;
- pagedaba[page] = "";
- }
- if (henght > pageheight && surplusheight - henght < 27.5) {
- page++
- henght = 0;
- pagedaba[page] = "";
- console.log(page);
- }
- item.subjectjson = item.subjectjson ? JSON.parse(item.subjectjson) : [];
- var subject_num = {};
- pagedaba[page] += "<tr><td>" + item.username + "</td><td>" + item.loginname + "</td>";
- var num = 0;
- $.each(item.subjectjson, function (idx, item) {
- num += item.num;
- subject_num[item.subjectid] = item.num || 0;
- })
- if (num > maxstu.num) {
- maxstu = {
- num: num,
- username:item.username
- }
- } else if (num == maxstu.num){
- maxstu.username+='、'+item.username
- }
- $.each(list.wjkm,function (idx, item){
- pagedaba[page] += "<td>" + (subject_num[item.subjectid]|| 0) + "</td>";
- })
- });
- console.log(pagesheight);
- console.log(maxstu);
- var maxstuhtml = '<div class="echarts_result"><div>上图统计结果表示:</div><div class="echarts_result_content"><span class="dot bg_5699FF"></span>违纪行为最多的学生:'+maxstu.username +'</div></div>';
- for (var i = 0; i <= page; i++){
- table[i] = '<table border="1" class="my_table"><thead><tr class="goodTableHeadTr1">' +
- goodTableHeadTr1Html +
- '</tr><tr class="goodTableHeadTr2">' +
- goodTableHeadTr2Html +
- '</tr></thead><tbody class="goodTableTbody">' +
- pagedaba[i] +
- "</tbody></table>";
- if (i != 0) {
- //添加分页
- $(".page_"+ (i-1)+".section_4").after(
- '<div class="page_root section_4'+' page_'+i+'"></div>'
- );
- $(".page_root.section_4"+'.page_'+i).html(table[i]);
- }
- }
- $(".section_4 .stuViolationtable").html(table[0]);
- }
- var parameter = $(".section_4_html_root").data("page-params");
- parameter = JSON.parse(parameter);
- initviolationEcharts(parameter);
- console.log(parameter);
- });
|