| | |
| | | |
| | | |
| | | <div class="panel admin-panel"> |
| | | <div class="panel-head"><strong><span class="icon-pencil-square-o"></span> {if $id>0}{编辑普通课程}{else}添加普通课程{/if}</strong></div> |
| | | {if $type == '5'} |
| | | <div class="panel-head"><strong><span class="icon-pencil-square-o"></span> {if $id>0}{编辑专题课程}{else}添加专题课程{/if}</strong></div> |
| | | {else} |
| | | <div class="panel-head"><strong><span class="icon-pencil-square-o"></span> {if $id>0}{编辑普通课程}{else}添加普通课程{/if}</strong></div> |
| | | {/if} |
| | | |
| | | <div class="body-content"> |
| | | <form method="post" id="lesson-form" class="form-x" enctype="multipart/form-data" onsubmit="return checkForm()"> |
| | | <div class="form-group"> |
| | |
| | | {loop $knowList $item} |
| | | <option value="{$item['id']}">{$item['name']}</option> |
| | | {/loop} |
| | | <option value="-1">+添加新专题</option> |
| | | </select> |
| | | <select name="know_cid" class="input category-input" id="know_child"> |
| | | <option value="">请选择知识点</option> |
| | | </select> |
| | | </div> |
| | | </div> |
| | | <div class="form-group" id="add_know_div" style="display: none;"> |
| | | <div class="label"></div> |
| | | <div class="field" id="knowdiv"> |
| | | </div> |
| | | </div> |
| | | {/if} |
| | |
| | | } |
| | | }); |
| | | }); |
| | | |
| | | <?php if($type=='5'){ ?> |
| | | $("#category_child").change(function(){ |
| | | var cid = $(this).children('option:selected').val(); |
| | | var ajaxurl = "{php echo $this->createMobileUrl('index', array('op'=>'edit','type'=>5));}"; |
| | | $.get(ajaxurl, {cid: cid }, function (data) { |
| | | if (data.length > 0) { |
| | | know = JSON.parse(data); |
| | | renderKnow(); |
| | | document.getElementById("know_parent").onchange(); |
| | | } |
| | | }); |
| | | }); |
| | | <?php } ?> |
| | | |
| | | function uploadImage(){ |
| | | $("#uploadDiv").show(); |
| | | $("#imgDiv").hide(); |
| | |
| | | return false; |
| | | } |
| | | |
| | | $("#category_child").change(function(){ |
| | | var cid = $(this).children('option:selected').val(); |
| | | var ajaxurl = "{php echo $this->createMobileUrl('index', array('op'=>'edit','type'=>5));}"; |
| | | $.get(ajaxurl, {cid: cid }, function (data) { |
| | | if (data.length > 0) { |
| | | know = JSON.parse(data); |
| | | renderKnow(); |
| | | document.getElementById("know_parent").onchange(); |
| | | } |
| | | }); |
| | | //添加专题&知识点 |
| | | function addKnowParent() { |
| | | if($("#add_know").length>0){ |
| | | $("#add_know").empty(); |
| | | } |
| | | if($("#add_know_parent").length>0){ |
| | | $("#add_know_parent").show(); |
| | | }else{ |
| | | var spec_html = ''; |
| | | $("#knowdiv").empty(); |
| | | spec_html += '<div id="add_know_parent" class="input-group w60">'; |
| | | spec_html += ' <span class="input-group-addon">专题名称</span>'; |
| | | spec_html += ' <input type="text" class="input" id="know_parent_name" name="know_parent_name">'; |
| | | spec_html += ' <span class="input-group-addon">知识点名称</span>'; |
| | | spec_html += ' <input type="text" class="input" id="know_name" name="know_name">'; |
| | | spec_html += '</div>'; |
| | | |
| | | $("#knowdiv").append(spec_html); |
| | | } |
| | | $("#know_child").hide(); |
| | | } |
| | | |
| | | //添加知识点 |
| | | function addKnow() { |
| | | if($("#add_know_parent").length>0){ |
| | | $("#add_know_parent").empty(); |
| | | } |
| | | if($("#add_know").length>0){ |
| | | $("#add_know").show(); |
| | | }else{ |
| | | var spec_html = ''; |
| | | $("#knowdiv").empty(); |
| | | spec_html += '<div id="add_know" class="input-group w60">'; |
| | | spec_html += ' <span class="input-group-addon">知识点名称</span>'; |
| | | spec_html += ' <input type="text" class="input" id="know_name" name="know_name">'; |
| | | spec_html += '</div>'; |
| | | |
| | | $("#knowdiv").append(spec_html); |
| | | } |
| | | $("#know_child").hide(); |
| | | } |
| | | |
| | | // 知识点下拉列表选择变化时 |
| | | $("#know_child").change(function(){ |
| | | var know_cid = $(this).children('option:selected').val(); |
| | | // -1时为:添加新知识点 |
| | | if(know_cid == -1){ |
| | | addKnow(); |
| | | $("#add_know_div").show(); |
| | | }else{ |
| | | $("#add_know_div").hide(); |
| | | } |
| | | }); |
| | | |
| | | //添加规格按钮 |
| | |
| | | var chtml = '<option value="0">请选择专题</option>'; |
| | | if(know.length==0){ |
| | | $("#know_parent").html(chtml); |
| | | return; |
| | | } |
| | | var know_pid = {php echo $lesson['knowledge_pid']?$lesson['knowledge_pid']:0}; |
| | | for(var i in know){ |
| | | if(know[i].id==know_pid){ |
| | | chtml += '<option value="' + know[i].id+'" selected>' + know[i].name + '</option>'; |
| | | }else{ |
| | | chtml += '<option value="' + know[i].id+'">' + know[i].name + '</option>'; |
| | | }else{ |
| | | var know_pid = {php echo $lesson['knowledge_pid']?$lesson['knowledge_pid']:0}; |
| | | for(var i in know){ |
| | | if(know[i].id==know_pid){ |
| | | chtml += '<option value="' + know[i].id+'" selected>' + know[i].name + '</option>'; |
| | | }else{ |
| | | chtml += '<option value="' + know[i].id+'">' + know[i].name + '</option>'; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | chtml += '<option value="-1">+添加新专题</option>'; |
| | | $("#know_parent").html(chtml); |
| | | } |
| | | |
| | | function renderKnowChild(id){ |
| | | var chtml = '<option value="0">请选择知识点</option>'; |
| | | if(id==0){ |
| | | // id=-1为选择添加新专题时,否则为具体的专题 |
| | | if(id == -1){ |
| | | addKnowParent(); |
| | | $("#know_child").hide(); |
| | | $("#add_know_div").show(); |
| | | }else{ |
| | | $("#know_child").show(); |
| | | $("#add_know_div").hide(); |
| | | var chtml = '<option value="0">请选择知识点</option>'; |
| | | if(id==0){ |
| | | $("#know_child").html(chtml); |
| | | }else{ |
| | | var cid = {php echo $lesson['knowledge_id']?$lesson['knowledge_id']:0}; |
| | | for(var i in know){ |
| | | if(know[i].id==id){ |
| | | var child = know[i].child; |
| | | for(var j in child){ |
| | | if(child[j].id==cid){ |
| | | chtml += '<option value="' + child[j].id+'" selected>' + child[j].name + '</option>'; |
| | | }else{ |
| | | chtml += '<option value="' + child[j].id+'">' + child[j].name + '</option>'; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | chtml += '<option value="-1">+添加知识点</option>'; |
| | | $("#know_child").html(chtml); |
| | | return; |
| | | } |
| | | var cid = {php echo $lesson['cid']?$lesson['cid']:0}; |
| | | for(var i in know){ |
| | | if(know[i].id==id){ |
| | | var child = know[i].child; |
| | | for(var j in child){ |
| | | if(child[j].id==cid){ |
| | | chtml += '<option value="' + child[j].id+'" selected>' + child[j].name + '</option>'; |
| | | }else{ |
| | | chtml += '<option value="' + child[j].id+'">' + child[j].name + '</option>'; |
| | | } |
| | | } |
| | | $("#know_child").html(chtml); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | function checkForm(){ |
| | |
| | | alert('请选择课程分类'); |
| | | return false; |
| | | } |
| | | <?php if($type=='5'){ ?> |
| | | if($("#know_parent option:selected").val()=='0' || $("#know_parent option:selected").val()==''){ |
| | | alert('请选择专题'); |
| | | $("#know_parent").focus(); |
| | | return false; |
| | | } |
| | | if($("#know_parent option:selected").val()!='-1' &&($("#know_child option:selected").val()=='0' || $("#know_child option:selected").val()=='')){ |
| | | alert('请选择知识点'); |
| | | $("#know_child").focus(); |
| | | return false; |
| | | } |
| | | if($("#know_parent option:selected").val()=='-1' && $("#know_parent_name").val()==''){ |
| | | alert('请输入要添加专题的名称'); |
| | | $("#know_parent_name").focus(); |
| | | return false; |
| | | } |
| | | if($("#know_parent option:selected").val()=='-1' && $("#know_name").val()==''){ |
| | | alert('请输入要添加知识点的名称'); |
| | | $("#know_name").focus(); |
| | | return false; |
| | | } |
| | | if($("#know_child option:selected").val()=='-1' && $("#know_name").val()==''){ |
| | | alert('请输入要添加知识点的名称'); |
| | | $("#know_name").focus(); |
| | | return false; |
| | | } |
| | | <?php } ?> |
| | | |
| | | if($("input[name=images]").val()==''){ |
| | | alert('请上传课程封面'); |
| | | return false; |