123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308 |
- <link rel="stylesheet" href="/fonts/fpdf/iconfont.css"/>
- <link rel="stylesheet" href="/css/alert.css"/>
- <?php $imgUrl = Yii::app()->request->hostInfo.'/images/disable.png';?>
- <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;
- margin-top:10px;
- 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: #619aff;
- }
- .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;
- }
- </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>
- <ul id="node-content">
- <li class="option-wrap">
- <span class="option-name"></span>
- <div class="option-con" id="optionEdition">
- <?php if(isset($topNode) && $topNode):?>
- <?php $no =1;?>
- <?php foreach($topNode as $k=>$v):?>
- <span parentid="<?php echo $v->parent_id;?>" pcid="<?php echo $v->pc_id;?>"><?php echo $v->pc_name;?></span>
- <?php $no++;?>
- <?php endforeach;?>
- <?php endif;?>
- </div>
- </li>
- </ul>
- <div class="option-wrap">
- <span class="option-name">班级:</span>
- <div class="option-con">
- <div>
- <select name="grade" class="select-grade">
- <option value="1" selected>高一</option>
- <option value="2">高二</option>
- <option value="3">高三</option>
- </select>
- </div>
- <div class="option-con-class" id="optionClass">
- </div>
- </div>
- </div>
- <div class="option-wrap">
- <span class="option-name">生成方式:</span>
- <div class="option-con">
- <span><input type="radio" name="is-answer-merge" value="0" checked="checked">题目答案分开生成</span>
- <span><input type="radio" name="is-answer-merge" value="1" >题目答案合并生成</span>
- </div>
- </div>
- <!--是否新版本:1-新版本-->
- <input type="hidden" value="1" class="is-new-version">
- <span class="btn-start" id="preview" >开始预览</span>
- <span class="btn-start" id="confirm" active="true" style="margin-left: 10px;">开始生成</span>
- </div>
- </div>
- <script src="/js/jquery.ajaxfileupload.js"></script>
- <script type="text/javascript">
- $(document).ready(function () {
- getClassByGrade(1);
- // 选择年级
- $(".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("#node-content li div span","click",function () {
- $(this).siblings().removeClass('active');
- $(this).addClass('active');
- $(this).parent().parent().nextAll().remove();
- $.ajax({
- url: "<?php echo $this->createUrl('htb/ajaxChildNode');?>",
- type: "GET",
- dataType: "json",
- data: {
- parentId: $(this).attr('pcid')
- },
- success: function (data) {
- if(data.status == 1 && data.data!= null) {
- var con = '<li class="option-wrap"> <span class="option-name"></span><div class="option-con" id="optionEdition">';
- $.each(data.data, function (index, item) {
- con += '<span pcid="' + item.pc_id + '" parentid="' + item.parent_id +'">' + item.pc_name + '</span>';
- });
- con += '</div></li>';
- $("#node-content").append(con);
- }}
- })
- });
- $('.select-grade').change(function(){
- var grade = $(this).val();
- getClassByGrade(grade);
- });
- $("body").delegate("#confirm[active='true']", "click", function() {
- var This = $(this);
- This.attr("active","false");
- var error = [];
- var selectClassIds = [];
- var grade = parseInt($('.select-grade').val());
- var isAnswerMerge = $("input[name='is-answer-merge']:checked").val();
- var isNewVersion=parseInt($('.is-new-version').val());
- var pcIds = [];
- $('#node-content li div span.active').each(function () {
- var data1 = {"pcId": $(this).attr('pcid'),"pcName":$(this).text(), "parentId":$(this).attr('parentid')};
- pcIds.push(data1);
- });
- $('#optionClass input:checked').each(function(k,v){
- if($(this).attr("status") == 0){
- selectClassIds.push($(this).val());
- }
- });
- if(pcIds.length == 0){
- error.push("请选择末节点~");
- }
- var noSelect = true;
- var lastNode = $('#node-content').children().last();
- lastNode.find('span').each(function (i) {
- if($(this).hasClass('active')){
- noSelect = false;
- }
- });
- if(noSelect){
- error.push("请选择末节点~");
- }
- if(selectClassIds.length == 0){
- error.push("请选择班级");
- }
- if(grade <= 0 || !grade){
- error.push("请选择年级");
- }
- if(error.length == 0){
- $.ajax({
- url: "<?php echo $this->createUrl('htb/ajaxSaveHtb');?>",
- type: "POST",
- dataType: "json",
- data: {
- grade: grade,
- selectClassIds:selectClassIds,
- pcIds:pcIds,
- isAnswerMerge:isAnswerMerge,
- isNewVersion:isNewVersion
- },
- success: function (data) {
- if(data.status == 1){
- layer.msg('已发送到后台,预计1小时左右生成!', {
- time: 2000,
- });
- setTimeout(function(){window.location.href = "<?php echo Yii::app()->createUrl('htb/index');?>";}, 2000);
- }else{
- layer.msg(data.error.join('</br>'));
- This.attr("active","true");
- }
- }
- });
- }else{
- This.attr("active","true");
- layer.msg(error[0]);
- }
- });
- //好题本预览
- $("body").delegate("#preview", "click", function() {
- var error = [];
- var pcIds = [];
- $('#node-content li div span.active').each(function () {
- var data1 = {"pcId": $(this).attr('pcid'),"pcName":$(this).text(), "parentId":$(this).attr('parentid')};
- pcIds.push(data1);
- });
- if(pcIds.length == 0){
- error.push("请选择末节点~");
- }
- var noSelect = true;
- var lastNode = $('#node-content').children().last();
- lastNode.find('span').each(function (i) {
- if($(this).hasClass('active')){
- noSelect = false;
- }
- });
- if(noSelect){
- error.push("请选择末节点~");
- }
- var ids = $.param({pcIds}, false);
- if(error.length == 0) {
- layer.open({
- title: '内容预览',
- type: 2,
- area: ['650px', '700px'],
- content: '<?php echo $this->createUrl('htb/newPreview');?>'+'?'+ids //这里content是一个URL,如果你不想让iframe出现滚动条,你还可以content: ['http://sentsin.com', 'no']
- });
- }else {
- layer.msg(error[0]);
- }
- });
- function getClassByGrade(grade){
- if(grade){
- $.ajax({
- url: "<?php echo $this->createUrl('htb/ajaxGetClasses');?>",
- type: "POST",
- dataType: "json",
- data: {
- grade: grade,
- },
- success: function (data) {
- var html = '';
- if(data && data.length > 0){
- for(var i in data){
- html +='<label>';
- if(data[i].status == 1){
- html += '<span title="该班级已达每周生成的最大次数"><img src="<?php echo $imgUrl;?>">'+data[i].class_name+'</span>';
- }else{
- html += '<input type="checkbox" name="option-class" value="'+data[i].class_id+'" status="0">'+data[i].class_name;
- }
- html +='</label>';
- }
- }
- $('#optionClass').html(html);
- }
- });
- }
- }
- });
- </script>
|