setting.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <link rel="stylesheet" href="/fonts/fpdf/iconfont.css"/>
  2. <link rel="stylesheet" href="/css/alert.css"/>
  3. <?php $imgUrl = Yii::app()->request->hostInfo.'/images/disable.png';?>
  4. <style>
  5. .color-red{
  6. color: red;
  7. }
  8. .en-tfb-grade-1 .date>span{
  9. margin-right: 40px;
  10. }
  11. .option-wrap{
  12. margin-top: 20px;
  13. min-width: 600px;
  14. }
  15. .option-name{
  16. display: inline-block;
  17. width: 100px;
  18. vertical-align: top;
  19. margin-top: 10px;
  20. }
  21. .option-con{
  22. display: inline-block;
  23. width: 80%;
  24. min-width: 490px;
  25. padding: 10px;
  26. border: 1px solid #ccc;
  27. }
  28. .option-con>span{
  29. display: inline-block;
  30. margin-right: 20px;
  31. margin-top:10px;
  32. line-height: 1rem;
  33. cursor: pointer;
  34. }
  35. .select-grade{
  36. width: 150px;
  37. line-height: 30px;
  38. margin-bottom: 10px;
  39. }
  40. .option-con-class label{
  41. display: inline-block;
  42. margin-right: 20px;
  43. }
  44. .active{
  45. color: #619aff;
  46. }
  47. .btn-start{
  48. display: inline-block;
  49. margin-top: 20px;
  50. margin-left: 100px;
  51. padding: 10px 30px;
  52. color: #fff;
  53. background-color: #2977ff;
  54. cursor: pointer;
  55. }
  56. .en-tfb-grade-1{
  57. margin-left: 20px;
  58. }
  59. </style>
  60. <div class="main-content-inner">
  61. <!-- 导航栏开始-->
  62. <?php include(Yii::app()->basePath.'/views/layouts/view_production_navigation.php');?>
  63. <!-- 导航栏结束-->
  64. <div class="en-tfb-grade-1">
  65. <h2>好题本生成</h2>
  66. <p class="color-red">提示:每个班级每周原则上生成一次,请根据实际需要生成。</p>
  67. <ul id="node-content">
  68. <li class="option-wrap">
  69. <span class="option-name"></span>
  70. <div class="option-con" id="optionEdition">
  71. <?php if(isset($topNode) && $topNode):?>
  72. <?php $no =1;?>
  73. <?php foreach($topNode as $k=>$v):?>
  74. <span parentid="<?php echo $v->parent_id;?>" pcid="<?php echo $v->pc_id;?>"><?php echo $v->pc_name;?></span>
  75. <?php $no++;?>
  76. <?php endforeach;?>
  77. <?php endif;?>
  78. </div>
  79. </li>
  80. </ul>
  81. <div class="option-wrap">
  82. <span class="option-name">班级:</span>
  83. <div class="option-con">
  84. <div>
  85. <select name="grade" class="select-grade">
  86. <option value="1" selected>高一</option>
  87. <option value="2">高二</option>
  88. <option value="3">高三</option>
  89. </select>
  90. </div>
  91. <div class="option-con-class" id="optionClass">
  92. </div>
  93. </div>
  94. </div>
  95. <div class="option-wrap">
  96. <span class="option-name">生成方式:</span>
  97. <div class="option-con">
  98. <span><input type="radio" name="is-answer-merge" value="0" checked="checked">题目答案分开生成</span>
  99. <span><input type="radio" name="is-answer-merge" value="1" >题目答案合并生成</span>
  100. </div>
  101. </div>
  102. <!--是否新版本:1-新版本-->
  103. <input type="hidden" value="1" class="is-new-version">
  104. <span class="btn-start" id="preview" >开始预览</span>
  105. <span class="btn-start" id="confirm" active="true" style="margin-left: 10px;">开始生成</span>
  106. </div>
  107. </div>
  108. <script src="/js/jquery.ajaxfileupload.js"></script>
  109. <script type="text/javascript">
  110. $(document).ready(function () {
  111. getClassByGrade(1);
  112. // 选择年级
  113. $(".select-grade").change(function() {
  114. console.log($(this).val())
  115. });
  116. // 单选按钮
  117. $("input[name='option-class']").change(function() {
  118. getsClassSelected();
  119. });
  120. function getsClassSelected() {
  121. optionData.class=[];
  122. var selectedData = $("input[name='option-class']:checked"); //获取所以选中学生
  123. for (var i = 0; i < selectedData.length; i++) {
  124. code = $(selectedData[i]).val();
  125. optionData.class.push(code);
  126. }
  127. };
  128. $("body").delegate("#node-content li div span","click",function () {
  129. $(this).siblings().removeClass('active');
  130. $(this).addClass('active');
  131. $(this).parent().parent().nextAll().remove();
  132. $.ajax({
  133. url: "<?php echo $this->createUrl('htb/ajaxChildNode');?>",
  134. type: "GET",
  135. dataType: "json",
  136. data: {
  137. parentId: $(this).attr('pcid')
  138. },
  139. success: function (data) {
  140. if(data.status == 1 && data.data!= null) {
  141. var con = '<li class="option-wrap"> <span class="option-name"></span><div class="option-con" id="optionEdition">';
  142. $.each(data.data, function (index, item) {
  143. con += '<span pcid="' + item.pc_id + '" parentid="' + item.parent_id +'">' + item.pc_name + '</span>';
  144. });
  145. con += '</div></li>';
  146. $("#node-content").append(con);
  147. }}
  148. })
  149. });
  150. $('.select-grade').change(function(){
  151. var grade = $(this).val();
  152. getClassByGrade(grade);
  153. });
  154. $("body").delegate("#confirm[active='true']", "click", function() {
  155. var This = $(this);
  156. This.attr("active","false");
  157. var error = [];
  158. var selectClassIds = [];
  159. var grade = parseInt($('.select-grade').val());
  160. var isAnswerMerge = $("input[name='is-answer-merge']:checked").val();
  161. var isNewVersion=parseInt($('.is-new-version').val());
  162. var pcIds = [];
  163. $('#node-content li div span.active').each(function () {
  164. var data1 = {"pcId": $(this).attr('pcid'),"pcName":$(this).text(), "parentId":$(this).attr('parentid')};
  165. pcIds.push(data1);
  166. });
  167. $('#optionClass input:checked').each(function(k,v){
  168. if($(this).attr("status") == 0){
  169. selectClassIds.push($(this).val());
  170. }
  171. });
  172. if(pcIds.length == 0){
  173. error.push("请选择末节点~");
  174. }
  175. var noSelect = true;
  176. var lastNode = $('#node-content').children().last();
  177. lastNode.find('span').each(function (i) {
  178. if($(this).hasClass('active')){
  179. noSelect = false;
  180. }
  181. });
  182. if(noSelect){
  183. error.push("请选择末节点~");
  184. }
  185. if(selectClassIds.length == 0){
  186. error.push("请选择班级");
  187. }
  188. if(grade <= 0 || !grade){
  189. error.push("请选择年级");
  190. }
  191. if(error.length == 0){
  192. $.ajax({
  193. url: "<?php echo $this->createUrl('htb/ajaxSaveHtb');?>",
  194. type: "POST",
  195. dataType: "json",
  196. data: {
  197. grade: grade,
  198. selectClassIds:selectClassIds,
  199. pcIds:pcIds,
  200. isAnswerMerge:isAnswerMerge,
  201. isNewVersion:isNewVersion
  202. },
  203. success: function (data) {
  204. if(data.status == 1){
  205. layer.msg('已发送到后台,预计1小时左右生成!', {
  206. time: 2000,
  207. });
  208. setTimeout(function(){window.location.href = "<?php echo Yii::app()->createUrl('htb/index');?>";}, 2000);
  209. }else{
  210. layer.msg(data.error.join('</br>'));
  211. This.attr("active","true");
  212. }
  213. }
  214. });
  215. }else{
  216. This.attr("active","true");
  217. layer.msg(error[0]);
  218. }
  219. });
  220. //好题本预览
  221. $("body").delegate("#preview", "click", function() {
  222. var error = [];
  223. var pcIds = [];
  224. $('#node-content li div span.active').each(function () {
  225. var data1 = {"pcId": $(this).attr('pcid'),"pcName":$(this).text(), "parentId":$(this).attr('parentid')};
  226. pcIds.push(data1);
  227. });
  228. if(pcIds.length == 0){
  229. error.push("请选择末节点~");
  230. }
  231. var noSelect = true;
  232. var lastNode = $('#node-content').children().last();
  233. lastNode.find('span').each(function (i) {
  234. if($(this).hasClass('active')){
  235. noSelect = false;
  236. }
  237. });
  238. if(noSelect){
  239. error.push("请选择末节点~");
  240. }
  241. var ids = $.param({pcIds}, false);
  242. if(error.length == 0) {
  243. layer.open({
  244. title: '内容预览',
  245. type: 2,
  246. area: ['650px', '700px'],
  247. content: '<?php echo $this->createUrl('htb/newPreview');?>'+'?'+ids //这里content是一个URL,如果你不想让iframe出现滚动条,你还可以content: ['http://sentsin.com', 'no']
  248. });
  249. }else {
  250. layer.msg(error[0]);
  251. }
  252. });
  253. function getClassByGrade(grade){
  254. if(grade){
  255. $.ajax({
  256. url: "<?php echo $this->createUrl('htb/ajaxGetClasses');?>",
  257. type: "POST",
  258. dataType: "json",
  259. data: {
  260. grade: grade,
  261. },
  262. success: function (data) {
  263. var html = '';
  264. if(data && data.length > 0){
  265. for(var i in data){
  266. html +='<label>';
  267. if(data[i].status == 1){
  268. html += '<span title="该班级已达每周生成的最大次数"><img src="<?php echo $imgUrl;?>">'+data[i].class_name+'</span>';
  269. }else{
  270. html += '<input type="checkbox" name="option-class" value="'+data[i].class_id+'" status="0">'+data[i].class_name;
  271. }
  272. html +='</label>';
  273. }
  274. }
  275. $('#optionClass').html(html);
  276. }
  277. });
  278. }
  279. }
  280. });
  281. </script>