Browse Source

update 登录

zhulizhen1111 4 years ago
parent
commit
32976a4904
5 changed files with 103 additions and 89 deletions
  1. 0 5
      src/api/httputils.js
  2. 1 1
      src/components/menuList.vue
  3. 58 57
      src/router/index.js
  4. 41 25
      src/store/index.js
  5. 3 1
      src/views/equipment/table/zwTable.vue

+ 0 - 5
src/api/httputils.js

@@ -22,11 +22,6 @@ axiosservice.interceptors.request.use(
         config.withCredentials = true // 允许携带token ,这个是解决跨域产生的相关问题
         let token = store.getters['ssoToken']
         let isPreview = store.getters["isPreview"]
-        // if (token) {
-        //     config.headers = {
-        //         'sso-token': token,
-        //     }
-        // }
         if (config.url.indexOf('mapapp') < 0) {
             config.headers = {
                 "sso-token": token,

+ 1 - 1
src/components/menuList.vue

@@ -5,7 +5,7 @@
             <div class='downright'></div>
             <div class='home-box'>
                 <img src='@/assets/imgs/logo.png' alt />
-                <span>{{plazas.length>0?formatter(plazaId,plazas):'--'}}</span>
+                <span v-if="plazas">{{plazas.length>0?formatter(plazaId,plazas):'--'}}</span>
             </div>
         </div>
         <div>

+ 58 - 57
src/router/index.js

@@ -1,103 +1,104 @@
-import Vue from 'vue'
-import store from '@/store'
-import VueRouter from 'vue-router'
-import { query } from '@/utils/query'
+import Vue from "vue"
+import store from "@/store"
+import VueRouter from "vue-router"
+import { query } from "@/utils/query"
 Vue.use(VueRouter)
 
 const routes = [
     // 登陆页面
     {
-        path: '/',
-        redirect: '/home/overview',
+        path: "/",
+        redirect: "/home/overview",
     },
     {
-        path: '/404',
-        component: () => import('../components/404'),
+        path: "/404",
+        component: () => import("../components/404"),
     },
     // home
     {
-        path: '/home',
-        name: 'home',
-        component: () => import('../views/index'),
-        redirect: '/home/first',
+        path: "/home",
+        name: "home",
+        component: () => import("../views/index"),
+        redirect: "/home/first",
         children: [
             {
-                path: 'first',
-                component: () => import('../views/first'),
+                path: "first",
+                component: () => import("../views/first"),
             },
             //概览
             {
-                path: 'overview',
-                component: () => import('../views/overview'),
+                path: "overview",
+                component: () => import("../views/overview"),
             },
             // 楼层功能
             {
-                path: 'floorFunc',
-                component: () => import('../views/floorFunc'),
+                path: "floorFunc",
+                component: () => import("../views/floorFunc"),
             },
             // 设备设施
             {
-                path: 'equipment',
-                component: () => import('../views/equipment'),
+                path: "equipment",
+                component: () => import("../views/equipment"),
             },
             // 其他功能
             {
-                path: 'other',
-                component: () => import('../views/other'),
+                path: "other",
+                component: () => import("../views/other"),
             },
             // 分析
             {
-                path: 'analysis',
-                component: () => import('../views/analysis'),
+                path: "analysis",
+                component: () => import("../views/analysis"),
             },
             //图例库管理
             {
-                path: 'legendLibrary',
-                component: () => import('../views/legendLibrary'),
+                path: "legendLibrary",
+                component: () => import("../views/legendLibrary"),
             },
             //图例绘制规则
             {
-                path: 'legendRules',
-                component: () => import('../views/legendRules'),
+                path: "legendRules",
+                component: () => import("../views/legendRules"),
             },
         ],
     },
 ]
 const router = new VueRouter({
-    mode: 'history',
+    mode: "history",
     base: process.env.BASE_URL,
     routes,
 })
+const ignore = ["/404"]
 router.beforeEach(async (to, from, next) => {
-    const token = query().token
-    console.log(token)
-    const ssoToken = store.getters['ssoToken']
-    if (ssoToken) {
-        store.commit('SETSSOTOKEN', ssoToken)
-        await store.dispatch('getUserInfo')
-        await store.dispatch('getFloors')
-        await store.dispatch('getBrand')
-        next()
-    } else if (token) {
-        store.commit('SETSSOTOKEN', token)
-        console.log(store.state.ssoToken)
-        await store.dispatch('getUserInfo')
-        next()
-    } else {
-        let lastRoute = {
-            path: to.path,
-            params: to.params,
-            query: to.query,
+    if (!ignore.includes(to.path)) {
+        const token = query().token
+        const ssoToken = store.getters["ssoToken"]
+        if (ssoToken) {
+            store.commit("SETSSOTOKEN", ssoToken)
+            await store.dispatch("getUserInfo", router)
+            await store.dispatch("getFloors")
+            await store.dispatch("getBrand")
+            next()
+        } else if (token) {
+            store.commit("SETSSOTOKEN", token)
+            await store.dispatch("getUserInfo", router)
+            next()
+        } else {
+            let lastRoute = {
+                path: to.path,
+                params: to.params,
+                query: to.query,
+            }
+            store.commit("SETLASTROUTER", lastRoute)
+            let ssoServer = "http://oauth.wanda-dev.cn"
+            let systemcode = "CAD156",
+                signal = new Date().getTime(),
+                version = "1.0.0"
+            window.location.href = `${ssoServer}/login?systemcode=${systemcode}&signal=${signal}&version=${version}`
         }
-        store.commit('SETLASTROUTER', lastRoute)
-        let ssoServer = 'http://oauth.wanda-dev.cn'
-        let systemcode = 'CAD156',
-            signal = new Date().getTime(),
-            version = '1.0.0',
-            // returnurl = 'http://glsms.wanda-dev.cn/'
-            // returnurl = window.location.protocol + "//" + window.location.host + "/wandaBmGuide"
-            returnurl = 'http://localhost:8090/wandaBmGuide/home/equipment'
-        window.location.href = `${ssoServer}/login?token=${token}&systemcode=${systemcode}&signal=${signal}&version=${version}&returnurl=${returnurl}`
+    } else {
+        next()
+        return
     }
 })
 export default router

+ 41 - 25
src/store/index.js

@@ -1,34 +1,35 @@
-import Vue from 'vue'
-import Vuex from 'vuex'
-import { login, queryFloor, queryfmapID } from '@/api/login.js'
-import { queryBrand } from '@/api/public.js'
-import axios from 'axios'
+import Vue from "vue"
+import Vuex from "vuex"
+import { login, queryFloor, queryfmapID } from "@/api/login.js"
+import { queryBrand } from "@/api/public.js"
+import axios from "axios"
+import router from "../router"
 
 Vue.use(Vuex)
 export default new Vuex.Store({
     state: {
-        ssoToken: 'admin:lengqiang',
-        // ssoToken: null,
+        // ssoToken: 'admin:lengqiang',
+        ssoToken: null,
         isPreview: false,
-        lastRoute: '',
+        lastRoute: "",
         isrequestAuth: true, // 是否请求登录校验接口
         permissions: [], //权限信息 "GLSMS_VIEW":"说明书查看"、"GLSMS_SYMBOL_MANAGE": "图例库管理"、 "GLSMS_PLANARGRAPH_MANAGE":"平面图维护"
         plazas: [], //项目列表
         userInfo: {
-            employeename: '', //用户名称:艾宇;
-            orgCode: '',
-            username: 'lengqiang', //账户名称
+            employeename: "", //用户名称:艾宇;
+            orgCode: "",
+            username: "lengqiang", //账户名称
         },
-        plazaId: '1000423', //项目Id
-        projectName: '', //全局项目名称
+        plazaId: "1000423", //项目Id
+        projectName: "", //全局项目名称
         floorsArr: [], //楼层数组
         floorSelect: [], //楼层下拉框
-        fmapID: '',
+        fmapID: "",
         haveFengMap: false, //是否有蜂鸟地图的数据
         isMessage: true, //是否有发布的图
         scpzTable: [], //土建系统图例展示
         legendTable: [], //除土建系统图例展示
-        remarksText: '', //备注
+        remarksText: "", //备注
         bunkObj: {}, // 铺位名称
         currentFloor: {}, //当前选中的楼层信息
     },
@@ -111,20 +112,35 @@ export default new Vuex.Store({
     actions: {
         // 获取项目列表、userId
         async getUserInfo({ commit }, palyload) {
-            await login({ username: palyload }).then((res) => {
-                if (res.result == 'success') {
-                    commit('SETISREQUESTtAUTH', true)
-                    commit('SETAUTHMSG', res)
+            await login({}).then((res) => {
+                if (res.result == "success") {
+                    // token校验成功 拿到权限
+                    //commit("SETISREQUESTtAUTH", true)
+                    debugger
+                    console.log("-----", palyload)
+                    if (res.permissions.length == 0) {
+                        //权限不足
+                        console.log("权限不足!!")
+                        router.push({ path: "/404", query: { result: "权限不足" } })
+                    }
+                    commit("SETAUTHMSG", res)
+                } else if (res.result == "no_auth") {
+                    //登录失败
+                    console.log("登录失败!!")
+                    commit("SETISREQUESTtAUTH", false)
+                    router.push({ path: "/404", query: { result: "登录失败" } })
                 } else {
-                    console.log('接口报错!!')
-                    commit('SETISREQUESTtAUTH', false)
+                    //访问出错 500
+                    console.log("访问出错!!")
+                    commit("SETISREQUESTtAUTH", false)
+                    router.push({ path: "/404", query: { result: "访问出错" } })
                 }
             })
         },
         getFloors(context) {
             queryFloor({ plazaId: context.state.plazaId }).then((res) => {
-                if (res.result == 'success') {
-                    context.commit('SETFLOORS', res.data)
+                if (res.result == "success") {
+                    context.commit("SETFLOORS", res.data)
                 }
             })
         },
@@ -132,7 +148,7 @@ export default new Vuex.Store({
             await queryfmapID({
                 mapId: context.state.plazaId,
             }).then((res) => {
-                context.commit('SETMAPID', `${context.state.plazaId}_${res.mapVersion}`)
+                context.commit("SETMAPID", `${context.state.plazaId}_${res.mapVersion}`)
             })
         },
         async getBrand(context) {
@@ -147,7 +163,7 @@ export default new Vuex.Store({
                         obj[i.bunkdesc] = i
                     })
                 }
-                context.commit('SETBUNKOBJ', obj)
+                context.commit("SETBUNKOBJ", obj)
             })
         },
     },

+ 3 - 1
src/views/equipment/table/zwTable.vue

@@ -70,7 +70,9 @@
                 <template slot-scope='{row}'>{{row.sl>=0?row.sl:'--'}}</template>
             </el-table-column>
             <el-table-column prop='ssfasm' label='实施方案说明' show-overflow-tooltip resizable min-width='320'>
-                <template slot-scope='{row}'>{{row.ssfasm || '--'}}</template>
+                <template slot-scope='{row}'>
+                    <a :href="`http://10.199.204.167:7001/maximo/ui/?event=loadapp&value=GCZXWXLINE&uniqueid=${row.ssfasm}`" target='_blank'>{{row.ssfasm || '--'}}</a>
+                </template>
             </el-table-column>
             <el-table-column prop='sxjd' label='当前阶段' show-overflow-tooltip resizable width='80'>
                 <template slot-scope='{row}'>{{row.sxjd || '--'}}</template>