Blame view

WebRoot/static/js/teach_paper.js 7.83 KB
ddbc622f   孙向锦   0829版本
1
2
3
4
5
6
  		var class_html="",
  			option_html="";
  		var user_id= "",
  			subject_id="",
  			class_id="";
  		$(document).ready(function(){
ff7ab13e   孙向锦   修复一些小bug
7
  			
ddbc622f   孙向锦   0829版本
8
9
  			timeList();
  			$.ajax({
eef2f078   孙向锦   修改域名问题
10
  				url:url+"/teacher/info",
ddbc622f   孙向锦   0829版本
11
12
13
14
  				async:false,
  				type:"post",
  				success:function(data){
  					console.log(data);
8a43805a   孙向锦   修改bug
15
16
17
  					if(typeof(data.data.subjectList) != 'undefind' && data.data.subjectList.length > 0){
  						subject_id=data.data.subjectList[0].SUBJECT_ID;
  					}
ddbc622f   孙向锦   0829版本
18
19
20
21
22
23
24
25
26
27
28
  					user_id=data.data.ID;
  
  					if(data.data.classInfoList.length>0){
  						for(var i=0;i<data.data.classInfoList.length;i++){
  							class_html += '<li data-classId="'+data.data.classInfoList[i].CLASS_ID+'">'+data.data.classInfoList[i].CLASS_NAME+'</li>';
  							option_html += '<option value="'+data.data.classInfoList[i].CLASS_ID+'">'+data.data.classInfoList[i].CLASS_NAME+'</option>'
  						}
  						$(".classList").html(class_html+'<div class="clearfix"></div>');
  						$(".classList li").eq(0).addClass("active");
  						$("#dealer_id_2").html(option_html);
  					}
ff7ab13e   孙向锦   修复一些小bug
29
  					getList();
bda221f4   孙向锦   0830版本
30
31
  				},
  				error: function (XMLHttpRequest, textStatus, errorThrown) {
fd0087a8   孙向锦   添加英语语言
32
33
  				// wrong massage   
  				alert("Status code:"+XMLHttpRequest.status+"Status"+XMLHttpRequest.readyState+"wrong massage:"+textStatus+"");
bda221f4   孙向锦   0830版本
34
  				window.top.loading.remove();
f19da108   孙向锦   添加英语对应的修改
35
  				$(".table_box").css("margin-top",$(".head_box").height() - 143);
ddbc622f   孙向锦   0829版本
36
37
38
  				}
  			})
  
fd0087a8   孙向锦   添加英语语言
39
  			
ddbc622f   孙向锦   0829版本
40
41
42
43
44
45
  			window.top.loading.remove();
  		})
  		
  		function getList(start_date,end_date,class_id){       //获取试卷列表
  			var tab_html="";
  			$.ajax({
eef2f078   孙向锦   修改域名问题
46
  				url:url+"/api/v1/paper",
ddbc622f   孙向锦   0829版本
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
  				async:false,
  				type:"post",
  				data:{
  					paper_type:"101",
  					user_id:user_id,
  					subject_id:subject_id,
  					class_id:class_id,
  					currentpage:"1",
  					showcount:"",
  					start_date:start_date,
  					end_date:end_date
  				},
  				success:function(data){
  					console.log(data);
  					for(var i=0;i<data.data.length;i++){
a0eff87f   孙向锦   修改课后练bug
62
  						tab_html += '<tr data-id="'+data.data[i].PAPER_ID+'" data-classid="'+data.data[i].CLASS_ID+'"><td><input type="checkbox" name="ids" id="ids" value="'+data.data[i].PAPER_ID+'"/>'+(i+1)+'</td><td>'+data.data[i].TITLE+'</td><td>'+getClassName(data.data[i].CLASS_ID)+'</td><td>'+getSubjectName(data.data[i].SUBJECT_ID)+'</td><td>'+data.data[i].EXAM_TIME+'分钟</td><td>'+data.data[i].CREATE_DATE+'</td><td><a onclick="jump($(this))">查看</a></td><td><a href="#" onclick="del($(this));"><img src="../static/images/remove.png" /></a></td></tr>';
ddbc622f   孙向锦   0829版本
63
64
65
  					}
  					$("#tab_body").html(tab_html);
  					window.top.loading.remove();
bda221f4   孙向锦   0830版本
66
67
  				},
  				error: function (XMLHttpRequest, textStatus, errorThrown) {
fd0087a8   孙向锦   添加英语语言
68
69
  				// wrong massage   
  				alert("Status code:"+XMLHttpRequest.status+"Status"+XMLHttpRequest.readyState+"wrong massage:"+textStatus+"");
bda221f4   孙向锦   0830版本
70
71
  				window.top.loading.remove();
  			}
ddbc622f   孙向锦   0829版本
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
  			});
  		}
  		$('#ids').on('click', function(){
  				var th_checked = $("#ids").prop('checked');//checkbox inside "TH" table header
  				
  				$(".table_box .table").find('tbody > tr').each(function(){
  					var row = this;
  					if(th_checked) $(row).find('input[type=checkbox]').eq(0).prop('checked', true);
  					else $(row).find('input[type=checkbox]').eq(0).prop('checked', false);
  				});
  		});
  		function jump(obj){          //预览试卷
  			window.top.loading.show();
  			var id=obj.closest("tr").attr("data-id");
  			var classid=obj.closest("tr").attr("data-classid");
  			location.href="paper_view2.do?PAPER_ID="+id+"&classID="+classid+"&userid="+user_id;
  		}
  		$(".classList").on("click","li",function(){
  			$(this).siblings().removeClass("active");
  			$(this).addClass("active");
  			
  		});
  		$("#creatPaper").click(function(){   //新建试卷
  			$('#myModal').modal('show');
  		});
  		function setQUestion(){             //新建试卷-选择班级
  			if($(".classList .active").length>0){
  				class_id=$(".classList .active").attr("data-classid");
  				location.href="set_question.do?subject_id="+subject_id+"&class_id="+class_id+"&user_id="+user_id;
  			}else{
fd0087a8   孙向锦   添加英语语言
102
  				alert("Please select class first");
ddbc622f   孙向锦   0829版本
103
104
105
106
107
108
109
110
  			}
  			window.top.loading.show();
  				console.log($(".classList .active").length);
  			//location.href="";
  		}
  		function getSubjectName(id){           //获取科目中文名
  			var subjectName="";
  			$.ajax({
eef2f078   孙向锦   修改域名问题
111
  				url:url+"/api/v1/subjectcname",
ddbc622f   孙向锦   0829版本
112
113
114
115
116
  				async:false,
  				type:"post",
  				data:{id:id},
  				success:function(data){
  					subjectName=data.data;
bda221f4   孙向锦   0830版本
117
118
  				},
  				error: function (XMLHttpRequest, textStatus, errorThrown) {
fd0087a8   孙向锦   添加英语语言
119
120
  				// wrong massage   
  				alert("Status code:"+XMLHttpRequest.status+"Status"+XMLHttpRequest.readyState+"wrong massage:"+textStatus+"");
bda221f4   孙向锦   0830版本
121
122
  				window.top.loading.remove();
  			}
ddbc622f   孙向锦   0829版本
123
124
125
126
127
128
  			})
  			return subjectName;
  		}
  		function getClassName(id){        //获取班级中文名
  			var className="";
  			$.ajax({
eef2f078   孙向锦   修改域名问题
129
  				url:url+"/api/v1/classname",
ddbc622f   孙向锦   0829版本
130
131
132
133
134
  				async:false,
  				type:"post",
  				data:{id:id},
  				success:function(data){
  					className=data.data;
bda221f4   孙向锦   0830版本
135
136
  				},
  				error: function (XMLHttpRequest, textStatus, errorThrown) {
fd0087a8   孙向锦   添加英语语言
137
138
  				// wrong massage   
  				alert("Status code:"+XMLHttpRequest.status+"Status:"+XMLHttpRequest.readyState+"wrong massage:"+textStatus+"");
bda221f4   孙向锦   0830版本
139
140
  				window.top.loading.remove();
  			}
ddbc622f   孙向锦   0829版本
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
  			})
  			return className;
  		}
  		function getday(month){         //获取日期
  			var time=[];
  			var  d= new Date();
  			 d.setMonth(month-1);
  			 d.setDate(1);
  			 var day=d.getDate();
  			 var month=d.getMonth()+1;
  			 if((d.getMonth()+1)<10){
  				 var month="0"+(d.getMonth()+1);
  			 }
  			 var year=d.getFullYear();
  			 var startTime=year+"-"+month+"-"+day;
  			 d.setMonth(month);
  			 var end_day=d.getDate();
  			 var end_month=d.getMonth()+1;
  			 if((d.getMonth()+1)<10){
  				 var end_month="0"+(d.getMonth()+1);
  			 }
  			 var end_year=d.getFullYear();
  			 var endTime=end_year+"-"+end_month+"-"+end_day;
  			 time[0]=startTime;
  			 time[1]=endTime;
  			 return time;
  		}
  		function timeList(){          //渲染时间列表
  			var time = new Date();
  			var now_month=time.getMonth()+1;
  			time.setMonth(now_month-1)
  			if(time.getMonth()!= 0 ){
  				var preceding_month = time.getMonth();
  			}else
  				var preceding_month = 12;
  			time.setMonth(now_month-2)
  			if(time.getMonth()!= 0 ){
  				var last_month = time.getMonth();
  			}else
  				var last_month = 12;
  			var option_html="";
  			option_html += '<option value="'+now_month+'">'+now_month+'月</option><option value="'+preceding_month+'">'+preceding_month+'月</option><option value="'+last_month+'">'+last_month+'月</option>';
  			$("#dealer_id_1").html(option_html);
  		}
  		function tosearch(){        //搜索
  			//var timeBox=getday($("#dealer_id_1").val());
  			var start_date=$("#lastStart").val();
  			var end_date=$("#lastEnd").val();
  			var class_id=$("#dealer_id_2").val();
  			getList(start_date,end_date,class_id);
  		}
  
  		function del(obj){       //删除
  			//var remove = new remove();
  			var id=obj.closest("tr").attr("data-id");
fd0087a8   孙向锦   添加英语语言
196
  			window.top.remove.init({"title":"Delete","func":function(success){
ddbc622f   孙向锦   0829版本
197
  				if(success){
eef2f078   孙向锦   修改域名问题
198
  					var url1 = url+ "/paper/delete.do?PAPER_ID="+id+"&tm="+new Date().getTime();
ddbc622f   孙向锦   0829版本
199
  					window.top.loading.show();
eef2f078   孙向锦   修改域名问题
200
  					$.get(url1,function(data){
ddbc622f   孙向锦   0829版本
201
202
203
204
205
206
207
208
209
210
  						tosearch();
  					});
  				}
  				else{
  					console.log("false");
  				}
  			}});
  			window.top.remove.show();
  		}
  		function deleteAll(){       //批量删除
fd0087a8   孙向锦   添加英语语言
211
  			window.top.remove.init({"title":"Delete","func":function(success){
ddbc622f   孙向锦   0829版本
212
213
214
215
216
217
218
219
220
221
222
223
224
  				if(success){
  					var str = '';
  					for(var i=0;i < document.getElementsByName('ids').length;i++){
  					  if(document.getElementsByName('ids')[i].checked){
  					  	if(str=='') str += document.getElementsByName('ids')[i].value;
  					  	else str += ',' + document.getElementsByName('ids')[i].value;
  					  }
  					}
  					if(str==''){
  						
  					}else{
  						$.ajax({
  								type: "POST",
eef2f078   孙向锦   修改域名问题
225
  								url:url+ '/paper/deleteAll.do?tm='+new Date().getTime(),
ddbc622f   孙向锦   0829版本
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
  						    	data: {DATA_IDS:str},
  								dataType:'json',
  								//beforeSend: validateData,
  								cache: false,
  								success: function(data){
  									 $.each(data.list, function(i, list){
  											tosearch();
  									 });
  								}
  							});
  					}
  				}
  				else{
  					console.log("false");
  				}
  			}});
  			window.top.remove.show();
  		}