mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-20 18:15:56 +08:00
update 优化 更改登陆页面选择租户形式
This commit is contained in:
parent
16c8f65909
commit
86f6ce717c
@ -1,19 +1,24 @@
|
||||
package com.ruoyi.web.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.domain.model.LoginBody;
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.core.domain.model.SmsLoginBody;
|
||||
import com.ruoyi.common.satoken.utils.LoginHelper;
|
||||
import com.ruoyi.system.domain.SysMenu;
|
||||
import com.ruoyi.system.domain.bo.SysTenantBo;
|
||||
import com.ruoyi.system.domain.vo.RouterVo;
|
||||
import com.ruoyi.system.domain.vo.SysTenantVo;
|
||||
import com.ruoyi.system.domain.vo.SysUserVo;
|
||||
import com.ruoyi.system.service.ISysMenuService;
|
||||
import com.ruoyi.system.service.ISysTenantService;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
import com.ruoyi.web.service.SysLoginService;
|
||||
import com.ruoyi.web.domain.vo.LoginVo;
|
||||
import com.ruoyi.web.domain.vo.TenantListVo;
|
||||
import com.ruoyi.web.domain.vo.UserInfoVo;
|
||||
import com.ruoyi.web.service.SysLoginService;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -37,6 +42,7 @@ public class SysLoginController {
|
||||
private final SysLoginService loginService;
|
||||
private final ISysMenuService menuService;
|
||||
private final ISysUserService userService;
|
||||
private final ISysTenantService tenantService;
|
||||
|
||||
/**
|
||||
* 登录方法
|
||||
@ -99,6 +105,19 @@ public class SysLoginController {
|
||||
return R.ok("退出成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录页面租户下拉框
|
||||
*
|
||||
* @return 租户列表
|
||||
*/
|
||||
@SaIgnore
|
||||
@GetMapping("/tenant/list")
|
||||
public R<List<TenantListVo>> tenantList() {
|
||||
List<SysTenantVo> tenantList = tenantService.queryList(new SysTenantBo());
|
||||
List<TenantListVo> voList = BeanUtil.copyToList(tenantList, TenantListVo.class);
|
||||
return R.ok(voList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
*
|
||||
|
||||
@ -0,0 +1,17 @@
|
||||
package com.ruoyi.web.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 租户列表
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Data
|
||||
public class TenantListVo {
|
||||
|
||||
private String tenantId;
|
||||
|
||||
private String companyName;
|
||||
|
||||
}
|
||||
@ -1,7 +1,6 @@
|
||||
package com.ruoyi.system.controller.system;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import com.baomidou.lock.annotation.Lock4j;
|
||||
import com.ruoyi.common.core.constant.UserConstants;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
@ -52,15 +51,6 @@ public class SysTenantController extends BaseController {
|
||||
return sysTenantService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据关键字查询租户列表
|
||||
*/
|
||||
@SaIgnore
|
||||
@GetMapping("/listByWord/{keyword}")
|
||||
public R<List<SysTenantVo>> listByWord(@PathVariable String keyword) {
|
||||
return R.ok(sysTenantService.listByWord(keyword));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出租户列表
|
||||
*/
|
||||
|
||||
@ -30,11 +30,6 @@ public interface ISysTenantService {
|
||||
*/
|
||||
TableDataInfo<SysTenantVo> queryPageList(SysTenantBo bo, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 根据关键字查询租户列表
|
||||
*/
|
||||
List<SysTenantVo> listByWord(String keyword);
|
||||
|
||||
/**
|
||||
* 查询租户列表
|
||||
*/
|
||||
|
||||
@ -77,17 +77,6 @@ public class SysTenantServiceImpl implements ISysTenantService {
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据关键字查询租户列表
|
||||
*/
|
||||
@Override
|
||||
public List<SysTenantVo> listByWord(String keyword) {
|
||||
SysTenantBo bo = new SysTenantBo();
|
||||
bo.setCompanyName(keyword);
|
||||
LambdaQueryWrapper<SysTenant> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<SysTenant> buildQueryWrapper(SysTenantBo bo) {
|
||||
LambdaQueryWrapper<SysTenant> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getTenantId()), SysTenant::getTenantId, bo.getTenantId());
|
||||
|
||||
@ -70,3 +70,14 @@ export function getCodeSms() {
|
||||
timeout: 20000
|
||||
})
|
||||
}
|
||||
|
||||
// 获取租户列表
|
||||
export function tenantList() {
|
||||
return request({
|
||||
url: '/tenant/list',
|
||||
headers: {
|
||||
isToken: false
|
||||
},
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
@ -56,10 +56,3 @@ export function delTenant(id) {
|
||||
})
|
||||
}
|
||||
|
||||
// 根据关键字获取相关企业名称
|
||||
export function listByWord(data) {
|
||||
return request({
|
||||
url: '/system/tenant/listByWord/' + data,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
@ -3,33 +3,15 @@
|
||||
<el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form">
|
||||
<h3 class="title">RuoYi-Vue-Plus后台管理系统</h3>
|
||||
<el-form-item prop="tenantId">
|
||||
<el-input
|
||||
v-model="loginForm.tenantId"
|
||||
type="text"
|
||||
auto-complete="off"
|
||||
placeholder="租户编号"
|
||||
>
|
||||
<svg-icon slot="prefix" icon-class="input" class="el-input__icon input-icon" />
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
<el-form-item prop="companyName">
|
||||
<el-select v-if="loginForm.tenantId"
|
||||
v-model="loginForm.companyName"
|
||||
filterable
|
||||
remote
|
||||
reserve-keyword
|
||||
placeholder="请输入公司名称"
|
||||
:remote-method="remoteMethod"
|
||||
:loading="selectLoading" style="width: 100%">
|
||||
<el-select v-model="loginForm.tenantId" filterable placeholder="请选择/输入公司名称" style="width: 100%">
|
||||
<el-option
|
||||
v-for="item in companyList"
|
||||
:key="item.id"
|
||||
v-for="item in tenantList"
|
||||
:key="item.tenantId"
|
||||
:label="item.companyName"
|
||||
:value="item.tenantId">
|
||||
</el-option>
|
||||
<svg-icon slot="prefix" icon-class="input" class="el-input__icon input-icon" />
|
||||
</el-select>
|
||||
<span v-else>{{loginForm.companyName}}</span>
|
||||
</el-form-item>
|
||||
<el-form-item prop="username">
|
||||
<el-input
|
||||
@ -91,10 +73,9 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getCodeImg } from "@/api/login";
|
||||
import { getCodeImg, tenantList } from "@/api/login";
|
||||
import Cookies from "js-cookie";
|
||||
import { encrypt, decrypt } from '@/utils/jsencrypt'
|
||||
import { listByWord } from "@/api/system/tenant";
|
||||
|
||||
export default {
|
||||
name: "Login",
|
||||
@ -127,8 +108,8 @@ export default {
|
||||
// 注册开关
|
||||
register: false,
|
||||
redirect: undefined,
|
||||
selectLoading:false,
|
||||
companyList:[]
|
||||
// 租户列表
|
||||
tenantList:[]
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
@ -141,6 +122,7 @@ export default {
|
||||
},
|
||||
created() {
|
||||
this.getCode();
|
||||
this.getTenantList();
|
||||
this.getCookie();
|
||||
},
|
||||
methods: {
|
||||
@ -153,23 +135,10 @@ export default {
|
||||
}
|
||||
});
|
||||
},
|
||||
getListByWord(word) {
|
||||
listByWord(word).then(res => {
|
||||
this.selectLoading = false;
|
||||
this.companyList = res.data
|
||||
})
|
||||
},
|
||||
// 搜索公司
|
||||
remoteMethod(query) {
|
||||
if (query !== '') {
|
||||
this.selectLoading = true;
|
||||
setTimeout(() => {
|
||||
this.selectLoading = false;
|
||||
this.getListByWord(query)
|
||||
}, 200);
|
||||
} else {
|
||||
this.companyList = [];
|
||||
}
|
||||
getTenantList() {
|
||||
tenantList().then(res => {
|
||||
this.tenantList = res.data;
|
||||
});
|
||||
},
|
||||
getCookie() {
|
||||
const tenantId = Cookies.get("tenantId");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user