<!--{include file="<!--{$oetplpath}-->block_head.tpl"}-->

<!--{if $a == "run"}-->
<div class="layui-fluid oe_fluid">

  <form class="layui-form" id="mysearch" action="<!--{$oefile}-->&c=<!--{$c}-->" method="post">
  <div class="oe_breadcrumb_box clearfix">
    <div class="layui-breadcrumb fl" lay-filter="breadcrumb" style="visibility: visible;">
      <a href="javascript:;">内容管理</a><span lay-separator="">/</span>
      <a href="javascript:;">文章管理</a><span lay-separator="">/</span>
      <a><cite>文章分类</cite></a>
    </div>
    <div class="oe_tool_bar ft" style="display:none;">
      <button class="layui-btn layui-btn-sm search" id="but_submit_search" lay-submit lay-filter="searchform2">
        <i class="layui-icon layui-icon-search"></i>
        搜索
        <span class="oe_btn_loading layui-anim layui-icon layui-anim-rotate layui-anim-loop" style="display:none;">&#xe63d;</span>
      </button>
    </div>
  </div>
  <!--//Top End -->
  
  <div class="oe_searchbar layui-form">
    <div class="more_search_open"></div>
    <div class="layui-form-item">
      <b>温馨提示：</b>
      分类支持无限级，删除分类时必须从子分类开始删除，当含有子分类时不能删除。
    </div>
  </div>
  <!--//search End -->
  </form>

  <div class="oe_table_wrap layui-form">
    <div class="oe_tbl_tool clearfix">
      <div class="oe_gnbar clearfix">
        <div class="add btn fl" style="border-right:none;">
          <i class="layui-icon layui-icon-add-1"></i>
          <span><a href="<!--{$oefile}-->&c=<!--{$c}-->&a=add">添加一级分类</a></span>
        </div>
      </div>
    </div>
    
    <form class="layui-form" id="myform" action="<!--{$oefile}-->&c=<!--{$c}-->" method="post">
    <input type="hidden" name="a" id="a" value="del" />
    <table class="layui-table">
      <thead>
        <tr>
          <th width="8%">#ID</th>
          <th width="25%">名称</th>
          <th width="10%">子名称</th>
          <th width="8%">图标</th>
          <th>描述</th>
          <th width="8%">排序</th>
          <th width="8%">推荐</th>
          <th width="20%">操作</th>
        </tr> 
      </thead>
      
      <!--{if empty($category)}-->
      <tr>
        <td colspan="8" class="text_center">没有符合条件的信息</td>
      </tr>
      <!--{else}-->
      <!--{foreach $category as $volist}-->
      <tr>
        <td class="check">
          <!--{$volist.catid}-->
        </td>
        <td>
          <!--{if $volist.depth==0}-->
            <b><!--{$volist.tree_node}--></b>
          <!--{else}-->
            <!--{if $volist.depth=='1'}-->
            <font color="green"><!--{$volist.tree_node}--></font>
            <!--{elseif $volist.depth=='2'}-->
            <font color="blue"><!--{$volist.tree_node}--></font>
            <!--{elseif $volist.depth=='3'}-->
            <font color="orange"><!--{$volist.tree_node}--></font>
            <!--{else}-->
            <!--{$volist.tree_node}-->
            <!--{/if}-->
          <!--{/if}-->
          &nbsp;&nbsp;
        </td>
        <td>
          <!--{if !empty($volist.subname)}-->
          <!--{$volist.subname}-->
          <!--{else}-->
          --
          <!--{/if}-->
        </td>
        <td class="text_center">
          <!--{if !empty($volist.catimg)}-->
          <img src="<!--{$volist.catimg}-->" width="20px" height="20px" f="viewimg" />
          <!--{else}-->
          --
          <!--{/if}-->
        </td>
        <td>
          <!--{if !empty($volist.intro)}-->
          <!--{$volist.intro}-->
          <!--{else}-->
          --
          <!--{/if}-->
        </td>
        <td class="text_center"><!--{$volist.orders}--></td>
        <td class="text_center">
          <input type="checkbox" name="elite" lay-skin="primary" value="1" lay-filter="updatestatus" data-id="<!--{$volist.catid}-->" data-type="elite"<!--{if $volist.elite == '1'}--> checked<!--{/if}--> />
        </td>
        <td class="text_center">
          <div class="btn_box">
            <a href="<!--{$oefile}-->&c=<!--{$c}-->&a=add&sparentid=<!--{$volist.catid}-->" class="layui-btn layui-btn-xs">添加子分类</a>
            <a href="<!--{$oefile}-->&c=<!--{$c}-->&a=edit&id=<!--{$volist.catid}-->&<!--{$comeurl}-->" class="layui-btn layui-btn-xs layui-btn-normal">编辑</a>
            <a href="javascript:;" f="handle-one" data-url="<!--{$oefile}-->&c=<!--{$c}-->&a=del&id=<!--{$volist.catid}-->&<!--{$comeurl}-->" class="layui-btn layui-btn-xs layui-btn-danger">删除</a>
          </div>
        </td>
      </tr>
      <!--{/foreach}-->
      <!--{/if}-->
    </table>
    </form>
    <div class="oe_page_box"><!--{$showpage}--></div>

  </div>
</div>
<!--{/if}-->

<!--{if $a == "add"}-->
<div class="layui-fluid oe_fluid">

  <div class="oe_breadcrumb_box clearfix">
    <div class="layui-breadcrumb fl" lay-filter="breadcrumb" style="visibility: visible;">
      <a href="javascript:;">内容模块</a><span lay-separator="">/</span>
      <a href="javascript:;">攻略管理</a><span lay-separator="">/</span>
      <a><cite>文章分类</cite></a>
    </div>
    <div class="oe_tool_bar ft">
      <button class="layui-btn layui-btn-sm layui-btn-radius" id="but_submit_post2" lay-submit lay-filter="addform">
        添加保存
        <span class="oe_btn_loading layui-anim layui-icon layui-anim-rotate layui-anim-loop" style="display:none;">&#xe63d;</span>
      </button>
      <span class="layui-btn layui-btn-sm layui-btn-primary layui-btn-radius"><a href="<!--{$oefile}-->&c=<!--{$c}-->&<!--{$comeurl}-->">返回列表</a></span>
    </div> 
  </div>
  
  <form class="layui-form" id="myform" action="<!--{$oefile}-->&c=<!--{$c}-->&<!--{$comeurl}-->" method="post">
  <input type="hidden" name="a" id="a" value="saveadd" />
  <div class="layui-card">
    <div class="layui-card-header">添加分类</div>
    <div class="layui-card-body">
      <table class="oe_tbl_form layui-form">
        <tr>
          <th width="15%">上级分类：</th>
          <td width="35%">
            <div class="input-200">
            <!--{hook mod='articlecat' type='select' name='parentid' text='=不从属任何分类=' value=$sparentid}-->
            </div>
          </td>
          <th width="15%"><font color="red">*</font> 分类名称：</th>
          <td width="35%"><input type="text" name="catname" id="catname" class="layui-input input-200" /></td>
        </tr>

        <tr>
          <th>排&#12288;&#12288;序：</th>
          <td><input type="text" name="orders" id="orders" class="layui-input input-200" value="<!--{$orders}-->" /></td>
          <th>&nbsp;子&nbsp;名&nbsp;称：</th>
          <td><input type="text" name="subname" id="subname" class="layui-input input-200" /></td>
        </tr>
        <tr>
          <th>图&#12288;&#12288;标：<span class="f_red"></span></th>
          <td>
            <div class="layui-btn">
              <i class="layui-icon layui-icon-upload"></i>
              点击上传
              <input type="file" name="img" id="img" f="but_upload_image" />
            </div>
            <div class="upload_loading" id="img_loading" style="display:none;"></div>
            <input type="hidden" id="img_thumb" name="img_thumb" value="" />
            <input type="hidden" id="img_url" name="catimg" value="" />
        
            <div class="tblform_tips normal">&nbsp;&nbsp;&nbsp;预览：</div>
            <div class="upload_pic upload_pic_md" style="width:30px;height:30px;">
              <img src="<!--{$urlpath}-->tpl/static/images/nopic.jpg" id="img_preview" f="viewimg" />
            </div>
            <a href="javascript:;" class="oe_deluploadimg" f="removeimg" data-preview="img" data-input="img">移除</a>
          </td>
          <th>是否推荐：</th>
          <td>
            <input type="radio" name="elite" title="是" value="1" />
            <input type="radio" name="elite" title="否" value="0" checked />
          </td>
        </tr>
        
        <tr>
          <th>分类简介：</th>
          <td colspan="3">
            <textarea name="intro" id="intro" class="layui-textarea" style="width:50%;height:60px;"></textarea>
          </td>
        </tr>
        <tr>
          <th>meta标题：</th>
          <td colspan="3">
            <textarea name="metatitle" id="metatitle" class="layui-textarea" style="width:50%;height:40px;"></textarea>
          </td>
        </tr>
        <tr>
          <th>meta描述：</th>
          <td colspan="3">
            <textarea name="metadesc" id="metadesc" class="layui-textarea" style="width:50%;height:60px;"></textarea>
          </td>
        </tr>
        <tr>
          <th>meta关键词：</th>
          <td colspan="3">
            <textarea name="metakeyword" id="metakeyword" class="layui-textarea" style="width:50%;height:60px;"></textarea>
            <font color="gray">（多个关键词请使用英文逗号“,”隔开）</font>
          </td>
        </tr>
        <tr>
          <th>指定模板：<span class="f_red"></span> </th>
          <td colspan="3">
            <table class="oe_tbl_form layui-form">
              <tr>
                <td width="15%">文章列表页：</td>
                <td width="85%">
                  tpl/templets/<!--{$config.templet}-->/&nbsp;
                  <input type="text" name="listtpl" id="listtpl" class="layui-input input-200" />.tpl
                </td>
              </tr>
              <tr>
                <td>文章内容页：</td>
                <td>
                  tpl/templets/<!--{$config.templet}-->/&nbsp;
                  <input type="text" name="detailtpl" id="detailtpl" class="layui-input input-200" />.tpl
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
    </div>
  </div>
  </form>
  
  <div class="oe_kong"></div>
  <div class="oe_tbl_form_btn current">
    <button class="layui-btn" id="but_submit_post" lay-submit lay-filter="addform">
      添加保存
      <span class="oe_btn_loading layui-anim layui-icon layui-anim-rotate layui-anim-loop" style="display:none;">&#xe63d;</span>
    </button>
  </div>
  
</div>

<script type="text/javascript">
$(function(){

    layui.use('form', function(){
        $form = layui.form;
        //保存...
        $form.on('submit(addform)', function(data){
            $obj_id = data.elem.getAttribute("id");
            if (!$("#"+$obj_id).hasClass("forbid_submit")) {
            
                if ($("#catname").val().length  == 0) {
                    layer.msg("请填写分类名称");
                    return false;
                }
                
                $("#"+$obj_id).addClass("forbid_submit");
                if ($("#"+$obj_id).find("span").length > 0) {
                    $("#"+$obj_id).find("span").show();
                }
                //...
                $("#myform").submit();
            }
        });   
    });
    
});
</script>
<!--{/if}-->

<!--{if $a == "edit"}-->
<div class="layui-fluid oe_fluid">

  <div class="oe_breadcrumb_box clearfix">
    <div class="layui-breadcrumb fl" lay-filter="breadcrumb" style="visibility: visible;">
      <a href="javascript:;">内容模块</a><span lay-separator="">/</span>
      <a href="javascript:;">攻略管理</a><span lay-separator="">/</span>
      <a><cite>文章分类</cite></a>
    </div>
    <div class="oe_tool_bar ft">
      <button class="layui-btn layui-btn-sm layui-btn-radius" id="but_submit_post2" lay-submit lay-filter="editform">
        编辑保存
        <span class="oe_btn_loading layui-anim layui-icon layui-anim-rotate layui-anim-loop" style="display:none;">&#xe63d;</span>
      </button>
      <span class="layui-btn layui-btn-sm layui-btn-primary layui-btn-radius"><a href="<!--{$oefile}-->&c=<!--{$c}-->&<!--{$comeurl}-->">返回列表</a></span>
    </div> 
  </div>
  
  <form class="layui-form" id="myform" action="<!--{$oefile}-->&c=<!--{$c}-->&<!--{$comeurl}-->" method="post">
  <input type="hidden" name="a" id="a" value="saveedit" />
	<input type="hidden" name="id" id="id" value="<!--{$id}-->" />
  <div class="layui-card">
    <div class="layui-card-header">编辑分类</div>
    <div class="layui-card-body">
      <table class="oe_tbl_form layui-form">
        <tr>
          <th width="15%">上级分类：</th>
          <td width="35%">
            <div class="input-200">
            <!--{hook mod='articlecat' type='select' name='parentid' text='=不从属任何分类=' value=$category.parentid}-->
            </div>
          </td>
          <th width="15%"><font color="red">*</font> 分类名称：</th>
          <td width="35%">
            <input type="text" name="catname" id="catname" class="layui-input input-200" value="<!--{$category.catname}-->" />
          </td>
        </tr>

        <tr>
          <th>排&#12288;&#12288;序：</th>
          <td><input type="text" name="orders" id="orders" class="layui-input input-200" value="<!--{$category.orders}-->" /></td>
          <th>&nbsp;子&nbsp;名&nbsp;称：</th>
          <td><input type="text" name="subname" id="subname" class="layui-input input-200" value="<!--{$category.subname}-->" /></td>
        </tr>
        <tr>
          <th>图&#12288;&#12288;标：<span class="f_red"></span></th>
          <td>
            <div class="layui-btn">
              <i class="layui-icon layui-icon-upload"></i>
              点击上传
              <input type="file" name="img" id="img" f="but_upload_image" />
            </div>
            <div class="upload_loading" id="img_loading" style="display:none;"></div>
            <input type="hidden" id="img_thumb" name="img_thumb" value="" />
            <input type="hidden" id="img_url" name="catimg" value="<!--{$category.catimg}-->" />
        
            <div class="tblform_tips normal">&nbsp;&nbsp;&nbsp;预览：</div>
            <div class="upload_pic upload_pic_md" style="width:30px;height:30px;">
              <img src="<!--{$urlpath}--><!--{if !empty($aboutcat.catimg)}--><!--{$aboutcat.catimg}--><!--{else}-->tpl/static/images/nopic.jpg<!--{/if}-->" id="img_preview" f="viewimg" />
            </div>
            <a href="javascript:;" class="oe_deluploadimg" f="removeimg" data-preview="img" data-input="img">移除</a>
          </td>
          <th>是否推荐：</th>
          <td>
            <input type="radio" name="elite" title="是" value="1" />
            <input type="radio" name="elite" title="否" value="0" checked />
          </td>
        </tr>
        
        <tr>
          <th>分类简介：</th>
          <td colspan="3">
            <textarea name="intro" id="intro" class="layui-textarea" style="width:50%;height:80px;"><!--{$category.intro}--></textarea>
          </td>
        </tr>
        <tr>
          <th>指定模板：<span class="f_red"></span> </th>
          <td colspan="3">
            <table class="oe_tbl_form layui-form">
              <tr>
                <td width="15%">文章列表页：</td>
                <td width="85%">
                  tpl/templets/<!--{$config.templet}-->/&nbsp;
                  <input type="text" name="listtpl" id="listtpl" class="layui-input input-200" value="<!--{$category.listtpl}-->" />.tpl
                </td>
              </tr>
              <tr>
                <td>文章内容页：</td>
                <td>
                  tpl/templets/<!--{$config.templet}-->/&nbsp;
                  <input type="text" name="detailtpl" id="detailtpl" class="layui-input input-200" value="<!--{$category.detailtpl}-->" />.tpl
                </td>
              </tr>
            </table>
          </td>
        </tr>
        <tr>
          <th>meta标题：</th>
          <td colspan="3">
            <textarea name="metatitle" id="metatitle" class="layui-textarea" style="width:50%;height:40px;"><!--{$category.metatitle}--></textarea>
          </td>
        </tr>
        <tr>
          <th>meta描述：</th>
          <td colspan="3">
            <textarea name="metadesc" id="metadesc" class="layui-textarea" style="width:50%;height:60px;"><!--{$category.metadesc}--></textarea>
          </td>
        </tr>
        <tr>
          <th>meta关键词：</th>
          <td colspan="3">
            <textarea name="metakeyword" id="metakeyword" class="layui-textarea" style="width:50%;height:60px;"><!--{$category.metakeyword}--></textarea>
            <font color="gray">（多个关键词请使用英文逗号“,”隔开）</font>
          </td>
        </tr>
      </table>
    </div>
  </div>
  </form>
  
  <div class="oe_kong"></div>
  <div class="oe_tbl_form_btn current">
    <button class="layui-btn" id="but_submit_post" lay-submit lay-filter="editform">
      编辑保存
      <span class="oe_btn_loading layui-anim layui-icon layui-anim-rotate layui-anim-loop" style="display:none;">&#xe63d;</span>
    </button>
  </div>
  
</div>
<script type="text/javascript">
$(function(){

    layui.use('form', function(){
        $form = layui.form;
        //保存...
        $form.on('submit(editform)', function(data){
            $obj_id = data.elem.getAttribute("id");
            if (!$("#"+$obj_id).hasClass("forbid_submit")) {
            
                if ($("#catname").val().length  == 0) {
                    layer.msg("请填写分类名称");
                    return false;
                }
                
                $("#"+$obj_id).addClass("forbid_submit");
                if ($("#"+$obj_id).find("span").length > 0) {
                    $("#"+$obj_id).find("span").show();
                }
                //...
                $("#myform").submit();
            }
        });   
    });
    
});
</script>
<!--{/if}-->
</body>
</html>