fix(用户管理): 用户表单可以保存包含特殊字符.的姓名

This commit is contained in:
fit2cloud-chenyw 2022-11-28 11:55:56 +08:00
parent 762c369eec
commit 62b1993236
4 changed files with 17 additions and 6 deletions

View File

@ -651,6 +651,7 @@ export default {
input_password: 'Please input a password',
input_phone: 'Please enter the phone number',
input_roles: 'Please select role',
user_name_pattern_error: 'IDs can only contain alphanumeric underscores and - and start with a letter!',
special_characters_are_not_supported: 'Special characters are not supported',
mobile_number_format_is_incorrect: 'Incorrect format of mobile phone number',
email_format_is_incorrect: 'The mailbox format is incorrect',

View File

@ -652,6 +652,7 @@ export default {
input_roles: '請選擇角色',
select_users: '請選擇用戶',
select_gender: '請選擇性別',
user_name_pattern_error: 'ID只能包含字母数字下划线以及-并以字母开头!',
special_characters_are_not_supported: '不支持特殊字符',
mobile_number_format_is_incorrect: '手機號碼格式不正確',
email_format_is_incorrect: '郵箱格式不正確',

View File

@ -651,6 +651,7 @@ export default {
input_roles: '请选择角色',
select_users: '请选择用户',
select_gender: '请选择性别',
user_name_pattern_error: 'ID只能包含字母数字下划线以及-并以字母开头!',
special_characters_are_not_supported: '不支持特殊字符',
mobile_number_format_is_incorrect: '手机号码格式不正确',
email_format_is_incorrect: '邮箱格式不正确',

View File

@ -264,7 +264,7 @@ export default {
},
{
required: true,
pattern: '^[^\u4e00-\u9fa5]+$',
pattern: '^[a-zA-Z][a-zA-Z0-9_-]*$',
message: this.$t('user.special_characters_are_not_supported'),
trigger: 'blur'
}
@ -281,11 +281,8 @@ export default {
message: this.$t('commons.input_limit', [2, 50]),
trigger: 'blur'
},
{
required: true,
message: this.$t('user.special_characters_are_not_supported'),
trigger: 'blur'
}
{ required: true, validator: this.validateNickname, trigger: 'blur' }
],
phone: [
{
@ -411,6 +408,17 @@ export default {
callback()
}
},
validateNickname(rule, value, callback) {
const pattern = "[\\u00A0\\s\"`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~@#¥%……&*()——+|{}【】‘;:”“'。,、?]"
const regep = new RegExp(pattern)
if (regep.test(value)) {
const msg = this.$t('user.special_characters_are_not_supported')
callback(new Error(msg))
} else {
callback()
}
},
create() {
this.formType = 'add'
this.form = Object.assign({}, JSON.parse(JSON.stringify(this.defaultForm)))