分角色登录
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-12-23 17:23:51 +08:00
parent a17359a56e
commit eeac5b76c4
5 changed files with 195 additions and 34 deletions
+45 -24
View File
@@ -243,6 +243,7 @@
</div>
</el-dialog>
<browserTip ref="browserTip" />
<toggleRole :visible="toggleRoleVisible" @save="loginByRole" />
</div>
</template>
@@ -253,9 +254,10 @@ import TopLang from './topLang'
import Vcode from 'vue-puzzle-vcode'
import browserTip from '@/views/dictionary/template/browser/tip.vue'
import Img1 from '@/assets/pic-2.png'
import toggleRole from '@/components/toggleRole'
export default {
name: 'Login',
components: { TopLang, Vcode, browserTip },
components: { TopLang, Vcode, browserTip, toggleRole },
data() {
return {
NODE_ENV: process.env.NODE_ENV, // process.env.NODE_ENV
@@ -298,6 +300,7 @@ export default {
isShow: false,
showCode: false,
Img1,
toggleRoleVisible: false,
}
},
computed: {
@@ -416,31 +419,49 @@ export default {
// this.$alert(this.$t('login:message:login4'), this.$t('common:title:warning'))
this.$message.warning(this.$t('login:message:login4'))
}
this.$store.dispatch('permission/generateRoutes').then((res) => {
this.loading = false
if (res && res.length > 0) {
this.$store.dispatch('global/getNoticeList')
this.$router.addRoutes(res)
if (this.loginType === 'DevOps') {
this.$router.replace({ path: res[0].path })
return
}
if (this.hasPermi(['role:radmin'])) {
this.$router.replace({ path: res[0].path })
return
}
if (
this.hasPermi(['role:air', 'role:rpm', 'role:rcrc', 'role:rir'])
) {
this.$router.replace({ path: '/trials/trials-list' })
return (this.toggleRoleVisible = true)
})
.catch(() => {
this.showCode = true
this.loading = false
})
},
loginByRole(UserTypeId) {
this.$store
.dispatch('user/loginByRole', { UserTypeId })
.then((res) => {
if (res) {
this.$store.dispatch('permission/generateRoutes').then((res) => {
this.loading = false
if (res && res.length > 0) {
this.$store.dispatch('global/getNoticeList')
this.$router.addRoutes(res)
if (this.loginType === 'DevOps') {
this.$router.replace({ path: res[0].path })
return
}
if (this.hasPermi(['role:radmin'])) {
this.$router.replace({ path: res[0].path })
return
}
if (
this.hasPermi([
'role:air',
'role:rpm',
'role:rcrc',
'role:rir',
])
) {
this.$router.replace({ path: '/trials/trials-list' })
} else {
this.$router.replace({ path: '/trials' })
}
} else {
this.$router.replace({ path: '/trials' })
// 此账户暂未配置菜单权限,请联系管理员处理后再登录。
this.$message.warning(this.$t('login:message:login2'))
}
} else {
// 此账户暂未配置菜单权限,请联系管理员处理后再登录。
this.$message.warning(this.$t('login:message:login2'))
}
})
})
}
})
.catch(() => {
this.showCode = true
@@ -225,7 +225,7 @@ export default {
// 保存权限配置
async savePermission(){
try{
let validate = this.$refs.permissionForm.validate();
let validate =await this.$refs.permissionForm.validate();
if(!validate) return false;
this.assignLoadStatus = true;
let data = Object.assign({ Id: this.trialId },this.permission)