edit.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505
  1. <link type="text/css" rel="stylesheet" href="/css/needDetail.css" />
  2. <link type="text/css" rel="stylesheet" href="/js/select/select2.min.css" />
  3. <script src="/js/xsgl.js"></script>
  4. <script src="/js/select/select2.min.js"></script>
  5. <style>
  6. .addborder{border:1px solid #ccc}
  7. .addheight{height:30px;border-radius:2px;}
  8. .addheight:focus{border-color: #66afe9;box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset, 0 0 8px rgba(102, 175, 233, 0.6);outline: 0 none;}
  9. .ace{position:relative;top:0px !important;left:0px !important;}
  10. label{font-weight:100 !important;}
  11. /* #coach_id-error{position: absolute;right:-80px;top:5px;}
  12. #level_name-error{position: absolute;right:-80px;top:5px;}
  13. #material_id-error{position: absolute;right:-110px;top:5px;}
  14. #class_name-error{margin: 6px 0px 0px 18px;font-size:13px;} */
  15. .clearfix:after {
  16. content: "";
  17. display: block;
  18. visibility: hidden;
  19. height: 0;
  20. clear: both;
  21. }
  22. .clearfix {
  23. zoom: 1;
  24. }
  25. .fl {
  26. float: left;
  27. }
  28. .fr {
  29. float: right;
  30. }
  31. em{
  32. color: #FF000C;
  33. margin-right: 4px;
  34. }
  35. .bm-name{
  36. width: 100px;
  37. text-align: right;
  38. // border: 1px solid #000;
  39. }
  40. .bm-inp-con{
  41. width: 170px;
  42. }
  43. .basic-message select{
  44. width: 160px;
  45. height: 26px;
  46. }
  47. .basic-message input{
  48. width: 156px;
  49. height: 22px;
  50. }
  51. .basic-message{
  52. padding: 10px 0;
  53. }
  54. .th-describe{
  55. margin-top: 10px;
  56. }
  57. .th-describe span{
  58. color: #FF000C;
  59. }
  60. table{
  61. width: 800px;
  62. border-color: #fff;
  63. text-align: center;
  64. font-size: 14px;
  65. margin-top: 10px;
  66. }
  67. thead{
  68. background: #F2F2F2;
  69. }
  70. .serial{
  71. width: 80px;
  72. }
  73. .operation{
  74. width: 100px;
  75. }
  76. .subject,.teacher,.remarks{
  77. width: 180px;
  78. }
  79. .teacher{
  80. }
  81. .remarks{
  82. }
  83. td{
  84. height: 40px;
  85. }
  86. table input,table select{
  87. width: 80%;
  88. height: 86%;
  89. text-indent: 10px;
  90. }
  91. .opration-con{
  92. font-size: 23px;
  93. font-weight: bold;
  94. }
  95. .opration-con > span{
  96. color: #2977ff;
  97. cursor: pointer;
  98. }
  99. .types-con{
  100. margin-top: 25px;
  101. }
  102. .getscore-type{
  103. margin-left: 60px;
  104. }
  105. .types-con input {
  106. margin-left: 10px;
  107. cursor: pointer;
  108. }
  109. .submit{
  110. width: 100px;
  111. height: 30px;
  112. background: #01B677;
  113. color: #fff;
  114. border: none;
  115. margin-top: 50px;
  116. }
  117. .name-con{left:13px;top:28px;}
  118. .title_msg{
  119. padding-top:30px;
  120. padding-left:20px
  121. }
  122. </style>
  123. <div class="main-content-inner">
  124. <!-- 导航栏开始-->
  125. <?php include(Yii::app()->basePath.'/views/layouts/class_navigation.php');?>
  126. <!-- 导航栏结束-->
  127. <!--新版增加班级-->
  128. <div class="page-content" style="margin-top:15px;">
  129. <div class="row" style="margin:0px">
  130. <div class="col-xs-12 fontSize1">
  131. <!-- PAGE CONTENT BEGINS -->
  132. <section class="anc-top flex status_1" >
  133. <div class="flex-one flex">
  134. <p class="anc-title">行政班</p>
  135. <p class="title_msg">当前学年:<?php echo $thisSemester["school_year"];?>学年 当前学期:<?php echo $thisSemester["semester_name"];?></p>
  136. </div>
  137. </section>
  138. <form class="form-horizontal" action="<?php echo $this->createUrl('classes/edit',array('cid'=>$classInfo->class_id));?>" method="post" id="classAdd">
  139. <div class="col-xs-12 col-sm-12">
  140. <div class="form-group col-xs-12 col-sm-4">
  141. <label class="control-label col-xs-12 col-sm-3 no-padding-right">班级名称<span class="errorMessage">*</span>:</label>
  142. <div class="col-sm-9 mtCentent">
  143. <input type="text" id="class_name" name="class_name" class="col-xs-10 col-sm-4 addborder addheight" value="<?php echo $classInfo->class_name;?>" />
  144. </div>
  145. </div>
  146. <div class="form-group col-xs-12 col-sm-4">
  147. <label class="control-label col-xs-12 col-sm-3 no-padding-right">年级<span class="errorMessage">*</span>:</label>
  148. <div class="col-sm-9">
  149. <input type="hidden" id="grade" value="<?php echo $classInfo->grade ? $classInfo->grade : 0;?>">
  150. <?php echo Yii::app()->params['grade_list'][$classInfo->grade]['grade_name']?>
  151. </div>
  152. </div>
  153. <div class="form-group col-xs-12 col-sm-4 ">
  154. <label class="control-label col-xs-12 col-sm-3 no-padding-right">班主任<span class="errorMessage">*</span>:</label>
  155. <div class="col-sm-9 mtCentent ">
  156. <input type="text" id="main-teacher" name="main-teacher" class="col-xs-10 col-sm-4 addborder addheight marginLeftNo" autocomplete="off" value="<?php if(isset($bzr)) echo $bzr?>" />
  157. <ul class="name-con">
  158. </ul>
  159. </div>
  160. </div>
  161. <div class="form-group col-xs-12 col-sm-4">
  162. <label class="control-label col-xs-12 col-sm-3 no-padding-right">助教<span class="errorMessage">*</span>:</label>
  163. <div class="col-xs-12 col-sm-9">
  164. <select id="coach_id" name="coach_id">
  165. <?php
  166. foreach($coachList as $cl) {
  167. if (isset($relatCoach) && $relatCoach->coach_id == $cl->coach_id) {
  168. echo '<option selected value="' . $cl->coach_id . '">' . $cl->coach_name . '</option>';
  169. } else {
  170. echo '<option value="' . $cl->coach_id . '">' . $cl->coach_name . '</option>';
  171. }
  172. }
  173. ?>
  174. </select>
  175. </div>
  176. </div>
  177. <div class="form-group col-xs-12 col-sm-4">
  178. <label class="control-label col-xs-12 col-sm-3 no-padding-right">层级:</label>
  179. <div class="col-xs-12 col-sm-9">
  180. <div class="clearfix">
  181. <select class="input-medium" id="level_name" name="level_name">
  182. <option value="">请选择</option>
  183. <?php
  184. $levelArr=array(
  185. '1'=>'A',
  186. '2'=>'B',
  187. '3'=>'C'
  188. );
  189. if($classLevels){
  190. foreach ($classLevels as $classLevel){
  191. if($levelArr[$classInfo->level]==$classLevel[0]){
  192. echo '<option selected value="'.$classLevel[0].'">'.$classLevel[0].'层</option>';
  193. }else{
  194. echo '<option value="'.$classLevel[0].'">'.$classLevel[0].'层</option>';
  195. }
  196. }
  197. }
  198. ?>
  199. </select>
  200. </div>
  201. </div>
  202. <input type="hidden" name="class_array" id="class_array">
  203. </div>
  204. <?php if( Yii::app()->params['section']==1):?>
  205. <div class="form-group col-xs-12 col-sm-4">
  206. <label class="control-label col-xs-12 col-sm-3 no-padding-right">文理科:</label>
  207. <div class="col-sm-9">
  208. <select id="arts_science" name="arts_science">
  209. <option value="0" <?php if($classInfo->arts_science==0) echo 'selected';?>>不分科</option>
  210. <option value="1" <?php if($classInfo->arts_science==1) echo 'selected';?>>文科</option>
  211. <option value="2" <?php if($classInfo->arts_science==2) echo 'selected';?>>理科</option>
  212. </select>
  213. </div>
  214. </div>
  215. <?php endif;?>
  216. </div>
  217. <p class="th-describe"><em>*</em>执教老师:(<span>点击"+"添加列,点击"-"删除列</span>)</p>
  218. <table class="" cellpadding="0" cellspacing="0" border="1">
  219. <thead>
  220. <td class="serial">序号</td>
  221. <td class="operation">操作</td>
  222. <td class="subject">学科组</td>
  223. <td class="teacher">老师(岗位)</td>
  224. </thead>
  225. <?php foreach($classTeachersIds as $ck=>$cv){
  226. ?>
  227. <tr>
  228. <td><?php echo $ck+1;?></td>
  229. <td class="opration-con"><span class="add">+</span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="redus">-</span></td>
  230. <td>
  231. <select name="subject_ids[]" id="subject_ids" class="subject_ids">
  232. <?php
  233. $noShow=array(18,19);
  234. $noShow=array_merge($noShow,Yii::app()->params['mathSubjectId']);
  235. unset($noShow[array_search(3,$noShow)]);
  236. unset($noShow[array_search(41,$noShow)]);
  237. foreach(Yii::app()->params["subjectId"] as $k=>$v){
  238. if(!in_array($k,$noShow)){
  239. ?>
  240. <option value="<?php echo $k?>" <?php if(isset($subject_teacher[$cv]) && !empty($subject_teacher[$cv]) && $subject_teacher[$cv]==$k){echo 'selected';}?>><?php echo $v?></option>
  241. <?php
  242. }}?>
  243. </select>
  244. </td>
  245. <td>
  246. <select name="teacher_ids[]" id="teacher_ids" class="teacher_ids projSelect">
  247. <?php if(isset($subject_teacher[$cv]) && !empty($subject_teacher[$cv]) && isset($subject_teacher_array[$subject_teacher[$cv]]) && !empty($subject_teacher_array[$subject_teacher[$cv]])){
  248. foreach($subject_teacher_array[$subject_teacher[$cv]] as $k=>$v){
  249. ?>
  250. <option value="<?php echo $v[$k]['teacher_id']?>"
  251. <?php if(isset($class_teacher[$cv]) && !empty($class_teacher[$cv]) && isset($v[$class_teacher[$cv]]['teacher_id'])){echo 'selected';}?>>
  252. <?php echo $v[$k]['teacher_name'].'('.$v[$k]['posts'].')'?>
  253. </option>
  254. <?php
  255. }}?>
  256. </select>
  257. </td>
  258. </tr>
  259. <?php
  260. }?>
  261. </table>
  262. <input type="hidden" class="ace" name="wrong_book_type" value="0" >
  263. <input type="hidden" class="ace" name="improve_book_type" value="0" >
  264. <div class="clearfix form-actions mt15">
  265. <input type='hidden' id="school_year" name="period" class='diy_select_input' value="<?php echo $classInfo->period?>"/>
  266. <input type='hidden' id="bzr_id" name="bzrId" class='diy_select_input' value="<?php echo $classInfo->teacher_id?>"/>
  267. <div class="col-md-offset-3 col-md-9">
  268. <button class="btn btn-success btn-sm" type="submit" id="schoolSubmit">
  269. <i class="ace-icon fa fa-check bigger-110"></i> 提交
  270. </button>
  271. <!--&nbsp; &nbsp; &nbsp;
  272. <button class="btn" type="reset">
  273. <i class="ace-icon fa fa-undo bigger-110"></i>
  274. 重填
  275. </button>-->
  276. </div>
  277. </div>
  278. </form>
  279. <!-- PAGE CONTENT ENDS -->
  280. </div>
  281. </div>
  282. </div>
  283. <!--新版添加班级结束-->
  284. </div>
  285. <script src="/js/jquery.validate.min.js"></script>
  286. <script src="/js/birthday.js" type="text/javascript" charset="utf-8"></script>
  287. <script>
  288. $(document).ready(function(){
  289. $('.projSelect').select2();
  290. var subjectIds = <?php echo json_encode(Yii::app()->params["subjectId"]);?>;
  291. var selectCount=0;
  292. $(document).on("click",".add",function () {
  293. var index = $(this).parent().parent().index();
  294. var data = {'grade':$('#grade').val()};
  295. var obj = $(this);
  296. var noShow=[];
  297. <?php
  298. $noShow=array(18,19);
  299. $noShow=array_merge($noShow,Yii::app()->params['mathSubjectId']);
  300. unset($noShow[array_search(3,$noShow)]);
  301. unset($noShow[array_search(41,$noShow)]);
  302. foreach ($noShow as $item){
  303. echo 'noShow.push('.$item.');';
  304. }
  305. ?>
  306. var str = '';
  307. str += '<tr><td>1</td>';
  308. str+='<td class="opration-con"><span class="add">+</span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="redus">-</span></td>'
  309. str+='<td><select name="subject_ids[]" id="subject_ids" class="subject_ids projSelect">'
  310. $.each(subjectIds,function(index,val){
  311. if($.inArray(parseInt(index),noShow)==-1){
  312. str += '<option value="'+index+'">'+val+'</option>';
  313. }
  314. });
  315. str += '</select></td>';
  316. $.post("<?php echo Yii::app()->createUrl('classes/getAllTeachers')?>",data,function(flags){
  317. var m = JSON.parse(flags);
  318. if(m.status==0)
  319. {
  320. alert('没有教师');
  321. }else
  322. {
  323. selectCount++;
  324. var selectClass='projSelect'+selectCount;
  325. str += '<td><select name="teacher_ids[]" id="teacher_ids" class="teacher_ids '+selectClass+'">';
  326. $.each(m.result,function(index,val){
  327. str += '<option value="'+index+'">'+val+'</option>';
  328. });
  329. str += '<select></td></tr>';
  330. obj.parent().parent().after(str);
  331. for (var i=index+1;i<$('tbody tr').length;i++) {
  332. var tNum = parseInt($('tbody tr').eq(i-1).find('td').eq(0).text())+1;
  333. $('tbody tr').eq(i).find('td').eq(0).text(tNum);
  334. }
  335. $('.'+selectClass).select2();
  336. }
  337. });
  338. });
  339. $(document).on("click",".redus",function () {
  340. var index = $(this).parent().parent().index();
  341. for (var i=index+1;i<$('tbody tr').length;i++) {
  342. var tNum = parseInt($('tbody tr').eq(i).find('td').eq(0).text())-1;
  343. $('tbody tr').eq(i).find('td').eq(0).text(tNum);
  344. }
  345. if ($('tbody tr').length>1) {
  346. $(this).parent().parent().remove();
  347. } else{
  348. alert("最后一行不能删除了哦");
  349. }
  350. });
  351. $('body').on("change",".subject_ids",function(){
  352. /*$('#subject_ids').change(function(){*/
  353. var data= {
  354. subject_id:$(this).val(),
  355. grade: $('#grade').val()
  356. };
  357. var str ='';
  358. var _this = $(this);
  359. $.post("<?php echo Yii::app()->createUrl('classes/get_subject_teachers')?>",data,function(flags){
  360. var m = JSON.parse(flags);
  361. if(m.status==0)
  362. {
  363. alert('没有教师');
  364. }else
  365. {
  366. selectCount++;
  367. var selectClass='projSelect'+selectCount;
  368. str='<select name="teacher_ids[]" id="teacher_ids" class="teacher_ids '+selectClass+'">';
  369. $.each(m.result,function(index,val){
  370. str += '<option value="'+index+'">'+val+'</option>'
  371. });
  372. str+='</select>';
  373. }
  374. _this.parent().next().html(str);
  375. $('.'+selectClass).select2();
  376. //_this.parent().next().children('select').html(str);
  377. });
  378. });
  379. });
  380. </script>
  381. <script language="javascript">
  382. $(function(){
  383. //加载班主任教师
  384. $('#main-teacher').bind('input propertychange,input focus', function() {
  385. var obj_list=$(this).parent().find('.name-con');
  386. var keyword=$(this).val();
  387. console.log($(this).width());
  388. if(keyword==''){
  389. // return false;
  390. }
  391. width=parseInt($(this).width())+24;
  392. obj_list.css('width',width+'px');
  393. obj_list.html('');
  394. $(this).attr('teacher_id','');
  395. $('#bzr_id').val(0);
  396. $.ajax({
  397. url:'<?php echo $this->createUrl('classes/loadTeacher')?>',
  398. type:'POST',
  399. dataType:'json',
  400. data:{'keyword':keyword},
  401. success:function(res){
  402. if(res.status==1){
  403. var html='';
  404. if(res.data.length>0){
  405. for(var i=0;i<res.data.length;i++){
  406. html+='<li class="name-list" id="'+res.data[i]['teacher_id']+'">'+res.data[i]['teacher_name']+'</li>';
  407. }
  408. obj_list.html(html);
  409. obj_list.show();
  410. }
  411. }
  412. }
  413. });
  414. });
  415. $('.mtCentent').on('click','.name-list',function(){
  416. $(this).closest('.mtCentent').find('#main-teacher').val($(this).html());
  417. $(this).closest('.mtCentent').find('#main-teacher').attr('teacher_id',$(this).attr('id'));
  418. $(this).closest('.mtCentent').find('#main-teacher').attr('title',$(this).html());
  419. $('#bzr_id').val($(this).attr('id'));
  420. $(this).closest('.mtCentent').find('.name-con').hide();
  421. })
  422. //提交保存
  423. $('#schoolSubmit').click(function(){
  424. var className=$('input[name=class_name]').val();
  425. if(className==''){
  426. layer.msg('请输入班级名称');
  427. return false;
  428. }
  429. if(className.length>10){
  430. layer.msg('班级名称不能超过10个字符');
  431. return false;
  432. }
  433. var teacher_ids=$('#teacher_ids');
  434. if(teacher_ids.length==0){
  435. layer.msg('请选择执教教师');
  436. return false;
  437. }
  438. if($('#coach_id').val()==''){
  439. layer.msg('请选择助教');
  440. return false;
  441. }
  442. if($('input[name=bzrId]').val()=='0'){
  443. layer.msg('请选择班主任');
  444. return false;
  445. }
  446. });
  447. })
  448. </script>