From 37de2f4b0f732ca5c19582d4a340ad7c987925b5 Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期三, 05 十一月 2025 22:40:47 +0800
Subject: [PATCH] feat: 部门管理多个车辆

---
 app/store/modules/user.js |   29 ++++++++++++++++++++++++++++-
 1 files changed, 28 insertions(+), 1 deletions(-)

diff --git a/app/store/modules/user.js b/app/store/modules/user.js
index 9e25e89..66b252d 100644
--- a/app/store/modules/user.js
+++ b/app/store/modules/user.js
@@ -12,12 +12,14 @@
     token: getToken(),
     userId: storage.get(constant.userId),
     name: storage.get(constant.name),
+    nickName: storage.get(constant.nickName),
     avatar: storage.get(constant.avatar),
     roles: storage.get(constant.roles),
     permissions: storage.get(constant.permissions),
     deptId: storage.get(constant.deptId),
     branchCompanyId: storage.get(constant.branchCompanyId),
-    branchCompanyName: storage.get(constant.branchCompanyName)
+    branchCompanyName: storage.get(constant.branchCompanyName),
+    oaUserId: storage.get(constant.oaUserId)
   },
 
   mutations: {
@@ -31,6 +33,10 @@
     SET_NAME: (state, name) => {
       state.name = name
       storage.set(constant.name, name)
+    },
+    SET_NICK_NAME: (state, nickName) => {
+      state.nickName = nickName
+      storage.set(constant.nickName, nickName)
     },
     SET_AVATAR: (state, avatar) => {
       state.avatar = avatar
@@ -55,6 +61,10 @@
     SET_BRANCH_COMPANY_NAME: (state, branchCompanyName) => {
       state.branchCompanyName = branchCompanyName
       storage.set(constant.branchCompanyName, branchCompanyName)
+    },
+    SET_OA_USER_ID: (state, oaUserId) => {
+      state.oaUserId = oaUserId
+      storage.set(constant.oaUserId, oaUserId)
     }
   },
 
@@ -96,6 +106,7 @@
           const user = res.user
           const avatar = (user == null || user.avatar == "" || user.avatar == null) ? require("@/static/images/profile.jpg") : baseUrl + user.avatar
           const username = (user == null || user.userName == "" || user.userName == null) ? "" : user.userName
+          const nickname = (user == null || user.nickName == "" || user.nickName == null) ? username : user.nickName
           const userId = (user == null || user.userId == null) ? null : user.userId
           const deptId = (user == null || user.deptId == null) ? null : user.deptId
           
@@ -107,10 +118,12 @@
           }
           commit('SET_USER_ID', userId)
           commit('SET_NAME', username)
+          commit('SET_NICK_NAME', nickname)
           commit('SET_AVATAR', avatar)
           commit('SET_DEPT_ID', deptId)
           commit('SET_BRANCH_COMPANY_ID', res.branchCompanyId)
           commit('SET_BRANCH_COMPANY_NAME', res.branchCompanyName)
+          commit('SET_OA_USER_ID', res.oaUserId)
           resolve(res)
         }).catch(error => {
           reject(error)
@@ -127,8 +140,22 @@
           commit('SET_PERMISSIONS', [])
           removeToken()
           storage.clean()
+          
+          // 瑙﹀彂鍏ㄥ眬浜嬩欢锛岄�氱煡 App.vue 鍋滄杞
+          uni.$emit('user-logout')
+          
           resolve()
         }).catch(error => {
+          // 鍗充娇閫�鍑烘帴鍙eけ璐ワ紝涔熻娓呯┖鏈湴鐘舵��
+          commit('SET_TOKEN', '')
+          commit('SET_ROLES', [])
+          commit('SET_PERMISSIONS', [])
+          removeToken()
+          storage.clean()
+          
+          // 瑙﹀彂鍏ㄥ眬浜嬩欢
+          uni.$emit('user-logout')
+          
           reject(error)
         })
       })

--
Gitblit v1.9.1