qxk_units.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. <link rel="stylesheet" href="/css/bootstrap.min.css">
  2. <link rel="stylesheet" href="/css/style.css">
  3. <link rel="stylesheet" href="/css/ace.min.css" class="ace-main-stylesheet" id="main-ace-style">
  4. <link rel="stylesheet" href="/fonts/fpdf/iconfont.css"/>
  5. <link rel="stylesheet" href="/css/alert.css"/>
  6. <?php $imgUrl = Yii::app()->request->hostInfo;?>
  7. <?php $disableImgUrl = Yii::app()->request->hostInfo.'/images/disable.png';?>
  8. <style>
  9. .color-red{
  10. color: red;
  11. }
  12. .en-tfb-grade-1 .date>span{
  13. margin-right: 40px;
  14. }
  15. .option-wrap{
  16. margin-top: 20px;
  17. min-width: 600px;
  18. }
  19. .option-name{
  20. display: inline-block;
  21. width: 100px;
  22. vertical-align: top;
  23. margin-top: 10px;
  24. }
  25. .option-con{
  26. display: inline-block;
  27. width: 80%;
  28. min-width: 490px;
  29. padding: 10px;
  30. border: 1px solid #ccc;
  31. }
  32. .option-con>span{
  33. display: inline-block;
  34. margin-right: 20px;
  35. cursor: pointer;
  36. }
  37. .select-grade{
  38. width: 150px;
  39. line-height: 30px;
  40. margin-bottom: 10px;
  41. }
  42. .option-con-class label{
  43. display: inline-block;
  44. margin-right: 20px;
  45. }
  46. .active{
  47. color: #07af66;
  48. }
  49. .btn-start{
  50. display: inline-block;
  51. margin-top: 20px;
  52. margin-left: 100px;
  53. padding: 10px 30px;
  54. color: #fff;
  55. background-color: #07af66;
  56. cursor: pointer;
  57. }
  58. .en-tfb-grade-1{
  59. margin-left: 20px;
  60. }
  61. #selectedUnit{
  62. display: inline-block;
  63. width: 80%;
  64. min-width: 490px;
  65. padding: 10px;
  66. border: 1px solid #ccc;
  67. }
  68. #selectedUnit span{
  69. position: relative;
  70. padding: 5px;
  71. padding-right: 30px;
  72. border: 1px solid #999;
  73. margin-right: 15px;
  74. }
  75. .delete-icon{
  76. position: absolute;
  77. top: 50%;
  78. right: 5px;
  79. transform: translateY(-50%);
  80. width: 15px;
  81. height: 15px;
  82. background: url(<?php echo $imgUrl.'/images/icon-delect.png';?>) no-repeat center;
  83. background-size: contain;
  84. cursor: pointer;
  85. }
  86. </style>
  87. <div class="main-content-inner">
  88. <div class="en-tfb-grade-1">
  89. <div class="option-wrap">
  90. <span class="option-name">版本:</span>
  91. <div class="option-con" id="optionEdition">
  92. <?php if(isset($textbooks) && $textbooks):?>
  93. <?php $no =1;?>
  94. <?php foreach($textbooks as $k=>$v):?>
  95. <span code="<?php echo $v['textbook_id'];?>" class="<?php echo $no==1?'active':'';?>"><?php echo $v['textbook_name'];?></span>
  96. <?php $no++;?>
  97. <?php endforeach;?>
  98. <?php endif;?>
  99. </div>
  100. </div>
  101. <div class="option-wrap">
  102. <span class="option-name">模块:</span>
  103. <div class="option-con" id="optionModular">
  104. <?php if(isset($modules) && $modules):?>
  105. <?php $no =1;?>
  106. <?php foreach($modules as $k=>$v):?>
  107. <span code="<?php echo $v['textbook_id'];?>" class="<?php echo $no==1?'active':'';?>"><?php echo $v['textbook_name'];?></span>
  108. <?php $no++;?>
  109. <?php endforeach;?>
  110. <?php endif;?>
  111. </div>
  112. </div>
  113. <div class="option-wrap">
  114. <span class="option-name">单元:</span>
  115. <div class="option-con" id="optionUnit">
  116. <?php if(isset($units) && $units):?>
  117. <?php $no =1;?>
  118. <?php foreach($units as $k=>$v):?>
  119. <span code="<?php echo $v['textbook_id'];?>" class="<?php echo $no==1?'active':'';?>"><?php echo $v['textbook_name'];?></span>
  120. <?php $no++;?>
  121. <?php endforeach;?>
  122. <?php endif;?>
  123. </div>
  124. </div>
  125. <div class="option-wrap">
  126. <span class="option-name">已选单元:</span>
  127. <div id="selectedUnit">
  128. <?php if(!empty($str) && !empty($ids)):?>
  129. <span node="<?php echo $ids;?>"><?php echo $str;?><i class="delete-icon" onclick="deleteUnit(this)"></i></span>
  130. <?php endif;?>
  131. </div>
  132. </div>
  133. <div class="option-wrap">
  134. <p >* 根据所选教学进度,推送产品时,将只推送进度之前的相关知识点的语篇练习。</p>
  135. </div>
  136. </div>
  137. </div>
  138. <script src="/js/ace-extra.min.js"></script>
  139. <script src="/js/jquery-2.2.2.min.js"></script>
  140. <!-- HTML5shiv and Respond.js for IE8 to support HTML5 elements and media queries -->
  141. <script src="/js/layer/layer.js"></script>
  142. <script type="text/javascript">
  143. $(document).ready(function () {
  144. var optionData={
  145. edition:0,
  146. modular:0,
  147. unit:0,
  148. }
  149. //获取版本模块单元
  150. // 版本点击
  151. $("#optionEdition>span").on("click", function(event) {
  152. if(!limitUnit()){
  153. layer.msg('已选单元超出限制');return false;
  154. }
  155. $("#optionEdition>span").removeClass('active')
  156. $(this).addClass('active');
  157. var code = $(this).attr("code");
  158. optionData.edition=code;
  159. console.log('版本',code)
  160. });
  161. // 模块点击
  162. $("#optionModular>span").on("click", function(event) {
  163. if(!limitUnit()){
  164. layer.msg('已选单元超出限制');return false;
  165. }
  166. $("#optionModular>span").removeClass('active')
  167. $(this).addClass('active');
  168. var code = $(this).attr("code");
  169. optionData.modular=code;
  170. console.log('模块',code)
  171. });
  172. // 单元点击
  173. $("body").delegate("#optionUnit>span", "click", function() {
  174. if(!limitUnit()){
  175. layer.msg('已选单元超出限制');return false;
  176. }
  177. // $("#optionUnit>span").on("click", function(event) {
  178. $("#optionUnit>span").removeClass('active')
  179. $(this).addClass('active');
  180. var code = $(this).attr("code");
  181. optionData.unit=code;
  182. console.log('单元',code)
  183. });
  184. //
  185. $("body").delegate("#optionEdition span", "click", function() {
  186. if(!limitUnit()){
  187. layer.msg('已选单元超出限制');return false;
  188. }
  189. // $('#optionEdition span').on("click", function(event) {
  190. var textbookId = $(this).attr("code");
  191. if(textbookId){
  192. $.ajax({
  193. url: "<?php echo $this->createUrl('print/ajaxNewGetModuleAndUnit');?>",
  194. type: "POST",
  195. dataType: "json",
  196. data: {
  197. version_id: textbookId,
  198. query_type:2
  199. },
  200. success: function (data) {
  201. console.log(data);
  202. var htmlModule = '';
  203. var htmlUnit = '';
  204. if(data.data.modules){
  205. var a = 1;
  206. for(var i in data.data.modules){
  207. var module=data.data.modules[i];
  208. if(a == 1){
  209. htmlModule += '<span code="'+module.textbook_id+'" class="active">'+module.textbook_name+'</span>';
  210. }else{
  211. htmlModule += '<span code="'+module.textbook_id+'">'+module.textbook_name+'</span>';
  212. }
  213. a++;
  214. }
  215. }
  216. if(data.data.units){
  217. var a = 1;
  218. for(var i in data.data.units){
  219. var unit=data.data.units[i];
  220. if(a == 1){
  221. htmlUnit += '<span code="'+unit.textbook_id+'" class="active">'+unit.textbook_name+'</span>';
  222. }else{
  223. htmlUnit += '<span code="'+unit.textbook_id+'">'+unit.textbook_name+'</span>';
  224. }
  225. a++;
  226. }
  227. }
  228. $('#optionModular').html(htmlModule);
  229. $('#optionUnit').html(htmlUnit);
  230. }
  231. });
  232. }
  233. })
  234. $("body").delegate("#optionModular span", "click", function() {
  235. if(!limitUnit()){
  236. layer.msg('已选单元超出限制');return false;
  237. }
  238. $("#optionModular>span").removeClass('active')
  239. $(this).addClass('active');
  240. var code = $(this).attr("code");
  241. optionData.modular=code;
  242. // $('#optionModular span').on("click", function(event) {
  243. var moduleId = $(this).attr("code");
  244. var textbookId = $('#optionEdition span.active').attr("code");
  245. if(textbookId && moduleId){
  246. $.ajax({
  247. url: "<?php echo $this->createUrl('print/ajaxNewGetUnitByModuleId');?>",
  248. type: "POST",
  249. dataType: "json",
  250. data: {
  251. version_id: textbookId,
  252. module_id:moduleId,
  253. query_type:2
  254. },
  255. success: function (data) {
  256. console.log(data);
  257. var htmlUnit = '';
  258. if(data.data.units){
  259. var a = 1;
  260. for(var i in data.data.units){
  261. var unit=data.data.units[i];
  262. if(a == 1){
  263. htmlUnit += '<span code="'+unit.textbook_id+'" class="active">'+unit.textbook_name+'</span>';
  264. }else{
  265. htmlUnit += '<span code="'+unit.textbook_id+'">'+unit.textbook_name+'</span>';
  266. }
  267. a++;
  268. }
  269. }
  270. $('#optionUnit').html(htmlUnit);
  271. }
  272. });
  273. }
  274. })
  275. $("body").delegate("#optionUnit span","click",function () {
  276. if(!limitUnit()){
  277. layer.msg('已选单元超出限制');return false;
  278. }
  279. var text_book_id = $("#optionEdition").children(".active").attr("code");
  280. var module_id = $("#optionModular").children(".active").attr("code");
  281. var unit_id = $(this).attr("code");
  282. var ids = text_book_id + '_' + module_id + '_' + unit_id;
  283. var selected_arr = [];
  284. if($('#selectedUnit span').length > 0){
  285. $('#selectedUnit span').each(function(index){
  286. selected_arr.push($(this).attr('node'));
  287. });
  288. }
  289. if($.inArray(ids, selected_arr) >= 0){
  290. layer.msg('不能重复添加该单元');return false;
  291. }
  292. var text_book_name = $("#optionEdition").children(".active").text();
  293. var module_name = $("#optionModular").children(".active").text();
  294. var unit_name = $(this).text();
  295. var names = text_book_name + '_' + module_name + '_' + unit_name;
  296. var _html = '<span node="' + ids + '">' + names + '<i class="delete-icon" onclick="deleteUnit(this)"></i></span>';
  297. $("#selectedUnit").append(_html);
  298. });
  299. });
  300. function deleteUnit(a) {
  301. var ids = $(a).parent().attr('node');
  302. var grade = parseInt($('.select-grade').val());
  303. var generate_class = ".unit"+ ids;
  304. $("span").remove(generate_class);
  305. $(a).parent().remove();
  306. }
  307. function limitUnit() {
  308. var selected_count = $("#selectedUnit").children("span").length;
  309. if(selected_count==1){
  310. return false;
  311. }
  312. return true;
  313. }
  314. // $("#unitsSelected").click(function () {
  315. //
  316. //
  317. // var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  318. //
  319. // parent.layer.close(index); //再执行关闭
  320. // $("#progress").attr("value", 11)
  321. // })
  322. function callbackdata() {
  323. return {
  324. html : $("#selectedUnit").html(),
  325. ids : $("#selectedUnit").children().attr("node"),
  326. str : $("#selectedUnit").children().text()
  327. }
  328. }
  329. </script>