zhangqi пре 7 месеци
родитељ
комит
ada6660b91

+ 8 - 7
src/components/newLayout/modules/aside.vue

@@ -158,14 +158,15 @@ export default {
     const link = ()=>{
       this.$router.push({path:app.path})
     }
-    let active_model = JSON.parse(sessionStorage.getItem('active_modules'))
-    if (sessionStorage.getItem('activeApp')) {
-      let active_app = JSON.parse(sessionStorage.getItem('activeApp'))
+    // let active_model = JSON.parse(sessionStorage.getItem('active_modules'))
+    // if (sessionStorage.getItem('activeApp')) {
+    //   let active_app = JSON.parse(sessionStorage.getItem('activeApp'))
+
+    //   this.$store.dispatch('setActiveApp',{app:active_app,val:''})
+    // } else {
+    //   this.$store.dispatch('setActiveApp',{app:active_model.apps[0],val:''})
+    // }
 
-      this.$store.dispatch('setActiveApp',{app:active_app,val:'',link})
-    } else {
-      this.$store.dispatch('setActiveApp',{app:active_model.apps[0],val:'',link})
-    }
     this.systemList = JSON.parse(sessionStorage.getItem('module_info'))
 
     this.$store.dispatch('setAppMenu')

+ 7 - 5
src/components/newLayout/modules/header.vue

@@ -157,12 +157,16 @@ export default {
   methods: {
     // 选择登录账号
     async selectAccount(item) {
-      let arr = ["module_info", "activeApp", "active_modules", "folderid"];
+      let arr = ["module_info", "active_modules", "folderid"];
       arr.forEach((key) => {
         sessionStorage.removeItem(key);
       });
       sessionStorage.setItem("active_account", JSON.stringify(item));
-      await this.basicData.query_userauth();
+      await this.basicData.query_userauth(()=>{
+        this.$nextTick(() => {
+        this.$router.go(0);
+        });
+      })
       this.siteInfos();
       this.accountInfo = JSON.parse(sessionStorage.getItem("active_account"));
       this.accountList = JSON.parse(
@@ -170,9 +174,7 @@ export default {
       ).filter((e) => {
         return e.siteid !== this.accountInfo.siteid;
       });
-      this.$nextTick(() => {
-        this.$router.go(0);
-      });
+      
     },
     async getWeather() {
       const res = await axios.get(this.url);

+ 1 - 0
src/store/index.js

@@ -89,6 +89,7 @@ export default new Vuex.Store({
     },
 
     setActiveApp (state,data) {
+      console.log(state,data,'-')
       //头部区域搜索所传入的数值
       state.searchValue = data.val
 

+ 36 - 3
src/utils/basic-data.js

@@ -1,7 +1,7 @@
 import api from '../api/api'
 import tool from './tool'
 import store from '../store/index'
-
+import router from '../router';
 var areaData = [];
 /* 企业列表数据 */
 var enterpriseList = []
@@ -30,9 +30,30 @@ function getEnterpriseList () {
   }).then(res=>{
     enterpriseList = res.data
   })
+}
+function findAppByName(systems, targetName) {
+
+  let foundApp = null;
+  function search(systems) {
+    for (let i = 0; i < systems.length; i++) {
+      const system = systems[i];
+      if (system.modules && system.modules.length > 0) {
+        search(system.modules); // 递归调用搜索函数
+      }
+      if (system.apps) {
+        const app = system.apps.find((app) => app.name === targetName);
+        if (app) {
+          foundApp = app;
+          break; // 找到目标 app 后停止搜索
+        }
+      }
+    }
+  }
+  search(systems);
+  return foundApp;
 }
  // 查询应用授权
- function query_userauth () {
+function query_userauth (fn) {
   return new Promise((reslove, reject)=>{
     api.requested({
       "classname": "sysmanage.develop.userauthforweb.userauth",
@@ -41,10 +62,22 @@ function getEnterpriseList () {
         "place":1
       }
     }).then((res)=>{
+
       let active_modules = res.data[0].modules[0]
       sessionStorage.setItem('module_info', JSON.stringify(res.data))
       sessionStorage.setItem('active_modules', JSON.stringify(active_modules))
-      store.dispatch('setActiveApp',{name:active_modules.apps[0].systemappname,app:active_modules.apps[0],val:''})
+
+      let oldApp = JSON.parse(sessionStorage.getItem('activeApp'))
+      if (findAppByName(res.data,oldApp.name)) {
+        store.dispatch('setActiveApp',{name:active_modules.apps[0].systemappname,app:active_modules.apps[0],val:''})
+      } else {
+        const link = ()=>{
+          router.push({path:active_modules.apps[0].path})
+        }
+        store.dispatch('setActiveApp',{name:active_modules.apps[0].systemappname,app:active_modules.apps[0],val:'',link})
+      }
+      fn ? fn() :''
+
       reslove()
     })
   })