| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731 |
- <!DOCTYPE html>
- <html lang="zh-CN" class="iframe-content">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>用户管理 - 爱智农</title>
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css">
- <link rel="stylesheet" href="https://at.alicdn.com/t/font_3114978_qe0b39no76.css">
- <link rel="stylesheet" href="../assets/css/global.css">
- <style>
- body {
- font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
- background-color: #f5f7f9;
- color: #333;
- }
-
- .page-container {
- padding: 20px;
- }
-
- .card {
- background-color: white;
- border-radius: 8px;
- box-shadow: 0 2px 8px rgba(0,0,0,0.05);
- }
-
- .table-container {
- position: relative;
- position: relative;
- overflow-x: auto;
- position: relative;
- }
-
- table {
- width: 100%;
- border-collapse: separate;
- border-spacing: 0;
- }
-
- th {
- white-space: nowrap;
- position: relative;
- overflow: visible;
- max-width: none;
- text-overflow: clip;
- white-space: nowrap;
- position: relative;
- background-color: #f9fafb;
- padding: 12px 16px;
- text-align: left;
- font-weight: 500;
- color: #6b7280;
- border-bottom: 1px solid #e5e7eb;
- white-space: nowrap;
- position: relative;
- }
-
- td {
- white-space: nowrap;
- max-width: 200px;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- max-width: 200px;
- overflow: hidden;
- text-overflow: ellipsis;
- padding: 12px 16px;
- border-bottom: 1px solid #e5e7eb;
- white-space: nowrap;
- max-width: 200px;
- overflow: hidden;
- text-overflow: ellipsis;
- }
-
- /* 固定最后一列(操作列)样式 */
- .table-fixed-right {
- position: relative;
- }
-
- .table-fixed-right th:last-child,
- .table-fixed-right td:last-child {
- position: sticky;
- right: 0;
- z-index: 2;
- background-color: white;
- box-shadow: -5px 0 5px -5px rgba(0, 0, 0, 0.1);
- }
-
- .table-fixed-right th:last-child {
- background-color: #f9fafb;
- }
-
- /* 表格滚动控件 */
- .table-scroll-controls {
- display: none;
- position: absolute;
- top: 50%;
- transform: translateY(-50%);
- width: 100%;
- pointer-events: none;
- z-index: 3;
- }
-
- .table-scroll-btn {
- position: absolute;
- width: 32px;
- height: 32px;
- border-radius: 50%;
- background-color: rgba(255, 255, 255, 0.9);
- color: #4CAF50;
- border: 1px solid #e0e0e0;
- display: flex;
- align-items: center;
- justify-content: center;
- cursor: pointer;
- pointer-events: auto;
- box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
- z-index: 4;
- }
-
- .table-scroll-left {
- left: 10px;
- }
-
- .table-scroll-right {
- right: 10px;
- }
-
- .has-overflow .table-scroll-controls {
- display: block;
- }
-
- tr:hover {
- background-color: #f9fafb;
- }
-
- tr:hover td:last-child {
- background-color: #f9fafb;
- }
-
- .btn {
- display: inline-flex;
- align-items: center;
- justify-content: center;
- padding: 8px 16px;
- border-radius: 4px;
- font-weight: 500;
- cursor: pointer;
- transition: all 0.2s;
- }
-
- .btn-primary {
- background-color: #4CAF50;
- color: white;
- }
-
- .btn-primary:hover {
- background-color: #388E3C;
- }
-
- .btn-default {
- background-color: white;
- border: 1px solid #d1d5db;
- color: #374151;
- }
-
- .btn-default:hover {
- background-color: #f9fafb;
- }
-
- .btn-danger {
- background-color: #ef4444;
- color: white;
- }
-
- .btn-danger:hover {
- background-color: #dc2626;
- }
-
- .btn-sm {
- padding: 4px 8px;
- font-size: 12px;
- }
-
- .btn-icon {
- margin-right: 4px;
- }
-
- .search-box {
- display: flex;
- gap: 8px;
- }
-
- .input {
- padding: 8px 12px;
- border: 1px solid #d1d5db;
- border-radius: 4px;
- flex-grow: 1;
- }
-
- .input:focus {
- outline: none;
- border-color: #4CAF50;
- box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
- }
-
- .select {
- padding: 8px 12px;
- border: 1px solid #d1d5db;
- border-radius: 4px;
- background-color: white;
- }
-
- .modal-overlay {
- position: fixed;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- background-color: rgba(0, 0, 0, 0.5);
- display: flex;
- align-items: center;
- justify-content: center;
- z-index: 50;
- display: none;
- }
-
- .modal {
- background-color: white;
- border-radius: 8px;
- width: 100%;
- max-width: 500px;
- box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
- }
-
- .modal-header {
- padding: 16px 24px;
- border-bottom: 1px solid #e5e7eb;
- display: flex;
- align-items: center;
- justify-content: space-between;
- }
-
- .modal-title {
- font-size: 18px;
- font-weight: 500;
- }
-
- .modal-close {
- cursor: pointer;
- font-size: 20px;
- }
-
- .modal-body {
- padding: 24px;
- }
-
- .modal-footer {
- padding: 16px 24px;
- border-top: 1px solid #e5e7eb;
- display: flex;
- justify-content: flex-end;
- gap: 8px;
- }
-
- .form-group {
- margin-bottom: 16px;
- }
-
- .form-label {
- display: block;
- margin-bottom: 4px;
- font-weight: 500;
- }
-
- .form-input {
- width: 100%;
- padding: 8px 12px;
- border: 1px solid #d1d5db;
- border-radius: 4px;
- }
-
- .form-input:focus {
- outline: none;
- border-color: #4CAF50;
- box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.2);
- }
-
- .badge {
- display: inline-block;
- padding: 2px 8px;
- border-radius: 9999px;
- font-size: 12px;
- font-weight: 500;
- }
-
- .badge-success {
- background-color: #d1fae5;
- color: #065f46;
- }
-
- .badge-warning {
- background-color: #fef3c7;
- color: #92400e;
- }
-
- .pagination {
- display: flex;
- align-items: center;
- justify-content: flex-end;
- gap: 4px;
- }
-
- .pagination-item {
- display: inline-flex;
- align-items: center;
- justify-content: center;
- width: 32px;
- height: 32px;
- border-radius: 4px;
- cursor: pointer;
- transition: all 0.2s;
- }
-
- .pagination-item:hover {
- background-color: #f3f4f6;
- }
-
- .pagination-item.active {
- background-color: #4CAF50;
- color: white;
- }
-
- .pagination-item.disabled {
- color: #9ca3af;
- cursor: not-allowed;
- }
- </style>
- </head>
- <body>
- <div class="page-container responsive-container">
- <div class="flex justify-between items-center mb-6">
- <h1 class="text-2xl font-bold">用户管理</h1>
- <button class="btn btn-primary" id="addUserBtn">
- <i class="iconfont icon-plus btn-icon"></i>
- 新增用户
- </button>
- </div>
-
- <div class="card p-6 mb-6">
- <div class="flex flex-wrap gap-4">
- <div class="search-box flex-grow">
- <input type="text" class="input" placeholder="请输入用户名/姓名/手机号">
- <button class="btn btn-primary">
- <i class="iconfont icon-search btn-icon"></i>
- 搜索
- </button>
- <button class="btn btn-default">
- <i class="iconfont icon-reload btn-icon"></i>
- 重置
- </button>
- </div>
-
- <div class="flex gap-2">
- <select class="select">
- <option value="">所有角色</option>
- <option value="admin">管理员</option>
- <option value="operator">操作员</option>
- <option value="viewer">查看者</option>
- </select>
-
- <select class="select">
- <option value="">所有状态</option>
- <option value="1">启用</option>
- <option value="0">禁用</option>
- </select>
- </div>
- </div>
- </div>
-
- <div class="card">
- <div class="table-container">
- <div class="table-scroll-controls">
- <button class="table-scroll-btn table-scroll-left">
- <i class="iconfont icon-left"></i>
- </button>
- <button class="table-scroll-btn table-scroll-right">
- <i class="iconfont icon-right"></i>
- </button>
- </div>
- <table class="table-fixed-right">
- <thead>
- <tr>
- <th class="min-w-[120px]">用户名</th>
- <th class="min-w-[100px]">姓名</th>
- <th class="min-w-[120px]">手机号</th>
- <th class="min-w-[180px]">邮箱</th>
- <th class="min-w-[100px]">角色</th>
- <th class="min-w-[100px]">部门</th>
- <th class="min-w-[80px]">状态</th>
- <th class="min-w-[180px]">创建时间</th>
- <th class="min-w-[150px]">操作</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>admin</td>
- <td>系统管理员</td>
- <td>13800138000</td>
- <td>admin@aizhinong.com</td>
- <td>管理员</td>
- <td>技术部</td>
- <td><span class="badge badge-success">启用</span></td>
- <td>2023-01-01 12:00:00</td>
- <td>
- <div class="flex gap-2">
- <button class="btn btn-default btn-sm edit-btn" data-id="1">
- <i class="iconfont icon-edit btn-icon"></i>
- 编辑
- </button>
- <button class="btn btn-danger btn-sm">
- <i class="iconfont icon-delete btn-icon"></i>
- 删除
- </button>
- </div>
- </td>
- </tr>
- <tr>
- <td>operator</td>
- <td>张三</td>
- <td>13900139000</td>
- <td>zhangsan@aizhinong.com</td>
- <td>操作员</td>
- <td>运营部</td>
- <td><span class="badge badge-success">启用</span></td>
- <td>2023-01-02 10:30:00</td>
- <td>
- <div class="flex gap-2">
- <button class="btn btn-default btn-sm edit-btn" data-id="2">
- <i class="iconfont icon-edit btn-icon"></i>
- 编辑
- </button>
- <button class="btn btn-danger btn-sm">
- <i class="iconfont icon-delete btn-icon"></i>
- 删除
- </button>
- </div>
- </td>
- </tr>
- <tr>
- <td>viewer</td>
- <td>李四</td>
- <td>13700137000</td>
- <td>lisi@aizhinong.com</td>
- <td>查看者</td>
- <td>市场部</td>
- <td><span class="badge badge-warning">禁用</span></td>
- <td>2023-01-03 09:15:00</td>
- <td>
- <div class="flex gap-2">
- <button class="btn btn-default btn-sm edit-btn" data-id="3">
- <i class="iconfont icon-edit btn-icon"></i>
- 编辑
- </button>
- <button class="btn btn-danger btn-sm">
- <i class="iconfont icon-delete btn-icon"></i>
- 删除
- </button>
- </div>
- </td>
- </tr>
- <tr>
- <td>tester</td>
- <td>王五</td>
- <td>13600136000</td>
- <td>wangwu@aizhinong.com</td>
- <td>操作员</td>
- <td>测试部</td>
- <td><span class="badge badge-success">启用</span></td>
- <td>2023-01-04 14:20:00</td>
- <td>
- <div class="flex gap-2">
- <button class="btn btn-default btn-sm edit-btn" data-id="4">
- <i class="iconfont icon-edit btn-icon"></i>
- 编辑
- </button>
- <button class="btn btn-danger btn-sm">
- <i class="iconfont icon-delete btn-icon"></i>
- 删除
- </button>
- </div>
- </td>
- </tr>
- <tr>
- <td>guest</td>
- <td>访客</td>
- <td>13500135000</td>
- <td>guest@aizhinong.com</td>
- <td>查看者</td>
- <td>-</td>
- <td><span class="badge badge-success">启用</span></td>
- <td>2023-01-05 16:45:00</td>
- <td>
- <div class="flex gap-2">
- <button class="btn btn-default btn-sm edit-btn" data-id="5">
- <i class="iconfont icon-edit btn-icon"></i>
- 编辑
- </button>
- <button class="btn btn-danger btn-sm">
- <i class="iconfont icon-delete btn-icon"></i>
- 删除
- </button>
- </div>
- </td>
- </tr>
- </tbody>
- </table>
- </div>
-
- <div class="p-4 flex justify-between items-center">
- <div class="text-sm text-gray-500">
- 共 <span class="font-medium">5</span> 条记录,每页 <span class="font-medium">10</span> 条
- </div>
-
- <div class="pagination">
- <div class="pagination-item disabled">
- <i class="iconfont icon-left"></i>
- </div>
- <div class="pagination-item active">1</div>
- <div class="pagination-item">2</div>
- <div class="pagination-item">3</div>
- <div class="pagination-item">
- <i class="iconfont icon-right"></i>
- </div>
- </div>
- </div>
- </div>
- </div>
-
- <!-- 用户表单弹窗 -->
- <div class="modal-overlay" id="userModal">
- <div class="modal">
- <div class="modal-header">
- <h3 class="modal-title" id="modalTitle">新增用户</h3>
- <div class="modal-close" id="closeModal">×</div>
- </div>
- <div class="modal-body">
- <form id="userForm">
- <div class="form-group">
- <label class="form-label" for="username">用户名</label>
- <input type="text" id="username" class="form-input" placeholder="请输入用户名">
- </div>
-
- <div class="form-group">
- <label class="form-label" for="realname">姓名</label>
- <input type="text" id="realname" class="form-input" placeholder="请输入姓名">
- </div>
-
- <div class="form-group">
- <label class="form-label" for="password">密码</label>
- <input type="password" id="password" class="form-input" placeholder="请输入密码">
- </div>
-
- <div class="form-group">
- <label class="form-label" for="phone">手机号</label>
- <input type="text" id="phone" class="form-input" placeholder="请输入手机号">
- </div>
-
- <div class="form-group">
- <label class="form-label" for="email">邮箱</label>
- <input type="email" id="email" class="form-input" placeholder="请输入邮箱">
- </div>
-
- <div class="form-group">
- <label class="form-label" for="role">角色</label>
- <select id="role" class="form-input">
- <option value="">请选择角色</option>
- <option value="admin">管理员</option>
- <option value="operator">操作员</option>
- <option value="viewer">查看者</option>
- </select>
- </div>
-
- <div class="form-group">
- <label class="form-label" for="department">部门</label>
- <select id="department" class="form-input">
- <option value="">请选择部门</option>
- <option value="tech">技术部</option>
- <option value="operation">运营部</option>
- <option value="market">市场部</option>
- <option value="test">测试部</option>
- </select>
- </div>
-
- <div class="form-group">
- <label class="form-label" for="status">状态</label>
- <select id="status" class="form-input">
- <option value="1">启用</option>
- <option value="0">禁用</option>
- </select>
- </div>
-
- <div class="form-group">
- <label class="form-label" for="remark">备注</label>
- <textarea id="remark" class="form-input" rows="3" placeholder="请输入备注信息"></textarea>
- </div>
- </form>
- </div>
- <div class="modal-footer">
- <button class="btn btn-default" id="cancelBtn">取消</button>
- <button class="btn btn-primary" id="saveBtn">保存</button>
- </div>
- </div>
- </div>
-
- <script>
- document.addEventListener('DOMContentLoaded', function() {
- const userModal = document.getElementById('userModal');
- const modalTitle = document.getElementById('modalTitle');
- const addUserBtn = document.getElementById('addUserBtn');
- const closeModal = document.getElementById('closeModal');
- const cancelBtn = document.getElementById('cancelBtn');
- const saveBtn = document.getElementById('saveBtn');
- const editBtns = document.querySelectorAll('.edit-btn');
- const userForm = document.getElementById('userForm');
-
- // 初始化表格滚动功能
- function initTableScroll() {
- const tableContainer = document.querySelector('.table-container');
- const scrollLeftBtn = document.querySelector('.table-scroll-left');
- const scrollRightBtn = document.querySelector('.table-scroll-right');
-
- // 检查表格是否需要水平滚动
- function checkTableOverflow() {
- if (tableContainer.scrollWidth > tableContainer.clientWidth) {
- tableContainer.classList.add('has-overflow');
- } else {
- tableContainer.classList.remove('has-overflow');
- }
- }
-
- // 左右滚动按钮点击事件
- scrollLeftBtn.addEventListener('click', function() {
- tableContainer.scrollLeft -= 150;
- });
-
- scrollRightBtn.addEventListener('click', function() {
- tableContainer.scrollLeft += 150;
- });
-
- // 初始检查和窗口大小变化时检查
- checkTableOverflow();
- window.addEventListener('resize', checkTableOverflow);
-
- // 滚动事件处理
- tableContainer.addEventListener('scroll', function() {
- // 根据滚动位置显示/隐藏滚动按钮
- if (tableContainer.scrollLeft <= 10) {
- scrollLeftBtn.style.opacity = '0.5';
- } else {
- scrollLeftBtn.style.opacity = '1';
- }
-
- if (tableContainer.scrollLeft >= tableContainer.scrollWidth - tableContainer.clientWidth - 10) {
- scrollRightBtn.style.opacity = '0.5';
- } else {
- scrollRightBtn.style.opacity = '1';
- }
- });
-
- // 初始触发滚动事件,设置初始按钮状态
- tableContainer.dispatchEvent(new Event('scroll'));
- }
-
- // 初始化表格滚动
- initTableScroll();
-
- // 打开新增用户弹窗
- addUserBtn.addEventListener('click', function() {
- modalTitle.textContent = '新增用户';
- userForm.reset();
- userModal.style.display = 'flex';
- });
-
- // 打开编辑用户弹窗
- editBtns.forEach(btn => {
- btn.addEventListener('click', function() {
- const userId = this.getAttribute('data-id');
- modalTitle.textContent = '编辑用户';
-
- // 模拟获取用户数据
- // 实际应用中应该通过API获取
- if (userId === '1') {
- document.getElementById('username').value = 'admin';
- document.getElementById('realname').value = '系统管理员';
- document.getElementById('phone').value = '13800138000';
- document.getElementById('email').value = 'admin@aizhinong.com';
- document.getElementById('role').value = 'admin';
- document.getElementById('department').value = 'tech';
- document.getElementById('status').value = '1';
- }
-
- userModal.style.display = 'flex';
- });
- });
-
- // 关闭弹窗
- function closeUserModal() {
- userModal.style.display = 'none';
- }
-
- closeModal.addEventListener('click', closeUserModal);
- cancelBtn.addEventListener('click', closeUserModal);
-
- // 保存用户
- saveBtn.addEventListener('click', function() {
- // 模拟保存
- alert('用户信息保存成功!');
- closeUserModal();
- });
-
- // 点击弹窗外部关闭弹窗
- userModal.addEventListener('click', function(e) {
- if (e.target === userModal) {
- closeUserModal();
- }
- });
- });
- </script>
- </body>
- </html>
|