setting.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  1. <link rel="stylesheet" href="/fonts/fpdf/iconfont.css"/>
  2. <link rel="stylesheet" href="/css/alert.css"/>
  3. <?php $imgUrl = Yii::app()->request->hostInfo;?>
  4. <?php $disableImgUrl = Yii::app()->request->hostInfo.'/images/disable.png';?>
  5. <style>
  6. .color-red{
  7. color: red;
  8. }
  9. .color-green{
  10. color: green;
  11. }
  12. .option-wrap{
  13. margin-top: 20px;
  14. min-width: 600px;
  15. }
  16. .option-name{
  17. display: inline-block;
  18. width: 100px;
  19. vertical-align: top;
  20. margin-top: 10px;
  21. }
  22. .option-con{
  23. display: inline-block;
  24. width: 80%;
  25. min-width: 490px;
  26. padding: 10px;
  27. border: 1px solid #ccc;
  28. }
  29. .option-con>span{
  30. display: inline-block;
  31. margin-right: 20px;
  32. line-height: 1rem;
  33. cursor: pointer;
  34. }
  35. .option-con-class label{
  36. display: inline-block;
  37. margin-right: 20px;
  38. }
  39. .active{
  40. color: #619aff;
  41. }
  42. .btn-start{
  43. display: inline-block;
  44. margin-top: 20px;
  45. margin-left: 100px;
  46. padding: 10px 30px;
  47. color: #fff;
  48. background-color: #2977ff;
  49. cursor: pointer;
  50. }
  51. .en-tfb-grade-1{
  52. margin-left: 20px;
  53. }
  54. #selectedUnit,#selectedPaper,#selectedSpecials{
  55. /*display: inline-block;*/
  56. width: 80%;
  57. min-width: 490px;
  58. padding: 10px;
  59. border: 1px solid #ccc;
  60. display: inline-flex;
  61. flex-wrap: wrap;
  62. }
  63. #selectedUnit span,#selectedPaper span,#selectedSpecials span{
  64. position: relative;
  65. padding: 5px;
  66. padding-right: 30px;
  67. border: 1px solid #999;
  68. margin-right: 15px;
  69. margin-bottom: 5px;
  70. }
  71. .delete-icon{
  72. position: absolute;
  73. top: 50%;
  74. right: 5px;
  75. transform: translateY(-50%);
  76. width: 15px;
  77. height: 15px;
  78. background: url(<?php echo $imgUrl.'/images/icon-delect.png';?>) no-repeat center;
  79. background-size: contain;
  80. cursor: pointer;
  81. }
  82. .download-pdf{
  83. margin-right: 280px;
  84. float: right;
  85. background: #2977ff;
  86. height: 35px;
  87. width: 100px;
  88. line-height: 35px;
  89. text-align: center;
  90. }
  91. .download-pdf a{
  92. color: white;
  93. }
  94. </style>
  95. <div class="main-content-inner">
  96. <!-- 导航栏开始-->
  97. <?php include(Yii::app()->basePath.'/views/layouts/view_production_navigation.php');?>
  98. <!-- 导航栏结束-->
  99. <div class="en-tfb-grade-1">
  100. <h2>专题宝</h2>
  101. <div class="download-pdf"><a href="<?php echo $this->createUrl('special/downloadDir');?>">专题目录下载</a></div>
  102. <div class="color-red">
  103. <div class="blue">
  104. ** 每个班级每个专题最多生成3次产品(包括自动生成和手动生成)<br>
  105. ** 自动生成,每次只能选择一个专题生成,学生产品根据学生层次推送一套试卷,教师产品推送两套试卷<br>
  106. ** 手动生成,每次只能选择一个专题,并且最多选择12个方法,最多选择1套试卷或不选试卷<br>
  107. </div>
  108. 特别提示:新高考地区,请不要选择专题八,包括手动和自动!!!<br>
  109. 新高考地区包括:北京、天津、上海、浙江、山东、海南、广东、江苏、河北、重庆、辽宁、福建、湖南、湖北
  110. </div>
  111. <div class="option-wrap">
  112. <span class="option-name">选择班级:</span>
  113. <div class="option-con">
  114. <div class="option-con-class" id="optionClass">
  115. </div>
  116. </div>
  117. </div>
  118. <div class="option-wrap">
  119. <span class="option-name">生成方式:</span>
  120. <div class="option-con">
  121. <span><input type="radio" name="create_type" value="1" checked="checked">自动生成(根据高三复习考试大数据)</span>
  122. <span><input type="radio" name="create_type" value="2">手动生成(自主选择专题方法)</span>
  123. </div>
  124. </div>
  125. <div class="option-wrap">
  126. <span class="option-name">专题:</span>
  127. <div class="option-con" id="optionEdition">
  128. <?php foreach ($topNode as $item):?>
  129. <span code="<?php echo $item->pc_id;?>" class=""><?php echo $item->pc_name;?></span>
  130. <?php endforeach;?>
  131. </div>
  132. </div>
  133. <div class="option-wrap" id="lectureBox">
  134. <span class="option-name">第几讲:</span>
  135. <div class="option-con" id="optionModular">
  136. </div>
  137. </div>
  138. <div class="option-wrap" id="methodBox">
  139. <span class="option-name">方法:</span>
  140. <div class="option-con" id="optionUnit">
  141. </div>
  142. </div>
  143. <div class="option-wrap" id="selectedMethod">
  144. <span class="option-name">已选方法:</span>
  145. <div id="selectedUnit">
  146. </div>
  147. </div>
  148. <div class="option-wrap" id="selectedSpecial">
  149. <span class="option-name">已选专题:</span>
  150. <div id="selectedSpecials">
  151. </div>
  152. </div>
  153. <div class="option-wrap" id="specialPaper">
  154. <span class="option-name">试卷:</span>
  155. <div class="option-con" id="optionPaper">
  156. </div>
  157. </div>
  158. <div class="option-wrap" id="specialSelectedPaper">
  159. <span class="option-name">已选试卷:</span>
  160. <div id="selectedPaper">
  161. </div>
  162. </div>
  163. <div class="option-wrap">
  164. <span class="option-name">生成方式:</span>
  165. <div class="option-con">
  166. <span><input type="radio" name="is_answer_merge" value=1 checked="checked">答案部分与其他合并下载</span>
  167. <span style="margin-left: 10px;"><input type="radio" name="is_answer_merge" value=0>答案部分与其他分开下载</span>
  168. </div>
  169. </div>
  170. <button class="btn-start" id="confirm" active="true">开始生成</>
  171. </div>
  172. </div>
  173. <script src="/js/jquery.ajaxfileupload.js"></script>
  174. <script type="text/javascript">
  175. $(document).ready(function () {
  176. getClassByGrade(3);
  177. var optionData={
  178. edition:0,
  179. modular:0,
  180. unit:0,
  181. class:[],
  182. }
  183. var create_type = $('input:radio[name="create_type"]').val();
  184. if (create_type ==1){
  185. $("#specialPaper").hide();
  186. $("#specialSelectedPaper").hide();
  187. $("#lectureBox").hide();
  188. $("#methodBox").hide();
  189. $("#selectedMethod").hide();
  190. $("#selectedSpecial").show();
  191. }else{
  192. $("#selectedSpecial").hide();
  193. $("#lectureBox").show();
  194. $("#methodBox").show();
  195. $("#selectedMethod").show();
  196. $("#specialPaper").show();
  197. $("#specialSelectedPaper").show();
  198. }
  199. $('input:radio[name="create_type"]').change(function(){
  200. var v = $(this).val();
  201. if (v ==1){
  202. $('#selectedUnit').empty();
  203. $("#selectedSpecial").show();
  204. $("#lectureBox").hide();
  205. $("#methodBox").hide();
  206. $("#selectedMethod").hide();
  207. $("#specialPaper").hide();
  208. $("#specialSelectedPaper").hide();
  209. }else{
  210. $('#selectedSpecials').empty();
  211. $("#selectedSpecial").hide();
  212. $("#lectureBox").show();
  213. $("#methodBox").show();
  214. $("#selectedMethod").show();
  215. $("#specialPaper").show();
  216. $("#specialSelectedPaper").show();
  217. }
  218. });
  219. // 专题点击
  220. $("#optionEdition>span").on("click", function(event) {
  221. var create_type = $('input:radio[name="create_type"]:checked').val();
  222. if(create_type == 1){
  223. var selected_count = $("#selectedSpecials").children("span").length;
  224. if(selected_count == 1) {
  225. layer.msg('已选专题超出限制');
  226. return false;
  227. }
  228. }
  229. $("#optionEdition>span").removeClass('active')
  230. $(this).addClass('active');
  231. var code = $(this).attr("code");
  232. optionData.edition=code;
  233. });
  234. // 第几讲点击
  235. $("#optionModular>span").on("click", function(event) {
  236. $("#optionModular>span").removeClass('active')
  237. $(this).addClass('active');
  238. var code = $(this).attr("code");
  239. optionData.modular=code;
  240. });
  241. // 方法点击
  242. $("body").delegate("#optionUnit>span", "click", function() {
  243. if(!limitUnit()){
  244. layer.msg('已选方法数量超出限制');return false;
  245. }
  246. // $("#optionUnit>span").on("click", function(event) {
  247. $("#optionUnit>span").removeClass('active')
  248. $(this).addClass('active');
  249. var code = $(this).attr("code");
  250. optionData.unit=code;
  251. console.log('单元',code)
  252. });
  253. $("body").delegate("#optionEdition span", "click", function() {
  254. var create_type = $('input:radio[name="create_type"]:checked').val();
  255. //FIXME 自动生成方式
  256. if(create_type == 1){
  257. var node_id = $(this).attr("code");
  258. var selected_arr = [];
  259. if($('#selectedSpecials span').length > 0){
  260. $('#selectedSpecials span').each(function(index){
  261. selected_arr.push($(this).attr('node'));
  262. });
  263. }
  264. if($.inArray(node_id, selected_arr) >= 0){
  265. layer.msg('不能重复添加专题');return false;
  266. }
  267. var node_name = $(this).text();
  268. var _html = '<span node="' + node_id + '">' + node_name + '<i class="delete-icon" onclick="deleteUnit(this)"></i></span>';
  269. $("#selectedSpecials").append(_html);
  270. }else{
  271. //FIXME 手动生成方式
  272. if(!limitUnit()){
  273. layer.msg('已选单元超出限制');return false;
  274. }
  275. // $('#optionEdition span').on("click", function(event) {
  276. var textbookId = $(this).attr("code");
  277. if(textbookId){
  278. $.ajax({
  279. url: "<?php echo $this->createUrl('special/ajaxSpecialChild');?>",
  280. type: "POST",
  281. dataType: "json",
  282. data: {
  283. pc_id: textbookId
  284. },
  285. success: function (data) {
  286. console.log(data);
  287. var htmlModule = '';
  288. var htmlPaper = '';
  289. if(data.data.lectureList){
  290. $.each(data.data.lectureList, function (index, item) {
  291. htmlModule += '<span code="'+item.pc_id+'">'+item.pc_name+'</span>';
  292. })
  293. }
  294. if(data.data.paperList){
  295. $.each(data.data.paperList, function (index, item) {
  296. htmlPaper += '<span code="'+item.paper_id+'">'+item.paper_name+'</span>';
  297. })
  298. }
  299. $('#optionModular').html(htmlModule);
  300. $('#optionPaper').html(htmlPaper);
  301. }
  302. });
  303. }
  304. }
  305. })
  306. $("body").delegate("#optionModular span", "click", function() {
  307. var selected_count = $("#selectedSpecials").children("span").length;
  308. if(selected_count == 1) {
  309. layer.msg('已选专题超出限制');
  310. return false;
  311. }
  312. //FIXME 手动生成方式
  313. if(!limitUnit()){
  314. layer.msg('已选单元超出限制');return false;
  315. }
  316. $("#optionModular>span").removeClass('active')
  317. $(this).addClass('active');
  318. var code = $(this).attr("code");
  319. // optionData.modular=code;
  320. // $('#optionModular span').on("click", function(event) {
  321. // var moduleId = $(this).attr("code");
  322. // var textbookId = $('#optionEdition span.active').attr("code");
  323. if(code){
  324. $.ajax({
  325. url: "<?php echo $this->createUrl('special/ajaxMethod');?>",
  326. type: "POST",
  327. dataType: "json",
  328. data: {
  329. pc_id: code,
  330. },
  331. success: function (data) {
  332. console.log(data);
  333. var htmlUnit = '';
  334. if(data.data.methodList){
  335. $.each(data.data.methodList, function (index, item) {
  336. htmlUnit += '<span code="'+item.method_id+'">'+item.method_name+'</span>';
  337. })
  338. }
  339. $('#optionUnit').html(htmlUnit);
  340. }
  341. });
  342. }
  343. });
  344. $("body").delegate("#optionUnit span","click",function () {
  345. if(!limitUnit()){
  346. layer.msg('已选单元超出限制');return false;
  347. }
  348. var text_book_id = $("#optionEdition").children(".active").attr("code");
  349. var module_id = $("#optionModular").children(".active").attr("code");
  350. var unit_id = $(this).attr("code");
  351. var ids = text_book_id + '_' + module_id + '_' + unit_id;
  352. var selected_arr = [];
  353. if($('#selectedUnit span').length > 0){
  354. $('#selectedUnit span').each(function(index){
  355. selected_arr.push($(this).attr('node'));
  356. });
  357. }
  358. if($.inArray(ids, selected_arr) >= 0){
  359. layer.msg('不能重复添加该单元');return false;
  360. }
  361. var text_book_name = $("#optionEdition").children(".active").text();
  362. var module_name = $("#optionModular").children(".active").text();
  363. var unit_name = $(this).text();
  364. var names = text_book_name + '_' + module_name + '_' + unit_name;
  365. var _html = '<span node="' + ids + '">' + names + '<i class="delete-icon" onclick="deleteUnit(this)"></i></span>';
  366. $("#selectedUnit").append(_html);
  367. });
  368. $("body").delegate("#optionPaper span","click",function () {
  369. if($('#selectedPaper span').length == 1){
  370. layer.msg('已选试卷超出限制');return false;
  371. }
  372. var paper_id = $(this).attr("code");
  373. var selected_arr = [];
  374. if($('#selectedPaper span').length > 0){
  375. $('#selectedPaper span').each(function(index){
  376. selected_arr.push($(this).attr('node'));
  377. });
  378. }
  379. if($.inArray(paper_id, selected_arr) >= 0){
  380. layer.msg('不能重复添加该试卷');return false;
  381. }
  382. var paper_name = $(this).text();
  383. var _html = '<span node="' + paper_id + '">' + paper_name + '<i class="delete-icon" onclick="deleteUnit(this)"></i></span>';
  384. $("#selectedPaper").append(_html);
  385. });
  386. $("#confirm[active='true']").on("click", function() {
  387. $('#confirm').attr('disabled','disabled');
  388. var This = $(this);
  389. This.attr("active","false");
  390. var error = [];
  391. var selectClassIds = [];
  392. var unitIds = [];
  393. var names = [];
  394. var specialIds = [];
  395. var specialNames = [];
  396. var create_type = $('input:radio[name="create_type"]:checked').val();
  397. var is_answer_merge = $('input:radio[name="is_answer_merge"]:checked').val();
  398. var paperIds = [];
  399. var paperNames = [];
  400. // var train_push_type = $('input:radio[name="train_push_type"]:checked').val();
  401. $('#optionClass input:checked').each(function(k,v){
  402. selectClassIds.push($(this).val());
  403. });
  404. $('#selectedUnit span').each(function(k,v){
  405. unitIds.push($(this).attr('node'));
  406. names.push($(this).text())
  407. });
  408. $('#selectedSpecials span').each(function(k,v){
  409. specialIds.push($(this).attr('node'));
  410. specialNames.push($(this).text())
  411. });
  412. if(specialIds.length == 0){
  413. $('#optionEdition span').each(function(k,v){
  414. if($(this).hasClass('active')) {
  415. specialIds.push($(this).attr('code'));
  416. specialNames.push($(this).text())
  417. }
  418. });
  419. }
  420. $('#selectedPaper span').each(function(k,v){
  421. paperIds.push($(this).attr('node'));
  422. });
  423. $('#selectedPaper span').each(function(k,v){
  424. paperNames.push($(this).text());
  425. });
  426. if(selectClassIds.length == 0){
  427. error.push("请选择班级");
  428. }
  429. if(create_type == 1){
  430. if(specialIds.length == 0){
  431. error.push("请选择专题")
  432. }
  433. }else{
  434. if(unitIds.length == 0 && paperIds.length == 0){
  435. error.push("请专题方法或试卷生成")
  436. }
  437. }
  438. if(error.length == 0){
  439. $.ajax({
  440. url: "<?php echo $this->createUrl('special/ajaxSaveSetting');?>",
  441. type: "POST",
  442. dataType: "json",
  443. data: {
  444. grade: 3,
  445. selectClassIds:selectClassIds,
  446. unitIds: unitIds,
  447. names: names,
  448. createType : create_type,
  449. // trainPushType : train_push_type,
  450. specialIds : specialIds,
  451. specialNames : specialNames,
  452. paperIds : paperIds,
  453. isAnswerMerge : is_answer_merge,
  454. paperNames : paperNames
  455. },
  456. success: function (data) {
  457. if(data.status == 1){
  458. layer.msg('已发送到后台,预计1小时左右生成!', {
  459. time: 2000,
  460. });
  461. setTimeout(function(){window.location.href = "<?php echo Yii::app()->createUrl('special/index');?>";}, 2000);
  462. }else{
  463. layer.msg(data.error);
  464. This.attr("active","true");
  465. }
  466. $('#confirm').removeAttr('disabled');
  467. }
  468. });
  469. }else{
  470. $('#confirm').removeAttr('disabled');
  471. This.attr("active","true");
  472. layer.msg(error.join('</br>'));
  473. }
  474. });
  475. function getClassByGrade(grade){
  476. if(grade){
  477. $.ajax({
  478. url: "<?php echo $this->createUrl('special/ajaxGetClasses');?>",
  479. type: "POST",
  480. dataType: "json",
  481. data: {
  482. grade: grade,
  483. },
  484. beforeSend:function(){
  485. layer.load(1, {
  486. shade: [0.1,'#fff'] //0.1透明度的白色背景
  487. });
  488. },
  489. success: function (data) {
  490. var index = layer.load();
  491. layer.close(index);
  492. var html = '';
  493. if(data && data.length > 0){
  494. for(var i in data){
  495. html +='<label>';
  496. html += ' <input type="checkbox" name="option-class" value="'+data[i].class_id+'">'+data[i].class_name+'</label>';
  497. }
  498. }
  499. $('#optionClass').html(html);
  500. }
  501. });
  502. }
  503. }
  504. });
  505. function limitUnit() {
  506. var selected_count = $("#selectedUnit").children("span").length;
  507. if(selected_count == 12){
  508. return false;
  509. }
  510. return true;
  511. }
  512. function isPositiveInteger(s){//是否为正整数
  513. var reg = /^[1-9]\d*$/;
  514. return reg.test(s)
  515. }
  516. function deleteUnit(a) {
  517. $(a).parent().remove();
  518. }
  519. </script>