123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457 |
- $(document).ready(function(){
- var examGroupId=$('input[name=exam_group_id]').val();
- var page=1;
- $('#viewNoUploadPaperStudentAll').click(function(){
- page=1;
- loadStudent(examGroupId,page,0);
- });
- $('#studentType').change(function(){
- page=1;
- loadStudent(examGroupId,page,1);
- });
- $('#classes').change(function(){
- page=1;
- loadStudent(examGroupId,page,1);
- });
- $('.student_list_page')
- .on('click','.gotoPage',function(){
- page=parseInt($(this).html())
- loadStudent(examGroupId,page,1);
- })
- .on('click','.previous',function(){
- page=parseInt($(this).attr('pageNum'))
- loadStudent(examGroupId,page,1);
- })
- .on('click','.next',function(){
- page=parseInt($(this).attr('pageNum'))
- loadStudent(examGroupId,page,1);
- })
- $('.student-list')
- .on('click','.delStudent',function(){
- studentsIds=[];
- studentId=$(this).closest('tr').find('input').val();
- examId=$(this).attr('exam_id');
- studentsIds.push(studentId);
- obj=$(this).closest('tr');
- layer.msg('确定删除选中的学生吗?', {
- time: 0,
- btn: ['确定', '取消'],
- yes: function(index){
- layer.close(index);
- var data={
- "studentsIds":studentsIds,
- "examId":examId,
- "examGroupId":examGroupId,
- };
- jQuery.post(
- "/index.php/print/delExamStudent",data,function(data){
- var m =JSON.parse(data);
- if(m.status==1)
- {
- var icon = 6;
- layer.alert("删除成功", {icon: icon}, function(){
- obj.find('.status').html('缺考');
- obj.find('td:last').html('');
- layer.closeAll()
- });
- }else{
- var icon = 5;
- layer.alert("删除失败", {icon: icon}, function(){
- layer.closeAll()
- });
- }
- });
- }
- });
- })
- $('.delBatchStudent').click(function(){
- var studentsIds=[];
- layer.msg('确定删除选中的学生吗?', {
- time: 0,
- btn: ['确定', '取消'],
- yes: function(index){
- layer.close(index);
- if (!$("input[class='myselect']").is(':checked'))
- {
- layer.msg('请至少选择一个学生!');return false;
- }
- jQuery("input[class='myselect']").each(function()
- {
- if(jQuery(this).is(":checked") && typeof(jQuery(this).val())!= "undefined")
- {
- studentsIds.push(jQuery(this).val());
- }
- });
- var data={
- "studentsIds":studentsIds,
- "examGroupId":examGroupId,
- };
- jQuery.post(
- "/index.php/print/delExamStudent",data,function(data){
- var m =JSON.parse(data);
- if(m.status==1)
- {
- var icon = 6;
- layer.alert("删除成功", {icon: icon}, function(){
- loadStudent(examGroupId,page,1);
- layer.closeAll()
- });
- }else{
- var icon = 5;
- layer.alert("删除失败", {icon: icon}, function(){
- layer.closeAll()
- });
- }
- });
- }
- });
- return false;
- });
- $('.downLoadBatchStudent').click(function(){
- layer.msg('确定下载全部未上传学生吗?', {
- time: 0,
- btn: ['确定', '取消'],
- yes: function(index){
- layer.close(index);
- window.location.href="/index.php/print/downloadSelectStudent?examGroupId="+examGroupId
- }
- });
- return false;
- });
- $('.delAllStudent').click(function(){
- layer.msg('确定删除全部未上传学生吗?', {
- time: 0,
- btn: ['确定', '取消'],
- yes: function(index){
- layer.close(index);
- var data={
- "examGroupId":examGroupId,
- };
- jQuery.post(
- "/index.php/print/delAllNotUploadStudent",data,function(data){
- var m =JSON.parse(data);
- if(m.status==1)
- {
- var icon = 6;
- layer.alert("删除成功", {icon: icon}, function(){
- loadStudent(examGroupId,page,1);
- layer.closeAll()
- });
- }else{
- var icon = 5;
- layer.alert("删除失败", {icon: icon}, function(){
- layer.closeAll()
- });
- }
- });
- }
- });
- return false;
- });
- function loadStudent(examGroupId,page,select){
- var classId=$('#classes').val(),
- studentType=$('#studentType').val();
- if(select==0){
- classId=0;
- }
- $.ajax({
- url:'/index.php/print/ajaxLoadNoUploadStudent',
- type:'POST',
- dataType:'json',
- data:{exam_group_id:examGroupId,page:page,class_id:classId,is_del:studentType},
- success:function(res){
- if(res.status==1){
- var data=res.data,
- listHtml='',
- pageHtml='',
- classHtml='';
- if(select==0){
- classHtml+='<option value="0">全部</option>';
- $.each(data['classes'],function(index,value){
- classHtml+='<option value="'+index+'">'+value+'</option>';
- });
- $('#classes').html(classHtml);
- }
- if(data['list'].length>0){
- $.each(data['list'],function(index,value){
- listHtml+='<tr>';
- listHtml+='<td><input type="checkbox" value="'+value['student_id']+'" class="myselect" name="student[]"><input type="hidden" name="examId" class="examId" value="'+value['exam_id']+'"></td>';
- listHtml+='<td>'+(index+1+(page-1)*data['pageLimit'])+'</td>';
- listHtml+='<td class="studentName">'+value['student_name']+'</td>';
- listHtml+='<td class="studentCard">'+value['student_card']+'</td>';
- listHtml+='<td class="schoolStudentCard">'+value['school_student_card']+'</td>';
- listHtml+='<td class="className">'+value['class_name']+'</td>';
- listHtml+='<td class="status">'+value['status']+'</td>';
- if(value['status']=='未上传'){
- listHtml+='<td ><a href="#" exam_id="'+value['exam_id']+'" class="delStudent">删除</td>';
- }else{
- listHtml+='<td></td>';
- }
- listHtml+='</tr>';
- });
- }else{
- listHtml+='<tr>';
- listHtml+='<td colspan="8">暂无数据</td>';
- listHtml+='</tr>';
- }
- //分页
- if(data['totalPage']>1){
- pageHtml+='<ul class="yiiPager">';
- var startPage=page-2;
- var endPage=page+2;
- if(startPage<1){
- startPage=1;
- }
- if(endPage>data['totalPage']){
- endPage=data['totalPage']
- }
- if(page>1){
- pageHtml+='<li class="previous" pageNum="'+(page-1)+'"><a href="#" >上一页</a></li>';
- }
- for(var i=startPage;i<=endPage;i++){
- if(page==i){
- pageHtml+='<li class="page selected"><a href="#" >'+i+'</a></li>';
- }else{
- pageHtml+='<li class="page"><a href="#" class="gotoPage">'+i+'</a></li>';
- }
- }
- if(page<data['totalPage']){
- pageHtml+='<li class="next" pageNum="'+(page+1)+'"><a href="#" >下一页</a></li>';
- }
- pageHtml+='<li >共:'+data['total']+'条</li>';
- pageHtml+='</ul>';
- }
- $('.student_list_page').html(pageHtml);
- $('.student-list').find('tbody').html(listHtml)
- $('#fieldModalStudent').show();
- $(".selectAll").prop("checked",false);
- }
- }
- });
- }
- $('.student-list-close').click(function(){
- $("#classes").find("option:contains('0')").attr("selected",true);
- $('#fieldModalStudent').hide();
- });
- // 全选\反选
- $(".selectAll").on('click',function(event){
- if ($(this).prop("checked")) {
- var s_obj = $(".myselect");
- var s_len = s_obj.length;
- for (var i=0;i<s_len;i++) {
- if (!s_obj[i].disabled) {
- s_obj[i].checked=true;
- }
- }
- } else {
- $(".myselect").prop("checked",false);
- }
- });
- $('#transfer').click(function(){
- $.ajax({
- url:'/index.php/print/getUploadedStudent',
- type:'POST',
- dataType:'json',
- data:{examGroupId:examGroupId},
- success:function(res){
- if(res.success==1){
- if(res.data.uploaded.length>0){
- uploaded=res.data.uploaded;
- html='';
- for(var i=0;i<uploaded.length;i++){
- html+='<option value="'+uploaded[i]['student_id']+'">'+uploaded[i]['student_name']+' '+uploaded[i]['student_card']+'</option>';
- }
- $('#uploadedStudent').html(html);
- $('#uploadedStudent').select2();
- }
- if(res.data.noUploaded.length>0){
- noUploaded=res.data.noUploaded;
- html='';
- for(var i=0;i<noUploaded.length;i++){
- html+='<option value="'+noUploaded[i]['student_id']+'">'+noUploaded[i]['student_name']+' '+noUploaded[i]['student_card']+'</option>';
- }
- $('#noUploadedStudent').html(html);
- $('#noUploadedStudent').select2();
- }
- }else{
- if(res.message!=undefined){
- layer.msg(res.message);
- }else{
- layer.msg('加载考试学生数据失败');
- }
- }
- }
- })
- $('#transferWindow').show();
- });
- $('.transfer-close,.transfer-cancel-btn').click(function(){
- $('#transferWindow').hide();
- });
- $('.transferSubmit').click(function(){
- var uploadStudent=$('#uploadedStudent').val(),
- noUploadStudent=$('#noUploadedStudent').val();
- layer.msg('成绩转移中,请稍候。。。。。。',{time:0});
- $.ajax({
- url:'/index.php/print/ajaxTransferStudentRs',
- type:'POST',
- dataType:'json',
- data:{examGroupId:examGroupId,uploadStudentId:uploadStudent,noUploadStudentId:noUploadStudent},
- success:function(res){
- if(res.success==1){
- layer.msg('转移成功',{
- icon: 1
- }, function(){
- layer.closeAll();
- $('#transferWindow').hide();
- });
- }else{
- if(res.message!=undefined){
- layer.msg(res.message);
- }else{
- layer.msg('转移失败');
- }
- }
- }
- });
- });
- //删除未上传班级学生
- $('.delClassStudent').click(function(){
- //加载班级
- examGroupId=$('input[name=exam_group_id]').val();
- $.ajax({
- url:'/index.php/print/loadExamClass',
- type:'POST',
- dataType:'json',
- data:{examGroupId:examGroupId},
- success:function (res) {
- if(res.status==1){
- if(res.uploaded.length>0){
- html=' <input type="checkbox" class="select_upload_class" value="">全选';
- $.each(res.uploaded,function(i,n){
- html += "<span class='show_classes'><input type='checkbox' class='uploaded student_paper_class' name='paper_class[]' value='"+n.exam_id+"'>" + n.class_name + " </span>";
- });
- $('.show_uploaded').html(html);
- }else{
- $('.show_uploaded').html('无');
- }
- if(res.no_uploaded.length>0){
- html2=' <input type="checkbox" class="select_noupload_class" value="">全选';
- $.each(res.no_uploaded,function(i,n){
- html2 += "<span class='show_classes'><input type='checkbox' class='no_uploaded student_paper_class' name='paper_class[]' value='"+n.exam_id+"'>" + n.class_name + " </span>";
- });
- $('.show_nouploaded').html(html2);
- }else{
- $('.show_nouploaded').html('无');
- }
- layer.open({
- type: 1,
- title: '删除未上传',
- btn: ['确定', '取消'],
- area: ['420px', '340px'], //宽高
- btnAlign: 'c',
- content: $('#studentUploadClass'),
- yes: function (index, layero) {
- var examIds=[];
- $(".student_paper_class").each(function(m,n){
- if ($(this).prop('checked')) {
- examIds.push($(this).val())
- }
- });
- if (examIds.length==0) {
- layer.msg('请至少选择一个班级!');return false;
- }
- layer.msg('确定删除选中班级内未上传的学生吗?', {
- time: 0,
- btn: ['确定', '取消'],
- yes: function(index){
- indexNo=layer.msg('正在删除,请稍候......',{time:0})
- //提交
- $.ajax({
- type: 'post',
- url: "/index.php/print/delStudentPaperRelation",
- data: {'examIds': examIds},
- dataType: 'json',
- success: function (data) {
- layer.close(indexNo)
- if (data.status) {
- var icon = 6;
- layer.alert("删除成功", {icon: icon}, function(){
- loadStudent(examGroupId,page,1);
- layer.closeAll()
- });
- } else {
- var icon = 5;
- layer.alert("删除失败", {icon: icon}, function(){
- layer.closeAll()
- });
- }
- }
- })
- }
- });
- }
- });
- }
- }
- });
- return false;
- });
- // 全选\反选
- $('#studentUploadClass')
- .on('click','.select_upload_class',function(){
- if ($(this).prop("checked")) {
- $(".uploaded").prop("checked",true);
- } else {
- $(".uploaded").prop("checked",false);
- }
- })
- .on('click','.select_noupload_class',function(){
- if ($(this).prop("checked")) {
- $(".no_uploaded").prop("checked",true);
- } else {
- $(".no_uploaded").prop("checked",false);
- }
- })
- })
|