Browse Source

权限管理

master
huxinglu 4 years ago
parent
commit
d32a81c251
3 changed files with 63 additions and 47 deletions
  1. +4
    -1
      src/router/index.js
  2. +53
    -45
      src/views/index/index.vue
  3. +6
    -1
      src/views/login/index.vue

+ 4
- 1
src/router/index.js View File

@@ -92,7 +92,7 @@ router.onError((error) => {
router.beforeEach(async (to, from, next) => {
// 登录界面登录成功之后,会把用户信息保存在会话
// 存在时间为会话生命周期,页面关闭即失效。
if(to.path=='/main'||to.path=='/command'){
if(to.path=='/main'){
next()
return
}
@@ -111,6 +111,9 @@ router.beforeEach(async (to, from, next) => {
next()
}
} else{
if(to.path=='/command'){
next()
}
if (!store.state.user.roles) {
if (!store.state.user.info) {
await store.dispatch('user/getInfo')

+ 53
- 45
src/views/index/index.vue View File

@@ -19,6 +19,10 @@
<svg-icon iconClass='home' className='icon'></svg-icon>
<span>首页</span></el-menu-item>
</el-tooltip>
<el-menu-item @click="command">
<svg-icon iconClass='eye-open' className='icon'></svg-icon>
<span>指挥大屏</span>
</el-menu-item>
<el-submenu :key="index" v-for="(item,index) in filterMenuList" :index="item.name">
<template slot="title">
<svg-icon :iconClass='item.icon' className='icon'></svg-icon>
@@ -81,35 +85,35 @@
:direction="direction"
:size="drawerWidth"
:before-close="handleClose">
<el-form ref="passwordForm" :model="passwordForm" size="small" label-width="100px"
style="width: 50%" class="form">
<el-form-item label="原密码" prop="oldPassword" :rules="[
<el-form ref="passwordForm" :model="passwordForm" size="small" label-width="100px"
style="width: 50%" class="form">
<el-form-item label="原密码" prop="oldPassword" :rules="[
{required: true, message: '原密码不能为空', trigger: 'blur'},
{min: 6, max: 20, message: '长度6-20位', trigger: 'blur'}
]">
<el-input show-password type="password" clearable v-model="passwordForm.oldPassword" size="small"
placeholder="请输入原密码"/>
</el-form-item>
<el-form-item label="新密码" prop="password" :rules="[
<el-input show-password type="password" clearable v-model="passwordForm.oldPassword" size="small"
placeholder="请输入原密码"/>
</el-form-item>
<el-form-item label="新密码" prop="password" :rules="[
{required: true, message: '新密码不能为空', trigger: 'blur'},
{min: 6, max: 20, message: '长度6-20位', trigger: 'blur'}
]">
<el-input show-password type="password" clearable v-model="passwordForm.password" size="small"
placeholder="请输入新密码"/>
</el-form-item>
<el-form-item label="确认新密码" prop="rePassword" :rules="[
<el-input show-password type="password" clearable v-model="passwordForm.password" size="small"
placeholder="请输入新密码"/>
</el-form-item>
<el-form-item label="确认新密码" prop="rePassword" :rules="[
{required: true, message: '确认新密码不能为空', trigger: 'blur'},
{min: 6, max: 20, message: '长度6-20位', trigger: 'blur'}
]">
<el-input show-password type="password" clearable v-model="passwordForm.rePassword" size="small"
placeholder="请输入确认新密码"/>
</el-form-item>
<el-form-item>
<el-button :loading="addBtnLoading" type="primary" size="small"
@click="submitForm('passwordForm',2)">立即提交
</el-button>
</el-form-item>
</el-form>
<el-input show-password type="password" clearable v-model="passwordForm.rePassword" size="small"
placeholder="请输入确认新密码"/>
</el-form-item>
<el-form-item>
<el-button :loading="addBtnLoading" type="primary" size="small"
@click="submitForm('passwordForm',2)">立即提交
</el-button>
</el-form-item>
</el-form>
</el-drawer>
</div>
</template>
@@ -125,14 +129,14 @@
drawerWidth: (document.body.clientWidth - 190) + 'px',
direction: 'rtl',
isCollapse: false,
visible:false,
visible: false,
menuList: [],
info: {},
height: 0,
roles: store.state.user.roles.filter(item => item.type == 2),
filterMenuList: [],
isShowMenu: true,
browser:'',
browser: '',
configForm: {
photo: '',
realName: '',
@@ -161,7 +165,7 @@
}
},
created() {
this.browser=this.isIE()
this.browser = this.isIE()
this.height = document.body.clientHeight - 120
this.pageSize = parseInt((document.body.clientHeight - 344) / 50)
this.initConfig()
@@ -188,32 +192,34 @@
return this.$store.state.user.isIndexTag
},
getInfo() {
if(this.$store.state.user.info){
if (this.$store.state.user.info) {
this.filterMenu()
}
return this.$store.state.user.info
}
},
watch: {
},
watch: {},
components: {},
methods: {
handleClose(hide){
if(hide){
command(){
window.open('/command')
},
handleClose(hide) {
if (hide) {
hide()
}
this.visible=false
this.visible = false
},
removeImage(){
removeImage() {
this.configForm.avatar = ''
},
addImage(...data){
addImage(...data) {
this.configForm.avatar = data[0]
},
initConfig() {
let info = this.$store.state.user.info
this.configForm = {
id:info.id,
id: info.id,
avatar: info.avatar,
username: info.username,
mobile: info.mobile,
@@ -223,7 +229,7 @@
initPassword() {
let info = this.$store.state.user.info
this.passwordForm = {
id:info.id,
id: info.id,
oldPassword: '',
password: '',
rePassword: '',
@@ -240,8 +246,8 @@
submitForm(formName, type) {
this.$refs[formName].validate((valid) => {
if (valid) {
this.addBtnLoading=true
if(type==2){
this.addBtnLoading = true
if (type == 2) {
userApi.editPassword(this.passwordForm).then(res => {
this.addBtnLoading = false
this.initPassword()
@@ -255,7 +261,7 @@
}).catch(e => {
this.addBtnLoading = false
})
}else if(type==1){
} else if (type == 1) {
userApi.profile(this.configForm).then(res => {
this.addBtnLoading = false
this.$message({
@@ -271,9 +277,9 @@
})
},
isIE() {
if(!!window.ActiveXObject || "ActiveXObject" in window){
if (!!window.ActiveXObject || "ActiveXObject" in window) {
return true;
}else{
} else {
return false;
}
},
@@ -281,8 +287,8 @@
if (type == 1) {
this.initConfig()
this.initPassword()
this.activeName='config'
this.visible=true
this.activeName = 'config'
this.visible = true
} else if (type == 2) {
store.dispatch('user/logout').then(res => {
this.$message({
@@ -385,7 +391,8 @@
opacity: 1;
transform: translateX(0);
}
.home-dialog{

.home-dialog {
.el-dialog {
width: 70% !important;
}
@@ -406,13 +413,13 @@
overflow: hidden;

.el-input.is-disabled .el-input__inner {
background-color: #ffffff!important;
color: #333333!important;
background-color: #ffffff !important;
color: #333333 !important;
}

.el-menu-item.is-active {
color: #ffffff!important;
background-color: #1890ff!important;
color: #ffffff !important;
background-color: #1890ff !important;
}

.el-menu-item:hover {
@@ -516,6 +523,7 @@
width: 100%;
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.12), 0 0 3px 0 rgba(0, 0, 0, 0.04);
background-color: #fff;

.right-head-top {
height: 50px;
display: flex;

+ 6
- 1
src/views/login/index.vue View File

@@ -105,7 +105,12 @@
}
document.documentElement.style.fontSize = '16px';
if (redirect) {
this.$router.push({path: redirect});
if(redirect=='/command'){
this.$router.push({path: "/"});
window.open('/command')
}else{
this.$router.push({path: redirect});
}
} else {
this.$router.push({path: "/"});
}

Loading…
Cancel
Save