角色判断
parent
f76a30fc24
commit
ed73383afc
|
|
@ -7,6 +7,7 @@ enum Api {
|
|||
// Login = '/login',
|
||||
// GetUserInfo = '/getUserInfo',
|
||||
GetUserInfo = '/api/Check/GetUserProfile',
|
||||
GetRoles = '/api/Check/GetRoles',
|
||||
GetPermCode = '/getPermCode',
|
||||
TestRetry = '/testRetry',
|
||||
Login = '/api/Check/Login',
|
||||
|
|
@ -45,6 +46,9 @@ export function loginApi(params: LoginParams, mode: ErrorMessageMode = 'modal')
|
|||
export function getUserInfo() {
|
||||
return defHttp.get<GetUserInfoModel>({ url: Api.GetUserInfo }, { errorMessageMode: 'none' });
|
||||
}
|
||||
export function GetRoles() {
|
||||
return defHttp.get({ url: Api.GetRoles }, { errorMessageMode: 'none' });
|
||||
}
|
||||
|
||||
export function getPermCode() {
|
||||
return defHttp.get<string[]>({ url: Api.GetPermCode });
|
||||
|
|
|
|||
|
|
@ -130,9 +130,9 @@
|
|||
// setTimeout(start, 5000);
|
||||
}
|
||||
}
|
||||
signal.onclose(async () => {
|
||||
await start();
|
||||
});
|
||||
// signal.onclose(async () => {
|
||||
// await start();
|
||||
// });
|
||||
//接口推送
|
||||
signal.on('RevMsg', (user, message, time, id, issystem) => {
|
||||
console.log('报警', user, message, time, id, issystem); //拿到后台推送的数据
|
||||
|
|
@ -151,7 +151,7 @@
|
|||
});
|
||||
onMounted(() => {
|
||||
getList();
|
||||
start();
|
||||
// start();
|
||||
});
|
||||
</script>
|
||||
<style lang="less">
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ const setting: ProjectConfig = {
|
|||
multiTabsSetting: {
|
||||
cache: false,
|
||||
// Turn on
|
||||
show: true,
|
||||
show: false,
|
||||
// Is it possible to drag and drop sorting tabs
|
||||
canDrag: true,
|
||||
// Turn on quick actions
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import {
|
|||
} from '@/enums/cacheEnum';
|
||||
import { getAuthCache, setAuthCache } from '@/utils/auth';
|
||||
import { GetUserInfoModel, LoginParams } from '@/api/sys/model/userModel';
|
||||
import { doLogout, getUserInfo, loginApi } from '@/api/sys/user';
|
||||
import { doLogout, getUserInfo, loginApi, GetRoles } from '@/api/sys/user';
|
||||
import { useI18n } from '@/hooks/web/useI18n';
|
||||
import { useMessage } from '@/hooks/web/useMessage';
|
||||
import { router } from '@/router';
|
||||
|
|
@ -29,7 +29,7 @@ import { useMultipleTabStore } from '@/store/modules/multipleTab';
|
|||
interface UserState {
|
||||
userInfo: Nullable<UserInfo>;
|
||||
token?: string;
|
||||
roleList: RoleEnum[];
|
||||
roleList: string[];
|
||||
sessionTimeout?: boolean;
|
||||
lastUpdateTime: number;
|
||||
subject?: string;
|
||||
|
|
@ -61,8 +61,8 @@ export const useUserStore = defineStore({
|
|||
getToken(state): string {
|
||||
return state.token || getAuthCache<string>(TOKEN_KEY);
|
||||
},
|
||||
getRoleList(state): RoleEnum[] {
|
||||
return state.roleList.length > 0 ? state.roleList : getAuthCache<RoleEnum[]>(ROLES_KEY);
|
||||
getRoleList(state): string[] {
|
||||
return state.roleList.length > 0 ? state.roleList : getAuthCache<string[]>(ROLES_KEY);
|
||||
},
|
||||
getSessionTimeout(state): boolean {
|
||||
return !!state.sessionTimeout;
|
||||
|
|
@ -172,13 +172,11 @@ export const useUserStore = defineStore({
|
|||
if (!this.getToken) return null;
|
||||
const userInfo = await getUserInfo();
|
||||
const { roles = [] } = userInfo;
|
||||
if (isArray(roles)) {
|
||||
const roleList = roles.map((item) => item.value) as RoleEnum[];
|
||||
this.setRoleList(roleList);
|
||||
} else {
|
||||
userInfo.roles = [];
|
||||
this.setRoleList([]);
|
||||
}
|
||||
|
||||
const roleObjList = await GetRoles();
|
||||
const roleList = roleObjList.map((item) => item.name) as string[];
|
||||
this.setRoleList(roleList);
|
||||
userInfo.roles = roleList
|
||||
this.setUserInfo(userInfo);
|
||||
return userInfo;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -198,11 +198,12 @@ import { yearOptions, proxyColumns, supplierColumns, proprietorColumns, biddingf
|
|||
import { SearchOutlined, PlusOutlined, DownOutlined } from '@ant-design/icons-vue'
|
||||
import InsertModal from './InsertModal/index.vue'
|
||||
import { LoadBiddingInfo } from '@/api/demo/tender'
|
||||
import { getUserType } from '@/views/demo/util'
|
||||
|
||||
onMounted(() => {
|
||||
query()
|
||||
})
|
||||
const user = ref(3)
|
||||
const user = ref(getUserType())
|
||||
const params = ref({
|
||||
type: 0,
|
||||
year: null,
|
||||
|
|
|
|||
|
|
@ -74,4 +74,16 @@ export const getYearList = () => {
|
|||
});
|
||||
}
|
||||
return list;
|
||||
};
|
||||
};
|
||||
export const getUserType = () => {
|
||||
let userRoleList = userStore.getRoleList
|
||||
if(userRoleList.includes('甲方公司')){
|
||||
return 3
|
||||
}else if(userRoleList.includes('供应商')){
|
||||
return 2
|
||||
}else if(userRoleList.includes('招标代理')){
|
||||
return 1
|
||||
}else{
|
||||
return 1
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue