index.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. <style>
  2. /*弹出层*/
  3. .confirmbox-mask {
  4. background: rgba(0, 0, 0, .7);
  5. left: 0;
  6. right: 0;
  7. top: 0;
  8. bottom: 0;
  9. z-index: 99;
  10. position: fixed;
  11. }
  12. .confirmbox-mask button {
  13. border: none;
  14. background: #2977ff;
  15. width: 80px;
  16. height: 26px;
  17. border-radius: 3px;
  18. font-size: 14px;
  19. color: #fff;
  20. outline: none;
  21. cursor: pointer;
  22. }
  23. .confirmbox-mask button.save {
  24. display: block;
  25. margin: 40px auto;
  26. }
  27. .confirmbox .confirmbox-btns {
  28. margin-top: 40px;
  29. }
  30. .class-modal {
  31. width: 700px;
  32. background: #fff;
  33. // border-radius: 5px;
  34. position: absolute;
  35. top: 50%;
  36. left: 50%;
  37. transform: translate(-50%, -50%);
  38. height:420px;
  39. }
  40. .class-modal-head {
  41. font-size: 14px;
  42. background:#2977ff;
  43. color:#fff;
  44. height:25px;
  45. line-height: 25px;
  46. padding: 0 0 0 15px;
  47. }
  48. .class-modal-body {
  49. margin-top: 5px;
  50. overflow: auto;
  51. padding:15px;
  52. min-height: 340px;
  53. }
  54. .class-modal-body .classes {
  55. margin-bottom: 20px;
  56. }
  57. .class-modal-body .classes > div {
  58. display: inline-block;
  59. max-width: 640px;
  60. vertical-align: top;
  61. }
  62. .class-modal-body .classes a {
  63. text-decoration: none;
  64. display: inline-block;
  65. margin: 0 5px 5px;
  66. color: #136bfb;
  67. font-size: 14px;
  68. }
  69. .class-modal-body .classes a.active {
  70. color: #fc091b;
  71. }
  72. .class-modal .icon-close{
  73. position: absolute;
  74. right: 20px;
  75. top: 2px;
  76. color:#fff;
  77. }
  78. .class_btn{
  79. text-align: center;
  80. }
  81. .confirmbox-mask p{
  82. word-wrap : break-word ;
  83. }
  84. .icon-close{
  85. cursor: pointer;
  86. }
  87. .model-input label{
  88. margin:0 15px;
  89. }
  90. table{margin-top:5px;}
  91. .table_list{
  92. height:250px;
  93. overflow: auto;
  94. }
  95. .modify-btn{
  96. cursor: pointer;
  97. }
  98. .show_btn{
  99. display: inline-block;
  100. padding:2px 8px;
  101. cursor: pointer;
  102. }
  103. .c-red {
  104. color: #CC3300
  105. }
  106. </style>
  107. <div class="main-content-inner">
  108. <!-- 导航栏开始-->
  109. <?php include(Yii::app()->basePath.'/views/layouts/class_navigation.php');?>
  110. <!-- 导航栏结束-->
  111. <div class="page-content">
  112. <div class="row" style="margin:0px">
  113. <div class="col-xs-12">
  114. <!-- PAGE CONTENT BEGINS -->
  115. <div id="dynamic-table_wrapper" class="dataTables_wrapper form-inline no-footer">
  116. <div class="row">
  117. <div class="col-xs-9">
  118. <div class="dataTables_length margin-zy">
  119. <select name="subject" class="subject">
  120. <option value="3">数学</option>
  121. </select>
  122. <select name="grade" class="grade">
  123. <option value="0">年级</option>
  124. <?php
  125. if(Yii::app()->params['grade_list']){
  126. foreach (Yii::app()->params['grade_list'] as $id=> $val){
  127. echo '<option value="'.$id.'" >'.$val['grade_name'].'</option>';
  128. }
  129. }
  130. ?>
  131. </select>
  132. <select name="textbook" class="textbook">
  133. <option value="0">教材版本</option>
  134. <option value="43">新人教A版</option>
  135. <option value="44">新人教B版</option>
  136. <option value="45">新北师大版</option>
  137. <option value="46">新苏教版</option>
  138. <option value="47">新湘教版</option>
  139. <option value="13">人教A版</option>
  140. <option value="14">人教B版</option>
  141. <option value="15">苏教版</option>
  142. <option value="16">北师大版</option>
  143. <option value="32">湘教版</option>
  144. <option value="28">高三通用</option>
  145. </select>
  146. <button class="label-primary-s bth-s" id="add-btn" style="padding:4px 12px;">添加</button>
  147. </div>
  148. </div>
  149. </div>
  150. <table id="dynamic-table" class="table table-striped table-bordered table-hover dataTable no-footer DTTT_selectable">
  151. <thead>
  152. <tr>
  153. <th style="width:80px;">学科</th>
  154. <th>年级</th>
  155. <th>教材</th>
  156. <th>操作</th>
  157. </tr>
  158. </thead>
  159. <tbody>
  160. <?php if(!empty($data)):foreach($data as $val):?>
  161. <tr>
  162. <td><?php echo $val['subject']?></td>
  163. <td><?php echo $val['grade']?></td>
  164. <td><?php echo $val['textbook_name']?></td>
  165. <td><span class="modify-btn" subject_id="<?php echo $val['subject_id']?>" grade="<?php echo $val['grade_id']?>" textbook="<?php echo $val['textbook_id']?>">修改</span></td>
  166. </tr>
  167. <?php endforeach;else:?>
  168. <tr><td colspan="10">暂无数据!</td></tr>
  169. <?php endif;?>
  170. </tbody>
  171. </table>
  172. </div>
  173. </div>
  174. </div>
  175. </div>
  176. </div>
  177. <!-- 老教材-->
  178. <input type="hidden" value="0" class="is-qxk"/>
  179. <!--修改弹窗-->
  180. <div class="confirmbox-mask" style="display: none" id="fieldModal">
  181. <div class="class-modal">
  182. <i class="icon close_1 icon-close">×</i>
  183. <div class="class-modal-head">教材版本</div>
  184. <form id="examSelect">
  185. <div class="class-modal-body">
  186. <div class="table_list">
  187. <table id="dynamic-table" class="table table-striped table-bordered table-hover dataTable no-footer DTTT_selectable">
  188. <tr>
  189. <td>新教材版本:</td>
  190. <td>
  191. <?php
  192. if($textbookArr['51']){
  193. foreach ($textbookArr['51'] as $key => $item){
  194. echo '<span class="show_btn textbook_btn_'.$key.'" id="'.$key.'">'.$item.'</span>';
  195. }
  196. }
  197. ?>
  198. </td>
  199. </tr>
  200. <tr>
  201. <td>旧教材版本:</td>
  202. <td>
  203. <?php
  204. if($textbookArr['3']){
  205. foreach ($textbookArr['3'] as $key => $item){
  206. echo '<span class="show_btn textbook_btn_'.$key.'" id="'.$key.'">'.$item.'</span>';
  207. }
  208. }
  209. ?>
  210. </td>
  211. </tr>
  212. <tr>
  213. <td>高三通用:</td>
  214. <td><span class="show_btn textbook_btn_28" id="28">高三通用</span></td>
  215. </tr>
  216. </table>
  217. </div>
  218. </div>
  219. <p class="class_btn">
  220. <input type="hidden" name="grade" value="">
  221. <input type="hidden" name="subject" value="">
  222. <input type="hidden" name="textbook" value="">
  223. <button type="button" class="save_textbook">确定</button>
  224. </p>
  225. </form>
  226. </div>
  227. </div>
  228. <script>
  229. $('#add-btn').click(function(){
  230. var subjectId=$('.subject').val(),
  231. grade=$('.grade').val(),
  232. textbook=$('.textbook').val();
  233. var isQxk=$(".is-qxk").val();
  234. if(textbook==0){
  235. layer.msg('请选择教材');
  236. return false;
  237. }
  238. if(grade==0){
  239. layer.msg('请选择年级');
  240. return false;
  241. }
  242. txt=$('.grade').find("option:selected").text()+$('.subject').find("option:selected").text()+" 您选择的教材版本是 "+$('.textbook').find("option:selected").text()+" 请确认";
  243. layer.confirm(txt,function(){
  244. $.ajax({
  245. url:'<?php echo $this->createUrl('textbook/add')?>',
  246. type:'POST',
  247. dataType:'json',
  248. data:{subject:subjectId,grade:grade,textbook:textbook,isQxk:isQxk},
  249. success:function(res){
  250. if(res.status==1){
  251. layer.msg('添加成功',{time:3000},function(){
  252. window.location.reload();
  253. })
  254. }else{
  255. if(res.msg!=undefined){
  256. layer.msg(res.msg)
  257. }else{
  258. layer.msg('添加失败')
  259. }
  260. }
  261. }
  262. });
  263. });
  264. return false;
  265. });
  266. $('.modify-btn').click(function(){
  267. var subject_id=$(this).attr('subject_id'),
  268. grade=$(this).attr('grade'),
  269. textbook=$(this).attr('textbook');
  270. $('input[name=subject]').val(subject_id);
  271. $('input[name=grade]').val(grade);
  272. $('input[name=textbook]').val(textbook);
  273. $('.show_btn').removeClass('c-red');
  274. $('.textbook_btn_'+textbook).addClass('c-red');
  275. $('#fieldModal').show();
  276. });
  277. $('.icon-close').click(function(){
  278. $('#fieldModal').hide();
  279. });
  280. $('.show_btn').click(function(){
  281. $('.show_btn').removeClass('c-red');
  282. $(this).addClass('c-red');
  283. $('input[name=textbook]').val($(this).attr('id'));
  284. });
  285. $('.save_textbook').click(function(){
  286. var subjectId=$('input[name=subject]').val(),
  287. grade=$('input[name=grade]').val(),
  288. textbook=$('input[name=textbook]').val();
  289. var isQxk=$(".is-qxk").val();
  290. if(textbook==0){
  291. layer.msg('请选择教材');
  292. return false;
  293. }
  294. if(grade==0){
  295. layer.msg('年级数据错误');
  296. return false;
  297. }
  298. if(subjectId==0){
  299. layer.msg('科目数据错误');
  300. return false;
  301. }
  302. var data={subject:subjectId,grade:grade,textbook:textbook,isQxk:isQxk};
  303. console.log(data);
  304. $.ajax({
  305. url:'<?php echo $this->createUrl('textbook/edit')?>',
  306. type:'POST',
  307. dataType:'json',
  308. data:{subject:subjectId,grade:grade,textbook:textbook,isQxk:isQxk},
  309. success:function(res){
  310. if(res.status==1){
  311. layer.msg('修改成功',{time:3000},function(){
  312. window.location.reload();
  313. })
  314. }else{
  315. if(res.msg!=undefined){
  316. layer.msg(res.msg)
  317. }else{
  318. layer.msg('修改失败')
  319. }
  320. }
  321. }
  322. });
  323. });
  324. </script>