完成添加、修改用户开发
This commit is contained in:
parent
1356a2a7ba
commit
3a95dc7463
|
|
@ -1,5 +1,6 @@
|
||||||
package com.ruoyi.dfm.controller;
|
package com.ruoyi.dfm.controller;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.common.core.page.PageDomain;
|
import com.ruoyi.common.core.page.PageDomain;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.core.page.TableSupport;
|
import com.ruoyi.common.core.page.TableSupport;
|
||||||
|
|
@ -17,6 +18,8 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.ModelMap;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
@ -24,6 +27,7 @@ import org.springframework.web.servlet.ModelAndView;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
@RequestMapping("/user.do")
|
@RequestMapping("/user.do")
|
||||||
|
|
@ -52,8 +56,9 @@ public class UserController extends com.ruoyi.common.core.controller.BaseControl
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/addSave")
|
@RequestMapping("/addSave")
|
||||||
public ModelAndView addSave(HttpServletRequest req,
|
@ResponseBody
|
||||||
HttpServletResponse res) throws Exception {
|
public AjaxResult addSave(HttpServletRequest req,
|
||||||
|
HttpServletResponse res) throws Exception {
|
||||||
String name = req.getParameter("name");
|
String name = req.getParameter("name");
|
||||||
String username = req.getParameter("username");
|
String username = req.getParameter("username");
|
||||||
String pwd = req.getParameter("password");
|
String pwd = req.getParameter("password");
|
||||||
|
|
@ -71,10 +76,10 @@ public class UserController extends com.ruoyi.common.core.controller.BaseControl
|
||||||
user.setCcEmail(ccEmail);
|
user.setCcEmail(ccEmail);
|
||||||
user.setPassword(Md5Util.md5(pwd));
|
user.setPassword(Md5Util.md5(pwd));
|
||||||
int groupId = UserConstants.USER_LEVEL_NORMAL;
|
int groupId = UserConstants.USER_LEVEL_NORMAL;
|
||||||
if(StringUtils.isNotBlank(isAdmin) && "1".equals(isAdmin))
|
if(StringUtils.isNotBlank(isAdmin) && "on".equals(isAdmin))
|
||||||
{
|
{
|
||||||
groupId = UserConstants.USER_LEVEL_ADMIN;
|
groupId = UserConstants.USER_LEVEL_ADMIN;
|
||||||
} else if(StringUtils.isNotBlank(isDepAdmin) && "1".equals(isDepAdmin))
|
} else if(StringUtils.isNotBlank(isDepAdmin) && "on".equals(isDepAdmin))
|
||||||
{
|
{
|
||||||
groupId = UserConstants.USER_LEVEL_DEP_ADMIN;
|
groupId = UserConstants.USER_LEVEL_DEP_ADMIN;
|
||||||
}
|
}
|
||||||
|
|
@ -86,27 +91,28 @@ public class UserController extends com.ruoyi.common.core.controller.BaseControl
|
||||||
//创建用户目录
|
//创建用户目录
|
||||||
String dir = fileService.getRootPath() + user.getUsername();
|
String dir = fileService.getRootPath() + user.getUsername();
|
||||||
fileService.createDir(dir);
|
fileService.createDir(dir);
|
||||||
outputMsg(res, "<script>alert('添加成功,点击确定跳转到用户列表!');document.location.href='user.do?method=getUserList';</script>");
|
// outputMsg(res, "<script>alert('添加成功,点击确定跳转到用户列表!');document.location.href='user.do?method=getUserList';</script>");
|
||||||
return null;
|
// return null;
|
||||||
|
//返回数据库影响行数
|
||||||
|
return toAjax(1);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("添加用户失败", e);
|
logger.error("添加用户失败", e);
|
||||||
outputMsg(res, "<script>alert('添加用户失败,请检查数据正确性,重新添加!');window.history.go(-1)';</script>");
|
return toAjax(0);
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加用户页面
|
* 添加用户页面
|
||||||
* @param req
|
|
||||||
* @param res
|
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/add")
|
@GetMapping("/add")
|
||||||
public ModelAndView add(HttpServletRequest req,
|
public String add(ModelMap mmap) {
|
||||||
HttpServletResponse res) throws Exception {
|
UserInfo loginUser = ShiroUtils.getLoginUser();
|
||||||
return new ModelAndView("dfm/addUser");
|
mmap.put("groupId", loginUser.getGroupId());
|
||||||
|
return "dfm/addUser";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -208,9 +214,9 @@ public class UserController extends com.ruoyi.common.core.controller.BaseControl
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
@RequestMapping("/getModifyUser")
|
@RequestMapping("/edit")
|
||||||
public ModelAndView getModifyUser(HttpServletRequest req,
|
public ModelAndView getModifyUser(HttpServletRequest req,
|
||||||
HttpServletResponse res) throws Exception {
|
HttpServletResponse res, ModelMap mmap) throws Exception {
|
||||||
int uid = 0 ;
|
int uid = 0 ;
|
||||||
String ustr = req.getParameter("uid");
|
String ustr = req.getParameter("uid");
|
||||||
if(ustr == null || "".equals(ustr))
|
if(ustr == null || "".equals(ustr))
|
||||||
|
|
@ -222,12 +228,14 @@ public class UserController extends com.ruoyi.common.core.controller.BaseControl
|
||||||
}
|
}
|
||||||
|
|
||||||
UserInfo user = userService.getUserById(uid);
|
UserInfo user = userService.getUserById(uid);
|
||||||
req.setAttribute("user", user);
|
mmap.put("user", user);
|
||||||
return new ModelAndView("modifyUser");
|
mmap.put("groupId", ShiroUtils.getLoginUser().getGroupId());
|
||||||
|
return new ModelAndView("dfm/editUser");
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping("/modifyUser")
|
@RequestMapping("/editSave")
|
||||||
public ModelAndView modifyUser(HttpServletRequest req,
|
@ResponseBody
|
||||||
|
public AjaxResult modifyUser(HttpServletRequest req,
|
||||||
HttpServletResponse res) throws Exception {
|
HttpServletResponse res) throws Exception {
|
||||||
String id = req.getParameter("id");
|
String id = req.getParameter("id");
|
||||||
String name = req.getParameter("name");
|
String name = req.getParameter("name");
|
||||||
|
|
@ -244,10 +252,10 @@ public class UserController extends com.ruoyi.common.core.controller.BaseControl
|
||||||
String isDepAdmin = req.getParameter("isDepAdmin");
|
String isDepAdmin = req.getParameter("isDepAdmin");
|
||||||
String isAdmin = req.getParameter("isAdmin");
|
String isAdmin = req.getParameter("isAdmin");
|
||||||
// int groupId = UserConstants.USER_LEVEL_NORMAL;
|
// int groupId = UserConstants.USER_LEVEL_NORMAL;
|
||||||
if("1".equals(isAdmin))
|
if("on".equals(isAdmin))
|
||||||
{
|
{
|
||||||
groupId = UserConstants.USER_LEVEL_ADMIN;
|
groupId = UserConstants.USER_LEVEL_ADMIN;
|
||||||
} else if("1".equals(isDepAdmin))
|
} else if("on".equals(isDepAdmin))
|
||||||
{
|
{
|
||||||
groupId = UserConstants.USER_LEVEL_DEP_ADMIN;
|
groupId = UserConstants.USER_LEVEL_DEP_ADMIN;
|
||||||
}
|
}
|
||||||
|
|
@ -266,20 +274,21 @@ public class UserController extends com.ruoyi.common.core.controller.BaseControl
|
||||||
user.setUsername(username);
|
user.setUsername(username);
|
||||||
user.setGroupId(groupId);
|
user.setGroupId(groupId);
|
||||||
userService.updateUser(user);
|
userService.updateUser(user);
|
||||||
if(UserConstants.USER_LEVEL_ADMIN == user1.getGroupId())
|
// if(UserConstants.USER_LEVEL_ADMIN == user1.getGroupId())
|
||||||
{
|
// {
|
||||||
outputMsg(res, "<script>alert('修改成功,点击确定跳转到用户列表!');document.location.href='user.do?method=getUserList';</script>");
|
// outputMsg(res, "<script>alert('修改成功,点击确定跳转到用户列表!');document.location.href='user.do?method=getUserList';</script>");
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
outputMsg(res, "<script>alert('修改成功,点击确定跳转项目提交页面!');document.location.href='project.do?method=getAddPage';</script>");
|
// outputMsg(res, "<script>alert('修改成功,点击确定跳转项目提交页面!');document.location.href='project.do?method=getAddPage';</script>");
|
||||||
}
|
// }
|
||||||
|
return toAjax(1);
|
||||||
return null;
|
// return null;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("修改用户失败", e);
|
logger.error("修改用户失败", e);
|
||||||
outputMsg(res, "<script>alert('修改用户失败,请检查数据正确性,重新添加!');window.history.go(-1)';</script>");
|
// outputMsg(res, "<script>alert('修改用户失败,请检查数据正确性,重新添加!');window.history.go(-1)';</script>");
|
||||||
return null;
|
// return null;
|
||||||
|
return toAjax(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,20 +12,17 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-4 control-label is-required">用户名称:</label>
|
<label class="col-sm-4 control-label is-required">员工姓名:</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<input name="userName" placeholder="请输入用户名称" class="form-control" type="text" maxlength="30" required>
|
<input name="name" placeholder="请输入用户姓名" class="form-control" type="text" maxlength="30" required>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-4 control-label is-required">归属部门:</label>
|
<label class="col-sm-4 control-label is-required">用户名:</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<div class="input-group">
|
<input name="username" placeholder="请输入登录用户名" class="form-control" type="text" maxlength="30" required>
|
||||||
<input name="deptName" onclick="selectDeptTree()" id="treeName" type="text" placeholder="请选择归属部门" class="form-control" required>
|
|
||||||
<span class="input-group-addon"><i class="fa fa-search"></i></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -33,18 +30,55 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-4 control-label is-required">手机号码:</label>
|
<label class="col-sm-4 control-label is-required">登录密码:</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input id="phonenumber" name="phonenumber" placeholder="请输入手机号码" class="form-control" type="text" maxlength="11" required>
|
<input id="password" name="password" placeholder="请输入登录密码" class="form-control" type="password" required>
|
||||||
<span class="input-group-addon"><i class="fa fa-mobile"></i></span>
|
<span class="input-group-addon" title="登录密码,鼠标按下显示密码"
|
||||||
|
onmousedown="$('#password').attr('type','text')"
|
||||||
|
onmouseup="$('#password').attr('type','password')"><i class="fa fa-key"></i></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-4 control-label is-required">邮箱:</label>
|
<label class="col-sm-4 control-label is-required">确认密码:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<div class="input-group">
|
||||||
|
<input id="password1" name="password1" 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>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-4 control-label is-required">所在部门:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input name="name" placeholder="请输入部门" class="form-control" type="text" maxlength="30" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-4 control-label is-required">项目组:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input name="name" placeholder="请输入项目组" class="form-control" type="text" maxlength="30" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-4 control-label is-required">Email:</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input id="email" name="email" class="form-control email" type="text" maxlength="50" placeholder="请输入邮箱" required>
|
<input id="email" name="email" class="form-control email" type="text" maxlength="50" placeholder="请输入邮箱" required>
|
||||||
|
|
@ -53,88 +87,46 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-sm-4 control-label is-required">登录账号:</label>
|
<label class="col-sm-4 control-label is-required">抄送Email:</label>
|
||||||
<div class="col-sm-8">
|
|
||||||
<input id="loginName" name="loginName" placeholder="请输入登录账号" class="form-control" type="text" maxlength="30" required>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-sm-6">
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="col-sm-4 control-label is-required">登录密码:</label>
|
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<div class="input-group">
|
<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="ccEmail" name="ccEmail" class="form-control email" type="text" maxlength="50" placeholder="请输入抄送邮箱" required>
|
||||||
<span class="input-group-addon" title="登录密码,鼠标按下显示密码"
|
<span class="input-group-addon"><i class="fa fa-envelope"></i></span>
|
||||||
onmousedown="$('#password').attr('type','text')"
|
|
||||||
onmouseup="$('#password').attr('type','password')"><i class="fa fa-key"></i></span>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row">
|
|
||||||
<div class="col-sm-6">
|
|
||||||
<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}"></option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-sm-6">
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="col-sm-4 control-label">用户状态:</label>
|
|
||||||
<div class="col-sm-8">
|
|
||||||
<label class="toggle-switch switch-solid">
|
|
||||||
<input type="checkbox" id="status" checked>
|
|
||||||
<span></span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-sm-12">
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="col-xs-2 control-label">岗位:</label>
|
|
||||||
<div class="col-xs-4">
|
|
||||||
<select id="post" class="form-control select2-multiple" multiple>
|
|
||||||
<option th:each="post:${posts}" th:value="${post.postId}" th:text="${post.postName}" th:disabled="${post.status == '1'}"></option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-sm-12">
|
|
||||||
<div class="form-group">
|
|
||||||
<label class="col-xs-2 control-label">角色:</label>
|
|
||||||
<div class="col-xs-10">
|
|
||||||
<label th:each="role:${roles}" class="check-box">
|
|
||||||
<input name="role" type="checkbox" th:value="${role.roleId}" th:text="${role.roleName}" th:disabled="${role.status == '1'}">
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<h4 class="form-header h4">其他信息</h4>
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-12">
|
<div class="col-sm-12">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-xs-2 control-label">备注:</label>
|
<label class="col-xs-2 control-label">是否部门管理员:</label>
|
||||||
<div class="col-xs-10">
|
<div class="col-xs-10">
|
||||||
<textarea name="remark" maxlength="500" class="form-control" rows="3"></textarea>
|
<label class="check-box">
|
||||||
|
<input name="isDepAdmin" type="checkbox" onclick="checkAdmin(this);">
|
||||||
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="row" th:if="${groupId == 1}">
|
||||||
|
<div class="col-sm-12">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-xs-2 control-label">是否系统管理员:</label>
|
||||||
|
<div class="col-xs-10">
|
||||||
|
<label class="check-box">
|
||||||
|
<input name="isAdmin" type="checkbox" onclick="checkAdmin(this);" >
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -147,124 +139,53 @@
|
||||||
<th:block th:include="include :: footer" />
|
<th:block th:include="include :: footer" />
|
||||||
<th:block th:include="include :: select2-js" />
|
<th:block th:include="include :: select2-js" />
|
||||||
<script>
|
<script>
|
||||||
var prefix = ctx + "system/user";
|
var prefix = ctx + "user.do";
|
||||||
|
|
||||||
$("#form-user-add").validate({
|
$("#form-user-add").validate({
|
||||||
onkeyup: false,
|
onkeyup: false,
|
||||||
rules:{
|
rules:{
|
||||||
loginName:{
|
name:{
|
||||||
minlength: 2,
|
minlength: 1,
|
||||||
maxlength: 20,
|
maxlength: 32
|
||||||
remote: {
|
},
|
||||||
url: prefix + "/checkLoginNameUnique",
|
username:{
|
||||||
type: "post",
|
minlength: 1,
|
||||||
dataType: "json",
|
maxlength: 32
|
||||||
data: {
|
},
|
||||||
"loginName": function() {
|
|
||||||
return $.common.trim($("#loginName").val());
|
|
||||||
}
|
|
||||||
},
|
|
||||||
dataFilter: function(data, type) {
|
|
||||||
return $.validate.unique(data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
password:{
|
password:{
|
||||||
minlength: 5,
|
minlength: 4,
|
||||||
maxlength: 20
|
maxlength: 32
|
||||||
},
|
},
|
||||||
|
password1:{
|
||||||
|
minlength: 4,
|
||||||
|
maxlength: 32
|
||||||
|
},
|
||||||
email:{
|
email:{
|
||||||
email:true,
|
email:true,
|
||||||
remote: {
|
|
||||||
url: prefix + "/checkEmailUnique",
|
|
||||||
type: "post",
|
|
||||||
dataType: "json",
|
|
||||||
data: {
|
|
||||||
"email": function () {
|
|
||||||
return $.common.trim($("#email").val());
|
|
||||||
}
|
|
||||||
},
|
|
||||||
dataFilter: function (data, type) {
|
|
||||||
return $.validate.unique(data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
phonenumber:{
|
|
||||||
isPhone:true,
|
|
||||||
remote: {
|
|
||||||
url: prefix + "/checkPhoneUnique",
|
|
||||||
type: "post",
|
|
||||||
dataType: "json",
|
|
||||||
data: {
|
|
||||||
"phonenumber": function () {
|
|
||||||
return $.common.trim($("#phonenumber").val());
|
|
||||||
}
|
|
||||||
},
|
|
||||||
dataFilter: function (data, type) {
|
|
||||||
return $.validate.unique(data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
ccEmail:{
|
||||||
|
email:true,
|
||||||
|
},
|
||||||
|
department:{
|
||||||
|
|
||||||
|
},
|
||||||
|
projectGroup:{
|
||||||
|
|
||||||
|
}
|
||||||
},
|
},
|
||||||
messages: {
|
|
||||||
"loginName": {
|
|
||||||
remote: "用户已经存在"
|
|
||||||
},
|
|
||||||
"email": {
|
|
||||||
remote: "Email已经存在"
|
|
||||||
},
|
|
||||||
"phonenumber":{
|
|
||||||
remote: "手机号码已经存在"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
focusCleanup: true
|
focusCleanup: true
|
||||||
});
|
});
|
||||||
|
|
||||||
function submitHandler() {
|
function submitHandler() {
|
||||||
var chrtype = [[${#strings.defaultString(@config.getKey('sys.account.chrtype'), 0)}]];
|
// var chrtype = [[${#strings.defaultString(@config.getKey('sys.account.chrtype'), 0)}]];
|
||||||
var password = $("#password").val();
|
// var password = $("#password").val();
|
||||||
if ($.validate.form() && checkpwd(chrtype, password)) {
|
// if ($.validate.form() && checkpwd(chrtype, password)) {
|
||||||
|
if ($.validate.form() ) {
|
||||||
var data = $("#form-user-add").serializeArray();
|
var data = $("#form-user-add").serializeArray();
|
||||||
var status = $("input[id='status']").is(':checked') == true ? 0 : 1;
|
$.operate.save(prefix + "/addSave", data);
|
||||||
var roleIds = $.form.selectCheckeds("role");
|
|
||||||
var postIds = $.form.selectSelects("post");
|
|
||||||
data.push({"name": "status", "value": status});
|
|
||||||
data.push({"name": "roleIds", "value": roleIds});
|
|
||||||
data.push({"name": "postIds", "value": postIds});
|
|
||||||
$.operate.saveTab(prefix + "/add", data);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 用户管理-新增-选择部门树 */
|
|
||||||
function selectDeptTree() {
|
|
||||||
var treeId = $("#treeId").val();
|
|
||||||
var deptId = $.common.isEmpty(treeId) ? "100" : $("#treeId").val();
|
|
||||||
var url = ctx + "system/dept/selectDeptTree/" + deptId;
|
|
||||||
var options = {
|
|
||||||
title: '选择部门',
|
|
||||||
width: "380",
|
|
||||||
url: url,
|
|
||||||
callBack: doSubmit
|
|
||||||
};
|
|
||||||
$.modal.openOptions(options);
|
|
||||||
}
|
|
||||||
|
|
||||||
function doSubmit(index, layero){
|
|
||||||
var tree = layero.find("iframe")[0].contentWindow.$._tree;
|
|
||||||
if ($.tree.notAllowParents(tree)) {
|
|
||||||
var body = layer.getChildFrame('body', index);
|
|
||||||
$("#treeId").val(body.find('#treeId').val());
|
|
||||||
$("#treeName").val(body.find('#treeName').val());
|
|
||||||
layer.close(index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$(function() {
|
|
||||||
$('#post').select2({
|
|
||||||
placeholder: "请选择岗位",
|
|
||||||
allowClear: true
|
|
||||||
});
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
@ -0,0 +1,210 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
|
||||||
|
<head>
|
||||||
|
<th:block th:include="include :: header('修改用户')" />
|
||||||
|
<th:block th:include="include :: select2-css" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="main-content">
|
||||||
|
<form id="form-user-edit" class="form-horizontal" th:object="${user}">
|
||||||
|
<input name="id" type="hidden" th:field="*{id}" />
|
||||||
|
<input name="gid" type="hidden" th:field="*{groupId}" />
|
||||||
|
<h4 class="form-header h4">基本信息</h4>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-4 control-label is-required">员工姓名:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input name="name" placeholder="请输入用户姓名" class="form-control" type="text" maxlength="30" th:field="*{name}" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<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>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<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:field="*{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>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-4 control-label is-required">确认密码:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<div class="input-group">
|
||||||
|
<input id="password1" name="password1" placeholder="请再次输入登录密码" class="form-control" type="password" th:field="*{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>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-4 control-label is-required">所在部门:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input name="name" placeholder="请输入部门" class="form-control" type="text" maxlength="30" th:field="*{department}" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-4 control-label is-required">项目组:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<input name="name" placeholder="请输入项目组" class="form-control" type="text" maxlength="30" th:field="*{projectGroup}" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-4 control-label is-required">Email:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<div class="input-group">
|
||||||
|
<input id="email" name="email" class="form-control email" type="text" maxlength="50" placeholder="请输入邮箱" th:field="*{email}" required>
|
||||||
|
<span class="input-group-addon"><i class="fa fa-envelope"></i></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-4 control-label is-required">抄送Email:</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<div class="input-group">
|
||||||
|
<input id="ccEmail" name="ccEmail" class="form-control email" type="text" maxlength="50" th:field="*{ccEmail}" placeholder="请输入抄送邮箱" required>
|
||||||
|
<span class="input-group-addon"><i class="fa fa-envelope"></i></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row" th:if="${groupId == 1 || groupId == 3 }">
|
||||||
|
<div class="col-sm-12">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-xs-2 control-label">是否部门管理员:</label>
|
||||||
|
<div class="col-xs-10">
|
||||||
|
<label class="check-box">
|
||||||
|
<input name="isDepAdmin" type="checkbox" th:checked="*{groupId==3}" onclick="checkAdmin(this);">
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row" th:if="${groupId == 1 }">
|
||||||
|
<div class="col-sm-12">
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-xs-2 control-label">是否系统管理员:</label>
|
||||||
|
<div class="col-xs-10">
|
||||||
|
<label class="check-box">
|
||||||
|
<input name="isAdmin" type="checkbox" th:checked="*{groupId==1}" onclick="checkAdmin(this);" >
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-offset-5 col-sm-10">
|
||||||
|
<button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>
|
||||||
|
<button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<th:block th:include="include :: footer" />
|
||||||
|
<th:block th:include="include :: select2-js" />
|
||||||
|
<script>
|
||||||
|
|
||||||
|
jQuery(function($) {
|
||||||
|
initIsAdmin();
|
||||||
|
});
|
||||||
|
|
||||||
|
function initIsAdmin()
|
||||||
|
{
|
||||||
|
if('1' == $("input[name=isAdmin]").val())
|
||||||
|
{
|
||||||
|
$("input[name=isAdmin]").attr("checked",true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if('3' == $("input[name=isDepAdmin]").val())
|
||||||
|
{
|
||||||
|
$("input[name=isDepAdmin]").attr("checked",true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var prefix = ctx + "user.do";
|
||||||
|
|
||||||
|
$("#form-user-edit").validate({
|
||||||
|
onkeyup: false,
|
||||||
|
rules:{
|
||||||
|
name:{
|
||||||
|
minlength: 1,
|
||||||
|
maxlength: 32
|
||||||
|
},
|
||||||
|
username:{
|
||||||
|
minlength: 1,
|
||||||
|
maxlength: 32
|
||||||
|
},
|
||||||
|
password:{
|
||||||
|
minlength: 4,
|
||||||
|
maxlength: 32
|
||||||
|
},
|
||||||
|
password1:{
|
||||||
|
minlength: 4,
|
||||||
|
maxlength: 32
|
||||||
|
},
|
||||||
|
email:{
|
||||||
|
email:true,
|
||||||
|
},
|
||||||
|
ccEmail:{
|
||||||
|
email:true,
|
||||||
|
},
|
||||||
|
department:{
|
||||||
|
|
||||||
|
},
|
||||||
|
projectGroup:{
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
focusCleanup: true
|
||||||
|
});
|
||||||
|
|
||||||
|
function submitHandler() {
|
||||||
|
// var chrtype = [[${#strings.defaultString(@config.getKey('sys.account.chrtype'), 0)}]];
|
||||||
|
// var password = $("#password").val();
|
||||||
|
// if ($.validate.form() && checkpwd(chrtype, password)) {
|
||||||
|
if ($.validate.form() ) {
|
||||||
|
var data = $("#form-user-edit").serializeArray();
|
||||||
|
$.operate.saveTab(prefix + "/editSave", data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -39,10 +39,10 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="btn-group-sm" id="toolbar" role="group">
|
<div class="btn-group-sm" id="toolbar" role="group">
|
||||||
<a class="btn btn-success" onclick="$.operate.add()" >
|
<!--<a class="btn btn-success" onclick="$.operate.addTab()" >-->
|
||||||
<i class="fa fa-plus"></i> 新增
|
<!--<i class="fa fa-plus"></i> 新增-->
|
||||||
</a>
|
<!--</a>-->
|
||||||
<a class="btn btn-primary single disabled" onclick="$.operate.edit()" >
|
<a class="btn btn-primary single disabled" onclick="$.operate.editTab()" >
|
||||||
<i class="fa fa-edit"></i> 修改
|
<i class="fa fa-edit"></i> 修改
|
||||||
</a>
|
</a>
|
||||||
<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" >
|
<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" >
|
||||||
|
|
@ -60,15 +60,13 @@
|
||||||
</div>
|
</div>
|
||||||
<th:block th:include="include :: footer" />
|
<th:block th:include="include :: footer" />
|
||||||
<script th:inline="javascript">
|
<script th:inline="javascript">
|
||||||
var editFlag = [[${@permission.hasPermi('system:role:edit')}]];
|
|
||||||
var removeFlag = [[${@permission.hasPermi('system:role:remove')}]];
|
|
||||||
var prefix = ctx + "user.do";
|
var prefix = ctx + "user.do";
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
var options = {
|
var options = {
|
||||||
url: prefix + "/getUserList",
|
url: prefix + "/getUserList",
|
||||||
createUrl: prefix + "/add",
|
createUrl: prefix + "/add",
|
||||||
updateUrl: prefix + "/edit/{id}",
|
updateUrl: prefix + "/edit?uid={id}",
|
||||||
removeUrl: prefix + "/remove",
|
removeUrl: prefix + "/remove",
|
||||||
exportUrl: prefix + "/export",
|
exportUrl: prefix + "/export",
|
||||||
sortName: "roleSort",
|
sortName: "roleSort",
|
||||||
|
|
@ -77,10 +75,10 @@
|
||||||
{
|
{
|
||||||
checkbox: true
|
checkbox: true
|
||||||
},
|
},
|
||||||
// {
|
{
|
||||||
// field: 'id',
|
field: 'id',
|
||||||
// title: '员工ID'
|
visible: false
|
||||||
// },
|
},
|
||||||
{
|
{
|
||||||
field: 'name',
|
field: 'name',
|
||||||
title: '员工姓名',
|
title: '员工姓名',
|
||||||
|
|
@ -120,7 +118,7 @@
|
||||||
field: 'status',
|
field: 'status',
|
||||||
title: '状态',
|
title: '状态',
|
||||||
sortable: true
|
sortable: true
|
||||||
},
|
}
|
||||||
// {
|
// {
|
||||||
// field: 'roleSort',
|
// field: 'roleSort',
|
||||||
// title: '操作',
|
// title: '操作',
|
||||||
|
|
@ -139,58 +137,25 @@
|
||||||
// title: '创建时间',
|
// title: '创建时间',
|
||||||
// sortable: true
|
// sortable: true
|
||||||
// },
|
// },
|
||||||
{
|
// {
|
||||||
title: '操作',
|
// title: '操作',
|
||||||
align: 'center',
|
// align: 'center',
|
||||||
formatter: function(value, row, index) {
|
// formatter: function(value, row, index) {
|
||||||
var actions = [];
|
// var actions = [];
|
||||||
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.roleId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
|
// actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.roleId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
|
||||||
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.roleId + '\')"><i class="fa fa-remove"></i>删除</a> ');
|
// actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.roleId + '\')"><i class="fa fa-remove"></i>删除</a> ');
|
||||||
var more = [];
|
// var more = [];
|
||||||
more.push("<a class='btn btn-default btn-xs " + editFlag + "' href='javascript:void(0)' onclick='authDataScope(" + row.roleId + ")'><i class='fa fa-check-square-o'></i>数据权限</a> ");
|
// more.push("<a class='btn btn-default btn-xs " + editFlag + "' href='javascript:void(0)' onclick='authDataScope(" + row.roleId + ")'><i class='fa fa-check-square-o'></i>数据权限</a> ");
|
||||||
more.push("<a class='btn btn-default btn-xs " + editFlag + "' href='javascript:void(0)' onclick='authUser(" + row.roleId + ")'><i class='fa fa-user'></i>分配用户</a>");
|
// more.push("<a class='btn btn-default btn-xs " + editFlag + "' href='javascript:void(0)' onclick='authUser(" + row.roleId + ")'><i class='fa fa-user'></i>分配用户</a>");
|
||||||
actions.push('<a tabindex="0" class="btn btn-info btn-xs" role="button" data-container="body" data-placement="left" data-toggle="popover" data-html="true" data-trigger="hover" data-content="' + more.join('') + '"><i class="fa fa-chevron-circle-right"></i>更多操作</a>');
|
// actions.push('<a tabindex="0" class="btn btn-info btn-xs" role="button" data-container="body" data-placement="left" data-toggle="popover" data-html="true" data-trigger="hover" data-content="' + more.join('') + '"><i class="fa fa-chevron-circle-right"></i>更多操作</a>');
|
||||||
return actions.join('');
|
// return actions.join('');
|
||||||
}
|
// }
|
||||||
}]
|
// }
|
||||||
|
]
|
||||||
};
|
};
|
||||||
$.table.init(options);
|
$.table.init(options);
|
||||||
});
|
});
|
||||||
|
|
||||||
/* 角色管理-分配数据权限 */
|
|
||||||
function authDataScope(roleId) {
|
|
||||||
var url = prefix + '/authDataScope/' + roleId;
|
|
||||||
$.modal.open("分配数据权限", url);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 角色管理-分配用户 */
|
|
||||||
function authUser(roleId) {
|
|
||||||
var url = prefix + '/authUser/' + roleId;
|
|
||||||
$.modal.openTab("分配用户", url);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 角色状态显示 */
|
|
||||||
function statusTools(row) {
|
|
||||||
if (row.status == 1) {
|
|
||||||
return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enable(\'' + row.roleId + '\')"></i> ';
|
|
||||||
} else {
|
|
||||||
return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="disable(\'' + row.roleId + '\')"></i> ';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 角色管理-停用 */
|
|
||||||
function disable(roleId) {
|
|
||||||
$.modal.confirm("确认要停用角色吗?", function() {
|
|
||||||
$.operate.post(prefix + "/changeStatus", { "roleId": roleId, "status": 1 });
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 角色管理启用 */
|
|
||||||
function enable(roleId) {
|
|
||||||
$.modal.confirm("确认要启用角色吗?", function() {
|
|
||||||
$.operate.post(prefix + "/changeStatus", { "roleId": roleId, "status": 0 });
|
|
||||||
})
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Loading…
Reference in New Issue