From ef8c79f59f27a7861b4d508c41acd15c9d63ee15 Mon Sep 17 00:00:00 2001 From: green <2624612302@qq.com> Date: Thu, 27 Nov 2025 11:37:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=94=A8=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../psychology/PsyUserProfileServiceImpl.java | 16 ++++++++-------- xinli-ui/src/views/psychology/profile/index.vue | 16 ++++++++++------ 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/ry-xinli-system/src/main/java/com/ddnai/system/service/impl/psychology/PsyUserProfileServiceImpl.java b/ry-xinli-system/src/main/java/com/ddnai/system/service/impl/psychology/PsyUserProfileServiceImpl.java index bae52304..5c9caea5 100644 --- a/ry-xinli-system/src/main/java/com/ddnai/system/service/impl/psychology/PsyUserProfileServiceImpl.java +++ b/ry-xinli-system/src/main/java/com/ddnai/system/service/impl/psychology/PsyUserProfileServiceImpl.java @@ -121,14 +121,14 @@ public class PsyUserProfileServiceImpl implements IPsyUserProfileService profile.setInfoNumber(infoNumber); validateInfoNumberUnique(infoNumber, null); - // 验证姓名:如果提供,只能包含汉字 + // 验证姓名:如果提供,只能包含汉字和数字 if (StringUtils.isNotEmpty(profile.getUserName())) { String userName = profile.getUserName().trim(); - if (!userName.matches("^[\\u4e00-\\u9fa5]+$")) + if (!userName.matches("^[\\u4e00-\\u9fa5\\d]+$")) { - log.error("创建用户档案失败:姓名格式错误,只能输入汉字,userName: {}", userName); - throw new ServiceException("姓名只能输入汉字"); + log.error("创建用户档案失败:姓名格式错误,只能输入汉字和数字,userName: {}", userName); + throw new ServiceException("姓名只能输入汉字和数字"); } profile.setUserName(userName); } @@ -289,14 +289,14 @@ public class PsyUserProfileServiceImpl implements IPsyUserProfileService profile.setInfoNumber(infoNumber); validateInfoNumberUnique(infoNumber, profile.getProfileId()); - // 验证姓名:如果提供,只能包含汉字 + // 验证姓名:如果提供,只能包含汉字和数字 if (StringUtils.isNotEmpty(profile.getUserName())) { String userName = profile.getUserName().trim(); - if (!userName.matches("^[\\u4e00-\\u9fa5]+$")) + if (!userName.matches("^[\\u4e00-\\u9fa5\\d]+$")) { - log.error("修改用户档案失败:姓名格式错误,只能输入汉字,userName: {}", userName); - throw new ServiceException("姓名只能输入汉字"); + log.error("修改用户档案失败:姓名格式错误,只能输入汉字和数字,userName: {}", userName); + throw new ServiceException("姓名只能输入汉字和数字"); } profile.setUserName(userName); syncUserName(profile.getUserId(), userName); diff --git a/xinli-ui/src/views/psychology/profile/index.vue b/xinli-ui/src/views/psychology/profile/index.vue index a39e87c4..f143a116 100644 --- a/xinli-ui/src/views/psychology/profile/index.vue +++ b/xinli-ui/src/views/psychology/profile/index.vue @@ -183,7 +183,10 @@ - + + + * 信息编号 + @@ -288,7 +291,7 @@ @@ -480,11 +483,12 @@ export default { { required: true, message: "档案类型不能为空", trigger: "change" } ], infoNumber: [ + { required: true, message: "信息编号不能为空", trigger: "blur" }, { pattern: /^\d+$/, message: "信息编号只能输入数字", trigger: "blur" } ], userName: [ { required: true, message: "罪犯姓名不能为空", trigger: "blur" }, - { pattern: /^[\u4e00-\u9fa5]+$/, message: "姓名只能输入汉字", trigger: "blur" } + { pattern: /^[\u4e00-\u9fa5\d]+$/, message: "姓名只能输入汉字和数字", trigger: "blur" } ], prison: [ { required: true, message: "监狱不能为空", trigger: "blur" } @@ -753,8 +757,8 @@ export default { }, // 处理姓名输入,只允许汉字 handleUserNameInput(value) { - // 移除所有非汉字字符 - this.form.userName = value.replace(/[^\u4e00-\u9fa5]/g, '') + // 移除所有非汉字和非数字字符 + this.form.userName = value.replace(/[^\u4e00-\u9fa5\d]/g, '') }, /** 搜索按钮操作 */ handleQuery() {