index.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  1. <link rel="stylesheet" href="/css/learning-group.css">
  2. <div class="learning-group">
  3. <div class="btn-top-box clearfix">
  4. <a href="<?php echo $this->createUrl('classes/view/cid/'.$cid)?>" class="btn-back fl">返回</a>
  5. <!--<span class="btn-save fr" id="btn-learning-group-save" >保存</span>-->
  6. </div>
  7. <div class="group-box">
  8. <?php
  9. if(isset($teamData) && $teamData){
  10. foreach ($teamData as $val){
  11. ?>
  12. <div class="group" code="<?php echo $val['team_id']?>" id="<?php echo $val['team_id']?>">
  13. <div class="group-top">
  14. <span class="group-name"><?php echo $val['team_name']?></span>
  15. <span class="group-user-number">(<span><?php echo count($val['student'])?></span>人)</span>
  16. <span class="btn-edit-group-name fr"><img src="/images/icon-edit.svg" alt=""></span>
  17. </div>
  18. <div class="group-content">
  19. <?php
  20. if(isset($val['student']) && $val['student']){
  21. echo '<div class="group-list-box" >';
  22. echo '<table border="0" class="table-group-list">';
  23. echo '<tr>';
  24. echo '<td></td>';
  25. echo '<td>学生姓名</td>';
  26. echo '<td>系统准考证号</td>';
  27. echo '</tr>';
  28. foreach ($val['student'] as $v){
  29. echo '<tr>';
  30. echo '<td><img src="/images/icon-delete-student.svg" class="btn-delete-group-student" code="'.$v['student_id'].'" alt=""></td>';
  31. echo '<td>'.$v['real_name'].'</td>';
  32. echo '<td>'.$v['student_card'].'</td>';
  33. echo '</tr>';
  34. }
  35. echo '</table>';
  36. echo '</div>';
  37. ?>
  38. <?php
  39. }else{
  40. ?>
  41. <div class="group-list-box">
  42. <div class="btn-add-student-2 layer-add-student">
  43. <img src="/images/icon-add-student-2.svg" alt="">
  44. <span>请添加小组成员</span>
  45. </div>
  46. </div>
  47. <?php
  48. }
  49. ?>
  50. <div class="btn-group-bottom-box">
  51. <div class="btn-group-bottom-add-box">
  52. <span class="btn-delete-group"><img src="/images/icon-delete.svg" alt=""></span>
  53. <span class="btn-add-student layer-add-student"><img src="/images/icon-add-student1.svg" alt=""></span>
  54. </div>
  55. <div class="btn-group-bottom-delete-box">
  56. <span class="btn-delete-all-group">整组删除</span>
  57. <span class="btn-delete-group-save" >完成</span>
  58. </div>
  59. </div>
  60. </div>
  61. <div class="dialog-delete-all-group-student">
  62. <p class="dialog-delete-student">确定删除“<?php echo $val['team_name']?>”中的全部学生吗?</p>
  63. <p class="dialog-delete-team hide">确定删除分组“<?php echo $val['team_name']?>”吗?</p>
  64. <div class="btn-dialog-delete-all-group-student-box">
  65. <span class="btn-dialog-delete-all-group-student-save">确定</span>
  66. <span class="btn-dialog-delete-all-group-student-colse">取消</span>
  67. </div>
  68. </div>
  69. </div>
  70. <?php
  71. }
  72. }
  73. ?>
  74. <div class="group">
  75. <div class="group-top">
  76. </div>
  77. <div class="group-content">
  78. <div class="btn-add-group">
  79. <img src="/images/icon-add-group.svg" alt="">
  80. <span>新建小组</span>
  81. </div>
  82. </div>
  83. </div>
  84. </div>
  85. </div>
  86. <!-- 新增小组弹窗 -->
  87. <div class="dialog-set-group-name">
  88. <div class="set-group-name-title">
  89. <span>请设置小组名称</span>
  90. <img src="/images/icon-close.svg" alt="" class="btn-set-group-name-colse-1 btn-colse fr">
  91. </div>
  92. <div class="set-group-name-main">
  93. <div class="set-group-name-content">
  94. <span >小组名称:</span>
  95. <span class="set-group-name-wrap">
  96. <input type="text" name="team_new_name" class="input-set-group-name" maxlength="10">
  97. <input type="hidden" name="edit_team_id" value="0">
  98. </span>
  99. </div>
  100. <div class="btn-set-group-name-box">
  101. <span class="btn-set-group-name-colse btn-colse">取消</span>
  102. <span class="btn-set-group-name-save">保存</span>
  103. </div>
  104. </div>
  105. </div>
  106. <!-- 添加小组成员弹窗 -->
  107. <div class="dialog-add-group-student">
  108. <div class="add-group-student-title">
  109. <span>添加小组成员</span>
  110. <img src="/images/icon-close.svg" alt="" class="btn-add-group-student-colse-1 btn-colse fr">
  111. </div>
  112. <div class="add-group-student-content">
  113. <form >
  114. <table border="0" class="table-add-group-student">
  115. </table>
  116. <input type="hidden" name="team_id" value="0">
  117. </form>
  118. </div>
  119. <div class="btn-add-group-student-box">
  120. <span class="btn-add-group-student-colse btn-colse">取消</span>
  121. <span class="btn-add-group-student-save">确认添加</span>
  122. </div>
  123. </div>
  124. <script>
  125. $(document).ready(function() {
  126. var class_id='<?php echo $cid?>';
  127. //弹出新增小组
  128. $('.btn-add-group').on('click', function(){
  129. layer.open({
  130. title: false,
  131. closeBtn: 0,
  132. type: 1,
  133. area: ['610px', '242px'],
  134. content: $(".dialog-set-group-name")
  135. });
  136. });
  137. //关闭新增小组
  138. $(".btn-colse").on("click", function() {
  139. $('input[name=edit_team_id]').val(0);
  140. $('input[name=team_new_name]').val('');
  141. layer.close(layer.index);
  142. });
  143. $('.group-box')
  144. .on('click','.btn-delete-all-group',function () {
  145. var count=parseInt($(this).closest('.group').find('.group-user-number span').html());
  146. if(count>0){
  147. $(this).parents('.group').children('.dialog-delete-all-group-student').find('.dialog-delete-student').removeClass('hide');
  148. $(this).parents('.group').children('.dialog-delete-all-group-student').find('.dialog-delete-team').addClass('hide');
  149. }else{
  150. $(this).parents('.group').children('.dialog-delete-all-group-student').find('.dialog-delete-student').addClass('hide');
  151. $(this).parents('.group').children('.dialog-delete-all-group-student').find('.dialog-delete-team').removeClass('hide');
  152. }
  153. $(this).parents('.group').children('.dialog-delete-all-group-student').css('display','block');
  154. var team_name=$(this).closest('.group').find('.group-name').html();
  155. var team_id=$(this).closest('.group').attr('code');
  156. })
  157. //删除单个学生按钮
  158. .on('click','.btn-delete-group-student',function(){
  159. // 获取单个学生
  160. codes=$(this).attr('code');
  161. var obj=$(this);
  162. var _group = $(this).parents('.group');
  163. var count_obj=obj.closest('.group').find('.group-user-number span');
  164. var count=parseInt(count_obj.html());
  165. //删除单个学生
  166. $.ajax({
  167. url:'<?php echo $this->createUrl('team/del_student')?>',
  168. type:'POST',
  169. dataType:'json',
  170. data:{'cid':class_id,'student_id':$(this).attr('code')},
  171. success:function(res){
  172. if(res.status==1){
  173. obj.parents('tr').detach();
  174. if(count-1>=0){
  175. count_obj.html(--count);
  176. }
  177. if(count==0){
  178. console.log('222');
  179. var addHtml=' <div class="group-list-box">\n' +
  180. ' <div class="btn-add-student-2 layer-add-student">\n' +
  181. ' <img src="/images/icon-add-student-2.svg" alt="">\n' +
  182. ' <span>请添加小组成员</span>\n' +
  183. ' </div>\n' +
  184. ' </div>';
  185. // obj.closest('.group').find('.btn-group-bottom-box').before('<p>12312</p>');
  186. console.log(_group,8989);
  187. _group.find('.group-list-box').html(addHtml);
  188. _group.find('.btn-delete-group-save').click();
  189. }
  190. }else{
  191. layer.msg(res.msg);
  192. }
  193. }
  194. });
  195. })
  196. .on('click','.layer-add-student',function(){
  197. var team_id=$(this).closest('.group').attr('code');
  198. //加载学生列表
  199. $.ajax({
  200. url:'<?php echo $this->createUrl('team/getstudent')?>',
  201. type:'POST',
  202. dataType:'json',
  203. data:{'cid':class_id},
  204. success:function(res){
  205. if(res.status==1){
  206. $('.table-add-group-student').html(res.data);
  207. $('input[name=team_id]').val(team_id);
  208. layer.open({
  209. title: false,
  210. closeBtn: 0,
  211. type: 1,
  212. area: ['976px', '580px'],
  213. content: $(".dialog-add-group-student")
  214. });
  215. }
  216. }
  217. });
  218. })
  219. //确认删除整组学生按钮
  220. .on('click','.btn-dialog-delete-all-group-student-save',function(){
  221. //获取整组学生
  222. var codes = $(this).parents('.group').attr('code');
  223. var obj=$(this);
  224. var student_count=parseInt(obj.closest('.group').find('.group-user-number span').html());
  225. console.log(student_count);
  226. $.ajax({
  227. url:'<?php echo $this->createUrl('team/del_team')?>',
  228. type:'POST',
  229. dataType:'json',
  230. data:{'team_id':codes},
  231. success:function(res){
  232. if(res.status==1){
  233. obj.parents('.group').find('.table-group-list').detach();
  234. $('#'+codes).find('.group-user-number span').html(0);
  235. obj.parents('.group').children('.dialog-delete-all-group-student').css('display','none');
  236. var addHtml=' <div class="btn-add-student-2 layer-add-student">\n' +
  237. ' <img src="/images/icon-add-student-2.svg" alt="">\n' +
  238. ' <span>请添加小组成员</span>\n' +
  239. ' </div>' ;
  240. obj.parents('.group').find('.group-list-box').html(addHtml);
  241. obj.parents('.group').find('.btn-delete-group-save').click();
  242. if(student_count==0){
  243. obj.closest('.group').remove();
  244. }
  245. }else{
  246. layer.msg(res.msg);
  247. }
  248. }
  249. });
  250. })
  251. //取消删除整组学生按钮
  252. .on('click','.btn-dialog-delete-all-group-student-colse',function(){
  253. $(this).parents('.group').children('.dialog-delete-all-group-student').css('display','none');
  254. })
  255. .on('click','.btn-delete-group',function(){
  256. $(this).parent().css('display','none');
  257. $(this).parents('.btn-group-bottom-box').find('.btn-group-bottom-delete-box').css('display','block');
  258. $(this).parents('.group-content').children('.group-list-box').find('.btn-delete-group-student').css('display','inline-table');
  259. })
  260. .on('click','.btn-delete-group-save',function(){
  261. $(this).parent().css('display','none');
  262. $(this).parents('.btn-group-bottom-box').find('.btn-group-bottom-add-box').css('display','block');
  263. $(this).parents('.group-content').children('.group-list-box').find('.btn-delete-group-student').css('display','none');
  264. })
  265. //添加学生确认
  266. $(".btn-add-group-student-save").on("click", function() {
  267. var check_val = [];
  268. var realname = [];
  269. var student_card = [];
  270. var studentArr = $(this).parents('.dialog-add-group-student').find('.table-add-group-student').find('input[name="student-list"]:checked').each(function(){
  271. check_val.push($(this).val());
  272. realname.push($(this).closest('tr').find('.realname').html());
  273. student_card.push($(this).closest('tr').find('.student_card').html());
  274. });
  275. if(check_val.length>0){
  276. var team_id=$('input[name=team_id]').val();
  277. var count=parseInt($('#'+team_id).find('.group-user-number span').html())+check_val.length;
  278. var group_list_box=$('#'+team_id).find('.group-list-box');
  279. var list=$('#'+team_id).find('.table-group-list');
  280. var old_html=list.html();
  281. var add_html='';
  282. if(old_html==undefined){
  283. add_html+='<table border="0" class="table-group-list">';
  284. add_html+='<tr>';
  285. add_html+='<td></td>';
  286. add_html+='<td>学生姓名</td>';
  287. add_html+='<td>系统准考证号</td>';
  288. add_html+='</tr>';
  289. }
  290. for(var i=0;i<check_val.length;i++){
  291. add_html+='<tr>';
  292. add_html+='<td><img src="/images/icon-delete-student.svg" class="btn-delete-group-student" code="'+check_val[i]+'" alt=""></td>';
  293. add_html+='<td>'+realname[i]+'</td>';
  294. add_html+='<td>'+student_card[i]+'</td>';
  295. add_html+='</tr>';
  296. }
  297. if(old_html==undefined){
  298. add_html+='</table>';
  299. }
  300. $.ajax({
  301. url:'<?php echo $this->createUrl('team/add_student')?>',
  302. type:'POST',
  303. dataType:'json',
  304. data:{'cid':class_id,'team_id':team_id,'student_id':check_val,'realname':realname,'student_card':student_card},
  305. success:function(res){
  306. if(res.status==1){
  307. if(old_html==undefined){
  308. group_list_box.html(add_html);
  309. }else{
  310. list.html(old_html+add_html);
  311. }
  312. $('#'+team_id).find('.group-user-number span').html(count);
  313. layer.close(layer.index);
  314. }
  315. }
  316. });
  317. }
  318. //layer.close(layer.index);
  319. //console.log(check_val);
  320. });
  321. //编辑,新增小组
  322. $('.btn-set-group-name-save').click(function(){
  323. var team_name=$('input[name=team_new_name]').val();
  324. var team_id=$('input[name=edit_team_id]').val();
  325. if(team_name=='' || team_name==undefined){
  326. return false;
  327. }
  328. layer.close(layer.index);
  329. $('input[name=edit_team_id]').val(0);
  330. $('input[name=team_new_name]').val('');
  331. var lyi=layer.msg('正在提交,请稍候......',{time:0});
  332. $.ajax({
  333. url:'<?php echo $this->createUrl('team/add_team')?>',
  334. type:'POST',
  335. dataType:'json',
  336. data:{'cid':class_id,'team_name':team_name,'team_id':team_id},
  337. success:function(res){
  338. if(res.status==1){
  339. if(team_id==0){
  340. // window.location.reload();
  341. var html='<div class="group" code="'+res.team_id+'" id="'+res.team_id+'"><div class="group-top">';
  342. html+='<span class="group-name">'+team_name+'</span>';
  343. html+='<span class="group-user-number">(<span>0</span>人)</span>';
  344. html+='<span class="btn-edit-group-name fr"><img src="/images/icon-edit.svg" alt=""></span>';
  345. html+='</div>';
  346. html+='<div class="group-content">';
  347. html+='<div class="group-list-box">';
  348. html+=' <div class="btn-add-student-2 layer-add-student">\n' +
  349. ' <img src="/images/icon-add-student-2.svg" alt="">\n' +
  350. ' <span>请添加小组成员</span>\n' +
  351. ' </div></div>';
  352. html+=' <div class="btn-group-bottom-box">\n'+
  353. ' <div class="btn-group-bottom-add-box">\n'+
  354. ' <span class="btn-delete-group"><img src="/images/icon-delete.svg" alt=""></span>\n'+
  355. ' <span class="btn-add-student layer-add-student"><img src="/images/icon-add-student1.svg" alt=""></span>\n'+
  356. ' </div>\n'+
  357. ' <div class="btn-group-bottom-delete-box">\n'+
  358. ' <span class="btn-delete-all-group">整组删除</span>\n'+
  359. ' <span class="btn-delete-group-save" >完成</span>\n'+
  360. ' </div>\n'+
  361. ' </div>\n'+
  362. ' </div>\n'+
  363. ' <div class="dialog-delete-all-group-student">\n'+
  364. ' <p>确定删除'+team_name+'</p>\n'+
  365. ' <div class="btn-dialog-delete-all-group-student-box">\n'+
  366. ' <span class="btn-dialog-delete-all-group-student-save">确定</span>\n'+
  367. ' <span class="btn-dialog-delete-all-group-student-colse">取消</span>\n'+
  368. ' </div>\n'+
  369. ' </div>';
  370. html+='</div>';
  371. html+='</div>';
  372. html+='</div>';
  373. $('.btn-add-group').closest('.group').before(html);
  374. layer.msg('添加成功');
  375. }else{
  376. $('#'+team_id).find('.group-name').html(team_name);
  377. layer.msg('编辑成功');
  378. }
  379. }else{
  380. if(res.msg!=undefined){
  381. layer.msg(res.msg);
  382. }else{
  383. layer.msg('提交失败')
  384. }
  385. }
  386. }
  387. });
  388. });
  389. //编辑小组
  390. $(document)
  391. .on('click','.btn-edit-group-name',function(){
  392. var team_id=$(this).closest('.group').attr('code');
  393. var team_name=$(this).closest('.group').find('.group-name').html();
  394. $('input[name=edit_team_id]').val(team_id);
  395. $('input[name=team_new_name]').val(team_name);
  396. layer.open({
  397. title: false,
  398. closeBtn: 0,
  399. type: 1,
  400. area: ['610px', '242px'],
  401. content: $(".dialog-set-group-name")
  402. });
  403. })
  404. });
  405. </script>