<title>导航设置</title>
  
<div class="layui-card layadmin-header">
  <div class="layui-breadcrumb" lay-filter="breadcrumb">
    <a lay-href="">主页</a>
    <a><cite>问答管理</cite></a>
    <a><cite>基本设置</cite></a>
    <a><cite>导航设置</cite></a>
  </div>
</div>

  <div class="layui-fluid">
        <div class="layui-card">
          <div class="layui-card-body">
            <div class="layui-tab layui-tab-brief" lay-filter="J_tabLi">
              <ul class="layui-tab-title">
                <li class="layui-this" lay-id="main">站点导航</li>
                <li lay-id="my">我的菜单</li>
              </ul>
            </div>
          </div>


          <div class="layui-card-body">
      <div style="padding-bottom: 10px;">
        <a href="#J_view" class="layui-btn J_popup" title="添加导航"><i class="layui-icon layui-icon-add-circle"></i>添加</a>
        <a href="wendasns/navig/remove" class="layui-btn J_req" title="确定要删除吗？"><i class="layui-icon layui-icon-delete"></i>删除</a>
      </div>
      
            <table id="J_table_list" lay-filter="J_table_list" url="{:url('wendasns/navig/edit')}"></table>
          </div>
          
      </div>
    </div>

<script type="text/html" id="J_table_tool">
  <a href="#J_view" class="layui-btn layui-btn-normal layui-btn-xs" lay-event="popup" title="编辑导航"><i class="layui-icon layui-icon-edit"></i>编辑</a>
  <a href="wendasns/navig/remove" class="layui-btn layui-btn-danger layui-btn-xs" lay-event="req" title="确定要删除吗？"><i class="layui-icon layui-icon-delete"></i>删除</a>
</script>

<script type="text/html" id="J_checkbox_tpl">
  <input type="checkbox" name="status" lay-skin="switch" lay-text="开启|关闭" lay-filter="J_checkbox_enable" value="{{ d.id }}" {{ d.status == 1 ? 'checked' : '' }}>
</script>

<script>
var layid = 'main';
;!function(){
    var $ = layui.$
    ,table = layui.table
    ,element = layui.element
    ,router = layui.router();
  
  /* Hash地址的定位 */
  layid = router.hash.replace(/^#layid=/, '');
  layid && element.tabChange('J_tabLi', layid);
  
  element.on('tab(J_tabLi)', function(elem){
    location.hash = '/'+ router.path.join('/') + '#layid=' + $(this).attr('lay-id');
  });
  
  //执行渲染
table.render({
  elem: '#J_table_list'
  ,url: '{:url('wendasns/navig/list')}?type='+layid
  ,skin: 'line'
  ,cols: [[
      {type: 'checkbox'}
      ,{field:'id',title:'ID',width:80,align:'center'}
      ,{field:'parent',title:'上级导航',width:150}
      ,{field:'name',title:'导航名称',width:150}
      ,{field:'url',title:'链接地址',minWidth:220}
      ,{field:'icon',title:'图标',align:'center',width:60,templet:'<div><i class="layui-icon {{d.icon}}" style="font-size: 22px;"></i></div>'}
      ,{field:'enable',title:'是否启用',width:110,align:'center', templet: '#J_checkbox_tpl', unresize:true}
      ,{field:'sort',title:'排序',width:80,align:'center'}
      ,{title:'操作',width:150,align:'center',toolbar:'#J_table_tool'}
  ]]
  ,height: 'auto'
  ,text: {
    none: '暂无数据'
  }
});


}();
</script>

<script type="text/html" id="J_view">
<form class="layui-form" style="padding: 20px 0 0 0;" action="{:url('wendasns/navig/post')}" method="post">
  <input type="hidden" name="id" value="{{ d.id || 0 }}">
  <input type="hidden" name="type" value="{{ d.type || layid }}">
  
  {{# if(layid=='main'){ }}
  <div class="layui-form-item">
          <div class="layui-inline">
            <label class="layui-form-label">上级导航</label>
            <div class="layui-input-inline">
              <select name="parentid">
                <option value="0">顶级导航</option>
                {volist name="data" id="item"}
                <option value="{$item.id}" {{ d.parentid == {$item.id} ? 'selected="selected"' : '' }}>{$item.name}</option>
                {/volist}
              </select>
            </div>
          </div>
        </div>
  {{# } }}
  <div class="layui-form-item">
    <label class="layui-form-label">导航名称</label>
    <div class="layui-input-inline">
        <input type="text" name="name" value="{{ d.name || '' }}" placeholder="导航名称" class="layui-input">
    </div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">链接地址</label>
    <div class="layui-input-inline">
        <input type="text" name="url" value="{{ d.url || '' }}" class="layui-input">
    </div>
  </div>

  <div class="layui-form-item">
    <label class="layui-form-label"><i class="layui-icon {{ d.icon || '' }}"></i> 图标</label>
    <div class="layui-input-inline">
        <input type="text" name="icon" value="{{ d.icon || '' }}" placeholder="图标样式名" class="layui-input">
    </div>
    <div class="layui-form-mid layui-word-aux"><a href="https://www.layui.com/doc/element/icon.html" target="_blank">图标列表</a></div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">顺序</label>
    <div class="layui-input-inline">
        <input type="text" name="sort" value="{{ d.sort || 0 }}" lay-verify="number" class="layui-input">
    </div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">启用</label>
    <div class="layui-input-block">
        <input type="radio" name="status" value="1" title="是" {{ d.status === 1 ? 'checked="checked"' : '' }}>
        <input type="radio" name="status" value="0" title="否" {{ d.status === 0 ? 'checked="checked"' : '' }}>
    </div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label"></label>
    <div class="layui-input-inline">
      <button lay-submit lay-filter="J_ajax_submit_btn" class="layui-btn"><i class="layui-icon layui-icon-ok-circle"></i>提交</button>
    </div>
  </div>
</form>
</script>