<template>
|
<div class="sidebar-logo-container">
|
<router-link class="sidebar-logo-link" to="/">
|
<img :src="logo" class="sidebar-logo" />
|
<h1 class="sidebar-title">企业信息查询系统{{ title }}</h1>
|
</router-link>
|
<div class="right-menu">
|
<el-dropdown class="avatar-container" trigger="click">
|
<!-- <div class="avatar-wrapper">-->
|
<!-- <div style="line-height:30px;cursor: pointer;">{{ username }}</div>-->
|
<!-- <i class="el-icon-caret-bottom" />-->
|
<!-- </div>-->
|
<span class="el-dropdown-link">
|
{{username}}<i class="el-icon-arrow-down el-icon--right"></i>
|
</span>
|
<el-dropdown-menu slot="dropdown" class="user-dropdown">
|
<router-link to="/">
|
<el-dropdown-item>首页</el-dropdown-item>
|
</router-link>
|
<router-link to="/userpermisson/user">
|
<el-dropdown-item>用户管理</el-dropdown-item>
|
</router-link>
|
<el-dropdown-item divided>
|
<span style="display:block;" @click="logout">退出</span>
|
</el-dropdown-item>
|
<el-dropdown-item>
|
<span style="display:block;" @click="handleEdit()">修改密码</span>
|
</el-dropdown-item>
|
</el-dropdown-menu>
|
</el-dropdown>
|
|
</div>
|
<el-dialog
|
:close-on-click-modal="false"
|
:destroy-on-close="true"
|
title="修改密码"
|
:visible.sync="editDialogVisible"
|
width="30%"
|
:before-close="handleClose"
|
:append-to-body='true'
|
>
|
<el-form ref="editform" :model="editFormData" :rules="editRules" label-width="80px">
|
<el-form-item prop="account" label="账号">
|
<el-input disabled v-model="editFormData.account" size="medium"></el-input>
|
</el-form-item>
|
|
<el-form-item prop="oldpassword" label="原密码">
|
<el-input v-model="editFormData.oldpassword" size="medium" type="password"></el-input>
|
</el-form-item>
|
|
<el-form-item prop="newpassword" label="新密码">
|
<el-input v-model="editFormData.newpassword" size="medium" type="password"></el-input>
|
</el-form-item>
|
|
<el-form-item prop="confirmnewpassword" label="确认密码">
|
<el-input v-model="editFormData.confirmnewpassword" size="medium" type="password"></el-input>
|
</el-form-item>
|
|
<el-form-item align="center" label-width="0">
|
<el-button type="primary" @click="onEditSubmit()">{{ $t('common.ok') }}</el-button>
|
<el-button @click="editDialogVisible = false">{{ $t('common.cancel') }}</el-button>
|
</el-form-item>
|
</el-form>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script>
|
import { mount } from '@vue/test-utils';
|
import { getUser, getUserById1, updateUser } from '@/api/user';
|
import { rules } from '@/utils/validate';
|
import { deepClone } from '@/utils';
|
export default {
|
name: 'SidebarLogo',
|
props: {},
|
data() {
|
return {
|
title: '企业信息查询系统',
|
logo: require('@/assets/logo.png'),
|
disabled: false,
|
editDialogVisible: false,
|
editFormData: {
|
account: '',
|
oldpassword: '',
|
newpassword: '',
|
confirmnewpassword: ''
|
},
|
editRules: {
|
oldpassword: rules.empty,
|
newpassword: rules.empty,
|
confirmnewpassword: rules.empty
|
},
|
username: localStorage.getItem("name")
|
};
|
},
|
mounted() {
|
this.title = this.$store.state.park.name;
|
},
|
methods: {
|
async logout() {
|
await this.$store.dispatch('user/logout');
|
this.$router.push(`/login?redirect=${this.$route.fullPath}`);
|
window.location.reload();
|
},
|
async handleEdit() {
|
this.editDialogVisible = true;
|
const res = await getUserById1();
|
this.editFormData.account = res.data.username;
|
},
|
async onEditSubmit() {
|
// const res = await getUserById1();
|
// if (md5(this.editFormData.oldpassword, 32) != res.data.password) {
|
// this.$message('原密码不正确,请确认', 'error');
|
// return;
|
// }
|
|
if (this.editFormData.newpassword != this.editFormData.confirmnewpassword) {
|
this.$message('两次输入密码不一致,请确认', 'error');
|
return;
|
}
|
|
this.$refs.editform.validate(async valid => {
|
if (valid) {
|
//const res1 = await findCompanyById();
|
//res1.data.adminaccoutpassword = md5(this.editFormData.newpassword, 32);
|
// this.editFormData.password= md5(this.editFormData.newpassword, 32)
|
const res = await updateUser(this.editFormData);
|
if (res.status == 200) {
|
this.$message(this.$t('message.edit_success'), 'success');
|
} else {
|
this.$message(this.$t('message.edit_fail'), 'success');
|
}
|
this.editDialogVisible = false;
|
this.editFormData = deepClone(EditFormData);
|
}
|
});
|
},
|
handleClose(done) {
|
done();
|
}
|
}
|
};
|
</script>
|
|
<style lang="scss" scoped>
|
.sidebarLogoFade-enter-active {
|
transition: opacity 1.5s;
|
}
|
|
.sidebarLogoFade-enter,
|
.sidebarLogoFade-leave-to {
|
opacity: 0;
|
}
|
|
.sidebar-logo-container {
|
position: fixed;
|
z-index: 5;
|
top:0;
|
left: 0;
|
width: 100%;
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
height: 70px;
|
padding-left: 40px;
|
line-height: 70px;
|
background: linear-gradient(to right, #11abff, #3c50fc);
|
text-align: left;
|
|
.sidebar-logo-link {
|
height: 100%;
|
display: flex;
|
align-items: center;
|
|
.sidebar-logo {
|
width: 32px;
|
height: 32px;
|
margin-right: 10px;
|
}
|
|
.sidebar-title {
|
color: #fff;
|
font-weight: 600;
|
font-size: 18px;
|
letter-spacing: 2px;
|
font-family: Avenir, Helvetica Neue, Arial, Helvetica, sans-serif;
|
}
|
}
|
|
.right-menu {
|
height: 100%;
|
line-height: 70px;
|
color: #fff;
|
.el-dropdown-link{
|
color: #fff;
|
cursor: pointer;
|
}
|
.avatar-container {
|
margin-right: 30px;
|
|
.avatar-wrapper {
|
margin-top: 10px;
|
position: relative;
|
|
.user-avatar {
|
cursor: pointer;
|
width: 40px;
|
height: 40px;
|
border-radius: 10px;
|
}
|
|
.el-icon-caret-bottom {
|
cursor: pointer;
|
position: absolute;
|
right: -20px;
|
top: 10px;
|
font-size: 12px;
|
}
|
}
|
}
|
}
|
}
|
</style>
|