From 531f85017dd6d8337fc5c5951e386ec84df111b7 Mon Sep 17 00:00:00 2001 From: wangxin Date: Mon, 27 Aug 2018 17:40:14 +0800 Subject: [PATCH] =?UTF-8?q?ip=E5=B1=9E=E6=80=A7=E5=85=B1=E7=94=A8=E5=80=BC?= =?UTF-8?q?=E6=8F=90=E5=8F=96=E4=B8=BA=E4=B8=80=E4=B8=AA=E5=85=A8=E5=B1=80?= =?UTF-8?q?=E7=9A=84=E5=87=BD=E6=95=B0=EF=BC=8C=E5=BD=93initCommIpVal?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E7=9A=84=E6=97=B6=E5=80=99=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96ipcommon=E7=9A=84=E5=B1=9E=E6=80=A7=EF=BC=8C=E5=B9=B6?= =?UTF-8?q?=E4=B8=94=E5=88=9D=E5=A7=8B=E5=8C=96=E5=AE=8C=E6=88=90=E4=B9=8B?= =?UTF-8?q?=E5=90=8E=E5=B0=86=E9=A1=B5=E9=9D=A2=E6=97=A0=E7=94=A8=E7=9A=84?= =?UTF-8?q?select=20option=E7=9B=B4=E6=8E=A5remove?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WEB-INF/views/cfg/ipaddr/ipForm.jsp | 8 +++-- .../webapp/static/global/scripts/common.js | 35 ++++++++++++++++--- 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/src/main/webapp/WEB-INF/views/cfg/ipaddr/ipForm.jsp b/src/main/webapp/WEB-INF/views/cfg/ipaddr/ipForm.jsp index df5efbe25..381a2b760 100644 --- a/src/main/webapp/WEB-INF/views/cfg/ipaddr/ipForm.jsp +++ b/src/main/webapp/WEB-INF/views/cfg/ipaddr/ipForm.jsp @@ -67,10 +67,14 @@ } //处理ICMP if($(this).val()==32){ - tabInfo.find("select[name$='protocol'] option[value='1']").removeAttr("disabled"); + $.ipcommon.protocol.each(function(){ + if($(this).attr("value")==1){ + tabInfo.find("select[name$='protocol']").append($(this)); + } + }) tabInfo.find("select[name$='protocol']").selectpicker("refresh"); }else{ - tabInfo.find("select[name$='protocol'] option[value='1']").attr("disabled",true); + tabInfo.find("select[name$='protocol'] option[value='1']").remove(); tabInfo.find("select[name$='protocol']").selectpicker("refresh"); } diff --git a/src/main/webapp/static/global/scripts/common.js b/src/main/webapp/static/global/scripts/common.js index 3a15bcff8..db3543eff 100644 --- a/src/main/webapp/static/global/scripts/common.js +++ b/src/main/webapp/static/global/scripts/common.js @@ -1,4 +1,16 @@ $(function(){ + //扩展jquery,增加全局函数 + $.ipcommon=function(){ + return {}; + } + $.extend($.ipcommon, { + ipType:[], + ipPattern:[], + portPattern:[], + protocol:[], + direction:[] + + }); $("select[name$='isHexbin']").each(function(){ setIsHexBin(this); }); @@ -1453,6 +1465,7 @@ var initCommIpVal=function(){ //ip类型处理 if(ipType){ var arr=ipType.split(','); + $.ipcommon.ipType=$("select[name$='ipPattern'] option"); $("select[name$='ipType'] option").each(function(){ var has=false; for(var type in arr){ @@ -1465,13 +1478,14 @@ var initCommIpVal=function(){ } } if(!has){ - $(this).attr("disabled",true); + $(this).remove(); } }); } //ip格式处理 if(ipPattern){ arr=ipPattern.split(','); + $.ipcommon.ipPattern=$("select[name$='ipPattern'] option"); $("select[name$='ipPattern'] option").each(function(){ var has=false; for(var type in arr){ @@ -1484,13 +1498,16 @@ var initCommIpVal=function(){ } } if(!has){ - $(this).attr("disabled",true); + $(this).remove(); } }); + }else{ + $.ipcommon.ipPattern=[]; } //端口格式处理 if(portPattern){ arr=portPattern.split(','); + $.ipcommon.portPattern=$("select[name$='portPattern'] option"); $("select[name$='portPattern'] option").each(function(){ var has=false; for(var type in arr){ @@ -1503,13 +1520,16 @@ var initCommIpVal=function(){ } } if(!has){ - $(this).attr("disabled",true); + $(this).remove(); } }); + }else{ + $.ipcommon.portPattern=[]; } //方向处理 if(direction){ arr=direction.split(','); + $.ipcommon.direction=$("select[name$='direction'] option"); $("select[name$='direction'] option").each(function(){ var has=false; for(var type in arr){ @@ -1522,13 +1542,16 @@ var initCommIpVal=function(){ } } if(!has){ - $(this).attr("disabled",true); + $(this).remove(); } }); + }else{ + $.ipcommon.direction=[]; } //协议处理 if(protocol){ arr=protocol.split(','); + $.ipcommon.protocol=$("select[name$='protocol'] option"); $("select[name$='protocol'] option").each(function(){ var has=false; for(var type in arr){ @@ -1541,8 +1564,10 @@ var initCommIpVal=function(){ } } if(!has){ - $(this).attr("disabled",true); + $(this).remove(); } }); + }else{ + $.ipcommon.protocol=[]; } } \ No newline at end of file