User-.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. <!DOCTYPE html>
  2. <html class="x-admin-sm">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="renderer" content="webkit">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  7. <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
  8. <link rel="shortcut icon" href="https://osscold.baozhida.cn/favicon.ico">
  9. <link rel="bookmark" href="https://osscold.baozhida.cn/favicon.ico">
  10. <link rel="stylesheet" href="https://osscold.baozhida.cn/css/font.css">
  11. <link rel="stylesheet" href="https://osscold.baozhida.cn/css/xadmin.css">
  12. <link rel="stylesheet" href="https://osscold.baozhida.cn/layui/css/layui.css">
  13. <script type="text/javascript" src="https://osscold.baozhida.cn/layui/layui.js" charset="utf-8"></script>
  14. <script type="text/javascript" src="https://osscold.baozhida.cn/js/xadmin.js"></script>
  15. <script src="https://osscold.baozhida.cn/js/pingying.js"></script>
  16. <!-- 让IE8/9支持媒体查询,从而兼容栅格 -->
  17. <!--[if lt IE 9]>
  18. <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
  19. <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
  20. <![endif]--></head>
  21. <body>
  22. <div class="layui-fluid">
  23. <div class="layui-row">
  24. <form class="layui-form">
  25. <div class="layui-form-item" style="margin-top: 20px">
  26. <label for="Admin_name" class="layui-form-label">
  27. <span class="x-red">*</span>名称</label>
  28. <div class="layui-input-inline">
  29. <input {{if gt .id 0 }}
  30. value="{{.Date.Admin_name}}"
  31. {{end}} type="text" onchange="f_onchange()" id="Admin_name" name="Admin_name" required="" lay-verify="required" autocomplete="off" class="layui-input">
  32. </div>
  33. </div>
  34. <div class="layui-form-item">
  35. <label class="layui-form-label">
  36. <span class="x-red">*</span>权限</label>
  37. <div class="layui-input-inline">
  38. <select lay-filter="Admin_power" id="Admin_power" name="Admin_power" class="valid" >
  39. {{range $index, $elem := .Power_List}}
  40. <option value="{{$elem.Id}}" {{if gt $.id 0 }}
  41. {{if eq $.Date.Admin_power $elem.Id }}
  42. selected
  43. {{end}}
  44. {{end}}
  45. >{{$elem.Power_name}}</option>
  46. {{end}}
  47. </select>
  48. </div>
  49. </div>
  50. {{if eq .id 0 }}
  51. <div class="layui-form-item">
  52. <label for="Admin_user" class="layui-form-label">
  53. <span class="x-red">*</span>账号</label>
  54. <div class="layui-input-inline">
  55. <input {{if gt .id 0 }}
  56. value="{{.Date.Admin_user}}"
  57. {{end}} id="Admin_user" name="Admin_user" style="color: #1A1B20" class="layui-input " type="text" required="" autocomplete="off" ></div>
  58. </div>
  59. <div class="layui-form-item">
  60. <label class="layui-form-label">
  61. <span class="x-red">*</span>密码</label>
  62. <div class="layui-input-inline">
  63. <input disabled readonly class="layui-input layui-disabled"
  64. value="密码会自动生成"
  65. type="text" required="" autocomplete="off" class="layui-input">
  66. </div>
  67. </div>
  68. {{end}}
  69. <div class="layui-form-item">
  70. <label class="layui-form-label">性别</label>
  71. <div class="layui-input-inline">
  72. <select id="Admin_gender" name="Admin_gender" class="valid" >
  73. <option value="0" {{if gt $.id 0 }}
  74. {{if eq 0 .Date.Admin_gender }}
  75. selected
  76. {{end}}
  77. {{end}}
  78. >未知</option>
  79. <option value="1" {{if gt $.id 0 }}
  80. {{if eq 1 .Date.Admin_gender }}
  81. selected
  82. {{end}}
  83. {{end}}
  84. >男</option>
  85. <option value="2" {{if gt $.id 0 }}
  86. {{if eq 2 .Date.Admin_gender }}
  87. selected
  88. {{end}}
  89. {{end}}
  90. >女</option>
  91. </select>
  92. </div>
  93. </div>
  94. <div class="layui-form-item">
  95. <label for="Admin_telephone" class="layui-form-label">电话</label>
  96. <div class="layui-input-inline">
  97. <input {{if gt .id 0 }}
  98. value="{{.Date.Admin_telephone}}"
  99. {{end}} type="text" id="Admin_telephone" name="Admin_telephone" required="" autocomplete="off" class="layui-input">
  100. </div>
  101. </div>
  102. <div class="layui-form-item">
  103. <label for="Admin_mail" class="layui-form-label">邮箱</label>
  104. <div class="layui-input-inline">
  105. <input {{if gt .id 0 }}
  106. value="{{.Date.Admin_mail}}"
  107. {{end}} type="text" id="Admin_mail" name="Admin_mail" required="" autocomplete="off" class="layui-input">
  108. </div>
  109. </div>
  110. <div class="layui-form-item">
  111. <label for="Admin_text" class="layui-form-label">
  112. 备注</label>
  113. <div class="layui-input-inline">
  114. <input {{if gt .id 0 }}
  115. value="{{.Date.Admin_text}}"
  116. {{end}} type="text" id="Admin_text" name="Admin_text" required="" autocomplete="off" class="layui-input">
  117. </div>
  118. </div>
  119. <div class="layui-form-item" style="text-align: center;margin-top: 20px">
  120. <!-- <label for="L_repass" class="layui-form-label"></label>-->
  121. <button class="layui-btn layui-btn-normal" lay-filter="add" lay-submit="">提交</button></div>
  122. </form>
  123. </div>
  124. </div>
  125. <script>
  126. function f_onchange() {
  127. $("#Admin_user").val(codefans_net_CC2PY($("#Admin_name").val()))
  128. }
  129. layui.use(['form', 'layer',"layedit"],
  130. function() {
  131. $ = layui.jquery;
  132. var form = layui.form,
  133. layer = layui.layer;
  134. var layedit = layui.layedit
  135. layedit.set({
  136. uploadImage: {
  137. url: '/UpFile' //接口url
  138. }
  139. });
  140. //构建一个默认的编辑器
  141. var index = layedit.build('T_text', {
  142. height: 580 //设置编辑器高度,
  143. });
  144. //监听提交
  145. form.on('submit(add)',
  146. function(data) {
  147. console.log("=== submit(add) ==");
  148. console.log(data);
  149. $.ajax({
  150. type: 'POST',
  151. url: 'User_Post',//发送请求
  152. data: {
  153. Admin_uuid:"{{.Admin_uuid}}",
  154. Admin_name:data.field.Admin_name,
  155. Admin_power:data.field.Admin_power,
  156. Admin_user:data.field.Admin_user,
  157. Admin_telephone:data.field.Admin_telephone,
  158. Admin_mail:data.field.Admin_mail,
  159. Admin_gender:data.field.Admin_gender,
  160. Admin_text:data.field.Admin_text,
  161. },
  162. success: function(result) {
  163. console.log(result)
  164. if(result.Code == 200){
  165. layer.msg("操作成功", {
  166. icon: 1,
  167. time: 2000
  168. });
  169. //关闭当前frame
  170. parent.layer.close(parent.layer.getFrameIndex(window.name));
  171. parent.location.reload();
  172. form.render('select');
  173. }else if(result.Code == 210){
  174. layer.alert(
  175. "生成密码:"+result.Data,
  176. {icon: 6,closeBtn: 0 ,title: "请保管好密码,后期无法呈现"},
  177. function () {
  178. //关闭当前frame
  179. parent.layer.close(parent.layer.getFrameIndex(window.name));
  180. parent.location.reload();
  181. form.render('select');
  182. });
  183. }else {
  184. layer.msg("错误:"+result.Msg, {
  185. icon: 2,
  186. time: 2000
  187. });
  188. }
  189. //
  190. // return false;
  191. }
  192. });
  193. return false;
  194. });
  195. });
  196. </script>
  197. <script>
  198. layui.use('upload', function(){
  199. var $ = layui.jquery
  200. ,upload = layui.upload;
  201. //普通图片上传
  202. var uploadInst = upload.render({
  203. elem: '#test1'
  204. ,url: '/UpFile' //改成您自己的上传接口
  205. ,before: function(obj){
  206. //预读本地文件示例,不支持ie8
  207. obj.preview(function(index, file, result){
  208. $('#demo1').attr('src', result); //图片链接(base64)
  209. });
  210. }
  211. ,done: function(res){
  212. console.log(res)
  213. //如果上传失败
  214. if(res.code != 0){
  215. return layer.msg('上传失败');
  216. }
  217. T_img = res.data.src
  218. console.log(T_img)
  219. //上传成功
  220. }
  221. ,error: function(){
  222. console.log("error")
  223. //演示失败状态,并实现重传
  224. var demoText = $('#demoText');
  225. demoText.html('<span style="color: #ff5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
  226. demoText.find('.demo-reload').on('click', function(){
  227. uploadInst.upload();
  228. });
  229. }
  230. });
  231. //绑定原始文件域
  232. upload.render({
  233. elem: '#test20'
  234. ,url: 'https://httpbin.org/post' //改成您自己的上传接口
  235. ,done: function(res){
  236. layer.msg('上传成功');
  237. console.log(res)
  238. }
  239. });
  240. });
  241. </script>
  242. </body>
  243. </html>