$(".select-class").click(function () { teacherId=$('input[name=teacherId]').val(); grade=$('.select-grade').val(); gradetext=$('.select-grade option:selected').text(); if(teacherId==0){ layer.msg('请选择阅卷员'); return false; } if(grade==0){ layer.msg('请选择年级'); return false; } //已选择班级 selectClassData=[]; selectClassEle=$(".selected-box").find('li'); if(selectClassEle.length>0){ selectClassEle.each(function(index,ele){ selectClassData.push($(ele).attr('value')) }) } $('#global_check_all').prop('checked',false); $('#global_check_arts').prop('checked',false); $('#global_check_science').prop('checked',false); layer.msg('正在加载班级,请稍候......',{time:0}); $.ajax({ url:'/index.php/third/ajaxGetClassByTeacherGrade', type:'POST', dataType:'json', data:{teacherId:teacherId,grade:grade,selectClassData:selectClassData}, success:function(res){ layer.closeAll(); if(res.status==1){ var selectedBoxHtml=''; classData=res.data; for(var i=0;i"+handleLongName(classData[i]['class_name'],10)+""; }else{ selectedBoxHtml+="
  • "+handleLongName(classData[i]['class_name'],10)+"
  • "; } } $('#gradeTxt').html(gradetext); $('.area_1').html(selectedBoxHtml); $('#fieldModal').show(); } } }); return false; }); // 切换年级 $('.select-grade').change(function(){ $('.selected-box').html(''); grade=$(this).val(); isthird=$(this).attr('isthird'); if(isthird==0){ if(grade!=3){ if(subjects[grade]!=undefined){ $('input[name=subjectId]').val(subjects[grade]['subject_id']); $('input[name=textbookId]').val(subjects[grade]['textbook_id']); $('.show_text_book').html(subjects[grade]['subject_name']+' 教材版本'+subjects[grade]['text_book_name']); } }else{ if(subjects[3]!=undefined){ $('input[name=subjectId]').val(subjects[3]['subject_id']); $('input[name=textbookId]').val(subjects[3]['textbook_id']); $('.show_text_book').html(subjects[3]['subject_name']+' 教材版本'+subjects[3]['text_book_name']); }else{ $('.show_text_book').html(' 高三通用'); $('input[name=subjectId]').val(6); $('input[name=textbookId]').val(28); } } } }); $('.add-class-close,.cancel-btn').click(function () { $('#fieldModal').hide(); }); $('.area_1') .on('click','li',function(){ if($(this).hasClass('active')){ $(this).removeClass('active'); }else{ $(this).addClass('active'); } }) $('#global_check_all').change(function(){ var hasChecked = $(this).prop('checked'); if(!hasChecked){ $('#global_check_arts').prop('checked',false); $('#global_check_science').prop('checked',false); } var allChecks = $('#class_area').find('li'); allChecks.each(function (index,el) { if(hasChecked){ if($(el).hasClass('active'))return; $(el).addClass('active'); }else{ if($(el).hasClass('active')){ $(el).removeClass('active') } } }); }); $('#global_check_arts').change(function(){ var hasChecked = $(this).prop('checked'); var allChecks = $('#class_area').find('li'); if(!hasChecked){ $('#global_check_all').prop('checked',false); } allChecks.each(function (index,el) { if(hasChecked){ if($(el).attr('artsScience')=="1" && !$(el).hasClass('active')){ $(el).addClass('active'); } }else{ if($(el).attr('artsScience')=="1" && $(el).hasClass('active')){ $(el).removeClass('active'); } } }); }); $('#global_check_science').change(function(){ var hasChecked = $(this).prop('checked'); if(!hasChecked){ $('#global_check_all').prop('checked',false); } var allChecks = $('#class_area').find('li'); allChecks.each(function (index,el) { if(hasChecked){ if($(el).attr('artsScience')=="2" && !$(el).hasClass('active')){ $(el).addClass('active'); } }else{ $('#global_check_all').prop('checked',false); if($(el).attr('artsScience')=="2" && $(el).hasClass('active')){ $(el).removeClass('active'); } } }); }); //确定选择班级 $('.setting_sumbit').click(function(){ var allChecks = $('#class_area').find('li'); var selectedBoxHtml=''; allChecks.each(function (index,el) { if($(el).hasClass('active')){ selectedBoxHtml+='
  • '+$(el).attr('title')+'
  • '; } }); $('.selected-box').html(selectedBoxHtml); $('#fieldModal').hide(); }); $(".selected-box").on("click", "li", function() { $(this).remove(); }) function handleLongName(str,length) { var str_len = str.length; if(str_len > length){ return str.substring(0,length) + '...'; }else { return str; } }