Browse Source

对于部门变化,用户页面未刷新增加提示与强制刷新

cyy 1 year ago
parent
commit
62198b4a4e
1 changed files with 34 additions and 8 deletions
  1. 34 8
      src/layout/header-aside/components/header-user/index.vue

+ 34 - 8
src/layout/header-aside/components/header-user/index.vue

@@ -130,6 +130,8 @@ import setting from '@/setting.js'
 import ChangePassword from '@/views/platform/org/employee/change-password'
 import ChangePassword from '@/views/platform/org/employee/change-password'
 import UserInfo from '@/views/platform/org/employee/edit'
 import UserInfo from '@/views/platform/org/employee/edit'
 import request from '@/utils/request'
 import request from '@/utils/request'
+import { getUserInfo } from '@/api/oauth2/user'
+
 
 
 export default {
 export default {
     components: {
     components: {
@@ -149,6 +151,7 @@ export default {
             locationName,
             locationName,
             roleName,
             roleName,
             positions: userInfo.positions || [],
             positions: userInfo.positions || [],
+            users: userInfo.user || [],
             mainPosition,
             mainPosition,
             tenants: this.$store.getters.tenants,
             tenants: this.$store.getters.tenants,
             tenantid: this.$store.getters.tenantid,
             tenantid: this.$store.getters.tenantid,
@@ -256,14 +259,37 @@ export default {
             this.$router.replace('/tenantSelect')
             this.$router.replace('/tenantSelect')
         },
         },
         handleMainChange (item) {
         handleMainChange (item) {
-            if (this.$utils.isEmpty(this.mainPosition)) {
-                this.setMainPosition(item.id)
-                return
-            }
-            if (this.mainPosition && this.mainPosition.id === item.id) {
-                return
-            }
-            this.updateMainPosition(this.mainPosition.id, item.id)
+            console.log(this.positions,this.users.account)
+            getUserInfo(this.users.account).then(async response => {
+                if (!response) {
+                    reject(response)
+                }
+                const info = response.data
+                info.positions.sort((a, b) => a.id - b.id)
+                this.positions.sort((a, b) => a.id - b.id)
+                if(info.positions.length!==this.positions.length){
+                    this.$message.warning('部门信息更新,请在刷新后重新选择!')
+                    location.reload()
+                    return
+                }else{
+                    info.positions.forEach((element,i) => {
+                        if(element.id!==this.positions[i].id || element.isMainPost!==this.positions[i].isMainPost){
+                            this.$message.warning('部门信息更新,请在刷新后重新选择!')
+                            location.reload()
+                            return
+                        }
+                    });
+                }
+                if (this.$utils.isEmpty(this.mainPosition)) {
+                    this.setMainPosition(item.id)
+                    return
+                }
+                if (this.mainPosition && this.mainPosition.id === item.id) {
+                    return
+                }
+                this.updateMainPosition(this.mainPosition.id, item.id)
+            })
+            
         },
         },
         setMainPosition (mid) {
         setMainPosition (mid) {
             let sql = `select * from ibps_party_rel where biz_ = 'mainPost' and SUB_PID_ = '${this.userId}'`
             let sql = `select * from ibps_party_rel where biz_ = 'mainPost' and SUB_PID_ = '${this.userId}'`