thirdview.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. <script src="/js/jquery.datetimepicker.js"></script>
  2. <link rel="stylesheet" href="/fonts/fpdf/iconfont.css" />
  3. <link rel="stylesheet" href="/css/modelCreatePaper.css" />
  4. <link rel="stylesheet" href="/css/jquery.datetimepicker.css" />
  5. <style>
  6. #choose-error{color: #FF0000;}
  7. #examName-error{color: #FF0000;}
  8. #classIds-error{color: #FF0000;}
  9. #type-error{color: #FF0000;}
  10. #markType-error{color: #FF0000;}
  11. #subject-error,#score-error{color: #FF0000;}
  12. #examDate{color: #FF0000;}
  13. .check_subject{margin-right:15px;}
  14. </style>
  15. <div class="main-content-inner">
  16. <!-- 导航栏开始-->
  17. <?php include(Yii::app()->basePath.'/views/layouts/view_navigation.php');?>
  18. <!-- 导航栏结束-->
  19. <div class="page-content">
  20. <div class="mcp-title">模板组卷</div>
  21. <form class="saveForm" action="<?php echo Yii::app()->createUrl('zhiliao/createexam')?>" method="post" enctype="multipart/form-data">
  22. <div class="mcp-main-con">
  23. <div class="mcp-form-list clearfix">
  24. <div class="mcp-form-menu fl">试卷名称</div>
  25. <div class="mcp-form-detail fl"><input type="text" placeholder="必填" value="<?php if(isset($exam['zl_exam_name'])){echo $exam['zl_exam_name'];}?>" class="test-paper-name" name="examName"></div>
  26. <div id="examName-error"></div>
  27. </div>
  28. <div class="mcp-form-list clearfix">
  29. <div class="mcp-form-menu fl">参考科目</div>
  30. <div class="mcp-form-detail fl clearfix">
  31. <?php
  32. if(isset($subject) && $subject){
  33. foreach($subject as $key=> $val){
  34. if(isset($exam['items']) && isset($exam['items'][$key])){
  35. echo '<label for="k1" class="check_subject mlr5"><input type="checkbox" checked class="subject" name="subject" data="'.$val.'" value="'.$key.'">'.$val.'</label>';
  36. }else{
  37. echo '<label for="k1" class="check_subject mlr5"><input type="checkbox" class="subject" name="subject" data="'.$val.'" value="'.$key.'">'.$val.'</label>';
  38. }
  39. }
  40. }
  41. ?>
  42. </div>
  43. <div id="subject-error"></div>
  44. </div>
  45. <div class="mcp-form-list clearfix">
  46. <div class="mcp-form-menu fl">考试总分</div>
  47. <div class="mcp-form-detail fl clearfix subject_scores">
  48. <?php
  49. if(isset($exam['items'])){
  50. foreach ($exam['items'] as $key => $val){
  51. echo '<label for="k1" class="check_subject mlr5">'.$subject[$key].':<input type="text" style="width:75px;" name="subject_s" id="subject_'.$key.'" value="'.$val.'"></label>';
  52. }
  53. }
  54. ?>
  55. </div>
  56. <div id="score-error"></div>
  57. </div>
  58. <div class="mcp-form-list clearfix">
  59. <div class="mcp-form-menu fl">选择考试类型</div>
  60. <div class="mcp-form-detail fl clearfix">
  61. <div class="mcp-radio-sel fl">
  62. <span class="sel-btn <?php if(isset($exam['zl_exam_type']) && $exam['zl_exam_type']==1){echo 'select';}?> examType" value="1"></span>
  63. <span>周考</span>
  64. </div>
  65. <div class="mcp-radio-sel fl">
  66. <span class="sel-btn <?php if(isset($exam['zl_exam_type']) && $exam['zl_exam_type']==2){echo 'select';}?> examType" value="2"></span>
  67. <span>单元考</span>
  68. </div>
  69. <div class="mcp-radio-sel fl">
  70. <span class="sel-btn <?php if(isset($exam['zl_exam_type']) && $exam['zl_exam_type']==3){echo 'select';}?> examType" value="3"></span>
  71. <span>月考</span>
  72. </div>
  73. <div class="mcp-radio-sel fl">
  74. <span class="sel-btn <?php if(isset($exam['zl_exam_type']) && $exam['zl_exam_type']==4){echo 'select';}?> examType" value="4"></span>
  75. <span>联考</span>
  76. </div>
  77. <div class="mcp-radio-sel fl">
  78. <span class="sel-btn <?php if(isset($exam['zl_exam_type']) && $exam['zl_exam_type']==5){echo 'select';}?> examType" value="5"></span>
  79. <span>期中考试</span>
  80. </div>
  81. <div class="mcp-radio-sel fl">
  82. <span class="sel-btn <?php if(isset($exam['zl_exam_type']) && $exam['zl_exam_type']==6){echo 'select';}?> examType" value="6"></span>
  83. <span>期末考试</span>
  84. </div>
  85. <div class="mcp-radio-sel fl">
  86. <span class="sel-btn <?php if(isset($exam['zl_exam_type']) && $exam['zl_exam_type']==7){echo 'select';}?> examType" value="7"></span>
  87. <span>模拟考</span>
  88. </div>
  89. <div class="mcp-radio-sel fl">
  90. <span class="sel-btn <?php if(isset($exam['zl_exam_type']) && $exam['zl_exam_type']==8){echo 'select';}?> examType" value="8"></span>
  91. <span>冲刺考</span>
  92. </div>
  93. </div>
  94. <div id="type-error"></div>
  95. </div>
  96. <div class="mcp-form-list clearfix">
  97. <div class="mcp-form-menu fl">考试班级</div>
  98. <div class="mcp-form-detail fl">
  99. <div class="test-classes-desc">(<span class="">单击移除</span>)<span id="classIds-error"></span></div>
  100. <div class="sel-classes g1" status="1">
  101. </div>
  102. <div class="sel-classes g2" style="display: none;" status="0">
  103. </div>
  104. <div class="sel-classes g3" style="display: none;" status="0">
  105. </div>
  106. <div class="clearfix">
  107. <div class="grade-sel fl">
  108. <div class="grade-top">年级</div>
  109. <ul>
  110. <li class="active" grade="1">高一</li>
  111. <li class="" grade="2">高二</li>
  112. <li class="" grade="3">高三</li>
  113. </ul>
  114. </div>
  115. <div class="bj-sel fl" id="grade1">
  116. <div class="class-top">班级</div>
  117. <ul>
  118. </ul>
  119. </div>
  120. <div class="bj-sel fl" id="grade2" style="display: none;">
  121. <div class="class-top">班级</div>
  122. <ul>
  123. </ul>
  124. </div>
  125. <div class="bj-sel fl" id="grade3" style="display: none;">
  126. <div class="class-top">班级</div>
  127. <ul>
  128. </ul>
  129. </div>
  130. </div>
  131. </div>
  132. </div>
  133. <div class="mcp-form-list clearfix">
  134. <div class="mcp-form-menu fl">考试时间</div>
  135. <div class="mcp-form-detail fl clearfix">
  136. <input type="text" class='core datetimepicker8' readonly value="<?php if(isset($exam['examDate'])) echo $exam['examDate'] ?>" style="width: 100px;" name="examDate" />
  137. </div>
  138. <div id="examDate"></div>
  139. </div>
  140. </div>
  141. <input name="type" value="<?php if(isset($exam['zl_exam_type'])){echo $exam['zl_exam_type'];}?>" type="hidden"/>
  142. <input name="subjects" value="" type="hidden"/>
  143. <input name="classIds" value="0" type="hidden"/>
  144. <input name="grade" value="1" type="hidden"/>
  145. <input name="exam_group_id" value="<?php if(isset($exam_group_id)){echo $exam_group_id;}else{echo 0;}?>" type="hidden"/>
  146. </form>
  147. <!--<button id="createThird">确定</button>-->
  148. <div class="mcp-form-list mcp-fl-btns clearfix">
  149. <input type="button" value="确定" class="mcp-sure-btn" id="createThird" active="true">
  150. <input type="button" value="返回" class="mcp-back-btn">
  151. </div>
  152. </div>
  153. </div>
  154. <script>
  155. $(document).ready(function(){
  156. var selectedClassId=[];
  157. <?php
  158. if(isset($exam['classes'])){
  159. foreach ($exam['classes'] as $cid=>$cname){
  160. echo "selectedClassId.push('".$cid."');";
  161. }
  162. }
  163. ?>
  164. loadClass();
  165. $('.datetimepicker8').datetimepicker({
  166. onGenerate:function( ct ){
  167. $(this).find('.xdsoft_date').toggleClass('xdsoft_disabled');
  168. $(this).find('.xdsoft_today').removeClass('xdsoft_disabled');
  169. },
  170. format:'Y-m-d',
  171. formatDate:'Y-m-d',
  172. minDate:'-1970/01/2',
  173. maxDate:'+1970/01/2',
  174. //minDate: '-<?php echo date('Y-m-d', strtotime('Yesterday')); ?>',
  175. timepicker:false
  176. });
  177. //返回
  178. $('.mcp-back-btn').click(function(){
  179. location.href="<?php echo Yii::app()->createUrl('zhiliao/index')?>";
  180. });
  181. $('input[name="examName"]').keydown(function(event){
  182. $('#examName-error').html("");
  183. });
  184. //考试类型
  185. $('.examType').click(function(){
  186. var type = $(this).attr('value');
  187. if(type){
  188. $('#type-error').html("");
  189. }
  190. $('input[name="type"]').val(type);
  191. });
  192. //加载班级
  193. function loadClass(){
  194. $.post(
  195. "<?php echo Yii::app()->createUrl('zhiliao/ajaxchangeclasses')?>",
  196. {'selectedClassId':selectedClassId},
  197. function(result){
  198. if(result.error){
  199. $('#choose-error').html(result.error);
  200. }else{
  201. var htmlg1 = "";
  202. var htmlg2 = "";
  203. var htmlg3 = "";
  204. $('.g1').hide();
  205. $('.g2').hide();
  206. $('.g3').hide();
  207. $('.g1').attr('status',0);
  208. $('.g2').attr('status',0);
  209. $('.g3').attr('status',0);
  210. if(result.class_arr_select.length>0){
  211. $.each(result.class_arr_select,function(k,v){
  212. if(v.grade == 1){
  213. htmlg1+="<span grade='"+v.grade+"' classid='"+v.class_id+"'>"+v.class_name+"</span>";
  214. $('.g1').show();
  215. $('.g1').attr('status',1);
  216. $('.grade-sel ul li').eq(0).addClass('active');
  217. $('.grade-sel ul li').eq(1).removeClass('active');
  218. $('.grade-sel ul li').eq(2).removeClass('active');
  219. $('#grade1').show();
  220. $('#grade2').hide();
  221. $('#grade3').hide();
  222. $('input[name=grade]').val(1);
  223. }
  224. if(v.grade == 2){
  225. htmlg2+="<span grade='"+v.grade+"' classid='"+v.class_id+"'>"+v.class_name+"</span>";
  226. $('.g2').show();
  227. $('.g2').attr('status',1);
  228. $('.grade-sel ul li').eq(1).addClass('active');
  229. $('.grade-sel ul li').eq(0).removeClass('active');
  230. $('.grade-sel ul li').eq(2).removeClass('active');
  231. $('#grade1').hide();
  232. $('#grade2').show();
  233. $('#grade3').hide();
  234. $('input[name=grade]').val(2);
  235. }
  236. if(v.grade == 3){
  237. htmlg3+="<span grade='"+v.grade+"' classid='"+v.class_id+"'>"+v.class_name+"</span>";
  238. $('.g3').show();
  239. $('.g3').attr('status',1);
  240. $('.grade-sel ul li').eq(2).addClass('active');
  241. $('.grade-sel ul li').eq(0).removeClass('active');
  242. $('.grade-sel ul li').eq(1).removeClass('active');
  243. $('#grade1').hide();
  244. $('#grade2').hide();
  245. $('#grade3').show();
  246. $('input[name=grade]').val(3);
  247. }
  248. });
  249. }else{
  250. $('.g1').show();
  251. $('.g1').attr('status',1);
  252. }
  253. $('.g1').html(htmlg1);
  254. $('.g2').html(htmlg2);
  255. $('.g3').html(htmlg3);
  256. var htmlidg1 = "";
  257. var htmlidg2 = "";
  258. var htmlidg3 = "";
  259. $.each(result.class_arr_noselect,function(k,v){
  260. if(v.grade == 1){
  261. htmlidg1 += '<li class="bjs-lis ellipsis" grade="'+v.grade+'" classid="'+v.class_id+'" ><span class="judge-sel"></span>'+v.class_name+'</li>';
  262. }
  263. if(v.grade == 2){
  264. htmlidg2 += '<li class="bjs-lis ellipsis" grade="'+v.grade+'" classid="'+v.class_id+'" ><span class="judge-sel"></span>'+v.class_name+'</li>';
  265. }
  266. if(v.grade == 3){
  267. htmlidg3 += '<li class="bjs-lis ellipsis" grade="'+v.grade+'" classid="'+v.class_id+'" ><span class="judge-sel"></span>'+v.class_name+'</li>';
  268. }
  269. });
  270. $('#grade1 ul').html(htmlidg1);
  271. $('#grade2 ul').html(htmlidg2);
  272. $('#grade3 ul').html(htmlidg3);
  273. }
  274. },
  275. 'json'
  276. );
  277. }
  278. //切换年级
  279. $('.a-years,.a-province,.paper-type > span, .grade-sel ul li').click(function(){
  280. if(!$(this).hasClass('active')){
  281. $(this).addClass('active').siblings().removeClass('active');
  282. var gradearr=[1,2,3];
  283. var grade=$(this).attr("grade");
  284. $('input[name=grade]').val(grade);
  285. for(var i=0;i<=gradearr.length;i++){
  286. if(gradearr[i]==grade){
  287. $("#grade"+grade).show();
  288. $('.g'+grade).show();
  289. $('.g'+grade).attr('status',1);
  290. }else{
  291. $("#grade"+gradearr[i]).hide();
  292. $(".g"+gradearr[i]).hide();
  293. $(".g"+gradearr[i]).attr('status',0);
  294. }
  295. }
  296. }
  297. });
  298. //添加班级
  299. $(".bj-sel ul").on("click","li", function(){
  300. $('#classIds-error').html("");
  301. $(this).find('.judge-sel').addClass('active');
  302. $(this).remove();
  303. var grade = $(this).attr('grade');
  304. $('.g'+grade).append('<span grade="'+$(this).attr("grade")+'" classid="'+$(this).attr("classid")+'">'+$(this).text()+'</span>');
  305. });
  306. //移除班级
  307. $('.sel-classes').delegate('span','click',function(){
  308. $(this).remove();
  309. $("#grade"+$(this).attr("grade")).children("ul").append('<li class="bjs-lis" grade="'+$(this).attr("grade")+'" classid="'+$(this).attr("classid")+'"><span class="judge-sel"></span>'+$(this).html()+'</li>');
  310. });
  311. if ($('.sel-classes > span').length > 0){
  312. for (var i = 0;i < $('.sel-classes > span').length; i++){
  313. for (var k = 0;k < $('.bjs-lis').length; k++){
  314. if ($('.bjs-lis').eq(k).text().trim()==$('.sel-classes > span').eq(i).text().trim()) {
  315. $('.bjs-lis').eq(k).find('.judge-sel').addClass('active');
  316. }
  317. }
  318. }
  319. }
  320. $('.mcp-radio-sel').click(function(){
  321. if (!$(this).find('.sel-btn').hasClass('select')) {
  322. $(this).find('.sel-btn').addClass('select');
  323. $(this).siblings().find('.sel-btn').removeClass('select');
  324. var type = $(this).find('.examType').attr('value');
  325. // console.log(type);
  326. if(type){
  327. $('#type-error').html("");
  328. }
  329. $('input[name="type"]').val(type);
  330. }
  331. });
  332. $('.grade-sel ul li').click(function(){
  333. $(this).addClass('active').siblings().removeClass('active');
  334. });
  335. $('.sel-classes > span').click(function(){
  336. $(this).remove();
  337. for (var i = 0;i < $('.bjs-lis').length; i++) {
  338. if ($('.bjs-lis').eq(i).text().trim()==$(this).text().trim()){
  339. $('.bjs-lis').eq(i).find('.judge-sel').removeClass('active');
  340. }
  341. }
  342. });
  343. //选择科目
  344. $('body').on('click','.subject',function(){
  345. var subject_id=$(this).val(),
  346. subject_name=$(this).attr('data');
  347. HandleSubject(subject_id);
  348. if($(this).is(":checked")){
  349. html='<label for="k1" class="check_subject mlr5">'+subject_name+':<input type="text" style="width:75px;" name="subject_s" id="subject_'+subject_id+'" value=""></label>';
  350. $('.subject_scores').append(html);
  351. }else{
  352. $('#subject_'+subject_id).closest('label').remove();
  353. }
  354. });
  355. // 下拉列表模拟
  356. $('.inp-text').click(function(){
  357. if ($(this).next().is(':hidden')){
  358. $(this).next().show();
  359. } else {
  360. $(this).next().hide();
  361. }
  362. });
  363. // 点下拉列表选项
  364. $('.select-con li').click(function(){
  365. $(this).closest('.select-con').hide();
  366. $(this).closest('.mcp-form-detail').find('.inp-text').text($(this).text());
  367. });
  368. // 点击空白处下拉列表消失
  369. $(document).click(function(e){
  370. var targetNode = $(e.target).closest(".inp-text");
  371. if (targetNode.length>0){
  372. return;
  373. }else{
  374. $(".select-con").hide();
  375. }
  376. });
  377. $("body").delegate("#createThird[active='true']", "click", function(e) {
  378. var classIds='';
  379. $(".sel-classes[status=1]").children("span").each(function(){
  380. classIds += $(this).attr('classid')+",";
  381. });
  382. $('input[name="classIds"]').val(classIds);
  383. var error = new Array();
  384. var classIds = $('input[name="classIds"]').val();
  385. var examName = $('input[name="examName"]').val();
  386. var type = $('input[name="type"]').val();
  387. var examDate = $("input[name='examDate']").val();
  388. if(examName == "" || examName == null){
  389. $('#examName-error').html('请指定考试名称');
  390. error.push('没有指定考试名称');
  391. }else{
  392. $('#examName-error').html('');
  393. }
  394. if(type == "" || type == null){
  395. $('#type-error').html('请指定考试类型');
  396. error.push('没有指定考试类型');
  397. }else{
  398. $('#type-error').html('');
  399. }
  400. $('#choose-error').html('');
  401. if(classIds == "" || classIds == null){
  402. $('#classIds-error').html('请指定考试班级');
  403. error.push('没有指定考试班级');
  404. }else{
  405. $('#classIds-error').html('');
  406. }
  407. if (examDate == '') {
  408. $('#examDate').html('请设置考试日期');
  409. error.push('请设置考试日期');
  410. } else if (examDate < '<?php echo date('Y-m-d',(time()-86400*90)); ?>') {
  411. $('#examDate').html('考试日期设置错误');
  412. error.push('考试日期设置错误');
  413. }else{
  414. $('#examDate').html('');
  415. }
  416. //检测科目
  417. var subjects=[];
  418. // console.log($('.subject').length);
  419. for(var i=0;i<$('.subject').length;i++){
  420. if($('.subject').eq(i).is(":checked")){
  421. // subjects.push($('input[name=subject]').eq(i).val());
  422. subject_id=$('.subject').eq(i).val();
  423. score=$('#subject_'+subject_id).val();
  424. if(score=='' || isNaN(score)){
  425. $('#score-error').html('科目分数设置错误');
  426. error.push('科目分数设置错误');
  427. break;
  428. }else{
  429. subjects.push(subject_id+'///'+score);
  430. }
  431. }
  432. }
  433. if(subjects.length==0){
  434. $('#subject-error').html('未选择考试科目或分数设置错误');
  435. error.push('未选择考试科目或分数设置错误');
  436. }
  437. $('input[name=subjects]').val(subjects.join(','));
  438. if(error.length == 0){
  439. $(this).attr("active","false");
  440. $(".saveForm").submit();
  441. }
  442. });
  443. //理综,文综科目选择处理
  444. function HandleSubject(Subject_id) {
  445. if($.inArray(Subject_id,['12','13','14','15','16','17','18','19'])!=-1){
  446. var Arts=$('input[name="subject"]').eq(9);
  447. var Science=$('input[name="subject"]').eq(10);
  448. var ArtsStatus=Arts.is(':checked') ;
  449. var ScienceStatus=Science.is(':checked') ;
  450. var ArtsSubject=['12','13','14'];
  451. var ScienceSubject=['15','16','17'];
  452. for(var i in ArtsSubject){
  453. if($('input[name="subject"][value='+ArtsSubject[i]+']').is(':checked')==true){
  454. Arts.attr('disabled',true);
  455. break;
  456. }
  457. Arts.attr('disabled',false);
  458. }
  459. for(var i in ScienceSubject){
  460. if($('input[name="subject"][value='+ScienceSubject[i]+']').is(':checked')==true){
  461. Science.attr('disabled',true);
  462. break;
  463. }
  464. Science.attr('disabled',false);
  465. }
  466. if(Subject_id==18){
  467. var Artsdisabled=ArtsStatus==true?true:false;
  468. for(var i in ArtsSubject){
  469. $('input[name="subject"][value='+ArtsSubject[i]+']').attr('disabled',Artsdisabled);
  470. }
  471. }
  472. if(Subject_id==19){
  473. var Sciencedisabled=ScienceStatus?true:false;
  474. for(var i in ScienceSubject){
  475. $('input[name="subject"][value='+ScienceSubject[i]+']').attr('disabled',Sciencedisabled);
  476. }
  477. }
  478. }
  479. }
  480. });
  481. </script>