From a93255e0a0334b51ecbaf3d8f496ad0fae1ed747 Mon Sep 17 00:00:00 2001
From: loulijun2021 <1694218219@qq.com>
Date: 星期三, 07 六月 2023 10:38:00 +0800
Subject: [PATCH] 1.生产入库有源单提交测试OK

---
 src/store/modules/permission.js |   45 +++++++++++++++++++++++++++++++++------------
 1 files changed, 33 insertions(+), 12 deletions(-)

diff --git a/src/store/modules/permission.js b/src/store/modules/permission.js
index 2b74277..706fed9 100644
--- a/src/store/modules/permission.js
+++ b/src/store/modules/permission.js
@@ -1,5 +1,6 @@
-import { asyncRoutes, commonRoutes } from '@/router'
+import { asyncRoutes, asyncRoutesCloud, commonRoutes } from '@/router'
 import Layout from '@/layout'
+import { getCookie } from '@/utils/auth'
 
 // 鍒ゆ柇鏄惁鏈夋潈闄�
 function hasPermission(roles, route) {
@@ -13,28 +14,37 @@
 /**
  * 鎶婂悗鍙拌繑鍥炶彍鍗曠粍瑁呮垚routes瑕佹眰鐨勬牸寮�
  * @param {*} routes
+ * @param {*} menu
  */
-export function getAsyncRoutes(routes2, menu) {
+export function getAsyncRoutes(routes, menu) {
+  // menu  涓璮lag  "0" 琛ㄧず true  "1"琛ㄧずfalse
   const menuCode = []// 灏嗗悗绔痗ode鍙栧嚭瀛樻垚鏁扮粍褰㈠紡
+  const menuNameAndCode = []// 灏嗗悗绔痗ode涓巒ame鍙栧嚭瀛樻垚鏁扮粍褰㈠紡
   menu.forEach(item => {
-    menuCode.push(item.code)
-    if (item.children && item.children.length > 0) {
-      item.children.forEach(it => {
-        menuCode.push(it.code)
-      })
+    if (item.flag === '0') {
+      menuCode.push(item.code)
+      menuNameAndCode.push({ code: item.code, name: item.name })
+      if (item.children && item.children.length > 0) {
+        item.children.forEach(it => {
+          if (it.flag === '0') {
+            menuCode.push(it.code)
+            menuNameAndCode.push({ code: it.code, name: it.name })
+          }
+        })
+      }
     }
   })
 
-  const routes = routes2
-  const newRoutes = []
+  const newRoutes = [] // 鏂拌矾鐢�
 
   routes.forEach(item => {
     if (menuCode.includes(item.code) && item.children && item.children.length > 0) {
-      console.log(item)
+      item.meta.title = menuNameAndCode.find(item2 => item2.code === item.code).name
       const children = []
       let flag = false// 鍒ゆ柇鏄惁鏈塩hildren瀛樿繘鍘�
       item.children.forEach(it => {
         if (menuCode.includes(it.code)) {
+          it.meta.title = menuNameAndCode.find(item2 => item2.code === it.code).name
           children.push(it)
           flag = true
         }
@@ -89,8 +99,19 @@
 const actions = {
   generateRoutes({ commit }, menu) {
     return new Promise(resolve => {
-      const newRoutes = getAsyncRoutes(asyncRoutes, menu)
-      console.log(newRoutes, 2)
+      // const newRoutes = getAsyncRoutes(asyncRoutes, menu)
+      let newRoutes
+      if (getCookie('cloud')) {
+        const arr = menu.map(i => i.code)
+        newRoutes = asyncRoutesCloud.filter(i => {
+          if (arr.includes(i.code)) {
+            return i
+          }
+        })
+        newRoutes.push({ path: '*', redirect: '/404', hidden: true })
+      } else {
+        newRoutes = getAsyncRoutes(asyncRoutes, menu)
+      }
       commit('SET_ROUTES', newRoutes)
       resolve(newRoutes)
     })

--
Gitblit v1.9.3