From 90c58292410360c631b5bdeff2724a32d3998fe8 Mon Sep 17 00:00:00 2001 From: "liang.chao" <1360241448@qq.com> Date: Wed, 2 Apr 2025 10:22:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/bonus/imgTool/model/Role.java | 4 + .../system/controller/UserController.java | 6 +- .../resources/mappers/system/UserMapper.xml | 10 +- .../static/js/system/child/userFormTemp.js | 135 ++++++++++++------ .../resources/static/js/system/userMge.js | 97 +++++++------ .../static/pages/user/child/userForm.html | 28 ++-- .../static/pages/user/child/userFormTemp.html | 114 ++++++++------- .../resources/static/pages/user/userMge.html | 10 +- 8 files changed, 241 insertions(+), 163 deletions(-) diff --git a/src/main/java/com/bonus/imgTool/model/Role.java b/src/main/java/com/bonus/imgTool/model/Role.java index c36fb2e..615c364 100644 --- a/src/main/java/com/bonus/imgTool/model/Role.java +++ b/src/main/java/com/bonus/imgTool/model/Role.java @@ -58,5 +58,9 @@ public class Role extends PageEntity { * 角色级别 */ private Integer level; + /** + * 角色级别名称 + */ + private String levelName; } diff --git a/src/main/java/com/bonus/imgTool/system/controller/UserController.java b/src/main/java/com/bonus/imgTool/system/controller/UserController.java index 3a11f06..5c0cdab 100644 --- a/src/main/java/com/bonus/imgTool/system/controller/UserController.java +++ b/src/main/java/com/bonus/imgTool/system/controller/UserController.java @@ -100,14 +100,14 @@ public class UserController { try { SysUser u = userService.getUser(data.getData().getLoginName()); if (u != null) { - return ServerResponse.createErroe("登录名"+data.getData().getLoginName() + "已存在"); + return ServerResponse.createErroe("登录账号"+data.getData().getLoginName() + "已存在"); } - if(StringHelper.isNotEmpty(data.getData().getPhone())){ + /* 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){ diff --git a/src/main/resources/mappers/system/UserMapper.xml b/src/main/resources/mappers/system/UserMapper.xml index d18dfee..e001215 100644 --- a/src/main/resources/mappers/system/UserMapper.xml +++ b/src/main/resources/mappers/system/UserMapper.xml @@ -73,7 +73,7 @@ - select t.id,t.user_name as username,t.login_name as loginName,t.phone,t.org_id as orgId,so.org_name as orgName, + select t.id,t.user_name as username,t.login_name as loginName,t.org_id as orgId,so.org_name as orgName, t.password,t.state,t.role_id as roleId,t.login_type loginType,t.new_user newUser, sr.role_code AS roleCode,sr.role_name AS roleName,t.team_id AS teamId from sys_user t @@ -131,7 +131,6 @@ t.org_id as orgId, so.org_name as orgName, sr.role_name roleName, - t.phone AS phone, t.team_id as teamId, CASE t.user_type @@ -214,7 +213,12 @@ select t.role_id as id, - t.role_name as name + t.role_name as name, + t.level, + case when t.level = 0 then '项目部级' + when t.level = 1 then '公司级' + else '' + end as levelName from sys_role t where t.del_flag = 0 and t.state = 1 diff --git a/src/main/resources/static/js/system/child/userFormTemp.js b/src/main/resources/static/js/system/child/userFormTemp.js index 6b8889b..7eb0e00 100644 --- a/src/main/resources/static/js/system/child/userFormTemp.js +++ b/src/main/resources/static/js/system/child/userFormTemp.js @@ -6,6 +6,7 @@ let data = [], appResList = []; let roleList; let orgData; let teamList; + function setParams(params) { console.log(params) idParam = JSON.parse(params).id; @@ -20,38 +21,50 @@ function setParams(params) { dtree = layui.dtree; var $ = layui.jquery; roleList = getRoleSelected(); - teamList = getTeamSelected(); - orgData = getOrgTree(); + projectList = getProSelected(); + // teamList = getTeamSelected(); + // orgData = getOrgTree(); + console.log(idParam + "idParam") if (idParam) { getUserById(); } // form.render(); - form.render("checkbox","select");//重新渲染页面checkbox控件 + 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))) { + /* console.log( data.field.orgId_select_nodeId); + if(!data.field.orgId_select_nodeId){ + return layer.alert("请选择组织机构!", {icon: 2}) + }*/ + let loginName = $('#loginName').val(); + if (loginName) { + if (!(/^1[3456789]\d{9}$/.test(loginName))) { return layer.alert("请输入正确的手机号", {icon: 2}) } } - if (!validatePassword(data.field.password)){ + if (!validatePassword(data.field.password)) { return layer.alert("密码必须包含大、小写字母 、数字、 特殊字符四种里至少三种,且密码长度不低于8位", {icon: 2}) } saveData(data); }); + // 监听角色下拉框的 change 事件 + form.on('select(roleId)', function (data) { + const roleName = $('#roleId option:selected').text(); + if (roleName.includes('项目部级')) { + $('#projectDiv').removeClass('layui-hide'); // 显示 div + } else { + $('#projectDiv').addClass('layui-hide'); // 隐藏 div + } + }); + }); var a = 0; $(".secreteyesk1").hide(); $(".secreteyesk2").hide(); - $('.eyes1').click(function() { + $('.eyes1').click(function () { a += 1; if (a % 2 == 0) { $('.secreteyesk1').hide(); @@ -70,7 +83,7 @@ function setParams(params) { * 校验密码 */ function validatePassword(password) { - console.log("password:",password) + console.log("password:", password) // 定义正则表达式来检测不同的字符类型 const hasUpperCase = /[A-Z]/.test(password); const hasLowerCase = /[a-z]/.test(password); @@ -82,7 +95,7 @@ function validatePassword(password) { // 计算符合要求的字符类型数量 const typesCount = [hasUpperCase, hasLowerCase, hasDigit, hasSpecialChar].filter(Boolean).length; - console.log("typesCount:",typesCount) + console.log("typesCount:", typesCount) // 验证密码:长度合法且包含至少三种字符类型 return isLengthValid && typesCount >= 3; @@ -105,10 +118,28 @@ function getRoleSelected() { }); } +/** + * 获取工程数据 + */ +function getProSelected() { + let url = dataUrl + '/users/getRoleAll'; + 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() { + +/*function getTeamSelected() { let url = dataUrl + '/testReport/getTeamSelected'; ajaxRequest(url, "POST", null, true, function () { }, function (result) { @@ -120,26 +151,40 @@ function getTeamSelected() { }, function (xhr) { error(xhr) }); +}*/ + +function setSelectValue(list, selectName) { + let html = '请选择'; + $.each(list, function (index, item) { + html += '' + item.name + '(' + item.levelName + ')' + ''; + }) + $('#' + selectName).empty().append(html); + layui.form.render(); } -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() { + + + + + +// 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 () { @@ -155,7 +200,8 @@ function getOrgTree() { error(xhr) }); return data; -} +}*/ + // 根据id获取用户信息 function getUserById() { let loadingMsg = layer.msg("数据加载中,请稍候...", {icon: 16, scrollbar: false, time: 0,}); @@ -164,8 +210,8 @@ function getUserById() { id: idParam } console.log(params) - params={ - encryptedData:encryptCBC(JSON.stringify(params)) + params = { + encryptedData: encryptCBC(JSON.stringify(params)) } ajaxRequest(url, "POST", params, true, function () { }, function (result) { @@ -184,10 +230,10 @@ function getUserById() { // 设置表单内容 function setFormData(data) { - console.log("data:",data) + console.log("data:", data) if (data) { $("#password").removeAttr("lay-verify"); - $("#pwd").css("display","none"); + $("#pwd").css("display", "none"); $('#id').val(data.id) // $('#userCode').val(data.userCode) $('#username').val(data.username) @@ -212,7 +258,7 @@ function setFormData(data) { } else if (data.state === 0) { document.getElementById('state_0').checked = true; } - $('#type_'+data.type).attr('checked', true) + $('#type_' + data.type).attr('checked', true) $('#orgId').val(data.orgId) $('#roleId').val(data.roleId) $('#roleId option[value=' + data.roleId + ']').attr('selected', true) @@ -248,12 +294,12 @@ function saveData(data) { console.log(arr_box) params.loginType = arr_box.join() params.orgId = params.orgId_select_nodeId; - if(params.id !=""){ + if (params.id != "") { url = dataUrl + "/users/update"; } console.log(params) - params={ - encryptedData:encryptCBC(JSON.stringify(params)) + params = { + encryptedData: encryptCBC(JSON.stringify(params)) } ajaxRequest(url, "POST", params, true, function () { $('.save').addClass("layui-btn-disabled").attr("disabled", true); @@ -298,7 +344,8 @@ function isRepeat(paramName, phone) { function getPasswordConfig(callback) { let url = dataUrl + "/users/getPasswordConfig" - ajaxRequest(url, "POST", null, true, function () {}, function (result) { + ajaxRequest(url, "POST", null, true, function () { + }, function (result) { // layer.close(loadingMsg); // 关闭提示层 if (result.status === 200) { callback(result.data); diff --git a/src/main/resources/static/js/system/userMge.js b/src/main/resources/static/js/system/userMge.js index cbd5513..7c33420 100644 --- a/src/main/resources/static/js/system/userMge.js +++ b/src/main/resources/static/js/system/userMge.js @@ -1,12 +1,12 @@ let form, layer, dtree, table, tableIns; let pageNum = 1, limitSize = 10; // 默认第一页,分页数量为10 -let orgData,selectOrgId=""; +let orgData, selectOrgId = ""; layui.config({ base: "../../js/layui-v2.6.8/dtree/", //此处路径请自行处理, 可以使用绝对路径 }).extend({ dtree: 'dtree' -}).use(['form', 'layer', 'table','dtree', 'laydate'], function () { +}).use(['form', 'layer', 'table', 'dtree', 'laydate'], function () { form = layui.form; layer = layui.layer; table = layui.table; @@ -21,10 +21,11 @@ layui.config({ 'id': this.value, 'state': obj.elem.checked ? 1 : 0 } - params={ - encryptedData:encryptCBC(JSON.stringify(params)) + params = { + encryptedData: encryptCBC(JSON.stringify(params)) } - ajaxRequest(url, "POST", params, true, function () {}, function (result) { + ajaxRequest(url, "POST", params, true, function () { + }, function (result) { console.log(result) reloadData(); if (result.status === 200) { @@ -90,15 +91,15 @@ function initTable(dataList, limit, page) { cols: [ [ //表头 - {title: "序号", width: 80, unresize: true, align: "center", + { + title: "序号", width: 80, unresize: true, align: "center", templet: function (d) { return (page - 1) * limit + d.LAY_INDEX; } }, - {field: "loginName", title: "登录名", unresize: true, align: "center"}, - {field: "username", title: "用户名", unresize: true, align: "center"}, - // {field: "userCode", title: "工号", unresize: true, align: "center"}, - {field: "sex", title: "性别", unresize: true, align: "center", + {field: "loginName", title: "登录账号", unresize: true, align: "center"}, + {field: "username", title: "姓名", unresize: true, align: "center"}, + /*{field: "sex", title: "性别", unresize: true, align: "center", templet: function (d) { if (d.sex == 0) { return "女"; @@ -106,21 +107,23 @@ function initTable(dataList, limit, page) { return "男"; } } - }, - {field: "orgName", title: "单位部门", unresize: true, align: "center"}, + },*/ + // {field: "orgName", title: "单位部门", unresize: true, align: "center"}, {field: "roleName", title: "角色", unresize: true, align: "center"}, - {field: "phone", title: "联系电话", unresize: true, align: "center"}, - {field: "userType", title: "用户类型", unresize: true, align: "center"}, - {field: "state", title: "启用状态", align: "center",templet: '#is-state'}, - {title: "操作", unresize: true, width: 300, align: "center", + // {field: "phone", title: "联系电话", unresize: true, align: "center"}, + {field: "userType", title: "用户级别", unresize: true, align: "center"}, + {field: "state", title: "启用状态", align: "center", templet: '#is-state'}, + {field: "createTime", title: "创建时间", unresize: true, align: "center"}, + { + title: "操作", unresize: true, width: 300, align: "center", templet: function (d) { let html = ''; - // let updaetpwd=""; - let del="" - let edit=""; - html=edit+del; - if(d.delFlag==1){ + let updaetpwd = ""; + let del = "" + let edit = ""; + html = updaetpwd + edit + del; + if (d.delFlag == 1) { return ''; } return html; @@ -155,14 +158,14 @@ function getReqParams(page, limit, type) { page: '1', limit: '10', userName: '', - phone:'', - orgId:'', + phone: '', + orgId: '', userType: '', }; } console.log(obj) - obj={ - encryptedData:encryptCBC(JSON.stringify(obj)) + obj = { + encryptedData: encryptCBC(JSON.stringify(obj)) } return obj; } @@ -229,8 +232,8 @@ function delData(id) { let params = { 'id': id } - params={ - encryptedData:encryptCBC(JSON.stringify(params)) + params = { + encryptedData: encryptCBC(JSON.stringify(params)) } ajaxRequest(url, "POST", params, true, function () { }, function (result) { @@ -259,7 +262,7 @@ function editUserAccountStatus(id, status, type) { ajaxRequest(url, "POST", params, true, function () { }, function (result) { if (result.code === 200) { - if(type){ + if (type) { reloadData(); } parent.layer.msg(result.msg, {icon: 1}) @@ -286,7 +289,7 @@ function getOrgTree() { ajaxRequest(url, "POST", null, false, function () { }, function (result) { if (result.code === 200) { - console.log(result,"getOrgTree") + console.log(result, "getOrgTree") data = result.data; setOrgTree(data) } else { @@ -298,25 +301,25 @@ function getOrgTree() { return data; } -function setOrgTree(data){ - console.log("data",data) - var af=0,bf=0; +function setOrgTree(data) { + console.log("data", data) + var af = 0, bf = 0; $.each(data, function (i, item) { - if(item.id==0){ - item.id="99999"; - item.parentId="0"; - item.title="请选择组织机构"; - af=1; + if (item.id == 0) { + item.id = "99999"; + item.parentId = "0"; + item.title = "请选择组织机构"; + af = 1; } - if(item.id==1){ - item.parentId="99999"; - bf=1; + if (item.id == 1) { + item.parentId = "99999"; + bf = 1; } - if(af==1&&bf==1){ + if (af == 1 && bf == 1) { return } }) - orgTree =dtree.renderSelect({ + orgTree = dtree.renderSelect({ elem: "#orgId", width: "100%", // 指定树的宽度 dataFormat: "list", @@ -329,11 +332,11 @@ function setOrgTree(data){ } }); dtree.on('node(orgId)', function (obj) { - console.log("obj.param.nodeId",obj.param.nodeId); // 打印选中节点的值 - if(obj.param.nodeId=="99999"){ - selectOrgId=""; - }else{ - selectOrgId=obj.param.nodeId; + console.log("obj.param.nodeId", obj.param.nodeId); // 打印选中节点的值 + if (obj.param.nodeId == "99999") { + selectOrgId = ""; + } else { + selectOrgId = obj.param.nodeId; } }); } diff --git a/src/main/resources/static/pages/user/child/userForm.html b/src/main/resources/static/pages/user/child/userForm.html index 728419d..db721ea 100644 --- a/src/main/resources/static/pages/user/child/userForm.html +++ b/src/main/resources/static/pages/user/child/userForm.html @@ -21,7 +21,7 @@ - *登录名 + *登录账号 @@ -29,7 +29,7 @@ - *用户名 + *姓名 @@ -44,12 +44,12 @@ - + *角色 @@ -59,7 +59,15 @@ - + + *管理的工程 + + + + + + + - + - + *密码 diff --git a/src/main/resources/static/pages/user/child/userFormTemp.html b/src/main/resources/static/pages/user/child/userFormTemp.html index a8e5222..14cd903 100644 --- a/src/main/resources/static/pages/user/child/userFormTemp.html +++ b/src/main/resources/static/pages/user/child/userFormTemp.html @@ -21,15 +21,16 @@ - *登录名 + *登录账号 - *用户名 + *姓名 @@ -38,69 +39,80 @@ * 性别 - - - + + + - - *单位部门 - - - - + *角色 - + - - - - - - - - - - 班组 + + *管理的工程 - + - - *联系电话 - - - - - - - - * 用户类型: - - - - - - - - * 是否启用: - - - - - + + + + + + + + + + + + + + + + *密码 - - + - + diff --git a/src/main/resources/static/pages/user/userMge.html b/src/main/resources/static/pages/user/userMge.html index 7866a99..435b9dc 100644 --- a/src/main/resources/static/pages/user/userMge.html +++ b/src/main/resources/static/pages/user/userMge.html @@ -22,11 +22,11 @@ - + - + 查询 - - + 重置 +