home1020
This commit is contained in:
@@ -0,0 +1,332 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>后台管理系统 - 登录</title>
|
||||
<!-- 引入Vue.js -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.min.js"></script>
|
||||
<!-- 引入Element UI CSS -->
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/element-ui@2.15.8/lib/theme-chalk/index.css">
|
||||
<!-- 引入Element UI JavaScript -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/element-ui@2.15.8/lib/index.js"></script>
|
||||
<!-- 引入Font Awesome -->
|
||||
<link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
height: 100vh;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.login-container {
|
||||
width: 90%;
|
||||
max-width: 400px;
|
||||
background-color: white;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
|
||||
overflow: hidden;
|
||||
animation: fadeInUp 0.6s ease-out;
|
||||
}
|
||||
.login-header {
|
||||
background-color: #1989fa;
|
||||
color: white;
|
||||
padding: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
.logo {
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
border-radius: 50%;
|
||||
background-color: white;
|
||||
margin: 0 auto 15px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
.logo-icon {
|
||||
font-size: 32px;
|
||||
color: #1989fa;
|
||||
}
|
||||
.title {
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.subtitle {
|
||||
font-size: 14px;
|
||||
opacity: 0.9;
|
||||
}
|
||||
.login-body {
|
||||
padding: 30px 25px;
|
||||
}
|
||||
.form-item {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.form-label {
|
||||
display: block;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
color: #303133;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.input-wrapper {
|
||||
position: relative;
|
||||
}
|
||||
.input-icon {
|
||||
position: absolute;
|
||||
left: 12px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
color: #909399;
|
||||
font-size: 16px;
|
||||
}
|
||||
.form-input {
|
||||
padding-left: 38px;
|
||||
height: 40px;
|
||||
border-radius: 6px;
|
||||
}
|
||||
.form-input::-webkit-input-placeholder {
|
||||
color: #c0c4cc;
|
||||
}
|
||||
.form-input::-moz-placeholder {
|
||||
color: #c0c4cc;
|
||||
}
|
||||
.form-input:-ms-input-placeholder {
|
||||
color: #c0c4cc;
|
||||
}
|
||||
.options {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 25px;
|
||||
}
|
||||
.remember-me {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 13px;
|
||||
color: #606266;
|
||||
}
|
||||
.el-checkbox__label {
|
||||
font-size: 13px;
|
||||
color: #606266;
|
||||
}
|
||||
.forgot-password {
|
||||
font-size: 13px;
|
||||
color: #1989fa;
|
||||
cursor: pointer;
|
||||
}
|
||||
.login-button {
|
||||
width: 100%;
|
||||
height: 40px;
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
border-radius: 6px;
|
||||
}
|
||||
.system-info {
|
||||
text-align: center;
|
||||
margin-top: 20px;
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
}
|
||||
.version {
|
||||
margin-top: 5px;
|
||||
}
|
||||
@keyframes fadeInUp {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(30px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
.loading-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: 9999;
|
||||
}
|
||||
.loading-content {
|
||||
background-color: white;
|
||||
padding: 20px 30px;
|
||||
border-radius: 8px;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">
|
||||
<div class="login-container">
|
||||
<!-- 登录头部 -->
|
||||
<div class="login-header">
|
||||
<div class="logo">
|
||||
<i class="fa fa-tachometer logo-icon"></i>
|
||||
</div>
|
||||
<div class="title">图片收集系统</div>
|
||||
<div class="subtitle">后台管理平台</div>
|
||||
</div>
|
||||
|
||||
<!-- 登录表单 -->
|
||||
<div class="login-body">
|
||||
<form @submit.prevent="handleLogin">
|
||||
<div class="form-item">
|
||||
<div class="form-label">用户名</div>
|
||||
<div class="input-wrapper">
|
||||
<i class="fa fa-user input-icon"></i>
|
||||
<el-input
|
||||
v-model="loginForm.username"
|
||||
class="form-input"
|
||||
placeholder="请输入用户名"
|
||||
autofocus
|
||||
@keyup.enter.native="handleLogin"
|
||||
></el-input>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-item">
|
||||
<div class="form-label">密码</div>
|
||||
<div class="input-wrapper">
|
||||
<i class="fa fa-lock input-icon"></i>
|
||||
<el-input
|
||||
v-model="loginForm.password"
|
||||
class="form-input"
|
||||
placeholder="请输入密码"
|
||||
show-password
|
||||
@keyup.enter.native="handleLogin"
|
||||
></el-input>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="options">
|
||||
<div class="remember-me">
|
||||
<el-checkbox v-model="loginForm.rememberMe">记住登录</el-checkbox>
|
||||
</div>
|
||||
<div class="forgot-password" @click="forgotPassword">忘记密码?</div>
|
||||
</div>
|
||||
|
||||
<el-button
|
||||
type="primary"
|
||||
class="login-button"
|
||||
@click="handleLogin"
|
||||
:loading="loading"
|
||||
>
|
||||
登录
|
||||
</el-button>
|
||||
|
||||
<div class="system-info">
|
||||
<div>图片收集系统管理平台</div>
|
||||
<div class="version">版本 1.0.0</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 加载遮罩层 -->
|
||||
<transition name="fade">
|
||||
<div v-if="loading" class="loading-overlay">
|
||||
<div class="loading-content">
|
||||
<el-loading-spinner></el-loading-spinner>
|
||||
<div style="margin-top: 10px;">登录中...</div>
|
||||
</div>
|
||||
</div>
|
||||
</transition>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
new Vue({
|
||||
el: '#app',
|
||||
data() {
|
||||
return {
|
||||
loading: false,
|
||||
loginForm: {
|
||||
username: '',
|
||||
password: '',
|
||||
rememberMe: false
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 处理登录
|
||||
handleLogin() {
|
||||
// 表单验证
|
||||
if (!this.loginForm.username.trim()) {
|
||||
this.$message.error('请输入用户名');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.loginForm.password.trim()) {
|
||||
this.$message.error('请输入密码');
|
||||
return;
|
||||
}
|
||||
|
||||
this.loading = true;
|
||||
|
||||
// 模拟登录请求
|
||||
setTimeout(() => {
|
||||
// 模拟成功登录
|
||||
if (this.loginForm.username && this.loginForm.password) {
|
||||
this.$message.success('登录成功');
|
||||
|
||||
// 保存登录状态(如果选择记住登录)
|
||||
if (this.loginForm.rememberMe) {
|
||||
localStorage.setItem('rememberedUser', this.loginForm.username);
|
||||
} else {
|
||||
localStorage.removeItem('rememberedUser');
|
||||
}
|
||||
|
||||
// 跳转到部门管理页面
|
||||
setTimeout(() => {
|
||||
window.location.href = 'department-management.html';
|
||||
}, 1000);
|
||||
} else {
|
||||
this.$message.error('用户名或密码错误');
|
||||
this.loading = false;
|
||||
}
|
||||
}, 1500);
|
||||
},
|
||||
|
||||
// 忘记密码
|
||||
forgotPassword() {
|
||||
this.$alert('请联系系统管理员重置密码', '忘记密码', {
|
||||
confirmButtonText: '确定',
|
||||
dangerouslyUseHTMLString: true
|
||||
});
|
||||
},
|
||||
|
||||
// 自动填充保存的用户名
|
||||
fillRememberedUser() {
|
||||
const rememberedUser = localStorage.getItem('rememberedUser');
|
||||
if (rememberedUser) {
|
||||
this.loginForm.username = rememberedUser;
|
||||
this.loginForm.rememberMe = true;
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
// 尝试填充记住的用户名
|
||||
this.fillRememberedUser();
|
||||
|
||||
// 添加键盘事件监听
|
||||
document.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Enter') {
|
||||
this.handleLogin();
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,655 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>部门管理 - 图片收集系统</title>
|
||||
<!-- 引入Vue.js -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.min.js"></script>
|
||||
<!-- 引入Element UI CSS -->
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/element-ui@2.15.8/lib/theme-chalk/index.css">
|
||||
<!-- 引入Element UI JavaScript -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/element-ui@2.15.8/lib/index.js"></script>
|
||||
<!-- 引入Font Awesome -->
|
||||
<link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
height: 100vh;
|
||||
background-color: #f0f2f5;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
||||
}
|
||||
.container {
|
||||
height: 100vh;
|
||||
display: flex;
|
||||
}
|
||||
.sidebar {
|
||||
width: 220px;
|
||||
background-color: #001529;
|
||||
color: white;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.sidebar-header {
|
||||
padding: 20px;
|
||||
text-align: center;
|
||||
border-bottom: 1px solid #1f2937;
|
||||
}
|
||||
.logo {
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.logo-icon {
|
||||
margin-right: 8px;
|
||||
font-size: 22px;
|
||||
}
|
||||
.menu-item {
|
||||
padding: 15px 20px;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.3s;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.menu-item:hover {
|
||||
background-color: #1f2937;
|
||||
}
|
||||
.menu-item.active {
|
||||
background-color: #1989fa;
|
||||
}
|
||||
.menu-icon {
|
||||
margin-right: 10px;
|
||||
font-size: 16px;
|
||||
}
|
||||
.main-content {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
.header {
|
||||
background-color: white;
|
||||
padding: 15px 20px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
.header-title {
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
}
|
||||
.header-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 15px;
|
||||
}
|
||||
.user-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.user-avatar {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: 50%;
|
||||
background-color: #1989fa;
|
||||
color: white;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-right: 8px;
|
||||
font-size: 14px;
|
||||
}
|
||||
.user-name {
|
||||
color: #606266;
|
||||
}
|
||||
.content-wrapper {
|
||||
flex: 1;
|
||||
padding: 20px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
.card {
|
||||
background-color: white;
|
||||
border-radius: 8px;
|
||||
padding: 20px;
|
||||
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.search-section {
|
||||
display: flex;
|
||||
gap: 15px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.search-input {
|
||||
width: 300px;
|
||||
}
|
||||
.table-wrapper {
|
||||
overflow-x: auto;
|
||||
}
|
||||
.table-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.table-title {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
}
|
||||
.btn-primary {
|
||||
background-color: #1989fa;
|
||||
border-color: #1989fa;
|
||||
}
|
||||
.btn-primary:hover {
|
||||
background-color: #409eff;
|
||||
border-color: #409eff;
|
||||
}
|
||||
.operation-buttons {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
.el-button {
|
||||
padding: 6px 12px;
|
||||
font-size: 14px;
|
||||
}
|
||||
.dialog-form-item {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.dialog-form-label {
|
||||
font-weight: 500;
|
||||
color: #303133;
|
||||
margin-bottom: 8px;
|
||||
font-size: 14px;
|
||||
}
|
||||
.status-badge {
|
||||
padding: 4px 8px;
|
||||
border-radius: 4px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.status-active {
|
||||
background-color: #f0f9eb;
|
||||
color: #67c23a;
|
||||
}
|
||||
.status-inactive {
|
||||
background-color: #f5f7fa;
|
||||
color: #909399;
|
||||
}
|
||||
.statistics-cards {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||
gap: 20px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.stat-card {
|
||||
background-color: white;
|
||||
border-radius: 8px;
|
||||
padding: 20px;
|
||||
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.stat-icon {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border-radius: 50%;
|
||||
background-color: #ecf5ff;
|
||||
color: #1989fa;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 24px;
|
||||
margin-right: 15px;
|
||||
}
|
||||
.stat-content {
|
||||
flex: 1;
|
||||
}
|
||||
.stat-value {
|
||||
font-size: 24px;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.stat-label {
|
||||
font-size: 14px;
|
||||
color: #909399;
|
||||
}
|
||||
.logout-btn {
|
||||
cursor: pointer;
|
||||
color: #606266;
|
||||
transition: color 0.3s;
|
||||
}
|
||||
.logout-btn:hover {
|
||||
color: #f56c6c;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">
|
||||
<div class="container">
|
||||
<!-- 侧边栏 -->
|
||||
<div class="sidebar">
|
||||
<div class="sidebar-header">
|
||||
<div class="logo">
|
||||
<i class="fa fa-tachometer logo-icon"></i>
|
||||
<span>管理平台</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="menu-item active" @click="navigateTo('department')">
|
||||
<i class="fa fa-building-o menu-icon"></i>
|
||||
<span>部门管理</span>
|
||||
</div>
|
||||
<div class="menu-item" @click="navigateTo('user')">
|
||||
<i class="fa fa-users menu-icon"></i>
|
||||
<span>用户管理</span>
|
||||
</div>
|
||||
<div class="menu-item" @click="navigateTo('task')">
|
||||
<i class="fa fa-tasks menu-icon"></i>
|
||||
<span>任务管理</span>
|
||||
</div>
|
||||
<div class="menu-item" @click="navigateTo('image')">
|
||||
<i class="fa fa-picture-o menu-icon"></i>
|
||||
<span>图片管理</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 主内容区 -->
|
||||
<div class="main-content">
|
||||
<!-- 顶部导航栏 -->
|
||||
<div class="header">
|
||||
<div class="header-title">部门管理</div>
|
||||
<div class="header-actions">
|
||||
<div class="user-info">
|
||||
<div class="user-avatar">管</div>
|
||||
<span class="user-name">系统管理员</span>
|
||||
</div>
|
||||
<div class="logout-btn" @click="handleLogout">
|
||||
<i class="fa fa-sign-out"></i> 退出
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 内容区域 -->
|
||||
<div class="content-wrapper">
|
||||
<!-- 统计卡片 -->
|
||||
<div class="statistics-cards">
|
||||
<div class="stat-card">
|
||||
<div class="stat-icon">
|
||||
<i class="fa fa-building"></i>
|
||||
</div>
|
||||
<div class="stat-content">
|
||||
<div class="stat-value">{{ departmentStats.total }}</div>
|
||||
<div class="stat-label">总部门数</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-icon" style="background-color: #f0f9eb; color: #67c23a;">
|
||||
<i class="fa fa-check-circle"></i>
|
||||
</div>
|
||||
<div class="stat-content">
|
||||
<div class="stat-value">{{ departmentStats.active }}</div>
|
||||
<div class="stat-label">活跃部门</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-icon" style="background-color: #fef0f0; color: #f56c6c;">
|
||||
<i class="fa fa-users"></i>
|
||||
</div>
|
||||
<div class="stat-content">
|
||||
<div class="stat-value">{{ departmentStats.totalUsers }}</div>
|
||||
<div class="stat-label">总用户数</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 搜索和操作区域 -->
|
||||
<div class="card">
|
||||
<div class="search-section">
|
||||
<el-input
|
||||
v-model="searchQuery"
|
||||
placeholder="搜索部门名称"
|
||||
prefix-icon="el-icon-search"
|
||||
class="search-input"
|
||||
></el-input>
|
||||
<el-button
|
||||
type="primary"
|
||||
class="btn-primary"
|
||||
@click="addDepartment"
|
||||
>
|
||||
<i class="fa fa-plus"></i> 新增部门
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 部门列表 -->
|
||||
<div class="card">
|
||||
<div class="table-header">
|
||||
<div class="table-title">部门列表</div>
|
||||
</div>
|
||||
<div class="table-wrapper">
|
||||
<el-table :data="filteredDepartments" stripe style="width: 100%">
|
||||
<el-table-column prop="id" label="部门ID" width="80"></el-table-column>
|
||||
<el-table-column prop="name" label="部门名称" min-width="150"></el-table-column>
|
||||
<el-table-column prop="manager" label="部门负责人" min-width="120"></el-table-column>
|
||||
<el-table-column prop="userCount" label="用户数量" width="100"></el-table-column>
|
||||
<el-table-column prop="createTime" label="创建时间" min-width="150">
|
||||
<template slot-scope="scope">
|
||||
{{ formatDate(scope.row.createTime) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="status" label="状态" width="100">
|
||||
<template slot-scope="scope">
|
||||
<span
|
||||
class="status-badge"
|
||||
:class="scope.row.status === 'active' ? 'status-active' : 'status-inactive'"
|
||||
>
|
||||
{{ scope.row.status === 'active' ? '活跃' : '禁用' }}
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="180" fixed="right">
|
||||
<template slot-scope="scope">
|
||||
<div class="operation-buttons">
|
||||
<el-button
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="editDepartment(scope.row)"
|
||||
>
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
type="danger"
|
||||
size="small"
|
||||
@click="deleteDepartment(scope.row.id)"
|
||||
:disabled="scope.row.id === 1"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 部门对话框 -->
|
||||
<el-dialog
|
||||
:title="dialogTitle"
|
||||
:visible.sync="showDialog"
|
||||
width="500px"
|
||||
>
|
||||
<div class="dialog-form-item">
|
||||
<div class="dialog-form-label">部门名称</div>
|
||||
<el-input
|
||||
v-model="departmentForm.name"
|
||||
placeholder="请输入部门名称"
|
||||
></el-input>
|
||||
</div>
|
||||
|
||||
<div class="dialog-form-item">
|
||||
<div class="dialog-form-label">部门负责人</div>
|
||||
<el-select
|
||||
v-model="departmentForm.manager"
|
||||
placeholder="请选择部门负责人"
|
||||
>
|
||||
<el-option
|
||||
v-for="user in availableManagers"
|
||||
:key="user.id"
|
||||
:label="user.name"
|
||||
:value="user.name"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
|
||||
<div class="dialog-form-item">
|
||||
<div class="dialog-form-label">部门状态</div>
|
||||
<el-radio-group v-model="departmentForm.status">
|
||||
<el-radio label="active">活跃</el-radio>
|
||||
<el-radio label="inactive">禁用</el-radio>
|
||||
</el-radio-group>
|
||||
</div>
|
||||
|
||||
<div slot="footer">
|
||||
<el-button @click="showDialog = false">取消</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="saveDepartment"
|
||||
:loading="saving"
|
||||
>
|
||||
保存
|
||||
</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
new Vue({
|
||||
el: '#app',
|
||||
data() {
|
||||
return {
|
||||
searchQuery: '',
|
||||
showDialog: false,
|
||||
dialogTitle: '新增部门',
|
||||
saving: false,
|
||||
departments: [
|
||||
{
|
||||
id: 1,
|
||||
name: '技术部',
|
||||
manager: '张经理',
|
||||
userCount: 15,
|
||||
createTime: '2023-01-15',
|
||||
status: 'active'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: '市场部',
|
||||
manager: '李经理',
|
||||
userCount: 12,
|
||||
createTime: '2023-01-20',
|
||||
status: 'active'
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: '人力资源部',
|
||||
manager: '王经理',
|
||||
userCount: 5,
|
||||
createTime: '2023-02-05',
|
||||
status: 'active'
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: '财务部',
|
||||
manager: '赵经理',
|
||||
userCount: 8,
|
||||
createTime: '2023-02-10',
|
||||
status: 'active'
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
name: '行政部',
|
||||
manager: '刘经理',
|
||||
userCount: 6,
|
||||
createTime: '2023-03-01',
|
||||
status: 'inactive'
|
||||
}
|
||||
],
|
||||
departmentForm: {
|
||||
id: '',
|
||||
name: '',
|
||||
manager: '',
|
||||
status: 'active'
|
||||
},
|
||||
availableManagers: [
|
||||
{ id: 1, name: '张经理' },
|
||||
{ id: 2, name: '李经理' },
|
||||
{ id: 3, name: '王经理' },
|
||||
{ id: 4, name: '赵经理' },
|
||||
{ id: 5, name: '刘经理' }
|
||||
],
|
||||
departmentStats: {
|
||||
total: 5,
|
||||
active: 4,
|
||||
totalUsers: 46
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
filteredDepartments() {
|
||||
if (!this.searchQuery) {
|
||||
return this.departments;
|
||||
}
|
||||
const query = this.searchQuery.toLowerCase();
|
||||
return this.departments.filter(dept =>
|
||||
dept.name.toLowerCase().includes(query) ||
|
||||
dept.manager.toLowerCase().includes(query)
|
||||
);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 导航到其他页面
|
||||
navigateTo(page) {
|
||||
let url = '';
|
||||
switch (page) {
|
||||
case 'department':
|
||||
url = 'department-management.html';
|
||||
break;
|
||||
case 'user':
|
||||
url = 'user-management.html';
|
||||
break;
|
||||
case 'task':
|
||||
url = 'task-management.html';
|
||||
break;
|
||||
case 'image':
|
||||
url = 'image-management.html';
|
||||
break;
|
||||
}
|
||||
if (url && url !== window.location.pathname) {
|
||||
window.location.href = url;
|
||||
}
|
||||
},
|
||||
|
||||
// 格式化日期
|
||||
formatDate(dateStr) {
|
||||
return dateStr;
|
||||
},
|
||||
|
||||
// 新增部门
|
||||
addDepartment() {
|
||||
this.dialogTitle = '新增部门';
|
||||
this.departmentForm = {
|
||||
id: '',
|
||||
name: '',
|
||||
manager: '',
|
||||
status: 'active'
|
||||
};
|
||||
this.showDialog = true;
|
||||
},
|
||||
|
||||
// 编辑部门
|
||||
editDepartment(department) {
|
||||
this.dialogTitle = '编辑部门';
|
||||
this.departmentForm = { ...department };
|
||||
this.showDialog = true;
|
||||
},
|
||||
|
||||
// 保存部门
|
||||
saveDepartment() {
|
||||
// 表单验证
|
||||
if (!this.departmentForm.name.trim()) {
|
||||
this.$message.error('请输入部门名称');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.departmentForm.manager) {
|
||||
this.$message.error('请选择部门负责人');
|
||||
return;
|
||||
}
|
||||
|
||||
this.saving = true;
|
||||
|
||||
// 模拟保存操作
|
||||
setTimeout(() => {
|
||||
if (this.departmentForm.id) {
|
||||
// 编辑现有部门
|
||||
const index = this.departments.findIndex(d => d.id === this.departmentForm.id);
|
||||
if (index > -1) {
|
||||
this.departments[index] = { ...this.departmentForm };
|
||||
this.$message.success('部门信息已更新');
|
||||
}
|
||||
} else {
|
||||
// 添加新部门
|
||||
const newId = Math.max(...this.departments.map(d => d.id), 0) + 1;
|
||||
const newDepartment = {
|
||||
...this.departmentForm,
|
||||
id: newId,
|
||||
userCount: 0,
|
||||
createTime: new Date().toISOString().split('T')[0]
|
||||
};
|
||||
this.departments.unshift(newDepartment);
|
||||
this.departmentStats.total++;
|
||||
if (newDepartment.status === 'active') {
|
||||
this.departmentStats.active++;
|
||||
}
|
||||
this.$message.success('部门已创建');
|
||||
}
|
||||
|
||||
this.saving = false;
|
||||
this.showDialog = false;
|
||||
}, 1000);
|
||||
},
|
||||
|
||||
// 删除部门
|
||||
deleteDepartment(id) {
|
||||
if (id === 1) {
|
||||
this.$message.warning('默认部门不能删除');
|
||||
return;
|
||||
}
|
||||
|
||||
this.$confirm(`确定要删除该部门吗?删除后将无法恢复。`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
const index = this.departments.findIndex(d => d.id === id);
|
||||
if (index > -1) {
|
||||
const department = this.departments[index];
|
||||
this.departments.splice(index, 1);
|
||||
this.departmentStats.total--;
|
||||
if (department.status === 'active') {
|
||||
this.departmentStats.active--;
|
||||
}
|
||||
this.departmentStats.totalUsers -= department.userCount;
|
||||
this.$message.success('部门已删除');
|
||||
}
|
||||
}).catch(() => {
|
||||
// 取消删除
|
||||
});
|
||||
},
|
||||
|
||||
// 处理退出登录
|
||||
handleLogout() {
|
||||
this.$confirm('确定要退出登录吗?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
this.$message.success('退出成功');
|
||||
setTimeout(() => {
|
||||
window.location.href = 'admin-login.html';
|
||||
}, 1000);
|
||||
}).catch(() => {
|
||||
// 取消退出
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,942 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>用户管理 - 图片收集系统</title>
|
||||
<!-- 引入Vue.js -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.min.js"></script>
|
||||
<!-- 引入Element UI CSS -->
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/element-ui@2.15.8/lib/theme-chalk/index.css">
|
||||
<!-- 引入Element UI JavaScript -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/element-ui@2.15.8/lib/index.js"></script>
|
||||
<!-- 引入Font Awesome -->
|
||||
<link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
height: 100vh;
|
||||
background-color: #f0f2f5;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
||||
}
|
||||
.container {
|
||||
height: 100vh;
|
||||
display: flex;
|
||||
}
|
||||
.sidebar {
|
||||
width: 220px;
|
||||
background-color: #001529;
|
||||
color: white;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.sidebar-header {
|
||||
padding: 20px;
|
||||
text-align: center;
|
||||
border-bottom: 1px solid #1f2937;
|
||||
}
|
||||
.logo {
|
||||
font-size: 20px;
|
||||
font-weight: 600;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.logo-icon {
|
||||
margin-right: 8px;
|
||||
font-size: 22px;
|
||||
}
|
||||
.menu-item {
|
||||
padding: 15px 20px;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.3s;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.menu-item:hover {
|
||||
background-color: #1f2937;
|
||||
}
|
||||
.menu-item.active {
|
||||
background-color: #1989fa;
|
||||
}
|
||||
.menu-icon {
|
||||
margin-right: 10px;
|
||||
font-size: 16px;
|
||||
}
|
||||
.main-content {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
.header {
|
||||
background-color: white;
|
||||
padding: 15px 20px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
.header-title {
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
}
|
||||
.header-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 15px;
|
||||
}
|
||||
.user-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.user-avatar {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: 50%;
|
||||
background-color: #1989fa;
|
||||
color: white;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-right: 8px;
|
||||
font-size: 14px;
|
||||
}
|
||||
.user-name {
|
||||
color: #606266;
|
||||
}
|
||||
.content-wrapper {
|
||||
flex: 1;
|
||||
padding: 20px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
.card {
|
||||
background-color: white;
|
||||
border-radius: 8px;
|
||||
padding: 20px;
|
||||
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.search-section {
|
||||
display: flex;
|
||||
gap: 15px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.search-input {
|
||||
width: 250px;
|
||||
}
|
||||
.department-select {
|
||||
width: 200px;
|
||||
}
|
||||
.table-wrapper {
|
||||
overflow-x: auto;
|
||||
}
|
||||
.table-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.table-title {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
}
|
||||
.btn-primary {
|
||||
background-color: #1989fa;
|
||||
border-color: #1989fa;
|
||||
}
|
||||
.btn-primary:hover {
|
||||
background-color: #409eff;
|
||||
border-color: #409eff;
|
||||
}
|
||||
.operation-buttons {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
.el-button {
|
||||
padding: 6px 12px;
|
||||
font-size: 14px;
|
||||
}
|
||||
.dialog-form-item {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.dialog-form-label {
|
||||
font-weight: 500;
|
||||
color: #303133;
|
||||
margin-bottom: 8px;
|
||||
font-size: 14px;
|
||||
}
|
||||
.status-badge {
|
||||
padding: 4px 8px;
|
||||
border-radius: 4px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.status-active {
|
||||
background-color: #f0f9eb;
|
||||
color: #67c23a;
|
||||
}
|
||||
.status-inactive {
|
||||
background-color: #f5f7fa;
|
||||
color: #909399;
|
||||
}
|
||||
.role-badge {
|
||||
padding: 4px 8px;
|
||||
border-radius: 4px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.role-admin {
|
||||
background-color: #fef0f0;
|
||||
color: #f56c6c;
|
||||
}
|
||||
.role-manager {
|
||||
background-color: #f0f5ff;
|
||||
color: #409eff;
|
||||
}
|
||||
.role-user {
|
||||
background-color: #f0f9eb;
|
||||
color: #67c23a;
|
||||
}
|
||||
.statistics-cards {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||
gap: 20px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.stat-card {
|
||||
background-color: white;
|
||||
border-radius: 8px;
|
||||
padding: 20px;
|
||||
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.stat-icon {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border-radius: 50%;
|
||||
background-color: #ecf5ff;
|
||||
color: #1989fa;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 24px;
|
||||
margin-right: 15px;
|
||||
}
|
||||
.stat-content {
|
||||
flex: 1;
|
||||
}
|
||||
.stat-value {
|
||||
font-size: 24px;
|
||||
font-weight: 600;
|
||||
color: #303133;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
.stat-label {
|
||||
font-size: 14px;
|
||||
color: #909399;
|
||||
}
|
||||
.logout-btn {
|
||||
cursor: pointer;
|
||||
color: #606266;
|
||||
transition: color 0.3s;
|
||||
}
|
||||
.logout-btn:hover {
|
||||
color: #f56c6c;
|
||||
}
|
||||
.avatar-preview {
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
border-radius: 50%;
|
||||
object-fit: cover;
|
||||
border: 2px solid #dcdfe6;
|
||||
margin: 0 auto 15px;
|
||||
display: block;
|
||||
}
|
||||
.avatar-uploader {
|
||||
text-align: center;
|
||||
}
|
||||
.password-toggle {
|
||||
cursor: pointer;
|
||||
margin-left: 5px;
|
||||
color: #909399;
|
||||
}
|
||||
.password-toggle:hover {
|
||||
color: #1989fa;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app">
|
||||
<div class="container">
|
||||
<!-- 侧边栏 -->
|
||||
<div class="sidebar">
|
||||
<div class="sidebar-header">
|
||||
<div class="logo">
|
||||
<i class="fa fa-tachometer logo-icon"></i>
|
||||
<span>管理平台</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="menu-item" @click="navigateTo('department')">
|
||||
<i class="fa fa-building-o menu-icon"></i>
|
||||
<span>部门管理</span>
|
||||
</div>
|
||||
<div class="menu-item active" @click="navigateTo('user')">
|
||||
<i class="fa fa-users menu-icon"></i>
|
||||
<span>用户管理</span>
|
||||
</div>
|
||||
<div class="menu-item" @click="navigateTo('task')">
|
||||
<i class="fa fa-tasks menu-icon"></i>
|
||||
<span>任务管理</span>
|
||||
</div>
|
||||
<div class="menu-item" @click="navigateTo('image')">
|
||||
<i class="fa fa-picture-o menu-icon"></i>
|
||||
<span>图片管理</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 主内容区 -->
|
||||
<div class="main-content">
|
||||
<!-- 顶部导航栏 -->
|
||||
<div class="header">
|
||||
<div class="header-title">用户管理</div>
|
||||
<div class="header-actions">
|
||||
<div class="user-info">
|
||||
<div class="user-avatar">管</div>
|
||||
<span class="user-name">系统管理员</span>
|
||||
</div>
|
||||
<div class="logout-btn" @click="handleLogout">
|
||||
<i class="fa fa-sign-out"></i> 退出
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 内容区域 -->
|
||||
<div class="content-wrapper">
|
||||
<!-- 统计卡片 -->
|
||||
<div class="statistics-cards">
|
||||
<div class="stat-card">
|
||||
<div class="stat-icon">
|
||||
<i class="fa fa-user"></i>
|
||||
</div>
|
||||
<div class="stat-content">
|
||||
<div class="stat-value">{{ userStats.total }}</div>
|
||||
<div class="stat-label">总用户数</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-icon" style="background-color: #f0f9eb; color: #67c23a;">
|
||||
<i class="fa fa-check-circle"></i>
|
||||
</div>
|
||||
<div class="stat-content">
|
||||
<div class="stat-value">{{ userStats.active }}</div>
|
||||
<div class="stat-label">活跃用户</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-icon" style="background-color: #fef0f0; color: #f56c6c;">
|
||||
<i class="fa fa-user-circle"></i>
|
||||
</div>
|
||||
<div class="stat-content">
|
||||
<div class="stat-value">{{ userStats.admins }}</div>
|
||||
<div class="stat-label">管理员</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="stat-card">
|
||||
<div class="stat-icon" style="background-color: #e6f7ff; color: #1890ff;">
|
||||
<i class="fa fa-id-card"></i>
|
||||
</div>
|
||||
<div class="stat-content">
|
||||
<div class="stat-value">{{ userStats.managers }}</div>
|
||||
<div class="stat-label">部门负责人</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 搜索和操作区域 -->
|
||||
<div class="card">
|
||||
<div class="search-section">
|
||||
<el-input
|
||||
v-model="searchQuery"
|
||||
placeholder="搜索用户名或姓名"
|
||||
prefix-icon="el-icon-search"
|
||||
class="search-input"
|
||||
></el-input>
|
||||
<el-select
|
||||
v-model="departmentFilter"
|
||||
placeholder="选择部门"
|
||||
class="department-select"
|
||||
clearable
|
||||
>
|
||||
<el-option
|
||||
v-for="dept in departments"
|
||||
:key="dept.id"
|
||||
:label="dept.name"
|
||||
:value="dept.id"
|
||||
></el-option>
|
||||
</el-select>
|
||||
<el-select
|
||||
v-model="roleFilter"
|
||||
placeholder="选择角色"
|
||||
class="department-select"
|
||||
clearable
|
||||
>
|
||||
<el-option label="管理员" value="admin"></el-option>
|
||||
<el-option label="部门负责人" value="dept_manager"></el-option>
|
||||
<el-option label="普通用户" value="user"></el-option>
|
||||
</el-select>
|
||||
<el-button
|
||||
type="primary"
|
||||
class="btn-primary"
|
||||
@click="addUser"
|
||||
>
|
||||
<i class="fa fa-plus"></i> 新增用户
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 用户列表 -->
|
||||
<div class="card">
|
||||
<div class="table-header">
|
||||
<div class="table-title">用户列表</div>
|
||||
</div>
|
||||
<div class="table-wrapper">
|
||||
<el-table :data="filteredUsers" stripe style="width: 100%">
|
||||
<el-table-column prop="id" label="用户ID" width="80"></el-table-column>
|
||||
<el-table-column label="头像" width="80">
|
||||
<template slot-scope="scope">
|
||||
<img
|
||||
:src="scope.row.avatar"
|
||||
:alt="scope.row.name"
|
||||
style="width: 40px; height: 40px; border-radius: 50%;"
|
||||
>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="username" label="用户名" min-width="120"></el-table-column>
|
||||
<el-table-column prop="name" label="姓名" min-width="100"></el-table-column>
|
||||
<el-table-column prop="departmentName" label="所属部门" min-width="120"></el-table-column>
|
||||
<el-table-column prop="position" label="职位" min-width="100"></el-table-column>
|
||||
<el-table-column prop="phone" label="手机号" min-width="120"></el-table-column>
|
||||
<el-table-column prop="email" label="邮箱" min-width="180"></el-table-column>
|
||||
<el-table-column prop="role" label="角色" min-width="100">
|
||||
<template slot-scope="scope">
|
||||
<span
|
||||
class="role-badge"
|
||||
:class="{
|
||||
'role-admin': scope.row.role === 'admin',
|
||||
'role-manager': scope.row.role === 'dept_manager',
|
||||
'role-user': scope.row.role === 'user'
|
||||
}"
|
||||
>
|
||||
{{ getRoleText(scope.row.role) }}
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="status" label="状态" width="100">
|
||||
<template slot-scope="scope">
|
||||
<span
|
||||
class="status-badge"
|
||||
:class="scope.row.status === 'active' ? 'status-active' : 'status-inactive'"
|
||||
>
|
||||
{{ scope.row.status === 'active' ? '活跃' : '禁用' }}
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="createTime" label="创建时间" min-width="150">
|
||||
<template slot-scope="scope">
|
||||
{{ formatDate(scope.row.createTime) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="200" fixed="right">
|
||||
<template slot-scope="scope">
|
||||
<div class="operation-buttons">
|
||||
<el-button
|
||||
type="primary"
|
||||
size="small"
|
||||
@click="editUser(scope.row)"
|
||||
:disabled="scope.row.id === 1"
|
||||
>
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
type="success"
|
||||
size="small"
|
||||
@click="resetPassword(scope.row.id)"
|
||||
>
|
||||
重置密码
|
||||
</el-button>
|
||||
<el-button
|
||||
type="danger"
|
||||
size="small"
|
||||
@click="deleteUser(scope.row.id)"
|
||||
:disabled="scope.row.id === 1"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 用户对话框 -->
|
||||
<el-dialog
|
||||
:title="dialogTitle"
|
||||
:visible.sync="showDialog"
|
||||
width="600px"
|
||||
>
|
||||
<div class="dialog-form-item avatar-uploader">
|
||||
<img
|
||||
v-if="userForm.avatar"
|
||||
:src="userForm.avatar"
|
||||
class="avatar-preview"
|
||||
:alt="userForm.name"
|
||||
>
|
||||
<div v-else class="avatar-preview" style="background-color: #f5f7fa; display: flex; align-items: center; justify-content: center; color: #909399;">
|
||||
<i class="fa fa-user-circle" style="font-size: 40px;"></i>
|
||||
</div>
|
||||
<el-button type="primary" size="small" style="margin-top: 10px;">
|
||||
<i class="fa fa-upload"></i> 上传头像
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<div class="dialog-form-item">
|
||||
<div class="dialog-form-label">用户名</div>
|
||||
<el-input
|
||||
v-model="userForm.username"
|
||||
placeholder="请输入用户名"
|
||||
:disabled="!isNewUser"
|
||||
></el-input>
|
||||
</div>
|
||||
|
||||
<div class="dialog-form-item">
|
||||
<div class="dialog-form-label">姓名</div>
|
||||
<el-input
|
||||
v-model="userForm.name"
|
||||
placeholder="请输入姓名"
|
||||
></el-input>
|
||||
</div>
|
||||
|
||||
<div class="dialog-form-item">
|
||||
<div class="dialog-form-label">所属部门</div>
|
||||
<el-select
|
||||
v-model="userForm.departmentId"
|
||||
placeholder="请选择部门"
|
||||
>
|
||||
<el-option
|
||||
v-for="dept in departments"
|
||||
:key="dept.id"
|
||||
:label="dept.name"
|
||||
:value="dept.id"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
|
||||
<div class="dialog-form-item">
|
||||
<div class="dialog-form-label">职位</div>
|
||||
<el-input
|
||||
v-model="userForm.position"
|
||||
placeholder="请输入职位"
|
||||
></el-input>
|
||||
</div>
|
||||
|
||||
<div class="dialog-form-item">
|
||||
<div class="dialog-form-label">手机号</div>
|
||||
<el-input
|
||||
v-model="userForm.phone"
|
||||
placeholder="请输入手机号"
|
||||
></el-input>
|
||||
</div>
|
||||
|
||||
<div class="dialog-form-item">
|
||||
<div class="dialog-form-label">邮箱</div>
|
||||
<el-input
|
||||
v-model="userForm.email"
|
||||
placeholder="请输入邮箱"
|
||||
></el-input>
|
||||
</div>
|
||||
|
||||
<div class="dialog-form-item">
|
||||
<div class="dialog-form-label">角色</div>
|
||||
<el-radio-group v-model="userForm.role">
|
||||
<el-radio label="admin">管理员</el-radio>
|
||||
<el-radio label="dept_manager">部门负责人</el-radio>
|
||||
<el-radio label="user">普通用户</el-radio>
|
||||
</el-radio-group>
|
||||
</div>
|
||||
|
||||
<div class="dialog-form-item" v-if="isNewUser">
|
||||
<div class="dialog-form-label">初始密码</div>
|
||||
<el-input
|
||||
v-model="userForm.password"
|
||||
type="password"
|
||||
placeholder="请输入初始密码"
|
||||
></el-input>
|
||||
</div>
|
||||
|
||||
<div class="dialog-form-item">
|
||||
<div class="dialog-form-label">用户状态</div>
|
||||
<el-radio-group v-model="userForm.status">
|
||||
<el-radio label="active">活跃</el-radio>
|
||||
<el-radio label="inactive">禁用</el-radio>
|
||||
</el-radio-group>
|
||||
</div>
|
||||
|
||||
<div slot="footer">
|
||||
<el-button @click="showDialog = false">取消</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="saveUser"
|
||||
:loading="saving"
|
||||
>
|
||||
保存
|
||||
</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
new Vue({
|
||||
el: '#app',
|
||||
data() {
|
||||
return {
|
||||
searchQuery: '',
|
||||
departmentFilter: '',
|
||||
roleFilter: '',
|
||||
showDialog: false,
|
||||
dialogTitle: '新增用户',
|
||||
saving: false,
|
||||
departments: [
|
||||
{ id: 1, name: '技术部' },
|
||||
{ id: 2, name: '市场部' },
|
||||
{ id: 3, name: '人力资源部' },
|
||||
{ id: 4, name: '财务部' },
|
||||
{ id: 5, name: '行政部' }
|
||||
],
|
||||
users: [
|
||||
{
|
||||
id: 1,
|
||||
username: 'admin',
|
||||
name: '系统管理员',
|
||||
avatar: 'https://cdn.jsdelivr.net/npm/element-ui@2.15.8/lib/theme-chalk/avatar.jpg',
|
||||
departmentId: 1,
|
||||
departmentName: '技术部',
|
||||
position: '系统管理员',
|
||||
phone: '13800138000',
|
||||
email: 'admin@example.com',
|
||||
role: 'admin',
|
||||
status: 'active',
|
||||
createTime: '2023-01-01'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
username: 'zhangjingli',
|
||||
name: '张经理',
|
||||
avatar: 'https://cdn.jsdelivr.net/npm/element-ui@2.15.8/lib/theme-chalk/avatar.jpg',
|
||||
departmentId: 1,
|
||||
departmentName: '技术部',
|
||||
position: '部门经理',
|
||||
phone: '13812345678',
|
||||
email: 'zhang@example.com',
|
||||
role: 'dept_manager',
|
||||
status: 'active',
|
||||
createTime: '2023-01-15'
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
username: 'liming',
|
||||
name: '李明',
|
||||
avatar: 'https://cdn.jsdelivr.net/npm/element-ui@2.15.8/lib/theme-chalk/avatar.jpg',
|
||||
departmentId: 2,
|
||||
departmentName: '市场部',
|
||||
position: '专员',
|
||||
phone: '13987654321',
|
||||
email: 'liming@example.com',
|
||||
role: 'user',
|
||||
status: 'active',
|
||||
createTime: '2023-02-01'
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
username: 'wanghong',
|
||||
name: '王红',
|
||||
avatar: 'https://cdn.jsdelivr.net/npm/element-ui@2.15.8/lib/theme-chalk/avatar.jpg',
|
||||
departmentId: 3,
|
||||
departmentName: '人力资源部',
|
||||
position: 'HR',
|
||||
phone: '13765432198',
|
||||
email: 'wanghong@example.com',
|
||||
role: 'user',
|
||||
status: 'active',
|
||||
createTime: '2023-02-15'
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
username: 'zhaoming',
|
||||
name: '赵明',
|
||||
avatar: 'https://cdn.jsdelivr.net/npm/element-ui@2.15.8/lib/theme-chalk/avatar.jpg',
|
||||
departmentId: 4,
|
||||
departmentName: '财务部',
|
||||
position: '会计',
|
||||
phone: '13654321987',
|
||||
email: 'zhaoming@example.com',
|
||||
role: 'user',
|
||||
status: 'inactive',
|
||||
createTime: '2023-03-01'
|
||||
}
|
||||
],
|
||||
userForm: {
|
||||
id: '',
|
||||
username: '',
|
||||
name: '',
|
||||
avatar: '',
|
||||
departmentId: '',
|
||||
departmentName: '',
|
||||
position: '',
|
||||
phone: '',
|
||||
email: '',
|
||||
role: 'user',
|
||||
password: '',
|
||||
status: 'active'
|
||||
},
|
||||
userStats: {
|
||||
total: 5,
|
||||
active: 4,
|
||||
admins: 1,
|
||||
managers: 1
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
filteredUsers() {
|
||||
return this.users.filter(user => {
|
||||
// 搜索用户名或姓名
|
||||
const matchesSearch = !this.searchQuery ||
|
||||
user.username.toLowerCase().includes(this.searchQuery.toLowerCase()) ||
|
||||
user.name.toLowerCase().includes(this.searchQuery.toLowerCase());
|
||||
|
||||
// 部门筛选
|
||||
const matchesDepartment = !this.departmentFilter ||
|
||||
user.departmentId === this.departmentFilter;
|
||||
|
||||
// 角色筛选
|
||||
const matchesRole = !this.roleFilter ||
|
||||
user.role === this.roleFilter;
|
||||
|
||||
return matchesSearch && matchesDepartment && matchesRole;
|
||||
});
|
||||
},
|
||||
|
||||
isNewUser() {
|
||||
return !this.userForm.id;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 导航到其他页面
|
||||
navigateTo(page) {
|
||||
let url = '';
|
||||
switch (page) {
|
||||
case 'department':
|
||||
url = 'department-management.html';
|
||||
break;
|
||||
case 'user':
|
||||
url = 'user-management.html';
|
||||
break;
|
||||
case 'task':
|
||||
url = 'task-management.html';
|
||||
break;
|
||||
case 'image':
|
||||
url = 'image-management.html';
|
||||
break;
|
||||
}
|
||||
if (url && url !== window.location.pathname) {
|
||||
window.location.href = url;
|
||||
}
|
||||
},
|
||||
|
||||
// 格式化日期
|
||||
formatDate(dateStr) {
|
||||
return dateStr;
|
||||
},
|
||||
|
||||
// 获取角色文本
|
||||
getRoleText(role) {
|
||||
const roleMap = {
|
||||
'admin': '管理员',
|
||||
'dept_manager': '部门负责人',
|
||||
'user': '普通用户'
|
||||
};
|
||||
return roleMap[role] || '普通用户';
|
||||
},
|
||||
|
||||
// 新增用户
|
||||
addUser() {
|
||||
this.dialogTitle = '新增用户';
|
||||
this.userForm = {
|
||||
id: '',
|
||||
username: '',
|
||||
name: '',
|
||||
avatar: '',
|
||||
departmentId: '',
|
||||
departmentName: '',
|
||||
position: '',
|
||||
phone: '',
|
||||
email: '',
|
||||
role: 'user',
|
||||
password: '',
|
||||
status: 'active'
|
||||
};
|
||||
this.showDialog = true;
|
||||
},
|
||||
|
||||
// 编辑用户
|
||||
editUser(user) {
|
||||
this.dialogTitle = '编辑用户';
|
||||
this.userForm = { ...user };
|
||||
this.showDialog = true;
|
||||
},
|
||||
|
||||
// 保存用户
|
||||
saveUser() {
|
||||
// 表单验证
|
||||
if (!this.userForm.username.trim()) {
|
||||
this.$message.error('请输入用户名');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.userForm.name.trim()) {
|
||||
this.$message.error('请输入姓名');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.userForm.departmentId) {
|
||||
this.$message.error('请选择所属部门');
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.isNewUser && !this.userForm.password.trim()) {
|
||||
this.$message.error('请输入初始密码');
|
||||
return;
|
||||
}
|
||||
|
||||
// 更新部门名称
|
||||
const dept = this.departments.find(d => d.id === this.userForm.departmentId);
|
||||
if (dept) {
|
||||
this.userForm.departmentName = dept.name;
|
||||
}
|
||||
|
||||
this.saving = true;
|
||||
|
||||
// 模拟保存操作
|
||||
setTimeout(() => {
|
||||
if (this.userForm.id) {
|
||||
// 编辑现有用户
|
||||
const index = this.users.findIndex(u => u.id === this.userForm.id);
|
||||
if (index > -1) {
|
||||
this.users[index] = { ...this.userForm };
|
||||
this.$message.success('用户信息已更新');
|
||||
}
|
||||
} else {
|
||||
// 添加新用户
|
||||
const newId = Math.max(...this.users.map(u => u.id), 0) + 1;
|
||||
const newUser = {
|
||||
...this.userForm,
|
||||
id: newId,
|
||||
avatar: this.userForm.avatar || 'https://cdn.jsdelivr.net/npm/element-ui@2.15.8/lib/theme-chalk/avatar.jpg',
|
||||
createTime: new Date().toISOString().split('T')[0]
|
||||
};
|
||||
this.users.unshift(newUser);
|
||||
|
||||
// 更新统计数据
|
||||
this.userStats.total++;
|
||||
if (newUser.status === 'active') {
|
||||
this.userStats.active++;
|
||||
}
|
||||
if (newUser.role === 'admin') {
|
||||
this.userStats.admins++;
|
||||
} else if (newUser.role === 'dept_manager') {
|
||||
this.userStats.managers++;
|
||||
}
|
||||
|
||||
this.$message.success('用户已创建');
|
||||
}
|
||||
|
||||
this.saving = false;
|
||||
this.showDialog = false;
|
||||
}, 1000);
|
||||
},
|
||||
|
||||
// 重置密码
|
||||
resetPassword(userId) {
|
||||
this.$confirm(`确定要重置该用户的密码吗?重置后密码将变为123456。`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
this.$message.success('密码已重置为:123456');
|
||||
}).catch(() => {
|
||||
// 取消重置
|
||||
});
|
||||
},
|
||||
|
||||
// 删除用户
|
||||
deleteUser(userId) {
|
||||
if (userId === 1) {
|
||||
this.$message.warning('系统管理员不能删除');
|
||||
return;
|
||||
}
|
||||
|
||||
this.$confirm(`确定要删除该用户吗?删除后将无法恢复。`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
const index = this.users.findIndex(u => u.id === userId);
|
||||
if (index > -1) {
|
||||
const user = this.users[index];
|
||||
this.users.splice(index, 1);
|
||||
|
||||
// 更新统计数据
|
||||
this.userStats.total--;
|
||||
if (user.status === 'active') {
|
||||
this.userStats.active--;
|
||||
}
|
||||
if (user.role === 'admin') {
|
||||
this.userStats.admins--;
|
||||
} else if (user.role === 'dept_manager') {
|
||||
this.userStats.managers--;
|
||||
}
|
||||
|
||||
this.$message.success('用户已删除');
|
||||
}
|
||||
}).catch(() => {
|
||||
// 取消删除
|
||||
});
|
||||
},
|
||||
|
||||
// 处理退出登录
|
||||
handleLogout() {
|
||||
this.$confirm('确定要退出登录吗?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
this.$message.success('退出成功');
|
||||
setTimeout(() => {
|
||||
window.location.href = 'admin-login.html';
|
||||
}, 1000);
|
||||
}).catch(() => {
|
||||
// 取消退出
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user