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