官网 管理后台
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

1 рік тому
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <!DOCTYPE html>
  2. <html lang="zh-cn">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  7. <title>河南星火燎原软件科技有限公司</title>
  8. <link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
  9. <link rel="stylesheet" href="../librarys/bootstrap@3.4.1/bootstrap.css" />
  10. <link rel="stylesheet" href="../css/comm.css" />
  11. <style>
  12. body {
  13. background-color: #fff;
  14. }
  15. .user_main {
  16. margin: 0 auto;
  17. margin-top: 50px;
  18. width: 1000px;
  19. }
  20. .user_main .table.table-bordered th {
  21. text-align: center;
  22. background-color: #f7f7f7;
  23. }
  24. .user_main .table.table-bordered td {
  25. text-align: center;
  26. background-color: #fff;
  27. }
  28. .user_main .table.table-bordered .action_btn {
  29. margin: 0 10px;
  30. cursor: pointer;
  31. }
  32. .user_main .table.table-bordered .action_show {
  33. display: block;
  34. }
  35. .user_main .table.table-bordered .action_hide {
  36. display: none;
  37. }
  38. </style>
  39. </head>
  40. <body>
  41. <div class="user_main">
  42. <table class="table table-bordered">
  43. <thead>
  44. <tr>
  45. <th>序号</th>
  46. <th>用户姓名</th>
  47. <th>登录账户</th>
  48. <th style="width: 110px">手机号</th>
  49. <th style="width: 70px">状态</th>
  50. <th>创建人姓名</th>
  51. <th style="width: 160px">创建时间</th>
  52. <th style="width: 140px">操作</th>
  53. </tr>
  54. </thead>
  55. <tbody class="userTableBody"></tbody>
  56. </table>
  57. <div class="user_page page_box">
  58. <!-- <div class="page_prev disabled">&lt;</div>
  59. <div data-page="1" class="page_num selected">1</div>
  60. <div class="page_num">2</div>
  61. <div class="page_next">&gt;</div> -->
  62. </div>
  63. </div>
  64. <!-- 修改用户弹窗 -->
  65. <div
  66. class="modal fade"
  67. id="userModifyModal"
  68. tabindex="-1"
  69. role="dialog"
  70. aria-labelledby="modifyTitle"
  71. >
  72. <div class="modal-dialog" role="document">
  73. <div class="modal-content">
  74. <div class="modal-header">
  75. <button
  76. type="button"
  77. class="close"
  78. data-dismiss="modal"
  79. aria-label="Close"
  80. >
  81. <span aria-hidden="true">&times;</span>
  82. </button>
  83. <h4 class="modal-title" id="modifyTitle">修改用户信息</h4>
  84. </div>
  85. <div class="modal-body">确定删除选中信息?</div>
  86. <div class="modal-footer">
  87. <div type="button" class="btn btn-default" data-dismiss="modal">
  88. 关闭
  89. </div>
  90. <div type="button" class="btn btn-primary modify_save">保存</div>
  91. </div>
  92. </div>
  93. </div>
  94. </div>
  95. <!-- 删除用户弹窗 -->
  96. <div
  97. class="modal fade"
  98. id="userDelModal"
  99. tabindex="-1"
  100. role="dialog"
  101. aria-labelledby="delTitle"
  102. >
  103. <div class="modal-dialog tip_modal" role="document">
  104. <div class="modal-content">
  105. <div class="modal-header">
  106. <button
  107. type="button"
  108. class="close"
  109. data-dismiss="modal"
  110. aria-label="Close"
  111. >
  112. <span aria-hidden="true">&times;</span>
  113. </button>
  114. <h4 class="modal-title" id="delTitle">提示</h4>
  115. </div>
  116. <div class="modal-body">确定删除选中信息?</div>
  117. <div class="modal-footer">
  118. <div type="button" class="btn btn-default" data-dismiss="modal">
  119. 关闭
  120. </div>
  121. <div type="button" class="btn btn-primary del_save">保存</div>
  122. </div>
  123. </div>
  124. </div>
  125. </div>
  126. <script src="../librarys/jquery@1.12.4/jquery.min.js"></script>
  127. <script src="../librarys/bootstrap@3.4.1/bootstrap.js"></script>
  128. <script src="../utils/index.js"></script>
  129. <script>
  130. $(function () {
  131. if (!$.isLogin()) {
  132. window.location.href = "/sections/login.html";
  133. return;
  134. }
  135. let userSearch = {
  136. page: 1,
  137. size: 10,
  138. userstate: 1,
  139. username: "",
  140. total: 0,
  141. list: [],
  142. };
  143. // 获取用户列表
  144. function getUserList() {
  145. $.ajax({
  146. type: "POST",
  147. url: $.baseUrl + "user/list",
  148. dataType: "json",
  149. contentType: "application/json; charset=utf-8",
  150. data: JSON.stringify({
  151. page: userSearch.page,
  152. size: userSearch.size,
  153. userstate: userSearch.userstate,
  154. username: userSearch.username,
  155. }),
  156. success: function (data) {
  157. if (data.code === 0) {
  158. userSearch.total = data.obj.total;
  159. userSearch.list = data.obj.list;
  160. console.log("getUserList", data);
  161. setTableHtml();
  162. setPageList();
  163. } else {
  164. userSearch.total = 0;
  165. userSearch.list = [];
  166. alert(data.msg);
  167. }
  168. },
  169. });
  170. }
  171. // 设置页码信息
  172. function setPageList() {
  173. let pageBoxHtml =
  174. '<div class="page_prev ' +
  175. (userSearch.page === 1 ? "disabled" : "") +
  176. '">&lt;</div>';
  177. for (
  178. let _pageIndex = 0;
  179. _pageIndex < Math.ceil(userSearch.total / userSearch.size);
  180. _pageIndex++
  181. ) {
  182. pageBoxHtml +=
  183. '<div data-page="' +
  184. (_pageIndex + 1) +
  185. '" class="page_num ' +
  186. (_pageIndex + 1 === userSearch.page ? "selected" : "") +
  187. '">' +
  188. (_pageIndex + 1) +
  189. "</div>";
  190. }
  191. pageBoxHtml +=
  192. '<div class="page_next ' +
  193. (userSearch.page === Math.ceil(userSearch.total / userSearch.size)
  194. ? "disabled"
  195. : "") +
  196. '">&gt;</div>';
  197. if (userSearch.total > 0) {
  198. $(".user_page.page_box").html(pageBoxHtml);
  199. $(".user_page.page_box").on("click", ".page_prev", function () {
  200. if (userSearch.page > 1) {
  201. userSearch.page--;
  202. }
  203. });
  204. $(".user_page.page_box").on("click", ".page_num", function () {});
  205. $(".user_page.page_box").on("click", ".page_next", function () {});
  206. } else {
  207. $(".user_page.page_box").html("");
  208. }
  209. }
  210. // 设置表格信息
  211. function setTableHtml() {
  212. let userTableBodyHtml = "";
  213. $.each(userSearch.list, function (_userIndex, _userItem) {
  214. userTableBodyHtml +=
  215. "<tr><td>" +
  216. (_userIndex + 1 + (userSearch.page - 1) * userSearch.size) +
  217. "</td><td>" +
  218. (_userItem.username ? _userItem.username : "") +
  219. "</td><td>" +
  220. _userItem.loginname +
  221. "</td><td>" +
  222. (_userItem.userphone ? _userItem.userphone : "") +
  223. "</td><td>" +
  224. (_userItem.userstate === 1 ? "正常" : "已删除") +
  225. "</td><td>" +
  226. (_userItem.createname ? _userItem.createname : "") +
  227. "</td><td>" +
  228. $.dateFormat(_userItem.createtime) +
  229. '</td><td><div class="' +
  230. (_userItem.userstate === 1 ? "action_show" : "action_hide") +
  231. '"><span class="my_theme_color action_btn modify_btn" data-userid="' +
  232. _userItem.userid +
  233. '">修改</span><span class="my_theme_color">|</span><span class="del_color action_btn del_btn" data-userid="' +
  234. _userItem.userid +
  235. '">删除</span></div></td></tr>';
  236. });
  237. $(".userTableBody").html(userTableBodyHtml);
  238. let modify_userid = null;
  239. let del_userid = null;
  240. $(".userTableBody").on("click", ".modify_btn", function () {
  241. $("#userModifyModal").modal("show");
  242. modify_userid = $(this).data("userid");
  243. });
  244. $("#userModifyModal .modify_save").on("click", function () {
  245. console.log("modify_userid", modify_userid);
  246. });
  247. $(".userTableBody").on("click", ".del_btn", function () {
  248. $("#userDelModal").modal("show");
  249. del_userid = $(this).data("userid");
  250. });
  251. $("#userDelModal .del_save").on("click", function () {
  252. $.ajax({
  253. type: "POST",
  254. url: $.baseUrl + "user/del",
  255. dataType: "json",
  256. contentType: "application/json; charset=utf-8",
  257. data: JSON.stringify({
  258. userid: del_userid,
  259. }),
  260. success: function (data) {
  261. $("#userDelModal").modal("hide");
  262. if (data.code === 0) {
  263. getUserList();
  264. } else {
  265. alert(data.msg);
  266. }
  267. },
  268. });
  269. });
  270. }
  271. getUserList();
  272. });
  273. </script>
  274. </body>
  275. </html>