manager_edit.html 3.52 KB
{echo:JS::import('form');}
{echo:JS::import('date');}
{echo:JS::import('dialog?skin=brief');}
{echo:JS::import('dialogtools');}
<h1 class="page_title">管理员编辑</h1>
<div id="obj_form" class="form2">
    <form action="{url:/admin/manager_save}" method="post" >
        {if:isset($id)}<input type="hidden" name="id" id="objId" value="{$id}">{/if}
    <dl class="lineD">
      <dt><b class="red">*</b> 用户名:</dt>
      <dd>
        {if:isset($id) && isset($name) }
        <label>{$name}</label>
        {else:}
        <input name="name" type="text" pattern="required" value="{$name}" alt="用户名不能为空" />
        <label></label>
        {/if}
      </dd>
      </dl>
      <dl class="lineD">
      <dt>角色:</dt>
      <dd>
        <select name="roles" id="">
          <option value="administrator">超级管理员</option>
          {query:name=roles}
          <option value="{$item['id']}">{$item['name']}</option>
          {/query}
        </select>
      </dd>
      </dl>
      {if: isset($id) && isset($password)}
      <dl class="lineD">
      <dt>密码:</dt>
      <dd>
        <label><a href="javascript:;" onclick="password_dialog()">修改密码</a></label>
      </dd>
      </dl>
      {else:}
      <dl class="lineD">
      <dt><b class="red">*</b>密码:</dt>
      <dd>
        <input name="password" type="password"  bind="repassword" pattern=".{6,}" value="" alt="密码必需大于6位">
        <label></label>
      </dd>
      </dl><dl class="lineD">
      <dt><b class="red">*</b>确认密码:</dt>
      <dd>
        <input name="repassword" type="password" bind="password" pattern=".{6,}" value="" alt="密码必需大于6位">
        <label></label>
      </dd>
      </dl>
      {/if}
    <div style="text-align:center"><input type="submit" value="提交" class="button">&nbsp;&nbsp;&nbsp;&nbsp;<input type="reset" value="重置" class="button"></div>
    </form>
</div>
<div id="password_info" style="display: none;width:520px">
  <form class="form2" callback="changePassword">
  <dl class="lineD">
      <dt><b class="red">*</b>密码:</dt>
      <dd>
        <input name="password" type="password"  id="password" bind="repassword" pattern=".{6,}">
        <label>密码必需大于6位</label>
      </dd>
      </dl><dl class="lineD">
      <dt><b class="red">*</b>确认密码:</dt>
      <dd>
        <input name="repassword" type="password" id="repassword" bind="password" pattern=".{6,}" >
        <label>密码必需大于6位</label>
      </dd>
      </dl>
      <div style="text-align:center"><input type="submit" value="提交" class="button">&nbsp;&nbsp;&nbsp;&nbsp;<input type="reset" value="重置" class="button"></div>
      </form>
</div>
<script type="text/javascript">
var form =  new Form();
form.setValue('roles','{$roles}');

function password_dialog(){
  art.dialog({id:'password_dialog',title:'密码设定:',content:document.getElementById('password_info')});
}
function changePassword(e){
  var password = $("#password").val();
  var repassword = $("#repassword").val();
  var id = $("#objId").val();
  if(!e){
    $.post("{url:/admin/manager_password}",{id:id,password:password,repassword:repassword},function(data){
        if(data['status']=="success")
          art.dialog.tips("<p class='success'>密码修改成功!</p>");
        else art.dialog.tips("<p class='"+data['status']+"'>"+data['msg']+"</p>");
          art.dialog({id:"password_dialog"}).close();
    },"json");
  }
  return false;
}
</script>