<?php $this->display(tpl('head',true)); ?>

<style>
	.layui-tab{
		padding-left: 20px;
	}
	.layui-field-box{
		color: red;
	}
</style>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
  <legend>添加栏目</legend>
</fieldset>
<form class="layui-form" method="post">
	<table class="layui-table my-tabel">
		<tr>
			<td>栏目名称</td>
			<td><textarea name="post[name]" placeholder="请输入栏目名称" class="layui-textarea" ></textarea>
    			<p>要想一次批量创建多个分类或栏目,每个名称换一行</p>
			</td>
		</tr>
		<tr>
			<td>栏目类型</td>
			<td>
				<input name="post[type]" value="0" title="栏目" checked type="radio">
    			<input name="post[type]" value="1" title="分类" type="radio">
    			<input name="post[type]" value="2" title="单页" type="radio">
    			<p>分类可以无限级，栏目下面不可以继续添加任何分类或者栏目</p>
			</td>
		</tr>
		<tr>
			<td>所属分类</td>
			<td>
				<select name="post[cid]" lay-filter="ciddb"  onchange="changeForm(this.value)" >
    				<option value="">顶级分类</option>
					<?php 
						foreach($allcidDB AS $row){
							$selected="";
							if($row[cid]==$cid){
								$selected=" selected";
							}
							$disabled="";
							if($row[type] != '1'){
								$disabled="disabled";
							}
					?>
					<option value="<?php echo $row[cid]?>" type="<?php echo $row[type]?>" <?php echo $selected ; echo $disabled;?> ><?php echo $row[levels] ;echo $row[name]; ?></option>
					<?php } ?>
    			</select>
			</td>
		</tr>
		<tr>
			<td>所属内容模型</td>
			<td>
				<select name="post[mid]">
    				<option value="">不使用模型</option>
					<?php
						foreach($moduleDB AS $row){
					?>
              		<option value="<?php echo $row['id'] ?>"><?php echo $row['name'] ?></option>
					<?php }　?>
    			</select>
			</td>
		</tr>
		<tr>
			<td colspan="2" class="my_button">
				<input type="hidden" name="step" value="post" />
				<button class="layui-btn">立即提交</button>
			</td>
		</tr>
	</table>
</form>
<script>
layui.config({
	version: 'NOWTIME' //为了更新 js 缓存，可忽略
});
layui.use(['form','layer'], function(){
  	var $ = layui.jquery
  	,element = layui.element; //Tab的切换功能，切换事件监听等，需要依赖element模块

   	var $ = layui.jquery, layer = layui.layer; //独立版的layer无需执行这一句
	var form = layui.form;
	form.on('select(ciddb)', function(data){
		if(data.type !=1){
			$('.layui-btn').attr("disabled",true); 
			alert("只有分类才可以添加下级");
			return false;
		}else{
			$('.layui-btn').attr("disabled",false); 
		}	
	}); 
});
	  
</script>
<?php $this->display(tpl('foot',true)); ?>   
