index2.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  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. <?php foreach($textbookArr as $textbookId=>$textbookName): ?>
  134. <option value="<?php echo $textbookId?>"><?php echo $textbookName;?></option>
  135. <?php endforeach;?>
  136. </select>
  137. <button class="label-primary-s bth-s" id="add-btn" style="padding:4px 12px;">添加</button>
  138. </div>
  139. </div>
  140. </div>
  141. <table id="dynamic-table" class="table table-striped table-bordered table-hover dataTable no-footer DTTT_selectable">
  142. <thead>
  143. <tr>
  144. <th style="width:80px;">学科</th>
  145. <th>年级</th>
  146. <th>教材</th>
  147. <th>操作</th>
  148. </tr>
  149. </thead>
  150. <tbody>
  151. <?php if(!empty($data)):foreach($data as $val):?>
  152. <tr>
  153. <td><?php echo $val['subject']?></td>
  154. <td><?php echo $val['grade']?></td>
  155. <td><?php echo $val['textbook_name']?></td>
  156. <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>
  157. </tr>
  158. <?php endforeach;else:?>
  159. <tr><td colspan="10">暂无数据!</td></tr>
  160. <?php endif;?>
  161. </tbody>
  162. </table>
  163. </div>
  164. </div>
  165. </div>
  166. </div>
  167. </div>
  168. <!-- 全学科教材-->
  169. <input type="hidden" value="1" class="is-qxk"/>
  170. <!--修改弹窗-->
  171. <div class="confirmbox-mask" style="display: none" id="fieldModal">
  172. <div class="class-modal">
  173. <i class="icon close_1 icon-close">×</i>
  174. <div class="class-modal-head">教材版本</div>
  175. <form id="examSelect">
  176. <div class="class-modal-body">
  177. <div class="table_list">
  178. <table id="dynamic-table" class="table table-striped table-bordered table-hover dataTable no-footer DTTT_selectable">
  179. <tr>
  180. <td>全学科教材版本:</td>
  181. <td>
  182. <?php
  183. if($textbookArr){
  184. foreach ($textbookArr as $textbookId => $textbookName){
  185. echo '<span class="show_btn textbook_btn_'.$textbookId.'" id="'.$textbookId.'">'.$textbookName.'</span>';
  186. }
  187. }
  188. ?>
  189. </td>
  190. </tr>
  191. </table>
  192. </div>
  193. </div>
  194. <p class="class_btn">
  195. <input type="hidden" name="grade" value="">
  196. <input type="hidden" name="subject" value="">
  197. <input type="hidden" name="textbook" value="">
  198. <button type="button" class="save_textbook">确定</button>
  199. </p>
  200. </form>
  201. </div>
  202. </div>
  203. <script>
  204. $('#add-btn').click(function(){
  205. var subjectId=$('.subject').val(),
  206. grade=$('.grade').val(),
  207. textbook=$('.textbook').val();
  208. var isQxk=$(".is-qxk").val();
  209. if(textbook==0){
  210. layer.msg('请选择教材');
  211. return false;
  212. }
  213. if(grade==0){
  214. layer.msg('请选择年级');
  215. return false;
  216. }
  217. txt=$('.grade').find("option:selected").text()+$('.subject').find("option:selected").text()+" 您选择的教材版本是 "+$('.textbook').find("option:selected").text()+" 请确认";
  218. layer.confirm(txt,function(){
  219. $.ajax({
  220. url:'<?php echo $this->createUrl('textbook/add')?>',
  221. type:'POST',
  222. dataType:'json',
  223. data:{subject:subjectId,grade:grade,textbook:textbook,isQxk:isQxk},
  224. success:function(res){
  225. if(res.status==1){
  226. layer.msg('添加成功',{time:3000},function(){
  227. window.location.reload();
  228. })
  229. }else{
  230. if(res.msg!=undefined){
  231. layer.msg(res.msg)
  232. }else{
  233. layer.msg('添加失败')
  234. }
  235. }
  236. }
  237. });
  238. });
  239. return false;
  240. });
  241. $('.modify-btn').click(function(){
  242. var subject_id=$(this).attr('subject_id'),
  243. grade=$(this).attr('grade'),
  244. textbook=$(this).attr('textbook');
  245. $('input[name=subject]').val(subject_id);
  246. $('input[name=grade]').val(grade);
  247. $('input[name=textbook]').val(textbook);
  248. $('.show_btn').removeClass('c-red');
  249. $('.textbook_btn_'+textbook).addClass('c-red');
  250. $('#fieldModal').show();
  251. });
  252. $('.icon-close').click(function(){
  253. $('#fieldModal').hide();
  254. });
  255. $('.show_btn').click(function(){
  256. $('.show_btn').removeClass('c-red');
  257. $(this).addClass('c-red');
  258. $('input[name=textbook]').val($(this).attr('id'));
  259. });
  260. $('.save_textbook').click(function(){
  261. var subjectId=$('input[name=subject]').val(),
  262. grade=$('input[name=grade]').val(),
  263. textbook=$('input[name=textbook]').val();
  264. var isQxk=$(".is-qxk").val();
  265. if(textbook==0){
  266. layer.msg('请选择教材');
  267. return false;
  268. }
  269. if(grade==0){
  270. layer.msg('年级数据错误');
  271. return false;
  272. }
  273. if(subjectId==0){
  274. layer.msg('科目数据错误');
  275. return false;
  276. }
  277. var data={subject:subjectId,grade:grade,textbook:textbook,isQxk:isQxk};
  278. console.log(data);
  279. $.ajax({
  280. url:'<?php echo $this->createUrl('textbook/edit')?>',
  281. type:'POST',
  282. dataType:'json',
  283. data:{subject:subjectId,grade:grade,textbook:textbook,isQxk:isQxk},
  284. success:function(res){
  285. if(res.status==1){
  286. layer.msg('修改成功',{time:3000},function(){
  287. window.location.reload();
  288. })
  289. }else{
  290. if(res.msg!=undefined){
  291. layer.msg(res.msg)
  292. }else{
  293. layer.msg('修改失败')
  294. }
  295. }
  296. }
  297. });
  298. });
  299. </script>