admin_add.html 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. {include file="common/header"/}
  2. <div class="LM-container">
  3. <div class="LM-main">
  4. <div class="admin-main layui-anim layui-anim-upbit">
  5. <fieldset class="layui-elem-field layui-field-title">
  6. <legend>{$title}</legend>
  7. </fieldset>
  8. <form class="layui-form layui-form-pane" lay-filter="form">
  9. <div class="layui-form-item">
  10. <label class="layui-form-label">所属用户组</label>
  11. <div class="layui-input-inline">
  12. <select name="group_id" lay-verify="required" {if $info && $info.id==1} readonly="" {/if} >
  13. <option value="">请选择用户组</option>
  14. {volist name="authGroup" id="vo"}
  15. {if $vo.id !=1}
  16. <option value="{$vo.id}" {if !empty($info) && $info.group_id==$vo.id} selected {/if} >{$vo.title}</option>
  17. {else /}
  18. <option value="{$vo.id}" selected>{$vo.title}</option>
  19. {/if}
  20. {/volist}
  21. </select>
  22. </div>
  23. </div>
  24. <div class="layui-form-item">
  25. <label class="layui-form-label">{:lang('username')}</label>
  26. <div class="layui-input-inline">
  27. <input type="text" name="username" lay-verify="required" placeholder="{:lang('pleaseEnter')}登录用户名" class="layui-input">
  28. </div>
  29. <div class="layui-form-mid layui-word-aux">
  30. 用户名在4到25个字符之间。
  31. </div>
  32. </div>
  33. <div class="layui-form-item">
  34. <label class="layui-form-label">{:lang('password')}</label>
  35. <div class="layui-input-inline">
  36. <input type="password" name="password" placeholder="{:lang('pleaseEnter')}登录密码" class="layui-input">
  37. </div>
  38. <div class="layui-form-mid layui-word-aux">
  39. 密码必须大于6位,小于15位。
  40. </div>
  41. </div>
  42. <!--<div class="layui-form-item">-->
  43. <!--<label class="layui-form-label">头像</label>-->
  44. <!--<input type="hidden" name="avatar" id="avatar">-->
  45. <!--<div class="layui-input-inline">-->
  46. <!--<div class="layui-upload">-->
  47. <!--<button type="button" class="layui-btn layui-btn-primary" id="addBtn"><i class="icon icon-upload3"></i>点击上传</button>-->
  48. <!--<div class="layui-upload-list">-->
  49. <!--<img class="layui-upload-img" id="addPic">-->
  50. <!--<p id="notice"></p>-->
  51. <!--</div>-->
  52. <!--</div>-->
  53. <!--</div>-->
  54. <!--</div>-->
  55. <!--<div class="layui-form-item">-->
  56. <!--<label class="layui-form-label">{:lang('email')}</label>-->
  57. <!--<div class="layui-input-inline">-->
  58. <!--<input type="text" name="email" lay-verify="email" placeholder="{:lang('pleaseEnter')}用户邮箱" class="layui-input">-->
  59. <!--</div>-->
  60. <!--<div class="layui-form-mid layui-word-aux">-->
  61. <!--用于密码找回,请认真填写。-->
  62. <!--</div>-->
  63. <!--</div>-->
  64. <div class="layui-form-item">
  65. <label class="layui-form-label">{:lang('mobile')}</label>
  66. <div class="layui-input-inline">
  67. <input type="text" name="mobile" lay-verify="phone" value="" placeholder="{:lang('pleaseEnter')}手机号" class="layui-input">
  68. </div>
  69. </div>
  70. <div class="layui-form-item">
  71. <div class="layui-input-inline">
  72. <input type="hidden" name="id" >
  73. <button type="button" class="layui-btn" lay-submit="" lay-filter="submit">{:lang('submit')}</button>
  74. <a href="{:url('adminList')}" class="layui-btn layui-btn-primary">{:lang('back')}</a>
  75. </div>
  76. </div>
  77. </form>
  78. </div>
  79. </div>
  80. </div>
  81. {include file="common/footer"/}
  82. <script>
  83. layui.use(['form', 'layer','upload'], function () {
  84. var form = layui.form, layer = layui.layer,$= layui.jquery,upload = layui.upload;
  85. var info = '';
  86. info = {:json_encode($info)};
  87. form.val("form", info);
  88. console.log(info)
  89. if(info){
  90. $('#addPic').attr('src',info.avatar);
  91. }
  92. form.render();
  93. form.on('submit(submit)', function (data) {
  94. loading =layer.load(1, {shade: [0.1,'#fff']});
  95. $.post("", data.field, function (res) {
  96. layer.close(loading);
  97. if (res.code > 0) {
  98. layer.msg(res.msg, {time: 1800, icon: 1}, function () {
  99. location.href = res.url;
  100. });
  101. } else {
  102. layer.msg(res.msg, {time: 1800, icon: 2});
  103. }
  104. });
  105. });
  106. //普通图片上传
  107. var uploadInt = upload.render({
  108. elem: '#addBtn'
  109. ,url: '{:url("uploads/uploads")}'
  110. ,before: function(obj){
  111. //预读本地文件示例,不支持ie8
  112. obj.preview(function(index, file, result){
  113. $('#addPic').attr('src', result); //图片链接(base64)
  114. });
  115. },
  116. done: function(res){
  117. if(res.code>0){
  118. $('#avatar').val(res.url);
  119. }else{
  120. //如果上传失败
  121. return layer.msg('上传失败');
  122. }
  123. }
  124. ,error: function(){
  125. //演示失败状态,并实现重传
  126. var notice = $('#notice');
  127. notice.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
  128. notice.find('.demo-reload').on('click', function(){
  129. uploadInt.upload();
  130. });
  131. }
  132. });
  133. });
  134. </script>