batch_add.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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. <?php if(Yii::app()->params['section']==1):?>
  27. <th><span class="red">*</span>文理科</th>
  28. <?php endif;?>
  29. <th><span class="red">*</span>班主任</th>
  30. <th><span class="red">*</span>班主任电话</th>
  31. <th><span class="red">*</span>学科</th>
  32. <th><span class="red">*</span>老师</th>
  33. <th><span class="red">*</span>教师电话</th>
  34. </tr>
  35. <tr>
  36. <th></th>
  37. <th></th>
  38. <th></th>
  39. <?php if(Yii::app()->params['section']==1):?>
  40. <th></th>
  41. <?php endif;?>
  42. <th></th>
  43. <th></th>
  44. <th></th>
  45. <th></th>
  46. <th></th>
  47. </tr>
  48. </table>
  49. </div>
  50. </div>
  51. <div class="form-group">
  52. <label class="control-label col-xs-12 col-sm-1 no-padding-right">填写须知<span class="errorMessage">*</span>:</label>
  53. <div class="col-sm-11">
  54. <?php if(Yii::app()->params['section']==1):?>
  55. <div>1、Excel中带“*”为必填字段</div>
  56. <div>2、表格以及系统内班级名称不能重复</div>
  57. <div>3、年级只能填写“1”、“2”、“3”,分别代表“高一”、“高二”、高三</div>
  58. <div>4、层级只能填写“A”、“B”、“C”</div>
  59. <div>5、文理科只能填写“不分科”、“文科”、“理科”</div>
  60. <div>6、班主任与班主任电话要与系统内相匹配</div>
  61. <div>7、学科、老师和老师电话要与系统内相匹配(注意:上传学科老师时,每一行添加一位学科老师,当一个班级添加多学科老师时,班级名称、年级等需合并单元格)</div>
  62. <?php elseif(Yii::app()->params['section']==3):?>
  63. <div>1、Excel中带“*”为必填字段</div>
  64. <div>2、表格以及系统内班级名称不能重复</div>
  65. <div>3、年级只能填写“10”、“11”、“12”,分别代表“高一”、“高二”、高三</div>
  66. <div>4、层级只能填写“A”、“B”、“C”</div>
  67. <div>5、班主任与班主任电话要与系统内相匹配</div>
  68. <div>6、学科、老师和老师电话要与系统内相匹配(注意:上传学科老师时,每一行添加一位学科老师,当一个班级添加多学科老师时,班级名称、年级等需合并单元格)</div>
  69. <?php else:?>
  70. <div>1、Excel中带“*”为必填字段</div>
  71. <div>2、表格以及系统内班级名称不能重复</div>
  72. <div>3、年级只能填写阿拉伯数字,例如:“7”、“8”、“9”,分别代表“七年级”、“八年级”、“九年级”</div>
  73. <div>4、层级只能填写“A”、“B”、“C”</div>
  74. <div>5、班主任与班主任电话要与系统内相匹配</div>
  75. <div>7、学科、老师和老师电话要与系统内相匹配(注意:上传学科老师时,每一行添加一位学科老师,当一个班级添加多学科老师时,班级名称、年级等需合并单元格)</div>
  76. <?php endif;?>
  77. </div>
  78. </div>
  79. <div class="clearfix form-actions">
  80. <div class="col-md-offset-1">
  81. <?php if(Yii::app()->params['section']==1):?>
  82. <a class="btn label-primary-green btn-sm" href="/assets/data/bulk_import_class.xls">
  83. 下载excel模板
  84. </a>
  85. <?php else:?>
  86. <a class="btn label-primary-green btn-sm" href="/assets/data/bulk_import_class_section0.xls">
  87. 下载excel模板
  88. </a>
  89. <?php endif;?>
  90. <div class="btn label-primary-green btn-sm select_file" >上传excel</div>
  91. <form id="form1" action="<?php echo $this->createUrl('classes/classImport')?>" method="post" enctype="multipart/form-data">
  92. <input type="file" name="file" id="uploadFile" style="display: none">
  93. </form>
  94. </div>
  95. </div>
  96. <div class="clearfix form-actions">
  97. </div>
  98. </section>
  99. <section class="anc-finish-opt gray-border-top" >
  100. <div class="anc-finish-btn save_result hide" >确认导入成绩</div>
  101. </section>
  102. </div>
  103. </div>
  104. <div class="anc-pop">
  105. <div class="confirm-pop-con">
  106. <div class="need-pop-top clearfix">
  107. <div class="npt-title put-need fl">提示</div>
  108. <div class="npt-close fr">×</div>
  109. </div>
  110. <div class="confirm-msg red-font tac">
  111. 确认要放弃本次上传的数据吗?
  112. </div>
  113. <div class="pop-btns">
  114. <div class="confirm-pop-btn-sure">确认</div>
  115. <div class="confirm-pop-btn-cancel cancel-btn">取消</div>
  116. </div>
  117. </div>
  118. </div>
  119. <script>
  120. $(function(){
  121. /*
  122. $('.begain-check-btn').click(function(){
  123. $('.anc-status-con').removeClass('hide');
  124. $(this).hide();
  125. $('.anc-index-msg').hide();
  126. loadStudent();
  127. });
  128. */
  129. //checkFirst();
  130. //保存结果
  131. $('.save_result').click(function(){
  132. var l_index=layer.msg('导入中,请稍候......',{time:0});
  133. $.ajax({
  134. url:'<?php echo $this->createUrl('record/update_score')?>',
  135. dataType:'json',
  136. type:'POST',
  137. success:function(res){
  138. layer.close(l_index);
  139. if(res.status==1){
  140. layer.msg('导入成功',function(){
  141. window.location.href="<?php echo $this->createUrl('record/importscore')?>";
  142. });
  143. }else{
  144. layer.msg('导入失败');
  145. }
  146. }
  147. });
  148. });
  149. //第一步,检测数据
  150. // function checkFirst(){
  151. // var count=0;
  152. // $.ajax({
  153. // url:'<?php //echo $this->createUrl('record/Check_field_first')?>//',
  154. // dataType:'json',
  155. // type:'POST',
  156. // success:function(res){
  157. // if(res.status==1){
  158. // $('.first').addClass('finish-status');
  159. // $('.first').removeClass('now-status');
  160. // $('.first .status-charact').html('检查完成,导入的excel格式正确');
  161. // <?php //if($need_check_name==1):?>
  162. // checkAbnormal();
  163. // <?php //else:?>
  164. // checkRepeat();
  165. // <?php //endif;?>
  166. // }else{
  167. // $('.first').addClass('error-status');
  168. // $('.first').removeClass('now-status');
  169. // $('.first .status-charact').html('导入的excel格式与模版不一致,请重新上传:'+res.msg);
  170. // }
  171. // }
  172. // });
  173. // }
  174. //第二步,姓名异常
  175. function checkAbnormal(){
  176. $('.second .status-charact').html('正在检测...');
  177. $('.second').addClass('now-status');
  178. $.ajax({
  179. url:'<?php echo $this->createUrl('record/check_student_name')?>',
  180. dataType:'json',
  181. type:'POST',
  182. success:function(res){
  183. if(res.status==1){
  184. count=res.count;
  185. $('.second .status-charact').html('检测完成,已为'+count+'名学生去除姓名中的非汉字字符');
  186. $('.second').addClass('finish-status');
  187. $('.second').removeClass('now-status');
  188. checkRepeat();
  189. }else{
  190. $('.second .status-charact').html('检测失败');
  191. $('.second').addClass('error-status');
  192. $('.second').removeClass('now-status');
  193. }
  194. }
  195. });
  196. }
  197. //第三步
  198. function checkRepeat(){
  199. $('.fourth .status-charact').html('正在检测...');
  200. $('.fourth').addClass('now-status');
  201. $.ajax({
  202. url:'<?php echo $this->createUrl('record/matching')?>',
  203. dataType:'json',
  204. type:'POST',
  205. success:function(res){
  206. if(res.status==1){
  207. var html='';
  208. if(res.repeat>0){
  209. html+='<p>重名学生<span class="handle"><a href="<?php echo $this->createUrl('record/handle_repeat')?>">'+res.repeat+'组</a></span></p>';
  210. }else{
  211. html+='<p>重名学生<span class="handle">'+res.repeat+'组</span></p>';
  212. }
  213. if(res.noExistent>0){
  214. html+='<p>学生在系统中不存在<span class="handle"><a href="<?php echo $this->createUrl('record/handle_existent')?>">'+res.noExistent+'人</a></span></p>';
  215. }else{
  216. html+='<p>学生在系统中不存在<span class="handle">'+res.noExistent+'人</span></p>';
  217. }
  218. html+='<p>匹配成功<span class="handle">'+res.success+'人</span></p>';
  219. $('.third .status-charact').html(html);
  220. if(res.repeat==0 && res.success>0){
  221. $('.save_result').removeClass('hide');
  222. }
  223. $('.third').addClass('now-status');
  224. }else{
  225. $('.third .status-charact').html('检测失败,请稍后再试');
  226. $('.third').addClass('error-status');
  227. $('.third').removeClass('now-status');
  228. }
  229. }
  230. });
  231. }
  232. $('.give-up-check').click(function(){
  233. $('.anc-pop').show()
  234. })
  235. $('.npt-close,.confirm-pop-btn-cancel').click(function(){
  236. $('.anc-pop').hide()
  237. })
  238. $('.confirm-pop-btn-sure').click(function () {
  239. $.ajax({
  240. url:'<?php echo $this->createUrl('record/giveup')?>',
  241. dataType:'json',
  242. type:'POST',
  243. success:function(res){
  244. if(res.status==1){
  245. $('.anc-pop').hide();
  246. window.location.href='<?php echo $this->createUrl('record/importscore')?>';
  247. }else{
  248. $('.anc-pop').hide();
  249. }
  250. }
  251. });
  252. });
  253. $('#uploadFile').val('');
  254. $('.select_file').click(function(){
  255. $('#uploadFile').click();
  256. });
  257. $('#uploadFile').change(function(){
  258. if($('#uploadFile').val()!=''){
  259. $('#form1').submit();
  260. }
  261. });
  262. })
  263. </script>