123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388 |
- <link type="text/css" rel="stylesheet" href="/css/needDetail.css" />
- <style>
- dl.subject_list{clear: both;display: block;margin-top:5px;border:1px solid #ccc;padding:10px;height:50px;}
- dl.subject_list dd{float:left;margin:5px;}
- /*修改样式开始*/
- .form-item_name{
- line-height: 28px;
- }
- .form-item-input_name{
- text-indent: 26px;
- }
- .name-tips{
- position: relative;
- left: 18px;
- bottom: 2px;
- }
- .test-type-ties{
- /*display: inline-block;
- margin: 0 12px;*/
- color: red;
- }
- .icon-test-type-ties{
- margin: 0 12px;
- margin-top: -3px;
- vertical-align: middle;
- }
- .form-item-con{
- color: #333;
- }
- .class-tips{
- vertical-align: middle;
- margin: 0 4px;
- }
- .class-box{
- width: 500px;
- }
- .class-box>p{
- margin-bottom: 10px;
- }
- .class-box>ul{
- width: 500px;
- height: 200px;
- padding: 10px 20px;
- background-color: #FAFAFA;
- box-sizing: border-box;
- border:1px solid #ddd;
- overflow: auto;
- }
- .class-box>ul>li{
- float: left;
- margin-right: 15px;
- margin-bottom: 10px;
- cursor: pointer;
- }
- .class-box>ul>li>img{
- vertical-align: middle;
- margin-left: 3px;
- }
- .icon-change{
- margin: 0 37px;
- margin-top: 110px;
- }
- .red-tips{
- color: red;
- }
- button.save {
- height: 40px;
- }
- .selected-box li{
- color:#0e8e54;
- }
- .title_msg{
- padding-top:30px;
- padding-left:20px
- }
- </style>
- <div class="main-content-inner">
- <!-- 导航栏开始-->
- <?php include(Yii::app()->basePath.'/views/layouts/class_navigation.php');?>
- <!-- 导航栏结束-->
- <div class="layout-gap">
- <section class="anc-top flex status_1" >
- <div class="flex-one flex">
- <p class="anc-title">转班</p>
- <p class="title_msg">从其他学期或年级的教学班选择学生,添加到当前教学班</p>
- </div>
- <div class="anc-opt-btn green-font pointer reback" ><a href="<?php echo $this->createUrl('classes/index');?>?class_type=2">返回</a></div>
- </section>
- <section class="anc-main-con">
- <div class="pointer ">当前班级信息</div>
- <span>年级:<?php echo $gradeName?>丨教学班名称:<?php echo $cname?>丨学科:<?php echo implode('、',$subjects)?> </span>
- </section>
- <div class="handle-detail-main-excel">
- <p>
- <select name="semester_id" id="semesterId">
- <option value="0">选择学期</option>
- <?php
- if($semester){
- foreach ($semester as $val){
- echo '<option value="'.$val['semester_id'].'">'.$val['semester_name'].'</option>';
- }
- }
- ?>
- </select>
- <select name="subject_id" id="subjectId">
- <option value="0">选择学科</option>
- </select>
- <select name="grade" id="gradeId">
- <option value="0">选择年级</option>
- </select>
- <select name="class" id="select_class">
- <option value="0">选择教学班</option>
- </select>
- <input type="text" name="student_name" class="student_name" value="" >
- </p>
- <div class="form-item clearfix">
- <div class="class-box fl" >
- <p><img src="/images/icon-tips.png" alt="" class="class-tips">可选学生</p>
- <ul class="selected-box">
- </ul>
- </div>
- <img src="/images/icon-change.png" alt="" class="icon-change fl">
- <div class="class-box fl">
- <p><img src="/images/icon-tips.png" alt="" class="class-tips">已选学生</p>
- <ul class="unchecked-box">
- </ul>
- </div>
- </div>
- <div class="pop-btns">
- <input type="hidden" name="cid" value="<?php echo $cid?>">
- <div class="confirm-pop-btn-sure">确认</div>
- </div>
- </div>
- </div>
- </div>
- <script>
- $(function(){
- $('.add_btn').click(function(){
- $('.history-pop').show();
- });
- $('.npt-close').click(function(){
- $('.history-pop').hide();
- })
- var subjects=[];
- var selectedStudent=[];
- <?php
- foreach ($subjects as $key => $val){
- echo 'subjects.push('.$key.');';
- }
- ?>
- var defaultSemester='<?php echo Yii::app()->session['session_semester_id']?>';
- $("#semesterId").val(defaultSemester);
- changeSemester(defaultSemester);
- $("#semesterId").change(function(){
- var semester=$(this).val();
- changeSemester(semester);
- });
- function changeSemester(semester){
- if(semester==0) return false;
- $.ajax({
- url:'<?php echo $this->createUrl('classes/ajaxGetSubjectBySemester')?>',
- type:'POST',
- dataType:'json',
- data:{semester:semester},
- success:function(res){
- if(res.status==1){
- if(res.data.length>0){
- var selectedBoxHtml='<option value="0">选择学科</option>';
- for(var i=0;i<res.data.length;i++){
- selectedBoxHtml+='<option value="'+res.data[i]['subject_id']+'">'+res.data[i]['subject_name']+'</option>';
- }
- $('#subjectId').html(selectedBoxHtml);
- }
- }
- }
- });
- }
- //选择学科加载年级
- $("#subjectId").change(function(){
- var subject=$(this).val();
- var semester=$('#semesterId').val();
- if(subject==0) return false;
- $.ajax({
- url:'<?php echo $this->createUrl('classes/ajaxGetGradeBySubject')?>',
- type:'POST',
- dataType:'json',
- data:{semester:semester,subject:subject},
- success:function(res){
- if(res.status==1){
- if(res.data.length>0){
- var selectedBoxHtml='<option value="0">选择年级</option>';
- for(var i=0;i<res.data.length;i++){
- selectedBoxHtml+='<option value="'+res.data[i]['id']+'">'+res.data[i]['name']+'</option>';
- }
- $('#gradeId').html(selectedBoxHtml);
- }
- }
- }
- });
- });
- //加载班级
- $("#gradeId").change(function(){
- var grade=$(this).val();
- var semester=$('#semesterId').val();
- var subject=$('#subjectId').val();
- var to_class_id='<?php echo $cid?>';
- if(grade==0) return false;
- $.ajax({
- url:'<?php echo $this->createUrl('classes/ajaxGetClass')?>',
- type:'POST',
- dataType:'json',
- data:{semester:semester,subject:subject,grade:grade,to_class_id:to_class_id},
- success:function(res){
- if(res.status==1){
- if(res.data.length>0){
- var selectedBoxHtml='<option value="0">选择班级</option>';
- for(var i=0;i<res.data.length;i++){
- selectedBoxHtml+='<option value="'+res.data[i]['class_id']+'">'+res.data[i]['class_name']+'</option>';
- }
- $('#select_class').html(selectedBoxHtml);
- }
- }
- }
- });
- });
- // 加载学生
- $('#select_class').change(function(){
- var class_id=$(this).val();
- var grade=$('#gradeId').val();
- var subjectId=$('#subjectId').val();
- var semester=$('#semesterId').val();
- var to_class_id='<?php echo $cid?>';
- if(class_id==0){
- return false;
- }
- subjects=[];
- subjects.push(subjectId);
- $.ajax({
- url:'<?php echo $this->createUrl('studentinfo/getClassifiedStudent')?>',
- type:'POST',
- dataType:'json',
- data:{class_id:class_id,subjects:subjects,grade:grade,semester:semester,to_class_id:to_class_id},
- success:function(res){
- if(res.status==1){
- if(res.data.length>0){
- var selectedBoxHtml='';
- for(var i=0;i<res.data.length;i++){
- if($.inArray(res.data[i]['student_id'],selectedStudent)==-1){
- selectedBoxHtml+='<li value="'+res.data[i]['student_id']+'" class_id="'+class_id+'">'+res.data[i]['realname']+'</li>';
- }
- }
- $('.selected-box').html(selectedBoxHtml);
- }
- }
- }
- });
- });
- $('.student_name').change(function () {
- var realname=$(this).val();
- var to_class_id='<?php echo $cid?>';
- var grade=$('#gradeId').val();
- var subjectId=$('#subjectId').val();
- var semester=$('#semesterId').val();
- //读取班级ids
- classIds=[];
- $('#select_class option').each(function(){
- if($(this).attr('value')!=0){
- classIds.push($(this).attr('value'));
- }
- })
- if(grade==0 || subjectId==0 || semester==0){
- layer.msg('请选择学期、科目、年级');
- $('.student_name').val('');
- return false;
- }
- if(classIds.length==0){
- layer.msg('所选科目没有教学班级,请重新选择');
- $('.student_name').val('');
- return false;
- }
- if(realname!='' && realname !=undefined){
- $.ajax({
- url:'<?php echo $this->createUrl('studentinfo/getClassifiedStudentByName')?>',
- type:'POST',
- dataType:'json',
- data:{realname:realname,classIds:classIds},
- success:function(res){
- if(res.status==1){
- console.log(res.data.length);
- if(res.data.length>0){
- var selectedBoxHtml='';
- for(var i=0;i<res.data.length;i++){
- if($.inArray(res.data[i]['student_id'],selectedStudent)==-1){
- selectedBoxHtml+='<li value="'+res.data[i]['student_id']+'">'+res.data[i]['realname']+'</li>';
- }
- }
- console.log(selectedBoxHtml);
- $('.selected-box').html(selectedBoxHtml);
- }
- }
- }
- });
- }
- });
- $(".selected-box").on("click", "li", function() {
- var value = $(this).attr('value');
- var name = $(this).text();
- var cid=$(this).attr('class_id');
- $(this).remove();
- $(".unchecked-box").append('<li value="'+value+'" class_id="'+cid+'">'+name+'</li>');
- selectedStudent.push(value);
- return false;
- });
- // 移除已选学生
- $(".unchecked-box").on("click", "li", function() {
- var selectedStudentValue = $(this).attr('value');
- var selectedStudentName = $(this).text();
- var selectedStudentClassId = $(this).attr('class_id');
- $(this).remove();
- $(".selected-box").append('<li value="'+selectedStudentValue+'" class_id="'+selectedStudentClassId+'">'+selectedStudentName+'</li>');
- for(var ii=0;ii<selectedStudent.length;ii++){
- if($.trim(selectedStudentValue)==$.trim(selectedStudent[ii])){
- selectedStudent.splice(ii,1);
- }
- }
- // console.log(selectedStudent);
- return false;
- });
- //添加
- var repeatSubmit =true;
- $('.confirm-pop-btn-sure').click(function(){
- if(selectedStudent.length>0 && repeatSubmit){
- var class_id=$('input[name=cid]').val();
- studentData=[];
- $('.unchecked-box li').each(function () {
- studentData.push($(this).attr('class_id')+'///'+$(this).attr('value'));
- });
- layer.msg('正在添加请稍候。。。。。。',{time:0});
- repeatSubmit=false;
- $.ajax({
- url:'<?php echo $this->createUrl('studentinfo/copyClassified')?>',
- type:'POST',
- dataType:'json',
- data:{cid:class_id,student_id:studentData},
- success:function(res){
- if(res.status==1){
- layer.msg('添加成功');
- window.location.href='<?php echo $this->createUrl('classes/index?class_type=2')?>';
- }else if(res.msg!=undefined){
- repeatSubmit=true;
- layer.msg(res.msg);
- }else{
- repeatSubmit=true;
- layer.msg('添加失败');
- }
- }
- });
- }
- });
- })
- </script>
|