$(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+='';
$.each(data['classes'],function(index,value){
classHtml+='';
});
$('#classes').html(classHtml);
}
if(data['list'].length>0){
$.each(data['list'],function(index,value){
listHtml+='
';
listHtml+=' | ';
listHtml+=''+(index+1+(page-1)*data['pageLimit'])+' | ';
listHtml+=''+value['student_name']+' | ';
listHtml+=''+value['student_card']+' | ';
listHtml+=''+value['school_student_card']+' | ';
listHtml+=''+value['class_name']+' | ';
listHtml+=''+value['status']+' | ';
if(value['status']=='未上传'){
listHtml+='删除 | ';
}else{
listHtml+=' | ';
}
listHtml+='
';
});
}else{
listHtml+='';
listHtml+='暂无数据 | ';
listHtml+='
';
}
//分页
if(data['totalPage']>1){
pageHtml+='';
}
$('.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;i0){
uploaded=res.data.uploaded;
html='';
for(var i=0;i'+uploaded[i]['student_name']+' '+uploaded[i]['student_card']+'';
}
$('#uploadedStudent').html(html);
$('#uploadedStudent').select2();
}
if(res.data.noUploaded.length>0){
noUploaded=res.data.noUploaded;
html='';
for(var i=0;i'+noUploaded[i]['student_name']+' '+noUploaded[i]['student_card']+'';
}
$('#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=' 全选';
$.each(res.uploaded,function(i,n){
html += "" + n.class_name + " ";
});
$('.show_uploaded').html(html);
}else{
$('.show_uploaded').html('无');
}
if(res.no_uploaded.length>0){
html2=' 全选';
$.each(res.no_uploaded,function(i,n){
html2 += "" + n.class_name + " ";
});
$('.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);
}
})
})