htb_reset.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <style>
  2. .reset-title{padding-left: 20px; line-height: 40px;font-size: 14px;border-bottom: 1px solid #eee;}
  3. .paper-title{margin-right: 20px;font-weight: bold;}
  4. .chk-all{margin-left: 20px; padding-left:20px; cursor: pointer;background: url(/images/select_no.png) no-repeat left center;-webkit-background-size: 16px;background-size: 16px;}
  5. .chk-all.active{background: url(/images/select_ipt.png) no-repeat left center;-webkit-background-size: 16px;background-size: 16px;}
  6. .chk-num{margin-top: 10px;margin-left: 5px; width: 20px;height: 20px;line-height: 20px; text-align: center;font-style:normal; border-radius: 50%;background-color: #f40;color: #fff;}
  7. .class-box{padding-bottom:50px;}
  8. .class-box ul{padding:20px 0 0 24px;}
  9. .class-box li{position: relative;margin-right: 28px;margin-bottom: 20px; padding:10px 16px;width: 210px;height: 105px; border:1px solid #ccc;box-sizing: border-box;cursor: pointer;}
  10. .class-box li h3{margin:0; width: 180px; font-size: 16px;line-height: 24px; color: #697aff;}
  11. .class-box li p{margin-top: 6px;}
  12. .selected-img{position: absolute;top:50%;right: 10px;transform:translateY(-50%);display: none;}
  13. .class-box li.active,.class-box li:hover{border-color: #2977ff}
  14. .class-box li.active .selected-img{display: block;}
  15. .reset-btn{position: fixed;left: 24px;bottom:0;padding-top:10px;padding-bottom: 16px;width: 100%;background-color: #fff;}
  16. .reset-btn span{color: #f00;}
  17. .reset-btn a{margin-right: 10px; display: inline-block;color: #fff;background-color: grey;width: 100px;line-height: 30px;text-align: center; }
  18. .reset-btn2 a{text-decoration: none;background:#2977ff;}
  19. .reset-btn2 a:hover{text-decoration: none;background-color: #2977ff;}
  20. .reset-num{font-style:normal;}
  21. /*.topic-content*/
  22. .choose-topic h3,.filling-topic h3,.answer-topic h3{font-weight: 700;font-size: 14px;line-height: 34px;}
  23. .topic a{margin:0 5px; color: #4395ff}
  24. .topic p{display: inline;}
  25. .batch_topic a{margin:0 5px; color: #4395ff}
  26. .batch_topic p{display: inline;}
  27. /*.topic .score{color: #f00;}*/
  28. .score input,.right-answer{width: 30px;text-align: center; background: #fff;border:0;color: #50d2c2}
  29. .score input:focus,.right-answer:focus{border:1px solid #50d2c2;outline: none;}
  30. /*.right-answer{color: #f40;}*/
  31. .topic-answer input{width: 60px;}
  32. .model-score input{padding-left: 5px; height: 30px;width: 230px;border:1px solid #ccc;outline: none;}
  33. .model-score input:focus{border-color: #50d2c2;box-shadow: 0 0 5px #50d2c2;}
  34. .modal-btn{text-align: center;margin:10px 0;}
  35. .modal-btn a{display: inline-block;margin:0 5px; width: 100px; line-height: 40px;background: #50d2c2;color: #fff;}
  36. .modal-content{position: absolute;left: 50%;top: 50%;padding-top: 40px; width: 500px;background: #fff; transform: translate(-50%,-50%);}
  37. .modal-title{position: absolute;top: 0;left: 0;padding-left: 20px; width: 100%;height: 40px;line-height: 40px;background: #009965;color:#fff;}
  38. .modal-title em{width: 40px;height: 40px;text-align: center;font-size: 20px;cursor: pointer;}
  39. .model-score1 input{padding-left: 5px; height: 30px;width: 230px;border:1px solid #ccc;outline: none;}
  40. .model-score1 input:focus{border-color: #50d2c2;box-shadow: 0 0 5px #50d2c2;}
  41. .modal-btn{text-align: center;margin:10px 0;}
  42. .modal-btn a{display: inline-block;margin:0 5px; width: 100px; line-height: 40px;background: #50d2c2;color: #fff;}
  43. .model-score2 input{padding-left: 5px; height: 30px;width: 230px;border:1px solid #ccc;outline: none;}
  44. .model-score2 input:focus{border-color: #50d2c2;box-shadow: 0 0 5px #50d2c2;}
  45. .modal-btn{text-align: center;margin:10px 0;}
  46. .modal-btn a{display: inline-block;margin:0 5px; width: 100px; line-height: 40px;background: #009965;color: #fff;}
  47. .modal-btn .close3{display: inline-block;margin:0 5px; width: 100px; line-height: 40px;background: #fff;color: #000;border:1px solid #555;border-radius: 3px;}
  48. .modal1_multi{position: fixed;top: 0;left: 0;width: 100%;height: 100%;font-size:14px;display:none ;background: rgba(0,0,0,.4)}
  49. .model-rule{width:80%;margin:15px auto;text-align: center;font-size:18px;}
  50. .modal1_multi .model-score1{width:80%;margin:10px auto;text-align: left}
  51. .modal1_multi .model-score-m{width:80%;margin:5px auto;}
  52. #update_msg{color:red}
  53. .modal1_multi .model-score-m label{margin:5px 0;font-size: 12px;color:red;font-weight: initial}
  54. </style>
  55. <div class="reset-title clearfix">
  56. <span class="fl paper-title"><?php echo isset($data[0]['name'])?$data[0]['name']:'';?></span>
  57. <div class="fl">
  58. <span class="fl">参考班级</span>
  59. <span class="chk-all fl">全选</span>
  60. <em class="fl chk-num reset-num">0</em>
  61. </div>
  62. </div>
  63. <!--好题本组id-->
  64. <input type="hidden" value="<?php echo $htb_group_id; ?>" class="data-htb-group-id"/>
  65. <div class="class-box">
  66. <ul class="clearfix" id="select-class">
  67. <?php foreach($data as $key => $value):?>
  68. <li class="fl" htbId="<?php echo $value['htb_id'];?>">
  69. <div class="fl">
  70. <h3 class="ellipsis"><?php echo $value['class_name'];?></h3>
  71. <p>已生成/总数:<?php echo $value['create_count'];?>/<?php echo $value['total_count'];?></p>
  72. </div>
  73. <img src="/images/select_li.png" class="selected-img">
  74. </li>
  75. <?php endforeach;?>
  76. </ul>
  77. </div>
  78. <div class="reset-btn">
  79. <a href="javascript:;">重置</a>
  80. <span>您将重置<em class="reset-num">0</em>个班级的 好题本
  81. </span>
  82. </div>
  83. <!-- 重置提示框 -->
  84. <div class="modal1_multi">
  85. <div class="modal-shadow"></div>
  86. <div class="modal-content">
  87. <div class="modal-title clearfix">
  88. 提示<em class="fr close3">×</em>
  89. </div>
  90. <div class="model-rule">
  91. 同一场考试,只提供一次重置机会。 <br>确定需要重置吗?
  92. </div>
  93. <div class="model-score-m">
  94. <label>产品生成会占用服务器资源,请谨慎操作,重置后需排队等待哦!</label>
  95. </div>
  96. <div class="modal-btn">
  97. <a href="javascript:;" class="sumbit3">确定重置</a>
  98. <a href="javascript:;" class="close3 chameleon">取消</a>
  99. </div>
  100. </div>
  101. </div>
  102. <script>
  103. $(function () {
  104. resetCount=parseInt(<?php echo $resetCount;?>);
  105. $(".reset-btn a").click(function () {
  106. //判断重置次数
  107. if(resetCount==0){
  108. $('.model-rule').html('本周“好题本”只提供一次重置机会。 <br>确定需要重置吗?');
  109. $('.sumbit3').show();
  110. $('.chameleon').html('取消');
  111. $('.model-score-m').show();
  112. $('.modal1_multi').show();
  113. }else{
  114. $('.model-score-m').hide();
  115. $('.sumbit3').hide();
  116. $('.chameleon').html('知道了');
  117. $('.model-rule').html('本周“好题本”已重置,不能继续重置!<br>请联系技术支持,谢谢!');
  118. $('.modal1_multi').show();
  119. }
  120. });
  121. $('.close3').click(function(){
  122. $('.modal1_multi').hide();
  123. });
  124. $('.sumbit3').click(function(){
  125. doSubmit();
  126. });
  127. //提交重置
  128. function doSubmit(){
  129. var obj = $("#select-class>li.active");
  130. var selectHtbIds = [];
  131. $.each(obj, function(key, value) {
  132. selectHtbIds.push($(value).attr('htbId'));
  133. });
  134. var htbGroupId=$('.data-htb-group-id').val();
  135. if(htbGroupId==0 || htbGroupId==''){
  136. layer.msg('好题本组id为空,请稍后重试!',{
  137. icon: 5
  138. }, function(){
  139. layer.closeAll();
  140. });
  141. return false;
  142. }
  143. if(selectHtbIds.length > 0){
  144. var url = "<?php echo $this->createUrl('htb/ajaxResetHtb');?>";
  145. resetAction(selectHtbIds,url,htbGroupId);
  146. }else{
  147. layer.msg('请选择班级!',{
  148. icon: 5
  149. }, function(){
  150. layer.closeAll();
  151. });
  152. }
  153. }
  154. $(".chk-all").click(function () {
  155. if ($(this).hasClass("active")) {
  156. $(this).removeClass("active");
  157. $(".class-box li").removeClass("active");
  158. $(".reset-num").html(0);
  159. $(".reset-btn").removeClass('reset-btn2');
  160. } else {
  161. $(this).addClass("active");
  162. $(".class-box li").addClass("active");
  163. $(".reset-num").html($(".class-box li").length);
  164. $(".reset-btn").addClass('reset-btn2');
  165. }
  166. });
  167. $("body").delegate(".class-box li", "click", function () {
  168. var count = 0;
  169. if ($(this).hasClass("active")) {
  170. $(this).removeClass("active");
  171. } else {
  172. $(this).addClass("active");
  173. }
  174. for (var i = 0; i < $(".class-box li").length; i++) {
  175. if ($(".class-box li").eq(i).hasClass("active")) {
  176. count++;
  177. }
  178. if(count > 0){
  179. $(".reset-btn").addClass('reset-btn2');
  180. }else{
  181. $(".reset-btn").removeClass('reset-btn2');
  182. }
  183. }
  184. if (count == $(".class-box li").length) {
  185. $(".chk-all").addClass("active");
  186. } else {
  187. $(".chk-all").removeClass("active");
  188. }
  189. $(".reset-num").html(count);
  190. });
  191. // toast("重置失败!请再次尝试")
  192. // toast("重置失败!请再次尝试",true)
  193. function toast(msg, flag) {
  194. /*flag参数为true,不能自动关闭,不传则3秒以后关闭*/
  195. $("body").append("<div class='toast'></div>");
  196. $(".toast").css({
  197. "position": "fixed",
  198. "left": "50%",
  199. "top": "50%",
  200. "transform": "translate(-50%,-50%)",
  201. "padding": "15px 25px",
  202. "max-width": "250px",
  203. "background": "rgba(0,0,0,.8)",
  204. "color": "#fff",
  205. "font-size": "14px",
  206. "border-radius": "5px",
  207. "display": "none",
  208. "z-index": "9999999"
  209. }).html(msg).fadeIn(400);
  210. if (flag)
  211. return;
  212. var tempTimer = setTimeout(function () {
  213. $(".toast").fadeOut(400).remove();
  214. clearTimeout(tempTimer)
  215. }, 3000)
  216. }
  217. function resetAction(htbIds,url,htbGroupId){
  218. $.ajax({
  219. url: url,
  220. type: "POST",
  221. dataType: "json",
  222. data: {htbIds:htbIds,htbGroupId:htbGroupId},
  223. success: function (data){
  224. if(data.status > 0){
  225. layer.msg('操作成功!自动返回上一层',{
  226. icon: 1
  227. }, function(){
  228. layer.closeAll();
  229. window.history.go(-1);
  230. });
  231. }else{
  232. layer.msg('操作失败!请再次尝试',{
  233. icon: 5
  234. }, function(){
  235. layer.closeAll();
  236. });
  237. }
  238. },
  239. error: function (data, status, e){ //服务器响应失败处理函数
  240. layer.msg('返回失败!',{
  241. icon: 5
  242. }, function(){
  243. layer.closeAll();
  244. });
  245. }
  246. });
  247. }
  248. })
  249. </script>