Browse Source

fix: get personal department tree 401

Casper Dai 2 years ago
parent
commit
4139f9e307
3 changed files with 11 additions and 7 deletions
  1. 6 2
      src/api/user.js
  2. 2 2
      src/store/getters.js
  3. 3 3
      src/views/dashboard/Dashboard.vue

+ 6 - 2
src/api/user.js

@@ -309,7 +309,7 @@ export function getDepartments () {
 }
 }
 
 
 export function getDepartmentTree () {
 export function getDepartmentTree () {
-  if (store.getters.isTopGroup) {
+  if (store.getters.isTenantAdmin) {
     return getDepartments().then(({ data }) => {
     return getDepartments().then(({ data }) => {
       return {
       return {
         data: [{
         data: [{
@@ -325,7 +325,11 @@ export function getDepartmentTree () {
     method: 'GET'
     method: 'GET'
   }).then(({ data }) => {
   }).then(({ data }) => {
     return {
     return {
-      data: [data]
+      data: [{
+        path: store.getters.tenant,
+        name: '我的部门',
+        children: data
+      }]
     }
     }
   })
   })
 }
 }

+ 2 - 2
src/store/getters.js

@@ -13,8 +13,8 @@ const getters = {
   tenantName (state) {
   tenantName (state) {
     return state.user.tenantName
     return state.user.tenantName
   },
   },
-  org (state) {
-    return state.user.orgKey
+  org (state, getters) {
+    return getters.isTenantAdmin ? getters.tenant : state.user.orgKey
   },
   },
   userId (state) {
   userId (state) {
     return state.user.id
     return state.user.id

+ 3 - 3
src/views/dashboard/Dashboard.vue

@@ -155,7 +155,7 @@ export default {
     }
     }
   },
   },
   computed: {
   computed: {
-    ...mapGetters(['tenant', 'org', 'isTopGroup'])
+    ...mapGetters(['tenant', 'org'])
   },
   },
   created () {
   created () {
     this.$timer = -1
     this.$timer = -1
@@ -165,7 +165,7 @@ export default {
       '+/+/calendar/update'
       '+/+/calendar/update'
     ], this.onMessage)
     ], this.onMessage)
     this.getDepartmentTree()
     this.getDepartmentTree()
-    this.group = { path: this.org, name: '我的设备' }
+    this.group = { path: this.org, name: '我的部门' }
     this.refreshDevices(true)
     this.refreshDevices(true)
   },
   },
   beforeDestroy () {
   beforeDestroy () {
@@ -196,7 +196,7 @@ export default {
     },
     },
     onGroupChanged ({ path, name }) {
     onGroupChanged ({ path, name }) {
       if (this.group.path !== path) {
       if (this.group.path !== path) {
-        this.group = { path, name: path === this.org ? '我的设备' : name }
+        this.group = { path, name }
         this.refreshDevices(true)
         this.refreshDevices(true)
         this.drawer = false
         this.drawer = false
       }
       }