Explorar o código

feat:新增权限接口

YaolongHan %!s(int64=4) %!d(string=hai) anos
pai
achega
945b2b047e
Modificáronse 5 ficheiros con 69 adicións e 19 borrados
  1. 2 2
      src/api/login.js
  2. 5 0
      src/api/public.js
  3. 8 10
      src/main.js
  4. 46 5
      src/store/index.js
  5. 8 2
      src/views/equipment/index.vue

+ 2 - 2
src/api/login.js

@@ -1,6 +1,6 @@
 // 登录校验接口
 import httputils from "@/api/httputils"
 
-export function login({ getParams }) {
-    return httputils.getJson(`/api/auth/check`, getParams)
+export function login(params) {
+    return httputils.getJson(`/api/auth/check`, params)
 }

+ 5 - 0
src/api/public.js

@@ -0,0 +1,5 @@
+import httputils from "@/api/httputils"
+// 查询楼层清单
+export function getFloorList(getParams) {
+    return httputils.getJson(`/api/plaza/floor`, getParams)
+}

+ 8 - 10
src/main.js

@@ -29,18 +29,16 @@ Vue.use(PicLarge)
 
 import Legend from '@/components/Legend'
 Vue.use(Legend)
-import {
-    login
-} from '@/api/login.js'
+
+//////////模拟传入参数
+const username = 'aiyu6';
+/////////////////
 // 在跳入路由之前要请求获取权限信息
-router.beforeEach((to, from, next) => {
-    const getParams = {
-        username: 'aiyu6'
+router.beforeEach(async (to, from, next) => {
+    if (!store.state.isrequestAuth) {
+        await store.dispatch('getUserInfo',username);
     }
-    login(getParams).then(res => {
-        console.log(res)
-    })
-    next()
+    next();
 })
 new Vue({
     router,

+ 46 - 5
src/store/index.js

@@ -1,15 +1,56 @@
 import Vue from 'vue'
 import Vuex from 'vuex'
-
+import {
+  login
+} from '@/api/login.js'
 Vue.use(Vuex)
-
 export default new Vuex.Store({
   state: {
+    isrequestAuth: false, // 是否请求登录校验接口
+    permissions: [], //权限信息 "GLSMS_VIEW":"说明书查看"、"GLSMS_SYMBOL_MANAGE": "图例库管理"、 "GLSMS_PLANARGRAPH_MANAGE":"平面图维护"
+    plazas: [], //项目列表
+    userInfo: {
+      employeename: '', //用户名称:艾宇;
+      orgCode: '',
+      username: 'aiyu6' //账户名称
+    }
   },
+
   mutations: {
+    // 设置是否登陆校验
+    SETISREQUESTtAUTH(state, palyload) {
+      state.isrequestAuth = palyload;
+    },
+    // 设置相关权限信息
+    SETAUTHMSG(state, palyload) {
+      state.permissions = palyload.permissions;
+      state.plazas = palyload.plazas;
+      state.userInfo.employeename = palyload.employeename;
+      state.userInfo.orgCode = palyload.orgCode;
+      state.userInfo.username = palyload.username;
+    },
   },
+  //   const params = {
+  //     username: 'aiyu6'
+  // }
+
   actions: {
+    // 获取项目列表、userId
+    async getUserInfo({
+      commit
+    }, palyload) {
+      await login({
+        username: palyload
+      }).then(res => {
+        if (res.result == "success") {
+          commit("SETISREQUESTtAUTH", true);
+          commit("SETAUTHMSG", res);
+        } else {
+          console.log('接口报错!!')
+          commit("SETISREQUESTtAUTH", false);
+        }
+      })
+    }
   },
-  modules: {
-  }
-})
+  modules: {}
+})

+ 8 - 2
src/views/equipment/index.vue

@@ -43,6 +43,9 @@ import eqDialog from './eqDialog'
 import bottomLayer from './bottomLayer'
 import editList from '@/components/edit.vue'
 import { system, floors } from '@/utils/plugins/components.js'
+import {
+  getFloorList
+} from '@/api/public.js'
 export default {
     data() {
         return {
@@ -75,7 +78,10 @@ export default {
     },
     mounted() {
         this.everySystem = this.system[0].children
-        this.$refs.floorMap.init()
+        this.$refs.floorMap.init();
+        getFloorList({plazaId:'964'}).then((res)=>{
+            console.log('12313',res)
+        })
         // this.$refs.dialog.init()
     }
 }
@@ -159,4 +165,4 @@ export default {
         }
     }
 }
-</style> 
+</style>