mrv_3.php 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944
  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. <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. display: inline-block;
  23. width: 80%;
  24. min-width: 490px;
  25. padding: 10px;
  26. border: 1px solid #ccc;
  27. }
  28. .option-con>span{
  29. display: inline-block;
  30. margin-right: 20px;
  31. line-height: 1rem;
  32. cursor: pointer;
  33. }
  34. .select-grade{
  35. width: 150px;
  36. line-height: 30px;
  37. margin-bottom: 10px;
  38. }
  39. .option-con-class label{
  40. display: inline-block;
  41. margin-right: 20px;
  42. }
  43. .active{
  44. color: #2977ff;
  45. }
  46. .btn-start{
  47. display: inline-block;
  48. margin-top: 20px;
  49. margin-left: 100px;
  50. padding: 10px 30px;
  51. color: #fff;
  52. background-color: #2977ff;
  53. cursor: pointer;
  54. }
  55. .en-tfb-grade-1{
  56. margin-left: 20px;
  57. }
  58. .hgc_leader-btn {
  59. display: flex;
  60. justify-content: space-between;
  61. padding: 10px 0;
  62. font-size: 14px;
  63. }
  64. .hgc_leader-btn span {
  65. display: flex;
  66. align-items: center;
  67. cursor: pointer;
  68. }
  69. .hgc_leader-btn span .icon {
  70. width: 15px;
  71. height: 15px;
  72. background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAAWCAYAAADNX8xBAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAHXSURBVDhPnZS/S4JRFIZvYlDQYOBg0ODg4ODW4ugaNDT2HxRE0NA/EA0NFQUNDRENjQUN0dRQQVDgEmQ4aBQouLQVJBTZ816PpvX5o154Oufce87r57X7uU6qOReBsJV/16dzU5DHpEZ8g2MYt+3+ZCYVTKZhCKLUa1Aij1hbbzGgJ5kmzmgYstRJ4j6sWFugBiw2zqTEwijxkaUNmIBXOIX5kHOTxECx15QGpIT+sLGF6R5pklgklrXeSU0jmj8IFxAD5Q3prGS+XC/7EANxziIN+mqqM6Bf7wXebS/N2pAf6CYzaxop1yDxQKZCa5CAtB9CrWfUSU987So8YHJFPQhl6gLxBLMzNXkjGsL6BOU9VLSzLDKzTj5GridLhVhIgn72Agvn5DpsL/JnQq5etYv+ezPVE0dlNEtxBMNwC8fgxePmYEE5fTcMXPqNIPEUq3BopepN8IfdSewnMB6xXN8io0/SfcrLwHch8kVLe6ppJJHEfpr1KxlBysr/m9F/zWzcyrr+akZ/hF69dn6/AFvMtgMbWkTPEuxa+VtmloU7ct23NkNqXaMd8FfFloOlYZrmQG9H3S+96DRYAf8KZj1q7d8vtm5iIEnw//Hkumeiqrou574AaXrOncWtEY0AAAAASUVORK5CYII=') no-repeat center;
  73. background-size: contain;
  74. }
  75. .hgc_leader-btn span:nth-child(2) .icon {
  76. background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAWCAYAAADAQbwGAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAE6SURBVDhP7ZStTgNBFEZvmwpkRUUFsqJJKyoqKhBIRCWiD4CkggRPeAIEgodA8gAYEgQPgICktrJJDUkJ5dztV5id7KZDlqA4ydf7N/duZtIZK+PD7Bi9rM3WoTyHTrQsDRoHNK3QEs0iLTV4rOW7YfGNmiZKfUFupNq9UjlqFI5qZm3FGTRcY/bQlNpblgygfkW+iT3DLpR2Fj5wRbKhRGV84CkDW/gXm5RdyqYS9n3vxs/FpTCZuK8u+2sUDuQYJsj/b33Ft+hRfgc9o3OPYwoHcqZd1NHZOkP8kTvYfa/j9jyO+ZstV+F/YHVSB77LOqFfTniF+GmhQ+QvjsddNJDfQAcoe6GwxVe2tLCDuC+3ZbKvcpOh50FuHu7m3fZrPxW9TxrjV3MDhTbyl3p7f1OZM8Rf7rmZ2Sd4TZIuop129AAAAABJRU5ErkJggg==') no-repeat center;
  77. background-size: contain;
  78. }
  79. .hgc_leader-btn i {
  80. font-style: normal;
  81. }
  82. .hgc_option-con label {
  83. position: relative;
  84. padding: 5px;
  85. padding-right: 30px;
  86. border: 1px solid #999;
  87. }
  88. .hgc_option-con .icon {
  89. position: absolute;
  90. top: 50%;
  91. right: 5px;
  92. transform: translateY(-50%);
  93. width: 15px;
  94. height: 15px;
  95. background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAWCAYAAADAQbwGAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAE6SURBVDhP7ZStTgNBFEZvmwpkRUUFsqJJKyoqKhBIRCWiD4CkggRPeAIEgodA8gAYEgQPgICktrJJDUkJ5dztV5id7KZDlqA4ydf7N/duZtIZK+PD7Bi9rM3WoTyHTrQsDRoHNK3QEs0iLTV4rOW7YfGNmiZKfUFupNq9UjlqFI5qZm3FGTRcY/bQlNpblgygfkW+iT3DLpR2Fj5wRbKhRGV84CkDW/gXm5RdyqYS9n3vxs/FpTCZuK8u+2sUDuQYJsj/b33Ft+hRfgc9o3OPYwoHcqZd1NHZOkP8kTvYfa/j9jyO+ZstV+F/YHVSB77LOqFfTniF+GmhQ+QvjsddNJDfQAcoe6GwxVe2tLCDuC+3ZbKvcpOh50FuHu7m3fZrPxW9TxrjV3MDhTbyl3p7f1OZM8Rf7rmZ2Sd4TZIuop129AAAAABJRU5ErkJggg==') no-repeat center;
  96. background-size: contain;
  97. cursor: pointer;
  98. }
  99. #selectedUnit{
  100. display: inline-block;
  101. width: 80%;
  102. min-width: 490px;
  103. padding: 10px;
  104. border: 1px solid #ccc;
  105. }
  106. #selectedUnit span{
  107. position: relative;
  108. padding: 5px;
  109. padding-right: 30px;
  110. border: 1px solid #999;
  111. margin-right: 15px;
  112. }
  113. .delete-icon{
  114. position: absolute;
  115. top: 50%;
  116. right: 5px;
  117. transform: translateY(-50%);
  118. width: 15px;
  119. height: 15px;
  120. background: url(<?php echo $imgUrl.'/images/icon-delect.png';?>) no-repeat center;
  121. background-size: contain;
  122. cursor: pointer;
  123. }
  124. .p-one-level{
  125. margin-left: 5%;
  126. }
  127. .p-two-level{
  128. margin-left: 8%;
  129. }
  130. .option-wrap-content{
  131. margin-left: 10%;
  132. }
  133. .option-wrap-content .option-con{
  134. border-color: #2977ff;
  135. width: auto;
  136. min-width: 250px;
  137. }
  138. </style>
  139. <div class="main-content-inner">
  140. <!-- 导航栏开始-->
  141. <?php include(Yii::app()->basePath.'/views/layouts/view_production_navigation.php');?>
  142. <!-- 导航栏结束-->
  143. <div class="en-tfb-grade-1">
  144. <h2>语法题自定义生成</h2>
  145. <p class="color-red">提示:只适用于高三年级,每个班级每周最多生成三份,请根据班级的实际复习内容生成</p>
  146. <p class="date">
  147. <span>当前时间:</span>
  148. <span><?php echo $year;?>年<?php echo $month;?>月第<?php echo $week;?>周</span>
  149. </p>
  150. <div class="option-wrap">
  151. <span class="option-name">班级:</span>
  152. <div class="option-con">
  153. <div class="option-con-class" id="optionClass">
  154. </div>
  155. </div>
  156. </div>
  157. <div class="option-wrap">
  158. <span class="option-name">版本:</span>
  159. <div class="option-con" id="optionEdition">
  160. <?php if(isset($textbookNames) && $textbookNames):?>
  161. <?php $no =1;?>
  162. <?php foreach($textbookNames as $k=>$v):?>
  163. <span code="<?php echo $k;?>" class="<?php echo $no==1?'active':'';?>"><?php echo $v;?></span>
  164. <?php $no++;?>
  165. <?php endforeach;?>
  166. <?php endif;?>
  167. </div>
  168. </div>
  169. <div class="option-wrap">
  170. <span class="option-name">模块:</span>
  171. <div class="option-con" id="optionModular">
  172. <?php if(isset($moduleNames) && $moduleNames):?>
  173. <?php $no =1;?>
  174. <?php foreach($moduleNames as $k=>$v):?>
  175. <span code="<?php echo $k;?>" class="<?php echo $no==1?'active':'';?>"><?php echo $v;?></span>
  176. <?php $no++;?>
  177. <?php endforeach;?>
  178. <?php endif;?>
  179. </div>
  180. </div>
  181. <div class="option-wrap">
  182. <span class="option-name">单元:</span>
  183. <div class="option-con" id="optionUnit">
  184. <?php if(isset($unitNames) && $unitNames):?>
  185. <?php $no =1;?>
  186. <?php foreach($unitNames as $k=>$v):?>
  187. <span code="<?php echo $k;?>" class="<?php echo $no==1?'active':'';?>"><?php echo $v;?></span>
  188. <?php $no++;?>
  189. <?php endforeach;?>
  190. <?php endif;?>
  191. </div>
  192. </div>
  193. <div class="option-wrap">
  194. <span class="option-name">已选单元:</span>
  195. <div id="selectedUnit">
  196. </div>
  197. </div>
  198. <div class="option-wrap">
  199. <span class="option-name">下载方式:</span>
  200. <div class="option-con">
  201. <span><input type="radio" name="is_answer_separate" value="1" checked="checked">分离题目和答案</span>
  202. <span><input type="radio" name="is_answer_separate" value="0">合并题目和答案</span>
  203. </div>
  204. </div>
  205. <div class="option-wrap" style="display: none">
  206. <span class="option-name">班级间内容:</span>
  207. <div class="option-con">
  208. <span><input type="radio" name="is_same_answer" value="1" checked="checked">答案相同</span>
  209. <span><input type="radio" name="is_same_answer" value="0" >答案不同</span>
  210. </div>
  211. </div>
  212. <div class="option-wrap">
  213. <span class="option-name">专题:</span>
  214. <div class="option-con" id="optionItem">
  215. <?php if(isset($special_arr) && $special_arr):?>
  216. <?php $no =1;?>
  217. <?php foreach($special_arr as $k=>$v):?>
  218. <span code="<?php echo $v['special_id'];?>" class="special-name <?php echo $no==1?'active':'';?>"><?php echo $v['special_name'];?></span>
  219. <?php $no++;?>
  220. <?php endforeach;?>
  221. <?php endif;?>
  222. </div>
  223. </div>
  224. <div class="option-wrap">
  225. <span class="option-name">专项:</span>
  226. <?php if(isset($special_arr) && $special_arr):?>
  227. <?php $no =1;?>
  228. <?php foreach($special_arr as $k=>$special):?>
  229. <div class="option-con" id="special_item_<?php echo $special['special_id'];?>" style="display: <?php echo $no == 1?'':'none';?>">
  230. <div class="hgc_leader-btn select-all">
  231. <span class="color-red" is_all="1"><i class="icon"></i>全选</span>
  232. <span class="color-red" is_all="0"><i class="icon"></i>全不选</span>
  233. </div>
  234. <div class="option-con-class" id="">
  235. <?php if($special['items']):?>
  236. <?php foreach($special['items'] as $item):?>
  237. <label>
  238. <input type="checkbox" name="option-class" value="<?php echo $item['item_id'];?>" item_name="<?php echo $item['item_name'];?>">
  239. <?php echo $item['item_name'];?>
  240. </label>
  241. <?php endforeach;?>
  242. <?php endif;?>
  243. </div>
  244. </div>
  245. <?php $no++;?>
  246. <?php endforeach;?>
  247. <?php endif;?>
  248. </div>
  249. <div class="option-wrap">
  250. <span class="option-name">已选择:</span>
  251. <div class="option-con">
  252. <div class="hgc_leader-btn">
  253. <span>已选<i class="color-red item-num">0</i>个选项</span>
  254. <span class="color-red clear-all-item"><i class="icon"></i>清空所有选项</span>
  255. </div>
  256. <div class="option-con-class hgc_option-con special-item-box">
  257. <!-- <label>一般现在时<i class="icon"></i></label>-->
  258. </div>
  259. </div>
  260. </div>
  261. <p style="margin-top:10px;background-color: #2977ff;color:white;height: 40px;line-height:40px;min-width: 600px;width: 85%;">
  262. <span style="float: left;margin-left: 20px;">内容自定义</span>
  263. <span style="float: right;margin-right: 20px;"> *产品设置未打开部分,设置将无效。</span></p>
  264. <p class="p-one-level">1. 词汇自测</p>
  265. <p class="p-two-level">1.1 核心单词/全单元词汇</p>
  266. <div class="option-wrap option-wrap-content">
  267. <span class="option-name">数量:</span>
  268. <div class="option-con">
  269. <span><input style="width: 50px;" name="words_count" type="text" value=30>(<i id="word_total">0</i>)个(1-100)</span>
  270. </div>
  271. </div>
  272. <div class="option-wrap option-wrap-content">
  273. <span class="option-name">范围:</span>
  274. <div class="option-con">
  275. <span><input type="radio" name="words_range" value=1 checked="checked">核心词汇</span>
  276. <span><input type="radio" name="words_range" value=2>全单元单词</span>
  277. </div>
  278. </div>
  279. <div class="option-wrap option-wrap-content">
  280. <span class="option-name">形式:</span>
  281. <div class="option-con">
  282. <span><input type="radio" name="words_type" value="1" checked="checked">汉译英</span>
  283. <span><input type="radio" name="words_type" value="2">英译汉</span>
  284. <span><input type="radio" name="words_type" value="3">中英互译</span>
  285. </div>
  286. </div>
  287. <div class="option-wrap option-wrap-content">
  288. <span class="option-name">派生:</span>
  289. <div class="option-con">
  290. <span><input type="radio" name="is_word_derive" value=1 checked="checked">有</span>
  291. <span><input type="radio" name="is_word_derive" value=0>无</span>
  292. </div>
  293. </div>
  294. <p class="p-two-level">1.2 词汇运用</p>
  295. <div class="option-wrap option-wrap-content">
  296. <span class="option-name">题数(0~20):</span>
  297. <div class="option-con">
  298. <span>单词拼写&nbsp;<input style="width: 50px;" name="spell_count" type="text">&nbsp;题</span>
  299. <span>完成句子&nbsp;<input style="width: 50px;" name="sentence_count" type="text">&nbsp;题</span>
  300. <span>单句语法填空&nbsp;<input style="width: 50px;" name="blank_count" type="text">&nbsp;题</span>
  301. <span>单句翻译&nbsp;<input style="width: 50px;" name="translate_count" type="text">&nbsp;题</span>
  302. </div>
  303. </div>
  304. <p class="p-two-level">1.3 重点短语</p>
  305. <div class="option-wrap option-wrap-content">
  306. <span class="option-name">数量:</span>
  307. <div class="option-con">
  308. <span><input style="width: 50px;" name="phrase_count" type="text" value=20>(<i id="phrase_total">0</i>)个</span>
  309. </div>
  310. </div>
  311. <div class="option-wrap option-wrap-content">
  312. <span class="option-name">形式:</span>
  313. <div class="option-con">
  314. <span><input type="radio" name="phrase_type" value="1" checked="checked">汉译英</span>
  315. <span><input type="radio" name="phrase_type" value="2">英译汉</span>
  316. </div>
  317. </div>
  318. <p class="p-one-level">2. 语法聚焦</p>
  319. <p class="p-two-level">2.1 单句语法填空</p>
  320. <div class="option-wrap option-wrap-content">
  321. <span class="option-name">题数:</span>
  322. <div class="option-con">
  323. <span><input style="width: 50px;" name="grammar_single_count" type="text">&nbsp;题(0-20)个</span>
  324. </div>
  325. </div>
  326. <p class="p-two-level">2.2 语法填空</p>
  327. <div class="option-wrap option-wrap-content">
  328. <span class="option-name">篇数:</span>
  329. <div class="option-con">
  330. <span><input style="width: 50px;" name="grammar_sheet_count" type="text">&nbsp;题(0-3)篇</span>
  331. </div>
  332. </div>
  333. <p class="p-one-level">3. 外刊泛读</p>
  334. <div class="option-wrap option-wrap-content">
  335. <span class="option-name">篇数:</span>
  336. <div class="option-con">
  337. <span><input style="width: 50px;" name="reading_count" type="text">&nbsp;题(0-3)篇</span>
  338. </div>
  339. </div>
  340. <button class="btn-start" id="confirm" active="true">开始生成</button>
  341. </div>
  342. </div>
  343. <script src="/js/jquery.ajaxfileupload.js"></script>
  344. <script type="text/javascript">
  345. $(document).ready(function () {
  346. getClassByGrade(3);
  347. //增加专项
  348. function addItem(id,name) {
  349. var ele = '<label item_id="'+id+'">'+name+'<i class="icon selected-item"></i></label>';
  350. $(".special-item-box").append(ele);
  351. }
  352. function itmeNume() {
  353. $(".item-num").text($(".special-item-box>label").length);
  354. }
  355. //切换专题
  356. $(".special-name").click(function () {
  357. $("#optionItem>span").removeClass('active')
  358. $(this).addClass('active');
  359. var specialId = $(this).attr('code');
  360. $('#special_item_'+specialId).show().siblings('.option-con').hide();
  361. });
  362. //选择专项
  363. $(".select-all>span").click(function () {
  364. var input_arr = $(this).parent().siblings('.option-con-class').children('label').children('input');
  365. //全选
  366. if ($(this).attr('is_all') > 0) {
  367. if (input_arr) {
  368. $.each(input_arr,function () {
  369. if (!$(this).is(':checked')) {
  370. $(this).prop("checked",true);
  371. addItem($(this).val(), $(this).attr('item_name'));
  372. }
  373. })
  374. }
  375. }else{//全不选
  376. if (input_arr) {
  377. $.each(input_arr,function () {
  378. if ($(this).is(':checked')) {
  379. $(this).prop("checked",false);
  380. var item_id = $(this).val();
  381. $('label[item_id="'+item_id+'"]').remove();
  382. }
  383. })
  384. }
  385. }
  386. itmeNume();
  387. });
  388. //选择单个专项
  389. $('input[name="option-class"]').change(function () {
  390. if (!$(this).is(':checked')) {
  391. var item_id = $(this).val();
  392. $('label[item_id="'+item_id+'"]').remove();
  393. }else{
  394. addItem($(this).val(), $(this).attr('item_name'));
  395. }
  396. itmeNume();
  397. });
  398. //清空所有选项
  399. $(".clear-all-item").click(function () {
  400. $.each($(".special-item-box>label"),function () {
  401. $('input[value="'+$(this).attr('item_id')+'"]').prop("checked",false);
  402. })
  403. $(".special-item-box").empty();
  404. itmeNume();
  405. });
  406. //清空单个选项
  407. $("body").delegate(".selected-item", "click", function() {
  408. $('input[value="'+$(this).parent('label').attr('item_id')+'"]').prop("checked",false);
  409. $(this).parent('label').remove();
  410. itmeNume();
  411. });
  412. var optionData={
  413. edition:0,
  414. modular:0,
  415. unit:0,
  416. class:[],
  417. }
  418. // 单选按钮
  419. $("input[name='option-class']").change(function() {
  420. getsClassSelected();
  421. });
  422. function getsClassSelected() {
  423. optionData.class=[];
  424. var selectedData = $("input[name='option-class']:checked"); //获取所以选中学生
  425. for (var i = 0; i < selectedData.length; i++) {
  426. code = $(selectedData[i]).val();
  427. optionData.class.push(code);
  428. }
  429. };
  430. //获取版本模块单元
  431. // 版本点击
  432. $("#optionEdition>span").on("click", function(event) {
  433. if(!limitUnit()){
  434. layer.msg('已选单元超出限制');return false;
  435. }
  436. $("#optionEdition>span").removeClass('active')
  437. $(this).addClass('active');
  438. var code = $(this).attr("code");
  439. optionData.edition=code;
  440. console.log('版本',code)
  441. });
  442. // 模块点击
  443. $("#optionModular>span").on("click", function(event) {
  444. if(!limitUnit()){
  445. layer.msg('已选单元超出限制');return false;
  446. }
  447. $("#optionModular>span").removeClass('active')
  448. $(this).addClass('active');
  449. var code = $(this).attr("code");
  450. optionData.modular=code;
  451. console.log('模块',code)
  452. });
  453. // 单元点击
  454. $("body").delegate("#optionUnit>span", "click", function() {
  455. if(!limitUnit()){
  456. layer.msg('已选单元超出限制');return false;
  457. }
  458. // $("#optionUnit>span").on("click", function(event) {
  459. $("#optionUnit>span").removeClass('active')
  460. $(this).addClass('active');
  461. var code = $(this).attr("code");
  462. optionData.unit=code;
  463. console.log('单元',code)
  464. });
  465. // 选择年级
  466. $(".select-grade").change(function() {
  467. console.log($(this).val())
  468. });
  469. // 单选按钮
  470. $("input[name='option-class']").change(function() {
  471. getsClassSelected();
  472. });
  473. function getsClassSelected() {
  474. optionData.class=[];
  475. var selectedData = $("input[name='option-class']:checked"); //获取所以选中学生
  476. for (var i = 0; i < selectedData.length; i++) {
  477. code = $(selectedData[i]).val();
  478. optionData.class.push(code);
  479. }
  480. };
  481. //
  482. $("body").delegate("#optionEdition span", "click", function() {
  483. if(!limitUnit()){
  484. layer.msg('已选单元超出限制');return false;
  485. }
  486. // $('#optionEdition span').on("click", function(event) {
  487. var textbookId = $(this).attr("code");
  488. if(textbookId){
  489. $.ajax({
  490. url: "<?php echo $this->createUrl('print/ajaxWeekGetModuleAndUnit');?>",
  491. type: "POST",
  492. dataType: "json",
  493. data: {
  494. textbookId: textbookId
  495. },
  496. success: function (data) {
  497. console.log(data);
  498. var htmlModule = '';
  499. var htmlUnit = '';
  500. if(data.moduleNames){
  501. var a = 1;
  502. for(var i in data.moduleNames){
  503. if(a == 1){
  504. htmlModule += '<span code="'+i+'" class="active">'+data.moduleNames[i]+'</span>';
  505. }else{
  506. htmlModule += '<span code="'+i+'">'+data.moduleNames[i]+'</span>';
  507. }
  508. a++;
  509. }
  510. }
  511. if(data.unitNames){
  512. var a = 1;
  513. for(var i in data.unitNames){
  514. if(a == 1){
  515. htmlUnit += '<span code="'+i+'" class="active">'+data.unitNames[i]+'</span>';
  516. }else{
  517. htmlUnit += '<span code="'+i+'">'+data.unitNames[i]+'</span>';
  518. }
  519. a++;
  520. }
  521. }
  522. $('#optionModular').html(htmlModule);
  523. $('#optionUnit').html(htmlUnit);
  524. }
  525. });
  526. }
  527. })
  528. $("body").delegate("#optionModular span", "click", function() {
  529. if(!limitUnit()){
  530. layer.msg('已选单元超出限制');return false;
  531. }
  532. $("#optionModular>span").removeClass('active')
  533. $(this).addClass('active');
  534. var code = $(this).attr("code");
  535. optionData.modular=code;
  536. // $('#optionModular span').on("click", function(event) {
  537. var moduleId = $(this).attr("code");
  538. var textbookId = $('#optionEdition span.active').attr("code");
  539. if(textbookId && moduleId){
  540. $.ajax({
  541. url: "<?php echo $this->createUrl('print/ajaxWeekGetUnitByModuleId');?>",
  542. type: "POST",
  543. dataType: "json",
  544. data: {
  545. textbookId: textbookId,
  546. moduleId:moduleId
  547. },
  548. success: function (data) {
  549. console.log(data);
  550. var htmlUnit = '';
  551. if(data.unitNames){
  552. var a = 1;
  553. for(var i in data.unitNames){
  554. if(a == 1){
  555. htmlUnit += '<span code="'+i+'" class="active">'+data.unitNames[i]+'</span>';
  556. }else{
  557. htmlUnit += '<span code="'+i+'">'+data.unitNames[i]+'</span>';
  558. }
  559. a++;
  560. }
  561. }
  562. $('#optionUnit').html(htmlUnit);
  563. }
  564. });
  565. }
  566. })
  567. $("body").delegate("#optionUnit span","click",function () {
  568. if(!limitUnit()){
  569. layer.msg('已选单元超出限制');return false;
  570. }
  571. var text_book_id = $("#optionEdition").children(".active").attr("code");
  572. var module_id = $("#optionModular").children(".active").attr("code");
  573. var unit_id = $(this).attr("code");
  574. var ids = text_book_id + '_' + module_id + '_' + unit_id;
  575. var selected_arr = [];
  576. if($('#selectedUnit span').length > 0){
  577. $('#selectedUnit span').each(function(index){
  578. selected_arr.push($(this).attr('node'));
  579. });
  580. }
  581. if($.inArray(ids, selected_arr) >= 0){
  582. layer.msg('不能重复添加该单元');return false;
  583. }
  584. //动态获取单元关联单词和短语数量
  585. $.ajax({
  586. url: "<?php echo $this->createUrl('englishWeek/ajaxWordPhraseCount');?>",
  587. type: "POST",
  588. dataType: "json",
  589. data: {
  590. ids: ids,
  591. grade:3
  592. },
  593. beforeSend:function(){
  594. layer.load(1, {
  595. shade: [0.1,'#fff'] //0.1透明度的白色背景
  596. });
  597. },
  598. success: function (data) {
  599. var index = layer.load();
  600. layer.close(index);
  601. var label = $("#optionClass > label");
  602. jQuery.each(label, function(){
  603. var class_id = $(this).children().val();
  604. count = 0;
  605. $.each(data.data.classCount, function(id,number) {
  606. if(id==class_id){
  607. count = number;
  608. }
  609. });
  610. $(this).children('.unit_generate_count').children('span').append('<span style="color: #07af66;margin-left:5px;margin-right: 5px" class="unit' + ids + '">' + count + '</span>');
  611. $('.unit_generate_count').show();
  612. });
  613. var word_total = parseInt($('#word_total').text());
  614. var phrase_total = parseInt($('#phrase_total').text());
  615. word_total = word_total + data.data.wordCount;
  616. phrase_total = phrase_total + data.data.phraseCount;
  617. $('#word_total').text(word_total);
  618. $('#phrase_total').text(phrase_total);
  619. }
  620. });
  621. var text_book_name = $("#optionEdition").children(".active").text();
  622. var module_name = $("#optionModular").children(".active").text();
  623. var unit_name = $(this).text();
  624. var names = text_book_name + '_' + module_name + '_' + unit_name;
  625. var _html = '<span node="' + ids + '">' + names + '<i class="delete-icon" onclick="deleteUnit(this)"></i></span>';
  626. $("#selectedUnit").append(_html);
  627. });
  628. $("#confirm[active='true']").on("click", function() {
  629. $('#confirm').attr('disabled','disabled');
  630. var This = $(this);
  631. This.attr("active","false");
  632. var error = [];
  633. var selectClassIds = [];
  634. var selectedItemIds = [];
  635. var unitIds = [];
  636. var names = [];
  637. var specialNames = [];
  638. $('#optionClass input:checked').each(function(k,v){
  639. if($(this).attr("status") == 0){
  640. selectClassIds.push($(this).val());
  641. }
  642. });
  643. $('#selectedUnit span').each(function(k,v){
  644. unitIds.push($(this).attr('node'));
  645. names.push($(this).text())
  646. });
  647. $('#optionClass input:checked').each(function(k,v){
  648. if($(this).attr("status") == 0){
  649. selectClassIds.push($(this).val());
  650. }
  651. });
  652. $(".special-item-box>label").each(function(k,v){
  653. if($(this).attr("item_id")){
  654. selectedItemIds.push($(this).attr("item_id"));
  655. specialNames.push($(this).text())
  656. }
  657. });
  658. if(selectClassIds.length == 0){
  659. error.push("请选择班级");
  660. }
  661. if(unitIds.length == 0){
  662. error.push("请选择单元")
  663. }
  664. if(selectedItemIds.length == 0){
  665. error.push("请选择专项");
  666. }
  667. //核心单词输入校验
  668. var word_count = $("input[name='words_count']").val();
  669. if(!isPositiveInteger(word_count)){
  670. error.push("单词数量请输入正整数")
  671. }
  672. word_count = parseInt(word_count);
  673. var word_total = parseInt($('#word_total').text());
  674. if(word_count > word_total || word_count>100){
  675. error.push("单词数量超出总数")
  676. }
  677. if(word_count <= 0){
  678. error.push("请检查单词数量")
  679. }
  680. //重点短语输入校验
  681. var phrase_count = $("input[name='phrase_count']").val();
  682. if(!isPositiveInteger(phrase_count)){
  683. error.push("重点短语数量请输入正整数")
  684. }
  685. phrase_count = parseInt(phrase_count);
  686. var phrase_total = parseInt($('#phrase_total').text());
  687. if(phrase_count > phrase_total || phrase_count>100){
  688. error.push("重点短语数量超出总数")
  689. }
  690. if(phrase_count <= 0){
  691. error.push("请检查短语数量")
  692. }
  693. var isAnswerSeparate = $("input[name='is_answer_separate']:checked").val();
  694. var isSameAnswer = $("input[name='is_same_answer']:checked").val();
  695. var wordsType = $("input[name='words_type']:checked").val();
  696. var phraseType = $("input[name='phrase_type']:checked").val();
  697. var isWordDerive = $("input[name='is_word_derive']:checked").val();
  698. var wordRange = $("input[name='words_range']:checked").val();
  699. var spellCount = parseInt($("input[name='spell_count']").val());
  700. var sentenceCount = parseInt($("input[name='sentence_count']").val());
  701. var blankCount = parseInt($("input[name='blank_count']").val());
  702. var translateCount = parseInt($("input[name='translate_count']").val());
  703. var grammarSingleCount = parseInt($("input[name='grammar_single_count']").val());
  704. var grammarSheetCount = parseInt($("input[name='grammar_sheet_count']").val());
  705. var readingCount = parseInt($("input[name='reading_count']").val());
  706. if(!isPositiveInteger(spellCount) || spellCount<0 ){
  707. error.push("请检查单词拼写数量")
  708. }
  709. if(!isPositiveInteger(sentenceCount) || sentenceCount<0){
  710. error.push("请检查完成句子数量")
  711. }
  712. if(!isPositiveInteger(blankCount) || blankCount<0){
  713. error.push("请检查单句语法填空数量")
  714. }
  715. if(!isPositiveInteger(translateCount) || translateCount<0){
  716. error.push("请检查单句翻译数量")
  717. }
  718. if((spellCount+sentenceCount+blankCount+translateCount)>20){
  719. error.push("词汇运用题数超出限制")
  720. }
  721. if(!isPositiveInteger(grammarSingleCount) || grammarSingleCount<0 || grammarSingleCount>20 || !isPositiveInteger(grammarSheetCount) || grammarSheetCount<0 || grammarSheetCount>3){
  722. error.push("请检查语法聚焦数量")
  723. }
  724. if(!isPositiveInteger(readingCount) || readingCount<0 || readingCount>3){
  725. error.push("请检查外刊泛读数量")
  726. }
  727. if(error.length == 0){
  728. $.ajax({
  729. url: "<?php echo $this->createUrl('print/ajaxSaveEnglishWeek');?>",
  730. type: "POST",
  731. dataType: "json",
  732. data: {
  733. grade:3,
  734. selectClassIds:selectClassIds,
  735. selectedItemIds:selectedItemIds,
  736. unitIds: unitIds,
  737. names: names,
  738. wordCount:word_count,
  739. phraseCount:phrase_count,
  740. isAnswerSeparate:isAnswerSeparate,
  741. wordsType:wordsType,
  742. phraseType:phraseType,
  743. isSameAnswer:isSameAnswer,
  744. wordRange:wordRange,
  745. spellCount:spellCount,
  746. sentenceCount:sentenceCount,
  747. isWordDerive:isWordDerive,
  748. blankCount:blankCount,
  749. translateCount:translateCount,
  750. grammarSingleCount:grammarSingleCount,
  751. grammarSheetCount:grammarSheetCount,
  752. readingCount:readingCount,
  753. specialNames:specialNames
  754. },
  755. success: function (data) {
  756. if(data.status == 1){
  757. layer.msg('已发送到后台,预计1小时左右生成!', {
  758. time: 2000,
  759. });
  760. setTimeout(function(){window.location.href = "<?php echo Yii::app()->createUrl('print/mrv');?>";}, 2000);
  761. }else{
  762. layer.msg(data.error.join('</br>'));
  763. This.attr("active","true");
  764. }
  765. }
  766. });
  767. }else{
  768. $('#confirm').removeAttr('disabled');
  769. This.attr("active","true");
  770. layer.msg(error.join('</br>'));
  771. }
  772. });
  773. function getClassByGrade(grade){
  774. if(grade){
  775. $.ajax({
  776. url: "<?php echo $this->createUrl('print/ajaxGetClassesBySettingWeek');?>",
  777. type: "POST",
  778. dataType: "json",
  779. data: {
  780. grade: grade,
  781. },
  782. beforeSend:function(){
  783. layer.load(1, {
  784. shade: [0.1,'#fff'] //0.1透明度的白色背景
  785. });
  786. },
  787. success: function (data) {
  788. var index = layer.load();
  789. layer.close(index);
  790. console.log(data);
  791. var html = '';
  792. if(data && data.length > 0){
  793. for(var i in data){
  794. html +='<label>';
  795. if(data[i].status == 1){
  796. html += ' <input type="checkbox" name="option-class" value="'+data[i].class_id+'" checked="checked" disabled="disabled" status="1">'+data[i].class_name;
  797. }else{
  798. html += ' <input type="checkbox" name="option-class" value="'+data[i].class_id+'" status="0">'+data[i].class_name;
  799. }
  800. html +='<span style="display: none;margin-left: 5px;" class="unit_generate_count">' + '(' + '<span></span>' + ')' + '</span></label>';
  801. }
  802. }
  803. html += '<div style="color: red;font-weight: bold">' + '* 选择单元后班级右边括号内数字为该单元历史生成次数' + '</div>';
  804. $('#optionClass').html(html);
  805. }
  806. });
  807. }
  808. }
  809. });
  810. function deleteUnit(a) {
  811. var ids = $(a).parent().attr('node');
  812. var generate_class = ".unit"+ ids;
  813. $("span").remove(generate_class);
  814. //动态获取单元关联单词和短语数量
  815. $.ajax({
  816. url: "<?php echo $this->createUrl('englishWeek/ajaxWordPhraseCount');?>",
  817. type: "POST",
  818. dataType: "json",
  819. data: {
  820. ids: ids,
  821. grade: 3
  822. },
  823. beforeSend:function(){
  824. layer.load(1, {
  825. shade: [0.1,'#fff'] //0.1透明度的白色背景
  826. });
  827. },
  828. success: function (data) {
  829. var index = layer.load();
  830. layer.close(index);
  831. var word_total = parseInt($('#word_total').text());
  832. var phrase_total = parseInt($('#phrase_total').text());
  833. word_total = word_total - data.data.wordCount;
  834. phrase_total = phrase_total - data.data.phraseCount;
  835. $('#word_total').text(word_total);
  836. $('#phrase_total').text(phrase_total);
  837. }
  838. });
  839. $(a).parent().remove();
  840. if($("#selectedUnit").children("span").length == 0){
  841. $('.unit_generate_count').hide();
  842. }
  843. }
  844. function limitUnit() {
  845. var grade = $('.select-grade').val();
  846. var selected_count = $("#selectedUnit").children("span").length;
  847. if(selected_count == 3){
  848. return false;
  849. }
  850. return true;
  851. }
  852. function isPositiveInteger(s){//是否为正整数
  853. var re = /^[0-9]+$/ ;
  854. return re.test(s)
  855. }
  856. </script>