fix: 网元信息IP地址输入校验
This commit is contained in:
@@ -5,6 +5,7 @@ import { addNeInfo, getNeInfoByTypeAndID, updateNeInfo } from '@/api/ne/neInfo';
|
||||
import { neHostAuthorizedRSA, testNeHost } from '@/api/ne/neHost';
|
||||
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
||||
import { NE_TYPE_LIST } from '@/constants/ne-constants';
|
||||
import { regExpIPv4, regExpIPv6 } from '@/utils/regular-utils';
|
||||
import { fnRestStepState, fnToStepName, stepState } from '../hooks/useStep';
|
||||
import useI18n from '@/hooks/useI18n';
|
||||
import useDictStore from '@/store/modules/dict';
|
||||
@@ -50,7 +51,7 @@ let modalState: ModalStateType = reactive({
|
||||
ip: '',
|
||||
port: 33030,
|
||||
pvFlag: 'PNF',
|
||||
rmUid: '0000XX1AMF001',
|
||||
rmUid: '4400HXAMF001',
|
||||
neAddress: '',
|
||||
dn: '-',
|
||||
vendorName: '-',
|
||||
@@ -107,7 +108,7 @@ const modalStateFrom = Form.useForm(
|
||||
ip: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入网元IP地址',
|
||||
validator: modalStateFromEqualIPV4AndIPV6,
|
||||
},
|
||||
],
|
||||
port: [
|
||||
@@ -119,6 +120,28 @@ const modalStateFrom = Form.useForm(
|
||||
})
|
||||
);
|
||||
|
||||
/**表单验证IP地址是否有效 */
|
||||
function modalStateFromEqualIPV4AndIPV6(
|
||||
rule: Record<string, any>,
|
||||
value: string,
|
||||
callback: (error?: string) => void
|
||||
) {
|
||||
if (!value) {
|
||||
return Promise.reject('请输入网元IP地址');
|
||||
}
|
||||
|
||||
if(value.indexOf('.') === -1 && value.indexOf(':') === -1) {
|
||||
return Promise.reject('请输入有效的IP地址');
|
||||
}
|
||||
if (value.indexOf('.') !== -1 && !regExpIPv4.test(value)) {
|
||||
return Promise.reject('不是有效IPv4地址');
|
||||
}
|
||||
if (value.indexOf(':') !== -1 && !regExpIPv6.test(value)) {
|
||||
return Promise.reject('不是有效IPv6地址');
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试主机连接
|
||||
*/
|
||||
@@ -375,7 +398,9 @@ onMounted(() => {
|
||||
>
|
||||
<a-auto-complete
|
||||
v-model:value="modalState.from.neType"
|
||||
:options="NE_TYPE_LIST.map(v => ({ value: v }))"
|
||||
:options="
|
||||
NE_TYPE_LIST.filter(s => s !== 'OMC').map(v => ({ value: v }))
|
||||
"
|
||||
@change="fnNeTypeChange"
|
||||
>
|
||||
<a-input
|
||||
@@ -459,6 +484,7 @@ onMounted(() => {
|
||||
style="width: 100%"
|
||||
:min="1"
|
||||
:max="65535"
|
||||
:maxlength="5"
|
||||
placeholder="<=65535"
|
||||
>
|
||||
<template #prefix>
|
||||
@@ -493,6 +519,7 @@ onMounted(() => {
|
||||
allow-clear
|
||||
:maxlength="128"
|
||||
:placeholder="t('common.inputPlease')"
|
||||
:disabled="true"
|
||||
>
|
||||
</a-input>
|
||||
</a-form-item>
|
||||
@@ -504,6 +531,7 @@ onMounted(() => {
|
||||
:min="10"
|
||||
:max="65535"
|
||||
:step="1"
|
||||
:maxlength="5"
|
||||
style="width: 100%"
|
||||
></a-input-number>
|
||||
</a-form-item>
|
||||
|
||||
Reference in New Issue
Block a user