@extends('vip.layouts')
@section('content')
<form class="layui-form" action="{{ url()->full() }}" id="submitForm" name="submitForm" method="post" eventType=eventAjaxForm>
{!! csrf_field() !!}
  <div class="layui-form-item">
    <label class="layui-form-label">菜单名称</label>
    <div class="layui-input-block">
      <input type="text" name="menu_name" required  lay-verify="required" placeholder="请输入菜单名称" autocomplete="off" value="{{ isset($name)?$name:'' }}" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">链接地址</label>
    <div class="layui-input-block">
    <input type="text" name="menu_url"   lay-verify="" placeholder="请输入链接地址" autocomplete="off" class="layui-input"  value="{{ isset($href)?$href:'' }}" >
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">ICON图标</label>
    <div class="layui-input-block">
    <input type="text" name="menu_icon"   lay-verify="" placeholder="请输入ICON图标" autocomplete="off" class="layui-input"  value="{{ isset($icon)?$icon:'' }}" >
    </div>
    <div class="layui-form-mid layui-word-aux">专用的图标代码</div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">上级菜单</label>
    <div class="layui-input-block">
      <select name="parent_id" >
        <option value="0">无上级</option>
        @if(isset($parents))
        @foreach($parents as $k=>$v)
          <option value="{{ $v['id'] }}"  @if(isset($parent_id)&&$parent_id==$v['id'])  selected @endif>
             @if(isset($lange[$v['name']]))  {{$lange[trim($v['name'])]}} @else {{$v['name']}}   @endif
          </option>
          
        @endforeach
        @endif
      </select>
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">排序</label>
    <div class="layui-input-inline">
    <input type="text" name="menu_sort"   lay-verify="" placeholder="请输入序号" autocomplete="off" class="layui-input" value="{{ isset($sort)?$sort:'' }}">
    </div>
    <div class="layui-form-mid layui-word-aux">序号</div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">类型</label>
    <div class="layui-input-block">
      @if(isset($type))
		<input type="radio" name="type" value="1" title="顶部菜单" @if($type=='1') checked @endif >
		<input type="radio" name="type" value="0" title="左侧菜单" @if($type=='0') checked @endif>
		<input type="radio" name="type" value="2" title="快捷菜单" @if($type=='2') checked @endif>
	  @else
		<input type="radio" name="type" value="1" title="顶部菜单" checked >
		<input type="radio" name="type" value="0" title="左侧菜单">
		<input type="radio" name="type" value="2" title="快捷菜单">
	  @endif
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label">打开方式</label>
    <div class="layui-input-block">
      @if(isset($target))
    <input type="radio" name="target" value="0" title="后台打开" @if($target=='0') checked @endif>
    <input type="radio" name="target" value="1" title="跳转新页面" @if($target=='1') checked @endif >
    <input type="radio" name="target" value="2" title="本页面打开" @if($target=='2') checked @endif>
    <input type="radio" name="target" value="3" title="本页打开" @if($target=='3') checked @endif>
    @else
    <input type="radio" name="target" value="0" title="后台打开">
    <input type="radio" name="target" value="1" title="新窗口打开">
    <input type="radio" name="target" value="2" title="本页跳转">
    <input type="radio" name="target" value="3" title="本页打开" checked>
    @endif
    </div>
  </div>

@if(S('ACTION')!='view')
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit lay-filter="submitForm">立即提交</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>
@endif
</form>

<script>
//Demo
layui.use(['form'], function(){
  var form = layui.form;

  //监听提交
  form.on('submit(submitForm)', function(data){
    return true;
  });
});
function cbFormSuccess(data){
	layer.msg(data.msg);
	setTimeout(function(){
		parent.window.location.reload();
	},2500);
}
</script>
@endsection
