刘翔宇-旅管家 3 years ago
parent fc0adfbcfd
commit 6faaf9d111

@ -1,133 +1,140 @@
<template> <template>
<div class="navbar"> <div class="navbar">
<hamburger :is-active="sidebar.opened" class="hamburger-container" @toggleClick="toggleSideBar" /> <hamburger :is-active="sidebar.opened" class="hamburger-container" @toggleClick="toggleSideBar" />
<breadcrumb class="breadcrumb-container" /> <breadcrumb class="breadcrumb-container" />
<div class="right-menu"> <div class="right-menu">
<el-dropdown class="avatar-container" trigger="click"> <el-dropdown class="avatar-container" trigger="click">
<div class="avatar-wrapper"> <div class="avatar-wrapper">
<img src="../../assets/face.jpg" class="user-avatar"> <img src="../../assets/face.jpg" class="user-avatar">
<i class="el-icon-caret-bottom" /> <i class="el-icon-caret-bottom" />
</div> </div>
<el-dropdown-menu slot="dropdown" class="user-dropdown"> <el-dropdown-menu slot="dropdown" class="user-dropdown">
<router-link to="/"> <router-link to="/">
<el-dropdown-item> <el-dropdown-item>
系统首页 系统首页
</el-dropdown-item> </el-dropdown-item>
</router-link> </router-link>
<el-dropdown-item divided @click.native="logout"> <router-link to="/info/password">
<span style="display:block;">退出</span> <el-dropdown-item>
</el-dropdown-item> 个人信息
</el-dropdown-menu> </el-dropdown-item>
</el-dropdown> </router-link>
</div> <el-dropdown-item divided @click.native="logout">
</div> <span style="display:block;">退出</span>
</template> </el-dropdown-item>
</el-dropdown-menu>
<script> </el-dropdown>
import { mapGetters } from 'vuex' </div>
import Breadcrumb from '@/components/Breadcrumb' </div>
import Hamburger from '@/components/Hamburger' </template>
export default { <script>
components: { import {
Breadcrumb, mapGetters
Hamburger } from 'vuex'
}, import Breadcrumb from '@/components/Breadcrumb'
computed: { import Hamburger from '@/components/Hamburger'
...mapGetters([
'sidebar', export default {
'avatar' components: {
]) Breadcrumb,
}, Hamburger
methods: { },
toggleSideBar() { computed: {
this.$store.dispatch('app/toggleSideBar') ...mapGetters([
}, 'sidebar',
async logout() { 'avatar'
await this.$store.dispatch('user/logout') ])
this.$router.push(`/login?redirect=${this.$route.fullPath}`) },
} methods: {
} toggleSideBar() {
} this.$store.dispatch('app/toggleSideBar')
</script> },
async logout() {
<style lang="scss" scoped> await this.$store.dispatch('user/logout')
.navbar { this.$router.push(`/login?redirect=${this.$route.fullPath}`)
height: 50px; }
overflow: hidden; }
position: relative; }
background: #fff; </script>
box-shadow: 0 1px 4px rgba(0,21,41,.08);
<style lang="scss" scoped>
.hamburger-container { .navbar {
line-height: 46px; height: 50px;
height: 100%; overflow: hidden;
float: left; position: relative;
cursor: pointer; background: #fff;
transition: background .3s; box-shadow: 0 1px 4px rgba(0, 21, 41, .08);
-webkit-tap-highlight-color:transparent;
.hamburger-container {
&:hover { line-height: 46px;
background: rgba(0, 0, 0, .025) height: 100%;
} float: left;
} cursor: pointer;
transition: background .3s;
.breadcrumb-container { -webkit-tap-highlight-color: transparent;
float: left;
} &:hover {
background: rgba(0, 0, 0, .025)
.right-menu { }
float: right; }
height: 100%;
line-height: 50px; .breadcrumb-container {
float: left;
&:focus { }
outline: none;
} .right-menu {
float: right;
.right-menu-item { height: 100%;
display: inline-block; line-height: 50px;
padding: 0 8px;
height: 100%; &:focus {
font-size: 18px; outline: none;
color: #5a5e66; }
vertical-align: text-bottom;
.right-menu-item {
&.hover-effect { display: inline-block;
cursor: pointer; padding: 0 8px;
transition: background .3s; height: 100%;
font-size: 18px;
&:hover { color: #5a5e66;
background: rgba(0, 0, 0, .025) vertical-align: text-bottom;
}
} &.hover-effect {
} cursor: pointer;
transition: background .3s;
.avatar-container {
margin-right: 30px; &:hover {
background: rgba(0, 0, 0, .025)
.avatar-wrapper { }
margin-top: 5px; }
position: relative; }
.user-avatar { .avatar-container {
cursor: pointer; margin-right: 30px;
width: 40px;
height: 40px; .avatar-wrapper {
border-radius: 10px; margin-top: 5px;
} position: relative;
.el-icon-caret-bottom { .user-avatar {
cursor: pointer; cursor: pointer;
position: absolute; width: 40px;
right: -20px; height: 40px;
top: 25px; border-radius: 10px;
font-size: 12px; }
}
} .el-icon-caret-bottom {
} cursor: pointer;
} position: absolute;
} right: -20px;
top: 25px;
font-size: 12px;
}
}
}
}
}
</style> </style>

@ -1,92 +1,106 @@
import Vue from 'vue' import Vue from 'vue'
import Router from 'vue-router' import Router from 'vue-router'
Vue.use(Router) Vue.use(Router)
/* Layout */ /* Layout */
import Layout from '@/layout' import Layout from '@/layout'
/** /**
* Note: sub-menu only appear when route children.length >= 1 * Note: sub-menu only appear when route children.length >= 1
* Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
* *
* hidden: true if set true, item will not show in the sidebar(default is false) * hidden: true if set true, item will not show in the sidebar(default is false)
* alwaysShow: true if set true, will always show the root menu * alwaysShow: true if set true, will always show the root menu
* if not set alwaysShow, when item has more than one children route, * if not set alwaysShow, when item has more than one children route,
* it will becomes nested mode, otherwise not show the root menu * it will becomes nested mode, otherwise not show the root menu
* redirect: noRedirect if set noRedirect will no redirect in the breadcrumb * redirect: noRedirect if set noRedirect will no redirect in the breadcrumb
* name:'router-name' the name is used by <keep-alive> (must set!!!) * name:'router-name' the name is used by <keep-alive> (must set!!!)
* meta : { * meta : {
roles: ['admin','editor'] control the page roles (you can set multiple roles) roles: ['admin','editor'] control the page roles (you can set multiple roles)
title: 'title' the name show in sidebar and breadcrumb (recommend set) title: 'title' the name show in sidebar and breadcrumb (recommend set)
icon: 'svg-name'/'el-icon-x' the icon show in the sidebar icon: 'svg-name'/'el-icon-x' the icon show in the sidebar
breadcrumb: false if set false, the item will hidden in breadcrumb(default is true) breadcrumb: false if set false, the item will hidden in breadcrumb(default is true)
activeMenu: '/example/list' if set path, the sidebar will highlight the path you set activeMenu: '/example/list' if set path, the sidebar will highlight the path you set
} }
*/ */
/** /**
* constantRoutes * constantRoutes
* a base page that does not have permission requirements * a base page that does not have permission requirements
* all roles can be accessed * all roles can be accessed
*/ */
export const constantRoutes = [{ export const constantRoutes = [{
path: '/login', path: '/login',
component: () => import('@/views/login/index'), component: () => import('@/views/login/index'),
hidden: true hidden: true
}, },
{ {
path: '/404', path: '/404',
component: () => import('@/views/404'), component: () => import('@/views/404'),
hidden: true hidden: true
}, },
{
path: '/', {
component: Layout, path: '/info',
redirect: '/dashboard', component: Layout,
children: [{ children: [{
path: 'dashboard', path: 'password',
name: '系统首页', component: () => import('@/views/system/password'),
component: () => import('@/views/dashboard/index'), name: '密码修改',
meta: { meta: {
title: '系统首页', title: '密码修改'
icon: 'dashboard' }
} }],
}, hidden: true
] },
}
] {
path: '/',
/** component: Layout,
* asyncRoutes redirect: '/dashboard',
* the routes that need to be dynamically loaded based on user roles children: [{
*/ path: 'dashboard',
export const asyncRoutes = [ name: '系统首页',
component: () => import('@/views/dashboard/index'),
meta: {
// 404 page must be placed at the end !!! title: '系统首页',
{ icon: 'dashboard'
path: '*', }
redirect: '/404', }, ]
hidden: true }
} ]
]
/**
const createRouter = () => new Router({ * asyncRoutes
// mode: 'history', // require service support * the routes that need to be dynamically loaded based on user roles
scrollBehavior: () => ({ */
y: 0 export const asyncRoutes = [
}),
routes: constantRoutes
}) // 404 page must be placed at the end !!!
{
const router = createRouter() path: '*',
redirect: '/404',
// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465 hidden: true
export function resetRouter() { }
const newRouter = createRouter() ]
router.matcher = newRouter.matcher // reset router
} const createRouter = () => new Router({
// mode: 'history', // require service support
scrollBehavior: () => ({
y: 0
}),
routes: constantRoutes
})
const router = createRouter()
// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
const newRouter = createRouter()
router.matcher = newRouter.matcher // reset router
}
export default router export default router

@ -0,0 +1,72 @@
<template>
<el-form :model="form" ref="form" :rules="rules">
<el-form-item label="姓名" label-position="right" prop="name">
<el-input v-model.trim="form.name" />
</el-form-item>
<el-form-item label="密码" label-position="right" prop="password">
<el-input v-model.trim="form.password" type="password" />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="submit"></el-button>
</el-form-item>
</el-form>
</template>
<script>
import {
save
} from '../../../api/system/user.js'
import {
getInfo
} from '../../../api/user.js'
export default {
data() {
return {
form: {
id: "",
name: "",
username: "",
password: ""
},
rules: {
name: [{
required: true,
message: '请输入姓名',
trigger: 'blur'
}],
password: [{
required: true,
message: '请输入密码',
trigger: 'blur',
}]
},
}
},
created() {
getInfo().then(res => {
this.form.id = res.id;
this.form.name = res.name
this.form.username = res.username
})
},
methods: {
submit() {
let that = this;
this.$refs["form"].validate((valid) => {
if (valid) {
save(that.form).then(response => {
this.$Message.success('操作成功');
}).catch(error => {
//reject(error)
})
} else {
this.$Message.error('数据校验失败');
console.log('error submit!!');
return false;
}
});
}
}
}
</script>

@ -0,0 +1,54 @@
<template>
<div class="block">
<el-timeline>
<el-timeline-item v-for="(item,index) of timeline" :key="index" :timestamp="item.timestamp" placement="top">
<el-card>
<h4>{{ item.created_at }}</h4>
<p>{{ item.name }}</p>
</el-card>
</el-timeline-item>
</el-timeline>
</div>
</template>
<script>
import {
listlog
} from "../../../api/system/log.js";
export default {
data() {
return {
timeline: [],
paginations: {
page: 1,
page_size: 15,
total: 0
},
tableHeight: 0,
//
searchFields: {
keyword: ""
}
}
},
created() {
this.load();
},
methods: {
load() {
var that = this;
listlog({
page: that.paginations.page,
...this.searchFields
}).then(response => {
var data = response.data;
this.paginations.total = response.total;
that.timeline = data;
}).catch(error => {
console.log(error)
//reject(error)
})
}
}
}
</script>

@ -0,0 +1,118 @@
<template>
<el-card style="margin-bottom:20px;">
<div slot="header" class="clearfix">
<span>个人信息</span>
</div>
<div class="user-profile">
<div class="box-center">
<pan-thumb :image="user.avatar" :height="'100px'" :width="'100px'" :hoverable="false">
<div>Hello</div>
{{ user.role }}
</pan-thumb>
</div>
<div class="box-center">
<div class="user-name text-center">{{ user.name }}</div>
<div class="user-role text-center text-muted">{{ user.role | uppercaseFirst }}</div>
</div>
</div>
<div class="user-bio">
<div class="user-education user-bio-section">
<div class="user-bio-section-header">
<svg-icon icon-class="education" /><span>部门信息</span>
</div>
<div class="user-bio-section-body">
<div class="text-muted">
{{user.department||"暂无"}}
</div>
</div>
</div>
</div>
</el-card>
</template>
<script>
import PanThumb from '@/components/PanThumb'
export default {
components: {
PanThumb
},
props: {
user: {
type: Object,
default: () => {
return {
name: '',
username: '',
avatar: '',
role: '',
department: ''
}
}
}
},
}
</script>
<style lang="scss" scoped>
.box-center {
margin: 0 auto;
display: table;
}
.text-muted {
color: #777;
}
.user-profile {
.user-name {
font-weight: bold;
}
.box-center {
padding-top: 10px;
}
.user-role {
padding-top: 10px;
font-weight: 400;
font-size: 14px;
}
.box-social {
padding-top: 30px;
.el-table {
border-top: 1px solid #dfe6ec;
}
}
.user-follow {
padding-top: 20px;
}
}
.user-bio {
margin-top: 20px;
color: #606266;
span {
padding-left: 4px;
}
.user-bio-section {
font-size: 14px;
padding: 15px 0;
.user-bio-section-header {
border-bottom: 1px solid #dfe6ec;
padding-bottom: 10px;
margin-bottom: 10px;
font-weight: bold;
}
}
}
</style>

@ -0,0 +1,78 @@
<template>
<div class="" style="margin-top: 20px;">
<div v-if="user">
<el-row :gutter="20">
<el-col :span="6" :xs="24">
<user-card :user="user" />
</el-col>
<el-col :span="18" :xs="24">
<el-card>
<el-tabs v-model="activeTab">
<el-tab-pane label="操作日志" name="timeline">
<timeline />
</el-tab-pane>
<el-tab-pane label="信息修改" name="account">
<account />
</el-tab-pane>
</el-tabs>
</el-card>
</el-col>
</el-row>
</div>
</div>
</template>
<script>
import {
mapGetters
} from 'vuex'
import UserCard from './components/UserCard'
import Timeline from './components/Timeline'
import Account from './components/Account'
import {
getInfo
} from '../../api/user.js'
export default {
name: 'Profile',
components: {
UserCard,
Timeline,
Account
},
data() {
return {
user: {},
activeTab: 'timeline'
}
},
computed: {
...mapGetters([
'name',
'avatar',
'roles'
])
},
created() {
this.getUser()
},
methods: {
getUser() {
getInfo().then(res => {
this.user = {
name:res.name,
username:res.username,
role: this.roles.join(' | '),
avatar: this.avatar
}
})
}
}
}
</script>

@ -113,24 +113,12 @@
required: true, required: true,
message: '请输入姓名', message: '请输入姓名',
trigger: 'blur' trigger: 'blur'
},
{
min: 3,
max: 5,
message: '长度在 3 到 5 个字符',
trigger: 'blur'
} }
], ],
username: [{ username: [{
required: true, required: true,
message: '请输入用户名', message: '请输入用户名',
trigger: 'blur' trigger: 'blur'
},
{
min: 3,
max: 5,
message: '长度在 3 到 5 个字符',
trigger: 'blur'
} }
], ],
password: [{ password: [{

Loading…
Cancel
Save