Blame view

WebRoot/static/js/control1.js 6.51 KB
4d39642d   孙向锦   添加学生报表
1
2
3
4
5
6
7
8
9
10
11
  
  	var data0=[],data1=[],data2=[],data3=[];
  	var startDate,endDate;
  	var studentid;
  	var data_temp,_index=0;
  	function getQueryString(name) {
  		  var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
  		  var r = window.location.search.substr(1).match(reg);
  		  if (r != null) return unescape(r[2]); return null;
  	  	}
  	function getData(startDate,endDate){
066f7673   孙向锦   修复bug
12
13
14
15
  		var attend = "" ;
  		if(startDate != null && endDate != null){
  			attend = "&start_Date="+startDate+"&end_Date="+endDate;
  		}
4d39642d   孙向锦   添加学生报表
16
  		$.ajax({
066f7673   孙向锦   修复bug
17
  			url:URL+ attend,
4d39642d   孙向锦   添加学生报表
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
  			type:"get",
  			async:false,
  			dataType:"json",
  			success:function(data){
  				data_temp=data;
  				console.log(data);
  				var _html='';
  				for(var i=0;i<data.data.studentList.length;i++){
  					_html+='<li><p>'+data.data.studentList[i].NAME+'</p></li>';
  					if(studentid==data.data.studentList[i].ID)
  						_index=i;
  				}
  				$(".content_l ul").html(_html);
  				console.log(_index);
  				
  			}
  			
  		});
  		data(_index,data_temp);
  		$(".content_l li").eq(_index).siblings().removeClass("on");
  		$(".content_l li").eq(_index).addClass("on");
  	}		
  	$( document ).ready(function() {
  		//alert($("input[type=radio][checked]").val());
  		
  		studentid=getQueryString("studentid");
  		
  		getData();
  		
  		
  		//$('#myStathalf').circliful();
  		//$('#myStathalf1').circliful();
  		$(document).on("click",".content_l li",function(){
  		 $(this).siblings().removeClass("on");
  			$(this).addClass("on");
  			_index=$(this).index();
  			data(_index,data_temp);
  			studentid = 0;
  		 })
  		 $("input[type=radio]").change(function(){
  			//alert($("input[type='radio']:checked").val());
  			data(_index,data_temp);
  		})
  		
  		$("#search").click(function(){
8942b440   孙向锦   提交code
63
64
65
66
67
68
  //			var date_string=$("#test6").val();
  //			var date_arry=date_string.split(' - ');
  //			startDate=date_arry[0];
  //			endDate=date_arry[1];
  			startDate = $("#starDate").val();
  			endDate = $("#endDate").val();
4d39642d   孙向锦   添加学生报表
69
70
  			getData(startDate,endDate);
  		})
a7c57a42   孙向锦   成绩添加上一个下一个学生功能
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
  		
  		$(".prev").click(function(){
  			 _index-=1;
  			 if(_index<0){
  				 _index=data_temp.data.studentList.length-1;
  			 }
  			$(".content_l li").eq(_index).siblings().removeClass("on");
  			$(".content_l li").eq(_index).addClass("on");
  			 data(_index,data_temp);
  		 })
  		 $(".next").click(function(){
  			 _index+=1;
  			 if(_index>(data_temp.data.studentList.length-1)){
  				 _index=0;
  			 }
  			$(".content_l li").eq(_index).siblings().removeClass("on");
  			$(".content_l li").eq(_index).addClass("on");
  			 data(_index,data_temp);
  		 })
4d39642d   孙向锦   添加学生报表
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
      });
  	
  	
  	function data(index,data){
  	console.log(data);
  		var GETSCORE = parseInt(data.data.studentList[index].GETSCORE);
  		var TOTALSCORE = parseInt(data.data.TOTAL_SCORE);
  		var ratio=(GETSCORE/TOTALSCORE*100).toFixed(2);
  		var class_avg= (parseInt(data.data.AVG_SCORE)/ parseInt(data.data.TOTAL_SCORE)*100).toFixed(2);
  		var class_max=(parseInt(data.data.MAX_SCORE)/ parseInt(data.data.TOTAL_SCORE)*100).toFixed(2);
  		
  		var test_num=data.data.studentList[index].testList.length;
  		var part_num=test_num;
  		//console.log(data.data.studentList[index].testList[2].SCORE);
  		if($("input[type='radio']:checked").val()==1){
  			for(var i=0;i<test_num;i++){
  			if(data.data.studentList[index].testList[i].TOTAL_SCORE>0){
  				data0[i]=data.data.studentList[index].testList[i].NAME;
  				data1[i]=(data.data.studentList[index].testList[i].AVG_SCORE/data.data.studentList[index].testList[i].TOTAL_SCORE*100).toFixed(2);
  				data2[i]=(data.data.studentList[index].testList[i].SCORE/data.data.studentList[index].testList[i].TOTAL_SCORE*100).toFixed(2);
  				data3[i]=(data.data.studentList[index].testList[i].MAX_SCORE/data.data.studentList[index].testList[i].TOTAL_SCORE*100).toFixed(2);
  			}else{
  				data1[i]=0;
  				data2[i]=0;
  				data3[i]=0;
  			}
  			
  			if(data.data.studentList[index].testList[i].SCORE=="0")
  				part_num--;
  			}
  		}else if($("input[type='radio']:checked").val()==2){
  			for(var i=0;i<test_num;i++){
  			data0[i]=data.data.studentList[index].testList[i].NAME;
  			data1[i]=data.data.studentList[index].testList[i].AVG_SCORE;
  			data2[i]=data.data.studentList[index].testList[i].SCORE;
  			data3[i]=data.data.studentList[index].testList[i].MAX_SCORE;
  			if(data.data.studentList[index].testList[i].SCORE=="0")
  				part_num--;
  			}
  		}
  		
  		console.log(data0);
  		console.log(data1);
  		console.log(data2);
  		console.log(data2);
  		var partake=(part_num/test_num*100).toFixed(2);
  		
  		
  		$("#class_avg").html(class_avg);
  		$("#class_max").html(class_max);
  		$(".name h1").html(data.data.studentList[index].NAME);
  		$(".circle .col-md-6").eq(1).html('<div id="myStathalf1" data-dimension="350" data-text="'+ratio+"%"+'" data-info="个人平均得分率" data-width="10" data-fontsize="38" data-percent="'+ratio+'" data-fgcolor="#8ad254" data-bgcolor="#a9f9ff" data-type="half" data-fill="#50b5c9"></div>');
  		$(".circle .col-md-6").eq(0).html('<div id="myStathalf" data-dimension="350" data-text="'+part_num+'/'+test_num+'" data-info="参与测试" data-width="10" data-fontsize="38" data-percent="'+partake+'" data-fgcolor="#8ad254" data-bgcolor="#a9f9ff" data-type="half" data-fill="#50b5c9"></div>');
  		$('#myStathalf1').circliful();
  		$('#myStathalf').circliful();
  		 myChart.setOption(option);
  	}
  	 
  	 
  	var myChart = echarts.init(document.getElementById('main'));
  	var option = {
      xAxis: {
          type: 'category',
          data: data0
      },
      yAxis: {
          type: 'value'
      },
      series: [{
          data: data1,
          type: 'line',
          symbol: 'circle',
3371dbc6   孙向锦   0720 版本
162
          symbolSize: 5,
4d39642d   孙向锦   添加学生报表
163
164
165
          lineStyle: {
              normal: {
                  color: 'green',
3371dbc6   孙向锦   0720 版本
166
167
                  width: 2,
                  type: 'dashed'
4d39642d   孙向锦   添加学生报表
168
169
170
171
              }
          },
          itemStyle: {
              normal: {
3371dbc6   孙向锦   0720 版本
172
                  borderWidth: 2,
4d39642d   孙向锦   添加学生报表
173
174
175
176
177
                  borderColor: 'green',
                  color: 'green'
              }
          }
      },{
3371dbc6   孙向锦   0720 版本
178
          data: data3,
4d39642d   孙向锦   添加学生报表
179
180
          type: 'line',
          symbol: 'circle',
3371dbc6   孙向锦   0720 版本
181
          symbolSize: 5,
4d39642d   孙向锦   添加学生报表
182
183
          lineStyle: {
              normal: {
3371dbc6   孙向锦   0720 版本
184
185
186
                  color: 'yellow',
                  width: 2,
                  type: 'dashed',
4d39642d   孙向锦   添加学生报表
187
188
189
190
              }
          },
          itemStyle: {
              normal: {
3371dbc6   孙向锦   0720 版本
191
192
193
                  borderWidth: 2,
                  borderColor: 'yellow',
                  color: 'yellow'
4d39642d   孙向锦   添加学生报表
194
195
196
              }
          }
      },{
3371dbc6   孙向锦   0720 版本
197
          data: data2,
4d39642d   孙向锦   添加学生报表
198
199
200
201
202
          type: 'line',
          symbol: 'circle',
          symbolSize: 10,
          lineStyle: {
              normal: {
3371dbc6   孙向锦   0720 版本
203
                  color: 'blue',
4d39642d   孙向锦   添加学生报表
204
                  width: 4,
3371dbc6   孙向锦   0720 版本
205
                  type: 'solid'
4d39642d   孙向锦   添加学生报表
206
207
208
209
210
              }
          },
          itemStyle: {
              normal: {
                  borderWidth: 3,
3371dbc6   孙向锦   0720 版本
211
212
213
                  borderColor: 'blue',
                  color: 'blue',
                  label : {show: true}
4d39642d   孙向锦   添加学生报表
214
215
216
217
              }
          }
      }]
  };