upload.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  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">上传成绩 <a href="<?php echo $this->createUrl('zhiliao/downloadexcel');?>">下载Excel表格示例</a></div>
  21. <form class="saveForm" action="<?php echo Yii::app()->createUrl('zhiliao/importstore')?>" method="post" enctype="multipart/form-data">
  22. <div class="mcp-form-list clearfix">
  23. <input type="file" name="exname">
  24. </div>
  25. <div class="mcp-form-list clearfix">
  26. <input type="hidden" name="exam_group_id" value="<?php if(isset($examGroupId)) echo $examGroupId;?>">
  27. <input type="submit" value="提交" class="label-primary-s bth-s" >
  28. <input type="reset" value="重置" class="label-primary-s bth-s">
  29. </div>
  30. </form>
  31. </div>
  32. </div>
  33. <script>
  34. $(document).ready(function(){
  35. var selectedClassId=[];
  36. <?php
  37. if(isset($exam['classes'])){
  38. foreach ($exam['classes'] as $cid=>$cname){
  39. echo "selectedClassId.push('".$cid."');";
  40. }
  41. }
  42. ?>
  43. loadClass();
  44. $('.datetimepicker8').datetimepicker({
  45. onGenerate:function( ct ){
  46. $(this).find('.xdsoft_date').toggleClass('xdsoft_disabled');
  47. $(this).find('.xdsoft_today').removeClass('xdsoft_disabled');
  48. },
  49. format:'Y-m-d',
  50. formatDate:'Y-m-d',
  51. //minDate:'-1970/01/2',
  52. maxDate:'+1970/01/2',
  53. minDate: '-<?php echo date('Y-m-d', strtotime('Yesterday')); ?>',
  54. timepicker:false
  55. });
  56. //返回
  57. $('.mcp-back-btn').click(function(){
  58. location.href="<?php echo Yii::app()->createUrl('zhiliao/index')?>";
  59. });
  60. $('input[name="examName"]').keydown(function(event){
  61. $('#examName-error').html("");
  62. });
  63. //考试类型
  64. $('.examType').click(function(){
  65. var type = $(this).attr('value');
  66. if(type){
  67. $('#type-error').html("");
  68. }
  69. $('input[name="type"]').val(type);
  70. });
  71. //加载班级
  72. function loadClass(){
  73. $.post(
  74. "<?php echo Yii::app()->createUrl('zhiliao/ajaxchangeclasses')?>",
  75. {'selectedClassId':selectedClassId},
  76. function(result){
  77. if(result.error){
  78. $('#choose-error').html(result.error);
  79. }else{
  80. var htmlg1 = "";
  81. var htmlg2 = "";
  82. var htmlg3 = "";
  83. $.each(result.class_arr_select,function(k,v){
  84. if(v.grade == 1){
  85. htmlg1+="<span grade='"+v.grade+"' classid='"+v.class_id+"'>"+v.class_name+"</span>";
  86. }
  87. if(v.grade == 2){
  88. htmlg2+="<span grade='"+v.grade+"' classid='"+v.class_id+"'>"+v.class_name+"</span>";
  89. }
  90. if(v.grade == 3){
  91. htmlg3+="<span grade='"+v.grade+"' classid='"+v.class_id+"'>"+v.class_name+"</span>";
  92. }
  93. });
  94. $('.g1').html(htmlg1);
  95. $('.g2').html(htmlg2);
  96. $('.g3').html(htmlg3);
  97. var htmlidg1 = "";
  98. var htmlidg2 = "";
  99. var htmlidg3 = "";
  100. $.each(result.class_arr_noselect,function(k,v){
  101. if(v.grade == 1){
  102. htmlidg1 += '<li class="bjs-lis ellipsis" grade="'+v.grade+'" classid="'+v.class_id+'" ><span class="judge-sel"></span>'+v.class_name+'</li>';
  103. }
  104. if(v.grade == 2){
  105. htmlidg2 += '<li class="bjs-lis ellipsis" grade="'+v.grade+'" classid="'+v.class_id+'" ><span class="judge-sel"></span>'+v.class_name+'</li>';
  106. }
  107. if(v.grade == 3){
  108. htmlidg3 += '<li class="bjs-lis ellipsis" grade="'+v.grade+'" classid="'+v.class_id+'" ><span class="judge-sel"></span>'+v.class_name+'</li>';
  109. }
  110. });
  111. $('#grade1 ul').html(htmlidg1);
  112. $('#grade2 ul').html(htmlidg2);
  113. $('#grade3 ul').html(htmlidg3);
  114. }
  115. },
  116. 'json'
  117. );
  118. }
  119. //切换年级
  120. $('.a-years,.a-province,.paper-type > span, .grade-sel ul li').click(function(){
  121. if(!$(this).hasClass('active')){
  122. $(this).addClass('active').siblings().removeClass('active');
  123. var gradearr=[1,2,3];
  124. var grade=$(this).attr("grade");
  125. $('input[name=grade]').val(grade);
  126. for(var i=0;i<=gradearr.length;i++){
  127. if(gradearr[i]==grade){
  128. $("#grade"+grade).show();
  129. $('.g'+grade).show();
  130. $('.g'+grade).attr('status',1);
  131. }else{
  132. $("#grade"+gradearr[i]).hide();
  133. $(".g"+gradearr[i]).hide();
  134. $(".g"+gradearr[i]).attr('status',0);
  135. }
  136. }
  137. }
  138. });
  139. //添加班级
  140. $(".bj-sel ul").on("click","li", function(){
  141. $('#classIds-error').html("");
  142. $(this).find('.judge-sel').addClass('active');
  143. $(this).remove();
  144. var grade = $(this).attr('grade');
  145. $('.g'+grade).append('<span grade="'+$(this).attr("grade")+'" classid="'+$(this).attr("classid")+'">'+$(this).text()+'</span>');
  146. });
  147. //移除班级
  148. $('.sel-classes').delegate('span','click',function(){
  149. $(this).remove();
  150. $("#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>');
  151. });
  152. if ($('.sel-classes > span').length > 0){
  153. for (var i = 0;i < $('.sel-classes > span').length; i++){
  154. for (var k = 0;k < $('.bjs-lis').length; k++){
  155. if ($('.bjs-lis').eq(k).text().trim()==$('.sel-classes > span').eq(i).text().trim()) {
  156. $('.bjs-lis').eq(k).find('.judge-sel').addClass('active');
  157. }
  158. }
  159. }
  160. }
  161. $('.mcp-radio-sel').click(function(){
  162. if (!$(this).find('.sel-btn').hasClass('select')) {
  163. $(this).find('.sel-btn').addClass('select');
  164. $(this).siblings().find('.sel-btn').removeClass('select');
  165. }
  166. });
  167. $('.grade-sel ul li').click(function(){
  168. $(this).addClass('active').siblings().removeClass('active');
  169. });
  170. $('.sel-classes > span').click(function(){
  171. $(this).remove();
  172. for (var i = 0;i < $('.bjs-lis').length; i++) {
  173. if ($('.bjs-lis').eq(i).text().trim()==$(this).text().trim()){
  174. $('.bjs-lis').eq(i).find('.judge-sel').removeClass('active');
  175. }
  176. }
  177. });
  178. //选择科目
  179. $('body').on('click','.subject',function(){
  180. var subject_id=$(this).val(),
  181. subject_name=$(this).attr('data');
  182. if($(this).is(":checked")){
  183. 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>';
  184. $('.subject_scores').append(html);
  185. }else{
  186. $('#subject_'+subject_id).closest('label').remove();
  187. }
  188. });
  189. // 下拉列表模拟
  190. $('.inp-text').click(function(){
  191. if ($(this).next().is(':hidden')){
  192. $(this).next().show();
  193. } else {
  194. $(this).next().hide();
  195. }
  196. });
  197. // 点下拉列表选项
  198. $('.select-con li').click(function(){
  199. $(this).closest('.select-con').hide();
  200. $(this).closest('.mcp-form-detail').find('.inp-text').text($(this).text());
  201. });
  202. // 点击空白处下拉列表消失
  203. $(document).click(function(e){
  204. var targetNode = $(e.target).closest(".inp-text");
  205. if (targetNode.length>0){
  206. return;
  207. }else{
  208. $(".select-con").hide();
  209. }
  210. });
  211. $("body").delegate("#createThird[active='true']", "click", function(e) {
  212. var classIds='';
  213. $(".sel-classes[status=1]").children("span").each(function(){
  214. classIds += $(this).attr('classid')+",";
  215. });
  216. $('input[name="classIds"]').val(classIds);
  217. var error = new Array();
  218. var classIds = $('input[name="classIds"]').val();
  219. var examName = $('input[name="examName"]').val();
  220. var type = $('input[name="type"]').val();
  221. var examDate = $("input[name='examDate']").val();
  222. if(examName == "" || examName == null){
  223. $('#examName-error').html('请指定考试名称');
  224. error.push('没有指定考试名称');
  225. }else{
  226. $('#examName-error').html('');
  227. }
  228. if(type == "" || type == null){
  229. $('#type-error').html('请指定考试类型');
  230. error.push('没有指定考试类型');
  231. }else{
  232. $('#type-error').html('');
  233. }
  234. $('#choose-error').html('');
  235. if(classIds == "" || classIds == null){
  236. $('#classIds-error').html('请指定考试班级');
  237. error.push('没有指定考试班级');
  238. }else{
  239. $('#classIds-error').html('');
  240. }
  241. if (examDate == '') {
  242. $('#examDate').html('请设置考试日期');
  243. error.push('请设置考试日期');
  244. } else if (examDate < '<?php echo date('Y-m-d'); ?>') {
  245. $('#examDate').html('考试日期设置错误');
  246. error.push('考试日期设置错误');
  247. }else{
  248. $('#examDate').html('');
  249. }
  250. //检测科目
  251. var subjects=[];
  252. // console.log($('.subject').length);
  253. for(var i=0;i<$('.subject').length;i++){
  254. if($('.subject').eq(i).is(":checked")){
  255. // subjects.push($('input[name=subject]').eq(i).val());
  256. subject_id=$('.subject').eq(i).val();
  257. score=$('#subject_'+subject_id).val();
  258. if(score=='' || isNaN(score)){
  259. $('#score-error').html('科目分数设置错误');
  260. error.push('科目分数设置错误');
  261. break;
  262. }else{
  263. subjects.push(subject_id+'///'+score);
  264. }
  265. }
  266. }
  267. if(subjects.length==0){
  268. $('#subject-error').html('请选择考试科目');
  269. error.push('没有指定考试科目');
  270. }
  271. $('input[name=subjects]').val(subjects.join(','));
  272. if(error.length == 0){
  273. $(this).attr("active","false");
  274. $(".saveForm").submit();
  275. }
  276. });
  277. });
  278. </script>