权限问题修改

master
zhangdi 2 months ago
parent d4ba256077
commit 8e0fabd16f
  1. 45
      public/index.html
  2. 2
      src/page/index/index.vue
  3. 12
      src/page/index/top/index.vue
  4. 453
      src/store/modules/user.js

@ -10,17 +10,17 @@
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet" href="<%= BASE_URL %>cdn/element-ui/2.15.6/theme-chalk/index.css">
<link rel="stylesheet" href="<%= BASE_URL %>cdn/animate/3.5.2/animate.css">
<link rel="stylesheet" href="<%= BASE_URL %>cdn/iconfont/index.css">
<link rel="stylesheet" href="<%= BASE_URL %>cdn/iconfont/avue/iconfont.css">
<link rel="stylesheet" href="<%= BASE_URL %>cdn/iconfont/saber/iconfont.css">
<link rel="stylesheet" href="<%= BASE_URL %>cdn/iconfont/common/iconfont.css">
<link rel="stylesheet" href="<%= BASE_URL %>cdn/avue/2.12.6/index.css">
<script src="<%= BASE_URL %>cdn/xlsx/FileSaver.min.js"></script>
<script src="/js/xlsx.full.min.js"></script>
<link rel="icon" href="<%= BASE_URL %>favicon.png">
<title>BladeX微服务开发平台</title>
<link rel="stylesheet" href="cdn/element-ui/2.15.6/theme-chalk/index.css">
<link rel="stylesheet" href="cdn/animate/3.5.2/animate.css">
<link rel="stylesheet" href="cdn/iconfont/index.css">
<link rel="stylesheet" href="cdn/iconfont/avue/iconfont.css">
<link rel="stylesheet" href="cdn/iconfont/saber/iconfont.css">
<link rel="stylesheet" href="cdn/iconfont/common/iconfont.css">
<link rel="stylesheet" href="cdn/avue/2.12.6/index.css">
<script src="cdn/xlsx/FileSaver.min.js"></script>
<script src="js/xlsx.full.min.js"></script>
<link rel="icon" href="favicon.png">
<title>低值耐用品信息平台</title>
<style>
html,
body,
@ -88,7 +88,7 @@
<div id="app">
<div class="avue-home">
<div class="avue-home__main">
<img class="avue-home__loading" src="<%= BASE_URL %>svg/loading-spin.svg" alt="loading">
<img class="avue-home__loading" alt="loading">
<div class="avue-home__title">
正在加载资源
</div>
@ -96,21 +96,18 @@
初次加载资源可能需要较多时间 请耐心等待
</div>
</div>
<div class="avue-home__footer">
<a href="https://bladex.cn" target="_blank">
https://bladex.cn </a>
</div>
</div>
</div>
<!-- built files will be auto injected -->
<script src="<%= BASE_URL %>util/aes.js" charset="utf-8"></script>
<script src="<%= BASE_URL %>cdn/vue/2.6.10/vue.min.js" charset="utf-8"></script>
<script src="<%= BASE_URL %>cdn/vuex/3.1.1/vuex.min.js" charset="utf-8"></script>
<script src="<%= BASE_URL %>cdn/vue-router/3.0.1/vue-router.min.js" charset="utf-8"></script>
<script src="<%= BASE_URL %>cdn/axios/1.0.0/axios.min.js" charset="utf-8"></script>
<script src="<%= BASE_URL %>cdn/element-ui/2.15.6/index.js" charset="utf-8"></script>
<script src="<%= BASE_URL %>cdn/avue/2.12.6/avue.min.js" charset="utf-8"></script>
<script src="<%= BASE_URL %>cdn/nutflow/wf-design-base/index.umd.min.js" charset="utf-8"></script>
<script src="util/aes.js" charset="utf-8"></script>
<script src="cdn/vue/2.6.10/vue.min.js" charset="utf-8"></script>
<script src="cdn/vuex/3.1.1/vuex.min.js" charset="utf-8"></script>
<script src="cdn/vue-router/3.0.1/vue-router.min.js" charset="utf-8"></script>
<script src="cdn/axios/1.0.0/axios.min.js" charset="utf-8"></script>
<script src="cdn/element-ui/2.15.6/index.js" charset="utf-8"></script>
<script src="cdn/avue/2.12.6/avue.min.js" charset="utf-8"></script>
<script src="cdn/nutflow/wf-design-base/index.umd.min.js" charset="utf-8"></script>
</body>
</html>

@ -91,7 +91,7 @@
console.log("itemitemitemopenMenu", this.userInfo)
let roleIds = this.userInfo.roleList.map(item => item.id);
this.$store.dispatch("GetMenu", {roleId:roleIds.join(',')}).then(data => {
this.$store.dispatch("GetMenu", {roleIds:roleIds.join(',')}).then(data => {
console.log("每次刷新调用", data);
if (data.length !== 0) {
this.$router.$avueRouter.formatRoutes(data, true);

@ -74,26 +74,26 @@
@click="handleScreen"></i>
</div>
</el-tooltip> -->
<img class="top-bar__img"
:src="userInfo.avatar">
<el-dropdown>
<!-- <img class="top-bar__img"
:src="userInfo.avatar"> -->
<!-- <el-dropdown>
<span class="el-dropdown-link">
{{userInfo.real_name}}
<i class="el-icon-arrow-down el-icon--right"></i>
</span>
<el-dropdown-menu slot="dropdown">
<!-- <el-dropdown-item>
<el-dropdown-item>
<router-link to="/"><i class="icon-zuzhixiaxia" /> {{$t('navbar.dashboard')}}</router-link>
</el-dropdown-item>
<el-dropdown-item>
<router-link to="/info/index"><i class="icon-yonghu" /> {{$t('navbar.userinfo')}}</router-link>
</el-dropdown-item>
<el-dropdown-item @click.native="switchDept"><i class="icon-guanlianshebei" /> {{$t('navbar.switch')}}
</el-dropdown-item> -->
</el-dropdown-item>
<el-dropdown-item @click.native="logout" divided><i class="icon-tuichu" /> {{$t('navbar.logOut')}}
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</el-dropdown> -->
<el-dialog title="用户信息选择"
append-to-body
:visible.sync="userBox"

@ -1,8 +1,8 @@
import {setToken, setRefreshToken, getRefreshToken, removeToken, removeRefreshToken} from '@/util/auth'
import {Message} from 'element-ui'
import {setStore, getStore} from '@/util/store'
import {isURL, validatenull} from '@/util/validate'
import {deepClone} from '@/util/util'
import { setToken, setRefreshToken, getRefreshToken, removeToken, removeRefreshToken } from '@/util/auth'
import { Message } from 'element-ui'
import { setStore, getStore } from '@/util/store'
import { isURL, validatenull } from '@/util/validate'
import { deepClone } from '@/util/util'
import website from '@/config/website'
import {
loginByUsername,
@ -15,8 +15,8 @@ import {
getButtons,
registerUser
} from '@/api/user'
import {getTopMenu, getRoutes} from '@/api/system/menu'
import {encrypt} from '@/util/sm2'
import { getTopMenu, getRoutes } from '@/api/system/menu'
import { encrypt } from '@/util/sm2'
function addPath(ele, first) {
@ -44,20 +44,20 @@ function addPath(ele, first) {
const user = {
state: {
tenantId: getStore({name: 'tenantId'}) || '',
userInfo: getStore({name: 'userInfo'}) || [],
permission: getStore({name: 'permission'}) || {},
tenantId: getStore({ name: 'tenantId' }) || '',
userInfo: getStore({ name: 'userInfo' }) || [],
permission: getStore({ name: 'permission' }) || {},
roles: [],
menuId: {},
menu: getStore({name: 'menu'}) || [],
menuAll: getStore({name: 'menuAll'}) || [],
token: getStore({name: 'token'}) || '',
refreshToken: getStore({name: 'refreshToken'}) || '',
userAuthInfo:getStore({name: 'userAuthInfo'}) || [],
menu: getStore({ name: 'menu' }) || [],
menuAll: getStore({ name: 'menuAll' }) || [],
token: getStore({ name: 'token' }) || '',
refreshToken: getStore({ name: 'refreshToken' }) || '',
userAuthInfo: getStore({ name: 'userAuthInfo' }) || [],
},
actions: {
//根据用户名登录
LoginByUsername({commit}, userInfo) {
LoginByUsername({ commit }, userInfo) {
return new Promise((resolve, reject) => {
loginByUsername(userInfo.tenantId, userInfo.deptId, userInfo.roleId, userInfo.username, encrypt(userInfo.password), userInfo.type, userInfo.key, userInfo.code).then(res => {
const data = res.data;
@ -80,8 +80,8 @@ const user = {
})
})
},
//获取用户信息之后进行存储
AuthLoginByUsername({commit}, userInfo) {
//获取用户信息之后进行存储
AuthLoginByUsername({ commit }, userInfo) {
return new Promise((resolve, reject) => {
// loginByUsername(userInfo.tenantId, userInfo.deptId, userInfo.roleId, userInfo.username, encrypt(userInfo.password), userInfo.type, userInfo.key, userInfo.code).then(res => {
// const data = res.data;
@ -94,12 +94,12 @@ const user = {
// commit('SET_TOKEN', data.access_token);
// commit('SET_REFRESH_TOKEN', data.refresh_token);
// commit('SET_TENANT_ID', data.tenant_id);
console.log('userInfo',userInfo);
commit('SET_USER_AUTH_INFO', userInfo);
console.log('userInfo', userInfo);
commit('SET_USER_AUTH_INFO', userInfo);
// commit('DEL_ALL_TAG');
// commit('CLEAR_LOCK');
// }
resolve();
resolve();
// }).catch(error => {
// reject(error);
// })
@ -130,7 +130,7 @@ const user = {
});
},
//根据第三方信息登录
LoginBySocial({commit}, userInfo) {
LoginBySocial({ commit }, userInfo) {
return new Promise((resolve, reject) => {
loginBySocial(userInfo.tenantId, userInfo.source, userInfo.code, userInfo.state).then(res => {
const data = res.data;
@ -154,7 +154,7 @@ const user = {
})
},
//根据单点信息登录
LoginBySso({commit}, userInfo) {
LoginBySso({ commit }, userInfo) {
return new Promise((resolve, reject) => {
loginBySso(userInfo.state, userInfo.code).then(res => {
const data = res.data;
@ -177,7 +177,7 @@ const user = {
})
})
},
RegisterUser({commit}, userInfo = {}) {
RegisterUser({ commit }, userInfo = {}) {
return new Promise((resolve, reject) => {
registerUser(
userInfo.tenantId,
@ -207,7 +207,7 @@ const user = {
});
},
//获取用户信息
GetUserInfo({commit}) {
GetUserInfo({ commit }) {
return new Promise((resolve, reject) => {
getUserInfo().then((res) => {
const data = res.data.data;
@ -219,7 +219,7 @@ const user = {
})
},
//刷新token
RefreshToken({state, commit}, userInfo) {
RefreshToken({ state, commit }, userInfo) {
return new Promise((resolve, reject) => {
refreshToken(getRefreshToken(), state.tenantId,
!validatenull(userInfo) ? userInfo.deptId : state.userInfo.dept_id,
@ -236,7 +236,7 @@ const user = {
})
},
// 登出
LogOut({commit}) {
LogOut({ commit }) {
return new Promise((resolve, reject) => {
logout().then(() => {
commit('SET_TOKEN', '');
@ -255,7 +255,7 @@ const user = {
})
},
//注销session
FedLogOut({commit}) {
FedLogOut({ commit }) {
return new Promise(resolve => {
commit('SET_TOKEN', '');
commit('SET_MENU_ALL_NULL', []);
@ -287,21 +287,378 @@ const user = {
// console.log(8888,'获取userid',state.userInfo)
getRoutes(userId).then((res) => {
const data = res.data.result
let menu = deepClone(data);
menu.forEach(ele => {
addPath(ele, true);
});
commit('SET_MENU_ALL', menu)
commit('SET_MENU', menu)
// dispatch('GetButtons');
resolve(menu)
// console.log('接口获取路由信息',res)
// let res = {
// data: {
// success: true,
// message: "操作成功!",
// code: 200,
// result: [
// {
// id: "1946092006130769923",
// parentId: "0",
// code: "firstOrder",
// name: "一级库管理",
// alias: "menu",
// path: "/firstOrder",
// source: "iconfont iconicon_roundadd",
// component: null,
// sort: 1,
// category: 1,
// action: 0,
// isOpen: 1,
// remark: "",
// isDeleted: 0,
// children: [
// {
// id: "1946092006130769924",
// parentId: "1946092006130769923",
// code: "firstOrderList",
// name: "库存列表",
// alias: "menu",
// path: "/firstOrder/list",
// source: "iconfont iconicon_task_done",
// component: null,
// sort: 1,
// category: 1,
// action: 0,
// isOpen: 1,
// remark: "",
// isDeleted: 0,
// parentName: null,
// categoryName: null,
// actionName: null,
// isOpenName: null,
// },
// {
// id: "1946092006130769925",
// parentId: "1946092006130769923",
// code: "firstOrderInbound",
// name: "一级库入库",
// alias: "menu",
// path: "/firstOrder/inbound",
// source: "iconfont iconicon_voipphone",
// component: null,
// sort: 2,
// category: 1,
// action: 0,
// isOpen: 1,
// remark: "",
// isDeleted: 0,
// parentName: null,
// categoryName: null,
// actionName: null,
// isOpenName: null,
// },
// {
// id: "1946092006130769926",
// parentId: "1946092006130769923",
// code: "firstOrderOutbound",
// name: "一级库出库",
// alias: "memu",
// path: "/firstOrder/outbound",
// source: "iconfont iconicon_voipphone",
// component: null,
// sort: 3,
// category: 1,
// action: 0,
// isOpen: 1,
// remark: "",
// isDeleted: 0,
// parentName: null,
// categoryName: null,
// actionName: null,
// isOpenName: null,
// },
// ],
// parentName: null,
// categoryName: null,
// actionName: null,
// isOpenName: null,
// },
// {
// id: "1946092006130769927",
// parentId: "0",
// code: "secondOrder",
// name: "二级库管理",
// alias: "menu",
// path: "/secondOrder",
// source: "iconfont iconicon_voipphone",
// component: null,
// sort: 2,
// category: 1,
// action: 0,
// isOpen: 1,
// remark: "",
// isDeleted: 0,
// children: [
// {
// id: "1946092006130769928",
// parentId: "1946092006130769927",
// code: "secondOrderList",
// name: "易耗品列表",
// alias: "menu",
// path: "/secondOrder/list",
// source: "iconfont iconicon_voipphone",
// component: null,
// sort: 1,
// category: 1,
// action: 0,
// isOpen: 1,
// remark: "",
// isDeleted: 0,
// parentName: null,
// categoryName: null,
// actionName: null,
// isOpenName: null,
// },
// {
// id: "1946092006130769929",
// parentId: "1946092006130769927",
// code: "secondOrderInbound",
// name: "二级库入库",
// alias: "menu",
// path: "/secondOrder/inbound",
// source: "iconfont iconicon_voipphone",
// component: null,
// sort: 2,
// category: 1,
// action: 0,
// isOpen: 1,
// remark: "",
// isDeleted: 0,
// parentName: null,
// categoryName: null,
// actionName: null,
// isOpenName: null,
// },
// {
// id: "1946092006130769930",
// parentId: "1946092006130769927",
// code: "secondOrderOutbound",
// name: "二级库出库",
// alias: "menu",
// path: "/secondOrder/outbound",
// source: "iconfont iconicon_voipphone",
// component: null,
// sort: 3,
// category: 1,
// action: 0,
// isOpen: 1,
// remark: "",
// isDeleted: 0,
// parentName: null,
// categoryName: null,
// actionName: null,
// isOpenName: null,
// },
// {
// id: "1946092006130769931",
// parentId: "1946092006130769927",
// code: "materialsExpend",
// name: "耐用品列表",
// alias: "menu",
// path: "/materials/expend",
// source: "iconfont iconicon_share",
// component: null,
// sort: 4,
// category: 1,
// action: 0,
// isOpen: 1,
// remark: "",
// isDeleted: 0,
// parentName: null,
// categoryName: null,
// actionName: null,
// isOpenName: null,
// },
// ],
// parentName: null,
// categoryName: null,
// actionName: null,
// isOpenName: null,
// },
// {
// id: "1946092006130769932",
// parentId: "0",
// code: "materials",
// name: "物资管理",
// alias: "menu",
// path: "/materials",
// source: "iconfont iconicon_voipphone",
// component: null,
// sort: 3,
// category: 1,
// action: 0,
// isOpen: 1,
// remark: "",
// isDeleted: 0,
// parentName: null,
// categoryName: null,
// actionName: null,
// isOpenName: null,
// },
// {
// id: "1946092006130769933",
// parentId: "0",
// code: "purchaseOrders",
// name: "采购单管理",
// alias: "menu",
// path: "/purchaseOrders",
// source: "iconfont iconicon_voipphone",
// component: null,
// sort: 4,
// category: 1,
// action: 0,
// isOpen: 1,
// remark: "",
// isDeleted: 0,
// parentName: null,
// categoryName: null,
// actionName: null,
// isOpenName: null,
// },
// {
// id: "1946092006130769934",
// parentId: "0",
// code: "demandOrder",
// name: "需求单管理",
// alias: "menu",
// path: "/demandOrder",
// source: "iconfont iconicon_voipphone",
// component: null,
// sort: 5,
// category: 1,
// action: 0,
// isOpen: 1,
// remark: "",
// isDeleted: 0,
// parentName: null,
// categoryName: null,
// actionName: null,
// isOpenName: null,
// },
// {
// id: "1946092006130769935",
// parentId: "0",
// code: "dataAnalysis",
// name: "数据分析",
// alias: "menu",
// path: "/dataAnalysis",
// source: "iconfont iconicon_voipphone",
// component: null,
// sort: 6,
// category: 1,
// action: 0,
// isOpen: 1,
// remark: "",
// isDeleted: 0,
// parentName: null,
// categoryName: null,
// actionName: null,
// isOpenName: null,
// },
// {
// id: "1123598815738675203",
// parentId: "0",
// code: "system",
// name: "系统管理",
// alias: "menu",
// path: "/system",
// source: "iconfont iconicon_setting",
// component: "",
// sort: 99,
// category: 1,
// action: 0,
// isOpen: 1,
// remark: null,
// isDeleted: 0,
// children: [
// {
// id: "1123598815738675308",
// parentId: "1123598815738675203",
// code: "role",
// name: "角色管理",
// alias: "menu",
// path: "/authority/role",
// source: "iconfont icon-hezuohuobanmiyueguanli",
// component: "",
// sort: 1,
// category: 1,
// action: 0,
// isOpen: 1,
// remark: null,
// isDeleted: 0,
// parentName: null,
// categoryName: null,
// actionName: null,
// isOpenName: null,
// },
// {
// id: "1123598815738675206",
// parentId: "1123598815738675203",
// code: "dict",
// name: "系统字典",
// alias: "menu",
// path: "/system/dict",
// source: "iconfont iconicon_addresslist",
// component: "",
// sort: 4,
// category: 1,
// action: 0,
// isOpen: 1,
// remark: null,
// isDeleted: 0,
// parentName: null,
// categoryName: null,
// actionName: null,
// isOpenName: null,
// },
// {
// id: "1123598815738675207",
// parentId: "1123598815738675203",
// code: "menu",
// name: "菜单管理",
// alias: "menu",
// path: "/system/menu",
// source: "iconfont iconicon_subordinate",
// component: "",
// sort: 6,
// category: 1,
// action: 0,
// isOpen: 1,
// remark: null,
// isDeleted: 0,
// parentName: null,
// categoryName: null,
// actionName: null,
// isOpenName: null,
// },
// ],
// parentName: null,
// categoryName: null,
// actionName: null,
// isOpenName: null,
// },
// ],
// timestamp: 1769062184895,
// }
// };
const data = res.data.result
let menu = deepClone(data);
menu.forEach(ele => {
addPath(ele, true);
});
commit('SET_MENU_ALL', menu)
commit('SET_MENU', menu)
// dispatch('GetButtons');
resolve(menu)
})
})
},
//获取系统按钮
GetButtons({commit}) {
GetButtons({ commit }) {
return new Promise((resolve) => {
getButtons().then(res => {
const data = res.data.data;
@ -315,7 +672,7 @@ const user = {
SET_TOKEN: (state, token) => {
setToken(token);
state.token = token;
setStore({name: 'token', content: state.token})
setStore({ name: 'token', content: state.token })
},
SET_MENU_ID(state, menuId) {
state.menuId = menuId;
@ -328,40 +685,40 @@ const user = {
}
})
state.menuAll = menu
setStore({name: 'menuAll', content: state.menuAll})
setStore({ name: 'menuAll', content: state.menuAll })
},
SET_MENU_ALL_NULL: (state) => {
state.menuAll = []
setStore({name: 'menuAll', content: state.menuAll})
setStore({ name: 'menuAll', content: state.menuAll })
},
SET_MENU: (state, menu) => {
state.menu = menu
setStore({name: 'menu', content: state.menu})
setStore({ name: 'menu', content: state.menu })
},
SET_REFRESH_TOKEN: (state, refreshToken) => {
setRefreshToken(refreshToken)
state.refreshToken = refreshToken;
setStore({name: 'refreshToken', content: state.refreshToken})
setStore({ name: 'refreshToken', content: state.refreshToken })
},
SET_TENANT_ID: (state, tenantId) => {
state.tenantId = tenantId;
setStore({name: 'tenantId', content: state.tenantId})
setStore({ name: 'tenantId', content: state.tenantId })
},
SET_USER_INFO: (state, userInfo) => {
if (validatenull(userInfo.user_id) && validatenull(userInfo.account)) {
state.userInfo = {user_name: 'unauth', role_name: 'unauth'};
state.userInfo = { user_name: 'unauth', role_name: 'unauth' };
} else {
if (validatenull(userInfo.avatar)) {
userInfo.avatar = "/img/bg/img-logo.png";
}
state.userInfo = userInfo;
}
setStore({name: 'userInfo', content: state.userInfo})
setStore({ name: 'userInfo', content: state.userInfo })
},
SET_USER_AUTH_INFO: (state, userInfo) => {
console.log('userInfo')
state.userInfo = userInfo;
setStore({name: 'userInfo', content: state.userInfo})
setStore({ name: 'userInfo', content: state.userInfo })
},
SET_ROLES: (state, roles) => {
state.roles = roles;
@ -388,7 +745,7 @@ const user = {
result.forEach(ele => {
state.permission[ele] = true;
});
setStore({name: 'permission', content: state.permission})
setStore({ name: 'permission', content: state.permission })
}
}

Loading…
Cancel
Save