|
@@ -318,11 +318,24 @@ export default {
|
|
|
console.log(this.FormData.IpList);
|
|
|
console.log(arr, "1111111");
|
|
|
},
|
|
|
+ //正整数
|
|
|
+ positiveInteger(ip) {
|
|
|
+ let reg = /^[+]{0,1}(\d+)$/;
|
|
|
+ return reg.test(ip);
|
|
|
+ },
|
|
|
+ //ip区间
|
|
|
+ isValidIPs(ip) {
|
|
|
+ let reg =
|
|
|
+ /^(?=(\b|\D))(((\d{1,2})|(1\d{1,2})|(2[0-4]\d)|(25[0-5]))\.){3}((\d{1,2})|(1\d{1,2})|(2[0-4]\d)|(25[0-5]))(?=(\b|\D))-(?=(\b|\D))(((\d{1,2})|(1\d{1,2})|(2[0-4]\d)|(25[0-5]))\.){3}((\d{1,2})|(1\d{1,2})|(2[0-4]\d)|(25[0-5]))(?=(\b|\D))$/;
|
|
|
+ return reg.test(ip);
|
|
|
+ },
|
|
|
+ //ip
|
|
|
isValidIP: function (ip) {
|
|
|
let reg =
|
|
|
/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;
|
|
|
return reg.test(ip);
|
|
|
},
|
|
|
+ //ip段
|
|
|
isValidseg(ip) {
|
|
|
let reg =
|
|
|
/^((?:(?:[01]?\d?\d|2(?:[0-4]\d|5[0-5]))\.){2}(?:[01]?\d?\d|2(?:[0-4]\d|5[0-5])))(?:(?:\.(?:[01]?\d?\d|2(?:[0-4]\d|5[0-5])))(\/(?:(?:[01]?\d?\d|2(?:[0-4]\d|5[0-5]))))?|(\/(?:(?:[01]?\d?\d|2(?:[0-4]\d|5[0-5])))\.(?:(?:[01]?\d?\d|2(?:[0-4]\d|5[0-5])))))$/;
|
|
@@ -337,9 +350,22 @@ export default {
|
|
|
let isSave = true;
|
|
|
if (ipArr.length >= 2) {
|
|
|
ipArr.forEach((item) => {
|
|
|
- if (this.isValidIP(item) == true || this.isValidseg(item) == true) {
|
|
|
- // this.$message.error("请输入正确IP段,并以;号隔开");
|
|
|
- isSave = true;
|
|
|
+ if (
|
|
|
+ this.isValidIP(item) == true ||
|
|
|
+ this.isValidseg(item) == true ||
|
|
|
+ this.isValidIPs(item) == true
|
|
|
+ ) {
|
|
|
+ if (this.isValidseg(item) == true) {
|
|
|
+ let arr = [];
|
|
|
+ arr = item.split("/");
|
|
|
+ let alt = arr[arr.length - 1];
|
|
|
+ if (alt > 32 && this.positiveInteger(alt) == true) {
|
|
|
+ isSave = false;
|
|
|
+ this.$message.error("请输入正确IP段,并以;号隔开");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ isSave = true;
|
|
|
+ }
|
|
|
} else {
|
|
|
this.$message.error("请输入正确IP段,并以;号隔开");
|
|
|
isSave = false;
|
|
@@ -348,9 +374,20 @@ export default {
|
|
|
} else {
|
|
|
if (
|
|
|
this.isValidIP(ipArr[0]) == true ||
|
|
|
- this.isValidseg(ipArr[0]) == true
|
|
|
+ this.isValidseg(ipArr[0]) == true ||
|
|
|
+ this.isValidIPs(ipArr[0]) == true
|
|
|
) {
|
|
|
- isSave = true;
|
|
|
+ if (this.isValidseg(ipArr[0]) == true) {
|
|
|
+ let arr = [];
|
|
|
+ arr = ipArr[0].split("/");
|
|
|
+ let alt = arr[arr.length - 1];
|
|
|
+ if (alt > 32 && this.positiveInteger(alt) == true) {
|
|
|
+ isSave = false;
|
|
|
+ this.$message.error("请输入正确IP段,并以;号隔开");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ isSave = true;
|
|
|
+ }
|
|
|
} else {
|
|
|
if (ipArr.length != 0) {
|
|
|
this.$message.error("请输入正确IP段,并以;号隔开");
|