admin_form.html 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <div class="layui-fluid">
  2. <div class="layui-row layui-col-space15">
  3. <div class="layui-col-md12">
  4. <div class="layui-card">
  5. <div class="layui-card-header">后台管理员</div>
  6. <div class="layui-card-body" pad15>
  7. <div class="layui-form layui-form-pane" lay-filter="{$lay_table}">
  8. <input type="hidden" name="id" value="{:array_get($info,'id')}">
  9. <div class="layui-form-item">
  10. <label class="layui-form-label"><span style="color:#f90c05;">*</span>登录名</label>
  11. <div class="layui-input-block">
  12. <input type="text" name="admin_name" value="{:array_get($info,'admin_name')}" lay-verify="required"
  13. placeholder="请输入登录名"
  14. autocomplete="off" class="layui-input">
  15. </div>
  16. </div>
  17. <div class="layui-form-item">
  18. <label class="layui-form-label"><span style="color:#f90c05;">*</span>登录密码</label>
  19. <div class="layui-input-block">
  20. <input type="text" name="password" value="" placeholder="请输入登录密码,不修改留空"
  21. autocomplete="off" class="layui-input">
  22. </div>
  23. </div>
  24. <div class="layui-form-item">
  25. <label class="layui-form-label"><span style="color:#f90c05;">*</span>姓名</label>
  26. <div class="layui-input-block">
  27. <input type="text" name="realname" value="{:array_get($info,'realname')}" lay-verify="required"
  28. placeholder="请输入姓名"
  29. autocomplete="off" class="layui-input">
  30. </div>
  31. </div>
  32. <div class="layui-form-item">
  33. <label class="layui-form-label">手机号</label>
  34. <div class="layui-input-block">
  35. <input type="text" name="mobile" value="{:array_get($info,'mobile')}" lay-verify="phone"
  36. placeholder="请输入号码" autocomplete="off"
  37. class="layui-input">
  38. </div>
  39. </div>
  40. <div class="layui-form-item">
  41. <label class="layui-form-label">备注</label>
  42. <div class="layui-input-block">
  43. <textarea name="remark" placeholder="请输入备注内容"
  44. class="layui-textarea">{:array_get($info,'remark')}</textarea>
  45. </div>
  46. </div>
  47. <div class="layui-form-item">
  48. <label class="layui-form-label">角色</label>
  49. <div class="layui-input-block">
  50. <select lay-filter="adminrole" name="role">
  51. <option value="1" {:array_get($info,'role')===1 ?'selected' : '' }>超级管理员</option>
  52. <option value="2" {:array_get($info,'role')!==1 ?'selected' : '' }>普通管理员</option>
  53. </select>
  54. <div class="layui-form-mid layui-word-aux">超级管理员,默认具备所有权限,请谨慎设置。</div>
  55. </div>
  56. </div>
  57. <div class="layui-form-item powerarrbox" style="display: {:array_get($info,'role')===1 ? 'none' : 'block' };"
  58. pane>
  59. <label class="layui-form-label">栏目权限</label>
  60. <div class="layui-input-block" id="powerarr"></div>
  61. </div>
  62. <div class="layui-form-item" pane>
  63. <label class="layui-form-label">状态</label>
  64. <div class="layui-input-block">
  65. <input type="checkbox" lay-filter="switch" name="status" {eq name="info.status|default=1" value="1" }checked{/eq} lay-skin="switch" lay-text="正常|禁用" value="1" />
  66. </div>
  67. </div>
  68. <div class="layui-form-item">
  69. <div class="layui-input-block">
  70. <input type="button" lay-submit lay-filter="{$lay_btn}"
  71. value="确认提交" class="layui-btn">
  72. </div>
  73. </div>
  74. </div>
  75. </div>
  76. </div>
  77. </div>
  78. </div>
  79. </div>
  80. <script>
  81. layui.use(['index', 'form', 'set', 'upload', 'tree'], function () {
  82. const $ = layui.$;
  83. const admin = layui.admin;
  84. const form = layui.form;
  85. const tree = layui.tree;
  86. form.render();
  87. form.on('select(adminrole)', function (data) {
  88. const val = data.value;
  89. if (val == 1) {
  90. $(".powerarrbox").css("display", "none");
  91. } else {
  92. $(".powerarrbox").css("display", "block");
  93. }
  94. });
  95. const defpowerarr = {$powerarr|raw|default= "[]"};
  96. tree.render({
  97. elem: '#powerarr',
  98. data: defpowerarr,
  99. showCheckbox: true,
  100. id: 'powerarr'
  101. });
  102. form.on('submit({$lay_btn})', function (obj) {
  103. const checkedData = tree.getChecked('powerarr');
  104. obj.field.powerids = getCheckedId(checkedData);
  105. const index = parent.layer.getFrameIndex(window.name);
  106. admin.req({
  107. url: "{:url('admin/editAdmin')}",
  108. data: obj.field,
  109. done: function (res) {
  110. layer.msg("提交成功", {
  111. icon: 1
  112. });
  113. parent.layui.table.reload('lay-admin-index-table'); //重载表格
  114. parent.layer.close(index);
  115. }
  116. });
  117. });
  118. });
  119. </script>