From 72a1659037d76de823457dad0c73210b0b3a9a64 Mon Sep 17 00:00:00 2001 From: hrx <18603305412@163.com> Date: Wed, 19 Nov 2025 16:10:12 +0800 Subject: [PATCH] updata --- f/web-kboss/src/store/modules/user.js | 69 ++++++---- .../customerInformationList/index.vue | 127 ++++++++++-------- 2 files changed, 113 insertions(+), 83 deletions(-) diff --git a/f/web-kboss/src/store/modules/user.js b/f/web-kboss/src/store/modules/user.js index 7cf77e2..c80c0b0 100644 --- a/f/web-kboss/src/store/modules/user.js +++ b/f/web-kboss/src/store/modules/user.js @@ -7,6 +7,12 @@ import store from "@/store"; import {myBalanceAPI} from "@/api/finance/customerRechargeManagement"; import {testData} from "@/views/homePage/components/topBox/testData"; +// 安全转换为字符串的辅助函数 +const safeToString = (value, defaultValue = '') => { + if (value == null) return defaultValue; + return value.toString(); +}; + // 从sessionStorage恢复状态 const getStoredState = () => { return { @@ -75,9 +81,18 @@ const mutations = { state.userType = userType; sessionStorage.setItem("userType", userType); }, - // 新增:设置组织类型 + // 修复:设置组织类型 - 添加防御性检查 SET_ORG_TYPE: (state, orgType) => { state.orgType = orgType; + + // 防御性检查,确保 orgType 不为 null 或 undefined + if (orgType == null) { + console.warn('SET_ORG_TYPE: orgType is null or undefined, setting to empty string'); + sessionStorage.setItem("orgType", ''); + return; + } + + // 安全地调用 toString() sessionStorage.setItem("orgType", orgType.toString()); }, // 新增:设置用户角色 @@ -120,7 +135,8 @@ const actions = { const userRoles = org_type == 2 ? ['客户'] : ['管理员']; commit("SET_USER_TYPE", userType); - commit("SET_ORG_TYPE", org_type); + // 确保 org_type 不为 undefined + commit("SET_ORG_TYPE", org_type || ''); commit("SET_ROLES", userRoles); // 新增:设置用户角色 console.log("登录用户类型:", userType, "org_type:", org_type, "用户角色:", userRoles); @@ -171,7 +187,9 @@ const actions = { commit("SET_USER_TYPE", userType); } if (orgType) { - commit("SET_ORG_TYPE", parseInt(orgType)); + // 确保 orgType 不为 null 或 undefined + const safeOrgType = orgType ? parseInt(orgType) : ''; + commit("SET_ORG_TYPE", safeOrgType); } if (roles) { commit("SET_ROLES", JSON.parse(roles)); @@ -190,34 +208,28 @@ const actions = { // user logout logout({commit, state, dispatch}) { return new Promise((resolve, reject) => { - // logout(state.token) - // .then(() => { - commit("SET_TOKEN", ""); - commit("SET_ROLES", []); - commit("SET_USER_TYPE", ""); // 新增:清除用户类型 - commit("SET_ORG_TYPE", ""); // 新增:清除组织类型 - commit("SET_USER", ""); - commit("SET_AUTHS", []); - removeToken(); - resetRouter(); + commit("SET_TOKEN", ""); + commit("SET_ROLES", []); + commit("SET_USER_TYPE", ""); // 新增:清除用户类型 + commit("SET_ORG_TYPE", ""); // 新增:清除组织类型 + commit("SET_USER", ""); + commit("SET_AUTHS", []); + removeToken(); + resetRouter(); - // 清除sessionStorage - sessionStorage.removeItem('user'); - sessionStorage.removeItem('auths'); - sessionStorage.removeItem('userType'); - sessionStorage.removeItem('orgType'); - sessionStorage.removeItem('mybalance'); - sessionStorage.removeItem('roles'); // 新增:清除角色信息 + // 清除sessionStorage + sessionStorage.removeItem('user'); + sessionStorage.removeItem('auths'); + sessionStorage.removeItem('userType'); + sessionStorage.removeItem('orgType'); + sessionStorage.removeItem('mybalance'); + sessionStorage.removeItem('roles'); // 新增:清除角色信息 - // reset visited views and cached views - // to fixed https://github.com/PanJiaChen/vue-element-admin/issues/2485 - dispatch("tagsView/delAllViews", null, {root: true}); + // reset visited views and cached views + // to fixed https://github.com/PanJiaChen/vue-element-admin/issues/2485 + dispatch("tagsView/delAllViews", null, {root: true}); - resolve(); - // }) - // .catch((error) => { - // reject(error); - // }); + resolve(); }); }, @@ -272,3 +284,4 @@ export default { mutations, actions, }; + \ No newline at end of file diff --git a/f/web-kboss/src/views/sales/customerManagement/customerInformationList/index.vue b/f/web-kboss/src/views/sales/customerManagement/customerInformationList/index.vue index 512b270..939e66d 100644 --- a/f/web-kboss/src/views/sales/customerManagement/customerInformationList/index.vue +++ b/f/web-kboss/src/views/sales/customerManagement/customerInformationList/index.vue @@ -14,57 +14,57 @@ -