fix: 标签输入增加输入校验&邮箱邀请校验邮箱格式
This commit is contained in:
parent
676f3ce4eb
commit
d9d3485370
|
@ -64,6 +64,7 @@
|
|||
size?: 'small' | 'large' | 'medium' | 'mini';
|
||||
disabled?: boolean;
|
||||
noTooltip?: boolean;
|
||||
inputValidator?: (value: string) => boolean;
|
||||
}>(),
|
||||
{
|
||||
retainInputValue: true,
|
||||
|
@ -153,12 +154,17 @@
|
|||
validateTagsCountBlur() &&
|
||||
(innerInputValue.value || '').trim().length <= props.maxLength
|
||||
) {
|
||||
if (props.inputValidator && !props.inputValidator(innerInputValue.value.trim())) {
|
||||
innerModelValue.value.splice(-1, 1);
|
||||
emit('update:modelValue', innerModelValue.value);
|
||||
} else {
|
||||
innerModelValue.value.push(innerInputValue.value.trim());
|
||||
innerInputValue.value = '';
|
||||
tagsLength.value += 1;
|
||||
emit('update:modelValue', innerModelValue.value);
|
||||
emit('change', innerModelValue.value);
|
||||
}
|
||||
}
|
||||
emit('blur');
|
||||
}
|
||||
|
||||
|
@ -169,8 +175,13 @@
|
|||
innerInputValue.value &&
|
||||
innerInputValue.value.trim().length <= props.maxLength
|
||||
) {
|
||||
if (props.inputValidator && !props.inputValidator(innerInputValue.value.trim())) {
|
||||
innerModelValue.value.splice(-1, 1);
|
||||
emit('update:modelValue', innerModelValue.value);
|
||||
} else {
|
||||
innerInputValue.value = '';
|
||||
tagsLength.value += 1;
|
||||
}
|
||||
} else {
|
||||
innerModelValue.value = innerModelValue.value.filter((item: any) => item.length <= props.maxLength);
|
||||
innerInputValue.value = '';
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
v-model:model-value="emailForm.emails"
|
||||
placeholder="system.user.inviteEmailPlaceholder"
|
||||
tags-duplicate-text="system.user.inviteEmailRepeat"
|
||||
:input-validator="validateInputEmailTag"
|
||||
allow-clear
|
||||
unique-value
|
||||
retain-input-value
|
||||
|
@ -61,6 +62,7 @@
|
|||
import { inviteUser } from '@/api/modules/setting/user';
|
||||
import { useI18n } from '@/hooks/useI18n';
|
||||
import useAppStore from '@/store/modules/app';
|
||||
import { validateEmail } from '@/utils/validate';
|
||||
|
||||
import { ProjectUserOption } from '@/models/projectManagement/projectAndPermission';
|
||||
import type { SystemRole } from '@/models/setting/user';
|
||||
|
@ -119,6 +121,14 @@
|
|||
}
|
||||
);
|
||||
|
||||
function validateInputEmailTag(value: string) {
|
||||
if (validateEmail(value)) {
|
||||
return true;
|
||||
}
|
||||
Message.warning(t('system.config.email.emailErrTip'));
|
||||
return false;
|
||||
}
|
||||
|
||||
function cancelInvite() {
|
||||
inviteVisible.value = false;
|
||||
inviteFormRef.value?.resetFields();
|
||||
|
|
Loading…
Reference in New Issue