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