|
@@ -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()
|
|
|
})
|
|
|
})
|