setting.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <link rel="stylesheet" href="/fonts/fpdf/iconfont.css"/>
  2. <link rel="stylesheet" href="/css/alert.css"/>
  3. <?php $imgUrl = Yii::app()->request->hostInfo;?>
  4. <?php $disableImgUrl = Yii::app()->request->hostInfo.'/images/disable.png';?>
  5. <style>
  6. .color-red{
  7. color: red;
  8. }
  9. .en-tfb-grade-1 .date>span{
  10. margin-right: 40px;
  11. }
  12. .option-wrap{
  13. margin-top: 20px;
  14. min-width: 600px;
  15. }
  16. .option-name{
  17. display: inline-block;
  18. width: 100px;
  19. vertical-align: top;
  20. margin-top: 10px;
  21. }
  22. .option-con{
  23. display: inline-block;
  24. width: 80%;
  25. min-width: 490px;
  26. padding: 10px;
  27. border: 1px solid #ccc;
  28. }
  29. .option-con>span{
  30. display: inline-block;
  31. margin-right: 20px;
  32. line-height: 1rem;
  33. cursor: pointer;
  34. }
  35. .select-grade{
  36. width: 150px;
  37. line-height: 30px;
  38. margin-bottom: 10px;
  39. }
  40. .option-con-class label{
  41. display: inline-block;
  42. margin-right: 20px;
  43. }
  44. .btn-start{
  45. display: inline-block;
  46. margin-top: 20px;
  47. margin-left: 100px;
  48. padding: 10px 30px;
  49. color: #fff;
  50. background-color: #07af66;
  51. cursor: pointer;
  52. }
  53. .en-tfb-grade-1{
  54. margin-left: 20px;
  55. }
  56. #selectedUnit span{
  57. position: relative;
  58. padding: 5px;
  59. padding-right: 30px;
  60. border: 1px solid #999;
  61. margin-right: 15px;
  62. }
  63. .teacher-word-group{
  64. color: green;
  65. }
  66. .word-group-hidden{
  67. height: 38px;
  68. overflow: hidden;
  69. }
  70. </style>
  71. <div class="main-content-inner">
  72. <!-- 导航栏开始-->
  73. <?php include(Yii::app()->basePath.'/views/layouts/view_production_navigation.php');?>
  74. <!-- 导航栏结束-->
  75. <div class="en-tfb-grade-1">
  76. <h2>生成写作宝</h2>
  77. <p class="color-red">* * 写作宝需选择教师端写作指导后生成产品PDF!题目需要!【每个班级 每周】最多生成【5次】写作宝,均不限年级、不限间隔时间。</p>
  78. <p class="date">
  79. <span>当前时间:</span>
  80. <span><?php echo $year;?>年<?php echo $month;?>月第<?php echo $week;?>周</span>
  81. </p>
  82. <div class="option-wrap">
  83. <span class="option-name">班级:</span>
  84. <div class="option-con">
  85. <div>
  86. <select name="grade" class="select-grade">
  87. <option value="1" <?php if(isset($setting['grade']) && $setting['grade']==1) echo 'selected';?>>高一</option>
  88. <option value="2" <?php if(isset($setting['grade']) && $setting['grade']==2) echo 'selected';?>>高二</option>
  89. <option value="3" <?php if(isset($setting['grade']) && $setting['grade']==3) echo 'selected';?>>高三</option>
  90. </select>
  91. </div>
  92. <div class="option-con-class" id="optionClass">
  93. </div>
  94. </div>
  95. </div>
  96. <div class="option-wrap card-teacher">
  97. <span class="option-name">教师端-自选写作指导:</span>
  98. <div class="option-con word-group-hidden" style="position: relative;" id="allTeacherWord">
  99. <?php foreach ($groupList as $group):?>
  100. <span><input type="radio" name="ewg_id" topic_type="<?php echo $group['topic_type'];?>" value="<?php echo $group['ewg_id'];?>" <?php if(isset($setting['ewg_id']) && $setting['ewg_id'] == $group['ewg_id']){ echo "checked";}; ?>>&nbsp;<?php echo $group['name'];?>&nbsp;<span class="teacher-word-group"><?php echo sprintf('(%s,%s)',$group['create_time'],$group['teacher_name']);?></span></span>
  101. <?php endforeach;?>
  102. <div style="cursor:pointer;position: absolute;right: 5px;top: 5px;color: green;" id="show-teacher-word" is-hold="1" onclick="isHold()">展开</div>
  103. </div>
  104. <p style="margin-left:100px;color: red;font-weight: bold">
  105. *每个写作指导名称后的括号内为生成时间。可以多次选择同一写作指导的题目以供不同班级检测。
  106. </p>
  107. </div>
  108. <div class="option-wrap">
  109. <span class="option-name">写作卡类型:</span>
  110. <div class="option-con writing-type-one" style="position: relative;">
  111. <span>
  112. <input type="radio" name="writing_type" value="1" checked="checked">一般写作卡&nbsp;&nbsp;&nbsp;
  113. <input type="radio" name="writing_type" value="2">题卡合一写作卡
  114. </span>
  115. </div>
  116. <div class="option-con writing-type-two" style="position: relative;display: none">
  117. <span>
  118. <input type="radio" name="writing_type" value="3">一卡两题&nbsp;&nbsp;&nbsp;
  119. <span style="margin-left:100px;color: red;font-weight: bold">*若写作组为一卡两题,写作卡类型为一卡两题,不可修改。</span>
  120. </span>
  121. </div>
  122. </div>
  123. <div class="option-wrap">
  124. <span class="option-name">考号方式:</span>
  125. <div class="option-con" style="position: relative;">
  126. <span>
  127. <input type="radio" name="scan_type" value="1" checked="checked">二维码&nbsp;&nbsp;&nbsp;
  128. <input type="radio" name="scan_type" value="2">填涂考号
  129. </span>
  130. </div>
  131. </div>
  132. <button class="btn-start" id="confirm" active="true">开始生成</>
  133. </div>
  134. </div>
  135. <script src="/js/jquery.ajaxfileupload.js"></script>
  136. <script type="text/javascript">
  137. $(document).ready(function () {
  138. getClassByGrade(<?php echo isset($setting['grade'])?$setting['grade']:1 ;?>);
  139. var optionData={
  140. edition:0,
  141. modular:0,
  142. unit:0,
  143. class:[],
  144. }
  145. // 选择年级
  146. $(".select-grade").change(function() {
  147. console.log($(this).val())
  148. });
  149. // 单选按钮
  150. $("input[name='option-class']").change(function() {
  151. getsClassSelected();
  152. });
  153. //选择写作指导
  154. $("input[name='ewg_id']").click(function() {
  155. var topic_type = $(this).attr("topic_type");
  156. if(topic_type == 3){
  157. $(".writing-type-two").show();
  158. $(".writing-type-one").hide();
  159. $("input[name='writing_type']").attr("checked",false);
  160. $("input[name='writing_type'][value='3']").prop("checked",true);
  161. }else{
  162. $(".writing-type-two").hide();
  163. $(".writing-type-one").show();
  164. $("input[name='writing_type']").attr("checked",false);
  165. $("input[name='writing_type'][value='1']").prop("checked",true);
  166. }
  167. });
  168. function getsClassSelected() {
  169. optionData.class=[];
  170. var selectedData = $("input[name='option-class']:checked"); //获取所以选中学生
  171. for (var i = 0; i < selectedData.length; i++) {
  172. code = $(selectedData[i]).val();
  173. optionData.class.push(code);
  174. }
  175. };
  176. $('.select-grade').change(function(){
  177. $('#selectedUnit').empty();
  178. var grade = $(this).val();
  179. getClassByGrade(grade);
  180. });
  181. $("#confirm[active='true']").on("click", function() {
  182. $('#confirm').attr('disabled','disabled');
  183. var This = $(this);
  184. This.attr("active","false");
  185. var error = [];
  186. var selectClassIds = [];
  187. var grade = parseInt($('.select-grade').val());
  188. var ewg_id = $("input[name='ewg_id']:checked").val();
  189. var scan_type = $("input[name='scan_type']:checked").val();
  190. var writing_type = $("input[name='writing_type']:checked").val();
  191. $('#optionClass input:checked').each(function(k,v){
  192. if($(this).attr("status") == 0){
  193. selectClassIds.push($(this).val());
  194. }
  195. });
  196. if(selectClassIds.length == 0){
  197. error.push("请选择班级");
  198. }
  199. if(grade <= 0 || !grade){
  200. error.push("请选择年级");
  201. }
  202. if(ewg_id){
  203. }
  204. if(error.length == 0){
  205. $.ajax({
  206. url: "<?php echo $this->createUrl('writing/ajaxSaveSetting');?>",
  207. type: "POST",
  208. dataType: "json",
  209. data: {
  210. grade: grade,
  211. selectClassIds:selectClassIds,
  212. ewg_id: ewg_id,
  213. scan_type:scan_type,
  214. writing_type:writing_type
  215. },
  216. success: function (data) {
  217. if(data.status == 1){
  218. layer.msg('已发送到后台,预计1小时左右生成!', {
  219. time: 2000,
  220. });
  221. setTimeout(function(){window.location.href = "<?php echo Yii::app()->createUrl('writing/index');?>";}, 2000);
  222. }else{
  223. layer.msg(data.error.join('</br>'));
  224. This.attr("active","true");
  225. }
  226. $('#confirm').removeAttr('disabled');
  227. }
  228. });
  229. }else{
  230. $('#confirm').removeAttr('disabled');
  231. This.attr("active","true");
  232. layer.msg(error.join('</br>'));
  233. }
  234. });
  235. function getClassByGrade(grade){
  236. if(grade){
  237. $.ajax({
  238. url: "<?php echo $this->createUrl('writing/ajaxGetClasses');?>",
  239. type: "POST",
  240. dataType: "json",
  241. data: {
  242. grade: grade,
  243. },
  244. beforeSend:function(){
  245. layer.load(1, {
  246. shade: [0.1,'#fff'] //0.1透明度的白色背景
  247. });
  248. },
  249. success: function (data) {
  250. var index = layer.load();
  251. layer.close(index);
  252. var html = '';
  253. if(data && data.length > 0){
  254. for(var i in data){
  255. html +='<label>';
  256. if(data[i].status == 1){
  257. html += '<span title="该班级已达每周生成的最大次数"><img src="<?php echo $disableImgUrl;?>">'+data[i].class_name+'</span><span style="margin-left: 5px;" class="unit_generate_count">(<span>5</span>)</span></label>';
  258. }else{
  259. var isChecked = data[i].selected === true ? 'checked' : '';
  260. html += ' <input type="checkbox" name="option-class" ' + isChecked + ' value="'+data[i].class_id+'" status="0">'+data[i].class_name+'<span style="color:red;margin-left: 5px;" class="unit_generate_count">' + '(' + '<span>'+ data[i].count +'</span>' + ')' + '</span></label>';
  261. }
  262. }
  263. }
  264. html += '<div style="color: red;font-weight: bold">' + '* 提示:每个班级名称后的括号内为本班的本周生成次数。' + '</div>';
  265. $('#optionClass').html(html);
  266. }
  267. });
  268. }
  269. }
  270. });
  271. function isPositiveInteger(s){//是否为正整数
  272. var reg = /^[1-9]\d*$/;
  273. return reg.test(s)
  274. }
  275. function isHold() {
  276. var is_hold = $('#show-teacher-word').attr('is-hold');
  277. if(is_hold == 0){
  278. $('#show-teacher-word').attr('is-hold', 1);
  279. $('#allTeacherWord').addClass('word-group-hidden');
  280. $('#show-teacher-word').html('展开');
  281. }else {
  282. $('#show-teacher-word').attr('is-hold', 0);
  283. $('#allTeacherWord').removeClass('word-group-hidden');
  284. $('#show-teacher-word').html('收起');
  285. }
  286. }
  287. </script>