gx
chenyc
2024-12-24 5dac25e97563d1a764383b615849a82efd342cb4
gx
3个文件已修改
40 ■■■■■ 已修改文件
src/layout/navBars/topBar/user.vue 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/stores/userInfo.ts 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/login/component/account.vue 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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;
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)
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('普通登录');