edit.html 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <div class="layui-layout layui-layout-admin" style="padding-left: 40px;margin-top: 20px;">
  2. <form class="layui-form" action="" method="post" >
  3. <div class="layui-form-item">
  4. <label class="layui-form-label">登录账号</label>
  5. <div class="layui-input-inline">
  6. <input type="text" name="login_name" readonly id="login_name" lay-verify="required" autocomplete="off" placeholder="登录账号" class="layui-input" value="{{.admin.login_name}}">
  7. </div>
  8. <div class="layui-form-mid layui-word-aux">*登录不允许修改</div>
  9. </div>
  10. <div class="layui-form-item">
  11. <label class="layui-form-label">真实姓名</label>
  12. <div class="layui-input-inline">
  13. <input type="text" name="real_name" id="real_name" lay-verify="required" autocomplete="off" placeholder="真实姓名" class="layui-input" value="{{.admin.real_name}}">
  14. </div>
  15. <div class="layui-form-mid layui-word-aux">*</div>
  16. </div>
  17. <div class="layui-form-item">
  18. <label class="layui-form-label">手机号码</label>
  19. <div class="layui-input-inline">
  20. <input type="text" name="phone" lay-verify="phone|required" autocomplete="off" placeholder="手机号码" class="layui-input" value="{{.admin.phone}}">
  21. </div>
  22. <div class="layui-form-mid layui-word-aux">*</div>
  23. </div>
  24. <div class="layui-form-item">
  25. <label class="layui-form-label">电子邮箱</label>
  26. <div class="layui-input-inline">
  27. <input type="text" name="email" id="email" lay-verify="email" autocomplete="off" placeholder="电子邮箱" class="layui-input" value="{{.admin.email}}">
  28. </div>
  29. <div class="layui-form-mid layui-word-aux">*</div>
  30. </div>
  31. <div class="layui-form-item">
  32. <label class="layui-form-label">是否修改</label>
  33. <div class="layui-input-inline">
  34. <input type="radio" name="reset_pwd" lay-verify="reset_pwd" value="1" title="是">
  35. <input type="radio" name="reset_pwd" lay-verify="reset_pwd" value="2" title="否" checked>
  36. </div>
  37. <div class="layui-form-mid layui-word-aux"></div>
  38. </div>
  39. <div class="layui-form-item password" style="display:none;">
  40. <label class="layui-form-label">旧密码</label>
  41. <div class="layui-input-inline">
  42. <input type="password" name="password_old" id="password_old" lay-verify="" autocomplete="off" placeholder="旧密码" class="layui-input" value="">
  43. </div>
  44. <div class="layui-form-mid layui-word-aux"></div>
  45. </div>
  46. <div class="layui-form-item password" style="display:none;">
  47. <label class="layui-form-label">设置密码</label>
  48. <div class="layui-input-inline">
  49. <input type="password" name="password_new1" id="password_new1" lay-verify="" autocomplete="off" placeholder="新密码" class="layui-input" value="">
  50. </div>
  51. <div class="layui-form-mid layui-word-aux"></div>
  52. </div>
  53. <div class="layui-form-item password" style="display:none;">
  54. <label class="layui-form-label">重复密码</label>
  55. <div class="layui-input-inline">
  56. <input type="password" name="password_new2" id="password_new2" lay-verify="" autocomplete="off" placeholder="新密码" class="layui-input" value="">
  57. </div>
  58. <div class="layui-form-mid layui-word-aux"></div>
  59. </div>
  60. <input type="hidden" id="id" name="id" value="{{.admin.id}}">
  61. <div class="layui-form-item">
  62. <div class="layui-input-block">
  63. <button class="layui-btn" lay-submit="" lay-filter="sub">立即提交</button>
  64. <button type="reset" class="layui-btn layui-btn-primary">重置</button>
  65. </div>
  66. </div>
  67. </form>
  68. </div>
  69. <script>
  70. var $;
  71. layui.config({
  72. base : "js/"
  73. }).use(['form','element','layer','jquery'],function(){
  74. var form = layui.form; //只有执行了这一步,部分表单元素才会自动修饰成功
  75. var $ = layui.jquery;
  76. form.on('radio', function(data){
  77. if(data.value==1){
  78. $(".password").show()
  79. }else{
  80. $(".password").hide()
  81. }
  82. });
  83. form.on('submit(sub)', function(data){
  84. var form_data = $("form").serialize();
  85. $.post('{{urlfor "UserController.AjaxSave"}}', form_data, function (out) {
  86. if (out.status == 0) {
  87. layer.msg("操作成功,请重新登录",{icon: 1},function () {
  88. top.location.href="/login_out"
  89. })
  90. } else {
  91. layer.msg(out.message)
  92. }
  93. }, "json");
  94. return false;
  95. });
  96. //但是,如果你的HTML是动态生成的,自动渲染就会失效
  97. //因此你需要在相应的地方,执行下述方法来手动渲染,跟这类似的还有 element.init();
  98. form.render();
  99. });
  100. </script>