<!--{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">
      <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">
      <div class="layui-inline">
        <div class="layui-form-label">帐号名：</div>
        <div class="layui-input-inline input-120">
          <input type="text" name="sname" id="sname" value="<!--{$sname}-->" class="layui-input" />
        </div>
      </div>
      <div class="layui-inline">
        <div class="layui-form-label">姓名：</div>
        <div class="layui-input-inline input-120">
          <input type="text" name="slastname" id="slastname" value="<!--{$slastname}-->" class="layui-input" />
        </div>
      </div>
      <div class="layui-inline">
        <div class="layui-form-label">邮箱：</div>
        <div class="layui-input-inline input-120">
          <input type="text" name="semail" id="semail" value="<!--{$semail}-->" class="layui-input" />
        </div>
      </div>
      <div class="layui-inline">
        <div class="layui-form-label">手机：</div>
        <div class="layui-input-inline input-120">
          <input type="text" name="smobile" id="smobile" value="<!--{$smobile}-->" class="layui-input" />
        </div>
      </div>
      <div class="layui-inline">
        <div class="layui-form-label">状态：</div>
        <div class="layui-input-inline input-120">
          <select name="sflag" id="sflag" lay-filter="sflag">
            <option value="">不限</option>
            <option value="1"<!--{if $sflag == '1'}--> selected<!--{/if}-->>正常</option>
            <option value="2"<!--{if $sflag == '2'}--> selected<!--{/if}-->>锁定</option>
          </select>
        </div>
      </div>
    </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="select btn fl">
          <input type="checkbox" name="allid[]" lay-skin="primary" title="全选" lay-filter="selectAll">
        </div>
        <div class="btn del fl" f="handle-array" data-form="myform">
          <i class="layui-icon layui-icon-delete"></i>
          <span>删除</span>
        </div>
        <a href="<!--{$oefile}-->&c=<!--{$c}-->&a=add" class="btn add fl">
          <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>
    
    <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="4%">选</th>
          <th width="8%">ID</th>
          <th width="10%">帐号</th>
          <th width="8%">姓名</th>
          <th width="8%">角色</th>
          <th width="6%">状态</th>
          <th width="8%">管理员</th>
          <th width="10%">手机</th>
          <th width="15%">邮箱</th>
          <th width="15%">最后登录</th>
          <th>操作</th>
        </tr>
      </thead>
      
      <!--{if empty($admin)}-->
      <tr>
        <td colspan="11" class="text_center">没有符合条件的信息</td>
      </tr>
      <!--{else}-->
      <!--{foreach $admin as $volist}-->
      <tr>
        <td class="check text_center">
          <input type="checkbox" name="id[]" lay-skin="primary" value="<!--{$volist.adminid}-->" />
        </td>
        <td class="text_center">
          <!--{$volist.adminid}-->
        </td>
        <td class="text_center"><!--{$volist.loginname}--></td>
        <td class="text_center"><!--{if empty($volist.lastname)}-->--<!--{else}--><!--{$volist.lastname}--><!--{/if}--></td>
        <td class="text_center">
          <!--{if empty($volist.rolename)}-->--<!--{else}--><!--{$volist.rolename}--><!--{/if}-->
        </td>
        <td class="text_center">
          <!--{if $volist.status == '1'}-->
          <font color="green">正常</font>
          <!--{else}-->
          <font color="red">锁定</font>
          <!--{/if}-->
        </td>
        <td class="text_center">
          <!--{if $volist.super == '1'}-->
          <font color="green">是</font>
          <!--{else}-->
          <font color="gray">否</font>
          <!--{/if}-->
        </td>
        <td class="text_center"><!--{$volist.mobile}--></td>
        <td class="text_center"><!--{$volist.email}--></td>
        <td class="text_center">
          <!--{if $volist.logintime == '0'}-->
          --
          <!--{else}-->
          <!--{$volist.logintime|date_format:"%Y-%m-%d %H:%M:%S"}-->
          <!--{/if}-->
        </td>
        <td class="text_center">
          <div class="btn_box">
            <a href="<!--{$oefile}-->&c=<!--{$c}-->&a=edit&id=<!--{$volist.adminid}-->&<!--{$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.adminid}-->&<!--{$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%"><font color="red">*</font>登录帐号：</th>
          <td width="35%">
            <input type="text" name="loginname" id="loginname" class="layui-input input-200" /> 
            <span id="loginname_tips"></span>
          </td>
          <th width="15%"><font color="red"></font>系统管理员：</th>
          <td width="35%">
            <input type="checkbox" name="super" id="super" lay-skin="primary" value="1" />
            <span class="text_tip_inline">（拥有所有操作权限）</span>
          </td>
        </tr>
        <tr>
          <th><font color="red">*</font>登录密码：</th>
          <td>
            <input type="password" name="password" id="password" class="layui-input input-200" />
            <br />
           <span class="text_tip_inline">(输入6-16个字符的密码)</span>
          </td>
          <th><font color="red">*</font>确认密码：</th>
          <td>
            <input type="password" name="confirmpassword" id="confirmpassword" class="layui-input input-200" />
            <br />
            <span class="text_tip_inline">(再次输入登录密码)</span>
          </td>
        </tr>
        <tr>
          <th><font color="red"></font>所属角色：</th>
          <td>
            <div class="input-200">
              <!--{hook mod='roles' type='select' name='roleid' text='=请选择='}--> 
            </div>
            <span class="text_tip_inline">(非系统管理权限关联角色)</span>
          </td>
          <th><font color="red">*</font>安全密码：</th>
          <td>
            <input type="password" name="safeword" id="safeword" class="layui-input input-200" />
            <br />
            <span class="text_tip_inline">(财务操作需要输入该密码)</span>
          </td>
        </tr>

        <tr>
          <th>姓名：</th>
          <td>
            <input type="text" name="lastname" id="lastname" class="layui-input input-200" />
          </td>
          <th>座机：</th>
          <td>
            <input type="text" name="tel" id="tel" class="layui-input input-200" />
          </td>
        </tr>
        <tr>
          <th>手机：</th>
          <td>
            <input type="text" name="mobile" id="mobile" class="layui-input input-200" />
          </td>
          <th>邮箱：</th>
          <td>
            <input type="text" name="email" id="email" class="layui-input input-200" />
          </td>
        </tr>
        <tr>
          <th>QQ：</th>
          <td>
            <input type="text" name="qq" id="qq" class="layui-input input-200" />
          </td>
          <th>微信：</th>
          <td>
            <input type="text" name="weixin" id="weixin" class="layui-input input-200" />
          </td>
        </tr>
        <tr>
          <th>头像：</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="headimg" value="" />
        
            <div class="tblform_tips normal">预览：</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><font color="red"></font>状态：</th>
          <td>
            <input type="radio" name="status" value="1" title="正常" checked />
            <input type="radio" name="status" value="0" title="锁定" />
          </td>
        </tr>
        <tr>
          <th>备注说明：</th>
          <td colspan="3">
            <textarea name="remark" id="remark" class="layui-textarea" style="width:40%;height:60px;"></textarea>
          </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(){
    
    //检测帐号
    $(document).on("blur", "#loginname", function(){
        if ($(this).val().length > 0) {
            $.ajax({
                type: "POST",
                url: "<!--{$oefile}-->&c=<!--{$c}-->",
                cache: false,
                data: {a:"checkname", name:$(this).val(),r:get_rndnum(8)},
                dataType: "json",
                success: function(data) {
                    $json = eval(data);
                    $response = $json.response;
                    $result = $json.result;
                    if ($response == '1') {
                        $("#loginname_tips").html("<font color='green'>该帐号可用</font>");
                    }
                    else {
                        if ($result.length == 0) {
                          $result = "该帐号已存在";
                        }
                        $("#loginname_tips").html("<font color='red'>"+$result+"</font>");
                    }
                },
                error: function() {
                    layer.msg("检测失败，请检查网络...");
                }
            });
        }
    });
  
    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 ($("#loginname").val().length  == 0) {
                    layer.msg("请填写登录帐号");
                    return false;
                }
                if ($("#password").val().length  == 0) {
                    layer.msg("请填写登录密码");
                    return false;
                }
                if ($("#confirmpassword").val().length  == 0) {
                    layer.msg("请填写确认密码");
                    return false;
                }
                if ($("#confirmpassword").val() != $("#password").val()) {
                    layer.msg("确认密码不正确");
                    return false;
                }
                if ($("#safeword").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%"><font color="red"></font>登录帐号：</th>
          <td width="35%">
            <!--{$admin.loginname}-->
            <span id="loginname_tips"></span>
          </td>
          <th width="15%"><font color="red"></font>系统管理员：</th>
          <td width="35%">
            <input type="checkbox" name="super" id="super" lay-skin="primary" value="1"<!--{if $admin.super == '1'}--> checked<!--{/if}--> />
            <span class="text_tip_inline">（拥有所有操作权限）</span>
          </td>
        </tr>
        <tr>
          <th><font color="red"></font>登录密码：</th>
          <td>
            <input type="password" name="password" id="password" class="layui-input input-200" />
            <br />
            <span class="text_tip_inline">(不修改请留空)</span>
          </td>
          <th><font color="red"></font>安全密码：</th>
          <td>
            <input type="password" name="safeword" id="safeword" class="layui-input input-200" />
            <br />
            <span class="text_tip_inline">(不修改请留空)</span>
          </td>
        </tr>
        <tr>
          <th><font color="red"></font>所属角色：</th>
          <td colspan="3">
            <div class="input-200">
              <!--{hook mod='roles' type='select' name='roleid' text='=请选择=' value=$admin.roleid}--> 
            </div>
            <span class="text_tip_inline">(非系统管理权限关联角色)</span>
          </td>
        </tr>
       
        <tr>
          <th>姓名：</th>
          <td>
            <input type="text" name="lastname" id="lastname" class="layui-input input-200" value="<!--{$admin.lastname}-->" />
          </td>
          <th>座机：</th>
          <td>
            <input type="text" name="tel" id="tel" class="layui-input input-200" value="<!--{$admin.tel}-->" />
          </td>
        </tr>
        <tr>
          <th>手机：</th>
          <td>
            <input type="text" name="mobile" id="mobile" class="layui-input input-200" value="<!--{$admin.mobile}-->" />
          </td>
          <th>邮箱：</th>
          <td>
            <input type="text" name="email" id="email" class="layui-input input-200" value="<!--{$admin.email}-->" />
          </td>
        </tr>
        <tr>
          <th>QQ：</th>
          <td>
            <input type="text" name="qq" id="qq" class="layui-input input-200" value="<!--{$admin.qq}-->" />
          </td>
          <th>微信：</th>
          <td>
            <input type="text" name="weixin" id="weixin" class="layui-input input-200" value="<!--{$admin.weixin}-->" />
          </td>
        </tr>
        <tr>
          <th>头像：</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="headimg" value="<!--{$admin.headimg}-->" />
        
            <div class="tblform_tips normal">预览：</div>
            <div class="upload_pic upload_pic_md" style="width:30px;height:30px;">
              <img src="<!--{$urlpath}--><!--{if !empty($admin.headimg)}--><!--{$admin.headimg}--><!--{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><font color="red"></font>状态：</th>
          <td>
            <input type="radio" name="status" value="1" title="正常"<!--{if $admin.status == '1'}--> checked<!--{/if}--> />
            <input type="radio" name="status" value="0" title="锁定"<!--{if $admin.status == '0'}--> checked<!--{/if}--> />
          </td>
        </tr>
        <tr>
          <th>备注说明：</th>
          <td colspan="3">
            <textarea name="remark" id="remark" class="layui-textarea" style="width:40%;height:60px;"><!--{$admin.remark}--></textarea>
          </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")) {
                
                $("#"+$obj_id).addClass("forbid_submit");
                if ($("#"+$obj_id).find("span").length > 0) {
                    $("#"+$obj_id).find("span").show();
                }
                //...
                $("#myform").submit();
            }
        });   
    });
    
});
</script>
<!--{/if}-->
</body>
</html>