add_classified.php 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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. </style>
  73. <div class="main-content-inner">
  74. <!-- 导航栏开始-->
  75. <?php include(Yii::app()->basePath.'/views/layouts/class_navigation.php');?>
  76. <!-- 导航栏结束-->
  77. <div class="layout-gap">
  78. <section class="anc-top flex status_1" >
  79. <div class="flex-one flex">
  80. <p class="anc-title">添加学生</p>
  81. </div>
  82. <div class="anc-opt-btn green-font pointer reback" ><a href="<?php echo $this->createUrl('classes/index');?>?class_type=2">返回</a></div>
  83. </section>
  84. <section class="anc-main-con">
  85. <div class="pointer ">当前班级信息</div>
  86. <span>年级:<?php echo $gradeName?>丨教学班名称:<?php echo $cname?>丨学科:<?php echo implode('、',$subjects)?> </span>
  87. </section>
  88. <div class="handle-detail-main-excel">
  89. <p>
  90. <select name="class" id="select_class">
  91. <option value="0">选择行政班</option>
  92. <?php
  93. if($classInfo){
  94. foreach ($classInfo as $val){
  95. echo '<option value="'.$val['class_id'].'">'.$val['class_name'].'</option>';
  96. }
  97. }
  98. ?>
  99. </select>
  100. <input type="text" name="student_name" class="student_name" value="" >
  101. </p>
  102. <div class="form-item clearfix">
  103. <div class="class-box fl" >
  104. <p><img src="/images/icon-tips.png" alt="" class="class-tips">未走班学生</p>
  105. <ul class="selected-box">
  106. </ul>
  107. </div>
  108. <img src="/images/icon-change.png" alt="" class="icon-change fl">
  109. <div class="class-box fl">
  110. <p><img src="/images/icon-tips.png" alt="" class="class-tips">已选学生</p>
  111. <ul class="unchecked-box">
  112. </ul>
  113. </div>
  114. </div>
  115. <div class="pop-btns">
  116. <input type="hidden" name="cid" value="<?php echo $cid?>">
  117. <div class="confirm-pop-btn-sure">确认</div>
  118. </div>
  119. </div>
  120. </div>
  121. </div>
  122. <script>
  123. $(function(){
  124. var jumpUrl=getCookie('needMemoryAction');
  125. function getCookie(cname) {
  126. var name = cname + "=";
  127. var decodedCookie = decodeURIComponent(document.cookie);
  128. var ca = decodedCookie.split(';');
  129. for(var i = 0; i <ca.length; i++) {
  130. var c = ca[i];
  131. while (c.charAt(0) == ' ') {
  132. c = c.substring(1);
  133. }
  134. if (c.indexOf(name) == 0) {
  135. return c.substring(name.length, c.length);
  136. }
  137. }
  138. return "";
  139. }
  140. $('.add_btn').click(function(){
  141. $('.history-pop').show();
  142. });
  143. $('.npt-close').click(function(){
  144. $('.history-pop').hide();
  145. })
  146. var subjects=[];
  147. var selectedStudent=[];
  148. var grade=<?php echo $grade?>;
  149. <?php
  150. foreach ($subjects as $key => $val){
  151. echo 'subjects.push('.$key.');';
  152. }
  153. ?>
  154. // 加载学生
  155. $('#select_class').change(function(){
  156. var class_id=$(this).val();
  157. getStudent(class_id);
  158. });
  159. function getStudent(class_id){
  160. if(class_id==0){
  161. return false;
  162. }
  163. $.ajax({
  164. url:'<?php echo $this->createUrl('studentinfo/getStudentByClassified')?>',
  165. type:'POST',
  166. dataType:'json',
  167. data:{class_id:class_id,subjects:subjects,grade:grade},
  168. success:function(res){
  169. if(res.status==1){
  170. if(res.data.length>0){
  171. var selectedBoxHtml='';
  172. for(var i=0;i<res.data.length;i++){
  173. if($.inArray(res.data[i]['student_id'],selectedStudent)==-1){
  174. selectedBoxHtml+='<li value="'+res.data[i]['student_id']+'">'+res.data[i]['realname']+'</li>';
  175. }
  176. }
  177. $('.selected-box').html(selectedBoxHtml);
  178. }
  179. }
  180. }
  181. });
  182. }
  183. $('.student_name').change(function () {
  184. var realname=$(this).val();
  185. if(realname!='' && realname !=undefined){
  186. $.ajax({
  187. url:'<?php echo $this->createUrl('studentinfo/searchStudentByClassified')?>',
  188. type:'POST',
  189. dataType:'json',
  190. data:{realname:realname,subjects:subjects,grade:grade},
  191. success:function(res){
  192. if(res.status==1){
  193. if(res.data.length>0){
  194. var selectedBoxHtml='';
  195. for(var i=0;i<res.data.length;i++){
  196. if($.inArray(res.data[i]['student_id'],selectedStudent)==-1){
  197. selectedBoxHtml+='<li value="'+res.data[i]['student_id']+'">'+res.data[i]['realname']+'</li>';
  198. }
  199. }
  200. $('.selected-box').html(selectedBoxHtml);
  201. }
  202. }
  203. }
  204. });
  205. }else{
  206. var class_id= $('#select_class').val();
  207. getStudent(class_id);
  208. }
  209. });
  210. $(".selected-box").on("click", "li", function() {
  211. var classValue = $(this).attr('value');
  212. var className = $(this).text();
  213. $(this).remove();
  214. $(".unchecked-box").append('<li value="'+classValue+'">'+className+'</li>');
  215. selectedStudent.push(classValue);
  216. return false;
  217. });
  218. // 移除已选学生
  219. $(".unchecked-box").on("click", "li", function() {
  220. var selectedStudentValue = $(this).attr('value');
  221. var selectedStudentName = $(this).text();
  222. $(this).remove();
  223. $(".selected-box").append('<li value="'+selectedStudentValue+'">'+selectedStudentName+'</li>');
  224. for(var ii=0;ii<selectedStudent.length;ii++){
  225. if($.trim(selectedStudentValue)==$.trim(selectedStudent[ii])){
  226. selectedStudent.splice(ii,1);
  227. }
  228. }
  229. console.log(selectedStudent);
  230. return false;
  231. });
  232. //添加
  233. $('.confirm-pop-btn-sure').click(function(){
  234. console.log(selectedStudent);
  235. if(selectedStudent.length>0){
  236. var class_id=$('input[name=cid]').val();
  237. $.ajax({
  238. url:'<?php echo $this->createUrl('studentinfo/addClassifiedStudent')?>',
  239. type:'POST',
  240. dataType:'json',
  241. data:{cid:class_id,student_id:selectedStudent},
  242. success:function(res){
  243. if(res.status==1){
  244. layer.msg('添加成功');
  245. if(jumpUrl!=''){
  246. window.location.href= jumpUrl;
  247. }else{
  248. window.location.href='<?php echo $this->createUrl('classes/index?class_type=2')?>';
  249. }
  250. }else if(res.msg!=undefined){
  251. layer.msg(res.msg);
  252. }else{
  253. layer.msg('添加失败');
  254. }
  255. }
  256. });
  257. }
  258. });
  259. })
  260. </script>