开源 usercontroller 相关代码
This commit is contained in:
@@ -0,0 +1,212 @@
|
||||
/**
|
||||
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
|
||||
*/
|
||||
package com.jeesite.modules.sys.web.user;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import com.jeesite.common.codec.DesUtils;
|
||||
import com.jeesite.common.codec.EncodeUtils;
|
||||
import com.jeesite.common.config.Global;
|
||||
import com.jeesite.common.entity.Page;
|
||||
import com.jeesite.common.lang.StringUtils;
|
||||
import com.jeesite.common.mapper.JsonMapper;
|
||||
import com.jeesite.common.service.ServiceException;
|
||||
import com.jeesite.common.web.BaseController;
|
||||
import com.jeesite.modules.sys.entity.User;
|
||||
import com.jeesite.modules.sys.service.UserService;
|
||||
import com.jeesite.modules.sys.utils.PwdUtils;
|
||||
import com.jeesite.modules.sys.utils.UserUtils;
|
||||
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
/**
|
||||
* 用户Controller
|
||||
* @author ThinkGem
|
||||
* @version 2017-3-21
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping(value = "${adminPath}/sys/user")
|
||||
@ConditionalOnProperty(name="web.core.enabled", havingValue="true", matchIfMissing=true)
|
||||
@ApiIgnore
|
||||
public class UserController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
/**
|
||||
* 获取用户列表
|
||||
*/
|
||||
@RequiresPermissions("user")
|
||||
@RequestMapping(value = "listData")
|
||||
@ResponseBody
|
||||
public Page<User> listData(User user, HttpServletRequest request, HttpServletResponse response) {
|
||||
if (User.USER_TYPE_NONE.equals(user.getUserType())){
|
||||
return new Page<User>(request, response);
|
||||
}
|
||||
if (Global.isStrictMode() && !user.getCurrentUser().isAdmin()){
|
||||
return new Page<User>(request, response);
|
||||
}
|
||||
user.setPage(new Page<>(request, response));
|
||||
Page<User> page = userService.findPage(user);
|
||||
return page;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证登录名是否有效
|
||||
*/
|
||||
@RequiresPermissions("user")
|
||||
@RequestMapping(value = "checkLoginCode")
|
||||
@ResponseBody
|
||||
public String checkLoginCode(String oldLoginCode, String loginCode) {
|
||||
return userService.checkLoginCode(oldLoginCode, loginCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户信息 - 显示
|
||||
*/
|
||||
@RequiresPermissions("user")
|
||||
@RequestMapping(value = "info")
|
||||
public String info(User user, String op, Model model) {
|
||||
if (StringUtils.isBlank(op)){
|
||||
op = "base";
|
||||
}
|
||||
model.addAttribute("op", op);
|
||||
model.addAttribute("user", user.getCurrentUser());
|
||||
return "modules/sys/user/userInfo";
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户信息 - 保存基础信息
|
||||
*/
|
||||
@RequiresPermissions("user")
|
||||
@PostMapping(value = "infoSaveBase")
|
||||
@ResponseBody
|
||||
public String infoSaveBase(User user, HttpServletRequest request) {
|
||||
if (StringUtils.isBlank(user.getUserName())){
|
||||
return renderResult(Global.TRUE, text("sys.user.userNameNotBlank"));
|
||||
}
|
||||
Global.assertDemoMode();
|
||||
User currentUser = UserUtils.getUser();
|
||||
currentUser.setAvatarBase64(user.getAvatarBase64());
|
||||
currentUser.setUserName(user.getUserName());
|
||||
currentUser.setEmail(user.getEmail());
|
||||
currentUser.setMobile(user.getMobile());
|
||||
currentUser.setPhone(user.getPhone());
|
||||
currentUser.setSex(user.getSex());
|
||||
currentUser.setSign(user.getSign());
|
||||
userService.updateUserInfo(currentUser);
|
||||
return renderResult(Global.TRUE, text("sys.user.infoSaveSuccess"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户信息 - 保存用户密码
|
||||
*/
|
||||
@RequiresPermissions("user")
|
||||
@PostMapping(value = "infoSavePwd")
|
||||
@ResponseBody
|
||||
public String infoSavePwd(User user, String oldPassword, String newPassword,
|
||||
String confirmNewPassword) {
|
||||
User currentUser = UserUtils.getUser();
|
||||
// 登录密码解密(解决密码明文传输安全问题)
|
||||
String secretKey = Global.getProperty("shiro.loginSubmit.secretKey");
|
||||
if (StringUtils.isNotBlank(secretKey)){
|
||||
oldPassword = DesUtils.decode(oldPassword, secretKey);
|
||||
newPassword = DesUtils.decode(newPassword, secretKey);
|
||||
confirmNewPassword = DesUtils.decode(confirmNewPassword, secretKey);
|
||||
}
|
||||
// 验证旧密码
|
||||
if(!PwdUtils.validatePassword(oldPassword, currentUser.getPassword())){
|
||||
return renderResult(Global.FALSE, text("sys.user.oldPasswordError"));
|
||||
}
|
||||
// 验证新密码和确认密码
|
||||
if(!StringUtils.equals(newPassword, confirmNewPassword)){
|
||||
return renderResult(Global.FALSE, text("sys.user.confirmPasswrodError"));
|
||||
}
|
||||
// 更新密码
|
||||
try{
|
||||
userService.updatePassword(currentUser.getUserCode(), confirmNewPassword);
|
||||
return renderResult(Global.TRUE, text("sys.user.passwordModifySuccess"));
|
||||
}catch(ServiceException se){
|
||||
return renderResult(Global.FALSE, se.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户信息 - 保存保密问题
|
||||
*/
|
||||
@RequiresPermissions("user")
|
||||
@PostMapping(value = "infoSavePqa")
|
||||
@ResponseBody
|
||||
public String infoSavePqa(User user, String validPassword, String oldPwdQuestionAnswer,
|
||||
String oldPwdQuestionAnswer2, String oldPwdQuestionAnswer3) {
|
||||
User currentUser = UserUtils.getUser();
|
||||
// 安全问题密码解密(解决密码明文传输安全问题)
|
||||
String secretKey = Global.getProperty("shiro.loginSubmit.secretKey");
|
||||
if (StringUtils.isNotBlank(secretKey)){
|
||||
validPassword = DesUtils.decode(validPassword, secretKey);
|
||||
oldPwdQuestionAnswer = DesUtils.decode(oldPwdQuestionAnswer, secretKey);
|
||||
oldPwdQuestionAnswer2 = DesUtils.decode(oldPwdQuestionAnswer2, secretKey);
|
||||
oldPwdQuestionAnswer3 = DesUtils.decode(oldPwdQuestionAnswer3, secretKey);
|
||||
user.setPwdQuestionAnswer(DesUtils.decode(user.getPwdQuestionAnswer(), secretKey));
|
||||
user.setPwdQuestionAnswer2(DesUtils.decode(user.getPwdQuestionAnswer2(), secretKey));
|
||||
user.setPwdQuestionAnswer3(DesUtils.decode(user.getPwdQuestionAnswer3(), secretKey));
|
||||
}
|
||||
boolean updateQuesstion = false;
|
||||
// 如果从未设置过
|
||||
if (StringUtils.isBlank(currentUser.getPwdQuestion())
|
||||
&& StringUtils.isBlank(currentUser.getPwdQuestion2())
|
||||
&& StringUtils.isBlank(currentUser.getPwdQuestion3())){
|
||||
if(!PwdUtils.validatePassword(validPassword, currentUser.getPassword())){
|
||||
return renderResult(Global.FALSE, text("sys.user.passwordError"));
|
||||
}
|
||||
updateQuesstion = true;
|
||||
}
|
||||
// 验证密保答案
|
||||
else if (PwdUtils.validatePassword(oldPwdQuestionAnswer, currentUser.getPwdQuestionAnswer())
|
||||
&& PwdUtils.validatePassword(oldPwdQuestionAnswer2, currentUser.getPwdQuestionAnswer2())
|
||||
&& PwdUtils.validatePassword(oldPwdQuestionAnswer3, currentUser.getPwdQuestionAnswer3())) {
|
||||
updateQuesstion = true;
|
||||
}
|
||||
// 保存密保答案
|
||||
if (updateQuesstion){
|
||||
currentUser.setPwdQuestion(user.getPwdQuestion());
|
||||
currentUser.setPwdQuestionAnswer(PwdUtils.encryptPassword(user.getPwdQuestionAnswer()));
|
||||
currentUser.setPwdQuestion2(user.getPwdQuestion2());
|
||||
currentUser.setPwdQuestionAnswer2(PwdUtils.encryptPassword(user.getPwdQuestionAnswer2()));
|
||||
currentUser.setPwdQuestion3(user.getPwdQuestion3());
|
||||
currentUser.setPwdQuestionAnswer3(PwdUtils.encryptPassword(user.getPwdQuestionAnswer3()));
|
||||
userService.updateQuestion(currentUser);
|
||||
return renderResult(Global.TRUE, text("sys.user.pwdQuestionModifySuccess"));
|
||||
}else{
|
||||
return renderResult(Global.FALSE, text("sys.user.pwdQuestionAnswerError"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 选择用户对话框
|
||||
*/
|
||||
@RequiresPermissions("user")
|
||||
@RequestMapping(value = "userSelect")
|
||||
public String userSelect(User user, String selectData, Model model) {
|
||||
String selectDataJson = EncodeUtils.decodeUrl(selectData);
|
||||
if (JsonMapper.fromJson(selectDataJson, Map.class) != null){
|
||||
model.addAttribute("selectData", selectDataJson);
|
||||
}
|
||||
model.addAttribute("user", user);
|
||||
return "modules/sys/user/userSelect";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,373 @@
|
||||
<%/* Copyright (c) 2013-Now http://jeesite.com All rights reserved. */ %>
|
||||
<% layout('/layouts/default.html', {title: '个人中心', libs: ['validate']}){ %>
|
||||
<link rel="stylesheet" href="${ctxStatic}/jquery-plugins/jquery.strength.css?${_version}">
|
||||
<link rel="stylesheet" href="${ctxStatic}/modules/sys/userInfo.css?${_version}">
|
||||
<div class="main-content">
|
||||
<div class="nav-tabs-custom nav-main">
|
||||
<ul class="nav nav-tabs pull-right">
|
||||
<li class="${op == 'pqa' ? 'active' : ''}"><a href="#tab-3" data-toggle="tab">${text('修改密保')}</a></li>
|
||||
<li class="${op == 'pwd' ? 'active' : ''}"><a href="#tab-2" data-toggle="tab">${text('修改密码')}</a></li>
|
||||
<% if(!(isNotBlank(parameter.msg) && op == 'pwd')){ %>
|
||||
<li class="${op == 'base' ? 'active' : ''}"><a href="#tab-1" data-toggle="tab">${text('个人信息')}</a></li>
|
||||
<% } %>
|
||||
<li class="pull-left header">
|
||||
<i class="fa icon-user" style="vertical-align:-1px;"></i>${text('个人中心')}
|
||||
</li>
|
||||
</ul>
|
||||
<div class="tab-content p0">
|
||||
<div class="tab-pane ${op == 'base' ? 'active' : ''}" id="tab-1">
|
||||
<#form:form id="inputFormBase" model="${user}" action="${ctx}/sys/user/infoSaveBase" method="post" class="form-horizontal">
|
||||
<div class="box-body"><br/>
|
||||
<div class="col-sm-offset-1 col-sm-3"><br/>
|
||||
<div class="box-body box-profile">
|
||||
<img id="avatarImg" class="profile-user-img img-responsive img-circle"
|
||||
src="${@user.getAvatarUrl().replaceFirst('/ctxPath', ctxPath)}">
|
||||
<h3 class="profile-username text-center">${user.userName}</h3>
|
||||
<p class="text-muted text-center">
|
||||
<#form:radio path="sex" dictType="sys_user_sex" class="form-control required"/>
|
||||
</p>
|
||||
<#form:imageclip name="avatarBase64" btnText="${text('修改头像')}" btnClass="btn-block"
|
||||
imageId="avatarImg" imageDefaultSrc="${ctxStatic+'/images/user'+(isNotBlank(user.sex)?user.sex:1)+'.jpg'}"
|
||||
circle="true"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-7"><br/>
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-sm-3">
|
||||
<span class="required">*</span> ${text('用户昵称')}:</label>
|
||||
<div class="col-sm-9">
|
||||
<div class="input-group">
|
||||
<#form:input path="userName" maxlength="32" class="form-control required"/>
|
||||
<span class="input-group-addon"><i class="fa fa-fw fa-user" style="margin-top:-2px;display:block;"></i></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-sm-3" title="">
|
||||
<span class="required hide">*</span> ${text('电子邮箱')}:<i class="fa icon-question hide"></i></label>
|
||||
<div class="col-sm-9">
|
||||
<div class="input-group">
|
||||
<#form:input path="email" maxlength="300" class="form-control email"/>
|
||||
<span class="input-group-addon"><i class="fa fa-fw fa-envelope" style="margin-top:-2px;display:block;"></i></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-sm-3" title="">
|
||||
<span class="required hide">*</span> ${text('手机号码')}:<i class="fa icon-question hide"></i></label>
|
||||
<div class="col-sm-9">
|
||||
<div class="input-group">
|
||||
<#form:input path="mobile" maxlength="100" class="form-control mobile"/>
|
||||
<span class="input-group-addon"><i class="fa fa-fw fa-mobile" style="margin-top:-2px;display:block;"></i></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-sm-3" title="">
|
||||
<span class="required hide">*</span> ${text('办公电话')}:<i class="fa icon-question hide"></i></label>
|
||||
<div class="col-sm-9">
|
||||
<div class="input-group">
|
||||
<#form:input path="phone" maxlength="100" class="form-control phone"/>
|
||||
<span class="input-group-addon"><i class="fa fa-fw fa-phone"></i></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-sm-3" title="">
|
||||
<span class="required hide">*</span> ${text('个性签名')}:<i class="fa icon-question hide"></i></label>
|
||||
<div class="col-sm-9">
|
||||
<#form:textarea path="sign" rows="3" maxlength="100" class="form-control "/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-sm-3">${text('上次登录')}:</label>
|
||||
<div class="col-sm-9 pt3">
|
||||
<% if(user.lastLoginDate != null){ %>
|
||||
${text('时间')}:${user.lastLoginDate,dateFormat='yyyy-MM-dd HH:mm'}
|
||||
IP:${user.lastLoginIp}
|
||||
<% }else{ %>${text('首次登录')}<% } %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-footer">
|
||||
<div class="row mr20 pr20">
|
||||
<div class="text-center mr20 pr20">
|
||||
<button type="submit" class="btn btn-sm btn-primary"><i class="fa fa-check"></i> ${text('保 存')}</button>
|
||||
<button type="button" class="btn btn-sm btn-default" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</#form:form>
|
||||
</div>
|
||||
<div class="tab-pane ${op == 'pwd' ? 'active' : ''}" id="tab-2">
|
||||
<#form:form id="inputFormPwd" model="${user}" action="${ctx}/sys/user/infoSavePwd" method="post" class="form-horizontal">
|
||||
<div class="box-body">
|
||||
<% if(isNotBlank(parameter.msg)){ %>
|
||||
<div class="alert alert-dismissible callout callout-info ml10 mr10 mt10">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||||
<p><i class="icon fa fa-info"></i> ${parameter.msg}</p>
|
||||
</div><br/>
|
||||
<% }else{ %>
|
||||
<div class="form-unit">${text('修改密码')}</div>
|
||||
<% } %>
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-sm-3">${text('旧密码')}:</label>
|
||||
<div class="col-sm-8">
|
||||
<input id="oldPassword" name="oldPassword" type="password" autocomplete="off" value="" maxlength="50" minlength="3" class="form-control required"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-sm-3">${text('新密码')}:</label>
|
||||
<div class="col-sm-8">
|
||||
<div class="strength strength-loose">
|
||||
<input id="newPassword" name="newPassword" type="password" autocomplete="off" value="" maxlength="50" minlength="3" class="form-control required"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-sm-3">${text('确认新密码')}:</label>
|
||||
<div class="col-sm-8">
|
||||
<input id="confirmNewPassword" name="confirmNewPassword" type="password" autocomplete="off" value="" maxlength="50" minlength="3" class="form-control required" equalTo="#newPassword"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-footer">
|
||||
<div class="row">
|
||||
<div class="col-sm-offset-3 col-sm-10">
|
||||
<button type="submit" class="btn btn-sm btn-primary"><i class="fa fa-check"></i> ${text('保 存')}</button>
|
||||
<button type="button" class="btn btn-sm btn-default" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</#form:form>
|
||||
</div>
|
||||
<div class="tab-pane ${op == 'pqa' ? 'active' : ''}" id="tab-3">
|
||||
<#form:form id="inputFormPqa" model="${user}" action="${ctx}/sys/user/infoSavePqa" method="post" class="form-horizontal">
|
||||
<div class="box-body">
|
||||
<% if(isBlank(user.pwdQuestion) && isBlank(user.pwdQuestion2) && isBlank(user.pwdQuestion3)){ %>
|
||||
<div class="alert alert-dismissible callout callout-info ml10 mr10 mt10">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||||
<p><i class="icon fa fa-info"></i> ${text('您还未设置过密保问题,您可以根据登录密码设置新的密保问题及答案。')}</p>
|
||||
</div><br/>
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-sm-3">${text('登录密码')}:</label>
|
||||
<div class="col-sm-8">
|
||||
<input id="validPassword" name="validPassword" type="password" autocomplete="off" value="" maxlength="50" minlength="3" class="form-control required"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% }else{ %>
|
||||
<div class="form-unit">${text('旧的密保问题及答案')}</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-sm-3">${text('旧密保问题')}(1)</label>
|
||||
<div class="col-sm-8">
|
||||
<input id="oldPwdQuestion" name="oldPwdQuestion" type="text" value="${user.pwdQuestion}" maxlength="50" minlength="3" readonly="readonly" class="form-control required"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-sm-3">${text('旧密保问题答案')}(1)</label>
|
||||
<div class="col-sm-8">
|
||||
<input id="oldPwdQuestionAnswer" name="oldPwdQuestionAnswer" type="text" value="" maxlength="50" minlength="1" class="form-control required"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-sm-3">${text('旧密保问题')}(2)</label>
|
||||
<div class="col-sm-8">
|
||||
<input id="oldPwdQuestion2" name="oldPwdQuestion2" type="text" value="${user.pwdQuestion2}" maxlength="50" minlength="3" readonly="readonly" class="form-control required"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-sm-3">${text('旧密保问题答案')}(2)</label>
|
||||
<div class="col-sm-8">
|
||||
<input id="oldPwdQuestionAnswer2" name="oldPwdQuestionAnswer2" type="text" value="" maxlength="50" minlength="1" class="form-control required"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-sm-3">${text('旧密保问题')}(3)</label>
|
||||
<div class="col-sm-8">
|
||||
<input id="oldPwdQuestion3" name="oldPwdQuestion3" type="text" value="${user.pwdQuestion3}" maxlength="50" minlength="3" readonly="readonly" class="form-control required"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-sm-3">${text('旧密保问题答案')}(3)</label>
|
||||
<div class="col-sm-8">
|
||||
<input id="oldPwdQuestionAnswer3" name="oldPwdQuestionAnswer3" type="text" value="" maxlength="50" minlength="1" class="form-control required"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% } %>
|
||||
<div class="form-unit">${text('新的密保问题及答案')}</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-sm-3">${text('新密保问题')}(1):</label>
|
||||
<div class="col-sm-8">
|
||||
<input id="pwdQuestion" name="pwdQuestion" type="text" value="${user.pwdQuestion}" maxlength="50" minlength="3" class="form-control required"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-sm-3">${text('新密保问题答案')}(1):</label>
|
||||
<div class="col-sm-8">
|
||||
<input id="pwdQuestionAnswer" name="pwdQuestionAnswer" type="text" value="" maxlength="50" minlength="1" class="form-control required"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-sm-3">${text('新密保问题')}(2):</label>
|
||||
<div class="col-sm-8">
|
||||
<input id="pwdQuestion2" name="pwdQuestion2" type="text" value="${user.pwdQuestion2}" maxlength="50" minlength="3" class="form-control required"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-sm-3">${text('新密保问题答案')}(2):</label>
|
||||
<div class="col-sm-8">
|
||||
<input id="pwdQuestionAnswer2" name="pwdQuestionAnswer2" type="text" value="" maxlength="50" minlength="1" class="form-control required"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-sm-3">${text('新密保问题')}(3):</label>
|
||||
<div class="col-sm-8">
|
||||
<input id="pwdQuestion3" name="pwdQuestion3" type="text" value="${user.pwdQuestion3}" maxlength="50" minlength="3" class="form-control required"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-sm-3">${text('新密保问题答案')}(3):</label>
|
||||
<div class="col-sm-8">
|
||||
<input id="pwdQuestionAnswer3" name="pwdQuestionAnswer3" type="text" value="" maxlength="50" minlength="1" class="form-control required"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-footer">
|
||||
<div class="row">
|
||||
<div class="col-sm-offset-3 col-sm-10">
|
||||
<button type="submit" class="btn btn-sm btn-primary"><i class="fa fa-check"></i> ${text('保 存')}</button>
|
||||
<button type="button" class="btn btn-sm btn-default" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</#form:form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% } %>
|
||||
<script src="${ctxStatic}/common/des.js?${_version}"></script>
|
||||
<script src="${ctxStatic}/jquery-plugins/jquery.strength.js?${_version}"></script>
|
||||
<script src="${ctxStatic}/jquery-plugins/jquery.strength_i18n.js?${_version}"></script>
|
||||
<script>
|
||||
// 个人信息
|
||||
$("#inputFormBase").validate({
|
||||
submitHandler: function(form){
|
||||
js.ajaxSubmitForm($(form), function(data){
|
||||
js.showMessage(data.message);
|
||||
if(data.result == Global.TRUE){
|
||||
location = '${ctx}/sys/user/info?op=base';
|
||||
}
|
||||
}, "json");
|
||||
}
|
||||
});
|
||||
$('#sex input').on('ifCreated ifChecked', function(){
|
||||
if ($(this).is(':checked')){
|
||||
var s = $('#avatarImg').attr('src');
|
||||
var m = "${ctxStatic}/images/user1.jpg";
|
||||
var w = "${ctxStatic}/images/user2.jpg";
|
||||
if (s == m || s == w){
|
||||
$('#avatarImg').attr('src', "${ctxStatic}/images/user"+$(this).val()+".jpg");
|
||||
}
|
||||
}
|
||||
});
|
||||
// 修改密码
|
||||
$("#newPassword").strength();
|
||||
$("#inputFormPwd").validate({
|
||||
submitHandler: function(form){
|
||||
var oldPassword = $('#oldPassword').val(),
|
||||
newPassword = $('#newPassword').val(),
|
||||
confirmNewPassword = $('#confirmNewPassword').val(),
|
||||
secretKey = '${@Global.getConfig("shiro.loginSubmit.secretKey")}';
|
||||
if (secretKey != ''){
|
||||
$('#oldPassword').val(DesUtils.encode(oldPassword, secretKey));
|
||||
$('#newPassword').val(DesUtils.encode(newPassword, secretKey));
|
||||
$('#confirmNewPassword').val(DesUtils.encode(confirmNewPassword, secretKey));
|
||||
}
|
||||
js.ajaxSubmitForm($(form), function(data){
|
||||
js.showMessage(data.message);
|
||||
if(data.result == Global.TRUE){
|
||||
if ('${parameter.url}'!=''){
|
||||
location = '${ctxPath}${parameter.url}';
|
||||
}else{
|
||||
location = '${ctx}/sys/user/info?op=pwd';
|
||||
}
|
||||
}
|
||||
}, "json");
|
||||
$('#oldPassword').val(oldPassword);
|
||||
$('#newPassword').val(newPassword);
|
||||
$('#confirmNewPassword').val(confirmNewPassword);
|
||||
}
|
||||
});
|
||||
// 密保问题
|
||||
$("#inputFormPqa").validate({
|
||||
submitHandler: function(form){
|
||||
var validPassword = $('#validPassword').val(),
|
||||
oldPwdQuestionAnswer = $('#oldPwdQuestionAnswer').val(),
|
||||
oldPwdQuestionAnswer2 = $('#oldPwdQuestionAnswer2').val(),
|
||||
oldPwdQuestionAnswer3 = $('#oldPwdQuestionAnswer3').val(),
|
||||
pwdQuestionAnswer = $('#pwdQuestionAnswer').val(),
|
||||
pwdQuestionAnswer2 = $('#pwdQuestionAnswer2').val(),
|
||||
pwdQuestionAnswer3 = $('#pwdQuestionAnswer3').val(),
|
||||
secretKey = '${@Global.getConfig("shiro.loginSubmit.secretKey")}';
|
||||
if (secretKey != ''){
|
||||
$('#validPassword').val(DesUtils.encode(validPassword, secretKey));
|
||||
$('#oldPwdQuestionAnswer').val(DesUtils.encode(oldPwdQuestionAnswer, secretKey));
|
||||
$('#oldPwdQuestionAnswer2').val(DesUtils.encode(oldPwdQuestionAnswer2, secretKey));
|
||||
$('#oldPwdQuestionAnswer3').val(DesUtils.encode(oldPwdQuestionAnswer3, secretKey));
|
||||
$('#pwdQuestionAnswer').val(DesUtils.encode(pwdQuestionAnswer, secretKey));
|
||||
$('#pwdQuestionAnswer2').val(DesUtils.encode(pwdQuestionAnswer2, secretKey));
|
||||
$('#pwdQuestionAnswer3').val(DesUtils.encode(pwdQuestionAnswer3, secretKey));
|
||||
}
|
||||
js.ajaxSubmitForm($(form), function(data){
|
||||
js.showMessage(data.message);
|
||||
if(data.result == Global.TRUE){
|
||||
location = '${ctx}/sys/user/info?op=pqa';
|
||||
}
|
||||
}, "json");
|
||||
$('#validPassword').val(validPassword);
|
||||
$('#oldPwdQuestionAnswer').val(oldPwdQuestionAnswer);
|
||||
$('#oldPwdQuestionAnswer2').val(oldPwdQuestionAnswer2);
|
||||
$('#oldPwdQuestionAnswer3').val(oldPwdQuestionAnswer3);
|
||||
$('#pwdQuestionAnswer').val(pwdQuestionAnswer);
|
||||
$('#pwdQuestionAnswer2').val(pwdQuestionAnswer2);
|
||||
$('#pwdQuestionAnswer3').val(pwdQuestionAnswer3);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,148 @@
|
||||
<%/* Copyright (c) 2013-Now http://jeesite.com All rights reserved. */ %>
|
||||
<% layout('/layouts/default.html', {title: '用户选择', libs: ['dataGrid']}){ %>
|
||||
<div class="main-content">
|
||||
<div class="box box-main">
|
||||
<div class="box-body">
|
||||
<#form:form id="searchForm" model="${user}" action="${ctx}/sys/user/listData" method="post" class="form-inline "
|
||||
data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
|
||||
<#form:hidden name="status" value="${isNotBlank(user.status) ? user.status : '0'}"/>
|
||||
<#form:hidden name="userType" value="${user.userType}"/>
|
||||
<#form:hidden name="isAll" value="${parameter.isAll}"/>
|
||||
<div class="form-group">
|
||||
<label class="control-label">${text('账号')}:</label>
|
||||
<div class="control-inline">
|
||||
<#form:input path="loginCode" maxlength="100" class="form-control width-90"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">${text('昵称')}:</label>
|
||||
<div class="control-inline">
|
||||
<#form:input path="userName" maxlength="100" class="form-control width-90"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">${text('邮箱')}:</label>
|
||||
<div class="control-inline">
|
||||
<#form:input path="email" maxlength="300" class="form-control width-90"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">${text('手机')}:</label>
|
||||
<div class="control-inline">
|
||||
<#form:input path="mobile" maxlength="100" class="form-control width-90"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label">${text('电话')}:</label>
|
||||
<div class="control-inline">
|
||||
<#form:input path="phone" maxlength="100" class="form-control width-90"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
|
||||
<button type="reset" class="btn btn-default btn-sm">${text('重置')}</button>
|
||||
</div>
|
||||
</#form:form>
|
||||
<div class="row">
|
||||
<div class="col-xs-10 pr10">
|
||||
<table id="dataGrid"></table>
|
||||
<div id="dataGridPage"></div>
|
||||
</div>
|
||||
<div class="col-xs-2 pl0">
|
||||
<div id="selectData" class="tags-input"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% } %>
|
||||
<script>
|
||||
var selectData = ${isNotBlank(selectData!) ? selectData! : "{\}"},
|
||||
selectNum = 0, dataGrid = $('#dataGrid').dataGrid({
|
||||
searchForm: $("#searchForm"),
|
||||
columnModel: [
|
||||
{header:'${text("登录账号")}', name:'loginCode', index:'a.login_code', width:200, align:"center"},
|
||||
{header:'${text("用户昵称")}', name:'userName', index:'a.user_name', width:200, align:"center"},
|
||||
{header:'${text("电子邮箱")}', name:'email', index:'a.email', width:200, align:"center"},
|
||||
{header:'${text("手机号码")}', name:'mobile', index:'a.mobile', width:200, align:"center"},
|
||||
{header:'${text("办公电话")}', name:'phone', index:'a.phone', width:200, align:"center"},
|
||||
{header:'${text("更新时间")}', name:'updateDate', index:'a.update_date', width:200, align:"center"},
|
||||
{header:'${text("状态")}', name:'status', index:'a.status', width:100, align:"center", formatter: function(val, obj, row, act){
|
||||
return js.getDictLabel(${@DictUtils.getDictListJson('sys_status')}, val, '未知', true);
|
||||
}},
|
||||
<% if(isBlank(user.userType)){ %>
|
||||
{header:'${text("类型")}', name:'userType', index:'a.user_type', width:100, align:"center", formatter: function(val, obj, row, act){
|
||||
return js.getDictLabel(${@DictUtils.getDictListJson('sys_user_type')}, val, '未知', true);
|
||||
}},
|
||||
<% } %>
|
||||
{header:'行数据', name:'rowData', hidden:true, formatter: function(val, obj, row, act){
|
||||
return JSON.stringify(row);
|
||||
}}
|
||||
],
|
||||
autoGridHeight: function(){
|
||||
var height = $(window).height() - $('#searchForm').height() - $('#dataGridPage').height() - 75;
|
||||
$('.tags-input').height($('.ui-jqgrid').height() - 10);
|
||||
return height;
|
||||
},
|
||||
showCheckbox: '${parameter.checkbox}' == 'true',
|
||||
multiboxonly: false, // 单击复选框时再多选
|
||||
ajaxSuccess: function(data){
|
||||
$.each(selectData, function(key, value){
|
||||
dataGrid.dataGrid('setSelectRow', key);
|
||||
});
|
||||
initSelectTag();
|
||||
},
|
||||
onSelectRow: function(id, isSelect, event){
|
||||
if ('${parameter.checkbox}' == 'true'){
|
||||
if(isSelect){
|
||||
selectData[id] = JSON.parse(dataGrid.dataGrid('getRowData', id).rowData);
|
||||
}else{
|
||||
delete selectData[id];
|
||||
}
|
||||
}else{
|
||||
selectData = {};
|
||||
selectData[id] = JSON.parse(dataGrid.dataGrid('getRowData', id).rowData);
|
||||
}
|
||||
initSelectTag();
|
||||
},
|
||||
onSelectAll: function(ids, isSelect){
|
||||
if ('${parameter.checkbox}' == 'true'){
|
||||
for (var i=0; i<ids.length; i++){
|
||||
if(isSelect){
|
||||
selectData[ids[i]] = JSON.parse(dataGrid.dataGrid('getRowData', ids[i]).rowData);
|
||||
}else{
|
||||
delete selectData[ids[i]];
|
||||
}
|
||||
}
|
||||
}
|
||||
initSelectTag();
|
||||
},
|
||||
ondblClickRow: function(id, rownum, colnum, event){
|
||||
if ('${parameter.checkbox}' != 'true'){
|
||||
js.layer.$('#' + window.name).closest('.layui-layer')
|
||||
.find(".layui-layer-btn0").trigger("click");
|
||||
}
|
||||
initSelectTag();
|
||||
}
|
||||
});
|
||||
function initSelectTag(){
|
||||
selectNum = 0;
|
||||
var html = [];
|
||||
$.each(selectData, function(key, value){
|
||||
selectNum ++;
|
||||
html.push('<span class="tag" id="'+key+'_tags-input"><span>'+value.userName+' </span>'
|
||||
+ '<a href="#" onclick="removeSelectTag(\''+key+'\');" title="${text("取消选择")}">x</a></span>');
|
||||
});
|
||||
html.unshift('<div class="title">${text("当前已选择 {0\} 项", "<span id=\"selectNum\">'+selectNum+'</span>")}:</div>');
|
||||
$('#selectData').empty().append(html.join(''));
|
||||
}
|
||||
function removeSelectTag(key){
|
||||
delete selectData[key];
|
||||
dataGrid.dataGrid('resetSelection', key);
|
||||
$('#selectNum').html(--selectNum);
|
||||
$('#'+key+'_tags-input').remove();
|
||||
}
|
||||
function getSelectData(){
|
||||
return selectData;
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user