Răsfoiți Sursa

fix(bpm): 修复权限控制问题,优化用户权限数据处理

yusheng 3 luni în urmă
părinte
comite
a111eea027
2 a modificat fișierele cu 12 adăugiri și 7 ștergeri
  1. 10 6
      src/store/modules/user.js
  2. 2 1
      src/views/bpm/collaborative/index.vue

+ 10 - 6
src/store/modules/user.js

@@ -6,7 +6,7 @@ import { USER_MENUS } from '@/config/setting';
 import { getResourcesTree } from '@/api/layout';
 import { SYSTEM_NAME } from '@/config/setting';
 import Vue from 'vue';
-import { getCurrentUser,setCurrentUser } from '@/utils/token-util';
+import { getCurrentUser, setCurrentUser } from '@/utils/token-util';
 
 const formatRouter = (list) => {
   let menuList = []; // menuType
@@ -17,7 +17,7 @@ const formatRouter = (list) => {
     for (const p of list) {
       if (p.menuType === 2) {
         // p.children = [];
-        // authorities.push(p);
+        authorities.push(p);
         p.hide = true;
       }
       //报表菜单 source = 2 为报表时 extend 为报表id
@@ -67,7 +67,7 @@ export default {
     },
     // 设置登录用户的权限
     setAuthorities(state, authorities) {
-      state.authorities = authorities;
+      state.authorities = authorities.map((item) => item.permissionCode);
     },
     // 设置登录用户的权限路由
     setAuthoritiesRouter(state, authoritiesRouter) {
@@ -111,15 +111,19 @@ export default {
     //   console.log('menus',menus, 'homePath',homePath)
     //   return { menus, homePath };
     // },
-    async fetchUserInfo({ commit}) {
-      let currentUser = getCurrentUser()
-      const result = await getResourcesTree({groupId:currentUser.currentGroupId,roleId:currentUser.currentRoleId}).catch(() => {});
+    async fetchUserInfo({ commit }) {
+      let currentUser = getCurrentUser();
+      const result = await getResourcesTree({
+        groupId: currentUser.currentGroupId,
+        roleId: currentUser.currentRoleId
+      }).catch(() => {});
       const list = result?.filter((i) => i.path === '/page-wt');
       if (!list?.length) {
         return {};
       }
 
       const { menuList, authorities } = formatRouter(list[0].children);
+      console.log(list[0].children,'authorities')
 
       // 用户权限
       // const authorities =

+ 2 - 1
src/views/bpm/collaborative/index.vue

@@ -652,7 +652,7 @@
                   </template> -->
                 </ele-pro-table>
               </el-tab-pane>
-              <el-tab-pane label="全部记录" name="all">
+              <el-tab-pane label="全部记录" name="all" v-if="$hasPermission('wt:collaborative:all')">
                 <ele-pro-table
                   ref="allTable"
                   :columns="deptColumns"
@@ -1137,6 +1137,7 @@
       await this.getTemplateList();
       await this.getUserList();
       await this.getDeptList();
+      console.log(this.$hasPermission('wt:collaborative:all'))
     },
     methods: {
       formatValue(value) {