classified.php 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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:120px;}
  4. dl.subject_list dd{float:left;margin:5px;}
  5. </style>
  6. <div class="main-content-inner">
  7. <!-- 导航栏开始-->
  8. <?php include(Yii::app()->basePath.'/views/layouts/class_navigation.php');?>
  9. <!-- 导航栏结束-->
  10. <div class="layout-gap">
  11. <section class="anc-top flex status_1" >
  12. <div class="flex-one flex">
  13. <p class="anc-title">走班学科设置</p>
  14. </div>
  15. <div class="anc-opt-btn green-font pointer reback" ><a href="<?php echo $this->createUrl('classes/index');?>?class_type=2">返回</a></div>
  16. </section>
  17. <section class="anc-main-con">
  18. <div class="begain-check-btn pointer add_btn">添加走班学科</div>
  19. <span class=" red-font">提示:走班的学科,无法再使用行政班考试了,请谨慎操作。</span>
  20. </section>
  21. <div class="handle-detail-main-excel">
  22. <table class="table table-striped table-bordered table-hover dataTable no-footer DTTT_selectable">
  23. <tr>
  24. <td>学科</td>
  25. <td>年级</td>
  26. <td>状态</td>
  27. <td>操作</td>
  28. <tr>
  29. <?php
  30. $gradeArr=array(
  31. 1=>'高一',
  32. 2=>'高二',
  33. 3=>'高三'
  34. );
  35. if($setting){
  36. foreach ($setting as $val){
  37. ?>
  38. <tr>
  39. <td><?php echo Yii::app()->params['subjectId'][$val['subject_id']]?></td>
  40. <td><?php echo $gradeArr[$val['grade']]?></td>
  41. <td>
  42. <?php
  43. if($val['status']==1){
  44. echo '已启用';
  45. }else{
  46. echo ' 已禁用';
  47. }
  48. ?>
  49. </td>
  50. <td>
  51. <?php
  52. if($val['status']==1){
  53. echo '<button subject="'.$val['subject_id'].'" grade="'.$val['grade'].'" class="red-font set-disable">禁用</button>';
  54. }else{
  55. echo '<button subject="'.$val['subject_id'].'" grade="'.$val['grade'].'" class="set-enable">启用</button>';
  56. }
  57. ?>
  58. </td>
  59. </tr>
  60. <?php
  61. }
  62. }
  63. ?>
  64. </table>
  65. </div>
  66. </div>
  67. </div>
  68. <div class="history-pop">
  69. <div class="history-pop-con">
  70. <div class="need-pop-top clearfix">
  71. <div class="npt-title put-need fl">添加走班学科</div>
  72. <div class="npt-close fr">×</div>
  73. </div>
  74. <div>
  75. <p>实行走班的年级
  76. <select name="grade" class="grade">
  77. <option value="0">选择年级</option>
  78. <option value="1">高一</option>
  79. <option value="2">高二</option>
  80. <option value="3">高三</option>
  81. </select>
  82. </p>
  83. </div>
  84. <div class="">
  85. <p>实行走班的学科</p>
  86. <dl class="subject_list">
  87. <?php
  88. if($subject){
  89. foreach ($subject as $key => $val){
  90. echo '<dd ><input name="subject[]" class="subject" id="subject_'.$key.'" type="checkbox" value="'.$key.'">'.$val.'</dd>';
  91. }
  92. }
  93. ?>
  94. </dl>
  95. </div>
  96. <div class="pop-btns">
  97. <div class="confirm-pop-btn-sure">确认</div>
  98. </div>
  99. </div>
  100. </div>
  101. <script>
  102. $(function(){
  103. $('.add_btn').click(function(){
  104. $('.history-pop').show();
  105. });
  106. $('.npt-close').click(function(){
  107. $('.subject').prop('disabled',false);
  108. $('.subject').prop('checked',false);
  109. $('.grade').val(0);
  110. $('.history-pop').hide();
  111. })
  112. $('.confirm-pop-btn-sure').click(function(){
  113. var grade=$('.grade').val();
  114. var subject=[];
  115. var subjectObj=$('.subject');
  116. for(var i=0;i<subjectObj.length;i++){
  117. if(subjectObj.eq(i).is(':checked')){
  118. subject.push(subjectObj.eq(i).val());
  119. }
  120. }
  121. if(grade==0){
  122. layer.msg('请选择年级 ');
  123. return false;
  124. }
  125. if(subjectObj.length<1){
  126. layer.msg('请选择开通的科目');
  127. return false;
  128. }
  129. $.ajax({
  130. url:'<?php echo $this->createUrl('classes/addClassified')?>',
  131. type:'POST',
  132. data:{grade:grade,subject:subject},
  133. dataType:'json',
  134. success:function(res){
  135. if(res.status==1){
  136. layer.msg('操作成功')
  137. window.location.reload();
  138. }else{
  139. if(res.msg!=undefined){
  140. layer.msg(res.msg);
  141. }else{
  142. layer.msg('添加失败');
  143. }
  144. }
  145. }
  146. });
  147. });
  148. //启用
  149. $('.set-enable').click(function(){
  150. var grade=$(this).attr('grade'),
  151. subject=$(this).attr('subject');
  152. layer.confirm('您确认开启走班吗?', {
  153. btn: ['确定', '取消'] //按钮
  154. }, function () {
  155. $.ajax({
  156. url:'<?php echo $this->createUrl('classes/updateClassified')?>',
  157. type:'POST',
  158. dataType:'json',
  159. data:{grade:grade,subject:subject,type:'enable'},
  160. success:function(res){
  161. if(res.status==1){
  162. layer.msg('操作成功', {
  163. icon: 1,
  164. time: 2000 //2秒关闭(如果不配置,默认是3秒)
  165. }, function(){
  166. window.location.reload();
  167. });
  168. }else{
  169. layer.msg('操作失败');
  170. }
  171. }
  172. })
  173. })
  174. })
  175. //启用
  176. $('.set-disable').click(function(){
  177. var grade=$(this).attr('grade'),
  178. subject=$(this).attr('subject');
  179. layer.confirm('您确认禁用走班吗?禁用后将使用行政班考试', {
  180. btn: ['确定', '取消'] //按钮
  181. }, function () {
  182. $.ajax({
  183. url:'<?php echo $this->createUrl('classes/updateClassified')?>',
  184. type:'POST',
  185. dataType:'json',
  186. data:{grade:grade,subject:subject,type:'disable'},
  187. success:function(res){
  188. if(res.status==1){
  189. layer.msg('操作成功', {
  190. icon: 1,
  191. time: 2000 //2秒关闭(如果不配置,默认是3秒)
  192. }, function(){
  193. window.location.reload();
  194. });
  195. }else{
  196. layer.msg('操作失败');
  197. }
  198. }
  199. })
  200. })
  201. })
  202. $('.grade').change(function(){
  203. var grade=$(this).val();
  204. if(grade!=0 && grade!=undefined){
  205. $('.subject').prop('disabled',false);
  206. $('.subject').prop('checked',false);
  207. $.ajax({
  208. url:'<?php echo $this->createUrl('classes/getClassSubjectByGrade')?>',
  209. type:'POST',
  210. dataType:'json',
  211. data:{grade:grade,rtype:'arr'},
  212. success:function(res){
  213. if(res.status==1){
  214. console.log(res.data.length);
  215. for(var i=0;i<res.data.length;i++){
  216. $('#subject_'+res.data[i]).prop('disabled',true);
  217. }
  218. }
  219. }
  220. })
  221. }
  222. })
  223. })
  224. </script>