Эх сурвалжийг харах

获取关联 子账号 由获取用户信息返回 改为 我的页面实时查询; 减少查询次数(用户进入我的页面 次数较少)

zhulu 11 сар өмнө
parent
commit
b547eeade7

+ 8 - 0
src/api/public.js

@@ -35,6 +35,14 @@ export function switchUser(subUserId) {
   })
 }
 
+//获取用户关联账号
+export function getSubUsers() {
+  return request({
+    url: `/system/user/subuser`,
+    method: 'get',
+  })
+}
+
 //获取用户
 export function userUnDoList(userIds) {
   return request({

+ 12 - 5
src/components/TopBar.vue

@@ -106,19 +106,20 @@
 </template>
 <script>
   import { mapGetters } from 'vuex'
-  import { logout,switchUser,userUnDoList } from '@/api/public'
+  import { logout,switchUser,userUnDoList,getSubUsers } from '@/api/public'
   export default {
     data() {
       return {
         showPopover:false,
         peoplesId:null,
         subUserActions: [],
+        subUserList:[],
       }
     },
-    created(){
+    created(){      
     },
-    mounted(){
-
+    mounted(){      
+      this.getMenuList()
     },
     watch:{
       subUserList:{
@@ -132,7 +133,7 @@
       }
     },
     computed: {
-      ...mapGetters(['userName', 'orgName','roleList', 'orgId','subUserList','masterUserName','masterUserId']),
+      ...mapGetters(['userName', 'orgName','roleList', 'orgId','masterUserName','masterUserId']),
     },
     methods: {
       showDailog(){
@@ -215,6 +216,12 @@
           this.$router.replace('/login');
           this.$toast('退出登录');
         })
+      },
+      getSubUserList()
+      {
+        getSubUsers().then(res=>{
+          this.subUserList=res.data;
+        })
       }
     }
   }

+ 1 - 1
src/components/layouts/index.vue

@@ -64,7 +64,7 @@ export default {
         this.$store.commit('SET_USER_ORGID', info.user.orgId)
         this.$store.commit('SET_USER_ORGNAME', info.user.orgName)
         this.$store.commit('SET_USER_ORGTYPE', info.user.orgType)
-        this.$store.commit('SET_USER_SUBUSERLIST', info.subUserList)
+        this.$store.commit('SET_USER_SUBUSERLIST', info.subUserList??null)
         this.$store.commit('SET_MASTER_USER_ID', info.masterUserId)
         this.$store.commit('SET_MASTER_USER_NAME', info.masterUserName)
         this.$store.commit('SET_MASTER_SIGNATURE_SEAL', info.user.signatureSeal)

+ 1 - 1
src/router/router.config.js

@@ -120,7 +120,7 @@ export let routers = [
         path: '/isMy',
         name: 'isMy',
         component: () => import('@/views/home/isMy'),
-        meta: { title: '我的', keepAlive: true, deep: 0.5 }
+        meta: { title: '我的', keepAlive: false, deep: 0.5 }
       },
       {
         path: '/message',

+ 2 - 1
src/views/home/isMy.vue

@@ -1,6 +1,6 @@
 <template>
   <div v-if="showMine" class="about-container">
-    <top-bar></top-bar>
+    <top-bar ref="topbar"></top-bar>
     <div  class="item-list">
 
       <van-cell is-link @click="clickMine">
@@ -140,6 +140,7 @@ export default {
   },
   mounted() {
     this.initData();
+    this.$refs.topbar.getSubUserList();
   },
   methods: {
     initData(){