copy_classified.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388
  1. <link type="text/css" rel="stylesheet" href="/css/needDetail.css" />
  2. <style>
  3. dl.subject_list{clear: both;display: block;margin-top:5px;border:1px solid #ccc;padding:10px;height:50px;}
  4. dl.subject_list dd{float:left;margin:5px;}
  5. /*修改样式开始*/
  6. .form-item_name{
  7. line-height: 28px;
  8. }
  9. .form-item-input_name{
  10. text-indent: 26px;
  11. }
  12. .name-tips{
  13. position: relative;
  14. left: 18px;
  15. bottom: 2px;
  16. }
  17. .test-type-ties{
  18. /*display: inline-block;
  19. margin: 0 12px;*/
  20. color: red;
  21. }
  22. .icon-test-type-ties{
  23. margin: 0 12px;
  24. margin-top: -3px;
  25. vertical-align: middle;
  26. }
  27. .form-item-con{
  28. color: #333;
  29. }
  30. .class-tips{
  31. vertical-align: middle;
  32. margin: 0 4px;
  33. }
  34. .class-box{
  35. width: 500px;
  36. }
  37. .class-box>p{
  38. margin-bottom: 10px;
  39. }
  40. .class-box>ul{
  41. width: 500px;
  42. height: 200px;
  43. padding: 10px 20px;
  44. background-color: #FAFAFA;
  45. box-sizing: border-box;
  46. border:1px solid #ddd;
  47. overflow: auto;
  48. }
  49. .class-box>ul>li{
  50. float: left;
  51. margin-right: 15px;
  52. margin-bottom: 10px;
  53. cursor: pointer;
  54. }
  55. .class-box>ul>li>img{
  56. vertical-align: middle;
  57. margin-left: 3px;
  58. }
  59. .icon-change{
  60. margin: 0 37px;
  61. margin-top: 110px;
  62. }
  63. .red-tips{
  64. color: red;
  65. }
  66. button.save {
  67. height: 40px;
  68. }
  69. .selected-box li{
  70. color:#0e8e54;
  71. }
  72. .title_msg{
  73. padding-top:30px;
  74. padding-left:20px
  75. }
  76. </style>
  77. <div class="main-content-inner">
  78. <!-- 导航栏开始-->
  79. <?php include(Yii::app()->basePath.'/views/layouts/class_navigation.php');?>
  80. <!-- 导航栏结束-->
  81. <div class="layout-gap">
  82. <section class="anc-top flex status_1" >
  83. <div class="flex-one flex">
  84. <p class="anc-title">转班</p>
  85. <p class="title_msg">从其他学期或年级的教学班选择学生,添加到当前教学班</p>
  86. </div>
  87. <div class="anc-opt-btn green-font pointer reback" ><a href="<?php echo $this->createUrl('classes/index');?>?class_type=2">返回</a></div>
  88. </section>
  89. <section class="anc-main-con">
  90. <div class="pointer ">当前班级信息</div>
  91. <span>年级:<?php echo $gradeName?>丨教学班名称:<?php echo $cname?>丨学科:<?php echo implode('、',$subjects)?> </span>
  92. </section>
  93. <div class="handle-detail-main-excel">
  94. <p>
  95. <select name="semester_id" id="semesterId">
  96. <option value="0">选择学期</option>
  97. <?php
  98. if($semester){
  99. foreach ($semester as $val){
  100. echo '<option value="'.$val['semester_id'].'">'.$val['semester_name'].'</option>';
  101. }
  102. }
  103. ?>
  104. </select>
  105. <select name="subject_id" id="subjectId">
  106. <option value="0">选择学科</option>
  107. </select>
  108. <select name="grade" id="gradeId">
  109. <option value="0">选择年级</option>
  110. </select>
  111. <select name="class" id="select_class">
  112. <option value="0">选择教学班</option>
  113. </select>
  114. <input type="text" name="student_name" class="student_name" value="" >
  115. </p>
  116. <div class="form-item clearfix">
  117. <div class="class-box fl" >
  118. <p><img src="/images/icon-tips.png" alt="" class="class-tips">可选学生</p>
  119. <ul class="selected-box">
  120. </ul>
  121. </div>
  122. <img src="/images/icon-change.png" alt="" class="icon-change fl">
  123. <div class="class-box fl">
  124. <p><img src="/images/icon-tips.png" alt="" class="class-tips">已选学生</p>
  125. <ul class="unchecked-box">
  126. </ul>
  127. </div>
  128. </div>
  129. <div class="pop-btns">
  130. <input type="hidden" name="cid" value="<?php echo $cid?>">
  131. <div class="confirm-pop-btn-sure">确认</div>
  132. </div>
  133. </div>
  134. </div>
  135. </div>
  136. <script>
  137. $(function(){
  138. $('.add_btn').click(function(){
  139. $('.history-pop').show();
  140. });
  141. $('.npt-close').click(function(){
  142. $('.history-pop').hide();
  143. })
  144. var subjects=[];
  145. var selectedStudent=[];
  146. <?php
  147. foreach ($subjects as $key => $val){
  148. echo 'subjects.push('.$key.');';
  149. }
  150. ?>
  151. var defaultSemester='<?php echo Yii::app()->session['session_semester_id']?>';
  152. $("#semesterId").val(defaultSemester);
  153. changeSemester(defaultSemester);
  154. $("#semesterId").change(function(){
  155. var semester=$(this).val();
  156. changeSemester(semester);
  157. });
  158. function changeSemester(semester){
  159. if(semester==0) return false;
  160. $.ajax({
  161. url:'<?php echo $this->createUrl('classes/ajaxGetSubjectBySemester')?>',
  162. type:'POST',
  163. dataType:'json',
  164. data:{semester:semester},
  165. success:function(res){
  166. if(res.status==1){
  167. if(res.data.length>0){
  168. var selectedBoxHtml='<option value="0">选择学科</option>';
  169. for(var i=0;i<res.data.length;i++){
  170. selectedBoxHtml+='<option value="'+res.data[i]['subject_id']+'">'+res.data[i]['subject_name']+'</option>';
  171. }
  172. $('#subjectId').html(selectedBoxHtml);
  173. }
  174. }
  175. }
  176. });
  177. }
  178. //选择学科加载年级
  179. $("#subjectId").change(function(){
  180. var subject=$(this).val();
  181. var semester=$('#semesterId').val();
  182. if(subject==0) return false;
  183. $.ajax({
  184. url:'<?php echo $this->createUrl('classes/ajaxGetGradeBySubject')?>',
  185. type:'POST',
  186. dataType:'json',
  187. data:{semester:semester,subject:subject},
  188. success:function(res){
  189. if(res.status==1){
  190. if(res.data.length>0){
  191. var selectedBoxHtml='<option value="0">选择年级</option>';
  192. for(var i=0;i<res.data.length;i++){
  193. selectedBoxHtml+='<option value="'+res.data[i]['id']+'">'+res.data[i]['name']+'</option>';
  194. }
  195. $('#gradeId').html(selectedBoxHtml);
  196. }
  197. }
  198. }
  199. });
  200. });
  201. //加载班级
  202. $("#gradeId").change(function(){
  203. var grade=$(this).val();
  204. var semester=$('#semesterId').val();
  205. var subject=$('#subjectId').val();
  206. var to_class_id='<?php echo $cid?>';
  207. if(grade==0) return false;
  208. $.ajax({
  209. url:'<?php echo $this->createUrl('classes/ajaxGetClass')?>',
  210. type:'POST',
  211. dataType:'json',
  212. data:{semester:semester,subject:subject,grade:grade,to_class_id:to_class_id},
  213. success:function(res){
  214. if(res.status==1){
  215. if(res.data.length>0){
  216. var selectedBoxHtml='<option value="0">选择班级</option>';
  217. for(var i=0;i<res.data.length;i++){
  218. selectedBoxHtml+='<option value="'+res.data[i]['class_id']+'">'+res.data[i]['class_name']+'</option>';
  219. }
  220. $('#select_class').html(selectedBoxHtml);
  221. }
  222. }
  223. }
  224. });
  225. });
  226. // 加载学生
  227. $('#select_class').change(function(){
  228. var class_id=$(this).val();
  229. var grade=$('#gradeId').val();
  230. var subjectId=$('#subjectId').val();
  231. var semester=$('#semesterId').val();
  232. var to_class_id='<?php echo $cid?>';
  233. if(class_id==0){
  234. return false;
  235. }
  236. subjects=[];
  237. subjects.push(subjectId);
  238. $.ajax({
  239. url:'<?php echo $this->createUrl('studentinfo/getClassifiedStudent')?>',
  240. type:'POST',
  241. dataType:'json',
  242. data:{class_id:class_id,subjects:subjects,grade:grade,semester:semester,to_class_id:to_class_id},
  243. success:function(res){
  244. if(res.status==1){
  245. if(res.data.length>0){
  246. var selectedBoxHtml='';
  247. for(var i=0;i<res.data.length;i++){
  248. if($.inArray(res.data[i]['student_id'],selectedStudent)==-1){
  249. selectedBoxHtml+='<li value="'+res.data[i]['student_id']+'" class_id="'+class_id+'">'+res.data[i]['realname']+'</li>';
  250. }
  251. }
  252. $('.selected-box').html(selectedBoxHtml);
  253. }
  254. }
  255. }
  256. });
  257. });
  258. $('.student_name').change(function () {
  259. var realname=$(this).val();
  260. var to_class_id='<?php echo $cid?>';
  261. var grade=$('#gradeId').val();
  262. var subjectId=$('#subjectId').val();
  263. var semester=$('#semesterId').val();
  264. //读取班级ids
  265. classIds=[];
  266. $('#select_class option').each(function(){
  267. if($(this).attr('value')!=0){
  268. classIds.push($(this).attr('value'));
  269. }
  270. })
  271. if(grade==0 || subjectId==0 || semester==0){
  272. layer.msg('请选择学期、科目、年级');
  273. $('.student_name').val('');
  274. return false;
  275. }
  276. if(classIds.length==0){
  277. layer.msg('所选科目没有教学班级,请重新选择');
  278. $('.student_name').val('');
  279. return false;
  280. }
  281. if(realname!='' && realname !=undefined){
  282. $.ajax({
  283. url:'<?php echo $this->createUrl('studentinfo/getClassifiedStudentByName')?>',
  284. type:'POST',
  285. dataType:'json',
  286. data:{realname:realname,classIds:classIds},
  287. success:function(res){
  288. if(res.status==1){
  289. console.log(res.data.length);
  290. if(res.data.length>0){
  291. var selectedBoxHtml='';
  292. for(var i=0;i<res.data.length;i++){
  293. if($.inArray(res.data[i]['student_id'],selectedStudent)==-1){
  294. selectedBoxHtml+='<li value="'+res.data[i]['student_id']+'">'+res.data[i]['realname']+'</li>';
  295. }
  296. }
  297. console.log(selectedBoxHtml);
  298. $('.selected-box').html(selectedBoxHtml);
  299. }
  300. }
  301. }
  302. });
  303. }
  304. });
  305. $(".selected-box").on("click", "li", function() {
  306. var value = $(this).attr('value');
  307. var name = $(this).text();
  308. var cid=$(this).attr('class_id');
  309. $(this).remove();
  310. $(".unchecked-box").append('<li value="'+value+'" class_id="'+cid+'">'+name+'</li>');
  311. selectedStudent.push(value);
  312. return false;
  313. });
  314. // 移除已选学生
  315. $(".unchecked-box").on("click", "li", function() {
  316. var selectedStudentValue = $(this).attr('value');
  317. var selectedStudentName = $(this).text();
  318. var selectedStudentClassId = $(this).attr('class_id');
  319. $(this).remove();
  320. $(".selected-box").append('<li value="'+selectedStudentValue+'" class_id="'+selectedStudentClassId+'">'+selectedStudentName+'</li>');
  321. for(var ii=0;ii<selectedStudent.length;ii++){
  322. if($.trim(selectedStudentValue)==$.trim(selectedStudent[ii])){
  323. selectedStudent.splice(ii,1);
  324. }
  325. }
  326. // console.log(selectedStudent);
  327. return false;
  328. });
  329. //添加
  330. var repeatSubmit =true;
  331. $('.confirm-pop-btn-sure').click(function(){
  332. if(selectedStudent.length>0 && repeatSubmit){
  333. var class_id=$('input[name=cid]').val();
  334. studentData=[];
  335. $('.unchecked-box li').each(function () {
  336. studentData.push($(this).attr('class_id')+'///'+$(this).attr('value'));
  337. });
  338. layer.msg('正在添加请稍候。。。。。。',{time:0});
  339. repeatSubmit=false;
  340. $.ajax({
  341. url:'<?php echo $this->createUrl('studentinfo/copyClassified')?>',
  342. type:'POST',
  343. dataType:'json',
  344. data:{cid:class_id,student_id:studentData},
  345. success:function(res){
  346. if(res.status==1){
  347. layer.msg('添加成功');
  348. window.location.href='<?php echo $this->createUrl('classes/index?class_type=2')?>';
  349. }else if(res.msg!=undefined){
  350. repeatSubmit=true;
  351. layer.msg(res.msg);
  352. }else{
  353. repeatSubmit=true;
  354. layer.msg('添加失败');
  355. }
  356. }
  357. });
  358. }
  359. });
  360. })
  361. </script>