From 5dac25e97563d1a764383b615849a82efd342cb4 Mon Sep 17 00:00:00 2001
From: chenyc <501753378@qq.com>
Date: 星期二, 24 十二月 2024 11:26:17 +0800
Subject: [PATCH] gx

---
 src/stores/userInfo.ts                |    7 ++++++-
 src/layout/navBars/topBar/user.vue    |    9 +++++++--
 src/views/login/component/account.vue |   24 +++++++++++++-----------
 3 files changed, 26 insertions(+), 14 deletions(-)

diff --git a/src/layout/navBars/topBar/user.vue b/src/layout/navBars/topBar/user.vue
index ada91a1..401bdc7 100644
--- a/src/layout/navBars/topBar/user.vue
+++ b/src/layout/navBars/topBar/user.vue
@@ -6,7 +6,7 @@
 
 			</div>
 			<template #dropdown>
-				<el-dropdown-menu>
+				<el-dropdown-menu :style="{ maxHeight: '600px', overflow: 'auto' }" class="scrollable-menu">
 					<el-dropdown-item v-for="(client,key) in userInfos.clientInfos" :key="key" @click="clientSet(client)" >
 						<span :style="{color:userInfos.clientName===client.clientName?'#409EFF':''}">
 							{{client.clientName}}
@@ -232,6 +232,8 @@
 };
 const clientSet=(client:any)=>{
 	useUserInfo().setUserCilent({code:client.code,clientName:client.clientName});
+	// 缓存客户选择
+	Local.set('client_'+client.code,client.code)
 	confirmClient('clientCode='+client.code).then((res)=>{
 		// 更新token
 		Session.set('token', res.data);
@@ -247,8 +249,11 @@
 });
 
 </script>
-
 <style scoped lang="scss">
+.scrollable-menu {
+  max-height: 600px;
+  overflow: auto;
+}
 .layout-navbars-breadcrumb-user {
 	display: flex;
 	align-items: center;
diff --git a/src/stores/userInfo.ts b/src/stores/userInfo.ts
index 869bfde..b6878b6 100644
--- a/src/stores/userInfo.ts
+++ b/src/stores/userInfo.ts
@@ -47,6 +47,7 @@
 					const userCode = userRet.code
 					// 模拟数据
 					let defaultRoles: Array<string> = [];
+					let defClients:Array<object>=[];
 					let defaultAuthBtnList: Array<string> = [];
 					// admin 页面权限标识,对应路由 meta.roles,用于控制路由的显示/隐藏
 					let adminRoles: Array<string> = ['admin'];
@@ -70,9 +71,13 @@
 					if (isadmin) {
 						defaultRoles = adminRoles;
 						defaultAuthBtnList = adminAuthBtnList;
+						defClients=userRet?.管理员能看到的客户列表
+
 					} else {
 						defaultRoles = testRoles;
 						defaultAuthBtnList = testAuthBtnList;
+						defClients=userRet.clientInfos
+
 					}
 					// 用户信息模拟数据
 					const userInfos = {
@@ -86,7 +91,7 @@
 						authBtnList: defaultAuthBtnList,
 						clientCode:userRet.currentClientInfo.code,
 						clientName:userRet.currentClientInfo.clientName,
-						clientInfos:userRet.clientInfos
+						clientInfos:defClients
 					};
 					console.log('-----------------2222------------------------------')
 					console.log(userInfos)
diff --git a/src/views/login/component/account.vue b/src/views/login/component/account.vue
index 38ecb11..373fe4a 100644
--- a/src/views/login/component/account.vue
+++ b/src/views/login/component/account.vue
@@ -149,17 +149,19 @@
 				) {
 
 					console.log('管理员登录');
-						var ps= new Object ({
-						page: 0,
-						size: 0,
-						wherecondition: '',
-						ordercondition: 'create_time desc'
-					})
-					getclients(ps).then(re=>{
-						state.clients = re.data.list;
-					}).finally(()=>{
-						state.loading.signIn = false;
-					})
+					state.loading.signIn = false;
+					state.clients=userinfoRes?.data?.管理员能看到的客户列表
+					// 看看有没有缓存客户选择
+					const lscode=Local.get('client_'+state.ruleForm.userName)
+
+					if(lscode){
+						const x=state.clients.findIndex((cl:any)=>{return cl.code===lscode})
+						if(x>=0){
+							// 默认选择客户项
+							state.ruleForm.clientCode=lscode
+						}
+					}
+					ElMessage.success('请选择登录客户再登录')
 					
 				} else {
 					console.log('普通登录');

--
Gitblit v1.8.0