diff --git a/src/main/java/com/bonus/aqgqj/system/controller/UserController.java b/src/main/java/com/bonus/aqgqj/system/controller/UserController.java index e578eee..14cc7b3 100644 --- a/src/main/java/com/bonus/aqgqj/system/controller/UserController.java +++ b/src/main/java/com/bonus/aqgqj/system/controller/UserController.java @@ -86,6 +86,34 @@ public class UserController { return ServerResponse.createErroe("操作失败"); } + @PostMapping(value = "addTemp") + @DecryptAndVerify(decryptedClass = UserDto.class)//加解密统一管理 + @LogAnnotation(operModul = "系统管理-用户管理", operation = "新增用户", operDesc = "系统级事件",operType="新增") + @PreAuthorize("@pms.hasPermission('sys:user:add')") + public ServerResponse saveUserTemp(EncryptedReq data) { + try { + SysUser u = userService.getUser(data.getData().getLoginName()); + if (u != null) { + return ServerResponse.createErroe("登录名"+data.getData().getLoginName() + "已存在"); + } + SysUser u3 = userService.getUserCode(data.getData().getUserCode()); + if(u3 != null){ + return ServerResponse.createErroe("工号"+data.getData().getUserCode() + "已存在"); + } + if(StringHelper.isNotEmpty(data.getData().getPhone())){ + SysUser u2 = userService.getPhone(data.getData().getPhone()); + if (u2 != null) { + return ServerResponse.createErroe("手机号"+data.getData().getPhone() + "已存在"); + } + } + ServerResponse response=userService.saveUser(data.getData()); + return response; + }catch (Exception e){ + log.error(e.toString(),e); + } + return ServerResponse.createErroe("操作失败"); + } + @PostMapping(value = "updateEnableState") @DecryptAndVerify(decryptedClass = UserDto.class) @LogAnnotation(operModul = "系统管理-用户管理", operation = "修改启用状态", operDesc = "业务级事件",operType="修改") diff --git a/src/main/java/com/bonus/aqgqj/system/dao/UserDao.java b/src/main/java/com/bonus/aqgqj/system/dao/UserDao.java index 21296f6..278cbbc 100644 --- a/src/main/java/com/bonus/aqgqj/system/dao/UserDao.java +++ b/src/main/java/com/bonus/aqgqj/system/dao/UserDao.java @@ -34,6 +34,8 @@ public interface UserDao { SysUser getUser(String username); + SysUser getUserCode(String userCode); + @Update("update sys_user t set t.password = #{password} where t.id = #{id}") int changePassword(@Param("id") Long id, @Param("password") String password); diff --git a/src/main/java/com/bonus/aqgqj/system/service/UserService.java b/src/main/java/com/bonus/aqgqj/system/service/UserService.java index 23f447e..c143180 100644 --- a/src/main/java/com/bonus/aqgqj/system/service/UserService.java +++ b/src/main/java/com/bonus/aqgqj/system/service/UserService.java @@ -27,6 +27,8 @@ public interface UserService { SysUser getUser(String loginName); + SysUser getUserCode(String userCode); + ServerResponse changePassword(SysUser user); void password(SysUser user); diff --git a/src/main/java/com/bonus/aqgqj/system/service/impl/UserServiceImpl.java b/src/main/java/com/bonus/aqgqj/system/service/impl/UserServiceImpl.java index 7dc155e..1cd60a8 100644 --- a/src/main/java/com/bonus/aqgqj/system/service/impl/UserServiceImpl.java +++ b/src/main/java/com/bonus/aqgqj/system/service/impl/UserServiceImpl.java @@ -71,6 +71,16 @@ public class UserServiceImpl implements UserService { return null; } + @Override + public SysUser getUserCode(String userCode) { + try{ + return userDao.getUserCode(userCode); + }catch (Exception e){ + log.error(e.toString(),e); + } + return null; + } + @Override public ServerResponse changePassword(SysUser user) { Long userId = UserUtil.getLoginUser().getId(); diff --git a/src/main/resources/mappers/system/UserMapper.xml b/src/main/resources/mappers/system/UserMapper.xml index cec15c2..bac8297 100644 --- a/src/main/resources/mappers/system/UserMapper.xml +++ b/src/main/resources/mappers/system/UserMapper.xml @@ -66,6 +66,15 @@ where t.login_name = #{username} + + diff --git a/src/main/resources/static/js/system/child/userFormTemp.js b/src/main/resources/static/js/system/child/userFormTemp.js new file mode 100644 index 0000000..7871db5 --- /dev/null +++ b/src/main/resources/static/js/system/child/userFormTemp.js @@ -0,0 +1,299 @@ +let form, layer, dtree, util, idParam, phoneParam; +let arr = ['background', 'web', 'mobile', 'wx']; +let background, web, mobile, wx; +let data = [], appResList = []; +// 角色下拉选 +let roleList; +let orgData; +let teamList; +// showDictSelect("orgId", "org_id"); +// showDictSelect("sex", "sex"); +// showDictSelect("unit", "unit"); +// showDictSelect("dept", "dept"); +function setParams(params) { + console.log(params) + idParam = JSON.parse(params).id; + layui.config({ + base: "../../../js/layui-v2.6.8/dtree/", //此处路径请自行处理, 可以使用绝对路径 + }).extend({ + dtree: 'dtree' + }).use(['form', 'layer', 'dtree', 'util'], function () { + layer = layui.layer; + form = layui.form; + util = layui.util; + dtree = layui.dtree; + var $ = layui.jquery; + roleList = getRoleSelected(); + teamList = getTeamSelected(); + orgData = getOrgTree(); + if (idParam) { + getUserById(); + } + + // form.render(); + form.render("checkbox","select");//重新渲染页面checkbox控件 + form.on('submit(formData)', function (data) { + data.field.id = $('#id').val(); + console.log( data.field.orgId_select_nodeId); + if(!data.field.orgId_select_nodeId){ + return layer.alert("请选择组织机构!", {icon: 2}) + } + let phone = $('#phone').val(); + if(phone){ + if (!(/^1[3456789]\d{9}$/.test(phone))) { + return layer.alert("请输入正确的手机号", {icon: 2}) + } + } + saveData(data); + }); + + }); + + var a = 0; + $(".secreteyesk1").hide(); + $(".secreteyesk2").hide(); + $('.eyes1').click(function() { + a += 1; + if (a % 2 == 0) { + $('.secreteyesk1').hide(); + $('.secreteyes1').show(); + $('.secret1').prop('type', 'password'); + } else if (a % 2 != 0) { + $('.secreteyes1').hide(); + $('.secreteyesk1').show(); + $('.secret1').prop('type', 'text'); + } + }) + +} + +/** + * 获取角色数据 + */ +function getRoleSelected() { + let url = dataUrl + '/roles/all'; + ajaxRequest(url, "POST", null, true, function () { + }, function (result) { + if (result.code === 200) { + setSelectValue(result.data, 'roleId'); + } else { + layer.alert(result.msg, {icon: 2}) + } + }, function (xhr) { + error(xhr) + }); +} + +/** + * 获取班组数据 + */ +function getTeamSelected() { + let url = dataUrl + '/samples/getTeamSelected'; + ajaxRequest(url, "POST", null, true, function () { + }, function (result) { + if (result.code === 200) { + setSelectValue(result.data, 'teamId'); + } else { + layer.alert(result.msg, {icon: 2}) + } + }, function (xhr) { + error(xhr) + }); +} +function setOrgTree(data){ + orgTree = dtree.renderSelect({ + elem: "#orgId", + data: data, + dataFormat: "list", + skin: "laySimple", + line: true, // 显示树线 + checkbar: false, //开启复选框 + done: function (data, url, first) { + console.log($('#orgId').val()) + if(first) { + var params = dtree.dataInit("orgId", $('#orgId').val()); + var selectParam = dtree.selectVal("orgId"); + console.log(params) + } + } + }); +} +function getOrgTree() { + let data = []; + let url = dataUrl + '/users/getOrg'; + ajaxRequest(url, "POST", null, true, function () { + }, function (result) { + if (result.code === 200) { + console.log(result,"getOrgTree") + data = result.data; + setOrgTree(data) + } else { + layer.alert(result.msg, {icon: 2}) + } + }, function (xhr) { + error(xhr) + }); + return data; +} +// 根据id获取用户信息 +function getUserById() { + let loadingMsg = layer.msg("数据加载中,请稍候...", {icon: 16, scrollbar: false, time: 0,}); + let url = dataUrl + "/users/getById"; + let params = { + id: idParam + } + console.log(params) + params={ + encryptedData:encryptCBC(JSON.stringify(params)) + } + ajaxRequest(url, "POST", params, true, function () { + }, function (result) { + layer.close(loadingMsg); // 关闭提示层 + if (result.code === 200) { + console.log(result) + setFormData(result.data); + } else if (result.code === 500) { + layer.alert(result.msg, {icon: 2}) + } + }, function (xhr) { + layer.close(loadingMsg); // 关闭提示层 + error(xhr) + }); +} + +// 设置表单内容 +function setFormData(data) { + console.log("data:",data) + if (data) { + $("#password").removeAttr("lay-verify"); + $("#pwd").css("display","none"); + $('#id').val(data.id) + // $('#userCode').val(data.userCode) + $('#username').val(data.username) + $('#loginName').val(data.loginName) + $('#phone').val(data.phone) + + // 设置选中状态 + if (data.sex === 1) { + document.getElementById('sex_1').checked = true; + } else if (data.sex === 0) { + document.getElementById('sex_0').checked = true; + } + + if (data.userType === '1') { + document.getElementById('userType_1').checked = true; + } else if (data.userType === '0') { + document.getElementById('userType_0').checked = true; + } + + if (data.state === 1) { + document.getElementById('state_1').checked = true; + } else if (data.state === 0) { + document.getElementById('state_0').checked = true; + } + $('#type_'+data.type).attr('checked', true) + $('#orgId').val(data.orgId) + $('#roleId').val(data.roleId) + $('#roleId option[value=' + data.roleId + ']').attr('selected', true) + $('#teamId').val(data.teamId) + $('#teamId option[value=' + data.teamId + ']').attr('selected', true) + var arrCB = data.loginTypes; + for (var j = 0; j < arrCB.length; j++) { + var cbthis = $("input[name='loginType']"); + for (var i = 0; i < cbthis.length; i++) { + if (cbthis[i].value == arrCB[j]) { + cbthis[i].checked = true; + } + } + } + phoneParam = data.phone; + layui.form.render(); + } +} + +function saveData2() { + $('#formSubmit').trigger('click') +} + +// 保存数据 +function saveData(data) { + let loadingMsg = layer.msg('数据上传中,请稍候...', {icon: 16, scrollbar: false, time: 0}); + let url = dataUrl + "/users/addTemp"; + let params = data.field; + var arr_box = [];//固定复选框 + $('#cbGuDing input[type=checkbox]:checked').each(function () { + arr_box.push($(this).val()); + }); + console.log(arr_box) + params.loginType = arr_box.join() + params.orgId = params.orgId_select_nodeId; + if(params.id !=""){ + url = dataUrl + "/users/update"; + } + console.log(params) + params={ + encryptedData:encryptCBC(JSON.stringify(params)) + } + ajaxRequest(url, "POST", params, true, function () { + $('.save').addClass("layui-btn-disabled").attr("disabled", true); + $('.cancel').addClass("layui-btn-disabled").attr("disabled", true); + }, function (result) { + layer.close(loadingMsg); // 关闭提示层 + if (result.code === 200) { + closePage(1); + parent.layer.msg(result.msg, {icon: 1}); + } else { + layer.alert(result.msg, {icon: 2}) + $('.save').removeClass("layui-btn-disabled").attr("disabled", false); + $('.cancel').removeClass("layui-btn-disabled").attr("disabled", false); + } + }, function (xhr) { + layer.close(loadingMsg); // 关闭提示层 + $('.save').removeClass("layui-btn-disabled").attr("disabled", false); + $('.cancel').removeClass("layui-btn-disabled").attr("disabled", false); + error(xhr) + }); +} + +// 手机号名称是否重复 +function isRepeat(paramName, phone) { + let data = {}; + let url = dataUrl + "/sys/user/isRepeat"; + let params = { + 'value': phone, + 'paramName': paramName + } + ajaxRequest(url, "POST", params, false, function () { + }, function (result) { + if (result.code === 200) { + data = result + } else if (result.code === 500) { + } + }, function (xhr) { + error(xhr) + }); + return data; +} + +function getPasswordConfig(callback) { + let url = dataUrl + "/users/getPasswordConfig" + ajaxRequest(url, "POST", null, true, function () {}, function (result) { + // layer.close(loadingMsg); // 关闭提示层 + if (result.status === 200) { + callback(result.data); + } else if (result.status === 500) { + layer.alert(result.msg, {icon: 2}) + } + }, function (xhr) { + error(xhr) + }); +} + +// 关闭页面 +function closePage(type) { + let index = parent.layer.getFrameIndex(window.name); //先得到当前 iframe层的索引 + parent.layer.close(index); //再执行关闭 + if (type === 1) { + parent.reloadData() + } +} \ No newline at end of file diff --git a/src/main/resources/static/js/system/userMge.js b/src/main/resources/static/js/system/userMge.js index 922781e..cbd5513 100644 --- a/src/main/resources/static/js/system/userMge.js +++ b/src/main/resources/static/js/system/userMge.js @@ -211,6 +211,14 @@ function addData(id) { openIframe2("addOrEditUser", title, "child/userForm.html", '1000px', '625px', param); } +function addDataTemp(id) { + let title = '新增用户' + let param = { + 'id': id + } + openIframe2("addOrEditUserTemp", title, "child/userFormTemp.html", '1000px', '625px', param); +} + /*删除用户*/ function delData(id) { layer.confirm("确定删除吗?", { diff --git a/src/main/resources/static/pages/user/child/userFormTemp.html b/src/main/resources/static/pages/user/child/userFormTemp.html new file mode 100644 index 0000000..fbb584c --- /dev/null +++ b/src/main/resources/static/pages/user/child/userFormTemp.html @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + 用户-新增/修改 + + +
+
+ + +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ + +
+
+ +
+ +
+
    +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + + +
    + +
    + + +
    +
    + +
    + +
    + + +
    +
    + +
    + +
    + + + + +
    +
    + +
    + +
    + + + + + + +
    +
    + + +
    + +
    +
    + + +
    + + + \ No newline at end of file diff --git a/src/main/resources/static/pages/user/userMge.html b/src/main/resources/static/pages/user/userMge.html index 318b361..f3a79cb 100644 --- a/src/main/resources/static/pages/user/userMge.html +++ b/src/main/resources/static/pages/user/userMge.html @@ -53,7 +53,7 @@