batch_addclass.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. <link type="text/css" rel="stylesheet" href="/css/needDetail.css" />
  2. <style>
  3. .handle{float: right}
  4. .font-center th{text-align: center!important;}
  5. .green-font{font-size: 12px;}
  6. </style>
  7. <div class="main-content-inner">
  8. <!-- 导航栏开始-->
  9. <?php include(Yii::app()->basePath.'/views/layouts/class_navigation.php');?>
  10. <!-- 导航栏结束-->
  11. <div class="layout-gap">
  12. <section class="anc-top flex status_1 ">
  13. <div class="flex-one flex">
  14. <p class="anc-title">导入班级 <span class="blue green-font">小贴士:新增了批量导入班级的功能,请按模板要求在excel表格内填写班级信息进行上传。</span></p>
  15. </div>
  16. </section>
  17. <section class="anc-main-con">
  18. <div class="form-group">
  19. <label class="control-label col-xs-12 col-sm-1 no-padding-right">模板示例<span class="errorMessage">*</span>:</label>
  20. <div class="col-sm-11">
  21. <table id="template" class="table table-striped table-bordered table-hover dataTable no-footer DTTT_selectable font-center">
  22. <tr>
  23. <th><span class="red">*</span>班级名称</th>
  24. <th><span class="red">*</span>年级</th>
  25. <th><span class="red">*</span>层级</th>
  26. <th><span class="red">*</span>学科</th>
  27. <th><span class="red">*</span>老师</th>
  28. <th><span class="red">*</span>老师电话</th>
  29. </tr>
  30. <tr>
  31. <th></th>
  32. <th></th>
  33. <th></th>
  34. <th></th>
  35. <th></th>
  36. <th></th>
  37. </tr>
  38. </table>
  39. </div>
  40. </div>
  41. <div class="form-group">
  42. <label class="control-label col-xs-12 col-sm-1 no-padding-right">填写须知<span class="errorMessage">*</span>:</label>
  43. <div class="col-sm-11">
  44. <div>1、Excel中带“*”为必填字段</div>
  45. <div>2、表格以及系统内班级名称不能重复</div>
  46. <div>3、年级只能填写“1”、“2”、“3”,分别代表“高一”、“高二”、“高三”</div>
  47. <div>4、层级只能填写“A”、“B”、“C”</div>
  48. <div>5、学科、老师和老师电话要与系统内相匹配(注意:多个学科、老师及老师电话需要用中文分号隔开,且每个学科的前后顺序需与老师、老师电话对应)</div>
  49. </div>
  50. </div>
  51. <div class="clearfix form-actions">
  52. <div class="col-md-offset-1">
  53. <a class="btn label-primary-green btn-sm" href="/assets/data/bulk_import_class2.xls">
  54. 下载excel模板
  55. </a>
  56. <div class="btn label-primary-green btn-sm select_file" >上传excel</div>
  57. <form id="form1" action="<?php echo $this->createUrl('classes/classImportType2')?>" method="post" enctype="multipart/form-data">
  58. <input type="file" name="file" id="uploadFile" style="display: none">
  59. </form>
  60. </div>
  61. </div>
  62. <div class="clearfix form-actions">
  63. </div>
  64. </section>
  65. <section class="anc-finish-opt gray-border-top" >
  66. <div class="anc-finish-btn save_result hide" >确认导入成绩</div>
  67. </section>
  68. </div>
  69. </div>
  70. <div class="anc-pop">
  71. <div class="confirm-pop-con">
  72. <div class="need-pop-top clearfix">
  73. <div class="npt-title put-need fl">提示</div>
  74. <div class="npt-close fr">×</div>
  75. </div>
  76. <div class="confirm-msg red-font tac">
  77. 确认要放弃本次上传的数据吗?
  78. </div>
  79. <div class="pop-btns">
  80. <div class="confirm-pop-btn-sure">确认</div>
  81. <div class="confirm-pop-btn-cancel cancel-btn">取消</div>
  82. </div>
  83. </div>
  84. </div>
  85. <script>
  86. $(function(){
  87. /*
  88. $('.begain-check-btn').click(function(){
  89. $('.anc-status-con').removeClass('hide');
  90. $(this).hide();
  91. $('.anc-index-msg').hide();
  92. loadStudent();
  93. });
  94. */
  95. //checkFirst();
  96. //保存结果
  97. $('.save_result').click(function(){
  98. var l_index=layer.msg('导入中,请稍候......',{time:0});
  99. $.ajax({
  100. url:'<?php echo $this->createUrl('record/update_score')?>',
  101. dataType:'json',
  102. type:'POST',
  103. success:function(res){
  104. layer.close(l_index);
  105. if(res.status==1){
  106. layer.msg('导入成功',function(){
  107. window.location.href="<?php echo $this->createUrl('record/importscore')?>";
  108. });
  109. }else{
  110. layer.msg('导入失败');
  111. }
  112. }
  113. });
  114. });
  115. //第一步,检测数据
  116. // function checkFirst(){
  117. // var count=0;
  118. // $.ajax({
  119. // url:'<?php //echo $this->createUrl('record/Check_field_first')?>//',
  120. // dataType:'json',
  121. // type:'POST',
  122. // success:function(res){
  123. // if(res.status==1){
  124. // $('.first').addClass('finish-status');
  125. // $('.first').removeClass('now-status');
  126. // $('.first .status-charact').html('检查完成,导入的excel格式正确');
  127. // <?php //if($need_check_name==1):?>
  128. // checkAbnormal();
  129. // <?php //else:?>
  130. // checkRepeat();
  131. // <?php //endif;?>
  132. // }else{
  133. // $('.first').addClass('error-status');
  134. // $('.first').removeClass('now-status');
  135. // $('.first .status-charact').html('导入的excel格式与模版不一致,请重新上传:'+res.msg);
  136. // }
  137. // }
  138. // });
  139. // }
  140. //第二步,姓名异常
  141. function checkAbnormal(){
  142. $('.second .status-charact').html('正在检测...');
  143. $('.second').addClass('now-status');
  144. $.ajax({
  145. url:'<?php echo $this->createUrl('record/check_student_name')?>',
  146. dataType:'json',
  147. type:'POST',
  148. success:function(res){
  149. if(res.status==1){
  150. count=res.count;
  151. $('.second .status-charact').html('检测完成,已为'+count+'名学生去除姓名中的非汉字字符');
  152. $('.second').addClass('finish-status');
  153. $('.second').removeClass('now-status');
  154. checkRepeat();
  155. }else{
  156. $('.second .status-charact').html('检测失败');
  157. $('.second').addClass('error-status');
  158. $('.second').removeClass('now-status');
  159. }
  160. }
  161. });
  162. }
  163. //第三步
  164. function checkRepeat(){
  165. $('.fourth .status-charact').html('正在检测...');
  166. $('.fourth').addClass('now-status');
  167. $.ajax({
  168. url:'<?php echo $this->createUrl('record/matching')?>',
  169. dataType:'json',
  170. type:'POST',
  171. success:function(res){
  172. if(res.status==1){
  173. var html='';
  174. if(res.repeat>0){
  175. html+='<p>重名学生<span class="handle"><a href="<?php echo $this->createUrl('record/handle_repeat')?>">'+res.repeat+'组</a></span></p>';
  176. }else{
  177. html+='<p>重名学生<span class="handle">'+res.repeat+'组</span></p>';
  178. }
  179. if(res.noExistent>0){
  180. html+='<p>学生在系统中不存在<span class="handle"><a href="<?php echo $this->createUrl('record/handle_existent')?>">'+res.noExistent+'人</a></span></p>';
  181. }else{
  182. html+='<p>学生在系统中不存在<span class="handle">'+res.noExistent+'人</span></p>';
  183. }
  184. html+='<p>匹配成功<span class="handle">'+res.success+'人</span></p>';
  185. $('.third .status-charact').html(html);
  186. if(res.repeat==0 && res.success>0){
  187. $('.save_result').removeClass('hide');
  188. }
  189. $('.third').addClass('now-status');
  190. }else{
  191. $('.third .status-charact').html('检测失败,请稍后再试');
  192. $('.third').addClass('error-status');
  193. $('.third').removeClass('now-status');
  194. }
  195. }
  196. });
  197. }
  198. $('.give-up-check').click(function(){
  199. $('.anc-pop').show()
  200. })
  201. $('.npt-close,.confirm-pop-btn-cancel').click(function(){
  202. $('.anc-pop').hide()
  203. })
  204. $('.confirm-pop-btn-sure').click(function () {
  205. $.ajax({
  206. url:'<?php echo $this->createUrl('record/giveup')?>',
  207. dataType:'json',
  208. type:'POST',
  209. success:function(res){
  210. if(res.status==1){
  211. $('.anc-pop').hide();
  212. window.location.href='<?php echo $this->createUrl('record/importscore')?>';
  213. }else{
  214. $('.anc-pop').hide();
  215. }
  216. }
  217. });
  218. });
  219. $('#uploadFile').val('');
  220. $('.select_file').click(function(){
  221. $('#uploadFile').click();
  222. });
  223. $('#uploadFile').change(function(){
  224. if($('#uploadFile').val()!=''){
  225. $('#form1').submit();
  226. }
  227. });
  228. })
  229. </script>