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

<!--{if $a == "run"}-->
<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>
  <!--//Top End -->
  
  <blockquote class="layui-elem-quote">
    <strong>温馨提示：</strong>
    地区最多支持四级，删除地区时会把子地区一起删除，请谨慎操作。
  </blockquote>
  <!--//search End -->
  
  
  <!--//0.06.19 -->
  <div class="oe_searchbar layui-form">
    <div class="more_search_open"></div>
    <div class="layui-form-item">
    
      <div class="layui-inline">
        <div class="layui-form-label">生成类型：</div>
        <div class="layui-input-inline input-120">
          <select name="type" id="type">
            <option value="">请选择</option>
            <option value="1">一级地区</option>
            <option value="2">二级地区</option>
            <option value="3">三级地区</option>
            <option value="4">四级地区</option>
          </select>
        </div>
      </div>
      <div class="layui-inline">
        <button class="layui-btn layui-btn-sm search" id="but_update_letter" f="but_update_letter">
          生成首字母
          <span class="oe_btn_loading layui-anim layui-icon layui-anim-rotate layui-anim-loop" style="display:none;">&#xe63d;</span>
        </button>
      </div>
    </div>
  </div>
  <!--//0.06.19 -->
  <script type="text/javascript">
	$(function(){
    //生成首字母
		$(document).on("click", "[f='but_update_letter']", function(){
			$type = $("#type").val();
			if ($type.length == 0) {
        layer.msg('请选择要生成的地区类型');
				return false;
			}
			$("#but_update_letter").find('span').show();
			$.ajax({
				type: "POST",
				url: _OECPFILE+"&c=area",
				cache: false,
				data: {a:"letter", type:$type},
				dataType: "json",
				success: function(data) {
					var $json = eval(data);
					var $response = $json.response;
					var $result = $json.result;
					if ($response == '1') {
            layer.msg('生成成功');
						setTimeout(function(){
							window.location.reload();
						}, 800);
					}
					else {
            layer.msg('生成失败，请检查');
						setTimeout(function(){
							window.location.reload();
						}, 800);
					}
				},
				error: function() {
          layer.msg('系统繁忙，请稍后再试！');
				}
			});
			
		});

	});
	</script>
  
  
  <div class="oe_table_wrap layui-form">
  
    <div class="oe_tbl_tool clearfix">
      <div class="oe_gnbar clearfix">
        <a href="<!--{$oefile}-->&c=<!--{$c}-->&a=add" class="btn add fl del_line">
          <i class="layui-icon layui-icon-add-1"></i>
          <span>添加一级地区</span>
        </a>
      </div>
      <div class="oe_tongji_bar clearfix current">
        <span><b><!--{$total}--></b> 条记录</span>
      </div>
    </div>
    
    <table class="layui-table">
      <thead>
        <!--//0.06.19 -->
        <tr>
          <th width="8%">ID</th>
          <th width="22%">名称</th>
          <th width="8%">扩展名</th>
          <th width="6%">首字母</th>
          <th width="8%">子地区</th>
          <th width="7%">排序</th>
          <th width="7%">状态</th>
          <th width="7%">推荐</th>
          <th>操作</th>
        </tr> 
      </thead>
      
      <!--{if empty($area)}-->
      <tr>
        <td colspan="9" class="text_center">没有符合条件的信息</td>
      </tr>
      <!--{else}-->
      <!--{foreach $area as $volist}-->
      <tr>
        <td class="text_center"><!--{$volist.areaid}--></td>
        <td><b><!--{$volist.areaname}--></b></td>
        <td class="text_center"><!--{$volist.spread}--></td>
        <td class="text_center"><!--{$volist.letter}--></td>
        <td class="text_center"><!--{$volist.nextchilds}--></td>
        <td class="text_center"><!--{$volist.orders}--></td>
        <td class="text_center">
          <input type="checkbox" name="flag" lay-skin="primary" value="1" lay-filter="updatestatus" data-id="<!--{$volist.areaid}-->" data-type="flag"<!--{if $volist.flag == '1'}--> checked<!--{/if}--> />
        </td>
        <td class="text_center">
          <input type="checkbox" name="elite" lay-skin="primary" value="1" lay-filter="updatestatus" data-id="<!--{$volist.areaid}-->" data-type="elite"<!--{if $volist.elite == '1'}--> checked<!--{/if}--> />
        </td>
        <td>
          <div class="btn_box">
            <a href="<!--{$oefile}-->&c=<!--{$c}-->&a=edit&id=<!--{$volist.areaid}-->" 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.areaid}-->" class="layui-btn layui-btn-xs layui-btn-danger">删除</a>
            <a href="<!--{$oefile}-->&c=<!--{$c}-->&a=add&parentid=<!--{$volist.areaid}-->" class="layui-btn layui-btn-xs">添加2级地区</a>
          </div>
        </td>
      </tr>
      
      <!--{if !empty($volist.child)}-->
      <!--{foreach $volist.child as $childval}-->
      <tr>
        <td class="text_center"><!--{$childval.areaid}--></td>
        <td>&nbsp;&nbsp;&nbsp;&nbsp;|-- <!--{$childval.areaname}--></td>
        <td class="text_center"><!--{$childval.spread}--></td>
        <td class="text_center"><!--{$childval.letter}--></td>
        <td class="text_center"><!--{$childval.nextchilds}--></td>
        <td class="text_center"><!--{$childval.orders}--></td>
        <td class="text_center">
          <input type="checkbox" name="flag" lay-skin="primary" value="1" lay-filter="updatestatus" data-id="<!--{$childval.areaid}-->" data-type="flag"<!--{if $childval.flag == '1'}--> checked<!--{/if}--> />
        </td>
        <td class="text_center">
          <input type="checkbox" name="elite" lay-skin="primary" value="1" lay-filter="updatestatus" data-id="<!--{$childval.areaid}-->" data-type="elite"<!--{if $childval.elite == '1'}--> checked<!--{/if}--> />
        </td>
        <td>
          <div class="btn_box">
            <a href="<!--{$oefile}-->&c=<!--{$c}-->&a=edit&id=<!--{$childval.areaid}-->" class="layui-btn layui-btn-xs layui-btn-normal">编辑</a>
            <a href="javascript:;" f="handle-one" data-url="<!--{$oefile}-->&c=<!--{$c}-->&a=del&id=<!--{$childval.areaid}-->" class="layui-btn layui-btn-xs layui-btn-danger">删除</a>
            <a href="<!--{$oefile}-->&c=<!--{$c}-->&a=add&parentid=<!--{$childval.areaid}-->" class="layui-btn layui-btn-xs">添加3级地区</a>
            <a href="<!--{$oefile}-->&c=<!--{$c}-->&a=child&rootid=<!--{$childval.areaid}-->&from=child" class="layui-btn layui-btn-xs layui-btn-warm">查看3级地区</a>
          </div>
        </td>
      </tr>
      <!--{/foreach}-->
      <!--{/if}-->
      
      <!--{/foreach}-->
      <!--{/if}-->
    </table>

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

<!--{if $a == "child"}-->
<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">
      <span class="layui-btn layui-btn-sm layui-btn-primary layui-btn-radius">
        <a href="<!--{$oefile}-->&c=<!--{$c}-->">返回列表</a>
      </span>
    </div>
    
  </div>
  <!--//Top End -->
  
  <blockquote class="layui-elem-quote">
    <strong>温馨提示：</strong>
    地区最多支持四级，删除地区时会把子地区一起删除，请谨慎操作。
    【上级节点地区：<!--{hook mod='areacat' type='text' value=$rootid}-->】
  </blockquote>
  <!--//search End -->


  <div class="oe_table_wrap layui-form">

    <table class="layui-table">
      <thead>
        <!--//0.06.19 -->
        <tr>
          <th width="8%">ID</th>
          <th width="15%">上级</th>
          <th width="20%">名称</th>
          <th width="8%">扩展名</th>
          <th width="7%">首字母</th>
          <th width="6%">子地区</th>
          <th width="6%">排序</th>
          <th width="6%">状态</th>
          <th width="6%">推荐</th>
          <th>操作</th>
        </tr> 
      </thead>
      
      <!--{if empty($area)}-->
      <tr>
        <td colspan="10" class="text_center">没有符合条件的信息</td>
      </tr>
      <!--{else}-->
      <!--{foreach $area as $volist}-->
      <tr>
        <td class="text_center"><!--{$volist.areaid}--></td>
        <td class="text_center"><!--{hook mod='areacat' type='text' value=$rootid}--></td>
        <td class="text_center"><!--{$volist.areaname}--></td>
        <td class="text_center"><!--{$volist.spread}--></td>
        <td class="text_center"><!--{$volist.letter}--></td>
        <td class="text_center"><!--{$volist.nextchilds}--></td>
        <td class="text_center"><!--{$volist.orders}--></td>
        <td class="text_center">
          <input type="checkbox" name="flag" lay-skin="primary" value="1" lay-filter="updatestatus" data-id="<!--{$volist.areaid}-->" data-type="flag"<!--{if $volist.flag == '1'}--> checked<!--{/if}--> />
        </td>
        <td class="text_center">
          <input type="checkbox" name="elite" lay-skin="primary" value="1" lay-filter="updatestatus" data-id="<!--{$volist.areaid}-->" data-type="elite"<!--{if $volist.elite == '1'}--> checked<!--{/if}--> />
        </td>
        <td>
          <div class="btn_box">
            <a href="<!--{$oefile}-->&c=<!--{$c}-->&a=edit&id=<!--{$volist.areaid}-->&rootid=<!--{$rootid}-->" 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.areaid}-->&rootid=<!--{$rootid}-->" class="layui-btn layui-btn-xs layui-btn-danger">删除</a>
            <!--{if $volist.depth < '3'}-->
            <a href="<!--{$oefile}-->&c=<!--{$c}-->&a=add&rootid=<!--{$rootid}-->&parentid=<!--{$volist.areaid}-->" class="layui-btn layui-btn-xs">添加4级地区</a>
            <!--{/if}-->
          </div>
        </td>
      </tr>
      
      <!--{if !empty($volist.child)}-->
      <!--{foreach $volist.child as $childval}-->
      <tr>
        <td class="text_center"><!--{$childval.areaid}--></td>
        <td class="text_center">--</td>
        <td class="text_center">&nbsp;&nbsp;&nbsp;&nbsp;|-- <!--{$childval.areaname}--></td>
        <td class="text_center"><!--{$childval.spread}--></td>
        <td class="text_center"><!--{$childval.letter}--></td>
        <td class="text_center"><!--{$childval.nextchilds}--></td>
        <td class="text_center"><!--{$childval.orders}--></td>
        <td class="text_center">
          <input type="checkbox" name="flag" lay-skin="primary" value="1" lay-filter="updatestatus" data-id="<!--{$childval.areaid}-->" data-type="flag"<!--{if $childval.flag == '1'}--> checked<!--{/if}--> />
        </td>
        <td class="text_center">
          <input type="checkbox" name="elite" lay-skin="primary" value="1" lay-filter="updatestatus" data-id="<!--{$childval.areaid}-->" data-type="elite"<!--{if $childval.elite == '1'}--> checked<!--{/if}--> />
        </td>
        <td>
          <div class="btn_box">
            <a href="<!--{$oefile}-->&c=<!--{$c}-->&a=edit&id=<!--{$childval.areaid}-->&rootid=<!--{$rootid}-->" class="layui-btn layui-btn-xs layui-btn-normal">编辑</a>
            <a href="javascript:;" f="handle-one" data-url="<!--{$oefile}-->&c=<!--{$c}-->&a=del&id=<!--{$childval.areaid}-->&rootid=<!--{$rootid}-->" class="layui-btn layui-btn-xs layui-btn-danger">删除</a>
          </div>
        </td>
      </tr>
      <!--{/foreach}-->
      <!--{/if}-->
      
      <!--{/foreach}-->
      <!--{/if}-->
    </table>

  </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">
        <!--{if $rootid > 0}-->
        <a href="<!--{$oefile}-->&c=<!--{$c}-->&a=child&rootid=<!--{$rootid}-->">返回列表</a>
        <!--{else}-->
        <a href="<!--{$oefile}-->&c=<!--{$c}-->">返回列表</a>
        <!--{/if}-->
      </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%"><font color="red"></font>从属地区：</th>
          <td width="85%">
            <!--//9.10.20 -->
            <!--{if $parentid == '0'}-->
              --
            <!--{else}-->
              <!--{area type="text" value=$parentid}-->
            <!--{/if}-->
            <input type="hidden" name="parentid" id="parentid" value="<!--{$parentid}-->" />
          </td>
        </tr>
        <tr>
          <th><font color="red">*</font>地区名称：</th>
          <td>
            <input type="text" name="areaname" id="areaname" class="layui-input input-250" value="" />
          </td>
        </tr>
        <tr>
          <th><font color="red"></font>扩展名：</th>
          <td>
            <input type="text" name="spread" id="spread" class="layui-input input-250" value="" />
            <span class="text_tip_inline">（省、市、区、县、镇、街道等...）</span>
          </td>
        </tr>
        <tr>
          <th>排序：</th>
          <td>
            <input type="text" name="orders" id="orders" class="layui-input input-80" value="<!--{$orders}-->" />
          </td>
        </tr>
        <tr>
          <th>状态：</th>
          <td>
            <input type="radio" name="flag" id="flag" value="1" title="开启" checked />
            <input type="radio" name="flag" id="flag" value="0" title="关闭" />
          </td>
        </tr>
        <tr>
          <th>推荐：</th>
          <td>
            <input type="radio" name="elite" id="elite" value="1" title="开启" />
            <input type="radio" name="elite" id="elite" value="0" title="关闭" checked />
          </td>
        </tr>
        <!--//0.06.19 -->
        <tr>
          <th>首字母：</th>
          <td>
            <input type="text" name="letter" id="letter" class="layui-input input-150" />
          </td>
        </tr>
      </table>
    </div>
  </div>
  </form>
  
  <div class="oe_tbl_form_btn">
    <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 ($("#areaname").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">
        <!--{if $rootid > 0}-->
        <a href="<!--{$oefile}-->&c=<!--{$c}-->&a=child&rootid=<!--{$rootid}-->">返回列表</a>
        <!--{else}-->
        <a href="<!--{$oefile}-->&c=<!--{$c}-->">返回列表</a>
        <!--{/if}-->
      </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%"><font color="red"></font>从属地区：</th>
          <td width="85%">
            <!--{if $area.parentid == '0'}-->
              --
            <!--{else}-->
              <!--//9.10.22 -->
              <!--{area type="text" value=$area.parentid}-->
            <!--{/if}-->
            <input type="hidden" name="parentid" id="parentid" value="<!--{$area.parentid}-->" />
          </td>
        </tr>
        <tr>
          <th><font color="red">*</font>地区名称：</th>
          <td>
            <input type="text" name="areaname" id="areaname" class="layui-input input-250" value="<!--{$area.areaname}-->" />
          </td>
        </tr>
        <tr>
          <th><font color="red"></font>扩展名：</th>
          <td>
            <input type="text" name="spread" id="spread" class="layui-input input-250" value="<!--{$area.spread}-->" />
            <span class="text_tip_inline">（省、市、区、县、镇、街道等...）</span>
          </td>
        </tr>
        <tr>
          <th>排序：</th>
          <td>
            <input type="text" name="orders" id="orders" class="layui-input input-80" value="<!--{$area.orders}-->" />
          </td>
        </tr>
        <tr>
          <th>状态：</th>
          <td>
            <input type="radio" name="flag" id="flag" value="1" title="开启"<!--{if $area.flag == '1'}--> checked<!--{/if}--> />
            <input type="radio" name="flag" id="flag" value="0" title="关闭"<!--{if $area.flag == '0'}--> checked<!--{/if}--> />
          </td>
        </tr>
        <tr>
          <th>推荐：</th>
          <td>
            <input type="radio" name="elite" id="elite" value="1" title="开启"<!--{if $area.elite == '1'}--> checked<!--{/if}--> />
            <input type="radio" name="elite" id="elite" value="0" title="关闭"<!--{if $area.elite == '0'}--> checked<!--{/if}--> />
          </td>
        </tr>
        <!--//0.06.19 -->
        <tr>
          <th>首字母：</th>
          <td>
            <input type="text" name="letter" id="letter" class="layui-input input-150" value="<!--{$area.letter}-->" />
          </td>
        </tr>
      </table>
    </div>
  </div>
  </form>
  
  <div class="oe_tbl_form_btn">
    <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 ($("#areaname").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>