1、Excel优化

Former-commit-id: 37c0bb9c46f915b2709546723add4b2e29ae001e
master
wangbing 5 years ago
parent 7aa13d85d4
commit 17fcfa5350

@ -76,15 +76,15 @@ public class ${table.getCName()}Ajax{
response.addError(ErrorType.BUSINESS_ERROR, "导出数据为空"); response.addError(ErrorType.BUSINESS_ERROR, "导出数据为空");
return response; return response;
} }
return ResponseUtil.apply(new WExcel<>(response.getResult())); return ResponseUtil.apply(new WExcel<>(${table.getCName()}.class).loadData(response.getResult()));
} }
public Object imports(MultipartFile file) { public Object imports(MultipartFile file) {
BaseResponse baseResponse = new BaseResponse(); BaseResponse baseResponse = new BaseResponse();
try { try {
WExcel<${table.getCName()}> sheet = new WExcel<>(file.getBytes(), ${table.getCName()}.class, new WExcel.Validator<${table.getCName()}>() { WExcel sheet = new WExcel<>(${table.getCName()}.class).loadData(file.getBytes(), new WExcel.Processor<${table.getCName()}>() {
@Override @Override
public List<String> validate(${table.getCName()} o) { public List<String> exec(${table.getCName()} o) {
${table.getCName()}CreateRequest request = MapperUtil.map(o, ${table.getCName()}CreateRequest.class); ${table.getCName()}CreateRequest request = MapperUtil.map(o, ${table.getCName()}CreateRequest.class);
return ValidationUtil.validate(request); return ValidationUtil.validate(request);
} }

@ -79,9 +79,9 @@ public class DeptAjax {
public Object imports(MultipartFile file) { public Object imports(MultipartFile file) {
BaseResponse baseResponse = new BaseResponse(); BaseResponse baseResponse = new BaseResponse();
try { try {
WExcel<Dept> sheet = new WExcel<>(file.getBytes(), Dept.class, new WExcel.Validator<Dept>() { WExcel sheet = new WExcel<>(Dept.class).loadData(file.getBytes(), new WExcel.Processor<Dept>() {
@Override @Override
public List<String> validate(Dept o) { public List<String> exec(Dept o) {
DeptCreateRequest request = MapperUtil.map(o, DeptCreateRequest.class); DeptCreateRequest request = MapperUtil.map(o, DeptCreateRequest.class);
return ValidationUtil.validate(request); return ValidationUtil.validate(request);
} }

@ -79,16 +79,16 @@ public class DictAjax {
public Object imports(MultipartFile file) { public Object imports(MultipartFile file) {
BaseResponse baseResponse = new BaseResponse(); BaseResponse baseResponse = new BaseResponse();
try { try {
WExcel<Dict> sheet = new WExcel<>(file.getBytes(), Dict.class, new WExcel.Validator<Dict>() { WExcel sheet = new WExcel<>(Dict.class).loadData(file.getBytes(), new WExcel.Processor<Dict>() {
@Override @Override
public List<String> validate(Dict o) { public List<String> exec(Dict o) {
DictCreateRequest request = MapperUtil.map(o, DictCreateRequest.class); DictCreateRequest request = MapperUtil.map(o, DictCreateRequest.class);
return ValidationUtil.validate(request); return ValidationUtil.validate(request);
} }
}); });
if (sheet.hasError()) { if (sheet.hasError()) {
return ResponseUtil.apply(sheet.getBytes(true), sheet.getName() + "-检查.xlsx"); return ResponseUtil.apply(sheet.getBytes(), sheet.getName() + "-检查.xlsx");
} else { } else {
return baseResponse; return baseResponse;
} }

@ -73,16 +73,16 @@ public class DictItemAjax {
public Object imports(MultipartFile file) { public Object imports(MultipartFile file) {
BaseResponse baseResponse = new BaseResponse(); BaseResponse baseResponse = new BaseResponse();
try { try {
WExcel<DictItem> sheet = new WExcel<>(file.getBytes(), DictItem.class, new WExcel.Validator<DictItem>() { WExcel sheet = new WExcel<>(DictItem.class).loadData(file.getBytes(), new WExcel.Processor<DictItem>() {
@Override @Override
public List<String> validate(DictItem o) { public List<String> exec(DictItem o) {
DictItemCreateRequest request = MapperUtil.map(o, DictItemCreateRequest.class); DictItemCreateRequest request = MapperUtil.map(o, DictItemCreateRequest.class);
return ValidationUtil.validate(request); return ValidationUtil.validate(request);
} }
}); });
if (sheet.hasError()) { if (sheet.hasError()) {
return ResponseUtil.apply(sheet.getBytes(true), sheet.getName() + "-检查.xlsx"); return ResponseUtil.apply(sheet.getBytes(), sheet.getName() + "-检查.xlsx");
} else { } else {
return baseResponse; return baseResponse;
} }

@ -73,9 +73,9 @@ public class FileAjax {
public Object imports(MultipartFile file) { public Object imports(MultipartFile file) {
BaseResponse baseResponse = new BaseResponse(); BaseResponse baseResponse = new BaseResponse();
try { try {
WExcel<File> sheet = new WExcel<>(file.getBytes(), File.class, new WExcel.Validator<File>() { WExcel sheet = new WExcel<>(File.class).loadData(file.getBytes(), new WExcel.Processor<File>() {
@Override @Override
public List<String> validate(File o) { public List<String> exec(File o) {
FileCreateRequest request = MapperUtil.map(o, FileCreateRequest.class); FileCreateRequest request = MapperUtil.map(o, FileCreateRequest.class);
return ValidationUtil.validate(request); return ValidationUtil.validate(request);
} }

@ -79,9 +79,9 @@ public class ResAjax {
public Object imports(MultipartFile file) { public Object imports(MultipartFile file) {
BaseResponse baseResponse = new BaseResponse(); BaseResponse baseResponse = new BaseResponse();
try { try {
WExcel<Res> sheet = new WExcel<>(file.getBytes(), Res.class, new WExcel.Validator<Res>() { WExcel sheet = new WExcel<>(Res.class).loadData(file.getBytes(), new WExcel.Processor<Res>() {
@Override @Override
public List<String> validate(Res o) { public List<String> exec(Res o) {
ResCreateRequest request = MapperUtil.map(o, ResCreateRequest.class); ResCreateRequest request = MapperUtil.map(o, ResCreateRequest.class);
return ValidationUtil.validate(request); return ValidationUtil.validate(request);
} }

@ -73,9 +73,9 @@ public class RoleAjax {
public Object imports(MultipartFile file) { public Object imports(MultipartFile file) {
BaseResponse baseResponse = new BaseResponse(); BaseResponse baseResponse = new BaseResponse();
try { try {
WExcel<Role> sheet = new WExcel<>(file.getBytes(), Role.class, new WExcel.Validator<Role>() { WExcel sheet = new WExcel<>(Role.class).loadData(file.getBytes(), new WExcel.Processor<Role>() {
@Override @Override
public List<String> validate(Role o) { public List<String> exec(Role o) {
RoleCreateRequest request = MapperUtil.map(o, RoleCreateRequest.class); RoleCreateRequest request = MapperUtil.map(o, RoleCreateRequest.class);
return ValidationUtil.validate(request); return ValidationUtil.validate(request);
} }

@ -79,9 +79,9 @@ public class TokensAjax {
public Object imports(MultipartFile file) { public Object imports(MultipartFile file) {
BaseResponse baseResponse = new BaseResponse(); BaseResponse baseResponse = new BaseResponse();
try { try {
WExcel<Tokens> sheet = new WExcel<>(file.getBytes(), Tokens.class, new WExcel.Validator<Tokens>() { WExcel sheet = new WExcel<>(Tokens.class).loadData(file.getBytes(), new WExcel.Processor<Tokens>() {
@Override @Override
public List<String> validate(Tokens o) { public List<String> exec(Tokens o) {
TokensCreateRequest request = MapperUtil.map(o, TokensCreateRequest.class); TokensCreateRequest request = MapperUtil.map(o, TokensCreateRequest.class);
return ValidationUtil.validate(request); return ValidationUtil.validate(request);
} }

@ -170,7 +170,6 @@ public class UserAjax {
return response; return response;
} }
Cookie cookie = CookieUtil.newCookie("token", tokensCreateRequest.getToken()); Cookie cookie = CookieUtil.newCookie("token", tokensCreateRequest.getToken());
cookie.setPath("/");
httpServletResponse.addCookie(cookie); httpServletResponse.addCookie(cookie);
response.setToken(tokensCreateRequest.getToken()); response.setToken(tokensCreateRequest.getToken());
} }
@ -181,17 +180,16 @@ public class UserAjax {
public UserLogoutResponse logout(UserLogoutRequest request) { public UserLogoutResponse logout(UserLogoutRequest request) {
UserLogoutResponse response = new UserLogoutResponse(); UserLogoutResponse response = new UserLogoutResponse();
TokensLogoutRequest tokensLogoutRequest = new TokensLogoutRequest(); if (LocalData.getToken() != null) {
tokensLogoutRequest.setToken(LocalData.getToken().getToken()); TokensLogoutRequest tokensLogoutRequest = new TokensLogoutRequest();
TokensLogoutResponse tokensLogoutResponse = tokensManager.logout(tokensLogoutRequest, LocalData.getSysToken()); tokensLogoutRequest.setToken(LocalData.getToken().getToken());
if (tokensLogoutResponse.hasError()) { TokensLogoutResponse tokensLogoutResponse = tokensManager.logout(tokensLogoutRequest, LocalData.getSysToken());
response.addErrors(tokensLogoutResponse.getErrors()); if (tokensLogoutResponse.hasError()) {
return response; response.addErrors(tokensLogoutResponse.getErrors());
return response;
}
} }
CookieUtil.clearCookie("token");
HttpServletResponse HttpServletResponse = LocalData.getResponse();
Cookie token = CookieUtil.newCookie("token", "");
HttpServletResponse.addCookie(token);
return response; return response;
} }
@ -214,9 +212,9 @@ public class UserAjax {
public Object imports(MultipartFile file) { public Object imports(MultipartFile file) {
BaseResponse baseResponse = new BaseResponse(); BaseResponse baseResponse = new BaseResponse();
try { try {
WExcel<User> sheet = new WExcel<>(file.getBytes(), User.class, new WExcel.Validator<User>() { WExcel sheet = new WExcel<>(User.class).loadData(file.getBytes(), new WExcel.Processor<User>() {
@Override @Override
public List<String> validate(User o) { public List<String> exec(User o) {
UserCreateRequest request = MapperUtil.map(o, UserCreateRequest.class); UserCreateRequest request = MapperUtil.map(o, UserCreateRequest.class);
return ValidationUtil.validate(request); return ValidationUtil.validate(request);
} }

@ -15,8 +15,13 @@ import org.springframework.security.web.access.intercept.FilterSecurityIntercept
import ${basePackage}.frame.auth.LocalData; import ${basePackage}.frame.auth.LocalData;
import ${basePackage}.frame.base.Token; import ${basePackage}.frame.base.Token;
import ${basePackage}.frame.utils.CookieUtil; import ${basePackage}.frame.utils.CookieUtil;
import ${basePackage}.frame.utils.IDgenerator;
import ${basePackage}.module.system.mgr.ResManager;
import ${basePackage}.module.system.mgr.TokensManager; import ${basePackage}.module.system.mgr.TokensManager;
import ${basePackage}.module.system.req.ResCreateRequest;
import ${basePackage}.module.system.req.ResFindRequest;
import ${basePackage}.module.system.req.TokensBuildRequest; import ${basePackage}.module.system.req.TokensBuildRequest;
import ${basePackage}.module.system.rsp.ResFindResponse;
import ${basePackage}.module.system.rsp.TokensBuildResponse; import ${basePackage}.module.system.rsp.TokensBuildResponse;
import javax.servlet.Filter; import javax.servlet.Filter;
@ -119,9 +124,36 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
return new Object() { return new Object() {
public boolean hasPermission(HttpServletRequest request, Authentication authentication) { public boolean hasPermission(HttpServletRequest request, Authentication authentication) {
// 授权
Token token_ = LocalData.getToken(); Token token_ = LocalData.getToken();
if (token_ != null && token_.hasRes(request.getServletPath())) { if (token_ == null) {
return false;
}
String path = request.getServletPath();
String[] profiles = LocalData.getEnvironment().getActiveProfiles();
for (String profile : profiles) {
if (profile.contains("dev")) {//测试环境捕获资源
ResFindRequest resFindRequest = new ResFindRequest();
resFindRequest.setPageSize(0);
resFindRequest.setResValue(request.getServletPath());
ResManager resManager = LocalData.getBean(ResManager.class);
ResFindResponse resFindResponse = resManager.find(resFindRequest, LocalData.getSysToken());
if (resFindResponse.getResult().size() == 0) {//资源不存在,主动收集资源
ResCreateRequest resCreateRequest = new ResCreateRequest();
resCreateRequest.setResCode(IDgenerator.nextUUID());
resCreateRequest.setResName("默认");
resCreateRequest.setResValue(path);
resCreateRequest.setValid(true);
resCreateRequest.setResType("");
resManager.create(resCreateRequest, LocalData.getSysToken());
}
}
}
// 授权
if (token_.hasRes(path)) {
return true; return true;
} }

@ -81,8 +81,7 @@ public class LocalData {
return getApplicationContext().getBean(t); return getApplicationContext().getBean(t);
} }
public static String getProp(String key) { public static Environment getEnvironment() {
Environment env = getBean(Environment.class); return getBean(Environment.class);
return env.getProperty(key, "");
} }
} }

@ -198,6 +198,10 @@ public class WExcel<T> implements Serializable, Cloneable {
return columnList; return columnList;
} }
public WExcel loadData(List<T> list) {
return loadData(list, null);
}
/** /**
* <br/> * <br/>
* *

@ -3,6 +3,7 @@ package ${basePackage}.frame.utils;
import ${basePackage}.frame.auth.LocalData; import ${basePackage}.frame.auth.LocalData;
import javax.servlet.http.Cookie; import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/** /**
* CookieUtil * CookieUtil
@ -37,15 +38,30 @@ public class CookieUtil {
/** /**
* Cookie * Cookie
* *
* @param key * @param name
* @param value * @param value
* @return passportID
*/ */
public static Cookie newCookie(String key, String value) { public static Cookie newCookie(String name, String value) {
HttpServletRequest request = LocalData.getRequest(); HttpServletRequest request = LocalData.getRequest();
Cookie cookie = new Cookie(key, value); Cookie cookie = new Cookie(name, value);
cookie.setDomain(request.getServerName()); cookie.setDomain(request.getServerName());
cookie.setPath(request.getContextPath()); cookie.setMaxAge(-1);
cookie.setPath("/");
return cookie; return cookie;
} }
}
/**
* Cookie
*
* @param name
*/
public static void clearCookie(String name) {
HttpServletRequest request = LocalData.getRequest();
HttpServletResponse response = LocalData.getResponse();
Cookie cookie = new Cookie(name, null);
cookie.setDomain(request.getServerName());
cookie.setMaxAge(0);
cookie.setPath("/");
response.addCookie(cookie);
}
}

@ -66,6 +66,8 @@ public class User extends BaseEntity {
private String roleNames; private String roleNames;
private String roleCodes;
public String getUserName() { public String getUserName() {
return this.userName; return this.userName;
} }
@ -137,4 +139,12 @@ public class User extends BaseEntity {
public void setRoleNames(String roleNames) { public void setRoleNames(String roleNames) {
this.roleNames = roleNames; this.roleNames = roleNames;
} }
public String getRoleCodes() {
return roleCodes;
}
public void setRoleCodes(String roleCodes) {
this.roleCodes = roleCodes;
}
} }

@ -54,6 +54,19 @@ public class RoleManagerImpl implements RoleManager {
return response; return response;
} }
{//检查Code是否重复
RoleFindRequest roleFindRequest = new RoleFindRequest();
roleFindRequest.setCode(request.getCode());
RoleFindResponse roleFindResponse = find(roleFindRequest, token);
if (roleFindResponse.hasError()) {
response.addErrors(roleFindResponse.getErrors());
return response;
} else if (roleFindResponse.getResult().size() > 0) {
response.addError(ErrorType.BUSINESS_ERROR, "[" + request.getCode() + "]已存在");
return response;
}
}
long id = IDgenerator.nextId(); long id = IDgenerator.nextId();
Role entity = MapperUtil.map(request, Role.class); Role entity = MapperUtil.map(request, Role.class);
entity.setId(id); entity.setId(id);

@ -252,7 +252,7 @@ public class TokensManagerImpl implements xyz.wbsite.module.system.mgr.TokensMan
// 获取用户的资源 // 获取用户的资源
ResFindRequest resFindRequest = new ResFindRequest(); ResFindRequest resFindRequest = new ResFindRequest();
resFindRequest.setPageSize(0); resFindRequest.setPageSize(0);
resFindRequest.setUserId(token.getUserId()); resFindRequest.setUserId(tokens.getUserId());
ResFindResponse resFindResponse = resManager.find(resFindRequest, token); ResFindResponse resFindResponse = resManager.find(resFindRequest, token);
if (resFindResponse.hasError()) { if (resFindResponse.hasError()) {
response.addErrors(resFindResponse.getErrors()); response.addErrors(resFindResponse.getErrors());

@ -15,9 +15,11 @@ import ${basePackage}.frame.utils.MapperUtil;
import ${basePackage}.frame.utils.Message; import ${basePackage}.frame.utils.Message;
import ${basePackage}.frame.utils.ValidationUtil; import ${basePackage}.frame.utils.ValidationUtil;
import ${basePackage}.module.system.ent.Dept; import ${basePackage}.module.system.ent.Dept;
import ${basePackage}.module.system.ent.Role;
import ${basePackage}.module.system.ent.User; import ${basePackage}.module.system.ent.User;
import ${basePackage}.module.system.mpr.UserMapper; import ${basePackage}.module.system.mpr.UserMapper;
import ${basePackage}.module.system.req.DeptFindRequest; import ${basePackage}.module.system.req.DeptFindRequest;
import ${basePackage}.module.system.req.RoleFindRequest;
import ${basePackage}.module.system.req.UserCreateRequest; import ${basePackage}.module.system.req.UserCreateRequest;
import ${basePackage}.module.system.req.UserDeleteRequest; import ${basePackage}.module.system.req.UserDeleteRequest;
import ${basePackage}.module.system.req.UserFindRequest; import ${basePackage}.module.system.req.UserFindRequest;
@ -25,6 +27,7 @@ import ${basePackage}.module.system.req.UserGetRequest;
import ${basePackage}.module.system.req.UserRoleCreateRequest; import ${basePackage}.module.system.req.UserRoleCreateRequest;
import ${basePackage}.module.system.req.UserUpdateRequest; import ${basePackage}.module.system.req.UserUpdateRequest;
import ${basePackage}.module.system.rsp.DeptFindResponse; import ${basePackage}.module.system.rsp.DeptFindResponse;
import ${basePackage}.module.system.rsp.RoleFindResponse;
import ${basePackage}.module.system.rsp.UserCreateResponse; import ${basePackage}.module.system.rsp.UserCreateResponse;
import ${basePackage}.module.system.rsp.UserDeleteResponse; import ${basePackage}.module.system.rsp.UserDeleteResponse;
import ${basePackage}.module.system.rsp.UserFindResponse; import ${basePackage}.module.system.rsp.UserFindResponse;
@ -48,6 +51,8 @@ public class UserManagerImpl implements UserManager {
@Autowired @Autowired
private DeptManager deptManager; private DeptManager deptManager;
@Autowired @Autowired
private RoleManager roleManager;
@Autowired
private UserRoleManager userRoleManager; private UserRoleManager userRoleManager;
/** /**
@ -94,12 +99,26 @@ public class UserManagerImpl implements UserManager {
return response; return response;
} }
for (Long aLong : request.getRoleIdList()) { for (String code : request.getRoleCodeList()) {
RoleFindRequest roleFindRequest = new RoleFindRequest();
roleFindRequest.setCode(code);
RoleFindResponse roleFindResponse = roleManager.find(roleFindRequest, token);
if (roleFindResponse.hasError()) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
response.addErrors(roleFindResponse.getErrors());
return response;
} else if (roleFindResponse.getResult().size() == 0) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
response.addError(ErrorType.BUSINESS_ERROR, "[" + code + "]角色代码不存在!");
return response;
}
Role role = roleFindResponse.getResult().get(0);
UserRoleCreateRequest userRoleCreateRequest = new UserRoleCreateRequest(); UserRoleCreateRequest userRoleCreateRequest = new UserRoleCreateRequest();
userRoleCreateRequest.setUserId(id); userRoleCreateRequest.setUserId(id);
userRoleCreateRequest.setUserCode(null); userRoleCreateRequest.setUserCode(request.getUserCode());
userRoleCreateRequest.setRoleId(aLong); userRoleCreateRequest.setRoleId(role.getId());
userRoleCreateRequest.setRoleCode(null); userRoleCreateRequest.setRoleCode(role.getCode());
UserRoleCreateResponse userRoleCreateResponse = userRoleManager.create(userRoleCreateRequest, token); UserRoleCreateResponse userRoleCreateResponse = userRoleManager.create(userRoleCreateRequest, token);
if (userRoleCreateResponse.hasError()) { if (userRoleCreateResponse.hasError()) {
response.addErrors(userRoleCreateResponse.getErrors()); response.addErrors(userRoleCreateResponse.getErrors());

@ -4,6 +4,9 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${basePackage}.module.system.mpr.ResMapper"> <mapper namespace="${basePackage}.module.system.mpr.ResMapper">
<!--开启缓存-->
<cache/>
<sql id="table">`SYS_RES`</sql> <sql id="table">`SYS_RES`</sql>
<sql id="entityColumnList"> <sql id="entityColumnList">

@ -20,6 +20,7 @@
<result column="DEPT_ID" jdbcType="BIGINT" property="deptId"/> <result column="DEPT_ID" jdbcType="BIGINT" property="deptId"/>
<result column="DEPT_CODE" jdbcType="VARCHAR" property="deptCode"/> <result column="DEPT_CODE" jdbcType="VARCHAR" property="deptCode"/>
<result column="DEPT_NAME" jdbcType="VARCHAR" property="deptName"/> <result column="DEPT_NAME" jdbcType="VARCHAR" property="deptName"/>
<result column="ROLE_CODES" jdbcType="VARCHAR" property="roleCodes"/>
<result column="ROLE_NAMES" jdbcType="VARCHAR" property="roleNames"/> <result column="ROLE_NAMES" jdbcType="VARCHAR" property="roleNames"/>
<result column="ROW_VERSION" jdbcType="BIGINT" property="rowVersion"/> <result column="ROW_VERSION" jdbcType="BIGINT" property="rowVersion"/>
<result column="IS_DELETED" jdbcType="BIT" property="isDeleted"/> <result column="IS_DELETED" jdbcType="BIT" property="isDeleted"/>
@ -31,12 +32,12 @@
<select id="find" resultMap="user"> <select id="find" resultMap="user">
SELECT SELECT
t1.*,t2.ROLE_NAMES t1.*,t2.ROLE_NAMES, t2.ROLE_CODES
FROM FROM
`sys_user` t1, `sys_user` t1,
( (
SELECT SELECT
t2.user_id, GROUP_CONCAT(t3.NAME) ROLE_NAMES t2.user_id, GROUP_CONCAT(t3.NAME) ROLE_NAMES, GROUP_CONCAT(t3.CODE) ROLE_CODES
FROM FROM
`sys_user_role` t2, `sys_user_role` t2,
`sys_role` t3 `sys_role` t3

@ -59,7 +59,7 @@ public class UserCreateRequest extends BaseRequest {
private String deptCode; private String deptCode;
@NotEmpty(message = "[roleIdList]角色主键不能为空") @NotEmpty(message = "[roleIdList]角色主键不能为空")
private List<Long> roleIdList; private List<String> roleCodeList;
public String getUserName() { public String getUserName() {
return this.userName; return this.userName;
@ -109,11 +109,11 @@ public class UserCreateRequest extends BaseRequest {
this.deptCode = deptCode; this.deptCode = deptCode;
} }
public List<Long> getRoleIdList() { public List<String> getRoleCodeList() {
return roleIdList; return roleCodeList;
} }
public void setRoleIdList(List<Long> roleIdList) { public void setRoleCodeList(List<String> roleCodeList) {
this.roleIdList = roleIdList; this.roleCodeList = roleCodeList;
} }
} }

@ -128,7 +128,7 @@ web.login.page=/login.htm
# 拦截验证 # 拦截验证
web.url.auth.included=/,/**/*.htm,/ajax/**,/api/** web.url.auth.included=/,/**/*.htm,/ajax/**,/api/**
# 直接放行 # 直接放行
web.url.auth.excluded=/login.htm,/ajax/system/User/login web.url.auth.excluded=/login.htm,/ajax/system/User/login,/ajax/system/User/logout
# 超级管理员 # 超级管理员
web.url.auth.admin=admin web.url.auth.admin=admin
web.url.auth.pwd=17fac3376f76d65943d1d26d1f7cb1e5 web.url.auth.pwd=17fac3376f76d65943d1d26d1f7cb1e5

@ -128,7 +128,7 @@ web.login.page=/login.htm
# 拦截验证 # 拦截验证
web.url.auth.included=/,/**/*.htm,/ajax/**,/api/** web.url.auth.included=/,/**/*.htm,/ajax/**,/api/**
# 直接放行 # 直接放行
web.url.auth.excluded=/login.htm,/ajax/system/User/login web.url.auth.excluded=/login.htm,/ajax/system/User/login,/ajax/system/User/logout
# 超级管理员 # 超级管理员
web.url.auth.admin=admin web.url.auth.admin=admin
web.url.auth.pwd=17fac3376f76d65943d1d26d1f7cb1e5 web.url.auth.pwd=17fac3376f76d65943d1d26d1f7cb1e5

@ -702,13 +702,14 @@
}, },
template: '' + template: '' +
'<el-cascader ' + '<el-cascader ' +
' :value="value" ' +
' @input="input" ' + ' @input="input" ' +
' :show-all-levels="false" ' + ' :show-all-levels="false" ' +
' :options="options" ' + ' :options="options" ' +
' :clearable="clearable" ' + ' :clearable="clearable" ' +
' :size="size" ' + ' :size="size" ' +
' :props="props" ' + ' :props="props" ' +
' filterable ' + ' filterable ' +
' :placeholder="placeholder">' + ' :placeholder="placeholder">' +
'</el-cascader>' '</el-cascader>'
}) })

@ -315,7 +315,7 @@
case "logout": case "logout":
new Ajax() new Ajax()
.module("system") .module("system")
.target("user") .target("User")
.method("logout") .method("logout")
.post(function (response) { .post(function (response) {
if (response.errors.length > 0) { if (response.errors.length > 0) {

@ -166,8 +166,8 @@
<br> <br>
<el-form-item label="用户角色" prop="roleIdList"> <el-form-item label="用户角色" prop="roleCodeList">
<el-transfer v-model="form.roleIdList" :data="roleList" :titles="['未选角色','已选角色']" style="width: 500px"></el-transfer> <el-transfer v-model="form.roleCodeList" :data="roleList" :titles="['未选角色','已选角色']" style="width: 500px"></el-transfer>
</el-form-item> </el-form-item>
</el-form> </el-form>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
@ -205,7 +205,7 @@
userPwd: "", userPwd: "",
userStatus: "1", userStatus: "1",
deptCode: "", deptCode: "",
roleIdList: [], roleCodeList: [],
rowVersion: "" rowVersion: ""
}, },
formRules: { formRules: {
@ -229,7 +229,7 @@
deptCode: [ deptCode: [
{min: 1, max: 50, message: '部门代码长度在 1 到 50 个字符', trigger: 'blur'} {min: 1, max: 50, message: '部门代码长度在 1 到 50 个字符', trigger: 'blur'}
], ],
roleIdList: [ roleCodeList: [
{required: true, message: '用户角色不能为空', trigger: 'blur'}, {required: true, message: '用户角色不能为空', trigger: 'blur'},
] ]
}, },
@ -265,6 +265,7 @@
this.form.deptId = item.deptId; this.form.deptId = item.deptId;
this.form.deptCode = item.deptCode; this.form.deptCode = item.deptCode;
this.form.deptName = item.deptName; this.form.deptName = item.deptName;
this.form.roleCodeList = item.roleCodes.split(",")
this.form.rowVersion = item.rowVersion; this.form.rowVersion = item.rowVersion;
break; break;
case "delete": case "delete":
@ -287,7 +288,7 @@
} else { } else {
this.roleList = response.result; this.roleList = response.result;
for (var i = 0; i < this.roleList.length; i++) { for (var i = 0; i < this.roleList.length; i++) {
this.roleList[i].key = this.roleList[i].id; this.roleList[i].key = this.roleList[i].code;
this.roleList[i].label = this.roleList[i].name; this.roleList[i].label = this.roleList[i].name;
} }
} }

Loading…
Cancel
Save

Powered by TurnKey Linux.