123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- $(".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<classData.length;i++){
- if(classData[i]['selected']==1){
- selectedBoxHtml+="<li class='ellipsis active' classId='"+classData[i]['class_id']+"' artsScience='"+classData[i]['arts_science']+"' title='"+classData[i]['class_name']+"'>"+handleLongName(classData[i]['class_name'],10)+"</li>";
- }else{
- selectedBoxHtml+="<li class='ellipsis' classId='"+classData[i]['class_id']+"' artsScience='"+classData[i]['arts_science']+"' title='"+classData[i]['class_name']+"'>"+handleLongName(classData[i]['class_name'],10)+"</li>";
- }
- }
- $('#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+='<li value="'+$(el).attr('classId')+'">'+$(el).attr('title')+'<img src="/images/icon-delete.png" alt=""></li>';
- }
- });
- $('.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;
- }
- }
|