diff --git a/report-ui/src/api/login.js b/report-ui/src/api/login.js index 77622a07..7f4eaf5f 100644 --- a/report-ui/src/api/login.js +++ b/report-ui/src/api/login.js @@ -1,9 +1,8 @@ import request from './axios' export function login (data) { - console.log(data) return request({ - url: '/login', + url: 'accessUser/login', method: 'post', data }) @@ -11,7 +10,7 @@ export function login (data) { export function logout () { return request({ - url: '/accessUser/logout', + url: 'accessUser/logout', method: 'post' }) } @@ -22,11 +21,3 @@ export const reqUpdatePassword = data => request({ method: 'post', data: data }) - -export function queryForCodeSelect (params = {}) { - return request({ - url: '/auth-service/dict/queryForCodeSelect', - method: 'post', - data: params - }) -} \ No newline at end of file diff --git a/report-ui/src/mixins/access.js b/report-ui/src/mixins/access.js index c32a39ac..4eea888e 100644 --- a/report-ui/src/mixins/access.js +++ b/report-ui/src/mixins/access.js @@ -1,62 +1,44 @@ import { setItem, getItem } from '@/utils/storage'; export default { - data() { + data () { return { } }, computed: { - username: function(){ - var username = getItem('username') - return username + operator: function () { + var operator = getItem('loginName') + return operator }, - getUser: function(){ + getUser: function () { // var user = getItem('user'); - var user =JSON.parse(localStorage.getItem('user')) - if(user != null ){ + var user = JSON.parse(localStorage.getItem('user')) + if (user != null) { return user; - }else{ + } else { return {}; } }, - isAdmin() { - if (this.getUser == null) { - return false - } - return this.getUser.userId === 1 - }, - opLoginName() { - return this.getUser == null ? '' : this.getUser.userName - }, - opNikeName() { - return this.getUser == null ? '' : this.getUser.nikeName - }, - opUserType() { - return this.getUser == null ? '' : this.getUser.userType - }, - opAuthorities() { + opAuthorities () { return this.getUser == null ? [] : this.getUser.authorityWithOrgIds } }, - created() { + created () { }, - mounted() { + mounted () { }, - destroyed() { + destroyed () { }, methods: { - hasPermission(permissionStr, orgIds) { + hasPermission (permissionStr, orgIds) { //判断用户权限列表是否为空 - if (this.opAuthorities == null) { - return false - } - if(this.isAdmin){ - return true; + if (this.opAuthorities == null) { + return false } - if(permissionStr && permissionStr.indexOf('|') !== -1) { + if (permissionStr && permissionStr.indexOf('|') !== -1) { let flag = false let arr = permissionStr.split('|') - for(let i=0; i< arr.length; i++) { + for (let i = 0; i < arr.length; i++) { let a = arr[i].replace(/(^\s*)|(\s*$)/g, ""); if (this.opAuthorities.hasOwnProperty(a)) { flag = true @@ -66,22 +48,22 @@ export default { } //登录用户没有某个操作权限 if (!this.opAuthorities.hasOwnProperty(permissionStr)) { - return false + return false } //如果当前验证,不包含项目级别验证,直接返回 - if (typeof(orgIds) == 'undefined' || orgIds == null) { + if (typeof (orgIds) == 'undefined' || orgIds == null) { return true - } + } //验证登录用户是否有某个项目的有操作权限 var orgIdsHasPermission = this.opAuthorities[permissionStr] //如果projectIds是个数字,只要验证登录用户是否有该项目的操作权限 if (typeof orgIds == 'number') { if (orgIdsHasPermission.indexOf(orgIds) > -1) { return true - }else{ + } else { return false } - }else{ + } else { var result = false for (var i in orgIdsHasPermission) { var flag = orgIds.indexOf(orgIdsHasPermission[i]) > -1 @@ -92,27 +74,5 @@ export default { return result } }, - - //从所有字典中,取某个字典的列表 - getDict(dictname){ - var basecode = JSON.parse(localStorage.getItem('queryForCodeSelect')); - var dictList = basecode[dictname] - return dictList; - }, - //从某个字典的列表,获取某个字典对象 - getDictCode(dictname, codeValue , value='value'){ - //如果 codeValue传过来的是字符串 all 则字典数组返回 - var dictList = this.getDict(dictname); - for (var i = 0; i < dictList.length; i++) { - var codeItem = dictList[i] - if(codeItem[value] == codeValue){ - return codeItem; - } - if(codeValue =='all'){ - return dictList - } - } - return {}; - }, } } diff --git a/report-ui/src/views/layout/components/Navbar.vue b/report-ui/src/views/layout/components/Navbar.vue index 05b0ece3..82f0462a 100644 --- a/report-ui/src/views/layout/components/Navbar.vue +++ b/report-ui/src/views/layout/components/Navbar.vue @@ -1,17 +1,23 @@ @@ -70,17 +112,17 @@ export default { components: { Verify, }, - data() { + data () { return { activeTop: '-50%', // 色条滑块控制 rememberPsw: false, // 记住密码选择框 loginForm: { - username: 'admin', + loginName: 'admin', password: '123456', verifyCode: '', }, // 登录表单 loginRules: { - username: [{ required: true, message: '用户名必填', trigger: 'blur' }], + loginName: [{ required: true, message: '用户名必填', trigger: 'blur' }], password: [ { required: true, message: '用户密码必填', trigger: 'blur' }, ], @@ -106,31 +148,31 @@ export default { immediate: true, }, }, - mounted() { + mounted () { // 获取焦点 - if (this.loginForm.username === '') { - this.$refs.username.focus() + if (this.loginForm.loginName === '') { + this.$refs.loginName.focus() } else if (this.loginForm.password === '') { this.$refs.password.focus() } }, methods: { // 获取存储的密码并解密 - getPsw() { - const cookVal = cookies.get(`u_${this.loginForm.username}`) + getPsw () { + const cookVal = cookies.get(`u_${this.loginForm.loginName}`) this.loginForm.password = cookVal && Decrypt(cookVal) }, // 滑动条块的top控制 - setTop(val) { + setTop (val) { this.activeTop = val }, // 检测大写锁定键是否开启 - checkCapslock(e) { + checkCapslock (e) { const { key } = e this.capsTooltip = key && key.length === 1 && key >= 'A' && key <= 'Z' }, // 查看密码 - showPwd() { + showPwd () { if (this.passwordType === 'password') { this.passwordType = '' } else { @@ -141,7 +183,7 @@ export default { }) }, // 滑动验证码 - useVerify() { + useVerify () { this.$refs.loginForm.validate((valid) => { if (valid) { this.$refs.verify.show() @@ -151,14 +193,14 @@ export default { }) }, // 验证成功的回调 - verifylogin(params) { + verifylogin (params) { this.loginForm.verifyCode = params.captchaVerification if (this.loginForm.verifyCode) { this.loginApi() } }, // 登录操作 - handleLogin() { + handleLogin () { this.$refs.loginForm.validate((valid) => { if (valid) { this.loading = true @@ -173,9 +215,9 @@ export default { } }) }, - async loginApi() { + async loginApi () { let obj = { - username: this.loginForm.username, + loginName: this.loginForm.loginName, password: transPsw(this.loginForm.password), verifyCode: '', } @@ -184,11 +226,11 @@ export default { this.loading = false if (code != '200') return setItem('token', data.token) - setItem('username', data.username) + setItem('loginName', data.loginName) // 选中记住密码时 把密码存到cookie里,时效15天 this.rememberPsw && cookies.set( - `u_${this.loginForm.username}`, + `u_${this.loginForm.loginName}`, Encrypt(this.loginForm.password), { expires: 15 } ) @@ -202,7 +244,7 @@ export default { }) } }, - getOtherQuery(query) { + getOtherQuery (query) { return Object.keys(query).reduce((acc, cur) => { if (cur !== 'redirect') { acc[cur] = query[cur] @@ -381,7 +423,7 @@ export default { height: 14px; } & > input:checked::before { - content: '\2713'; + content: "\2713"; background-color: #f5ab1b; position: absolute; top: 0;