user-management.html 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585
  1. <!DOCTYPE html>
  2. <html lang="zh-CN" class="iframe-content">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>用户管理 - 爱智农</title>
  7. <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css">
  8. <link rel="stylesheet" href="https://at.alicdn.com/t/font_3114978_qe0b39no76.css">
  9. <link rel="stylesheet" href="../assets/css/global.css">
  10. <style>
  11. body {
  12. font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  13. background-color: #f5f7f9;
  14. color: #333;
  15. }
  16. .page-container {
  17. padding: 20px;
  18. }
  19. .card {
  20. background-color: white;
  21. border-radius: 8px;
  22. box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  23. }
  24. .table-container {
  25. overflow-x: auto;
  26. }
  27. table {
  28. width: 100%;
  29. border-collapse: collapse;
  30. }
  31. th {
  32. background-color: #f9fafb;
  33. padding: 12px 16px;
  34. text-align: left;
  35. font-weight: 500;
  36. color: #6b7280;
  37. border-bottom: 1px solid #e5e7eb;
  38. }
  39. td {
  40. padding: 12px 16px;
  41. border-bottom: 1px solid #e5e7eb;
  42. }
  43. tr:hover {
  44. background-color: #f9fafb;
  45. }
  46. .btn {
  47. display: inline-flex;
  48. align-items: center;
  49. justify-content: center;
  50. padding: 8px 16px;
  51. border-radius: 4px;
  52. font-weight: 500;
  53. cursor: pointer;
  54. transition: all 0.2s;
  55. }
  56. .btn-primary {
  57. background-color: #4CAF50;
  58. color: white;
  59. }
  60. .btn-primary:hover {
  61. background-color: #388E3C;
  62. }
  63. .btn-default {
  64. background-color: white;
  65. border: 1px solid #d1d5db;
  66. color: #374151;
  67. }
  68. .btn-default:hover {
  69. background-color: #f9fafb;
  70. }
  71. .btn-danger {
  72. background-color: #ef4444;
  73. color: white;
  74. }
  75. .btn-danger:hover {
  76. background-color: #dc2626;
  77. }
  78. .btn-sm {
  79. padding: 4px 8px;
  80. font-size: 12px;
  81. }
  82. .btn-icon {
  83. margin-right: 4px;
  84. }
  85. .search-box {
  86. display: flex;
  87. gap: 8px;
  88. }
  89. .input {
  90. padding: 8px 12px;
  91. border: 1px solid #d1d5db;
  92. border-radius: 4px;
  93. flex-grow: 1;
  94. }
  95. .input:focus {
  96. outline: none;
  97. border-color: #4CAF50;
  98. box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
  99. }
  100. .select {
  101. padding: 8px 12px;
  102. border: 1px solid #d1d5db;
  103. border-radius: 4px;
  104. background-color: white;
  105. }
  106. .modal-overlay {
  107. position: fixed;
  108. top: 0;
  109. left: 0;
  110. right: 0;
  111. bottom: 0;
  112. background-color: rgba(0, 0, 0, 0.5);
  113. display: flex;
  114. align-items: center;
  115. justify-content: center;
  116. z-index: 50;
  117. display: none;
  118. }
  119. .modal {
  120. background-color: white;
  121. border-radius: 8px;
  122. width: 100%;
  123. max-width: 500px;
  124. box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  125. }
  126. .modal-header {
  127. padding: 16px 24px;
  128. border-bottom: 1px solid #e5e7eb;
  129. display: flex;
  130. align-items: center;
  131. justify-content: space-between;
  132. }
  133. .modal-title {
  134. font-size: 18px;
  135. font-weight: 500;
  136. }
  137. .modal-close {
  138. cursor: pointer;
  139. font-size: 20px;
  140. }
  141. .modal-body {
  142. padding: 24px;
  143. }
  144. .modal-footer {
  145. padding: 16px 24px;
  146. border-top: 1px solid #e5e7eb;
  147. display: flex;
  148. justify-content: flex-end;
  149. gap: 8px;
  150. }
  151. .form-group {
  152. margin-bottom: 16px;
  153. }
  154. .form-label {
  155. display: block;
  156. margin-bottom: 4px;
  157. font-weight: 500;
  158. }
  159. .form-input {
  160. width: 100%;
  161. padding: 8px 12px;
  162. border: 1px solid #d1d5db;
  163. border-radius: 4px;
  164. }
  165. .form-input:focus {
  166. outline: none;
  167. border-color: #4CAF50;
  168. box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
  169. }
  170. .badge {
  171. display: inline-block;
  172. padding: 2px 8px;
  173. border-radius: 9999px;
  174. font-size: 12px;
  175. font-weight: 500;
  176. }
  177. .badge-success {
  178. background-color: #d1fae5;
  179. color: #065f46;
  180. }
  181. .badge-warning {
  182. background-color: #fef3c7;
  183. color: #92400e;
  184. }
  185. .pagination {
  186. display: flex;
  187. align-items: center;
  188. justify-content: flex-end;
  189. gap: 4px;
  190. }
  191. .pagination-item {
  192. display: inline-flex;
  193. align-items: center;
  194. justify-content: center;
  195. width: 32px;
  196. height: 32px;
  197. border-radius: 4px;
  198. cursor: pointer;
  199. transition: all 0.2s;
  200. }
  201. .pagination-item:hover {
  202. background-color: #f3f4f6;
  203. }
  204. .pagination-item.active {
  205. background-color: #4CAF50;
  206. color: white;
  207. }
  208. .pagination-item.disabled {
  209. color: #9ca3af;
  210. cursor: not-allowed;
  211. }
  212. </style>
  213. </head>
  214. <body>
  215. <div class="page-container responsive-container">
  216. <div class="flex justify-between items-center mb-6">
  217. <h1 class="text-2xl font-bold">用户管理</h1>
  218. <button class="btn btn-primary" id="addUserBtn">
  219. <i class="iconfont icon-plus btn-icon"></i>
  220. 新增用户
  221. </button>
  222. </div>
  223. <div class="card p-6 mb-6">
  224. <div class="flex flex-wrap gap-4">
  225. <div class="search-box flex-grow">
  226. <input type="text" class="input" placeholder="请输入用户名/姓名/手机号">
  227. <button class="btn btn-primary">
  228. <i class="iconfont icon-search btn-icon"></i>
  229. 搜索
  230. </button>
  231. <button class="btn btn-default">
  232. <i class="iconfont icon-reload btn-icon"></i>
  233. 重置
  234. </button>
  235. </div>
  236. <div class="flex gap-2">
  237. <select class="select">
  238. <option value="">所有角色</option>
  239. <option value="admin">管理员</option>
  240. <option value="operator">操作员</option>
  241. <option value="viewer">查看者</option>
  242. </select>
  243. <select class="select">
  244. <option value="">所有状态</option>
  245. <option value="1">启用</option>
  246. <option value="0">禁用</option>
  247. </select>
  248. </div>
  249. </div>
  250. </div>
  251. <div class="card">
  252. <div class="table-container">
  253. <table>
  254. <thead>
  255. <tr>
  256. <th>用户名</th>
  257. <th>姓名</th>
  258. <th>手机号</th>
  259. <th>邮箱</th>
  260. <th>角色</th>
  261. <th>部门</th>
  262. <th>状态</th>
  263. <th>创建时间</th>
  264. <th>操作</th>
  265. </tr>
  266. </thead>
  267. <tbody>
  268. <tr>
  269. <td>admin</td>
  270. <td>系统管理员</td>
  271. <td>13800138000</td>
  272. <td>admin@aizhinong.com</td>
  273. <td>管理员</td>
  274. <td>技术部</td>
  275. <td><span class="badge badge-success">启用</span></td>
  276. <td>2023-01-01 12:00:00</td>
  277. <td>
  278. <div class="flex gap-2">
  279. <button class="btn btn-default btn-sm edit-btn" data-id="1">
  280. <i class="iconfont icon-edit btn-icon"></i>
  281. 编辑
  282. </button>
  283. <button class="btn btn-danger btn-sm">
  284. <i class="iconfont icon-delete btn-icon"></i>
  285. 删除
  286. </button>
  287. </div>
  288. </td>
  289. </tr>
  290. <tr>
  291. <td>operator</td>
  292. <td>张三</td>
  293. <td>13900139000</td>
  294. <td>zhangsan@aizhinong.com</td>
  295. <td>操作员</td>
  296. <td>运营部</td>
  297. <td><span class="badge badge-success">启用</span></td>
  298. <td>2023-01-02 10:30:00</td>
  299. <td>
  300. <div class="flex gap-2">
  301. <button class="btn btn-default btn-sm edit-btn" data-id="2">
  302. <i class="iconfont icon-edit btn-icon"></i>
  303. 编辑
  304. </button>
  305. <button class="btn btn-danger btn-sm">
  306. <i class="iconfont icon-delete btn-icon"></i>
  307. 删除
  308. </button>
  309. </div>
  310. </td>
  311. </tr>
  312. <tr>
  313. <td>viewer</td>
  314. <td>李四</td>
  315. <td>13700137000</td>
  316. <td>lisi@aizhinong.com</td>
  317. <td>查看者</td>
  318. <td>市场部</td>
  319. <td><span class="badge badge-warning">禁用</span></td>
  320. <td>2023-01-03 09:15:00</td>
  321. <td>
  322. <div class="flex gap-2">
  323. <button class="btn btn-default btn-sm edit-btn" data-id="3">
  324. <i class="iconfont icon-edit btn-icon"></i>
  325. 编辑
  326. </button>
  327. <button class="btn btn-danger btn-sm">
  328. <i class="iconfont icon-delete btn-icon"></i>
  329. 删除
  330. </button>
  331. </div>
  332. </td>
  333. </tr>
  334. <tr>
  335. <td>tester</td>
  336. <td>王五</td>
  337. <td>13600136000</td>
  338. <td>wangwu@aizhinong.com</td>
  339. <td>操作员</td>
  340. <td>测试部</td>
  341. <td><span class="badge badge-success">启用</span></td>
  342. <td>2023-01-04 14:20:00</td>
  343. <td>
  344. <div class="flex gap-2">
  345. <button class="btn btn-default btn-sm edit-btn" data-id="4">
  346. <i class="iconfont icon-edit btn-icon"></i>
  347. 编辑
  348. </button>
  349. <button class="btn btn-danger btn-sm">
  350. <i class="iconfont icon-delete btn-icon"></i>
  351. 删除
  352. </button>
  353. </div>
  354. </td>
  355. </tr>
  356. <tr>
  357. <td>guest</td>
  358. <td>访客</td>
  359. <td>13500135000</td>
  360. <td>guest@aizhinong.com</td>
  361. <td>查看者</td>
  362. <td>-</td>
  363. <td><span class="badge badge-success">启用</span></td>
  364. <td>2023-01-05 16:45:00</td>
  365. <td>
  366. <div class="flex gap-2">
  367. <button class="btn btn-default btn-sm edit-btn" data-id="5">
  368. <i class="iconfont icon-edit btn-icon"></i>
  369. 编辑
  370. </button>
  371. <button class="btn btn-danger btn-sm">
  372. <i class="iconfont icon-delete btn-icon"></i>
  373. 删除
  374. </button>
  375. </div>
  376. </td>
  377. </tr>
  378. </tbody>
  379. </table>
  380. </div>
  381. <div class="p-4 flex justify-between items-center">
  382. <div class="text-sm text-gray-500">
  383. 共 <span class="font-medium">5</span> 条记录,每页 <span class="font-medium">10</span> 条
  384. </div>
  385. <div class="pagination">
  386. <div class="pagination-item disabled">
  387. <i class="iconfont icon-left"></i>
  388. </div>
  389. <div class="pagination-item active">1</div>
  390. <div class="pagination-item">2</div>
  391. <div class="pagination-item">3</div>
  392. <div class="pagination-item">
  393. <i class="iconfont icon-right"></i>
  394. </div>
  395. </div>
  396. </div>
  397. </div>
  398. </div>
  399. <!-- 用户表单弹窗 -->
  400. <div class="modal-overlay" id="userModal">
  401. <div class="modal">
  402. <div class="modal-header">
  403. <h3 class="modal-title" id="modalTitle">新增用户</h3>
  404. <div class="modal-close" id="closeModal">&times;</div>
  405. </div>
  406. <div class="modal-body">
  407. <form id="userForm">
  408. <div class="form-group">
  409. <label class="form-label" for="username">用户名</label>
  410. <input type="text" id="username" class="form-input" placeholder="请输入用户名">
  411. </div>
  412. <div class="form-group">
  413. <label class="form-label" for="realname">姓名</label>
  414. <input type="text" id="realname" class="form-input" placeholder="请输入姓名">
  415. </div>
  416. <div class="form-group">
  417. <label class="form-label" for="password">密码</label>
  418. <input type="password" id="password" class="form-input" placeholder="请输入密码">
  419. </div>
  420. <div class="form-group">
  421. <label class="form-label" for="phone">手机号</label>
  422. <input type="text" id="phone" class="form-input" placeholder="请输入手机号">
  423. </div>
  424. <div class="form-group">
  425. <label class="form-label" for="email">邮箱</label>
  426. <input type="email" id="email" class="form-input" placeholder="请输入邮箱">
  427. </div>
  428. <div class="form-group">
  429. <label class="form-label" for="role">角色</label>
  430. <select id="role" class="form-input">
  431. <option value="">请选择角色</option>
  432. <option value="admin">管理员</option>
  433. <option value="operator">操作员</option>
  434. <option value="viewer">查看者</option>
  435. </select>
  436. </div>
  437. <div class="form-group">
  438. <label class="form-label" for="department">部门</label>
  439. <select id="department" class="form-input">
  440. <option value="">请选择部门</option>
  441. <option value="tech">技术部</option>
  442. <option value="operation">运营部</option>
  443. <option value="market">市场部</option>
  444. <option value="test">测试部</option>
  445. </select>
  446. </div>
  447. <div class="form-group">
  448. <label class="form-label" for="status">状态</label>
  449. <select id="status" class="form-input">
  450. <option value="1">启用</option>
  451. <option value="0">禁用</option>
  452. </select>
  453. </div>
  454. <div class="form-group">
  455. <label class="form-label" for="remark">备注</label>
  456. <textarea id="remark" class="form-input" rows="3" placeholder="请输入备注信息"></textarea>
  457. </div>
  458. </form>
  459. </div>
  460. <div class="modal-footer">
  461. <button class="btn btn-default" id="cancelBtn">取消</button>
  462. <button class="btn btn-primary" id="saveBtn">保存</button>
  463. </div>
  464. </div>
  465. </div>
  466. <script>
  467. document.addEventListener('DOMContentLoaded', function() {
  468. const userModal = document.getElementById('userModal');
  469. const modalTitle = document.getElementById('modalTitle');
  470. const addUserBtn = document.getElementById('addUserBtn');
  471. const closeModal = document.getElementById('closeModal');
  472. const cancelBtn = document.getElementById('cancelBtn');
  473. const saveBtn = document.getElementById('saveBtn');
  474. const editBtns = document.querySelectorAll('.edit-btn');
  475. const userForm = document.getElementById('userForm');
  476. // 打开新增用户弹窗
  477. addUserBtn.addEventListener('click', function() {
  478. modalTitle.textContent = '新增用户';
  479. userForm.reset();
  480. userModal.style.display = 'flex';
  481. });
  482. // 打开编辑用户弹窗
  483. editBtns.forEach(btn => {
  484. btn.addEventListener('click', function() {
  485. const userId = this.getAttribute('data-id');
  486. modalTitle.textContent = '编辑用户';
  487. // 模拟获取用户数据
  488. // 实际应用中应该通过API获取
  489. if (userId === '1') {
  490. document.getElementById('username').value = 'admin';
  491. document.getElementById('realname').value = '系统管理员';
  492. document.getElementById('phone').value = '13800138000';
  493. document.getElementById('email').value = 'admin@aizhinong.com';
  494. document.getElementById('role').value = 'admin';
  495. document.getElementById('department').value = 'tech';
  496. document.getElementById('status').value = '1';
  497. }
  498. userModal.style.display = 'flex';
  499. });
  500. });
  501. // 关闭弹窗
  502. function closeUserModal() {
  503. userModal.style.display = 'none';
  504. }
  505. closeModal.addEventListener('click', closeUserModal);
  506. cancelBtn.addEventListener('click', closeUserModal);
  507. // 保存用户
  508. saveBtn.addEventListener('click', function() {
  509. // 模拟保存
  510. alert('用户信息保存成功!');
  511. closeUserModal();
  512. });
  513. // 点击弹窗外部关闭弹窗
  514. userModal.addEventListener('click', function(e) {
  515. if (e.target === userModal) {
  516. closeUserModal();
  517. }
  518. });
  519. });
  520. </script>
  521. </body>
  522. </html>