From edbec20d20b0103ab9ddb342a995781d3fd6f6fb Mon Sep 17 00:00:00 2001 From: zhangrenyuan <18990852002@163.com> Date: Wed, 5 Nov 2025 09:58:57 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=88=20perf:=20=E6=8A=8A=E5=91=98?= =?UTF-8?q?=E5=B7=A5=E6=95=B0=E6=8D=AE=E7=9A=84=E6=8C=89=E9=92=AE=E9=9B=86?= =?UTF-8?q?=E6=88=90=E5=88=B0=E8=AE=BE=E7=BD=AE=E9=87=8C=EF=BC=8C=E7=9B=AE?= =?UTF-8?q?=E5=89=8D=E5=B7=B2=E5=AE=8C=E6=88=90=E5=AE=A2=E6=88=B7=E8=B4=A6?= =?UTF-8?q?=E6=88=B7=E6=98=8E=E7=BB=86=E7=9A=84=E6=9B=BF=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/index.js | 14 ++++++++++++ src/views/home.vue | 13 ++++++++++- src/views/usergold/gold/clientCountDetail.vue | 32 ++++++++++++++++++++------- 3 files changed, 50 insertions(+), 9 deletions(-) diff --git a/src/store/index.js b/src/store/index.js index de91a35..cab0bfe 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -6,6 +6,7 @@ export const useAdminStore = defineStore('admin', { adminData: null, // 用户信息 menuTree: [], // 菜单权限树 marketList: {}, // 市场列表 + flag: 0, //员工数据开关状态,0=不包含员工数据,1=包含员工数据 }), actions: { // 设置用户信息并同步到localStorage @@ -24,11 +25,18 @@ export const useAdminStore = defineStore('admin', { localStorage.setItem('marketList', JSON.stringify(list)) }, + // 设置员工数据开关状态(使用数字0和1) + setFlag(flag) { + this.flag = flag + localStorage.setItem('flag', JSON.stringify(flag)) + }, + // 从localStorage初始化数据 initFromLocalStorage() { const adminData = localStorage.getItem('adminData') const menuTree = localStorage.getItem('menuTree') const marketList = localStorage.getItem('marketList') + const flag = localStorage.getItem('flag') if (adminData) { this.adminData = JSON.parse(adminData) @@ -41,6 +49,10 @@ export const useAdminStore = defineStore('admin', { if (marketList) { this.marketList = JSON.parse(marketList) } + + if (flag) { + this.flag = JSON.parse(flag) + } }, // 清空状态并移除localStorage数据 @@ -48,9 +60,11 @@ export const useAdminStore = defineStore('admin', { this.adminData = null this.menuTree = [] this.marketList = {} + this.flag = 0 localStorage.removeItem('adminData') localStorage.removeItem('menuTree') localStorage.removeItem('marketList') + localStorage.removeItem('flag') // localStorage.removeItem('token') } } diff --git a/src/views/home.vue b/src/views/home.vue index b692dfe..5910196 100644 --- a/src/views/home.vue +++ b/src/views/home.vue @@ -79,7 +79,7 @@ const menuList = ref([]) // 获取仓库实例 const adminStore = useAdminStore() // 解构状态(保持响应式) 获得 adminData(用户信息) 和 menuTree(菜单树) -const { adminData, menuTree } = storeToRefs(adminStore) +const { adminData, menuTree, flag } = storeToRefs(adminStore) // 筛选权限菜单 ,menuTree 是组件通信拿的 menuList.value = filterMenu(menuTree.value) @@ -156,6 +156,13 @@ function logout() { ElMessage.success('退出成功') } +// 切换员工数据开关状态 +const toggleFlag = () => { + const newFlag = flag.value === 1 ? 0 : 1 + adminStore.setFlag(newFlag) + ElMessage.success(newFlag === 1 ? '员工数据已隐藏' : '员工数据已显示') + console.log('flag',newFlag) +} @@ -243,6 +250,10 @@ function logout() {