修改页面和接口

This commit is contained in:
liuwu 2023-09-21 14:54:44 +08:00
parent 2d3434df69
commit c3b3b158f4
6 changed files with 92 additions and 19 deletions

View File

@ -140,6 +140,13 @@ public class TAmentPersonnelController extends BaseController
return toAjax(tAmentPersonnelService.insertTAmentPersonnel(tAmentPersonnel));
}
@PostMapping("/getById")
@ResponseBody
public AjaxResult getById(Long id)
{
return AjaxResult.success(tAmentPersonnelService.selectTAmentPersonnelById(id));
}
/**
* 修改人员
*/

View File

@ -149,6 +149,11 @@ public class SysUserController extends BaseController
{
return error("新增用户'" + user.getLoginName() + "'失败,邮箱账号已存在");
}
SysUser one = userService.selectUserById(user.getUserId());
if (null != one){
return error("新增用户'" + user.getUserName() + "'失败,用户名称已存在");
}
user.setBranchId(getSysUser().getBranchId());
user.setSalt(ShiroUtils.randomSalt());
user.setPassword(passwordService.encryptPassword(user.getLoginName(), user.getPassword(), user.getSalt()));
user.setCreateBy(getLoginName());
@ -166,6 +171,7 @@ public class SysUserController extends BaseController
List<SysRole> roles = roleService.selectRolesByUserId(userId);
mmap.put("user", userService.selectUserById(userId));
mmap.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
mmap.put("perList",personnelService.selectTAmentPersonnelList(new TAmentPersonnel()));
mmap.put("posts", postService.selectPostsByUserId(userId));
return prefix + "/edit";
}

View File

@ -14,8 +14,8 @@
<div class="form-group">
<label class="col-sm-4 control-label is-required">用户名称:</label>
<div class="col-sm-8">
<!-- <input name="userName" placeholder="请输入用户名称" class="form-control" type="text" maxlength="30" required>-->
<select name="userId" id="userId" class="form-control">
<input name="userName" id="userName" placeholder="请输入用户名称" class="form-control" type="hidden" maxlength="30" required>
<select name="userId" id="userId" class="form-control" required>
<option value="">请选择</option>
<option th:each="item : ${perList}" th:text="${item.name}" th:value="${item.id}"></option>
</select>
@ -24,10 +24,10 @@
</div>
<div class="col-sm-6">
<div class="form-group">
<label class="col-sm-4 control-label">归属部门:</label>
<label class="col-sm-4 control-label is-required">归属部门:</label>
<div class="col-sm-8">
<div class="input-group">
<input name="deptName" onclick="selectDeptTree()" id="treeName" type="text" placeholder="请选择归属部门" class="form-control">
<input name="deptId" onclick="selectDeptTree()" required id="treeName" type="text" placeholder="请选择归属部门" class="form-control">
<span class="input-group-addon"><i class="fa fa-search"></i></span>
</div>
</div>
@ -37,10 +37,10 @@
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label class="col-sm-4 control-label">手机号码:</label>
<label class="col-sm-4 control-label is-required">手机号码:</label>
<div class="col-sm-8">
<div class="input-group">
<input id="phonenumber" name="phonenumber" placeholder="请输入手机号码" class="form-control" type="text" maxlength="11">
<input id="phonenumber" name="phonenumber" placeholder="请输入手机号码" required class="form-control" type="text" maxlength="11">
<span class="input-group-addon"><i class="fa fa-mobile"></i></span>
</div>
</div>
@ -72,7 +72,7 @@
<label class="col-sm-4 control-label is-required">登录密码:</label>
<div class="col-sm-8">
<div class="input-group">
<input id="password" name="password" placeholder="请输入登录密码" class="form-control" type="password" th:value="${@config.getKey('sys.user.initPassword')}" required>
<input id="password" autocomplete="off" name="password" placeholder="请输入登录密码" class="form-control" type="password" required>
<span class="input-group-addon" title="登录密码,鼠标按下显示密码"
onmousedown="$('#password').attr('type','text')"
onmouseup="$('#password').attr('type','password')"><i class="fa fa-key"></i></span>
@ -84,11 +84,15 @@
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<label class="col-sm-4 control-label">用户性别:</label>
<label class="col-sm-4 control-label is-required">用户性别:</label>
<div class="col-sm-8">
<select name="sex" class="form-control m-b" th:with="type=${@dict.getType('sys_user_sex')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
<select required name="sex" id="sex" class="form-control ">
<option value="1"></option>
<option value="2"></option>
</select>
<!-- <select name="sex" id="sex" required class="form-control m-b" th:with="type=${@dict.getType('sys_user_sex')}">-->
<!-- <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>-->
<!-- </select>-->
</div>
</div>
</div>
@ -153,6 +157,23 @@
<script>
var prefix = ctx + "system/user";
$("#userId").on("change", function() {
var data = $(this).val();
$.ajax({
type: "post",
url: ctx + "base/personnel/getById?id="+data,
data: {
},
success: function(res) {
$("#phonenumber").val(res.data.mphone);
$("#treeName").val(res.data.deptName);
$("#email").val(res.data.email);
$("#userName").val(res.data.name);
$('#sex').select2("val",res.data.sex)
}
});
})
$("#form-user-add").validate({
onkeyup: false,
rules:{

View File

@ -15,7 +15,12 @@
<div class="form-group">
<label class="col-sm-4 control-label is-required">用户名称:</label>
<div class="col-sm-8">
<input name="userName" placeholder="请输入用户名称" class="form-control" type="text" maxlength="30" th:field="*{userName}" required>
<input name="userName" id="userName" placeholder="请输入用户名称" class="form-control" type="hidden" maxlength="30" required>
<select name="userId" readonly="true" disabled id="userId" th:field="*{userId}" class="form-control" required>
<option value="">请选择</option>
<option th:each="item : ${perList}" th:text="${item.name}" th:value="${item.id}"></option>
</select>
<!-- <input name="userName" placeholder="请输入用户名称" class="form-control" type="text" maxlength="30" th:field="*{userName}" required>-->
</div>
</div>
</div>
@ -91,9 +96,13 @@
<div class="form-group">
<label class="col-sm-4 control-label">用户性别:</label>
<div class="col-sm-8">
<select name="sex" class="form-control m-b" th:with="type=${@dict.getType('sys_user_sex')}">
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{sex}"></option>
</select>
<select required name="sex" id="sex" th:field="*{sex}" class="form-control ">
<option value="1"></option>
<option value="2"></option>
</select>
<!-- <select name="sex" class="form-control m-b" th:with="type=${@dict.getType('sys_user_sex')}">-->
<!-- <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{sex}"></option>-->
<!-- </select>-->
</div>
</div>
</div>
@ -134,6 +143,24 @@
<script type="text/javascript">
var prefix = ctx + "system/user";
// function userChange(obj){
// var data = $(obj).val();
// $.ajax({
// type: "post",
// url: ctx + "base/personnel/getById?id="+data,
// data: {
// },
// success: function(res) {
// console.log(res)
// $("#phonenumber").val(res.data.mphone);
// $("#treeName").val(res.data.deptName);
// $("#email").val(res.data.email);
// $("#userName").val(res.data.name);
// $('#sex').select2("val",res.data.sex)
// }
// });
// }
$("#form-user-edit").validate({
onkeyup: false,
rules:{

View File

@ -29,6 +29,15 @@ public class SysUser extends BaseEntity
/** 部门ID */
@Excel(name = "部门编号", type = Type.IMPORT)
private Long deptId;
private Long branchId;
public Long getBranchId() {
return branchId;
}
public void setBranchId(Long branchId) {
this.branchId = branchId;
}
/** 部门父ID */
private Long parentId;

View File

@ -7,6 +7,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="SysUser" id="SysUserResult">
<id property="userId" column="user_id" />
<result property="deptId" column="dept_id" />
<result property="branchId" column="branch_id" />
<result property="loginName" column="login_name" />
<result property="userName" column="user_name" />
<result property="userType" column="user_type" />
@ -50,7 +51,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectUserVo">
select u.user_id, u.dept_id, u.login_name, u.user_name, u.user_type, u.email, u.avatar, u.phonenumber, u.sex, u.password, u.salt, u.status, u.del_flag, u.login_ip, u.login_date, u.pwd_update_date, u.create_time, u.remark,
select u.user_id, u.dept_id, u.branch_id, u.login_name, u.user_name, u.user_type, u.email, u.avatar, u.phonenumber, u.sex, u.password, u.salt, u.status, u.del_flag, u.login_ip, u.login_date, u.pwd_update_date, u.create_time, u.remark,
d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status,
r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status
from sys_user u
@ -60,7 +61,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</sql>
<select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult">
select u.user_id, u.dept_id, u.login_name, u.user_name, u.user_type, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.salt, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader from sys_user u
select u.user_id, u.dept_id, u.branch_id, u.login_name, u.user_name, u.user_type, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.salt, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader from sys_user u
left join sys_dept d on u.dept_id = d.dept_id
where u.del_flag = '0'
<if test="userId != null and userId != 0">
@ -89,7 +90,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectAllocatedList" parameterType="SysUser" resultMap="SysUserResult">
select distinct u.user_id, u.dept_id, u.login_name, u.user_name, u.user_type, u.email, u.avatar, u.phonenumber, u.status, u.create_time
select distinct u.user_id, u.dept_id, u.branch_id, u.login_name, u.user_name, u.user_type, u.email, u.avatar, u.phonenumber, u.status, u.create_time
from sys_user u
left join sys_dept d on u.dept_id = d.dept_id
left join sys_user_role ur on u.user_id = ur.user_id
@ -106,7 +107,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectUnallocatedList" parameterType="SysUser" resultMap="SysUserResult">
select distinct u.user_id, u.dept_id, u.login_name, u.user_name, u.user_type, u.email, u.avatar, u.phonenumber, u.status, u.create_time
select distinct u.user_id, u.dept_id, u.branch_id, u.login_name, u.user_name, u.user_type, u.email, u.avatar, u.phonenumber, u.status, u.create_time
from sys_user u
left join sys_dept d on u.dept_id = d.dept_id
left join sys_user_role ur on u.user_id = ur.user_id
@ -194,6 +195,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
insert into sys_user(
<if test="userId != null and userId != 0">user_id,</if>
<if test="deptId != null and deptId != 0">dept_id,</if>
<if test="branchId != null and branchId != 0">branch_id,</if>
<if test="loginName != null and loginName != ''">login_name,</if>
<if test="userName != null and userName != ''">user_name,</if>
<if test="userType != null and userType != ''">user_type,</if>
@ -211,6 +213,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
)values(
<if test="userId != null and userId != ''">#{userId},</if>
<if test="deptId != null and deptId != ''">#{deptId},</if>
<if test="branchId != null and branchId != ''">#{branchId},</if>
<if test="loginName != null and loginName != ''">#{loginName},</if>
<if test="userName != null and userName != ''">#{userName},</if>
<if test="userType != null and userType != ''">#{userType},</if>