123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944 |
- <link rel="stylesheet" href="/fonts/fpdf/iconfont.css"/>
- <link rel="stylesheet" href="/css/alert.css"/>
- <?php $imgUrl = Yii::app()->request->hostInfo;?>
- <style>
- .color-red{
- color: red;
- }
- .en-tfb-grade-1 .date>span{
- margin-right: 40px;
- }
- .option-wrap{
- margin-top: 20px;
- min-width: 600px;
- }
- .option-name{
- display: inline-block;
- width: 100px;
- vertical-align: top;
- margin-top: 10px;
- }
- .option-con{
- display: inline-block;
- width: 80%;
- min-width: 490px;
- padding: 10px;
- border: 1px solid #ccc;
- }
- .option-con>span{
- display: inline-block;
- margin-right: 20px;
- line-height: 1rem;
- cursor: pointer;
- }
- .select-grade{
- width: 150px;
- line-height: 30px;
- margin-bottom: 10px;
- }
- .option-con-class label{
- display: inline-block;
- margin-right: 20px;
- }
- .active{
- color: #2977ff;
- }
- .btn-start{
- display: inline-block;
- margin-top: 20px;
- margin-left: 100px;
- padding: 10px 30px;
- color: #fff;
- background-color: #2977ff;
- cursor: pointer;
- }
- .en-tfb-grade-1{
- margin-left: 20px;
- }
- .hgc_leader-btn {
- display: flex;
- justify-content: space-between;
- padding: 10px 0;
- font-size: 14px;
- }
- .hgc_leader-btn span {
- display: flex;
- align-items: center;
- cursor: pointer;
- }
- .hgc_leader-btn span .icon {
- width: 15px;
- height: 15px;
- 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;
- background-size: contain;
- }
- .hgc_leader-btn span:nth-child(2) .icon {
- 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;
- background-size: contain;
- }
- .hgc_leader-btn i {
- font-style: normal;
- }
- .hgc_option-con label {
- position: relative;
- padding: 5px;
- padding-right: 30px;
- border: 1px solid #999;
- }
- .hgc_option-con .icon {
- position: absolute;
- top: 50%;
- right: 5px;
- transform: translateY(-50%);
- width: 15px;
- height: 15px;
- 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;
- background-size: contain;
- cursor: pointer;
- }
- #selectedUnit{
- display: inline-block;
- width: 80%;
- min-width: 490px;
- padding: 10px;
- border: 1px solid #ccc;
- }
- #selectedUnit span{
- position: relative;
- padding: 5px;
- padding-right: 30px;
- border: 1px solid #999;
- margin-right: 15px;
- }
- .delete-icon{
- position: absolute;
- top: 50%;
- right: 5px;
- transform: translateY(-50%);
- width: 15px;
- height: 15px;
- background: url(<?php echo $imgUrl.'/images/icon-delect.png';?>) no-repeat center;
- background-size: contain;
- cursor: pointer;
- }
- .p-one-level{
- margin-left: 5%;
- }
- .p-two-level{
- margin-left: 8%;
- }
- .option-wrap-content{
- margin-left: 10%;
- }
- .option-wrap-content .option-con{
- border-color: #2977ff;
- width: auto;
- min-width: 250px;
- }
- </style>
- <div class="main-content-inner">
- <!-- 导航栏开始-->
- <?php include(Yii::app()->basePath.'/views/layouts/view_production_navigation.php');?>
- <!-- 导航栏结束-->
- <div class="en-tfb-grade-1">
- <h2>语法题自定义生成</h2>
- <p class="color-red">提示:只适用于高三年级,每个班级每周最多生成三份,请根据班级的实际复习内容生成</p>
- <p class="date">
- <span>当前时间:</span>
- <span><?php echo $year;?>年<?php echo $month;?>月第<?php echo $week;?>周</span>
- </p>
- <div class="option-wrap">
- <span class="option-name">班级:</span>
- <div class="option-con">
- <div class="option-con-class" id="optionClass">
- </div>
- </div>
- </div>
- <div class="option-wrap">
- <span class="option-name">版本:</span>
- <div class="option-con" id="optionEdition">
- <?php if(isset($textbookNames) && $textbookNames):?>
- <?php $no =1;?>
- <?php foreach($textbookNames as $k=>$v):?>
- <span code="<?php echo $k;?>" class="<?php echo $no==1?'active':'';?>"><?php echo $v;?></span>
- <?php $no++;?>
- <?php endforeach;?>
- <?php endif;?>
- </div>
- </div>
- <div class="option-wrap">
- <span class="option-name">模块:</span>
- <div class="option-con" id="optionModular">
- <?php if(isset($moduleNames) && $moduleNames):?>
- <?php $no =1;?>
- <?php foreach($moduleNames as $k=>$v):?>
- <span code="<?php echo $k;?>" class="<?php echo $no==1?'active':'';?>"><?php echo $v;?></span>
- <?php $no++;?>
- <?php endforeach;?>
- <?php endif;?>
- </div>
- </div>
- <div class="option-wrap">
- <span class="option-name">单元:</span>
- <div class="option-con" id="optionUnit">
- <?php if(isset($unitNames) && $unitNames):?>
- <?php $no =1;?>
- <?php foreach($unitNames as $k=>$v):?>
- <span code="<?php echo $k;?>" class="<?php echo $no==1?'active':'';?>"><?php echo $v;?></span>
- <?php $no++;?>
- <?php endforeach;?>
- <?php endif;?>
- </div>
- </div>
- <div class="option-wrap">
- <span class="option-name">已选单元:</span>
- <div id="selectedUnit">
- </div>
- </div>
- <div class="option-wrap">
- <span class="option-name">下载方式:</span>
- <div class="option-con">
- <span><input type="radio" name="is_answer_separate" value="1" checked="checked">分离题目和答案</span>
- <span><input type="radio" name="is_answer_separate" value="0">合并题目和答案</span>
- </div>
- </div>
- <div class="option-wrap" style="display: none">
- <span class="option-name">班级间内容:</span>
- <div class="option-con">
- <span><input type="radio" name="is_same_answer" value="1" checked="checked">答案相同</span>
- <span><input type="radio" name="is_same_answer" value="0" >答案不同</span>
- </div>
- </div>
- <div class="option-wrap">
- <span class="option-name">专题:</span>
- <div class="option-con" id="optionItem">
- <?php if(isset($special_arr) && $special_arr):?>
- <?php $no =1;?>
- <?php foreach($special_arr as $k=>$v):?>
- <span code="<?php echo $v['special_id'];?>" class="special-name <?php echo $no==1?'active':'';?>"><?php echo $v['special_name'];?></span>
- <?php $no++;?>
- <?php endforeach;?>
- <?php endif;?>
- </div>
- </div>
- <div class="option-wrap">
- <span class="option-name">专项:</span>
- <?php if(isset($special_arr) && $special_arr):?>
- <?php $no =1;?>
- <?php foreach($special_arr as $k=>$special):?>
- <div class="option-con" id="special_item_<?php echo $special['special_id'];?>" style="display: <?php echo $no == 1?'':'none';?>">
- <div class="hgc_leader-btn select-all">
- <span class="color-red" is_all="1"><i class="icon"></i>全选</span>
- <span class="color-red" is_all="0"><i class="icon"></i>全不选</span>
- </div>
- <div class="option-con-class" id="">
- <?php if($special['items']):?>
- <?php foreach($special['items'] as $item):?>
- <label>
- <input type="checkbox" name="option-class" value="<?php echo $item['item_id'];?>" item_name="<?php echo $item['item_name'];?>">
- <?php echo $item['item_name'];?>
- </label>
- <?php endforeach;?>
- <?php endif;?>
- </div>
- </div>
- <?php $no++;?>
- <?php endforeach;?>
- <?php endif;?>
- </div>
- <div class="option-wrap">
- <span class="option-name">已选择:</span>
- <div class="option-con">
- <div class="hgc_leader-btn">
- <span>已选<i class="color-red item-num">0</i>个选项</span>
- <span class="color-red clear-all-item"><i class="icon"></i>清空所有选项</span>
- </div>
- <div class="option-con-class hgc_option-con special-item-box">
- <!-- <label>一般现在时<i class="icon"></i></label>-->
- </div>
- </div>
- </div>
- <p style="margin-top:10px;background-color: #2977ff;color:white;height: 40px;line-height:40px;min-width: 600px;width: 85%;">
- <span style="float: left;margin-left: 20px;">内容自定义</span>
- <span style="float: right;margin-right: 20px;"> *产品设置未打开部分,设置将无效。</span></p>
- <p class="p-one-level">1. 词汇自测</p>
- <p class="p-two-level">1.1 核心单词/全单元词汇</p>
- <div class="option-wrap option-wrap-content">
- <span class="option-name">数量:</span>
- <div class="option-con">
- <span><input style="width: 50px;" name="words_count" type="text" value=30>(<i id="word_total">0</i>)个(1-100)</span>
- </div>
- </div>
- <div class="option-wrap option-wrap-content">
- <span class="option-name">范围:</span>
- <div class="option-con">
- <span><input type="radio" name="words_range" value=1 checked="checked">核心词汇</span>
- <span><input type="radio" name="words_range" value=2>全单元单词</span>
- </div>
- </div>
- <div class="option-wrap option-wrap-content">
- <span class="option-name">形式:</span>
- <div class="option-con">
- <span><input type="radio" name="words_type" value="1" checked="checked">汉译英</span>
- <span><input type="radio" name="words_type" value="2">英译汉</span>
- <span><input type="radio" name="words_type" value="3">中英互译</span>
- </div>
- </div>
- <div class="option-wrap option-wrap-content">
- <span class="option-name">派生:</span>
- <div class="option-con">
- <span><input type="radio" name="is_word_derive" value=1 checked="checked">有</span>
- <span><input type="radio" name="is_word_derive" value=0>无</span>
- </div>
- </div>
- <p class="p-two-level">1.2 词汇运用</p>
- <div class="option-wrap option-wrap-content">
- <span class="option-name">题数(0~20):</span>
- <div class="option-con">
- <span>单词拼写 <input style="width: 50px;" name="spell_count" type="text"> 题</span>
- <span>完成句子 <input style="width: 50px;" name="sentence_count" type="text"> 题</span>
- <span>单句语法填空 <input style="width: 50px;" name="blank_count" type="text"> 题</span>
- <span>单句翻译 <input style="width: 50px;" name="translate_count" type="text"> 题</span>
- </div>
- </div>
- <p class="p-two-level">1.3 重点短语</p>
- <div class="option-wrap option-wrap-content">
- <span class="option-name">数量:</span>
- <div class="option-con">
- <span><input style="width: 50px;" name="phrase_count" type="text" value=20>(<i id="phrase_total">0</i>)个</span>
- </div>
- </div>
- <div class="option-wrap option-wrap-content">
- <span class="option-name">形式:</span>
- <div class="option-con">
- <span><input type="radio" name="phrase_type" value="1" checked="checked">汉译英</span>
- <span><input type="radio" name="phrase_type" value="2">英译汉</span>
- </div>
- </div>
- <p class="p-one-level">2. 语法聚焦</p>
- <p class="p-two-level">2.1 单句语法填空</p>
- <div class="option-wrap option-wrap-content">
- <span class="option-name">题数:</span>
- <div class="option-con">
- <span><input style="width: 50px;" name="grammar_single_count" type="text"> 题(0-20)个</span>
- </div>
- </div>
- <p class="p-two-level">2.2 语法填空</p>
- <div class="option-wrap option-wrap-content">
- <span class="option-name">篇数:</span>
- <div class="option-con">
- <span><input style="width: 50px;" name="grammar_sheet_count" type="text"> 题(0-3)篇</span>
- </div>
- </div>
- <p class="p-one-level">3. 外刊泛读</p>
- <div class="option-wrap option-wrap-content">
- <span class="option-name">篇数:</span>
- <div class="option-con">
- <span><input style="width: 50px;" name="reading_count" type="text"> 题(0-3)篇</span>
- </div>
- </div>
- <button class="btn-start" id="confirm" active="true">开始生成</button>
- </div>
- </div>
- <script src="/js/jquery.ajaxfileupload.js"></script>
- <script type="text/javascript">
- $(document).ready(function () {
- getClassByGrade(3);
- //增加专项
- function addItem(id,name) {
- var ele = '<label item_id="'+id+'">'+name+'<i class="icon selected-item"></i></label>';
- $(".special-item-box").append(ele);
- }
- function itmeNume() {
- $(".item-num").text($(".special-item-box>label").length);
- }
- //切换专题
- $(".special-name").click(function () {
- $("#optionItem>span").removeClass('active')
- $(this).addClass('active');
- var specialId = $(this).attr('code');
- $('#special_item_'+specialId).show().siblings('.option-con').hide();
- });
- //选择专项
- $(".select-all>span").click(function () {
- var input_arr = $(this).parent().siblings('.option-con-class').children('label').children('input');
- //全选
- if ($(this).attr('is_all') > 0) {
- if (input_arr) {
- $.each(input_arr,function () {
- if (!$(this).is(':checked')) {
- $(this).prop("checked",true);
- addItem($(this).val(), $(this).attr('item_name'));
- }
- })
- }
- }else{//全不选
- if (input_arr) {
- $.each(input_arr,function () {
- if ($(this).is(':checked')) {
- $(this).prop("checked",false);
- var item_id = $(this).val();
- $('label[item_id="'+item_id+'"]').remove();
- }
- })
- }
- }
- itmeNume();
- });
- //选择单个专项
- $('input[name="option-class"]').change(function () {
- if (!$(this).is(':checked')) {
- var item_id = $(this).val();
- $('label[item_id="'+item_id+'"]').remove();
- }else{
- addItem($(this).val(), $(this).attr('item_name'));
- }
- itmeNume();
- });
- //清空所有选项
- $(".clear-all-item").click(function () {
- $.each($(".special-item-box>label"),function () {
- $('input[value="'+$(this).attr('item_id')+'"]').prop("checked",false);
- })
- $(".special-item-box").empty();
- itmeNume();
- });
- //清空单个选项
- $("body").delegate(".selected-item", "click", function() {
- $('input[value="'+$(this).parent('label').attr('item_id')+'"]').prop("checked",false);
- $(this).parent('label').remove();
- itmeNume();
- });
- var optionData={
- edition:0,
- modular:0,
- unit:0,
- class:[],
- }
- // 单选按钮
- $("input[name='option-class']").change(function() {
- getsClassSelected();
- });
- function getsClassSelected() {
- optionData.class=[];
- var selectedData = $("input[name='option-class']:checked"); //获取所以选中学生
- for (var i = 0; i < selectedData.length; i++) {
- code = $(selectedData[i]).val();
- optionData.class.push(code);
- }
- };
- //获取版本模块单元
- // 版本点击
- $("#optionEdition>span").on("click", function(event) {
- if(!limitUnit()){
- layer.msg('已选单元超出限制');return false;
- }
- $("#optionEdition>span").removeClass('active')
- $(this).addClass('active');
- var code = $(this).attr("code");
- optionData.edition=code;
- console.log('版本',code)
- });
- // 模块点击
- $("#optionModular>span").on("click", function(event) {
- if(!limitUnit()){
- layer.msg('已选单元超出限制');return false;
- }
- $("#optionModular>span").removeClass('active')
- $(this).addClass('active');
- var code = $(this).attr("code");
- optionData.modular=code;
- console.log('模块',code)
- });
- // 单元点击
- $("body").delegate("#optionUnit>span", "click", function() {
- if(!limitUnit()){
- layer.msg('已选单元超出限制');return false;
- }
- // $("#optionUnit>span").on("click", function(event) {
- $("#optionUnit>span").removeClass('active')
- $(this).addClass('active');
- var code = $(this).attr("code");
- optionData.unit=code;
- console.log('单元',code)
- });
- // 选择年级
- $(".select-grade").change(function() {
- console.log($(this).val())
- });
- // 单选按钮
- $("input[name='option-class']").change(function() {
- getsClassSelected();
- });
- function getsClassSelected() {
- optionData.class=[];
- var selectedData = $("input[name='option-class']:checked"); //获取所以选中学生
- for (var i = 0; i < selectedData.length; i++) {
- code = $(selectedData[i]).val();
- optionData.class.push(code);
- }
- };
- //
- $("body").delegate("#optionEdition span", "click", function() {
- if(!limitUnit()){
- layer.msg('已选单元超出限制');return false;
- }
- // $('#optionEdition span').on("click", function(event) {
- var textbookId = $(this).attr("code");
- if(textbookId){
- $.ajax({
- url: "<?php echo $this->createUrl('print/ajaxWeekGetModuleAndUnit');?>",
- type: "POST",
- dataType: "json",
- data: {
- textbookId: textbookId
- },
- success: function (data) {
- console.log(data);
- var htmlModule = '';
- var htmlUnit = '';
- if(data.moduleNames){
- var a = 1;
- for(var i in data.moduleNames){
- if(a == 1){
- htmlModule += '<span code="'+i+'" class="active">'+data.moduleNames[i]+'</span>';
- }else{
- htmlModule += '<span code="'+i+'">'+data.moduleNames[i]+'</span>';
- }
- a++;
- }
- }
- if(data.unitNames){
- var a = 1;
- for(var i in data.unitNames){
- if(a == 1){
- htmlUnit += '<span code="'+i+'" class="active">'+data.unitNames[i]+'</span>';
- }else{
- htmlUnit += '<span code="'+i+'">'+data.unitNames[i]+'</span>';
- }
- a++;
- }
- }
- $('#optionModular').html(htmlModule);
- $('#optionUnit').html(htmlUnit);
- }
- });
- }
- })
- $("body").delegate("#optionModular span", "click", function() {
- if(!limitUnit()){
- layer.msg('已选单元超出限制');return false;
- }
- $("#optionModular>span").removeClass('active')
- $(this).addClass('active');
- var code = $(this).attr("code");
- optionData.modular=code;
- // $('#optionModular span').on("click", function(event) {
- var moduleId = $(this).attr("code");
- var textbookId = $('#optionEdition span.active').attr("code");
- if(textbookId && moduleId){
- $.ajax({
- url: "<?php echo $this->createUrl('print/ajaxWeekGetUnitByModuleId');?>",
- type: "POST",
- dataType: "json",
- data: {
- textbookId: textbookId,
- moduleId:moduleId
- },
- success: function (data) {
- console.log(data);
- var htmlUnit = '';
- if(data.unitNames){
- var a = 1;
- for(var i in data.unitNames){
- if(a == 1){
- htmlUnit += '<span code="'+i+'" class="active">'+data.unitNames[i]+'</span>';
- }else{
- htmlUnit += '<span code="'+i+'">'+data.unitNames[i]+'</span>';
- }
- a++;
- }
- }
- $('#optionUnit').html(htmlUnit);
- }
- });
- }
- })
- $("body").delegate("#optionUnit span","click",function () {
- if(!limitUnit()){
- layer.msg('已选单元超出限制');return false;
- }
- var text_book_id = $("#optionEdition").children(".active").attr("code");
- var module_id = $("#optionModular").children(".active").attr("code");
- var unit_id = $(this).attr("code");
- var ids = text_book_id + '_' + module_id + '_' + unit_id;
- var selected_arr = [];
- if($('#selectedUnit span').length > 0){
- $('#selectedUnit span').each(function(index){
- selected_arr.push($(this).attr('node'));
- });
- }
- if($.inArray(ids, selected_arr) >= 0){
- layer.msg('不能重复添加该单元');return false;
- }
- //动态获取单元关联单词和短语数量
- $.ajax({
- url: "<?php echo $this->createUrl('englishWeek/ajaxWordPhraseCount');?>",
- type: "POST",
- dataType: "json",
- data: {
- ids: ids,
- grade:3
- },
- beforeSend:function(){
- layer.load(1, {
- shade: [0.1,'#fff'] //0.1透明度的白色背景
- });
- },
- success: function (data) {
- var index = layer.load();
- layer.close(index);
- var label = $("#optionClass > label");
- jQuery.each(label, function(){
- var class_id = $(this).children().val();
- count = 0;
- $.each(data.data.classCount, function(id,number) {
- if(id==class_id){
- count = number;
- }
- });
- $(this).children('.unit_generate_count').children('span').append('<span style="color: #07af66;margin-left:5px;margin-right: 5px" class="unit' + ids + '">' + count + '</span>');
- $('.unit_generate_count').show();
- });
- var word_total = parseInt($('#word_total').text());
- var phrase_total = parseInt($('#phrase_total').text());
- word_total = word_total + data.data.wordCount;
- phrase_total = phrase_total + data.data.phraseCount;
- $('#word_total').text(word_total);
- $('#phrase_total').text(phrase_total);
- }
- });
- var text_book_name = $("#optionEdition").children(".active").text();
- var module_name = $("#optionModular").children(".active").text();
- var unit_name = $(this).text();
- var names = text_book_name + '_' + module_name + '_' + unit_name;
- var _html = '<span node="' + ids + '">' + names + '<i class="delete-icon" onclick="deleteUnit(this)"></i></span>';
- $("#selectedUnit").append(_html);
- });
- $("#confirm[active='true']").on("click", function() {
- $('#confirm').attr('disabled','disabled');
- var This = $(this);
- This.attr("active","false");
- var error = [];
- var selectClassIds = [];
- var selectedItemIds = [];
- var unitIds = [];
- var names = [];
- var specialNames = [];
- $('#optionClass input:checked').each(function(k,v){
- if($(this).attr("status") == 0){
- selectClassIds.push($(this).val());
- }
- });
- $('#selectedUnit span').each(function(k,v){
- unitIds.push($(this).attr('node'));
- names.push($(this).text())
- });
- $('#optionClass input:checked').each(function(k,v){
- if($(this).attr("status") == 0){
- selectClassIds.push($(this).val());
- }
- });
- $(".special-item-box>label").each(function(k,v){
- if($(this).attr("item_id")){
- selectedItemIds.push($(this).attr("item_id"));
- specialNames.push($(this).text())
- }
- });
- if(selectClassIds.length == 0){
- error.push("请选择班级");
- }
- if(unitIds.length == 0){
- error.push("请选择单元")
- }
- if(selectedItemIds.length == 0){
- error.push("请选择专项");
- }
- //核心单词输入校验
- var word_count = $("input[name='words_count']").val();
- if(!isPositiveInteger(word_count)){
- error.push("单词数量请输入正整数")
- }
- word_count = parseInt(word_count);
- var word_total = parseInt($('#word_total').text());
- if(word_count > word_total || word_count>100){
- error.push("单词数量超出总数")
- }
- if(word_count <= 0){
- error.push("请检查单词数量")
- }
- //重点短语输入校验
- var phrase_count = $("input[name='phrase_count']").val();
- if(!isPositiveInteger(phrase_count)){
- error.push("重点短语数量请输入正整数")
- }
- phrase_count = parseInt(phrase_count);
- var phrase_total = parseInt($('#phrase_total').text());
- if(phrase_count > phrase_total || phrase_count>100){
- error.push("重点短语数量超出总数")
- }
- if(phrase_count <= 0){
- error.push("请检查短语数量")
- }
- var isAnswerSeparate = $("input[name='is_answer_separate']:checked").val();
- var isSameAnswer = $("input[name='is_same_answer']:checked").val();
- var wordsType = $("input[name='words_type']:checked").val();
- var phraseType = $("input[name='phrase_type']:checked").val();
- var isWordDerive = $("input[name='is_word_derive']:checked").val();
- var wordRange = $("input[name='words_range']:checked").val();
- var spellCount = parseInt($("input[name='spell_count']").val());
- var sentenceCount = parseInt($("input[name='sentence_count']").val());
- var blankCount = parseInt($("input[name='blank_count']").val());
- var translateCount = parseInt($("input[name='translate_count']").val());
- var grammarSingleCount = parseInt($("input[name='grammar_single_count']").val());
- var grammarSheetCount = parseInt($("input[name='grammar_sheet_count']").val());
- var readingCount = parseInt($("input[name='reading_count']").val());
- if(!isPositiveInteger(spellCount) || spellCount<0 ){
- error.push("请检查单词拼写数量")
- }
- if(!isPositiveInteger(sentenceCount) || sentenceCount<0){
- error.push("请检查完成句子数量")
- }
- if(!isPositiveInteger(blankCount) || blankCount<0){
- error.push("请检查单句语法填空数量")
- }
- if(!isPositiveInteger(translateCount) || translateCount<0){
- error.push("请检查单句翻译数量")
- }
- if((spellCount+sentenceCount+blankCount+translateCount)>20){
- error.push("词汇运用题数超出限制")
- }
- if(!isPositiveInteger(grammarSingleCount) || grammarSingleCount<0 || grammarSingleCount>20 || !isPositiveInteger(grammarSheetCount) || grammarSheetCount<0 || grammarSheetCount>3){
- error.push("请检查语法聚焦数量")
- }
- if(!isPositiveInteger(readingCount) || readingCount<0 || readingCount>3){
- error.push("请检查外刊泛读数量")
- }
- if(error.length == 0){
- $.ajax({
- url: "<?php echo $this->createUrl('print/ajaxSaveEnglishWeek');?>",
- type: "POST",
- dataType: "json",
- data: {
- grade:3,
- selectClassIds:selectClassIds,
- selectedItemIds:selectedItemIds,
- unitIds: unitIds,
- names: names,
- wordCount:word_count,
- phraseCount:phrase_count,
- isAnswerSeparate:isAnswerSeparate,
- wordsType:wordsType,
- phraseType:phraseType,
- isSameAnswer:isSameAnswer,
- wordRange:wordRange,
- spellCount:spellCount,
- sentenceCount:sentenceCount,
- isWordDerive:isWordDerive,
- blankCount:blankCount,
- translateCount:translateCount,
- grammarSingleCount:grammarSingleCount,
- grammarSheetCount:grammarSheetCount,
- readingCount:readingCount,
- specialNames:specialNames
- },
- success: function (data) {
- if(data.status == 1){
- layer.msg('已发送到后台,预计1小时左右生成!', {
- time: 2000,
- });
- setTimeout(function(){window.location.href = "<?php echo Yii::app()->createUrl('print/mrv');?>";}, 2000);
- }else{
- layer.msg(data.error.join('</br>'));
- This.attr("active","true");
- }
- }
- });
- }else{
- $('#confirm').removeAttr('disabled');
- This.attr("active","true");
- layer.msg(error.join('</br>'));
- }
- });
- function getClassByGrade(grade){
- if(grade){
- $.ajax({
- url: "<?php echo $this->createUrl('print/ajaxGetClassesBySettingWeek');?>",
- type: "POST",
- dataType: "json",
- data: {
- grade: grade,
- },
- beforeSend:function(){
- layer.load(1, {
- shade: [0.1,'#fff'] //0.1透明度的白色背景
- });
- },
- success: function (data) {
- var index = layer.load();
- layer.close(index);
- console.log(data);
- var html = '';
- if(data && data.length > 0){
- for(var i in data){
- html +='<label>';
- if(data[i].status == 1){
- html += ' <input type="checkbox" name="option-class" value="'+data[i].class_id+'" checked="checked" disabled="disabled" status="1">'+data[i].class_name;
- }else{
- html += ' <input type="checkbox" name="option-class" value="'+data[i].class_id+'" status="0">'+data[i].class_name;
- }
- html +='<span style="display: none;margin-left: 5px;" class="unit_generate_count">' + '(' + '<span></span>' + ')' + '</span></label>';
- }
- }
- html += '<div style="color: red;font-weight: bold">' + '* 选择单元后班级右边括号内数字为该单元历史生成次数' + '</div>';
- $('#optionClass').html(html);
- }
- });
- }
- }
- });
- function deleteUnit(a) {
- var ids = $(a).parent().attr('node');
- var generate_class = ".unit"+ ids;
- $("span").remove(generate_class);
- //动态获取单元关联单词和短语数量
- $.ajax({
- url: "<?php echo $this->createUrl('englishWeek/ajaxWordPhraseCount');?>",
- type: "POST",
- dataType: "json",
- data: {
- ids: ids,
- grade: 3
- },
- beforeSend:function(){
- layer.load(1, {
- shade: [0.1,'#fff'] //0.1透明度的白色背景
- });
- },
- success: function (data) {
- var index = layer.load();
- layer.close(index);
- var word_total = parseInt($('#word_total').text());
- var phrase_total = parseInt($('#phrase_total').text());
- word_total = word_total - data.data.wordCount;
- phrase_total = phrase_total - data.data.phraseCount;
- $('#word_total').text(word_total);
- $('#phrase_total').text(phrase_total);
- }
- });
- $(a).parent().remove();
- if($("#selectedUnit").children("span").length == 0){
- $('.unit_generate_count').hide();
- }
- }
- function limitUnit() {
- var grade = $('.select-grade').val();
- var selected_count = $("#selectedUnit").children("span").length;
- if(selected_count == 3){
- return false;
- }
- return true;
- }
- function isPositiveInteger(s){//是否为正整数
- var re = /^[0-9]+$/ ;
- return re.test(s)
- }
- </script>
|