<?php 
if('add'===METHOD){
	$target[0]	=	'checked';
	$state[0]	=	'checked';
}else{
	$target[$edit[target]]	=	'checked';
	$state[$edit[state]]	=	'checked';
}
$this->display(tpl('head')); 
?>
<script src="/public/global/js/colpick.js" type="text/javascript" charset="utf-8"></script>

<fieldset class="layui-elem-field layui-field-title">
  	<legend>添加网站导航菜单</legend>
  	<div class="layui-row" style="margin: 10px">
		<a class="layui-btn layui-btn-sm  layui-btn-warm" href="/admin/homemenu/index/">菜单管理</a>
		<a class="layui-btn layui-btn-sm  layui-btn-danger" href="/admin/homemenu/add/">添加菜单</a>
	</div>
</fieldset>
<style>
	.layui-form-select{
		width: 30%;
	}
</style>
<form class="layui-form" id="from" method="post" action="">
	<table class="layui-table my-tabel" >
		<tbody id="tbody">
			<tr>
				<td>一级分类</td>
				<td>
					<select name="sup">
						<option value="">请选择一级分类</option>
						<?php foreach($rows AS $row){
							$selected='';
							if($edit){
								if($row[id]===$edit[sup]){
									$selected='selected';
								}
							}
						?>
							<option value="<?php echo $row[id] ?>" <?php echo $selected ;?>><?php echo $row[name] ?></option>
						<?php } ?>
					</select>
				</td>
			</tr>
			<tr>
				<td>菜单名称</td>
				<td>
					<input type="text" class="layui-input my-input" name="name" id="name" value="<?php echo $edit[name] ?>" />
				</td>
			</tr>
			<tr>
				<td>链接地址</td>
				<td>
					<input type="text" class="layui-input my-input" name="link" id="link" value="<?php echo $edit[link] ?>" />
				</td>
			</tr>
			<tr>
				<td>字体颜色</td>
				<td>
					<input type="text" class="layui-input my-input" name="color" id="color" value="<?php echo $edit[color] ?>" />
					<div id="picker"></div>
				    <script type="text/javascript">
				    	$("#color").css('background-color','<?php echo $edit[color] ?>');
				    	$("#color").css('color','#fff');
				    	$('#color').colpick({
								layout:'hex',
								submit:0,
								colorScheme:'dark',
							onChange:function(hsb,hex,rgb,el,bySetColor) {
								$(el).css('border-color','#'+hex);
								$(el).css('color','#FFF');
								$(el).css('background-color','#'+hex);
								if(!bySetColor) $(el).val('#'+hex);
							}
						}).keyup(function(){
							$(this).colpickSetColor(this.value);
						});
				    </script>
				</td>
			</tr>
			<tr>
				<td>打开方式</td>
				<td>
					<input type="radio" name="target" value="0" title="本窗口"	<?php echo $target[0] ?>/>
					<input type="radio" name="target" value="1" title="新窗口"	<?php echo $target[1] ?>/>
				</td>
			</tr>
			<tr>
				<td>是否停用</td>
				<td>
					<input type="radio" name="state" value="1" title="是"		<?php echo $state[1] ?>/>
					<input type="radio" name="state" value="0" title="否"		<?php echo $state[0] ?>/>
				</td>
			</tr>
			<tr>
				<td>同目录排序</td>
				<td>
					<input type="number" value="<?php echo $edit[reorder] ?>" class="layui-input my-input" name="reorder" id="reorder" placeholder="数值越高排序越往前" />
				</td>
			</tr>
			<tr>
				<td colspan="2" class="my_button">
					<input type="hidden" name="step" id="step" value="post" />
					<input type="hidden" name="id" id="id" value="<?php echo $edit[id] ?>" />
					<button class="layui-btn" lay-submit="" lay-filter="post">立即提交</button>
				</td>
			</tr>
		</tbody>
	</table>
</from>
<script>
	layui.use(['form','layer'], function(){
	})
</script>
<?php 
$this->display(tpl('foot')); 
?>
