fix: 网元信息IP地址输入校验
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
||||
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 { fnToStepName } from '../hooks/useStep';
|
||||
import useI18n from '@/hooks/useI18n';
|
||||
import useDictStore from '@/store/modules/dict';
|
||||
@@ -83,7 +84,7 @@ function fnTabCreate() {
|
||||
ip: '',
|
||||
port: 33030,
|
||||
pvFlag: 'PNF',
|
||||
rmUid: `0000XXNew${neId}`,
|
||||
rmUid: `4400HXNew${neId}`,
|
||||
neAddress: '',
|
||||
dn: '-',
|
||||
vendorName: '-',
|
||||
@@ -214,12 +215,33 @@ function fnNeIPChange(e: any, data: any) {
|
||||
}
|
||||
}
|
||||
|
||||
/**表单验证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();
|
||||
}
|
||||
|
||||
/**保存信息 */
|
||||
function fnSaveFinish(pane: any) {
|
||||
console.log('Success:', pane);
|
||||
tabState.confirmLoading = true;
|
||||
const from = toRaw(pane);
|
||||
from.rmUid = `0000XX${from.neType}${from.neId}`; // 4400HX1AMF001
|
||||
from.rmUid = `4400HX${from.neType}${from.neId}`; // 4400HX1AMF001
|
||||
from.neName = `${from.neType}_${from.neId}`; // AMF_001
|
||||
const result = from.id ? updateNeInfo(from) : addNeInfo(from);
|
||||
const hide = message.loading(t('common.loading'), 0);
|
||||
@@ -300,6 +322,7 @@ function fnGetList() {
|
||||
console.log(res);
|
||||
if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.data)) {
|
||||
for (const item of res.data) {
|
||||
if (item.neType === 'OMC') continue;
|
||||
tabState.panes.push({
|
||||
key: `${item.neType}@${item.neId}`,
|
||||
data: item,
|
||||
@@ -396,7 +419,11 @@ onMounted(() => {
|
||||
>
|
||||
<a-auto-complete
|
||||
v-model:value="pane.data.neType"
|
||||
:options="NE_TYPE_LIST.map(v => ({ value: v }))"
|
||||
:options="
|
||||
NE_TYPE_LIST.filter(s => s !== 'OMC').map(v => ({
|
||||
value: v,
|
||||
}))
|
||||
"
|
||||
@change="v => fnNeTypeChange(v, pane.data)"
|
||||
>
|
||||
<a-input
|
||||
@@ -453,7 +480,7 @@ onMounted(() => {
|
||||
name="ip"
|
||||
:rules="{
|
||||
required: true,
|
||||
message: '请输入网元IP地址',
|
||||
validator: modalStateFromEqualIPV4AndIPV6,
|
||||
}"
|
||||
>
|
||||
<a-input
|
||||
@@ -490,6 +517,7 @@ onMounted(() => {
|
||||
style="width: 100%"
|
||||
:min="1"
|
||||
:max="65535"
|
||||
:maxlength="5"
|
||||
placeholder="<=65535"
|
||||
>
|
||||
<template #prefix>
|
||||
@@ -537,6 +565,7 @@ onMounted(() => {
|
||||
:min="10"
|
||||
:max="65535"
|
||||
:step="1"
|
||||
:maxlength="5"
|
||||
style="width: 100%"
|
||||
></a-input-number>
|
||||
</a-form-item>
|
||||
@@ -549,7 +578,7 @@ onMounted(() => {
|
||||
<a-input
|
||||
v-model:value="host.user"
|
||||
allow-clear
|
||||
:maxlength="50"
|
||||
:maxlength="32"
|
||||
:placeholder="t('common.inputPlease')"
|
||||
>
|
||||
</a-input>
|
||||
|
||||
Reference in New Issue
Block a user