Admin-.html 13 KB

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