useradmin.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. /** layuiAdmin.pro-v1.2.1 LPPL License By http://www.layui.com/admin/ */
  2. ;
  3. layui.define(["table", "form"],
  4. function(e) {
  5. var i = (layui.$, layui.admin),
  6. t = layui.view,
  7. l = layui.table,
  8. r = layui.form;
  9. l.render({
  10. elem: "#LAY-user-manage",
  11. url: "./json/useradmin/webuser.js",
  12. cols: [[{
  13. type: "checkbox",
  14. fixed: "left"
  15. },
  16. {
  17. field: "id",
  18. width: 100,
  19. title: "ID",
  20. sort: !0
  21. },
  22. {
  23. field: "username",
  24. title: "用户名",
  25. minWidth: 100
  26. },
  27. {
  28. field: "avatar",
  29. title: "头像",
  30. width: 100,
  31. templet: "#imgTpl"
  32. },
  33. {
  34. field: "phone",
  35. title: "手机"
  36. },
  37. {
  38. field: "email",
  39. title: "邮箱"
  40. },
  41. {
  42. field: "sex",
  43. width: 80,
  44. title: "性别"
  45. },
  46. {
  47. field: "ip",
  48. title: "IP"
  49. },
  50. {
  51. field: "jointime",
  52. title: "加入时间",
  53. sort: !0
  54. },
  55. {
  56. title: "操作",
  57. width: 150,
  58. align: "center",
  59. fixed: "right",
  60. toolbar: "#table-useradmin-webuser"
  61. }]],
  62. page: !0,
  63. limit: 30,
  64. height: "full-320",
  65. text: "对不起,加载出现异常!"
  66. }),
  67. l.on("tool(LAY-user-manage)",
  68. function(e) {
  69. var l = e.data;
  70. "del" === e.event ? layer.prompt({
  71. formType: 1,
  72. title: "敏感操作,请验证口令"
  73. },
  74. function(i, t) {
  75. layer.close(t),
  76. layer.confirm("真的删除行么",
  77. function(i) {
  78. e.del(),
  79. layer.close(i)
  80. })
  81. }) : "edit" === e.event && i.popup({
  82. title: "编辑用户",
  83. area: ["500px", "450px"],
  84. id: "LAY-popup-user-add",
  85. success: function(e, i) {
  86. t(this.id).render("user/user/userform", l).done(function() {
  87. r.render(null, "layuiadmin-form-useradmin"),
  88. r.on("submit(LAY-user-front-submit)",
  89. function(e) {
  90. e.field;
  91. layui.table.reload("LAY-user-manage"),
  92. layer.close(i)
  93. })
  94. })
  95. }
  96. })
  97. }),
  98. l.render({
  99. elem: "#LAY-user-back-manage",
  100. url: "./json/useradmin/mangadmin.js",
  101. cols: [[{
  102. type: "checkbox",
  103. fixed: "left"
  104. },
  105. {
  106. field: "id",
  107. width: 80,
  108. title: "ID",
  109. sort: !0
  110. },
  111. {
  112. field: "loginname",
  113. title: "登录名"
  114. },
  115. {
  116. field: "telphone",
  117. title: "手机"
  118. },
  119. {
  120. field: "email",
  121. title: "邮箱"
  122. },
  123. {
  124. field: "role",
  125. title: "角色"
  126. },
  127. {
  128. field: "jointime",
  129. title: "加入时间",
  130. sort: !0
  131. },
  132. {
  133. field: "check",
  134. title: "审核状态",
  135. templet: "#buttonTpl",
  136. minWidth: 80,
  137. align: "center"
  138. },
  139. {
  140. title: "操作",
  141. width: 150,
  142. align: "center",
  143. fixed: "right",
  144. toolbar: "#table-useradmin-admin"
  145. }]],
  146. text: "对不起,加载出现异常!"
  147. }),
  148. l.on("tool(LAY-user-back-manage)",
  149. function(e) {
  150. var l = e.data;
  151. "del" === e.event ? layer.prompt({
  152. formType: 1,
  153. title: "敏感操作,请验证口令"
  154. },
  155. function(i, t) {
  156. layer.close(t),
  157. layer.confirm("确定删除此管理员?",
  158. function(i) {
  159. console.log(e),
  160. e.del(),
  161. layer.close(i)
  162. })
  163. }) : "edit" === e.event && i.popup({
  164. title: "编辑管理员",
  165. area: ["420px", "450px"],
  166. id: "LAY-popup-user-add",
  167. success: function(e, i) {
  168. t(this.id).render("user/administrators/adminform", l).done(function() {
  169. r.render(null, "layuiadmin-form-admin"),
  170. r.on("submit(LAY-user-back-submit)",
  171. function(e) {
  172. e.field;
  173. layui.table.reload("LAY-user-back-manage"),
  174. layer.close(i)
  175. })
  176. })
  177. }
  178. })
  179. }),
  180. l.render({
  181. elem: "#LAY-user-back-role",
  182. // url: "./json/useradmin/role.js",
  183. url: "/login/getUser",
  184. cols: [[{
  185. type: "checkbox",
  186. fixed: "left"
  187. },
  188. {
  189. field: "id",
  190. width: 80,
  191. title: "ID",
  192. sort: !0
  193. },
  194. {
  195. field: "name",
  196. title: "名称"
  197. },
  198. {
  199. field: "username",
  200. title: "账号"
  201. },
  202. {
  203. field: "position",
  204. title: "拥有权限"
  205. },
  206. {
  207. title: "操作",
  208. width: 150,
  209. align: "center",
  210. fixed: "right",
  211. toolbar: "#table-useradmin-admin"
  212. }]],
  213. text: "对不起,加载出现异常!"
  214. }),
  215. l.on("tool(LAY-user-back-role)",
  216. function(e) {
  217. // console.log(e)
  218. var l = e.data;
  219. "del" === e.event ? layer.confirm("确定删除此角色?",
  220. function(i) {
  221. e.del(),
  222. console.log(e.data);
  223. layui.admin.req({
  224. url:'/login/delUser',
  225. type:'post',
  226. data:e.data,
  227. dataType:'json',
  228. traditional:true,
  229. done:function (err) {
  230. layer.close(i)
  231. }
  232. })
  233. // layer.close(i)
  234. }) : "edit" === e.event && i.popup({
  235. title: "编辑角色",
  236. area: ["500px", "480px"],
  237. id: "LAY-popup-user-add",
  238. success: function(e, i) {
  239. t(this.id).render("user/administrators/roleform", l).done(function() {
  240. r.render(null, "layuiadmin-form-role"),
  241. r.on("submit(LAY-user-role-submit)",
  242. function(e) {
  243. e.field;
  244. // console.log(e)//编辑角色传参
  245. layui.admin.req({
  246. url:'/login/updateUser',
  247. data:e.field,
  248. dataType:'json',
  249. traditional:true,
  250. type:'post',
  251. done:function (err) {
  252. // console.log(err)
  253. layui.table.reload("LAY-user-back-role"),
  254. layer.close(i)
  255. }
  256. })
  257. })
  258. })
  259. }
  260. })
  261. }),
  262. e("useradmin", {})
  263. });