sunlupeng преди 1 година
родител
ревизия
776de187b7
променени са 6 файла, в които са добавени 296 реда и са изтрити 270 реда
  1. 2 3
      src/api/home.js
  2. 12 9
      src/components/AppList/index.vue
  3. 166 151
      src/layout/components/Homebar.vue
  4. 108 99
      src/layout/components/Navbar.vue
  5. 1 1
      src/store/modules/permission.js
  6. 7 7
      src/views/system/menu/index.vue

+ 2 - 3
src/api/home.js

@@ -9,10 +9,9 @@ export function appList() {
 }
 
 //通过menuId查询本身及子级树 
-export function listPost(query) {
+export function getListByMenuId(menuId) {
   return request({
-    url: '/system/menu/getListByMenuId',
+    url: '/system/menu/getListByMenuId?menuId=' + menuId,
     method: 'get',
-    params: query
   })
 }

+ 12 - 9
src/components/AppList/index.vue

@@ -124,25 +124,28 @@ export default {
     },
     // 菜单选择事件
     handleSelect(item) {
+      console.log(item);
       let key = item.path;
-      getListByMenuId({menuld:item.id}).then(response => {
+      if(this.ishttp(key)){
+        // http(s):// 路径新窗口打开
+        window.open(key, "_blank");
+      }else if(item.path.indexOf('oa') > -1){
+        this.$router.push({ path: key });
+      }else{
+        getListByMenuId(item.id).then(response => {
           let menuList =response.data;
+          localStorage.setItem("parentId", item.parentId)
           localStorage.setItem("menus", JSON.stringify(menuList))
-          if (this.ishttp(key)) {
-            // http(s):// 路径新窗口打开
-            window.open(key, "_blank");
-          } else {
-            store.dispatch('GenerateRoutes', menuList).then(accessRoutes => {
+          store.dispatch('GenerateRoutes', menuList).then(accessRoutes => {
               console.log(accessRoutes);
               // 根据 roles 权限生成可访问的路由表
               router.addRoutes(accessRoutes) // 动态添加可访问路由表
             })
             setTimeout(() => {
-              this.$router.push({ path: key });
+              this.$router.push({ path: item.component });
             }, 200);
-          }
         });
-      
+      }
       const menus = [
         {
           "id": 1254,

+ 166 - 151
src/layout/components/Homebar.vue

@@ -1,35 +1,30 @@
 <template>
   <div class="navbar">
     <div class="left-menu">
-        <el-popover
-          popper-class="down-popover"
-          placement="bottom"
-          width="360"
-          :visible-arrow="false"
-          trigger="click">
-          <div class="corp-switch">
-            <div class="current-corp">{{ tenantName }}</div>
-            <el-button type="text" style="color: #00B899;" @click="showProcessInstance()">
-              <i class="el-icon-s-operation"></i>
-              切换企业/团队
-            </el-button>
-           
-          </div>
-          <i class="el-icon-s-grid icon-menu" slot="reference"></i>
-        </el-popover>
-        <div class="divider"></div>
-        <a class="text" href="/">
-          <img :src="logo" class="menu-icon dashboard" />
-          <!-- <div class="menu-icon dashboard" style="background-image: url(&quot;https://g.jdycdn.com/app/pc/311a8e2b1ed9.png&quot;);"></div> -->
-          工作台
-        </a>
+      <el-popover popper-class="down-popover" placement="bottom" width="360" :visible-arrow="false" trigger="click">
+        <div class="corp-switch">
+          <div class="current-corp">{{ tenantName }}</div>
+          <el-button type="text" style="color: #00B899;" @click="showProcessInstance()">
+            <i class="el-icon-s-operation"></i>
+            切换企业/团队
+          </el-button>
+
+        </div>
+        <i class="el-icon-s-grid icon-menu" slot="reference"></i>
+      </el-popover>
+      <div class="divider"></div>
+      <a class="text" href="/">
+        <img :src="logo" class="menu-icon dashboard" />
+        <!-- <div class="menu-icon dashboard" style="background-image: url(&quot;https://g.jdycdn.com/app/pc/311a8e2b1ed9.png&quot;);"></div> -->
+        工作台
+      </a>
     </div>
-    
-    
-    
+
+
+
 
     <div class="right-menu">
-      <template v-if="device!=='mobile'">
+      <template v-if="device !== 'mobile'">
         <el-tooltip content="文档地址" effect="dark" placement="bottom">
           <ruo-yi-doc id="ruoyi-doc" class="right-menu-item hover-effect" />
         </el-tooltip>
@@ -52,7 +47,7 @@
           <router-link to="/user/profile">
             <el-dropdown-item>个人中心</el-dropdown-item>
           </router-link>
-          <el-dropdown-item @click.native="companySetting('/system/companyInfo')">
+          <el-dropdown-item @click.native="companySetting()">
             <span>企业管理</span>
           </el-dropdown-item>
           <el-dropdown-item divided @click.native="logout">
@@ -61,7 +56,7 @@
         </el-dropdown-menu>
       </el-dropdown>
     </div>
-   
+
   </div>
 </template>
 
@@ -76,9 +71,11 @@ import Search from '@/components/HeaderSearch'
 import RuoYiGit from '@/components/RuoYi/Git'
 import RuoYiDoc from '@/components/RuoYi/Doc'
 import NotifyMessage from '@/layout/components/Message'
-import {getPath} from "@/utils/ruoyi";
+import { getPath } from "@/utils/ruoyi";
 import logoImg from '@/assets/logo/work.png'
 import router from '@/router'
+import {getListByMenuId} from "@/api/home";
+
 export default {
   data() {
     return {
@@ -126,124 +123,132 @@ export default {
       this.$parent.showTeamWork();
     },
     childMethod() {
-        this.$parent.fatherMethod();
+      this.$parent.fatherMethod();
     },
     toggleSideBar() {
       this.$store.dispatch('app/toggleSideBar')
     },
-    async companySetting(item){
-      let key = item;
-      const menus = [
-        {
-          "id": 1,
-          "parentId": 0,
-          "name": "企业管理",
-          "path": "/system",
-          "component": null,
-          "componentName": null,
-          "icon": "system",
-          "visible": true,
-          "keepAlive": true,
-          "alwaysShow": true,
-          "children": [
+    async companySetting() {
+      let item = {
+        id: 6,
+        parentId: 5,
+        path: "/system/companyInfo",
+      }
+      getListByMenuId(item.id).then(response => {
+        let menuList = response.data;
+        const menus = [
           {
-              "id": 109,
-              "parentId": 1,
-              "name": "企业信息",
-              "path": "companyInfo",
-              "component": "system/companyInfo/index",
-              "componentName": "SystemCompanyInfo",
-              "icon": "tree-table",
-              "visible": true,
-              "keepAlive": true,
-              "alwaysShow": true,
-              "children": null
-            },
-            {
-              "id": 102,
-              "parentId": 1,
-              "name": "菜单管理",
-              "path": "menu",
-              "component": "system/menu/index",
-              "componentName": "SystemMenu",
-              "icon": "tree-table",
-              "visible": true,
-              "keepAlive": true,
-              "alwaysShow": true,
-              "children": null
-            },
-            {
-              "id": 103,
-              "parentId": 1,
-              "name": "部门管理",
-              "path": "dept",
-              "component": "system/dept/index",
-              "componentName": "SystemDept",
-              "icon": "tree",
-              "visible": true,
-              "keepAlive": true,
-              "alwaysShow": true,
-              "children": null
-            },
-            {
-              "id": 100,
-              "parentId": 1,
-              "name": "用户管理",
-              "path": "user",
-              "component": "system/user/index",
-              "componentName": "SystemUser",
-              "icon": "user",
-              "visible": true,
-              "keepAlive": true,
-              "alwaysShow": true,
-              "children": null
-            },
-            {
-              "id": 101,
-              "parentId": 1,
-              "name": "角色管理",
-              "path": "role",
-              "component": "system/role/index",
-              "componentName": "SystemRole",
-              "icon": "peoples",
-              "visible": true,
-              "keepAlive": true,
-              "alwaysShow": true,
-              "children": null
-            },
-
-            {
-              "id": 105,
-              "parentId": 1,
-              "name": "字典管理",
-              "path": "dict",
-              "component": "system/dict/index",
-              "componentName": "SystemDictType",
-              "icon": "dict",
-              "visible": true,
-              "keepAlive": true,
-              "alwaysShow": true,
-              "children": null
-            }
-          ]
-        }
-      ]
-      localStorage.setItem("menus", JSON.stringify(menus))
-      this.$store.dispatch('GenerateRoutes', menus).then(accessRoutes => {
+            "id": 6,
+            "parentId": 5,
+            "name": "企业管理",
+            "path": "/system",
+            "component": null,
+            "componentName": null,
+            "icon": "system",
+            "visible": true,
+            "keepAlive": true,
+            "alwaysShow": true,
+            "children": [
+              {
+                "id": 109,
+                "parentId": 6,
+                "name": "企业信息",
+                "path": "companyInfo",
+                "component": "system/companyInfo/index",
+                "componentName": "SystemCompanyInfo",
+                "icon": "tree-table",
+                "visible": true,
+                "keepAlive": true,
+                "alwaysShow": true,
+                "children": null
+              },
+              {
+                "id": 102,
+                "parentId": 6,
+                "name": "菜单管理",
+                "path": "menu",
+                "component": "system/menu/index",
+                "componentName": "SystemMenu",
+                "icon": "tree-table",
+                "visible": true,
+                "keepAlive": true,
+                "alwaysShow": true,
+                "children": null
+              },
+              {
+                "id": 103,
+                "parentId": 6,
+                "name": "部门管理",
+                "path": "dept",
+                "component": "system/dept/index",
+                "componentName": "SystemDept",
+                "icon": "tree",
+                "visible": true,
+                "keepAlive": true,
+                "alwaysShow": true,
+                "children": null
+              },
+              {
+                "id": 100,
+                "parentId": 6,
+                "name": "用户管理",
+                "path": "user",
+                "component": "system/user/index",
+                "componentName": "SystemUser",
+                "icon": "user",
+                "visible": true,
+                "keepAlive": true,
+                "alwaysShow": true,
+                "children": null
+              },
+              {
+                "id": 101,
+                "parentId": 6,
+                "name": "角色管理",
+                "path": "role",
+                "component": "system/role/index",
+                "componentName": "SystemRole",
+                "icon": "peoples",
+                "visible": true,
+                "keepAlive": true,
+                "alwaysShow": true,
+                "children": null
+              },
+
+              {
+                "id": 105,
+                "parentId": 6,
+                "name": "字典管理",
+                "path": "dict",
+                "component": "system/dict/index",
+                "componentName": "SystemDictType",
+                "icon": "dict",
+                "visible": true,
+                "keepAlive": true,
+                "alwaysShow": true,
+                "children": null
+              }
+            ]
+          }
+        ]
+        localStorage.setItem("parentId", item.parentId)
+        localStorage.setItem("menus", JSON.stringify(menuList))
+        this.$store.dispatch('GenerateRoutes', menuList).then(accessRoutes => {
           console.log(accessRoutes);
           // 根据 roles 权限生成可访问的路由表
           router.addRoutes(accessRoutes) // 动态添加可访问路由表
         })
         setTimeout(() => {
-          this.$router.push({ path: key });
+          this.$router.push({ path: item.path });
         }, 200);
+      });
     },
     async logout() {
       this.$modal.confirm('确定注销并退出系统吗?', '提示').then(() => {
         this.$store.dispatch('LogOut').then(() => {
           location.href = getPath('/index');
         })
-      }).catch(() => {});
+      }).catch(() => { });
     }
   }
 }
@@ -258,28 +263,31 @@ a {
   outline: none;
   text-decoration: none;
 }
-.corp-switch{
+
+.corp-switch {
   align-items: center;
   display: flex;
   height: 65px;
   justify-content: space-between;
   padding-left: 20px;
+
   .current-corp {
-      color: #141e31;
-      font-size: 18px;
-      line-height: 32px;
-      overflow: hidden;
-      text-overflow: ellipsis;
-      white-space: nowrap;
-      width: 240px;
-  }      
+    color: #141e31;
+    font-size: 18px;
+    line-height: 32px;
+    overflow: hidden;
+    text-overflow: ellipsis;
+    white-space: nowrap;
+    width: 240px;
+  }
 }
+
 .navbar {
   height: 60px;
   overflow: hidden;
   position: relative;
   background: #fff;
-  box-shadow: 0 1px 4px rgba(0,21,41,.08);
+  box-shadow: 0 1px 4px rgba(0, 21, 41, .08);
 
   .hamburger-container {
     line-height: 46px;
@@ -287,7 +295,7 @@ a {
     float: left;
     cursor: pointer;
     transition: background .3s;
-    -webkit-tap-highlight-color:transparent;
+    -webkit-tap-highlight-color: transparent;
 
     &:hover {
       background: rgba(0, 0, 0, .025)
@@ -307,7 +315,7 @@ a {
     display: inline-block;
     vertical-align: top;
   }
-  
+
   .left-menu {
     font-size: 16px;
     padding: 0px 15px;
@@ -318,11 +326,13 @@ a {
     justify-content: center;
     align-items: center;
     cursor: pointer;
+
     .icon-menu:hover {
-        background: #e6e8ed;
-        border-radius: 3px;
+      background: #e6e8ed;
+      border-radius: 3px;
     }
-    .icon-menu{
+
+    .icon-menu {
       color: #525967;
       cursor: pointer;
       display: inline-block;
@@ -332,7 +342,8 @@ a {
       text-align: center;
       width: 30px;
     }
-    .divider{
+
+    .divider {
       height: 20px;
       margin: 0 5px;
       border: solid #EBECEE;
@@ -342,10 +353,12 @@ a {
       // margin: 0 15px;
       vertical-align: middle;
     }
+
     .text:hover {
-        background: #e6e8ed;
+      background: #e6e8ed;
     }
-    .text{
+
+    .text {
       height: 30px;
       align-items: center;
       border-radius: 4px;
@@ -353,7 +366,8 @@ a {
       display: flex;
       padding: 0 5px;
       transition: background .2s ease;
-      .menu-icon{
+
+      .menu-icon {
         background-size: 100px 20px;
         height: 20px;
         margin-right: 5px;
@@ -361,7 +375,7 @@ a {
       }
     }
   }
-  
+
   .right-menu {
     float: right;
     height: 100%;
@@ -404,7 +418,8 @@ a {
           height: 35px;
           border-radius: 50%;
         }
-        .user-nickname{
+
+        .user-nickname {
           margin-left: 5px;
           font-size: 14px;
         }

+ 108 - 99
src/layout/components/Navbar.vue

@@ -49,7 +49,7 @@
           <router-link to="/user/profile">
             <el-dropdown-item>个人中心</el-dropdown-item>
           </router-link>
-          <el-dropdown-item @click.native="companySetting('/system/companyInfo')">
+          <el-dropdown-item @click.native="companySetting()">
             <span>企业管理</span>
           </el-dropdown-item>
           <el-dropdown-item divided @click.native="logout">
@@ -74,6 +74,7 @@ import RuoYiDoc from '@/components/RuoYi/Doc'
 import NotifyMessage from '@/layout/components/Message'
 import {getPath} from "@/utils/ruoyi";
 import router from '@/router'
+import {getListByMenuId} from "@/api/home";
 export default {
   components: {
     Breadcrumb,
@@ -120,112 +121,120 @@ export default {
     toggleSideBar() {
       this.$store.dispatch('app/toggleSideBar')
     },
-    async companySetting(item){
-      let key = item;
-      const menus = [
-        {
-          "id": 1,
-          "parentId": 0,
-          "name": "企业管理",
-          "path": "/system",
-          "component": null,
-          "componentName": null,
-          "icon": "system",
-          "visible": true,
-          "keepAlive": true,
-          "alwaysShow": true,
-          "children": [
+    async companySetting() {
+      let item = {
+        id: 6,
+        parentId: 5,
+        path: "/system/companyInfo",
+      }
+      getListByMenuId(item.id).then(response => {
+        let menuList = response.data;
+        const menus = [
           {
-              "id": 109,
-              "parentId": 1,
-              "name": "企业信息",
-              "path": "companyInfo",
-              "component": "system/companyInfo/index",
-              "componentName": "SystemCompanyInfo",
-              "icon": "tree-table",
-              "visible": true,
-              "keepAlive": true,
-              "alwaysShow": true,
-              "children": null
-            },
-            // {
-            //   "id": 102,
-            //   "parentId": 1,
-            //   "name": "菜单管理",
-            //   "path": "menu",
-            //   "component": "system/menu/index",
-            //   "componentName": "SystemMenu",
-            //   "icon": "tree-table",
-            //   "visible": true,
-            //   "keepAlive": true,
-            //   "alwaysShow": true,
-            //   "children": null
-            // },
-            {
-              "id": 103,
-              "parentId": 1,
-              "name": "部门管理",
-              "path": "dept",
-              "component": "system/dept/index",
-              "componentName": "SystemDept",
-              "icon": "tree",
-              "visible": true,
-              "keepAlive": true,
-              "alwaysShow": true,
-              "children": null
-            },
-            {
-              "id": 100,
-              "parentId": 1,
-              "name": "用户管理",
-              "path": "user",
-              "component": "system/user/index",
-              "componentName": "SystemUser",
-              "icon": "user",
-              "visible": true,
-              "keepAlive": true,
-              "alwaysShow": true,
-              "children": null
-            },
-            {
-              "id": 101,
-              "parentId": 1,
-              "name": "角色管理",
-              "path": "role",
-              "component": "system/role/index",
-              "componentName": "SystemRole",
-              "icon": "peoples",
-              "visible": true,
-              "keepAlive": true,
-              "alwaysShow": true,
-              "children": null
-            },
+            "id": 6,
+            "parentId": 5,
+            "name": "企业管理",
+            "path": "/system",
+            "component": null,
+            "componentName": null,
+            "icon": "system",
+            "visible": true,
+            "keepAlive": true,
+            "alwaysShow": true,
+            "children": [
+              {
+                "id": 109,
+                "parentId": 6,
+                "name": "企业信息",
+                "path": "companyInfo",
+                "component": "system/companyInfo/index",
+                "componentName": "SystemCompanyInfo",
+                "icon": "tree-table",
+                "visible": true,
+                "keepAlive": true,
+                "alwaysShow": true,
+                "children": null
+              },
+              {
+                "id": 102,
+                "parentId": 6,
+                "name": "菜单管理",
+                "path": "menu",
+                "component": "system/menu/index",
+                "componentName": "SystemMenu",
+                "icon": "tree-table",
+                "visible": true,
+                "keepAlive": true,
+                "alwaysShow": true,
+                "children": null
+              },
+              {
+                "id": 103,
+                "parentId": 6,
+                "name": "部门管理",
+                "path": "dept",
+                "component": "system/dept/index",
+                "componentName": "SystemDept",
+                "icon": "tree",
+                "visible": true,
+                "keepAlive": true,
+                "alwaysShow": true,
+                "children": null
+              },
+              {
+                "id": 100,
+                "parentId": 6,
+                "name": "用户管理",
+                "path": "user",
+                "component": "system/user/index",
+                "componentName": "SystemUser",
+                "icon": "user",
+                "visible": true,
+                "keepAlive": true,
+                "alwaysShow": true,
+                "children": null
+              },
+              {
+                "id": 101,
+                "parentId": 6,
+                "name": "角色管理",
+                "path": "role",
+                "component": "system/role/index",
+                "componentName": "SystemRole",
+                "icon": "peoples",
+                "visible": true,
+                "keepAlive": true,
+                "alwaysShow": true,
+                "children": null
+              },
 
-            {
-              "id": 105,
-              "parentId": 1,
-              "name": "字典管理",
-              "path": "dict",
-              "component": "system/dict/index",
-              "componentName": "SystemDictType",
-              "icon": "dict",
-              "visible": true,
-              "keepAlive": true,
-              "alwaysShow": true,
-              "children": null
-            }
-          ]
-        }
-      ]
-      localStorage.setItem("menus", JSON.stringify(menus))
-      this.$store.dispatch('GenerateRoutes', menus).then(accessRoutes => {
+              {
+                "id": 105,
+                "parentId": 6,
+                "name": "字典管理",
+                "path": "dict",
+                "component": "system/dict/index",
+                "componentName": "SystemDictType",
+                "icon": "dict",
+                "visible": true,
+                "keepAlive": true,
+                "alwaysShow": true,
+                "children": null
+              }
+            ]
+          }
+        ]
+        localStorage.setItem("parentId", item.parentId)
+        localStorage.setItem("menus", JSON.stringify(menuList))
+        this.$store.dispatch('GenerateRoutes', menuList).then(accessRoutes => {
           console.log(accessRoutes);
           // 根据 roles 权限生成可访问的路由表
           router.addRoutes(accessRoutes) // 动态添加可访问路由表
         })
         setTimeout(() => {
-          this.$router.push({ path: key });
+          this.$router.push({ path: item.path });
         }, 200);
+      });
     },
     async logout() {
       this.$modal.confirm('确定注销并退出系统吗?', '提示').then(() => {

+ 1 - 1
src/store/modules/permission.js

@@ -75,7 +75,7 @@ function filterAsyncRouter(asyncRouterMap, lastRouter = false, type = false) {
     }
     // 处理 component 属性
     if (route.children) { // 父节点
-      if (route.parentId === 0) {
+      if (route.parentId == localStorage.getItem('parentId')) {
         route.component = Layout
       } else {
         route.component = ParentView

+ 7 - 7
src/views/system/menu/index.vue

@@ -363,13 +363,13 @@ export default {
             const path = this.form.path
             if (!isExternal(path)) {
               // 父权限为根节点,path 必须以 / 开头
-              if (this.form.parentId === 0 && path.charAt(0) !== '/') {
-                this.$modal.msgSuccess('前端必须以 / 开头')
-                return
-              } else if (this.form.parentId !== 0 && path.charAt(0) === '/') {
-                this.$modal.msgSuccess('前端不能以 / 开头')
-                return
-              }
+              // if (this.form.parentId === 0 && path.charAt(0) !== '/') {
+              //   this.$modal.msgSuccess('前端必须以 / 开头')
+              //   return
+              // } else if (this.form.parentId !== 0 && path.charAt(0) === '/') {
+              //   this.$modal.msgSuccess('前端不能以 / 开头')
+              //   return
+              // }
             }
           }