reportsetting.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. <link rel="stylesheet" href="/css/assist/successPage.css"/>
  2. <style>
  3. .report-setting-main{
  4. margin-top:130px;
  5. width: 40%;
  6. height: 20%;
  7. position: absolute;
  8. left: 50%;
  9. top: 50%;
  10. transform: translate(-50%,-50%);
  11. }
  12. .report-setting-main div{
  13. margin-bottom:40px;
  14. }
  15. .report-setting-radio{
  16. padding-left: 50px;
  17. }
  18. .report-setting-radio input{
  19. margin-left: 30px;
  20. }
  21. .report-setting-title{
  22. width: 100px;
  23. display: inline-block;
  24. }
  25. .report-setting-tips{
  26. color:#949494;
  27. display: block;
  28. margin-left: 180px;
  29. }
  30. .score-setting{
  31. color:#169BD5;
  32. margin-left: 180px;
  33. cursor:pointer;
  34. }
  35. .score-levels-box input{text-align: center;}
  36. .score-levels-box{padding:30px 0;}
  37. .score-levels{padding:10px 20px 0;}
  38. .level-box{display: flex;}
  39. .level-box input{width:100px;margin:0 10px;padding-left: 5px;border:1px solid #aaa;}
  40. .level-box *{height: 30px;line-height: 30px;}
  41. .level-remove{font-size: 30px;text-align: center;cursor: pointer;}
  42. .level-line{position: relative;width: 50px;}
  43. .level-line:after{content: "";display: block;height:1px;background: #aaa;position: absolute;left:0;top:50%;transform: translateY(-50%);width: 100%;}
  44. .score-levels p{margin-bottom: 0;padding-left: 10px;line-height: 30px;color: #ccc;}
  45. .add-level{display: inline-block;padding-left:30px;margin-top:20px; color: blue;}
  46. .level-precent{position: relative}
  47. .level-precent span{position:absolute;right:20px;top:50%;transform: translateY(-50%)}
  48. .filter button{
  49. border: none;
  50. background: #009965;
  51. width: 111px;
  52. height: 36px;
  53. border-radius: 3px;
  54. font-size: 14px;
  55. color: #fff;
  56. outline: none;
  57. cursor: pointer;
  58. margin-left: 180px;
  59. }
  60. </style>
  61. <!-- 导航栏开始-->
  62. <?php include(Yii::app()->basePath.'/views/layouts/view_navigation.php');?>
  63. <!-- 导航栏结束-->
  64. <div class="hgc_headOPerator fl" style="background: transparent;padding-left: 0;">
  65. <div class="menuBtn" id="hgc_scanUploadBtn">
  66. <img src="/images/assist/icon_hgc_menu.svg" />
  67. <span class="btnText">家长端成绩报告设置</span>
  68. </div>
  69. </div>
  70. <div class="hgc_siderBar" id="hgc_siderBar">
  71. <div class="menuBtn" id="hgc_hideMenuBtn">
  72. <img src="/images/assist/icon_hgc_menu.svg" />
  73. <span class="btnText">家校成绩设置</span>
  74. </div>
  75. <ul class="menuList">
  76. <li>
  77. <a href="<?php echo $this->createUrl('zhiliao/blackList')?>">不推送成绩设置</a>
  78. </li>
  79. <li>
  80. <a>家长端成绩报告设置</a>
  81. </li>
  82. <!-- <li>
  83. <a>阅卷监控管理</a>
  84. </li>-->
  85. <li class="back" id="hgc_menuBack">
  86. <a href="<?php echo $this->createUrl('zhiliao/index')?>"> <img src="/images/assist/icon_hgc_back.svg" alt=""> 返回</a>
  87. </li>
  88. </ul>
  89. </div>
  90. <div class="report-setting-main">
  91. <div class="">
  92. <span class="report-setting-title">班级平均分</span>
  93. <span class="report-setting-radio"><input type="radio" name="class_average" value="1">可见<input type="radio" name="class_average" value="0">不可见</span>
  94. <span class="report-setting-tips">设置家长是否可以看到学生成绩的班级平均分</span>
  95. </div>
  96. <div>
  97. <span class="report-setting-title">年级平均分</span>
  98. <span class="report-setting-radio"><input type="radio" name="grade_average" value="1">可见<input type="radio" name="grade_average" value="0">不可见</span>
  99. <span class="report-setting-tips">设置家长是否可以看到学生成绩的年级平均分</span>
  100. </div>
  101. <div>
  102. <span class="report-setting-title">班级排名</span>
  103. <span class="report-setting-radio"><input type="radio" name="class_rank" value="1">可见<input type="radio" name="class_rank" value="0">不可见</span>
  104. <span class="report-setting-tips">设置家长是否可以看到学生成绩的班级排名</span>
  105. </div>
  106. <div>
  107. <span class="report-setting-title">年级排名</span>
  108. <span class="report-setting-radio"><input type="radio" name="grade_rank" value="1">可见<input type="radio" name="grade_rank" value="0">不可见</span>
  109. <span class="report-setting-tips">设置家长是否可以看到学生成绩的年级排名</span>
  110. </div>
  111. <div>
  112. <span class="report-setting-title">等级代替分数</span>
  113. <span class="report-setting-radio"><input type="radio" name="level_replace_score" value="1">开启<input type="radio" name="level_replace_score" value="0">关闭</span>
  114. <span class="report-setting-tips">开启后,家长只能看到看到该学生的成绩等级,看不到具体的分数</span>
  115. </div>
  116. <div class="score-setting" style="display:none">分数等级设置</div>
  117. <div class="filter"><button type="button" class="save-setting">保存设置</button></div>
  118. </div>
  119. <div class="score-levels-box" style="display:none">
  120. <a href="javascript:;" class="add-level">+添加</a>
  121. </div>
  122. <script>
  123. $(function(){
  124. var scanMenuBtn = document.getElementById('hgc_scanUploadBtn');
  125. var scanMenu = document.getElementById('hgc_siderBar')
  126. var scanMenuBack = document.getElementById('hgc_menuBack')
  127. var scanMenuHideBtn = document.getElementById('hgc_hideMenuBtn')
  128. scanMenuBtn.addEventListener('click',function(){
  129. var originMeunText = scanMenuBtn.lastElementChild.innerText;
  130. scanMenu.style.top = $(scanMenuBtn).offset().top - $(window).scrollTop()+'px'
  131. scanMenu.className = 'hgc_siderBar active'
  132. scanMenuHideBtn.lastElementChild.innerText = originMeunText
  133. })
  134. scanMenuBack.addEventListener('click',function(){
  135. scanMenu.className = 'hgc_siderBar'
  136. })
  137. scanMenuHideBtn.addEventListener('click',function(){
  138. scanMenu.className = 'hgc_siderBar'
  139. })
  140. $(document).click(function(e){
  141. var e = e || window.event; //浏览器兼容性
  142. var elem = e.target || e.srcElement;
  143. while (elem) { //循环判断至跟节点,防止点击的是div子元素
  144. if (elem.id && (elem.id == 'hgc_scanUploadBtn' || elem.id == 'hgc_scanUploadBtn')) {
  145. return;
  146. }
  147. elem = elem.parentNode;
  148. }
  149. $('#hgc_siderBar').removeClass("active"); //点击的不是div或其子元素
  150. });
  151. $(".score-setting").click(function(){
  152. layer.open({
  153. type: 1,
  154. title:'分数等级设置',
  155. content: $('.score-levels-box'),
  156. btn: ['保存', '取消'],
  157. area: ['500px', '500px'],
  158. yes: function(index, layero){
  159. //按钮【按钮一】的回调
  160. // layer.close(index);
  161. save_msg();
  162. },
  163. cancel: function(){
  164. //右上角关闭回调
  165. //return false 开启该代码可禁止点击该按钮关闭
  166. }
  167. });
  168. });
  169. $(document).on("click", ".level-remove", function(){
  170. $(this).parent().parent().remove();
  171. });
  172. $(document).on("click", ".add-level", function(){
  173. var add_html = "";
  174. add_html += '<div class="score-levels">';
  175. add_html += ' <div class="level-box">';
  176. add_html += ' <input type="text" name="level_name" value="" onkeyup="value=value.replace(/[^\\w\.\\/]/ig,\'\')">';
  177. add_html += ' <div class="level-precent"><input type="text" name="score_name" value="" onkeyup="value=value.replace(/[^\\d]/g,\'\')"><span>%</span></div>';
  178. add_html += ' <span class="level-line"></span>';
  179. add_html += ' <div class="level-precent"><input type="text" name="score_name" value="" onkeyup="value=value.replace(/[^\\d]/g,\'\')"><span>%</span></div>';
  180. add_html += ' <span class="level-remove">×</span>';
  181. add_html += ' </div>';
  182. add_html += ' <p>得分率大于%,小于等于%,为级</p>';
  183. add_html += '</div>';
  184. $(this).before(add_html);
  185. });
  186. $(document).on("change", ".score-levels-box input", function(){
  187. if($(this).attr("name") == 'score_name'){
  188. if(parseInt($(this).val()) > 100){
  189. alert("输入数字有误");
  190. $(this).val("");
  191. }
  192. }
  193. var level_name = $(this).parent().find("input:eq(0)").val();
  194. var min_score = $(this).parent().find("input:eq(1)").val();
  195. var max_score = $(this).parent().find("input:eq(2)").val();
  196. var add_html = '<p>得分率大于'+min_score+'%,小于等于'+max_score+'%,为'+level_name+'级</p>';
  197. $(this).parent().parent().find("p").html(add_html);
  198. });
  199. $(document).on("change", "input[name='level_replace_score']", function(){
  200. if($(this).val() == 1){
  201. $(".score-setting").show();
  202. }else{
  203. $(".score-setting").hide();
  204. }
  205. });
  206. $(document).on("click", ".save-setting", function(){
  207. save_msg();
  208. });
  209. //设置信息
  210. function setting_msg(){
  211. $.ajax({
  212. url:'<?php echo $this->createUrl('zhiliao/ajaxGetReportSetting')?>',
  213. type:'POST',
  214. dataType:'json',
  215. data:{},
  216. success:function(res){
  217. if(res.status==1){
  218. if(res.data){
  219. $(".report-setting-main input").prop("checked",false);
  220. if(res.data.class_average == 1){
  221. $("input[name='class_average'][value=1]").prop("checked",true);
  222. }else{
  223. $("input[name='class_average'][value=0]").prop("checked",true);
  224. }
  225. if(res.data.grade_average == 1){
  226. $("input[name='grade_average'][value=1]").prop("checked",true);
  227. }else{
  228. $("input[name='grade_average'][value=0]").prop("checked",true);
  229. }
  230. if(res.data.class_rank == 1){
  231. $("input[name='class_rank'][value=1]").prop("checked",true);
  232. }else{
  233. $("input[name='class_rank'][value=0]").prop("checked",true);
  234. }
  235. if(res.data.grade_rank == 1){
  236. $("input[name='grade_rank'][value=1]").prop("checked",true);
  237. }else{
  238. $("input[name='grade_rank'][value=0]").prop("checked",true);
  239. }
  240. if(res.data.level_replace_score == 1){
  241. $("input[name='level_replace_score'][value=1]").prop("checked",true);
  242. $(".score-setting").show();
  243. }else{
  244. $("input[name='level_replace_score'][value=0]").prop("checked",true);
  245. $(".score-setting").hide();
  246. }
  247. if(res.data.score_level_setting){
  248. var score_html = "";
  249. for(var i in res.data.score_level_setting){
  250. score_html += '<div class="score-levels">';
  251. score_html += ' <div class="level-box">';
  252. score_html += ' <input type="text" name="level_name" value="'+i+'" onkeyup="value=value.replace(/[^\\w\.\\/]/ig,\'\')">';
  253. score_html += ' <div class="level-precent"><input type="text" name="score_name" value="'+res.data.score_level_setting[i].min_score+'" onkeyup = "value=value.replace(/[^\\d]/g,\'\')"><span>%</span></div>';
  254. score_html += ' <span class="level-line"></span>';
  255. score_html += ' <div class="level-precent"><input type="text" name="score_name" value="'+res.data.score_level_setting[i].max_score+'" onkeyup = "value=value.replace(/[^\\d]/g,\'\')"><span>%</span></div>';
  256. score_html += ' <span class="level-remove">×</span>';
  257. score_html += ' </div>';
  258. score_html += ' <p>得分率大于'+res.data.score_level_setting[i].min_score+'%,小于等于'+res.data.score_level_setting[i].max_score+'%,为'+i+'级</p>';
  259. score_html += '</div>';
  260. }
  261. score_html += '<a href="javascript:;" class="add-level">+添加</a>';
  262. $(".score-levels-box").html(score_html);
  263. }
  264. }
  265. }else{
  266. layer.msg(res.error);
  267. }
  268. },
  269. error: function () {
  270. layer.msg("获取信息失败!");
  271. }
  272. });
  273. }
  274. //保存信息
  275. function save_msg(){
  276. var error = [];
  277. var _This = $(this);
  278. var setting_data = {};
  279. var level_count = $(".score-levels").length;
  280. var class_average = parseInt($("input[name='class_average']:checked").val());
  281. var grade_average = parseInt($("input[name='grade_average']:checked").val());
  282. var class_rank = parseInt($("input[name='class_rank']:checked").val());
  283. var grade_rank = parseInt($("input[name='grade_rank']:checked").val());
  284. var level_replace_score = parseInt($("input[name='level_replace_score']:checked").val());
  285. if(level_replace_score == 1) {
  286. if (level_count > 0) {
  287. var sum_100 = 0;//验证总和是否为100
  288. var range_score_arr = [];//区间分数集合
  289. sum_100 += level_count - 1;
  290. $(".score-levels").each(function () {
  291. if (isNaN(parseInt($(this).find("input:eq(1)").val())) || isNaN(parseInt($(this).find("input:eq(2)").val()))) {
  292. error.push("分数设置有误");
  293. return false;
  294. }
  295. var min_score = isNaN(parseInt($(this).find("input:eq(1)").val())) ? 0 : parseInt($(this).find("input:eq(1)").val());
  296. var max_score = isNaN(parseInt($(this).find("input:eq(2)").val())) ? 0 : parseInt($(this).find("input:eq(2)").val());
  297. var level_name = $(this).find("input:eq(0)").val();
  298. if (min_score >= max_score) {
  299. error.push("最小区间不得大于最大区间");
  300. return false;
  301. }
  302. console.log(max_score);
  303. sum_100 += max_score - min_score;
  304. for (var a = min_score; a <= max_score; a++) {
  305. if ($.inArray(a, range_score_arr) >= 0) {
  306. error.push("各等级的范围不能重叠和交叉,请重新填写");
  307. return false;
  308. } else {
  309. range_score_arr.push(a);
  310. }
  311. }
  312. if (setting_data[level_name] == undefined) {
  313. setting_data[level_name] = {};
  314. }else{
  315. error.push("该级别已存在,不能重名");
  316. }
  317. setting_data[level_name]['min_score'] = min_score;
  318. setting_data[level_name]['max_score'] = max_score;
  319. });
  320. if (sum_100 != 100) {
  321. error.push("所有等级区间之和不是100%,请重新设置");
  322. }
  323. setting_data = JSON.stringify(setting_data);
  324. }else{
  325. error.push("请设置分数区间");
  326. }
  327. }else{
  328. setting_data = "";
  329. }
  330. if(error.length > 0){
  331. layer.msg(error.join("<br>"));
  332. }else{
  333. $.ajax({
  334. url:'<?php echo $this->createUrl('zhiliao/ajaxSaveReportSetting')?>',
  335. type:'POST',
  336. dataType:'json',
  337. data:{class_average:class_average,grade_average:grade_average,class_rank:class_rank,grade_rank:grade_rank,level_replace_score:level_replace_score,setting_data:setting_data},
  338. success:function(res){
  339. if(res.status==1){
  340. window.location.reload();
  341. }else{
  342. layer.msg(res.error);
  343. }
  344. },
  345. error: function () {
  346. layer.msg("请重新设置!");
  347. }
  348. });
  349. }
  350. }
  351. setting_msg();
  352. });
  353. </script>