units.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  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($textbookNames) && $textbookNames):?>
  93. <?php $no =1;?>
  94. <?php foreach($textbookNames as $k=>$v):?>
  95. <span code="<?php echo $k;?>" class="<?php echo $no==1?'active':'';?>"><?php echo $v;?></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($moduleNames) && $moduleNames):?>
  105. <?php $no =1;?>
  106. <?php foreach($moduleNames as $k=>$v):?>
  107. <span code="<?php echo $k;?>" class="<?php echo $no==1?'active':'';?>"><?php echo $v;?></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($unitNames) && $unitNames):?>
  117. <?php $no =1;?>
  118. <?php foreach($unitNames as $k=>$v):?>
  119. <span code="<?php echo $k;?>" class="<?php echo $no==1?'active':'';?>"><?php echo $v;?></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/ajaxGetModuleAndUnit');?>",
  194. type: "POST",
  195. dataType: "json",
  196. data: {
  197. textbookId: textbookId
  198. },
  199. success: function (data) {
  200. console.log(data);
  201. var htmlModule = '';
  202. var htmlUnit = '';
  203. if(data.moduleNames){
  204. var a = 1;
  205. for(var i in data.moduleNames){
  206. if(a == 1){
  207. htmlModule += '<span code="'+i+'" class="active">'+data.moduleNames[i]+'</span>';
  208. }else{
  209. htmlModule += '<span code="'+i+'">'+data.moduleNames[i]+'</span>';
  210. }
  211. a++;
  212. }
  213. }
  214. if(data.unitNames){
  215. var a = 1;
  216. for(var i in data.unitNames){
  217. if(a == 1){
  218. htmlUnit += '<span code="'+i+'" class="active">'+data.unitNames[i]+'</span>';
  219. }else{
  220. htmlUnit += '<span code="'+i+'">'+data.unitNames[i]+'</span>';
  221. }
  222. a++;
  223. }
  224. }
  225. $('#optionModular').html(htmlModule);
  226. $('#optionUnit').html(htmlUnit);
  227. }
  228. });
  229. }
  230. })
  231. $("body").delegate("#optionModular span", "click", function() {
  232. if(!limitUnit()){
  233. layer.msg('已选单元超出限制');return false;
  234. }
  235. $("#optionModular>span").removeClass('active')
  236. $(this).addClass('active');
  237. var code = $(this).attr("code");
  238. optionData.modular=code;
  239. // $('#optionModular span').on("click", function(event) {
  240. var moduleId = $(this).attr("code");
  241. var textbookId = $('#optionEdition span.active').attr("code");
  242. if(textbookId && moduleId){
  243. $.ajax({
  244. url: "<?php echo $this->createUrl('print/ajaxGetUnitByModuleId');?>",
  245. type: "POST",
  246. dataType: "json",
  247. data: {
  248. textbookId: textbookId,
  249. moduleId:moduleId
  250. },
  251. success: function (data) {
  252. console.log(data);
  253. var htmlUnit = '';
  254. if(data.unitNames){
  255. var a = 1;
  256. for(var i in data.unitNames){
  257. if(a == 1){
  258. htmlUnit += '<span code="'+i+'" class="active">'+data.unitNames[i]+'</span>';
  259. }else{
  260. htmlUnit += '<span code="'+i+'">'+data.unitNames[i]+'</span>';
  261. }
  262. a++;
  263. }
  264. }
  265. $('#optionUnit').html(htmlUnit);
  266. }
  267. });
  268. }
  269. })
  270. $("body").delegate("#optionUnit span","click",function () {
  271. if(!limitUnit()){
  272. layer.msg('已选单元超出限制');return false;
  273. }
  274. var text_book_id = $("#optionEdition").children(".active").attr("code");
  275. var module_id = $("#optionModular").children(".active").attr("code");
  276. var unit_id = $(this).attr("code");
  277. var ids = text_book_id + '_' + module_id + '_' + unit_id;
  278. var selected_arr = [];
  279. if($('#selectedUnit span').length > 0){
  280. $('#selectedUnit span').each(function(index){
  281. selected_arr.push($(this).attr('node'));
  282. });
  283. }
  284. if($.inArray(ids, selected_arr) >= 0){
  285. layer.msg('不能重复添加该单元');return false;
  286. }
  287. var text_book_name = $("#optionEdition").children(".active").text();
  288. var module_name = $("#optionModular").children(".active").text();
  289. var unit_name = $(this).text();
  290. var names = text_book_name + '_' + module_name + '_' + unit_name;
  291. var _html = '<span node="' + ids + '">' + names + '<i class="delete-icon" onclick="deleteUnit(this)"></i></span>';
  292. $("#selectedUnit").append(_html);
  293. });
  294. });
  295. function deleteUnit(a) {
  296. var ids = $(a).parent().attr('node');
  297. var grade = parseInt($('.select-grade').val());
  298. var generate_class = ".unit"+ ids;
  299. $("span").remove(generate_class);
  300. $(a).parent().remove();
  301. }
  302. function limitUnit() {
  303. var selected_count = $("#selectedUnit").children("span").length;
  304. if(selected_count==1){
  305. return false;
  306. }
  307. return true;
  308. }
  309. // $("#unitsSelected").click(function () {
  310. //
  311. //
  312. // var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
  313. //
  314. // parent.layer.close(index); //再执行关闭
  315. // $("#progress").attr("value", 11)
  316. // })
  317. function callbackdata() {
  318. return {
  319. html : $("#selectedUnit").html(),
  320. ids : $("#selectedUnit").children().attr("node"),
  321. str : $("#selectedUnit").children().text()
  322. }
  323. }
  324. </script>