鉴权相关配置
This commit is contained in:
parent
8cfd9d5df6
commit
d3a0651fb7
7
App.vue
7
App.vue
@ -1,6 +1,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import config from '@/config'
|
import config from '@/config'
|
||||||
import request from '@/utils/request';
|
import request from '@/utils/request';
|
||||||
|
import store from '@/store'
|
||||||
export default {
|
export default {
|
||||||
onLaunch: function() {
|
onLaunch: function() {
|
||||||
console.log('app lunch');
|
console.log('app lunch');
|
||||||
@ -81,6 +82,12 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
// 判断本地是否有 token,有的话就去获取权限
|
||||||
|
if (store.state.user.token) {
|
||||||
|
store.dispatch('GetInfo').catch(err => {
|
||||||
|
console.error('获取用户信息失败', err)
|
||||||
|
})
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onShow: function() {
|
onShow: function() {
|
||||||
console.log('App Show')
|
console.log('App Show')
|
||||||
|
@ -28,8 +28,12 @@ export function wechatLogin(data) {
|
|||||||
}
|
}
|
||||||
// 获取用户详细信息
|
// 获取用户详细信息
|
||||||
export function getInfo() {
|
export function getInfo() {
|
||||||
|
// return request({
|
||||||
|
// 'url': '/rescue/getInfo',
|
||||||
|
// 'method': 'get'
|
||||||
|
// })
|
||||||
return request({
|
return request({
|
||||||
'url': '/rescue/getInfo',
|
'url': '/admin-api/system/auth/get-permission-info',
|
||||||
'method': 'get'
|
'method': 'get'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
6
main.js
6
main.js
@ -40,6 +40,7 @@ export function getclearInterval() {
|
|||||||
Vue.prototype.$getclearInterval = getclearInterval;
|
Vue.prototype.$getclearInterval = getclearInterval;
|
||||||
// #ifndef VUE3
|
// #ifndef VUE3
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
|
import store from './store'
|
||||||
import './uni.promisify.adaptor'
|
import './uni.promisify.adaptor'
|
||||||
import {
|
import {
|
||||||
request
|
request
|
||||||
@ -48,13 +49,16 @@ Vue.prototype.$request = request
|
|||||||
Vue.config.productionTip = false
|
Vue.config.productionTip = false
|
||||||
App.mpType = 'app'
|
App.mpType = 'app'
|
||||||
const app = new Vue({
|
const app = new Vue({
|
||||||
|
store,
|
||||||
...App
|
...App
|
||||||
})
|
})
|
||||||
app.$mount()
|
app.$mount()
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
// #ifdef VUE3
|
// #ifdef VUE3
|
||||||
import { createSSRApp } from 'vue'
|
import {
|
||||||
|
createSSRApp
|
||||||
|
} from 'vue'
|
||||||
export function createApp() {
|
export function createApp() {
|
||||||
const app = createSSRApp(App)
|
const app = createSSRApp(App)
|
||||||
return {
|
return {
|
||||||
|
@ -23,6 +23,11 @@
|
|||||||
getJSONData,
|
getJSONData,
|
||||||
} from '@/utils/auth'
|
} from '@/utils/auth'
|
||||||
import tabBarVue from "@/components/tabBar/tabBar.vue";
|
import tabBarVue from "@/components/tabBar/tabBar.vue";
|
||||||
|
import {
|
||||||
|
checkPermi,
|
||||||
|
checkRole
|
||||||
|
} from "@/utils/permission"; // 权限判断函数
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@ -65,11 +70,14 @@
|
|||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (this.checkRole(['tenant_admin'])) {
|
||||||
|
console.log('哈哈哈哈哈');
|
||||||
|
}
|
||||||
|
if (this.checkPermi(['system:user:add', 'system:user:edit'])) {
|
||||||
|
console.log('哈哈哈哈哈');
|
||||||
|
}
|
||||||
|
|
||||||
this.customInfo = getUserInfo();
|
if (this.checkRole(['tenant_admin', 'weixiu'])) {
|
||||||
console.log('customInfo', this.customInfo);
|
|
||||||
|
|
||||||
if (this.customInfo.roleCodes.includes('weixiu') || this.customInfo.roleCodes.includes('tenant_admin')) {
|
|
||||||
this.filteredList = this.menuList;
|
this.filteredList = this.menuList;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@ -77,6 +85,8 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
checkPermi,
|
||||||
|
checkRole,
|
||||||
goManage(id) {
|
goManage(id) {
|
||||||
const routes = {
|
const routes = {
|
||||||
1: '/pages-internal/staffManagement/NewstaffManagement',
|
1: '/pages-internal/staffManagement/NewstaffManagement',
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
<text style="color: red;">*</text>
|
<text style="color: red;">*</text>
|
||||||
汇报内容
|
汇报内容
|
||||||
</view>
|
</view>
|
||||||
<u--textarea v-if="type != 'look'" v-model="report.reportContent" placeholder="请输入内容"></u--textarea>
|
<!-- <u--textarea v-if="type != 'look'" v-model="report.reportContent" placeholder="请输入内容"></u--textarea> -->
|
||||||
<textarea v-else v-model="report.reportContent" placeholder="请输入内容" disabled></textarea>
|
<textarea auto-height v-model="report.reportContent" placeholder="请输入内容" disabled></textarea>
|
||||||
<view class="x_"></view>
|
<view class="x_"></view>
|
||||||
<view class="d_b" @click="handleUpload" v-if="type != 'look'">
|
<view class="d_b" @click="handleUpload" v-if="type != 'look'">
|
||||||
<view class="">附件</view>
|
<view class="">附件</view>
|
||||||
|
@ -184,6 +184,7 @@
|
|||||||
//查租户下维修企业信息
|
//查租户下维修企业信息
|
||||||
this.getCompanyInfo()
|
this.getCompanyInfo()
|
||||||
this.getNoReadNum()
|
this.getNoReadNum()
|
||||||
|
this.loginSuccess()
|
||||||
if (res.data.userinfo.roleCodes.includes("repair_staff")) {
|
if (res.data.userinfo.roleCodes.includes("repair_staff")) {
|
||||||
//维修工角色,需要再查一下是否是班组长
|
//维修工角色,需要再查一下是否是班组长
|
||||||
this.getIdLeader()
|
this.getIdLeader()
|
||||||
@ -230,6 +231,13 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
// 登录成功后,处理函数
|
||||||
|
loginSuccess(result) {
|
||||||
|
// 设置用户信息
|
||||||
|
this.$store.dispatch('GetInfo').then(res => {
|
||||||
|
|
||||||
|
})
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* 查员工个人信息
|
* 查员工个人信息
|
||||||
*/
|
*/
|
||||||
@ -237,7 +245,9 @@
|
|||||||
request({
|
request({
|
||||||
url: '/admin-api/company/staff/getById',
|
url: '/admin-api/company/staff/getById',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: {id:userId}
|
params: {
|
||||||
|
id: userId
|
||||||
|
}
|
||||||
}).then((res) => {
|
}).then((res) => {
|
||||||
console.log(res)
|
console.log(res)
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
@ -344,7 +354,10 @@
|
|||||||
await request({
|
await request({
|
||||||
url: "/admin-api/base/company/getCompanyByTenantId",
|
url: "/admin-api/base/company/getCompanyByTenantId",
|
||||||
method: "GET",
|
method: "GET",
|
||||||
params:{tenantId:getTenantId(),systemCode:"weixiu"}
|
params: {
|
||||||
|
tenantId: getTenantId(),
|
||||||
|
systemCode: "weixiu"
|
||||||
|
}
|
||||||
}).then((res) => {
|
}).then((res) => {
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
setJSONData("companyInfo", res.data)
|
setJSONData("companyInfo", res.data)
|
||||||
@ -501,6 +514,7 @@
|
|||||||
border-bottom: 2px solid #E8E8E8;
|
border-bottom: 2px solid #E8E8E8;
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.inputs input {
|
.inputs input {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,16 @@
|
|||||||
import config from '@/config'
|
import config from '@/config'
|
||||||
import storage from '@/utils/storage'
|
import storage from '@/utils/storage'
|
||||||
import constant from '@/utils/constant'
|
import constant from '@/utils/constant'
|
||||||
import { login, logout, getInfo } from '@/api/login'
|
import {
|
||||||
import { getToken, setToken, removeToken } from '@/utils/auth'
|
login,
|
||||||
|
logout,
|
||||||
|
getInfo
|
||||||
|
} from '@/api/login'
|
||||||
|
import {
|
||||||
|
getToken,
|
||||||
|
setToken,
|
||||||
|
removeToken
|
||||||
|
} from '@/utils/auth'
|
||||||
|
|
||||||
const baseUrl = config.baseUrl
|
const baseUrl = config.baseUrl
|
||||||
|
|
||||||
@ -39,7 +47,9 @@ const user = {
|
|||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
// 登录
|
// 登录
|
||||||
Login({ commit }, userInfo) {
|
Login({
|
||||||
|
commit
|
||||||
|
}, userInfo) {
|
||||||
const username = userInfo.username.trim()
|
const username = userInfo.username.trim()
|
||||||
const password = userInfo.password
|
const password = userInfo.password
|
||||||
const code = userInfo.code
|
const code = userInfo.code
|
||||||
@ -56,15 +66,22 @@ const user = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// 获取用户信息
|
// 获取用户信息
|
||||||
GetInfo({ commit, state }) {
|
GetInfo({
|
||||||
|
commit,
|
||||||
|
state
|
||||||
|
}) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
commit('SET_ROLES', [])
|
||||||
|
commit('SET_PERMISSIONS', [])
|
||||||
getInfo().then(res => {
|
getInfo().then(res => {
|
||||||
const user = res.user
|
const user = res.data.user
|
||||||
const avatar = (user == null || user.avatar == "" || user.avatar == null) ? require("@/static/images/profile.jpg") : baseUrl + user.avatar
|
const avatar = (user == null || user.avatar == "" || user.avatar == null) ?
|
||||||
const username = (user == null || user.userName == "" || user.userName == null) ? "" : user.userName
|
require("@/static/images/yh.png") : baseUrl + user.avatar
|
||||||
if (res.roles && res.roles.length > 0) {
|
const username = (user == null || user.userName == "" || user.userName ==
|
||||||
commit('SET_ROLES', res.roles)
|
null) ? "" : user.userName
|
||||||
commit('SET_PERMISSIONS', res.permissions)
|
if (res.data.roles && res.data.roles.length > 0) {
|
||||||
|
commit('SET_ROLES', res.data.roles)
|
||||||
|
commit('SET_PERMISSIONS', res.data.permissions)
|
||||||
} else {
|
} else {
|
||||||
commit('SET_ROLES', ['ROLE_DEFAULT'])
|
commit('SET_ROLES', ['ROLE_DEFAULT'])
|
||||||
}
|
}
|
||||||
@ -78,7 +95,10 @@ const user = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// 退出系统
|
// 退出系统
|
||||||
LogOut({ commit, state }) {
|
LogOut({
|
||||||
|
commit,
|
||||||
|
state
|
||||||
|
}) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
logout(state.token).then(() => {
|
logout(state.token).then(() => {
|
||||||
commit('SET_TOKEN', '')
|
commit('SET_TOKEN', '')
|
||||||
|
@ -34,6 +34,7 @@ export function checkPermi(value) {
|
|||||||
export function checkRole(value) {
|
export function checkRole(value) {
|
||||||
if (value && value instanceof Array && value.length > 0) {
|
if (value && value instanceof Array && value.length > 0) {
|
||||||
const roles = store.getters && store.getters.roles
|
const roles = store.getters && store.getters.roles
|
||||||
|
console.log('拥有角色:', roles);
|
||||||
const permissionRoles = value
|
const permissionRoles = value
|
||||||
const super_admin = "admin"
|
const super_admin = "admin"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user