setting.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. <link rel="stylesheet" href="/fonts/fpdf/iconfont.css"/>
  2. <link rel="stylesheet" href="/css/alert.css"/>
  3. <?php $imgUrl = Yii::app()->request->hostInfo.'/images/disable.png';?>
  4. <style>
  5. .color-red{
  6. color: red;
  7. }
  8. .en-tfb-grade-1 .date>span{
  9. margin-right: 40px;
  10. }
  11. .option-wrap{
  12. margin-top: 20px;
  13. min-width: 600px;
  14. }
  15. .option-name{
  16. display: inline-block;
  17. width: 100px;
  18. vertical-align: top;
  19. margin-top: 10px;
  20. }
  21. .option-con{
  22. position: relative;
  23. display: inline-block;
  24. width: 80%;
  25. min-width: 490px;
  26. padding: 10px;
  27. border: 1px solid #ccc;
  28. }
  29. .option-con.current{
  30. padding-bottom: 40px;
  31. }
  32. .option-con.current .enclosure{
  33. display: flex;
  34. }
  35. .option-con>span{
  36. display: inline-block;
  37. margin-right: 20px;
  38. margin-top:10px;
  39. line-height: 1rem;
  40. cursor: pointer;
  41. }
  42. .select-grade{
  43. width: 150px;
  44. line-height: 30px;
  45. margin-bottom: 10px;
  46. }
  47. .option-con-class label{
  48. display: inline-block;
  49. margin-right: 20px;
  50. }
  51. .active{
  52. color: #07af66;
  53. }
  54. .btn-start{
  55. display: inline-block;
  56. margin-top: 20px;
  57. margin-left: 100px;
  58. padding: 10px 30px;
  59. color: #fff;
  60. background-color: #07af66;
  61. cursor: pointer;
  62. }
  63. .en-tfb-grade-1{
  64. margin-left: 20px;
  65. }
  66. .enclosure{
  67. position: absolute;
  68. width: 100%;
  69. height: 30px;
  70. padding-left: 10px;
  71. bottom: 0;
  72. left: 0;
  73. display: flex;
  74. align-items: center;
  75. border-top: 1px solid #cccccc;
  76. background: #cccccc60;
  77. display: none;
  78. }
  79. .enclosure .enclosureItem{
  80. display: flex;
  81. align-items: center;
  82. margin-right: 20px;
  83. }
  84. .enclosureItem em{
  85. font-style: normal;
  86. margin: 0 10px;
  87. }
  88. .enclosureItem a{
  89. width: 20px;
  90. height: 20px;
  91. background: url("/images/icon_downloadh.png") no-repeat center;
  92. -webkit-background-size: contain;
  93. background-size: contain;
  94. cursor: pointer;
  95. }
  96. </style>
  97. <div class="main-content-inner">
  98. <!-- 导航栏开始-->
  99. <?php include(Yii::app()->basePath.'/views/layouts/view_production_navigation.php');?>
  100. <!-- 导航栏结束-->
  101. <div class="en-tfb-grade-1">
  102. <h2>培优版赠品生成</h2>
  103. <p class="color-red">提示:每个班级每周原则上生成一次,请根据实际需要生成。</p>
  104. <ul id="node-content">
  105. <li class="option-wrap">
  106. <span class="option-name"></span>
  107. <div class="option-con" id="optionEdition">
  108. <?php if(isset($topNode) && $topNode):?>
  109. <?php $no =1;?>
  110. <?php foreach($topNode as $k=>$v):?>
  111. <span parentid="<?php echo $v->parentId;?>" pcid="<?php echo $v->pcId;?>"><?php echo $v->pcName;?></span>
  112. <?php $no++;?>
  113. <?php endforeach;?>
  114. <?php endif;?>
  115. <div class="enclosure">
  116. <div class="enclosureItem">
  117. <strong>相关附件</strong><em>高一学生心理健康维护.pdf</em><i></i>
  118. </div>
  119. </div>
  120. </div>
  121. </li>
  122. </ul>
  123. <div class="option-wrap">
  124. <span class="option-name">班级:</span>
  125. <div class="option-con">
  126. <div>
  127. <select name="grade" class="select-grade">
  128. <option value="1" selected>高一</option>
  129. <option value="2">高二</option>
  130. <option value="3">高三</option>
  131. </select>
  132. </div>
  133. <div class="option-con-class" id="optionClass">
  134. <div class="enclosure">
  135. <strong>相关附件</strong><em>高一学生心理健康维护.pdf</em><i></i>
  136. </div>
  137. </div>
  138. </div>
  139. </div>
  140. <span class="btn-start" id="confirm" active="true">开始生成</span>
  141. </div>
  142. </div>
  143. <script src="/js/jquery.ajaxfileupload.js"></script>
  144. <script type="text/javascript">
  145. $(document).ready(function () {
  146. getClassByGrade(1);
  147. // 选择年级
  148. $(".select-grade").change(function() {
  149. console.log($(this).val())
  150. });
  151. // 单选按钮
  152. $("input[name='option-class']").change(function() {
  153. getsClassSelected();
  154. });
  155. function getsClassSelected() {
  156. optionData.class=[];
  157. var selectedData = $("input[name='option-class']:checked"); //获取所以选中学生
  158. for (var i = 0; i < selectedData.length; i++) {
  159. code = $(selectedData[i]).val();
  160. optionData.class.push(code);
  161. }
  162. };
  163. $("body").delegate("#node-content li div span","click",function () {
  164. //显示下载项
  165. var $parent = $(this).parent('.option-con')
  166. $(this).siblings().removeClass('active');
  167. $(this).addClass('active');
  168. $(this).parent().parent().nextAll().remove();
  169. $(this).parent().parent().attr('id','li_'+ $(this).attr('pcid'));
  170. $.ajax({
  171. url: "<?php echo $this->createUrl('ispgift/ajaxChildNode');?>",
  172. type: "GET",
  173. dataType: "json",
  174. data: {
  175. parentId: $(this).attr('pcid'),
  176. },
  177. success: function (data) {
  178. if(data.status == 1) {
  179. if( data.data !== null){
  180. var con = '<li class="option-wrap"> <span class="option-name"></span><div class="option-con" id="optionEdition">';
  181. $.each(data.data, function (index, item) {
  182. con += '<span pcid="' + item.pcId + '" parentid="' + item.parentId +'">' + item.pcName + '</span>';
  183. });
  184. con += '</div></li>';
  185. }
  186. $("#node-content").append(con);
  187. //添加附件信息
  188. var enclosureInfo = ''
  189. if(data.detail && data.detail.length){
  190. var download_url = "<?php echo $this->createUrl('ispgift/download');?>";
  191. enclosureInfo+='<div class="enclosure">'
  192. enclosureInfo+=data.detail.reduce(function(htmls,cur){
  193. htmls+=cur.filePath?'<div class="enclosureItem">\n' +
  194. ' <strong>相关附件</strong><em>'+cur.fileName+'</em><a href="'+ download_url + '?pcdId=' + cur.pcdId + '&url=' + cur.filePath+ '&fileName='+ cur.fileName + '" ' +'></a>\n' +
  195. ' </div>':'';
  196. return htmls
  197. },'')
  198. enclosureInfo+='</div>'
  199. }
  200. $parent[enclosureInfo?'addClass':'removeClass']('current');
  201. $parent.find('.enclosure').remove()
  202. $parent.append(enclosureInfo)
  203. }}
  204. })
  205. });
  206. $('.select-grade').change(function(){
  207. var grade = $(this).val();
  208. getClassByGrade(grade);
  209. });
  210. $("body").delegate("#confirm[active='true']", "click", function() {
  211. var This = $(this);
  212. This.attr("active","false");
  213. var error = [];
  214. var selectClassIds = [];
  215. var grade = parseInt($('.select-grade').val());
  216. var pcIds = [];
  217. $('#node-content li div span.active').each(function () {
  218. var data1 = {"pcId": $(this).attr('pcid'),"pcName":$(this).text(), "parentId":$(this).attr('parentid')};
  219. pcIds.push(data1);
  220. });
  221. $('#optionClass input:checked').each(function(k,v){
  222. if($(this).attr("status") == 0){
  223. selectClassIds.push($(this).val());
  224. }
  225. });
  226. if(pcIds.length == 0){
  227. error.push("请指定目录");
  228. }
  229. var noSelect = true;
  230. var lastNode = $('#node-content').children().last();
  231. lastNode.find('span').each(function (i) {
  232. if($(this).hasClass('active')){
  233. noSelect = false;
  234. }
  235. });
  236. if(noSelect){
  237. error.push("请指定目录~");
  238. }
  239. if(selectClassIds.length == 0){
  240. error.push("请选择班级");
  241. }
  242. if(grade <= 0 || !grade){
  243. error.push("请选择年级");
  244. }
  245. if(error.length == 0){
  246. $.ajax({
  247. url: "<?php echo $this->createUrl('ispgift/ajaxSaveGift');?>",
  248. type: "POST",
  249. dataType: "json",
  250. data: {
  251. grade: grade,
  252. selectClassIds:selectClassIds,
  253. pcIds:pcIds
  254. },
  255. success: function (data) {
  256. if(data.status == 1){
  257. layer.msg('已发送到后台,预计1小时左右生成!', {
  258. time: 2000,
  259. });
  260. setTimeout(function(){window.location.href = "<?php echo Yii::app()->createUrl('ispgift/index');?>";}, 2000);
  261. }else{
  262. layer.msg(data.error.join('</br>'));
  263. This.attr("active","true");
  264. }
  265. }
  266. });
  267. }else{
  268. This.attr("active","true");
  269. layer.msg(error[0]);
  270. }
  271. });
  272. function getClassByGrade(grade){
  273. if(grade){
  274. $.ajax({
  275. url: "<?php echo $this->createUrl('ispgift/ajaxGetClasses');?>",
  276. type: "POST",
  277. dataType: "json",
  278. data: {
  279. grade: grade,
  280. },
  281. success: function (data) {
  282. var html = '';
  283. if(data && data.length > 0){
  284. for(var i in data){
  285. html +='<label>';
  286. if(data[i].status == 1){
  287. html += '<span title="该班级已达每周生成的最大次数"><img src="<?php echo $imgUrl;?>">'+data[i].class_name+'</span>';
  288. }else{
  289. html += '<input type="checkbox" name="option-class" id="class_'+ data[i].class_id +'" onclick="checkOrder('+ "'"+ grade + "','" + data[i].class_id + "')" +'" value="'+data[i].class_id+'" status="0">'+data[i].class_name;
  290. }
  291. html +='</label>';
  292. }
  293. }
  294. $('#optionClass').html(html);
  295. }
  296. });
  297. }
  298. }
  299. });
  300. function checkOrder(grade,classId) {
  301. $.ajax({
  302. url: "<?php echo $this->createUrl('ispgift/checkOrder');?>",
  303. type: "POST",
  304. dataType: "json",
  305. data: {
  306. classId: classId,
  307. grade:grade
  308. },
  309. success: function (data) {
  310. console.log(data);
  311. if(!data.status){
  312. layer.msg(data.message);
  313. var class_id = 'class_' + data.class_id;
  314. $('#'+ class_id.toString()).attr("checked",false);
  315. }
  316. }
  317. });
  318. }
  319. </script>