add.html 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. {include file="public/header" /}
  2. <body class="gray-bg">
  3. <div class="layui-fluid layui-col-md12">
  4. <div class="layui-card">
  5. <div class="layui-card-body layui-form">
  6. <div class="layui-row layui-col-space10 layui-form-item ">
  7. <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
  8. <label class="layui-form-label">用户名</label>
  9. <div class="layui-input-block">
  10. <input type="text" name="nickname" lay-verify="required|username" placeholder="请输入用户名" class="layui-input ">
  11. </div>
  12. </div>
  13. <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
  14. <label class="layui-form-label">账号</label>
  15. <div class="layui-input-block">
  16. <input type="text" name="username" lay-verify="required|username" placeholder="请输入账号" class="layui-input ">
  17. </div>
  18. </div>
  19. <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
  20. <label class="layui-form-label">角色</label>
  21. <div class="layui-input-block">
  22. <select name="groupid" lay-verify="required" lay-search="">
  23. <option value="">请选择角色</option>
  24. {if !empty($role)}
  25. {foreach name="role" item="vo"}
  26. <option value="{$vo.id}">{$vo.title}</option>
  27. {/foreach}
  28. {/if}
  29. </select>
  30. </div>
  31. </div>
  32. <!-- <div class="layui-form-item layui-col-md-offset1 layui-col-md8">-->
  33. <!-- <label class="layui-form-label">头像</label>-->
  34. <!-- <div class="layui-input-block">-->
  35. <!-- <input type="hidden" id="data_photo" name="portrait" lay-verify="headCrop">-->
  36. <!-- <div id="fileList" class="uploader-list" style="float:right"></div>-->
  37. <!-- <div style="float:left" class="layui-btn" onclick="wk.layer_show1('上传头像',$('#headCrop'),700);">选择头像</div>-->
  38. <!-- <img id="img_data" class="layui-circle layui-head-img" src="/static/admin/images/head_default.gif" />-->
  39. <!-- </div>-->
  40. <!-- </div>-->
  41. <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
  42. <label class="layui-form-label">密码</label>
  43. <div class="layui-input-block">
  44. <input type="password" name="password" lay-verify="required|pass" placeholder="登录密码" class="layui-input ">
  45. </div>
  46. </div>
  47. <!-- <div class="layui-form-item layui-col-md-offset1 layui-col-md8">-->
  48. <!-- <label class="layui-form-label">真实姓名</label>-->
  49. <!-- <div class="layui-input-block">-->
  50. <!-- <input type="text" name="real_name" lay-verify="required|realname" placeholder="管理员真实姓名" class="layui-input ">-->
  51. <!-- </div>-->
  52. <!-- </div>-->
  53. <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
  54. <label class="layui-form-label">联系电话</label>
  55. <div class="layui-input-block">
  56. <input type="text" name="phone" lay-verify="required|phone" placeholder="联系电话" class="layui-input ">
  57. </div>
  58. </div>
  59. <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
  60. <label class="layui-form-label">邮箱</label>
  61. <div class="layui-input-block">
  62. <input type="text" name="email" lay-verify="required|email" placeholder="邮箱" class="layui-input ">
  63. </div>
  64. </div>
  65. <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
  66. <label class="layui-form-label">状态</label>
  67. <div class="layui-input-block">
  68. <input type="radio" name="status" value="1" title="启用" checked>
  69. <input type="radio" name="status" value="2" title="禁用" >
  70. </div>
  71. </div>
  72. <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
  73. <div class="layui-input-block">
  74. <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="component-form-element">保存
  75. </button>
  76. <button class="layui-btn layui-btn-primary" onclick="wk.layer_close('close')">关闭</button>
  77. </div>
  78. </div>
  79. </div>
  80. </div>
  81. </div>
  82. </div>
  83. {include file="public/footer" /}
  84. <script type="text/javascript" src="__JS__/plugins/cropper/Crop.js"></script>
  85. <script>
  86. //裁剪后的处理
  87. $("#sureCut").on("click",function () {
  88. if ($("#tailoringImg").attr("src") == null ){
  89. layer.msg('请先选择头像',{anim:6})
  90. }else{
  91. var cas = $('#tailoringImg').cropper('getCroppedCanvas');//获取被裁剪后的canvas
  92. var base64url = cas.toDataURL('image/png'); //转换为base64地址形式
  93. $("#img_data").attr('src',base64url).show();
  94. $('#data_photo').val(base64url);
  95. //关闭裁剪框
  96. layer.closeAll();
  97. }
  98. });
  99. </script>
  100. <script>
  101. layui.use(['form'], function() {
  102. var form = layui.form;
  103. form.verify({
  104. username:function(value,item){
  105. if(!/^[\S]{2,10}$/.test(value)){
  106. return '名称必须2到10字符,且不能出现空格';
  107. }
  108. var checkResult = "";
  109. $.ajax({
  110. url:"{:url('User/checkName')}",
  111. type:'post',
  112. data:"username="+value,
  113. async: false,//必须同步
  114. success:function(res){
  115. if(res.code == 100){
  116. checkResult = "该名称已存在";
  117. }
  118. }
  119. })
  120. return checkResult;
  121. },
  122. pass: [/^[\S]{6,16}$/,'密码必须6到16位,且不能出现空格'],
  123. // headCrop:[/^[\S]$/,'头像不能为空'],
  124. // headCrop:function(value,item){
  125. // if(value == ""){
  126. // return '头像不能为空';
  127. // }
  128. // },
  129. realname:[/^[\S]{2,10}$/,'真实姓名必须2到10字符,且不能出现空格']
  130. });
  131. form.on('submit(component-form-element)', function (data) {
  132. $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
  133. $.ajax({
  134. url:"{:url('userAdd')}",
  135. type:'post',
  136. dataType:'json',
  137. data:data.field,
  138. success:function(res){
  139. if (res.code == 200) {
  140. wk.success(res.msg,'wk.layer_close()');
  141. } else {
  142. wk.error(res.msg,'$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\')');
  143. }
  144. }
  145. })
  146. });
  147. });
  148. </script>
  149. </body>
  150. </html>