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() {