feat(系统管理-用户管理): 增加辅助信息包含第三方平台账号
This commit is contained in:
parent
4d7578bfc2
commit
bf5bf82a30
@ -24,6 +24,7 @@ import io.dataease.controller.sys.request.SysUserStateRequest;
|
||||
import io.dataease.controller.sys.response.RoleUserItem;
|
||||
import io.dataease.controller.sys.response.SysUserGridResponse;
|
||||
import io.dataease.plugins.common.base.domain.SysUser;
|
||||
import io.dataease.plugins.common.base.domain.SysUserAssist;
|
||||
import io.dataease.service.sys.SysRoleService;
|
||||
import io.dataease.service.sys.SysUserService;
|
||||
import io.swagger.annotations.Api;
|
||||
@ -66,7 +67,7 @@ public class SysUserController {
|
||||
@ApiImplicitParam(name = "request", value = "查询条件", required = true)
|
||||
})
|
||||
public Pager<List<SysUserGridResponse>> userGrid(@PathVariable int goPage, @PathVariable int pageSize,
|
||||
@RequestBody KeyGridRequest request) {
|
||||
@RequestBody KeyGridRequest request) {
|
||||
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
||||
List<SysUserGridResponse> users = sysUserService.query(request);
|
||||
users.forEach(user -> {
|
||||
@ -87,9 +88,9 @@ public class SysUserController {
|
||||
@RequiresPermissions("user:add")
|
||||
@PostMapping("/create")
|
||||
@DeLog(
|
||||
operatetype = SysLogConstants.OPERATE_TYPE.CREATE,
|
||||
sourcetype = SysLogConstants.SOURCE_TYPE.USER,
|
||||
value = "userId"
|
||||
operatetype = SysLogConstants.OPERATE_TYPE.CREATE,
|
||||
sourcetype = SysLogConstants.SOURCE_TYPE.USER,
|
||||
value = "userId"
|
||||
)
|
||||
public void create(@RequestBody SysUserCreateRequest request) {
|
||||
sysUserService.save(request);
|
||||
@ -99,9 +100,9 @@ public class SysUserController {
|
||||
@RequiresPermissions("user:edit")
|
||||
@PostMapping("/update")
|
||||
@DeLog(
|
||||
operatetype = SysLogConstants.OPERATE_TYPE.MODIFY,
|
||||
sourcetype = SysLogConstants.SOURCE_TYPE.USER,
|
||||
value = "userId"
|
||||
operatetype = SysLogConstants.OPERATE_TYPE.MODIFY,
|
||||
sourcetype = SysLogConstants.SOURCE_TYPE.USER,
|
||||
value = "userId"
|
||||
)
|
||||
public void update(@RequestBody SysUserCreateRequest request) {
|
||||
sysUserService.update(request);
|
||||
@ -112,8 +113,8 @@ public class SysUserController {
|
||||
@PostMapping("/delete/{userId}")
|
||||
@ApiImplicitParam(paramType = "path", value = "用户ID", name = "userId", required = true, dataType = "Integer")
|
||||
@DeLog(
|
||||
operatetype = SysLogConstants.OPERATE_TYPE.DELETE,
|
||||
sourcetype = SysLogConstants.SOURCE_TYPE.USER
|
||||
operatetype = SysLogConstants.OPERATE_TYPE.DELETE,
|
||||
sourcetype = SysLogConstants.SOURCE_TYPE.USER
|
||||
)
|
||||
public void delete(@PathVariable("userId") Long userId) {
|
||||
sysUserService.delete(userId);
|
||||
@ -124,9 +125,9 @@ public class SysUserController {
|
||||
@RequiresRoles("1")
|
||||
@PostMapping("/updateStatus")
|
||||
@DeLog(
|
||||
operatetype = SysLogConstants.OPERATE_TYPE.MODIFY,
|
||||
sourcetype = SysLogConstants.SOURCE_TYPE.USER,
|
||||
value = "userId"
|
||||
operatetype = SysLogConstants.OPERATE_TYPE.MODIFY,
|
||||
sourcetype = SysLogConstants.SOURCE_TYPE.USER,
|
||||
value = "userId"
|
||||
)
|
||||
public void updateStatus(@RequestBody SysUserStateRequest request) {
|
||||
sysUserService.updateStatus(request);
|
||||
@ -201,7 +202,7 @@ public class SysUserController {
|
||||
@ApiImplicitParam(name = "request", value = "查询条件", required = true)
|
||||
})
|
||||
public Pager<List<SysRole>> roleGrid(@PathVariable int goPage, @PathVariable int pageSize,
|
||||
@RequestBody BaseGridRequest request) {
|
||||
@RequestBody BaseGridRequest request) {
|
||||
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
|
||||
Pager<List<SysRole>> listPager = PageUtils.setPageInfo(page, sysRoleService.query(request));
|
||||
return listPager;
|
||||
@ -226,4 +227,9 @@ public class SysUserController {
|
||||
authUserService.unlockAccount(username, one.getFrom());
|
||||
}
|
||||
|
||||
@PostMapping("/assistInfo/{userId}")
|
||||
public SysUserAssist assistInfo(@PathVariable("userId") Long userId) {
|
||||
return sysUserService.assistInfo(userId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package io.dataease.controller.sys.request;
|
||||
|
||||
import io.dataease.plugins.common.base.domain.SysUser;
|
||||
import io.dataease.plugins.common.base.domain.SysUserAssist;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
@ -14,4 +15,7 @@ public class SysUserCreateRequest extends SysUser {
|
||||
@ApiModelProperty(value = "角色ID集合", required = true, position = 7)
|
||||
private List<Long> roleIds;
|
||||
|
||||
@ApiModelProperty(value = "辅助信息", required = false, position = 8)
|
||||
private SysUserAssist sysUserAssist;
|
||||
|
||||
}
|
||||
|
||||
@ -1,17 +0,0 @@
|
||||
package io.dataease.ext;
|
||||
|
||||
import io.dataease.plugins.common.base.domain.SysUserAssist;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
@Mapper
|
||||
public interface ExtSysUserAssistMapper {
|
||||
|
||||
@Insert("insert into sys_user_assist values(#{po.userId}, #{po.needFirstNoti})")
|
||||
void save(@Param("po") SysUserAssist po);
|
||||
|
||||
@Select("select * from sys_user_assist where user_id = #{userId}")
|
||||
SysUserAssist query(@Param("userId") Long userId);
|
||||
}
|
||||
@ -14,6 +14,7 @@ import io.dataease.commons.utils.LogUtil;
|
||||
import io.dataease.commons.utils.ServletUtils;
|
||||
import io.dataease.job.sechedule.ScheduleManager;
|
||||
import io.dataease.job.sechedule.strategy.TaskHandler;
|
||||
import io.dataease.plugins.common.base.domain.SysUserAssist;
|
||||
import io.dataease.plugins.common.entity.GlobalTaskEntity;
|
||||
import io.dataease.plugins.common.entity.GlobalTaskInstance;
|
||||
import io.dataease.plugins.config.SpringContextUtil;
|
||||
@ -28,6 +29,7 @@ import io.dataease.plugins.xpack.lark.service.LarkXpackService;
|
||||
import io.dataease.plugins.xpack.wecom.dto.entity.WecomMsgResult;
|
||||
import io.dataease.plugins.xpack.wecom.service.WecomXpackService;
|
||||
import io.dataease.service.chart.ViewExportExcel;
|
||||
import io.dataease.service.sys.SysUserService;
|
||||
import io.dataease.service.system.EmailService;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
@ -154,6 +156,7 @@ public class EmailTaskHandler extends TaskHandler implements Job {
|
||||
|
||||
EmailXpackService emailXpackService = SpringContextUtil.getBean(EmailXpackService.class);
|
||||
AuthUserServiceImpl userService = SpringContextUtil.getBean(AuthUserServiceImpl.class);
|
||||
SysUserService sysUserService = SpringContextUtil.getBean(SysUserService.class);
|
||||
try {
|
||||
XpackEmailTaskRequest taskForm = emailXpackService.taskForm(taskInstance.getTaskId());
|
||||
if (ObjectUtils.isEmpty(taskForm) || CronUtils.taskExpire(taskForm.getEndTime())) {
|
||||
@ -215,17 +218,24 @@ public class EmailTaskHandler extends TaskHandler implements Job {
|
||||
for (int i = 0; i < channels.size(); i++) {
|
||||
String channel = channels.get(i);
|
||||
switch (channel) {
|
||||
case "email" :
|
||||
case "email":
|
||||
if (StringUtils.isNotBlank(recipients))
|
||||
emailService.sendWithImageAndFiles(recipients, emailTemplateDTO.getTitle(), contentStr, bytes, files);
|
||||
emailService.sendWithImageAndFiles(recipients, emailTemplateDTO.getTitle(), contentStr, bytes, files);
|
||||
break;
|
||||
case "wecom" :
|
||||
case "wecom":
|
||||
if (SpringContextUtil.getBean(AuthUserService.class).supportWecom()) {
|
||||
|
||||
List<String> wecomUsers = reciLists.stream().filter(reci -> {
|
||||
List<String> wecomUsers = new ArrayList<>();
|
||||
for (int j = 0; j < reciLists.size(); j++) {
|
||||
String reci = reciLists.get(j);
|
||||
SysUserEntity userBySub = userService.getUserBySub(reci, 4);
|
||||
return ObjectUtils.isNotEmpty(userBySub);
|
||||
}).collect(Collectors.toList());
|
||||
if (ObjectUtils.isEmpty(userBySub)) continue;
|
||||
Long userId = userBySub.getUserId();
|
||||
SysUserAssist sysUserAssist = sysUserService.assistInfo(userId);
|
||||
if (ObjectUtils.isEmpty(sysUserAssist) || StringUtils.isBlank(sysUserAssist.getLarkId()))
|
||||
continue;
|
||||
wecomUsers.add(sysUserAssist.getLarkId());
|
||||
}
|
||||
|
||||
if (CollectionUtils.isNotEmpty(wecomUsers)) {
|
||||
WecomXpackService wecomXpackService = SpringContextUtil.getBean(WecomXpackService.class);
|
||||
WecomMsgResult wecomMsgResult = wecomXpackService.pushOaMsg(wecomUsers, emailTemplateDTO.getTitle(), contentStr, bytes, files);
|
||||
@ -236,12 +246,20 @@ public class EmailTaskHandler extends TaskHandler implements Job {
|
||||
|
||||
}
|
||||
break;
|
||||
case "dingtalk" :
|
||||
case "dingtalk":
|
||||
if (SpringContextUtil.getBean(AuthUserService.class).supportDingtalk()) {
|
||||
List<String> dingTalkUsers = reciLists.stream().filter(reci -> {
|
||||
List<String> dingTalkUsers = new ArrayList<>();
|
||||
for (int j = 0; j < reciLists.size(); j++) {
|
||||
String reci = reciLists.get(j);
|
||||
SysUserEntity userBySub = userService.getUserBySub(reci, 5);
|
||||
return ObjectUtils.isNotEmpty(userBySub);
|
||||
}).collect(Collectors.toList());
|
||||
if (ObjectUtils.isEmpty(userBySub)) continue;
|
||||
Long userId = userBySub.getUserId();
|
||||
SysUserAssist sysUserAssist = sysUserService.assistInfo(userId);
|
||||
if (ObjectUtils.isEmpty(sysUserAssist) || StringUtils.isBlank(sysUserAssist.getLarkId()))
|
||||
continue;
|
||||
dingTalkUsers.add(sysUserAssist.getLarkId());
|
||||
}
|
||||
|
||||
if (CollectionUtils.isNotEmpty(dingTalkUsers)) {
|
||||
DingtalkXpackService dingtalkXpackService = SpringContextUtil.getBean(DingtalkXpackService.class);
|
||||
DingtalkMsgResult dingtalkMsgResult = dingtalkXpackService.pushOaMsg(dingTalkUsers, emailTemplateDTO.getTitle(), contentStr, bytes, files);
|
||||
@ -252,12 +270,20 @@ public class EmailTaskHandler extends TaskHandler implements Job {
|
||||
|
||||
}
|
||||
break;
|
||||
case "lark" :
|
||||
case "lark":
|
||||
if (SpringContextUtil.getBean(AuthUserService.class).supportLark()) {
|
||||
List<String> larkUsers = reciLists.stream().filter(reci -> {
|
||||
List<String> larkUsers = new ArrayList<>();
|
||||
for (int j = 0; j < reciLists.size(); j++) {
|
||||
String reci = reciLists.get(j);
|
||||
SysUserEntity userBySub = userService.getUserBySub(reci, 6);
|
||||
return ObjectUtils.isNotEmpty(userBySub);
|
||||
}).collect(Collectors.toList());
|
||||
if (ObjectUtils.isEmpty(userBySub)) continue;
|
||||
Long userId = userBySub.getUserId();
|
||||
SysUserAssist sysUserAssist = sysUserService.assistInfo(userId);
|
||||
if (ObjectUtils.isEmpty(sysUserAssist) || StringUtils.isBlank(sysUserAssist.getLarkId()))
|
||||
continue;
|
||||
larkUsers.add(sysUserAssist.getLarkId());
|
||||
}
|
||||
|
||||
if (CollectionUtils.isNotEmpty(larkUsers)) {
|
||||
LarkXpackService larkXpackService = SpringContextUtil.getBean(LarkXpackService.class);
|
||||
LarkMsgResult larkMsgResult = larkXpackService.pushOaMsg(larkUsers, emailTemplateDTO.getTitle(), contentStr, bytes, files);
|
||||
|
||||
@ -1,13 +1,17 @@
|
||||
package io.dataease.service.message.service.strategy;
|
||||
|
||||
import io.dataease.auth.entity.SysUserEntity;
|
||||
import io.dataease.auth.service.AuthUserService;
|
||||
import io.dataease.plugins.common.base.domain.SysUserAssist;
|
||||
import io.dataease.plugins.config.SpringContextUtil;
|
||||
import io.dataease.plugins.xpack.dingtalk.service.DingtalkXpackService;
|
||||
import io.dataease.service.message.service.SendService;
|
||||
import io.dataease.service.sys.SysUserService;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -17,12 +21,14 @@ public class SendDingtalk implements SendService {
|
||||
@Autowired
|
||||
private AuthUserService authUserService;
|
||||
|
||||
@Resource
|
||||
private SysUserService sysUserService;
|
||||
|
||||
@Override
|
||||
public void sendMsg(Long userId, Long typeId, String content, String param) {
|
||||
SysUserEntity userEntity = authUserService.getUserById(userId);
|
||||
|
||||
if (userEntity.getFrom() == 5 && authUserService.supportDingtalk()) {
|
||||
String username = userEntity.getUsername();
|
||||
SysUserAssist sysUserAssist = sysUserService.assistInfo(userId);
|
||||
if (ObjectUtils.isNotEmpty(sysUserAssist) && StringUtils.isNotBlank(sysUserAssist.getDingtalkId()) && authUserService.supportDingtalk()) {
|
||||
String username = sysUserAssist.getDingtalkId();
|
||||
DingtalkXpackService dingtalkXpackService = SpringContextUtil.getBean(DingtalkXpackService.class);
|
||||
List<String> userIds = new ArrayList<>();
|
||||
userIds.add(username);
|
||||
|
||||
@ -1,13 +1,17 @@
|
||||
package io.dataease.service.message.service.strategy;
|
||||
|
||||
import io.dataease.auth.entity.SysUserEntity;
|
||||
import io.dataease.auth.service.AuthUserService;
|
||||
import io.dataease.plugins.common.base.domain.SysUserAssist;
|
||||
import io.dataease.plugins.config.SpringContextUtil;
|
||||
import io.dataease.plugins.xpack.lark.service.LarkXpackService;
|
||||
import io.dataease.service.message.service.SendService;
|
||||
import io.dataease.service.sys.SysUserService;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -17,12 +21,14 @@ public class SendLark implements SendService {
|
||||
@Autowired
|
||||
private AuthUserService authUserService;
|
||||
|
||||
@Resource
|
||||
private SysUserService sysUserService;
|
||||
|
||||
@Override
|
||||
public void sendMsg(Long userId, Long typeId, String content, String param) {
|
||||
SysUserEntity userEntity = authUserService.getUserById(userId);
|
||||
|
||||
if (userEntity.getFrom() == 6 && authUserService.supportLark()) {
|
||||
String username = userEntity.getUsername();
|
||||
SysUserAssist sysUserAssist = sysUserService.assistInfo(userId);
|
||||
if (ObjectUtils.isNotEmpty(sysUserAssist) && StringUtils.isNotBlank(sysUserAssist.getLarkId()) && authUserService.supportLark()) {
|
||||
String username = sysUserAssist.getLarkId();
|
||||
LarkXpackService larkXpackService = SpringContextUtil.getBean(LarkXpackService.class);
|
||||
List<String> userIds = new ArrayList<>();
|
||||
userIds.add(username);
|
||||
|
||||
@ -1,13 +1,17 @@
|
||||
package io.dataease.service.message.service.strategy;
|
||||
|
||||
import io.dataease.auth.entity.SysUserEntity;
|
||||
import io.dataease.auth.service.AuthUserService;
|
||||
import io.dataease.plugins.common.base.domain.SysUserAssist;
|
||||
import io.dataease.plugins.config.SpringContextUtil;
|
||||
import io.dataease.plugins.xpack.wecom.service.WecomXpackService;
|
||||
import io.dataease.service.message.service.SendService;
|
||||
import io.dataease.service.sys.SysUserService;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -16,12 +20,16 @@ public class SendWecom implements SendService {
|
||||
|
||||
@Autowired
|
||||
private AuthUserService authUserService;
|
||||
|
||||
@Resource
|
||||
private SysUserService sysUserService;
|
||||
|
||||
@Override
|
||||
public void sendMsg(Long userId, Long typeId, String content, String param) {
|
||||
SysUserEntity userEntity = authUserService.getUserById(userId);
|
||||
SysUserAssist sysUserAssist = sysUserService.assistInfo(userId);
|
||||
if (ObjectUtils.isNotEmpty(sysUserAssist) && StringUtils.isNotBlank(sysUserAssist.getWecomId()) && authUserService.supportWecom()) {
|
||||
|
||||
if (userEntity.getFrom() == 4 && authUserService.supportWecom()) {
|
||||
String username = userEntity.getUsername();
|
||||
String username = sysUserAssist.getWecomId();
|
||||
WecomXpackService wecomXpackService = SpringContextUtil.getBean(WecomXpackService.class);
|
||||
List<String> userIds = new ArrayList<>();
|
||||
userIds.add(username);
|
||||
|
||||
@ -5,7 +5,6 @@ import io.dataease.auth.service.AuthUserService;
|
||||
import io.dataease.auth.service.ExtAuthService;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.controller.sys.request.*;
|
||||
import io.dataease.ext.ExtSysUserAssistMapper;
|
||||
import io.dataease.ext.ExtSysUserMapper;
|
||||
import io.dataease.ext.query.GridExample;
|
||||
import io.dataease.commons.constants.AuthConstants;
|
||||
@ -16,6 +15,7 @@ import io.dataease.controller.sys.response.SysUserGridResponse;
|
||||
import io.dataease.controller.sys.response.SysUserRole;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.*;
|
||||
import io.dataease.plugins.common.base.mapper.SysUserAssistMapper;
|
||||
import io.dataease.plugins.common.base.mapper.SysUserMapper;
|
||||
import io.dataease.plugins.common.base.mapper.SysUsersRolesMapper;
|
||||
import io.dataease.plugins.common.entity.XpackLdapUserEntity;
|
||||
@ -36,6 +36,7 @@ import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@ -57,8 +58,9 @@ public class SysUserService {
|
||||
@Resource
|
||||
private ExtAuthService extAuthService;
|
||||
|
||||
|
||||
@Resource
|
||||
private ExtSysUserAssistMapper extSysUserAssistMapper;
|
||||
private SysUserAssistMapper sysUserAssistMapper;
|
||||
|
||||
@Resource
|
||||
private AuthUserService authUserService;
|
||||
@ -99,8 +101,15 @@ public class SysUserService {
|
||||
}
|
||||
int insert = sysUserMapper.insert(user);
|
||||
SysUser dbUser = findOne(user);
|
||||
request.setUserId(dbUser.getUserId());
|
||||
saveUserRoles(dbUser.getUserId(), request.getRoleIds());//插入用户角色关联
|
||||
Long userId = dbUser.getUserId();
|
||||
request.setUserId(userId);
|
||||
saveUserRoles(userId, request.getRoleIds());//插入用户角色关联
|
||||
|
||||
SysUserAssist sysUserAssist = request.getSysUserAssist();
|
||||
if (ObjectUtils.isNotEmpty(sysUserAssist) && (StringUtils.isNotBlank(sysUserAssist.getWecomId()) || StringUtils.isNotBlank(sysUserAssist.getDingtalkId()) || StringUtils.isNotBlank(sysUserAssist.getLarkId()))) {
|
||||
saveAssist(userId, sysUserAssist.getWecomId(), sysUserAssist.getDingtalkId(), sysUserAssist.getLarkId());
|
||||
}
|
||||
|
||||
return insert;
|
||||
}
|
||||
|
||||
@ -125,12 +134,12 @@ public class SysUserService {
|
||||
// oidc默认角色是普通员工
|
||||
List<Long> roleIds = new ArrayList<Long>();
|
||||
roleIds.add(2L);
|
||||
saveUserRoles( dbUser.getUserId(), roleIds);
|
||||
saveUserRoles(dbUser.getUserId(), roleIds);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void saveWecomCUser(Map<String, Object> userMap , String userId, String email) {
|
||||
public void saveWecomCUser(Map<String, Object> userMap, String userId, String email) {
|
||||
long now = System.currentTimeMillis();
|
||||
SysUser sysUser = new SysUser();
|
||||
|
||||
@ -148,6 +157,7 @@ public class SysUserService {
|
||||
sysUser.setIsAdmin(false);
|
||||
sysUser.setSub(userId);
|
||||
sysUserMapper.insert(sysUser);
|
||||
Optional.ofNullable(findOne(sysUser)).ifPresent(u -> saveAssist(u.getUserId(), u.getUsername(), null, null));
|
||||
|
||||
}
|
||||
|
||||
@ -170,7 +180,7 @@ public class SysUserService {
|
||||
sysUser.setSub(dingUserEntity.getUnionid());
|
||||
sysUser.setPhone(dingUserEntity.getMobile());
|
||||
sysUserMapper.insert(sysUser);
|
||||
|
||||
Optional.ofNullable(findOne(sysUser)).ifPresent(u -> saveAssist(u.getUserId(), null, u.getUsername(), null));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@ -192,7 +202,7 @@ public class SysUserService {
|
||||
sysUser.setSub(larkUserInfo.getSub());
|
||||
sysUser.setPhone(larkUserInfo.getMobile());
|
||||
sysUserMapper.insert(sysUser);
|
||||
|
||||
Optional.ofNullable(findOne(sysUser)).ifPresent(u -> saveAssist(u.getUserId(), null, null, u.getUsername()));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@ -215,7 +225,7 @@ public class SysUserService {
|
||||
// oidc默认角色是普通员工
|
||||
List<Long> roleIds = new ArrayList<Long>();
|
||||
roleIds.add(2L);
|
||||
saveUserRoles( dbUser.getUserId(), roleIds);
|
||||
saveUserRoles(dbUser.getUserId(), roleIds);
|
||||
}
|
||||
}
|
||||
|
||||
@ -247,7 +257,7 @@ public class SysUserService {
|
||||
sysUserMapper.insert(sysUser);
|
||||
SysUser dbUser = findOne(sysUser);
|
||||
if (null != dbUser && null != dbUser.getUserId()) {
|
||||
saveUserRoles( dbUser.getUserId(), request.getRoleIds());
|
||||
saveUserRoles(dbUser.getUserId(), request.getRoleIds());
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -285,7 +295,13 @@ public class SysUserService {
|
||||
saveUserRoles(user.getUserId(), request.getRoleIds());//再插入角色关联
|
||||
if (ObjectUtils.isEmpty(user.getDeptId())) user.setDeptId(0L);
|
||||
authUserService.clearCache(user.getUserId());
|
||||
return sysUserMapper.updateByPrimaryKeySelective(user);
|
||||
int result = sysUserMapper.updateByPrimaryKeySelective(user);
|
||||
|
||||
SysUserAssist sysUserAssist = request.getSysUserAssist();
|
||||
if (ObjectUtils.isNotEmpty(sysUserAssist) && (StringUtils.isNotBlank(sysUserAssist.getWecomId()) || StringUtils.isNotBlank(sysUserAssist.getDingtalkId()) || StringUtils.isNotBlank(sysUserAssist.getLarkId()))) {
|
||||
saveAssist(user.getUserId(), sysUserAssist.getWecomId(), sysUserAssist.getDingtalkId(), sysUserAssist.getLarkId());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -308,6 +324,7 @@ public class SysUserService {
|
||||
* 更新用户基本信息
|
||||
* 只允许修改 email, nickname, phone
|
||||
* 防止此接口被恶意利用更改不允许更改的信息,新建SysUser对象并只设置部分值
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@ -426,33 +443,34 @@ public class SysUserService {
|
||||
SysUserExample example = new SysUserExample();
|
||||
example.createCriteria().andUsernameEqualTo(userName);
|
||||
List<SysUser> users = sysUserMapper.selectByExample(example);
|
||||
if(CollectionUtils.isNotEmpty(users)) {
|
||||
throw new RuntimeException("用户ID【"+userName+"】已存在,请联系管理员");
|
||||
if (CollectionUtils.isNotEmpty(users)) {
|
||||
throw new RuntimeException("用户ID【" + userName + "】已存在,请联系管理员");
|
||||
}
|
||||
}
|
||||
|
||||
public void validateExistUser(String userName, String nickName, String email) {
|
||||
SysUserExample example = new SysUserExample();
|
||||
if (StringUtils.isNotBlank(userName)) {
|
||||
example.createCriteria().andUsernameEqualTo(userName);
|
||||
List<SysUser> users = sysUserMapper.selectByExample(example);
|
||||
if(CollectionUtils.isNotEmpty(users)) {
|
||||
throw new RuntimeException("用户ID【"+userName+"】已存在,请联系管理员");
|
||||
if (CollectionUtils.isNotEmpty(users)) {
|
||||
throw new RuntimeException("用户ID【" + userName + "】已存在,请联系管理员");
|
||||
}
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(nickName)) {
|
||||
example.createCriteria().andNickNameEqualTo(nickName);
|
||||
List<SysUser> users = sysUserMapper.selectByExample(example);
|
||||
if(CollectionUtils.isNotEmpty(users)) {
|
||||
throw new RuntimeException("用户姓名【"+nickName+"】已存在,请联系管理员");
|
||||
if (CollectionUtils.isNotEmpty(users)) {
|
||||
throw new RuntimeException("用户姓名【" + nickName + "】已存在,请联系管理员");
|
||||
}
|
||||
}
|
||||
example.clear();
|
||||
if (StringUtils.isNotBlank(email)) {
|
||||
example.createCriteria().andEmailEqualTo(email);
|
||||
List<SysUser> users = sysUserMapper.selectByExample(example);
|
||||
if(CollectionUtils.isNotEmpty(users)) {
|
||||
throw new RuntimeException("用户邮箱【"+email+"】已存在,请联系管理员");
|
||||
if (CollectionUtils.isNotEmpty(users)) {
|
||||
throw new RuntimeException("用户邮箱【" + email + "】已存在,请联系管理员");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -510,16 +528,43 @@ public class SysUserService {
|
||||
}
|
||||
|
||||
public boolean needPwdNoti(Long userId) {
|
||||
SysUserAssist userAssist = extSysUserAssistMapper.query(userId);
|
||||
SysUserAssist userAssist = sysUserAssistMapper.selectByPrimaryKey(userId);
|
||||
return ObjectUtils.isEmpty(userAssist) || userAssist.getNeedFirstNoti();
|
||||
}
|
||||
|
||||
public void saveUserAssist(Boolean noti) {
|
||||
Long userId = AuthUtils.getUser().getUserId();
|
||||
SysUserAssist existAssist = sysUserAssistMapper.selectByPrimaryKey(userId);
|
||||
if (ObjectUtils.isNotEmpty(existAssist)) {
|
||||
existAssist.setNeedFirstNoti(noti);
|
||||
sysUserAssistMapper.updateByPrimaryKey(existAssist);
|
||||
return;
|
||||
}
|
||||
SysUserAssist sysUserAssist = new SysUserAssist();
|
||||
sysUserAssist.setUserId(userId);
|
||||
sysUserAssist.setNeedFirstNoti(noti);
|
||||
extSysUserAssistMapper.save(sysUserAssist);
|
||||
sysUserAssistMapper.insertSelective(sysUserAssist);
|
||||
}
|
||||
|
||||
public void saveAssist(Long userId, String wecomId, String dingtlkId, String larkId) {
|
||||
SysUserAssist existAssist = sysUserAssistMapper.selectByPrimaryKey(userId);
|
||||
if (ObjectUtils.isNotEmpty(existAssist)) {
|
||||
existAssist.setWecomId(wecomId);
|
||||
existAssist.setDingtalkId(dingtlkId);
|
||||
existAssist.setLarkId(larkId);
|
||||
sysUserAssistMapper.updateByPrimaryKey(existAssist);
|
||||
return;
|
||||
}
|
||||
SysUserAssist sysUserAssist = new SysUserAssist();
|
||||
sysUserAssist.setUserId(userId);
|
||||
sysUserAssist.setWecomId(wecomId);
|
||||
sysUserAssist.setDingtalkId(dingtlkId);
|
||||
sysUserAssist.setLarkId(larkId);
|
||||
sysUserAssistMapper.insert(sysUserAssist);
|
||||
}
|
||||
|
||||
public SysUserAssist assistInfo(Long userId) {
|
||||
return sysUserAssistMapper.selectByPrimaryKey(userId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -10,7 +10,8 @@ const pathMap = {
|
||||
updatePath: '/api/user/update',
|
||||
editPasswordPath: '/api/user/adminUpdatePwd',
|
||||
editStatusPath: '/api/user/updateStatus',
|
||||
unlockPath: '/api/user/unlock/'
|
||||
unlockPath: '/api/user/unlock/',
|
||||
queryAssistPath: '/api/user/assistInfo/'
|
||||
}
|
||||
export function userLists(page, size, data) {
|
||||
return request({
|
||||
@ -142,4 +143,12 @@ export function unLock(username) {
|
||||
})
|
||||
}
|
||||
|
||||
export default { editPassword, delUser, editUser, addUser, userLists, editStatus, personInfo, updatePerson, updatePersonPwd, allRoles, roleGrid, ldapUsers, saveLdapUser, existLdapUsers, unLock }
|
||||
export function queryAssist(userId) {
|
||||
return request({
|
||||
url: pathMap.queryAssistPath + userId,
|
||||
method: 'post',
|
||||
loading: false
|
||||
})
|
||||
}
|
||||
|
||||
export default { editPassword, delUser, editUser, addUser, userLists, editStatus, personInfo, updatePerson, updatePersonPwd, allRoles, roleGrid, ldapUsers, saveLdapUser, existLdapUsers, unLock, queryAssist }
|
||||
|
||||
@ -132,11 +132,10 @@ export default {
|
||||
},
|
||||
commons: {
|
||||
|
||||
|
||||
unlock: 'Unlock',
|
||||
unlock_success: 'Unlock success',
|
||||
|
||||
uninstall:'Uninstall',
|
||||
uninstall: 'Uninstall',
|
||||
|
||||
no_result: 'No Result',
|
||||
manage_member: 'Managing members',
|
||||
@ -671,7 +670,13 @@ export default {
|
||||
filter: 'Screen',
|
||||
list: 'List item',
|
||||
list_info: 'Please select the information to be displayed in the list',
|
||||
sure_delete: 'Are you sure to delete this user?'
|
||||
sure_delete: 'Are you sure to delete this user?',
|
||||
wecom_id: 'Wecom Account',
|
||||
dingtalk_id: 'Dingtalk Account',
|
||||
lark_id: 'Lark Account',
|
||||
input_wecom_id: 'Please input wecom account',
|
||||
input_dingtalk_id: 'Please input dingtalk account',
|
||||
input_lark_id: 'Please input lark account'
|
||||
},
|
||||
ldap: {
|
||||
url: 'LDAP url',
|
||||
|
||||
@ -132,11 +132,10 @@ export default {
|
||||
},
|
||||
commons: {
|
||||
|
||||
|
||||
unlock: '解鎖',
|
||||
unlock_success: '解鎖成功',
|
||||
|
||||
uninstall:'卸载',
|
||||
uninstall: '卸载',
|
||||
|
||||
no_result: '没有找到相关内容',
|
||||
manage_member: '管理成員',
|
||||
@ -671,7 +670,13 @@ export default {
|
||||
filter: '篩選',
|
||||
list: '列表項',
|
||||
list_info: '請選擇列表中要展示的信息',
|
||||
sure_delete: '確定刪除該用戶嗎?'
|
||||
sure_delete: '確定刪除該用戶嗎?',
|
||||
wecom_id: '企業微信賬號',
|
||||
dingtalk_id: '釘釘賬號',
|
||||
lark_id: '飛書賬號',
|
||||
input_wecom_id: '請輸入企業微信賬號',
|
||||
input_dingtalk_id: '請輸入釘釘賬號',
|
||||
input_lark_id: '請輸入飛書賬號'
|
||||
},
|
||||
ldap: {
|
||||
url: 'LDAP地址',
|
||||
|
||||
@ -134,7 +134,7 @@ export default {
|
||||
|
||||
unlock: '解锁',
|
||||
unlock_success: '解锁成功',
|
||||
uninstall:'卸载',
|
||||
uninstall: '卸载',
|
||||
|
||||
no_result: '没有找到相关内容',
|
||||
manage_member: '管理成员',
|
||||
@ -669,7 +669,13 @@ export default {
|
||||
filter: '筛选',
|
||||
list: '列表项',
|
||||
list_info: '请选择列表中要展示的信息',
|
||||
sure_delete: '确定删除该用户吗?'
|
||||
sure_delete: '确定删除该用户吗?',
|
||||
wecom_id: '企业微信账号',
|
||||
dingtalk_id: '钉钉账号',
|
||||
lark_id: '飞书账号',
|
||||
input_wecom_id: '请输入企业微信账号',
|
||||
input_dingtalk_id: '请输入钉钉账号',
|
||||
input_lark_id: '请输入飞书账号'
|
||||
},
|
||||
ldap: {
|
||||
url: 'LDAP地址',
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
:before-close="reset"
|
||||
>
|
||||
<div v-if="formType === 'add'" class="editer-form-title">
|
||||
<i class="el-icon-info"></i>
|
||||
<i class="el-icon-info" />
|
||||
<span class="pwd" type="text">{{
|
||||
$t("commons.default_pwd") + ":" + defaultPWD
|
||||
}}</span>
|
||||
@ -36,16 +36,16 @@
|
||||
<el-col :span="12">
|
||||
<el-form-item :label="$t('commons.nick_name')" prop="nickName">
|
||||
<el-input
|
||||
:placeholder="$t('user.input_name')"
|
||||
v-model="form.nickName"
|
||||
:placeholder="$t('user.input_name')"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="ID" prop="username">
|
||||
<el-input
|
||||
:placeholder="$t('user.input_id')"
|
||||
v-model="form.username"
|
||||
:placeholder="$t('user.input_id')"
|
||||
:disabled="formType !== 'add'"
|
||||
/>
|
||||
</el-form-item>
|
||||
@ -55,24 +55,24 @@
|
||||
<el-col :span="12">
|
||||
<el-form-item :label="$t('commons.email')" prop="email">
|
||||
<el-input
|
||||
:placeholder="$t('user.input_email')"
|
||||
v-model="form.email"
|
||||
:placeholder="$t('user.input_email')"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item :label="$t('commons.mobile_phone_number')" prop="phone">
|
||||
<el-input
|
||||
:placeholder="$t('commons.mobile_phone')"
|
||||
v-model="form.phone"
|
||||
:placeholder="$t('commons.mobile_phone')"
|
||||
class="input-with-select"
|
||||
>
|
||||
<el-select
|
||||
v-model="form.phonePrefix"
|
||||
slot="prepend"
|
||||
v-model="form.phonePrefix"
|
||||
:placeholder="$t('fu.search_bar.please_select')"
|
||||
>
|
||||
<el-option label="+86" value="+86"></el-option>
|
||||
<el-option label="+86" value="+86" />
|
||||
</el-select>
|
||||
</el-input>
|
||||
</el-form-item>
|
||||
@ -82,14 +82,13 @@
|
||||
<el-col :span="12">
|
||||
<el-form-item :label="$t('commons.gender')" prop="gender">
|
||||
<el-select
|
||||
class="form-gender-select"
|
||||
v-model="form.gender"
|
||||
class="form-gender-select"
|
||||
:placeholder="$t('user.select_gender')"
|
||||
>
|
||||
<el-option :label="$t('commons.man')" value="男"> </el-option>
|
||||
<el-option :label="$t('commons.woman')" value="女"> </el-option>
|
||||
<el-option :label="$t('commons.keep_secret')" value="保密">
|
||||
</el-option>
|
||||
<el-option :label="$t('commons.man')" value="男" />
|
||||
<el-option :label="$t('commons.woman')" value="女" />
|
||||
<el-option :label="$t('commons.keep_secret')" value="保密" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@ -100,37 +99,37 @@
|
||||
prop="deptId"
|
||||
>
|
||||
<el-popover
|
||||
placement="bottom"
|
||||
popper-class="user-popper dept"
|
||||
width="384"
|
||||
trigger="click"
|
||||
>
|
||||
<el-tree
|
||||
v-if="dialogVisible"
|
||||
:load="loadNode"
|
||||
:lazy="true"
|
||||
:expand-on-click-node="false"
|
||||
:data="depts"
|
||||
:props="defaultProps"
|
||||
@node-click="handleNodeClick"
|
||||
></el-tree>
|
||||
|
||||
<el-select
|
||||
ref="roleSelect"
|
||||
v-model="form.deptId"
|
||||
clearable
|
||||
slot="reference"
|
||||
class="form-gender-select"
|
||||
popper-class="tree-select"
|
||||
:placeholder="$t('commons.please_select')"
|
||||
placement="bottom"
|
||||
popper-class="user-popper dept"
|
||||
width="384"
|
||||
trigger="click"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in selectDepts"
|
||||
:key="item.label"
|
||||
:label="item.label"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
<el-tree
|
||||
v-if="dialogVisible"
|
||||
:load="loadNode"
|
||||
:lazy="true"
|
||||
:expand-on-click-node="false"
|
||||
:data="depts"
|
||||
:props="defaultProps"
|
||||
@node-click="handleNodeClick"
|
||||
/>
|
||||
|
||||
<el-select
|
||||
ref="roleSelect"
|
||||
slot="reference"
|
||||
v-model="form.deptId"
|
||||
clearable
|
||||
class="form-gender-select"
|
||||
popper-class="tree-select"
|
||||
:placeholder="$t('commons.please_select')"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in selectDepts"
|
||||
:key="item.label"
|
||||
:label="item.label"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-popover>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@ -165,14 +164,24 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item v-show="isPluginLoaded && wecomOpen" :label="$t('user.wecom_id')">
|
||||
<el-input v-model="form.sysUserAssist.wecomId" :placeholder="$t('user.input_wecom_id')" />
|
||||
</el-form-item>
|
||||
<el-form-item v-show="isPluginLoaded && dingTalkOpen" :label="$t('user.dingtalk_id')">
|
||||
<el-input v-model="form.sysUserAssist.dingtalkId" :placeholder="$t('user.input_dingtalk_id')" />
|
||||
</el-form-item>
|
||||
<el-form-item v-show="isPluginLoaded && larkOpen" :label="$t('user.lark_id')">
|
||||
<el-input v-model="form.sysUserAssist.larkId" :placeholder="$t('user.input_lark_id')" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item :label="$t('commons.status')" prop="enabled">
|
||||
<el-switch
|
||||
:disabled="formType !== 'add' && form.isAdmin"
|
||||
v-model="form.enabled"
|
||||
:disabled="formType !== 'add' && form.isAdmin"
|
||||
:active-value="1"
|
||||
:inactive-value="0"
|
||||
>
|
||||
</el-switch>
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
@ -187,287 +196,335 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { PHONE_REGEX } from "@/utils/validate";
|
||||
import { getDeptTree, treeByDeptId } from "@/api/system/dept";
|
||||
import { addUser, editUser, allRoles } from "@/api/system/user";
|
||||
import { pluginLoaded, defaultPwd } from "@/api/user";
|
||||
import { PHONE_REGEX } from '@/utils/validate'
|
||||
import { getDeptTree, treeByDeptId } from '@/api/system/dept'
|
||||
import { addUser, editUser, allRoles, queryAssist } from '@/api/system/user'
|
||||
import { pluginLoaded, defaultPwd, wecomStatus, dingtalkStatus, larkStatus } from '@/api/user'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
defaultProps: {
|
||||
children: "children",
|
||||
label: "label",
|
||||
isLeaf: "leaf",
|
||||
children: 'children',
|
||||
label: 'label',
|
||||
isLeaf: 'leaf'
|
||||
},
|
||||
selectDepts: [],
|
||||
form: {
|
||||
roles: [
|
||||
{
|
||||
id: "",
|
||||
},
|
||||
id: ''
|
||||
}
|
||||
],
|
||||
sysUserAssist: {
|
||||
wecomId: null,
|
||||
dingtalkId: null,
|
||||
larkId: null
|
||||
}
|
||||
},
|
||||
rule: {
|
||||
username: [
|
||||
{
|
||||
required: true,
|
||||
message: this.$t("user.id_mandatory"),
|
||||
trigger: "blur",
|
||||
message: this.$t('user.id_mandatory'),
|
||||
trigger: 'blur'
|
||||
},
|
||||
{
|
||||
min: 1,
|
||||
max: 50,
|
||||
message: this.$t("commons.input_limit", [1, 50]),
|
||||
trigger: "blur",
|
||||
message: this.$t('commons.input_limit', [1, 50]),
|
||||
trigger: 'blur'
|
||||
},
|
||||
{
|
||||
required: true,
|
||||
pattern: "^[^\u4e00-\u9fa5]+$",
|
||||
message: this.$t("user.special_characters_are_not_supported"),
|
||||
trigger: "blur",
|
||||
},
|
||||
pattern: '^[^\u4e00-\u9fa5]+$',
|
||||
message: this.$t('user.special_characters_are_not_supported'),
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
nickName: [
|
||||
{
|
||||
required: true,
|
||||
message: this.$t("user.name_mandatory"),
|
||||
trigger: "blur",
|
||||
message: this.$t('user.name_mandatory'),
|
||||
trigger: 'blur'
|
||||
},
|
||||
{
|
||||
min: 2,
|
||||
max: 50,
|
||||
message: this.$t("commons.input_limit", [2, 50]),
|
||||
trigger: "blur",
|
||||
message: this.$t('commons.input_limit', [2, 50]),
|
||||
trigger: 'blur'
|
||||
},
|
||||
{
|
||||
required: true,
|
||||
message: this.$t("user.special_characters_are_not_supported"),
|
||||
trigger: "blur",
|
||||
},
|
||||
message: this.$t('user.special_characters_are_not_supported'),
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
phone: [
|
||||
{
|
||||
pattern: PHONE_REGEX,
|
||||
message: this.$t("user.phone_format"),
|
||||
trigger: "blur",
|
||||
},
|
||||
message: this.$t('user.phone_format'),
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
email: [
|
||||
{
|
||||
required: true,
|
||||
message: this.$t("user.email_mandatory"),
|
||||
trigger: "blur",
|
||||
message: this.$t('user.email_mandatory'),
|
||||
trigger: 'blur'
|
||||
},
|
||||
{
|
||||
required: true,
|
||||
pattern: /^[a-zA-Z0-9_._-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/,
|
||||
message: this.$t("user.email_format_is_incorrect"),
|
||||
trigger: "blur",
|
||||
},
|
||||
message: this.$t('user.email_format_is_incorrect'),
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
password: [
|
||||
{
|
||||
required: true,
|
||||
message: this.$t("user.input_password"),
|
||||
trigger: "blur",
|
||||
message: this.$t('user.input_password'),
|
||||
trigger: 'blur'
|
||||
},
|
||||
{
|
||||
required: true,
|
||||
pattern: /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[^]{8,30}$/,
|
||||
message: this.$t("member.password_format_is_incorrect"),
|
||||
trigger: "blur",
|
||||
},
|
||||
message: this.$t('member.password_format_is_incorrect'),
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
confirmPassword: [
|
||||
{
|
||||
required: true,
|
||||
message: this.$t("user.input_password"),
|
||||
trigger: "blur",
|
||||
message: this.$t('user.input_password'),
|
||||
trigger: 'blur'
|
||||
},
|
||||
{ required: true, validator: this.repeatValidator, trigger: "blur" },
|
||||
{ required: true, validator: this.repeatValidator, trigger: 'blur' }
|
||||
],
|
||||
newPassword: [
|
||||
{
|
||||
required: true,
|
||||
message: this.$t("user.input_password"),
|
||||
trigger: "blur",
|
||||
message: this.$t('user.input_password'),
|
||||
trigger: 'blur'
|
||||
},
|
||||
{
|
||||
required: true,
|
||||
pattern: /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[^]{8,30}$/,
|
||||
message: this.$t("member.password_format_is_incorrect"),
|
||||
trigger: "blur",
|
||||
},
|
||||
message: this.$t('member.password_format_is_incorrect'),
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
roleIds: [
|
||||
{
|
||||
required: true,
|
||||
message: this.$t("user.role_mandatory"),
|
||||
trigger: "change",
|
||||
},
|
||||
message: this.$t('user.role_mandatory'),
|
||||
trigger: 'change'
|
||||
}
|
||||
],
|
||||
deptId: [],
|
||||
gender: [],
|
||||
enabled: [{ required: true, trigger: "change" }],
|
||||
enabled: [{ required: true, trigger: 'change' }]
|
||||
},
|
||||
defaultForm: {
|
||||
id: null,
|
||||
username: null,
|
||||
nickName: null,
|
||||
gender: "男",
|
||||
gender: '男',
|
||||
email: null,
|
||||
enabled: 1,
|
||||
deptId: null,
|
||||
phone: null,
|
||||
phonePrefix: "+86",
|
||||
phonePrefix: '+86',
|
||||
roleIds: [2],
|
||||
sysUserAssist: {
|
||||
wecomId: null,
|
||||
dingtalkId: null,
|
||||
larkId: null
|
||||
}
|
||||
},
|
||||
depts: [],
|
||||
roles: [],
|
||||
roleDatas: [],
|
||||
userRoles: [],
|
||||
formType: "add",
|
||||
formType: 'add',
|
||||
isPluginLoaded: false,
|
||||
defaultPWD: "DataEase123..",
|
||||
defaultPWD: 'DataEase123..',
|
||||
dialogVisible: false,
|
||||
};
|
||||
wecomOpen: false,
|
||||
dingTalkOpen: false,
|
||||
larkOpen: false,
|
||||
assistInfo: {}
|
||||
}
|
||||
},
|
||||
beforeCreate() {
|
||||
pluginLoaded().then((res) => {
|
||||
this.isPluginLoaded = res.success && res.data;
|
||||
});
|
||||
this.isPluginLoaded = res.success && res.data
|
||||
})
|
||||
wecomStatus().then(res => {
|
||||
if (res.success && res.data) {
|
||||
this.wecomOpen = true
|
||||
}
|
||||
})
|
||||
|
||||
dingtalkStatus().then(res => {
|
||||
if (res.success && res.data) {
|
||||
this.dingTalkOpen = true
|
||||
}
|
||||
})
|
||||
|
||||
larkStatus().then(res => {
|
||||
if (res.success && res.data) {
|
||||
this.larkOpen = true
|
||||
}
|
||||
})
|
||||
defaultPwd().then((res) => {
|
||||
if (res && res.data) {
|
||||
this.defaultPWD = res.data;
|
||||
this.defaultPWD = res.data
|
||||
}
|
||||
});
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
repeatValidator(rule, value, callback) {
|
||||
if (value !== this.form.password) {
|
||||
callback(new Error(this.$t("member.inconsistent_passwords")));
|
||||
callback(new Error(this.$t('member.inconsistent_passwords')))
|
||||
} else {
|
||||
callback();
|
||||
callback()
|
||||
}
|
||||
},
|
||||
create() {
|
||||
this.formType = "add";
|
||||
this.form = Object.assign({}, this.defaultForm);
|
||||
this.formType = 'add'
|
||||
this.form = Object.assign({}, JSON.parse(JSON.stringify(this.defaultForm)))
|
||||
},
|
||||
init(row) {
|
||||
this.initRoles();
|
||||
this.dialogVisible = true;
|
||||
if (!row) {
|
||||
this.create();
|
||||
return;
|
||||
}
|
||||
const { deptId:id, deptName:label } = (row.dept || {});
|
||||
this.selectDepts = [{id, label}]
|
||||
this.formType = "modify";
|
||||
this.dialogVisible = true;
|
||||
this.form = Object.assign({}, row);
|
||||
this.form.password = "";
|
||||
if (this.form.deptId === 0) {
|
||||
this.form.deptId = null;
|
||||
}
|
||||
this.initRoles()
|
||||
|
||||
if (!this.form.phonePrefix) {
|
||||
this.form.phonePrefix = '+86';
|
||||
this.dialogVisible = true
|
||||
if (!row) {
|
||||
this.create()
|
||||
return
|
||||
}
|
||||
this.initAssistInfo(row.userId).then(res => {
|
||||
this.assistInfo = res.data
|
||||
const { deptId: id, deptName: label } = (row.dept || {})
|
||||
this.selectDepts = [{ id, label }]
|
||||
this.formType = 'modify'
|
||||
this.dialogVisible = true
|
||||
row.sysUserAssist = JSON.parse(JSON.stringify(this.defaultForm.sysUserAssist))
|
||||
this.form = Object.assign({}, row)
|
||||
this.form.password = ''
|
||||
if (this.form.deptId === 0) {
|
||||
this.form.deptId = null
|
||||
}
|
||||
|
||||
if (!this.form.phonePrefix) {
|
||||
this.form.phonePrefix = '+86'
|
||||
}
|
||||
|
||||
if (this.assistInfo) {
|
||||
const info = JSON.parse(JSON.stringify(this.assistInfo))
|
||||
delete info.needFirstNoti
|
||||
delete info.userId
|
||||
const assist = Object.assign(JSON.parse(JSON.stringify(this.defaultForm.sysUserAssist)), info)
|
||||
this.form.sysUserAssist = assist
|
||||
}
|
||||
})
|
||||
},
|
||||
initRoles() {
|
||||
allRoles().then((res) => {
|
||||
this.roles = res.data;
|
||||
});
|
||||
this.roles = res.data
|
||||
})
|
||||
},
|
||||
initAssistInfo(userId) {
|
||||
return queryAssist(userId)
|
||||
},
|
||||
handleNodeClick({ id, label }) {
|
||||
const [ dept ] = this.selectDepts;
|
||||
const [dept] = this.selectDepts
|
||||
if (!dept || dept.id !== id) {
|
||||
this.selectDepts = [{ id, label }];
|
||||
this.selectDepts = [{ id, label }]
|
||||
this.form.deptId = id
|
||||
return
|
||||
}
|
||||
|
||||
if (dept.id === id) {
|
||||
this.selectDepts = [];
|
||||
this.selectDepts = []
|
||||
this.form.deptId = null
|
||||
}
|
||||
},
|
||||
// 获取弹窗内部门数据
|
||||
treeByDeptId() {
|
||||
treeByDeptId(0).then((res) => {
|
||||
this.depts = (res.data || []).map(ele => {
|
||||
return {
|
||||
this.depts = (res.data || []).map(ele => {
|
||||
return {
|
||||
...ele,
|
||||
leaf: !ele.hasChildren,
|
||||
leaf: !ele.hasChildren
|
||||
}
|
||||
})
|
||||
});
|
||||
})
|
||||
},
|
||||
loadNode(node, resolve) {
|
||||
loadNode(node, resolve) {
|
||||
if (!this.depts.length) {
|
||||
this.treeByDeptId();
|
||||
return;
|
||||
this.treeByDeptId()
|
||||
return
|
||||
}
|
||||
getDeptTree(node.data.id).then((res) => {
|
||||
resolve(
|
||||
res.data.map((dept) => {
|
||||
return this.normalizer(dept);
|
||||
return this.normalizer(dept)
|
||||
})
|
||||
);
|
||||
});
|
||||
)
|
||||
})
|
||||
},
|
||||
normalizer(node) {
|
||||
return {
|
||||
id: node.deptId,
|
||||
label: node.name,
|
||||
leaf: !node.hasChildren,
|
||||
};
|
||||
leaf: !node.hasChildren
|
||||
}
|
||||
},
|
||||
deleteTag(value) {
|
||||
this.userRoles.forEach(
|
||||
function (data, index) {
|
||||
function(data, index) {
|
||||
if (data.id === value) {
|
||||
this.userRoles.splice(index, value);
|
||||
this.userRoles.splice(index, value)
|
||||
}
|
||||
}.bind(this)
|
||||
);
|
||||
)
|
||||
},
|
||||
changeRole(value) {
|
||||
this.userRoles = [];
|
||||
this.userRoles = []
|
||||
value.forEach(
|
||||
function (data, index) {
|
||||
const role = { id: data };
|
||||
this.userRoles.push(role);
|
||||
function(data, index) {
|
||||
const role = { id: data }
|
||||
this.userRoles.push(role)
|
||||
}.bind(this)
|
||||
);
|
||||
)
|
||||
},
|
||||
reset() {
|
||||
this.depts = [];
|
||||
this.$refs.createUserForm.resetFields();
|
||||
this.dialogVisible = false;
|
||||
this.depts = []
|
||||
this.form.sysUserAssist = JSON.parse(JSON.stringify(this.defaultForm.sysUserAssist))
|
||||
this.$refs.createUserForm.resetFields()
|
||||
this.dialogVisible = false
|
||||
},
|
||||
save() {
|
||||
this.$refs.createUserForm.validate((valid) => {
|
||||
if (valid) {
|
||||
// !this.form.deptId && (this.form.deptId = 0)
|
||||
const method = this.formType === "add" ? addUser : editUser;
|
||||
const method = this.formType === 'add' ? addUser : editUser
|
||||
method(this.form).then((res) => {
|
||||
this.$success(this.$t("commons.save_success"));
|
||||
this.reset();
|
||||
this.$success(this.$t('commons.save_success'))
|
||||
this.reset()
|
||||
this.$emit('saved')
|
||||
});
|
||||
})
|
||||
} else {
|
||||
return false;
|
||||
return false
|
||||
}
|
||||
});
|
||||
})
|
||||
},
|
||||
onCopy(e) {
|
||||
this.$success(this.$t("commons.copy_success"));
|
||||
this.$success(this.$t('commons.copy_success'))
|
||||
},
|
||||
onError(e) {},
|
||||
},
|
||||
};
|
||||
onError(e) {}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
@ -590,4 +647,4 @@ export default {
|
||||
height: 300px;
|
||||
overflow: auto;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user