setting.php 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787
  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. .active{
  45. color: #619aff;
  46. }
  47. .btn-start{
  48. display: inline-block;
  49. margin-top: 20px;
  50. margin-left: 100px;
  51. padding: 10px 30px;
  52. color: #fff;
  53. background-color: #2977ff;
  54. cursor: pointer;
  55. }
  56. .en-tfb-grade-1{
  57. margin-left: 20px;
  58. }
  59. #selectedUnit{
  60. display: inline-block;
  61. width: 80%;
  62. min-width: 490px;
  63. padding: 10px;
  64. border: 1px solid #ccc;
  65. }
  66. #selectedUnit span{
  67. position: relative;
  68. padding: 5px;
  69. padding-right: 30px;
  70. border: 1px solid #999;
  71. margin-right: 15px;
  72. }
  73. .delete-icon{
  74. position: absolute;
  75. top: 50%;
  76. right: 5px;
  77. transform: translateY(-50%);
  78. width: 15px;
  79. height: 15px;
  80. background: url(<?php echo $imgUrl.'/images/icon-delect.png';?>) no-repeat center;
  81. background-size: contain;
  82. cursor: pointer;
  83. }
  84. .teacher-word-group{
  85. color: #619aff;
  86. }
  87. .word-group-hidden{
  88. height: 38px;
  89. overflow: hidden;
  90. }
  91. </style>
  92. <div class="main-content-inner">
  93. <!-- 导航栏开始-->
  94. <?php include(Yii::app()->basePath.'/views/layouts/view_production_navigation.php');?>
  95. <!-- 导航栏结束-->
  96. <div class="en-tfb-grade-1">
  97. <h2>生成词汇宝</h2>
  98. <p class="color-red">* 好消息!词汇宝现已支持教师端选词后生成检测卡!【每个班级 每周】最多生成【5次】词汇宝,均不限年级、不限间隔时间。</p>
  99. <p class="date">
  100. <span>当前时间:</span>
  101. <span><?php echo $year;?>年<?php echo $month;?>月第<?php echo $week;?>周</span>
  102. </p>
  103. <div class="option-wrap">
  104. <span class="option-name">班级:</span>
  105. <div class="option-con">
  106. <div>
  107. <select name="grade" class="select-grade">
  108. <option value="1" <?php if(isset($setting['grade']) && $setting['grade']==1) echo 'selected';?>>高一</option>
  109. <option value="2" <?php if(isset($setting['grade']) && $setting['grade']==2) echo 'selected';?>>高二</option>
  110. <option value="3" <?php if(isset($setting['grade']) && $setting['grade']==3) echo 'selected';?>>高三</option>
  111. </select>
  112. </div>
  113. <div class="option-con-class" id="optionClass">
  114. </div>
  115. </div>
  116. </div>
  117. <div class="option-wrap">
  118. <span class="option-name">版本:</span>
  119. <div class="option-con" id="optionEdition">
  120. <?php if(isset($textbookNames) && $textbookNames):?>
  121. <?php $no =1;?>
  122. <?php foreach($textbookNames as $k=>$v):?>
  123. <span code="<?php echo $k;?>" class="<?php echo $no==1?'active':'';?>"><?php echo $v;?></span>
  124. <?php $no++;?>
  125. <?php endforeach;?>
  126. <?php endif;?>
  127. </div>
  128. </div>
  129. <div class="option-wrap">
  130. <span class="option-name">模块:</span>
  131. <div class="option-con" id="optionModular">
  132. <?php if(isset($moduleNames) && $moduleNames):?>
  133. <?php $no =1;?>
  134. <?php foreach($moduleNames as $k=>$v):?>
  135. <span code="<?php echo $k;?>" class="<?php echo $no==1?'active':'';?>"><?php echo $v;?></span>
  136. <?php $no++;?>
  137. <?php endforeach;?>
  138. <?php endif;?>
  139. </div>
  140. </div>
  141. <div class="option-wrap">
  142. <span class="option-name">单元:</span>
  143. <div class="option-con" id="optionUnit">
  144. <?php if(isset($unitNames) && $unitNames):?>
  145. <?php $no =1;?>
  146. <?php foreach($unitNames as $k=>$v):?>
  147. <span code="<?php echo $k;?>" class="<?php echo $no==1?'active':'';?>"><?php echo $v;?></span>
  148. <?php $no++;?>
  149. <?php endforeach;?>
  150. <?php endif;?>
  151. </div>
  152. </div>
  153. <div class="option-wrap">
  154. <span class="option-name">已选单元:</span>
  155. <div id="selectedUnit">
  156. </div>
  157. <li style="list-style:none;margin-left:100px;color: red;font-weight: bold">* 高一二年级每次只可选一个单元,高三年级可选1~3个单元。</li>
  158. </div>
  159. <?php if($isWhole):?>
  160. <div class="option-wrap">
  161. <span class="option-name">词汇精讲数量:</span>
  162. <div class="option-con" >
  163. <!-- <span><input type="radio" name="words_count" value="1" >默认数量(<i id="word_default">20</i>)个</span>-->
  164. <span><input value="<?php echo isset($setting['words_count'])?$setting['words_count']:15;?>" style="width: 80px;" name="words_number" type="text" placeholder="最多40个"></span>
  165. <span>共(<i id="word_total">0</i>)个</span>
  166. <span style="margin-left:50px;color: red;font-weight: bold">* 数量限制:10-40个,且不超过所选单元总单词数。</span>
  167. </div>
  168. </div>
  169. <?php else:?>
  170. <div class="option-wrap" style="display: none;">
  171. <span class="option-name">词汇精讲数量:</span>
  172. <div class="option-con" >
  173. <!-- <span><input type="radio" name="words_count" value="1" >默认数量(<i id="word_default">20</i>)个</span>-->
  174. <span><input value="15" style="width: 80px;" name="words_number" type="text" placeholder="最多40个"></span>
  175. <span>共(<i id="word_total">0</i>)个</span>
  176. </div>
  177. </div>
  178. <?php endif;?>
  179. <div class="option-wrap">
  180. <span class="option-name">下载方式:</span>
  181. <div class="option-con">
  182. <?php if(isset($setting['is_answer_separate'])):?>
  183. <span><input type="radio" name="is_answer_separate" value="1" <?php if($setting['is_answer_separate']==1) echo 'checked';?>>分离题目和答案</span>
  184. <span><input type="radio" name="is_answer_separate" value="0" <?php if($setting['is_answer_separate']==0) echo 'checked';?>>合并题目和答案</span>
  185. <?php else:?>
  186. <span><input type="radio" name="is_answer_separate" value="1" checked="checked">分离题目和答案</span>
  187. <span><input type="radio" name="is_answer_separate" value="0">合并题目和答案</span>
  188. <?php endif;?>
  189. <span style="margin-left:50px;color: red;font-weight: bold">* 只影响词汇集训和错词再练板块。</span>
  190. </div>
  191. </div>
  192. <div class="option-wrap">
  193. <span class="option-name">精准训练形式:</span>
  194. <div class="option-con" >
  195. <?php if(isset($setting['practice_type'])):?>
  196. <span><input type="radio" name="practice_type" value="1" <?php if($setting['practice_type']==1) echo 'checked';?>>共性(全班学生题目内容一致)</span>
  197. <span><input type="radio" name="practice_type" value="2" <?php if($setting['practice_type']==2) echo 'checked';?> >个性(根据学生正确率个性化推送题目内容) </span>
  198. <?php else:?>
  199. <span><input type="radio" name="practice_type" value="1" checked="checked">共性(全班学生题目内容一致)</span>
  200. <span><input type="radio" name="practice_type" value="2" >个性(根据学生正确率个性化推送题目内容) </span>
  201. <?php endif;?>
  202. </div>
  203. </div>
  204. <div id="commonSet" style="margin-left: 100px;">
  205. <div class="option-wrap">
  206. <span class="option-name">英汉互译形式:</span>
  207. <div class="option-con" >
  208. <?php if(isset($setting['translate_type'])):?>
  209. <span><input type="radio" name="translate_type" value="1" <?php if($setting['translate_type']==1) echo 'checked';?>>英汉互译</span>
  210. <span><input type="radio" name="translate_type" value="2" <?php if($setting['translate_type']==2) echo 'checked';?>>英译中</span>
  211. <span><input type="radio" name="translate_type" value="3" <?php if($setting['translate_type']==3) echo 'checked';?>>中译英</span>
  212. <?php else:?>
  213. <span><input type="radio" name="translate_type" value="1" checked="checked">英汉互译</span>
  214. <span><input type="radio" name="translate_type" value="2">英译中</span>
  215. <span><input type="radio" name="translate_type" value="3">中译英</span>
  216. <?php endif;?>
  217. </div>
  218. </div>
  219. <div class="option-wrap">
  220. <span class="option-name">班级间内容:</span>
  221. <div class="option-con" >
  222. <?php if(isset($setting['is_class_common'])):?>
  223. <span><input type="radio" name="is_class_common" value="1" <?php if($setting['is_class_common']==1) echo 'checked';?>>相同</span>
  224. <span><input type="radio" name="is_class_common" value="0" <?php if($setting['is_class_common']==0) echo 'checked';?>>不同</span>
  225. <?php else:?>
  226. <span><input type="radio" name="is_class_common" value="1" checked="checked">相同</span>
  227. <span><input type="radio" name="is_class_common" value="0" >不同</span>
  228. <?php endif;?>
  229. </div>
  230. </div>
  231. </div>
  232. <div class="option-wrap">
  233. <span class="option-name">检测卡来源:</span>
  234. <div class="option-con" >
  235. <span><input type="radio" name="card_word_source" value="2" checked>教师端自选词汇</span>
  236. </div>
  237. </div>
  238. <div class="option-wrap card-as2" >
  239. <span class="option-name">检测卡词语数量:</span>
  240. <div class="option-con" >
  241. <?php if(isset($setting['card_word_count'])&& !empty($setting['card_word_count'])):?>
  242. <span>检测卡词语数量:</span>
  243. <span><input style="width: 80px;" name="card_number" type="text" value="<?php echo $setting['card_word_count'];?>" placeholder="最多50个"></span><span>共(<i id="card_word_count_total">0</i>)个</span>
  244. <span style="margin-left:50px;color: red;font-weight: bold">*数量限制:10-50个,且不超过所选单元总单词数。优先推送词汇回顾中的课标重点词汇,题型为中译英。</span>
  245. <?php else:?>
  246. <span>检测卡词语数量:</span>
  247. <span><input style="width: 80px;" name="card_number" type="text" value="30" placeholder="最多50个"></span><span>共(<i id="card_word_count_total">0</i>)个</span>
  248. <span style="margin-left:50px;color: red;font-weight: bold">*数量限制:10-50个,且不超过所选单元总单词数。优先推送词汇回顾中的课标重点词汇,题型为中译英。</span>
  249. <?php endif;?>
  250. </div>
  251. </div>
  252. <div class="option-wrap card-teacher">
  253. <span class="option-name">教师端-自选词汇组:</span>
  254. <div class="option-con word-group-hidden" style="position: relative;" id="allTeacherWord">
  255. <?php foreach ($groupList as $group):?>
  256. <span><input type="radio" name="word_group_id" value="<?php echo $group['word_group_id'];?>" <?php if(isset($setting['word_group_id']) && $setting['word_group_id'] == $group['word_group_id']){ echo "checked";}; ?>>&nbsp;<?php echo $group['name'];?>&nbsp;<span class="teacher-word-group"><?php echo sprintf('(%s,%s个)',$group['create_time'],$group['word_count']);?></span></span>
  257. <?php endforeach;?>
  258. <div style="cursor:pointer;position: absolute;right: 5px;top: 5px;color: #619aff;" id="show-teacher-word" is-hold="1" onclick="isHold()">展开</div>
  259. </div>
  260. <p style="margin-left:100px;color: red;font-weight: bold">
  261. *每个词汇组名称后的括号内为生成时间和词汇总数。
  262. </p>
  263. </div>
  264. <div class="option-wrap">
  265. <span class="option-name">扫描方式:</span>
  266. <div class="option-con">
  267. <?php if(isset($setting['scan_type'])):?>
  268. <span><input type="radio" name="scan_type" value="1" <?php if($setting['scan_type']==1) echo 'checked';?>>二维码</span>
  269. <span><input type="radio" name="scan_type" value="2" <?php if($setting['scan_type']==2) echo 'checked';?>>填涂考号</span>
  270. <?php else:?>
  271. <span><input type="radio" name="scan_type" value="1" checked="checked">二维码</span>
  272. <span><input type="radio" name="scan_type" value="2">填涂考号</span>
  273. <?php endif;?>
  274. </div>
  275. </div>
  276. <button class="btn-start" id="confirm" active="true">开始生成</>
  277. </div>
  278. </div>
  279. <script src="/js/jquery.ajaxfileupload.js"></script>
  280. <script type="text/javascript">
  281. $(document).ready(function () {
  282. getClassByGrade(<?php echo isset($setting['grade'])?$setting['grade']:1 ;?>);
  283. <?php if($setting['practice_type']==2){
  284. echo 'commonSet(2);';
  285. } ?>
  286. var optionData={
  287. edition:0,
  288. modular:0,
  289. unit:0,
  290. class:[],
  291. }
  292. //获取版本模块单元
  293. // 版本点击
  294. $("#optionEdition>span").on("click", function(event) {
  295. if(!limitUnit()){
  296. layer.msg('已选单元超出限制');return false;
  297. }
  298. $("#optionEdition>span").removeClass('active')
  299. $(this).addClass('active');
  300. var code = $(this).attr("code");
  301. optionData.edition=code;
  302. console.log('版本',code)
  303. });
  304. // 模块点击
  305. $("#optionModular>span").on("click", function(event) {
  306. if(!limitUnit()){
  307. layer.msg('已选单元超出限制');return false;
  308. }
  309. $("#optionModular>span").removeClass('active')
  310. $(this).addClass('active');
  311. var code = $(this).attr("code");
  312. optionData.modular=code;
  313. console.log('模块',code)
  314. });
  315. // 单元点击
  316. $("body").delegate("#optionUnit>span", "click", function() {
  317. if(!limitUnit()){
  318. layer.msg('已选单元超出限制');return false;
  319. }
  320. // $("#optionUnit>span").on("click", function(event) {
  321. $("#optionUnit>span").removeClass('active')
  322. $(this).addClass('active');
  323. var code = $(this).attr("code");
  324. optionData.unit=code;
  325. console.log('单元',code)
  326. });
  327. // 选择年级
  328. $(".select-grade").change(function() {
  329. console.log($(this).val())
  330. });
  331. // 单选按钮
  332. $("input[name='option-class']").change(function() {
  333. getsClassSelected();
  334. });
  335. //检测卡来源切换
  336. var card_sourse = $("input[name='card_word_source']:checked").val();
  337. if(card_sourse == 1){
  338. $('.card-as2').show();
  339. $('.card-teacher').hide();
  340. }else{
  341. $('.card-as2').hide();
  342. $('.card-teacher').show();
  343. }
  344. $("input[name='card_word_source']").change(function() {
  345. if($(this).val() == 1){
  346. $('.card-teacher').hide();
  347. $('.card-as2').show();
  348. }else{
  349. $('.card-as2').hide();
  350. $('.card-teacher').show();
  351. }
  352. });
  353. function getsClassSelected() {
  354. optionData.class=[];
  355. var selectedData = $("input[name='option-class']:checked"); //获取所以选中学生
  356. for (var i = 0; i < selectedData.length; i++) {
  357. code = $(selectedData[i]).val();
  358. optionData.class.push(code);
  359. }
  360. };
  361. //
  362. $("body").delegate("#optionEdition span", "click", function() {
  363. if(!limitUnit()){
  364. layer.msg('已选单元超出限制');return false;
  365. }
  366. // $('#optionEdition span').on("click", function(event) {
  367. var textbookId = $(this).attr("code");
  368. if(textbookId){
  369. $.ajax({
  370. url: "<?php echo $this->createUrl('print/ajaxGetModuleAndUnit');?>",
  371. type: "POST",
  372. dataType: "json",
  373. data: {
  374. textbookId: textbookId
  375. },
  376. success: function (data) {
  377. console.log(data);
  378. var htmlModule = '';
  379. var htmlUnit = '';
  380. if(data.moduleNames){
  381. var a = 1;
  382. for(var i in data.moduleNames){
  383. if(a == 1){
  384. htmlModule += '<span code="'+i+'" class="active">'+data.moduleNames[i]+'</span>';
  385. }else{
  386. htmlModule += '<span code="'+i+'">'+data.moduleNames[i]+'</span>';
  387. }
  388. a++;
  389. }
  390. }
  391. if(data.unitNames){
  392. var a = 1;
  393. for(var i in data.unitNames){
  394. if(a == 1){
  395. htmlUnit += '<span code="'+i+'" class="active">'+data.unitNames[i]+'</span>';
  396. }else{
  397. htmlUnit += '<span code="'+i+'">'+data.unitNames[i]+'</span>';
  398. }
  399. a++;
  400. }
  401. }
  402. $('#optionModular').html(htmlModule);
  403. $('#optionUnit').html(htmlUnit);
  404. }
  405. });
  406. }
  407. })
  408. $("body").delegate("#optionModular span", "click", function() {
  409. if(!limitUnit()){
  410. layer.msg('已选单元超出限制');return false;
  411. }
  412. $("#optionModular>span").removeClass('active')
  413. $(this).addClass('active');
  414. var code = $(this).attr("code");
  415. optionData.modular=code;
  416. // $('#optionModular span').on("click", function(event) {
  417. var moduleId = $(this).attr("code");
  418. var textbookId = $('#optionEdition span.active').attr("code");
  419. if(textbookId && moduleId){
  420. $.ajax({
  421. url: "<?php echo $this->createUrl('print/ajaxGetUnitByModuleId');?>",
  422. type: "POST",
  423. dataType: "json",
  424. data: {
  425. textbookId: textbookId,
  426. moduleId:moduleId
  427. },
  428. success: function (data) {
  429. console.log(data);
  430. var htmlUnit = '';
  431. if(data.unitNames){
  432. var a = 1;
  433. for(var i in data.unitNames){
  434. if(a == 1){
  435. htmlUnit += '<span code="'+i+'" class="active">'+data.unitNames[i]+'</span>';
  436. }else{
  437. htmlUnit += '<span code="'+i+'">'+data.unitNames[i]+'</span>';
  438. }
  439. a++;
  440. }
  441. }
  442. $('#optionUnit').html(htmlUnit);
  443. }
  444. });
  445. }
  446. })
  447. $("body").delegate("#optionUnit span","click",function () {
  448. if(!limitUnit()){
  449. layer.msg('已选单元超出限制');return false;
  450. }
  451. var text_book_id = $("#optionEdition").children(".active").attr("code");
  452. var module_id = $("#optionModular").children(".active").attr("code");
  453. var unit_id = $(this).attr("code");
  454. var ids = text_book_id + '_' + module_id + '_' + unit_id;
  455. var selected_arr = [];
  456. if($('#selectedUnit span').length > 0){
  457. $('#selectedUnit span').each(function(index){
  458. selected_arr.push($(this).attr('node'));
  459. });
  460. }
  461. if($.inArray(ids, selected_arr) >= 0){
  462. layer.msg('不能重复添加该单元');return false;
  463. }
  464. var grade = parseInt($('.select-grade').val());
  465. //动态获取单元关联单词和短语数量
  466. $.ajax({
  467. url: "<?php echo $this->createUrl('magic/ajaxWordCount');?>",
  468. type: "POST",
  469. dataType: "json",
  470. data: {
  471. ids: ids,
  472. grade: grade
  473. },
  474. beforeSend:function(){
  475. layer.load(1, {
  476. shade: [0.1,'#fff'] //0.1透明度的白色背景
  477. });
  478. },
  479. success: function (data) {
  480. var index = layer.load();
  481. layer.close(index);
  482. var word_total = parseInt($('#word_total').text());
  483. var card_word_count_total = parseInt($('#card_word_count_total').text());
  484. word_total = word_total + data.data.wordCount;
  485. card_word_count_total = card_word_count_total + data.data.wordCount;
  486. $('#word_total').text(word_total);
  487. $('#card_word_count_total').text(card_word_count_total);
  488. }
  489. });
  490. var text_book_name = $("#optionEdition").children(".active").text();
  491. var module_name = $("#optionModular").children(".active").text();
  492. var unit_name = $(this).text();
  493. var names = text_book_name + '_' + module_name + '_' + unit_name;
  494. var _html = '<span node="' + ids + '">' + names + '<i class="delete-icon" onclick="deleteUnit(this)"></i></span>';
  495. $("#selectedUnit").append(_html);
  496. });
  497. $('.select-grade').change(function(){
  498. $('#selectedUnit').empty();
  499. var grade = $(this).val();
  500. getClassByGrade(grade);
  501. $('#word_total').text(0);
  502. $('#card_default').text(0);
  503. $('#card_total').text(0);
  504. });
  505. $("#confirm[active='true']").on("click", function() {
  506. $('#confirm').attr('disabled','disabled');
  507. var This = $(this);
  508. This.attr("active","false");
  509. var error = [];
  510. var selectClassIds = [];
  511. var unitIds = [];
  512. var names = [];
  513. var grade = parseInt($('.select-grade').val());
  514. var is_class_common = $("input[name='is_class_common']:checked").val();
  515. var translate_type = $("input[name='translate_type']:checked").val();
  516. var practice_type = $("input[name='practice_type']:checked").val();
  517. var isAnswerSeparate = $("input[name='is_answer_separate']:checked").val();
  518. var card_word_source = $("input[name='card_word_source']:checked").val();
  519. var word_group_id = $("input[name='word_group_id']:checked").val();
  520. var scan_type = $("input[name='scan_type']:checked").val();
  521. $('#optionClass input:checked').each(function(k,v){
  522. if($(this).attr("status") == 0){
  523. selectClassIds.push($(this).val());
  524. }
  525. });
  526. $('#selectedUnit span').each(function(k,v){
  527. unitIds.push($(this).attr('node'));
  528. names.push($(this).text())
  529. });
  530. if(selectClassIds.length == 0){
  531. error.push("请选择班级");
  532. }
  533. if(grade <= 0 || !grade){
  534. error.push("请选择年级");
  535. }
  536. if(unitIds.length == 0){
  537. error.push("请选择单元")
  538. }
  539. var word_count = $("input[name='words_number']").val();
  540. if(!isPositiveInteger(word_count)){
  541. error.push("词汇精讲数量请输入正整数")
  542. }
  543. if(word_count > 40){
  544. error.push("词汇精讲数量最多40个")
  545. }
  546. if(word_count <= 0){
  547. error.push("请检查词汇精讲数量")
  548. }
  549. var input_card_count = $("input[name='card_number']").val();
  550. var total_card_count = parseInt($('#card_word_count_total').text());
  551. var card_count = 0;
  552. if(card_word_source == 1) {
  553. if (!isPositiveInteger(input_card_count)) {
  554. error.push("词汇检测卡词语数量请输入正整数");
  555. }
  556. card_count = parseInt(input_card_count);
  557. if (card_count > 50 || card_count<10) {
  558. error.push("词汇检测卡词语数量最多50个最少10个");
  559. }
  560. if(card_count>total_card_count){
  561. error.push("词汇检测卡词语数量超出总数");
  562. }
  563. }
  564. if(error.length == 0){
  565. $.ajax({
  566. url: "<?php echo $this->createUrl('magic/ajaxSaveSetting');?>",
  567. type: "POST",
  568. dataType: "json",
  569. data: {
  570. grade: grade,
  571. selectClassIds:selectClassIds,
  572. unitIds: unitIds,
  573. names: names,
  574. translateType:translate_type,
  575. isClassCommon:is_class_common,
  576. practiceType:practice_type,
  577. wordCount:word_count,
  578. cardWord_count:card_count,
  579. isAnswerSeparate:isAnswerSeparate,
  580. cardWordSource: card_word_source,
  581. wordGroupId: word_group_id,
  582. scanType:scan_type
  583. },
  584. success: function (data) {
  585. if(data.status == 1){
  586. layer.msg('已发送到后台,预计1小时左右生成!', {
  587. time: 2000,
  588. });
  589. setTimeout(function(){window.location.href = "<?php echo Yii::app()->createUrl('magic/index');?>";}, 2000);
  590. }else{
  591. layer.msg(data.error.join('</br>'));
  592. This.attr("active","true");
  593. }
  594. $('#confirm').removeAttr('disabled');
  595. }
  596. });
  597. }else{
  598. $('#confirm').removeAttr('disabled');
  599. This.attr("active","true");
  600. layer.msg(error.join('</br>'));
  601. }
  602. });
  603. function getClassByGrade(grade){
  604. if(grade){
  605. $.ajax({
  606. url: "<?php echo $this->createUrl('magic/ajaxGetClasses');?>",
  607. type: "POST",
  608. dataType: "json",
  609. data: {
  610. grade: grade,
  611. },
  612. beforeSend:function(){
  613. layer.load(1, {
  614. shade: [0.1,'#fff'] //0.1透明度的白色背景
  615. });
  616. },
  617. success: function (data) {
  618. var index = layer.load();
  619. layer.close(index);
  620. var html = '';
  621. if(data && data.length > 0){
  622. for(var i in data){
  623. html +='<label>';
  624. if(data[i].status == 1){
  625. 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>';
  626. }else{
  627. var isChecked = data[i].selected === true ? 'checked' : '';
  628. 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>';
  629. }
  630. }
  631. }
  632. html += '<div style="color: red;font-weight: bold">' + '* 提示:每个班级名称后的括号内为本班的本周生成次数。' + '</div>';
  633. $('#optionClass').html(html);
  634. }
  635. });
  636. }
  637. }
  638. });
  639. function deleteUnit(a) {
  640. var ids = $(a).parent().attr('node');
  641. var grade = parseInt($('.select-grade').val());
  642. var generate_class = ".unit"+ ids;
  643. $("span").remove(generate_class);
  644. //动态获取单元关联单词和短语数量
  645. $.ajax({
  646. url: "<?php echo $this->createUrl('magic/ajaxWordCount');?>",
  647. type: "POST",
  648. dataType: "json",
  649. data: {
  650. ids: ids,
  651. grade: grade
  652. },
  653. beforeSend:function(){
  654. layer.load(1, {
  655. shade: [0.1,'#fff'] //0.1透明度的白色背景
  656. });
  657. },
  658. success: function (data) {
  659. var index = layer.load();
  660. layer.close(index);
  661. var word_total = parseInt($('#word_total').text());
  662. var card_default = parseInt($('#card_default').text());
  663. var card_word_count_total = parseInt($('#card_word_count_total').text());
  664. word_total = word_total - data.data.wordCount;
  665. card_word_count_total = card_word_count_total - data.data.wordCount;
  666. if(card_word_count_total >= 30){
  667. card_default = 30;
  668. }else{
  669. card_default = card_word_count_total;
  670. }
  671. $('#word_total').text(word_total);
  672. $('#card_default').text(card_default);
  673. $('#card_word_count_total').text(card_word_count_total);
  674. }
  675. });
  676. $(a).parent().remove();
  677. }
  678. function limitUnit() {
  679. var grade = $('.select-grade').val();
  680. var selected_count = $("#selectedUnit").children("span").length;
  681. if(grade == 3 && selected_count == 3){
  682. return false;
  683. }
  684. if(grade!=3 && selected_count==1){
  685. return false;
  686. }
  687. return true;
  688. }
  689. function isPositiveInteger(s){//是否为正整数
  690. var reg = /^[1-9]\d*$/;
  691. return reg.test(s)
  692. }
  693. $('input:radio[name="practice_type"]').change(function(){
  694. var v = $(this).val();
  695. commonSet(v);
  696. });
  697. function commonSet(v){
  698. if (v ==1){
  699. $("#commonSet").show();
  700. }else{
  701. $("#commonSet").hide();
  702. }
  703. }
  704. function isHold() {
  705. var is_hold = $('#show-teacher-word').attr('is-hold');
  706. if(is_hold == 0){
  707. $('#show-teacher-word').attr('is-hold', 1);
  708. $('#allTeacherWord').addClass('word-group-hidden');
  709. $('#show-teacher-word').html('展开');
  710. }else {
  711. $('#show-teacher-word').attr('is-hold', 0);
  712. $('#allTeacherWord').removeClass('word-group-hidden');
  713. $('#show-teacher-word').html('收起');
  714. }
  715. }
  716. </script>