trialStudent.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  6. <title>试用人数</title>
  7. <meta name="description" content="">
  8. <meta name="keywords" content="">
  9. <link href="/css/ims/base.css" rel="stylesheet">
  10. <link rel="stylesheet" type="text/css" href="/css/ims/bootstrap.min.css" />
  11. <link rel="stylesheet" type="text/css" href="/css/ims/ace.min.css"/>
  12. <link href="/css/ims/ims.css" rel="stylesheet">
  13. <style>
  14. .ims-box {
  15. margin-top: 5px;
  16. margin-left: 20px;
  17. margin-right: 20px;
  18. }
  19. .screen {
  20. padding-left: 20px;
  21. height: 44px;
  22. line-height: 44px;
  23. background-color: #eff4fa;
  24. }
  25. .screen li {
  26. float: left;
  27. margin-right: 65px;
  28. }
  29. .bg-d9bf6e {
  30. margin-left: 5px;
  31. padding: 0 20px;
  32. color: #fff;
  33. background-color: #d9bf6e;
  34. }
  35. .number{
  36. margin-top: 10px;
  37. }
  38. .ims-add-student-box {
  39. margin: 20px;
  40. }
  41. .ims-add-student-box p{
  42. margin: 0;
  43. }
  44. .ims-add-student-box .ims-title{
  45. font-size: 20px;
  46. font-weight: bold;
  47. }
  48. .ims-add-student-box .ims-title span{
  49. margin-right: 20px;
  50. }
  51. .ims-add-student-box .add-student-box {
  52. margin-top: 20px;
  53. font-size: 0;
  54. overflow: hidden;
  55. }
  56. .ims-add-student-box .add-student-box>div{
  57. display: inline-block;
  58. height: 530px;
  59. font-size: 14px;
  60. vertical-align: top;
  61. }
  62. .ims-add-student-box .add-student-box .add-student-title{
  63. padding: 0 8px;
  64. line-height: 30px;
  65. color: #fff;
  66. background-color: #2977ff;
  67. }
  68. .ims-add-student-box .add-student-box .add-student-title label{
  69. font-size: 14px;
  70. font-weight: normal;
  71. cursor: pointer;
  72. margin-bottom: 0;
  73. }
  74. .ims-add-student-box .add-student-box .add-student-title input{
  75. vertical-align: middle;
  76. margin: 0;
  77. }
  78. #input-search-student{
  79. width: 120px;
  80. height: 20px;
  81. border: 0;
  82. color:#000;
  83. }
  84. .ims-add-student-box .add-student-box{
  85. line-height: 30px;
  86. min-width: 938px;
  87. }
  88. .ims-add-student-box .add-student-box .class-box {
  89. width: 180px;
  90. text-align: center;
  91. border: 1px solid #ccc;
  92. }
  93. .ims-add-student-box .student-list div{
  94. font-size: 14px;
  95. font-weight: normal;
  96. }
  97. .ims-add-student-box .add-student-box .class-list{
  98. height: 500px;
  99. overflow: auto;
  100. }
  101. .ims-add-student-box .add-student-box .class-list li{
  102. border-bottom: 1px solid #ccc;
  103. cursor: pointer;
  104. }
  105. .ims-add-student-box .class-list .active{
  106. color: #629aff;
  107. }
  108. .ims-add-student-box .add-student-box .student-list{
  109. margin: 0;
  110. width: 34%;
  111. min-width: 326px;
  112. border: 1px solid #ccc;
  113. border-left: 0;
  114. }
  115. .ims-add-student-box .student-list-content,.selected-list-content{
  116. padding: 8px;
  117. height: 500px;
  118. overflow: auto;
  119. }
  120. .ims-add-student-box .student-list-content label,.selected-list-content label{
  121. display: inline-block;
  122. width: 150px;
  123. cursor: pointer;
  124. font-size: 14px;
  125. font-weight: normal;
  126. }
  127. .ims-add-student-box .btn-search-student{
  128. height: 20px;
  129. line-height: 20px;
  130. padding: 0 5px;
  131. border-radius: 3px;
  132. color: #629aff;
  133. background-color: #2977ff;
  134. border: none;
  135. outline: none;
  136. cursor: pointer;
  137. }
  138. .ims-add-student-box .btns-box {
  139. width: 100px;
  140. text-align: center;
  141. }
  142. .ims-add-student-box .btn-left,.ims-add-student-box .btn-right{
  143. margin: 150px auto 0;
  144. width: 40px;
  145. height: 40px;border: 1px solid #ccc;
  146. border-radius: 50%;
  147. background-color: #fff;
  148. text-align: center;
  149. line-height: 40px;
  150. cursor: pointer;
  151. }
  152. .ims-add-student-box .selected-list{
  153. width: 34%;
  154. min-width: 326px;
  155. border: 1px solid #ccc;
  156. }
  157. .ims-add-student-box .btn-confirm_purchase {
  158. display: block;
  159. margin: 0 auto;
  160. margin-top: 100px;
  161. margin-bottom: 50px;
  162. width: 200px;
  163. line-height: 54px;
  164. color: #fff;
  165. font-family: PingFangSC-Regular, "PingFang SC";
  166. font-weight: 400;
  167. font-style: normal;
  168. font-size: 20px;
  169. text-align: center;
  170. background-color: #2977ff;
  171. cursor: pointer;
  172. }
  173. .yiiPager li{display: inline}
  174. .clear{clear: both}
  175. </style>
  176. </head>
  177. <body>
  178. <div class="ims-box">
  179. <div class="screen">
  180. <ul>
  181. <li><span class="product">试用商品</span><span class="product-name bg-d9bf6e"><?php echo $goodDetail['goodsTypeName'];?></span></li>
  182. <li><span class="grade">试用年级</span><span class="grade-name bg-d9bf6e"><?php echo $goodDetail['gradeName'];?></span></li>
  183. <li><span class="date">试用时间</span><span class="date-name bg-d9bf6e"><?php echo $goodDetail['date'];?></span></li>
  184. <li><span class="type">状态</span><span class="type-name bg-d9bf6e"><?php echo $goodDetail['status'];?></span></li>
  185. <li><span class="type">开启人数</span><span class="type-name bg-d9bf6e"><?php echo $goodDetail['enableNum'];?>/<?php echo $page['total'];?></span></li>
  186. </ul>
  187. </div>
  188. <div class="number">
  189. <table id="record-table" class="table table-striped table-bordered table-hover dataTable no-footer DTTT_selectable" style="font-size:12px">
  190. <thead>
  191. <tr>
  192. <th>序号</th>
  193. <th>学生姓名</th>
  194. <th>班级</th>
  195. </tr>
  196. </thead>
  197. <tbody>
  198. <?php if ($list):?>
  199. <?php foreach ($list as $k=>$item):?>
  200. <tr>
  201. <td><?php echo $k+1;?></td>
  202. <td><?php echo $item['studentName']?></td>
  203. <td><?php echo $item['clazzName']?></td>
  204. </tr>
  205. <?php endforeach;?>
  206. <?php else:?>
  207. <tr><td colspan="3">暂无数据</td></tr>
  208. <?php endif;?>
  209. </tbody>
  210. </table>
  211. <div>
  212. <?php if ($page): ?>
  213. <div class="col-sm-12" style="float: left;width:70%;">
  214. <ul class="pagination">
  215. <?php
  216. $params = array();
  217. if (isset($_GET['orderId']) && $_GET['orderId']) {
  218. $params['orderId'] = $_GET['orderId'];
  219. }
  220. if (isset($_GET['page'])) {
  221. $params['page'] = $_GET['page'];
  222. }else{
  223. $params['page'] = 1;
  224. }
  225. echo formatPage($page, 'imsSale/trialStudent', $params)
  226. ?>
  227. </ul>
  228. </div>
  229. <?php endif; ?>
  230. <div style="float: right;width:180px;text-align: right;padding-top:20px;">
  231. <button type="button" class="label-primary-s bth-s start " >部分开启</button>
  232. <button type="button" class="label-primary-s bth-s stop" >部分暂停</button>
  233. </div>
  234. </div>
  235. </div>
  236. <div class="clear"></div>
  237. <div class="layer-edit">
  238. <div class="ims-add-student-box">
  239. <h2 class="ims-title"><span>添加学生</span></h2>
  240. <div class="reason-div">
  241. <br>重启原因及备注:<br>
  242. <textarea rows="3" cols="80" class="use-explain reason" name="mark"></textarea>
  243. </div>
  244. <div class="add-student-box">
  245. <div class="class-box">
  246. <div class="add-student-title">
  247. <p>班级</p>
  248. </div>
  249. <ul class="class-list">
  250. <li class="active">一班</li>
  251. <li>二班</li>
  252. <li>三班</li>
  253. </ul>
  254. </div>
  255. <div class="student-list">
  256. <div class="add-student-title clearfix">
  257. <span class="fl">
  258. <label>
  259. <input type="checkbox" name="select-all" value="1" /><span class="msg1">已开启</span>
  260. </label>
  261. <span></span>
  262. </span>
  263. <span class="fr">
  264. </span>
  265. </div>
  266. <div class="student-list-content" id="studentListContent">
  267. </div>
  268. </div>
  269. <div class="btns-box">
  270. <p class="btn-left" id="btnRemoveStudent"><</p>
  271. <p class="btn-right" id="btnAddStudent" >></p>
  272. </div>
  273. <div class="selected-list">
  274. <div class="add-student-title">
  275. <p><span class="msg2">已开启</span>(<span id="studentSelectedLength">0</span>人)</p>
  276. </div>
  277. <div class="selected-list-content" id="selectedListContent">
  278. </div>
  279. </div>
  280. </div>
  281. <input type="hidden" name="actionType" value="">
  282. <button type="button" class="label-primary-s bth-s cancel" style="float: left;margin-top:5px;margin-left:45%" >返回</button>
  283. <button type="button" class="label-primary-s bth-s save" style="float: left;margin-top:5px;" >保存</button>
  284. </div>
  285. </div>
  286. </div>
  287. </body>
  288. <script src="/js/jquery-2.2.2.min.js" ></script>
  289. <script src="/js/layer/layer.js"></script>
  290. <script>
  291. var orderId='<?php echo $orderId?>';
  292. var canOpen='<?php echo $canOpen?>';
  293. var errMsg='<?php echo $errMsg?>';
  294. var selectedDataAll=[];
  295. var selectedDataValue =[];
  296. var selectedClassId=0;
  297. var selectedClassName='';
  298. $('.cancel').click(function(){
  299. layer.closeAll();
  300. selectedDataAll=[];
  301. selectedDataValue =[];
  302. $('#selectedListContent').html('');
  303. });
  304. $('.save').click(function(){
  305. reason=$('.reason').val();
  306. actionType=$('input[name=actionType]').val();
  307. if(selectedDataValue.length==0){
  308. layer.msg('请选择学生');
  309. return false;
  310. }
  311. if(actionType==1 && (reason=='' || reason==undefined)){
  312. layer.msg('请填写重启原因及备注');
  313. return false;
  314. }
  315. $.ajax({
  316. url:'<?php echo $this->createUrl('imsSale/doStudentOrder')?>',
  317. type:'POST',
  318. dataType:'json',
  319. data:{orderId:orderId,type:actionType,selectedDataValue:selectedDataValue,reason:reason},
  320. success:function (res) {
  321. if(res.status==1){
  322. layer.msg("执行成功");
  323. window.location.reload();
  324. }else{
  325. layer.msg("执行失败");
  326. }
  327. }
  328. });
  329. });
  330. $('.start').click(function(){
  331. if(canOpen!='1'){
  332. layer.msg(errMsg);
  333. return false;
  334. }
  335. selectedDataAll=[];
  336. selectedDataValue =[];
  337. selectedClassId=0;
  338. selectedClassName='';
  339. $('.ims-title').html('部分开启');
  340. $('.msg1').html('已暂停');
  341. $('.msg2').html('已开启');
  342. $('input[name=actionType]').val(1);
  343. $('.reason-div').show();
  344. //请求班级
  345. $.ajax({
  346. url:'<?php echo $this->createUrl('imsSale/getClassesByOrderId')?>',
  347. type:'POST',
  348. dataType:'json',
  349. data:{orderId:orderId,type:0},
  350. success:function (res) {
  351. if(res.status==1){
  352. var html='';
  353. for(var i=0;i<res.data.length;i++){
  354. html+='<li classId="'+res.data[i]['clazzId']+'" rel="0">'+res.data[i]['clazzName']+'</li>';
  355. }
  356. $('.class-list').html(html);
  357. var studentHtml='';
  358. for(var i=0;i<res.students.length;i++){
  359. studentHtml+='<label><input type="checkbox" name="studentName" value="'+res.students[i]['osId']+'" />'+res.students[i]['studentName']+'</label>';
  360. }
  361. $('.student-list-content').html(studentHtml);
  362. var selectStudentIndex=layer.open({
  363. title: false,
  364. closeBtn: 1,
  365. type: 1,
  366. offset: '20px',
  367. area: ['65%', '650px'],
  368. content: $(".layer-edit")
  369. });
  370. }
  371. }
  372. });
  373. });
  374. $('.stop').click(function(){
  375. selectedDataAll=[];
  376. selectedDataValue =[];
  377. selectedClassId=0;
  378. selectedClassName='';
  379. $('.ims-title').html('部分暂停');
  380. $('.msg1').html('已开启');
  381. $('.msg2').html('已暂停');
  382. $('input[name=actionType]').val(0);
  383. $('.reason-div').hide();
  384. $.ajax({
  385. url:'<?php echo $this->createUrl('imsSale/getClassesByOrderId')?>',
  386. type:'POST',
  387. dataType:'json',
  388. data:{orderId:orderId,type:1},
  389. success:function (res) {
  390. if(res.status==1){
  391. var html='';
  392. for(var i=0;i<res.data.length;i++){
  393. html+='<li classId="'+res.data[i]['clazzId']+'" rel="1">'+res.data[i]['clazzName']+'</li>';
  394. }
  395. $('.class-list').html(html);
  396. var studentHtml='';
  397. for(var i=0;i<res.students.length;i++){
  398. studentHtml+='<label><input type="checkbox" name="studentName" value="'+res.students[i]['osId']+'" />'+res.students[i]['studentName']+'</label>';
  399. }
  400. $('.student-list-content').html(studentHtml);
  401. var selectStudentIndex=layer.open({
  402. title: false,
  403. closeBtn: 1,
  404. type: 1,
  405. offset: '20px',
  406. area: ['65%', '650px'],
  407. content: $(".layer-edit")
  408. });
  409. }
  410. }
  411. });
  412. });
  413. //班级切换
  414. $(".class-list").on("click", "li", function(event) {
  415. if(!$(this).hasClass('subjectObj')){
  416. $(".class-list li").removeClass("active");
  417. $(this).addClass("active");
  418. selectedClassId=classId=$(this).attr('classId');
  419. selectType=$(this).attr('rel');
  420. selectedClassName=className=$(this).html();
  421. getStudent(classId,selectType);
  422. }
  423. });
  424. function getStudent(classId,selectType){
  425. $.ajax({
  426. url:'<?php echo $this->createUrl('imsSale/getStudentByClassIdOrderId')?>',
  427. type:'POST',
  428. dataType:'json',
  429. data:{'classId':classId,'orderId':orderId,'type':selectType},
  430. success:function(res){
  431. if(res.status==1){
  432. var studentHtml='';
  433. for(var i=0;i<res.data.length;i++){
  434. studentHtml+='<label><input type="checkbox" name="studentName" classId="'+classId+'" value="'+res.data[i]['osId']+'" />'+res.data[i]['studentName']+'</label>';
  435. }
  436. $('.student-list-content').html(studentHtml);
  437. }else{
  438. $('.student-list-content').html('');
  439. }
  440. }
  441. });
  442. }
  443. // 全选按钮
  444. $("input[name='select-all']").change(function() {
  445. var type = $("input[name='select-all']").prop("checked")
  446. if(type){
  447. obj=$("#studentListContent").find("input");
  448. for(var i=0;i<obj.length;i++){
  449. if(obj.eq(i).attr('disabled')==undefined){
  450. obj.eq(i).prop("checked", true);
  451. }
  452. }
  453. }else{
  454. $("#studentListContent").find("input").prop("checked", false);
  455. }
  456. });
  457. // 添加学生
  458. $("#btnAddStudent").on("click", function() {
  459. getStudentSelected();
  460. });
  461. // 移出学生
  462. $("#btnRemoveStudent").on("click", function() {
  463. removeStudentSelected();
  464. });
  465. function getStudentSelected() {
  466. var selectedData = $("#studentListContent input[name='studentName']:checked"); //获取所以选中学生
  467. var studentName = '';
  468. for (var i = 0; i < selectedData.length; i++) {
  469. if (!isSelected(selectedData[i].value)) {
  470. studentName = $(selectedData[i]).parent().text();
  471. var student ={
  472. name:studentName,
  473. value:selectedData[i].value,
  474. class:$(selectedData[i]).attr('className'),
  475. classId:$(selectedData[i]).attr('classId'),
  476. };
  477. selectedDataAll.push(student);
  478. selectedDataValue.push(selectedData[i].value);
  479. }else{
  480. //console.log(selectedData[i].value)
  481. }
  482. showSelectedStudent();
  483. }
  484. };
  485. function isSelected(val){
  486. return selectedDataValue.indexOf(val) > -1
  487. };
  488. function removeStudentSelected() {
  489. var selectedStudent = $("#selectedListContent input[name='selectedStudent']:checked"); //获取所有选中学生
  490. var selectedData = $("#studentListContent input[name='studentName']:checked"); //获取所以选中学生
  491. for (var i = 0; i < selectedStudent.length; i++) {
  492. $(selectedStudent[i]).parent().remove();
  493. for (var j = 0; j < selectedData.length; j++) {
  494. if(selectedData[j].value===selectedStudent[i].value){
  495. $(selectedData[j]).prop("checked", false);
  496. if(selectedDataValue.length>0){
  497. for(var k=0;k<selectedDataValue.length;k++){
  498. if(selectedDataValue[k]===selectedStudent[i].value){
  499. selectedDataValue.splice(k,1);
  500. selectedDataAll.splice(k,1);
  501. }
  502. }
  503. }
  504. }
  505. }
  506. }
  507. $('#studentSelectedLength').text(selectedDataAll.length);
  508. };
  509. function showSelectedStudent() {
  510. var selectedDataList = [];
  511. for (var i = 0; i < selectedDataAll.length; i++) {
  512. selectedDataList.push('<label><input type="checkbox" name="selectedStudent" value="'+ selectedDataAll[i].value +'" />'+selectedDataAll[i].name+'</label>');
  513. }
  514. $('#selectedListContent').html(selectedDataList);
  515. $('#studentSelectedLength').text(selectedDataAll.length);
  516. };
  517. </script>
  518. </html>