(1)IP Pattern拆分为源IP Pattern,目的IP Pattern,Port Pattern

拆分为源端口Pattern,目的端口Pattern
(2)show more修改,并移动刀ipRegion.js中
(3)IP复用未作修改
(4)删除部分废弃的导入模板以及废弃的导入方法
This commit is contained in:
wangxin
2019-04-18 10:15:23 +08:00
parent 6bd04a92ce
commit 5a5bdddba4
90 changed files with 2957 additions and 3362 deletions

View File

@@ -9,22 +9,71 @@
});
$.extend($.ipcommon, {
ipType:[],
ipPattern:[],
portPattern:[],
srcIpPattern:[],
destIpPattern:[],
srcPortPattern:[],
destPortPattern:[],
protocol:[],
direction:[]
});
})(jQuery);
$(function(){
initCommIpVal();
//IP域修改时默认展开,不显示show more
if($("input[name='compileId']")&&$("input[name='compileId']").val()!=0&&($(".btn-red-hollow").parents(".boxSolid").is(":visible")||$("input[name$='cfgRegionCode']").length==1)){
$(".port").removeClass("hidden").removeClass("disabled");
$(".destPort").removeClass("hidden").removeClass("disabled");
$(".protocol").removeClass("hidden").removeClass("disabled");
$(".ipCol:hidden").removeClass("hidden").removeClass("disabled");
$(".btn-red-hollow").addClass("hidden");
}
});
window.$.ipcommon=$.ipcommon;
/**
* 初始化格式处理
*/
var processPattern=function(selector,pattern){
if("ipType"==selector){
$.ipcommon.ipType=$("select[name$='ipType'] option");
}else if("srcIpPattern"==selector){
$.ipcommon.srcIpPattern=$("select[name$='srcIpPattern'] option");
}else if("destIpPattern"==selector){
$.ipcommon.destIpPattern=$("select[name$='destIpPattern'] option");
}else if("srcPortPattern"==selector){
$.ipcommon.srcPortPattern=$("select[name$='srcPortPattern'] option");
}else if("destPortPattern"==selector){
$.ipcommon.destPortPattern=$("select[name$='destPortPattern'] option");
}else if("direction"==selector){
$.ipcommon.direction=$("select[name$='direction'] option");
}else if("protocol"==selector){
$.ipcommon.protocol=$("select[name$='protocol'] option");
}
if(pattern){
var arr=pattern.split(',');
$("select[name$='"+selector+"'] option").each(function(){
var has=false;
for(var type in arr){
if($(this).val()==arr[type]){
has=true;
if($(this).attr("disabled")){
$(this).removeAttr("disabled")
}
break;
}
}
if(!has){
$(this).remove();
}
});
}
}
/**
* ip默认选项处理
*/
var initCommIpVal=function(){
var action,regionCode,serviceType,ipPortShow,ipType,
ipPattern,portPattern,direction,protocol,regionType;
srcIpPattern,destIpPattern,srcPortPattern,destPortPattern,
direction,protocol,regionType;
if($("input[name$='action']:checked").length>0){
regionCode=$("input[name$='action']:checked").attr("regionCode");
action=$("input[name$='action']:checked").val();
@@ -55,16 +104,20 @@ var initCommIpVal=function(){
if(regionCode){//IP域大于1个根据action获取ip属性
ipPortShow=$("input[name$='cfgRegionCode'][value='"+regionCode+"']").attr("ipPortShow"),
ipType=$("input[name$='cfgRegionCode'][value='"+regionCode+"']").attr("ipType"),
ipPattern=$("input[name$='cfgRegionCode'][value='"+regionCode+"']").attr("ipPattern"),
portPattern=$("input[name$='cfgRegionCode'][value='"+regionCode+"']").attr("portPattern"),
srcIpPattern=$("input[name$='cfgRegionCode'][value='"+regionCode+"']").attr("srcIpPattern"),
destIpPattern=$("input[name$='cfgRegionCode'][value='"+regionCode+"']").attr("destIpPattern"),
srcPortPattern=$("input[name$='cfgRegionCode'][value='"+regionCode+"']").attr("srcPortPattern"),
destPortPattern=$("input[name$='cfgRegionCode'][value='"+regionCode+"']").attr("destPortPattern"),
direction=$("input[name$='cfgRegionCode'][value='"+regionCode+"']").attr("direction"),
protocol=$("input[name$='cfgRegionCode'][value='"+regionCode+"']").attr("protocol"),
regionType=$("input[name$='cfgRegionCode'][value='"+regionCode+"']").attr("regionType");
}else{//IP域只有一个获取regionType为1的
ipPortShow=$("input[name$='cfgRegionCode'][regionType='1']").attr("ipPortShow"),
ipType=$("input[name$='cfgRegionCode'][regionType='1']").attr("ipType"),
ipPattern=$("input[name$='cfgRegionCode'][regionType='1']").attr("ipPattern"),
portPattern=$("input[name$='cfgRegionCode'][regionType='1']").attr("portPattern"),
srcIpPattern=$("input[name$='cfgRegionCode'][regionType='1']").attr("srcIpPattern"),
destIpPattern=$("input[name$='cfgRegionCode'][regionType='1']").attr("destIpPattern"),
srcPortPattern=$("input[name$='cfgRegionCode'][regionType='1']").attr("srcPortPattern"),
destPortPattern=$("input[name$='cfgRegionCode'][regionType='1']").attr("destPortPattern"),
direction=$("input[name$='cfgRegionCode'][regionType='1']").attr("direction"),
protocol=$("input[name$='cfgRegionCode'][regionType='1']").attr("protocol"),
regionType=$("input[name$='cfgRegionCode'][regionType='1']").attr("regionType");
@@ -73,124 +126,92 @@ var initCommIpVal=function(){
if(ipPortShow){
if(ipPortShow.indexOf('1')>-1){//展示源IP
$("input[name$='srcIpAddress']").parents(".form-group").removeClass("hidden");
$("select[name$='srcIpPattern']").parents(".form-group").removeClass("hidden");
}else{
$("input[name$='srcIpAddress']").parents(".form-group").addClass("hidden");
$("select[name$='srcIpPattern']").parents(".form-group").addClass("hidden");
if(!$("input[name$='srcIpAddress']").parents(".ipCol").is(":hidden")){
$("input[name$='srcIpAddress']").parents(".ipCol").addClass("hidden");
}
}
if(ipPortShow.indexOf('2')>-1){//展示源端口
$("input[name$='srcPort']").parents(".form-group").removeClass("hidden");
$("select[name$='srcPortPattern']").parents(".form-group").removeClass("hidden");
}else{
$("input[name$='srcPort']").parents(".form-group").addClass("hidden");
$("select[name$='srcPortPattern']").parents(".form-group").addClass("hidden");
}
if(ipPortShow.indexOf('3')>-1){//展示目的IP
$("input[name$='destIpAddress']").parents(".form-group").removeClass("hidden");
$("select[name$='destIpPattern']").parents(".form-group").removeClass("hidden");
//当源IP不展示的时候目的IP要默认展示
if($("input[name$='destIpAddress']").parents(".ipCol")&&ipPortShow.indexOf('1')==-1){
$("input[name$='destIpAddress']").parents(".ipCol").removeClass("hidden");
}
}else{
$("input[name$='destIpAddress']").parents(".form-group").addClass("hidden");
$("select[name$='destIpPattern']").parents(".form-group").addClass("hidden");
}
if(ipPortShow.indexOf('4')>-1){//展示目的端口
$("input[name$='destPort']").parents(".form-group").removeClass("hidden");
$("select[name$='destPortPattern']").parents(".form-group").removeClass("hidden");
}else{
$("input[name$='destPort']").parents(".form-group").addClass("hidden");
$("select[name$='destPortPattern']").parents(".form-group").addClass("hidden");
}
}
//ip类型处理
$.ipcommon.ipType=$("select[name$='ipType'] option");
if(ipType){
var arr=ipType.split(',');
$("select[name$='ipType'] option").each(function(){
var has=false;
for(var type in arr){
if($(this).val()==arr[type]){
has=true;
if($(this).attr("disabled")){
$(this).removeAttr("disabled")
}
break;
}
}
if(!has){
$(this).remove();
}
});
processPattern("ipType",ipType);
}
//ip格式处理
$.ipcommon.ipPattern=$("select[name$='ipPattern'] option");
if(ipPattern){
arr=ipPattern.split(',');
$("select[name$='ipPattern'] option").each(function(){
var has=false;
for(var type in arr){
if($(this).val()==arr[type]){
has=true;
if($(this).attr("disabled")){
$(this).removeAttr("disabled")
}
break;
}
}
if(!has){
$(this).remove();
}
});
if(srcIpPattern){
processPattern("srcIpPattern",srcIpPattern);
}
//端口格式处理
$.ipcommon.portPattern=$("select[name$='portPattern'] option");
if(portPattern){
arr=portPattern.split(',');
$("select[name$='portPattern'] option").each(function(){
var has=false;
for(var type in arr){
if($(this).val()==arr[type]){
has=true;
if($(this).attr("disabled")){
$(this).removeAttr("disabled")
}
break;
}
}
if(!has){
$(this).remove();
}
});
if(destIpPattern){
processPattern("destIpPattern",destIpPattern);
}
if(srcPortPattern){
processPattern("srcPortPattern",srcPortPattern);
}
if(destPortPattern){
processPattern("destPortPattern",destPortPattern);
}
//方向处理
$.ipcommon.direction=$("select[name$='direction'] option");
if(direction){
arr=direction.split(',');
$("select[name$='direction'] option").each(function(){
var has=false;
for(var type in arr){
if($(this).val()==arr[type]){
has=true;
if($(this).attr("disabled")){
$(this).removeAttr("disabled")
}
break;
}
}
if(!has){
$(this).remove();
}
});
processPattern("direction",direction);
}
//协议处理
$.ipcommon.protocol=$("select[name$='protocol'] option");
if(protocol){
arr=protocol.split(',');
$("select[name$='protocol'] option").each(function(){
processPattern("protocol",protocol);
}
}
var changePattern=function(o,selector,pattern){
if(pattern){
arr=pattern.split(',');
var ipPatternVal=o.find("select[name$='"+selector+"'] option:selected").attr("value");
o.find("select[name$='"+selector+"']").empty();
var patterns=selector=="srcIpPattern"?$.ipcommon.srcIpPattern:
selector=="destIpPattern"?$.ipcommon.destIpPattern:
selector=="srcPortPattern"?$.ipcommon.srcPortPattern:
selector=="destPortPattern"?$.ipcommon.destPortPattern:[];
$(patterns).each(function(){
var has=false;
for(var type in arr){
if($(this).val()==arr[type]){
has=true;
if($(this).attr("disabled")){
$(this).removeAttr("disabled")
}
o.find("select[name$='"+selector+"']").append($(this));
break;
}
}
if(!has){
$(this).remove();
}
});
o.find("select[name$='"+selector+"']").selectpicker("refresh");
if(o.find("select[name$='"+selector+"'] option[value='"+ipPatternVal+"']").length>0){
o.find("select[name$='"+selector+"']").selectpicker("val",ipPatternVal);
}else{
if(o.find("select[name$='"+selector+"'] option[value=1]").length>0){
o.find("select[name$='"+selector+"']").selectpicker("val",1);
}else{
o.find("select[name$='"+selector+"']").get(0).selectedIndex=0;
o.find("select[name$='"+selector+"']").selectpicker("refresh");
}
}
}
}
/**
@@ -198,7 +219,7 @@ var initCommIpVal=function(){
*/
var changeIPVal=function(obj){
var action,regionCode,serviceType,ipPortShow,ipType,
ipPattern,portPattern,direction,protocol,regionType,o;
srcIpPattern,destIpPattern,srcPortPattern,destPortPattern,direction,protocol,regionType,o;
o=$(obj);
if($("input[name$='action']:checked").length>0){
regionCode=$("input[name$='action']:checked").attr("regionCode");
@@ -230,16 +251,20 @@ var changeIPVal=function(obj){
if(regionCode){//IP域大于1个根据action获取ip属性
ipPortShow=$("input[name$='cfgRegionCode'][value='"+regionCode+"']").attr("ipPortShow"),
ipType=$("input[name$='cfgRegionCode'][value='"+regionCode+"']").attr("ipType"),
ipPattern=$("input[name$='cfgRegionCode'][value='"+regionCode+"']").attr("ipPattern"),
portPattern=$("input[name$='cfgRegionCode'][value='"+regionCode+"']").attr("portPattern"),
srcIpPattern=$("input[name$='cfgRegionCode'][value='"+regionCode+"']").attr("srcIpPattern"),
destIpPattern=$("input[name$='cfgRegionCode'][value='"+regionCode+"']").attr("destIpPattern"),
srcPortPattern=$("input[name$='cfgRegionCode'][value='"+regionCode+"']").attr("srcPortPattern"),
destPortPattern=$("input[name$='cfgRegionCode'][value='"+regionCode+"']").attr("destPortPattern"),
direction=$("input[name$='cfgRegionCode'][value='"+regionCode+"']").attr("direction"),
protocol=$("input[name$='cfgRegionCode'][value='"+regionCode+"']").attr("protocol"),
regionType=$("input[name$='cfgRegionCode'][value='"+regionCode+"']").attr("regionType");
}else{//IP域只有一个获取regionType为1的
ipPortShow=$("input[name$='cfgRegionCode'][regionType='1']").attr("ipPortShow"),
ipType=$("input[name$='cfgRegionCode'][regionType='1']").attr("ipType"),
ipPattern=$("input[name$='cfgRegionCode'][regionType='1']").attr("ipPattern"),
portPattern=$("input[name$='cfgRegionCode'][regionType='1']").attr("portPattern"),
srcIpPattern=$("input[name$='cfgRegionCode'][regionType='1']").attr("srcIpPattern"),
destIpPattern=$("input[name$='cfgRegionCode'][regionType='1']").attr("destIpPattern"),
srcPortPattern=$("input[name$='cfgRegionCode'][regionType='1']").attr("srcPortPattern"),
destPortPattern=$("input[name$='cfgRegionCode'][regionType='1']").attr("destPortPattern"),
direction=$("input[name$='cfgRegionCode'][regionType='1']").attr("direction"),
protocol=$("input[name$='cfgRegionCode'][regionType='1']").attr("protocol"),
regionType=$("input[name$='cfgRegionCode'][regionType='1']").attr("regionType");
@@ -249,23 +274,31 @@ var changeIPVal=function(obj){
if(ipPortShow){
if(ipPortShow.indexOf('1')>-1){//展示源IP
$("input[name$='srcIpAddress']").parents(".form-group").removeClass("hidden");
$("select[name$='srcIpPattern']").parents(".form-group").removeClass("hidden");
}else{
$("input[name$='srcIpAddress']").parents(".form-group").addClass("hidden");
$("select[name$='srcIpPattern']").parents(".form-group").addClass("hidden");
}
if(ipPortShow.indexOf('2')>-1){//展示源端口
$("input[name$='srcPort']").parents(".form-group").removeClass("hidden");
$("select[name$='srcPortPattern']").parents(".form-group").removeClass("hidden");
}else{
$("input[name$='srcPort']").parents(".form-group").addClass("hidden");
$("select[name$='srcPortPattern']").parents(".form-group").addClass("hidden");
}
if(ipPortShow.indexOf('3')>-1){//展示目的IP
$("input[name$='destIpAddress']").parents(".form-group").removeClass("hidden");
$("select[name$='destIpPattern']").parents(".form-group").removeClass("hidden");
}else{
$("input[name$='destIpAddress']").parents(".form-group").addClass("hidden");
$("select[name$='destIpPattern']").parents(".form-group").addClass("hidden");
}
if(ipPortShow.indexOf('4')>-1){//展示目的端口
$("input[name$='destPort']").parents(".form-group").removeClass("hidden");
$("select[name$='destPortPattern']").parents(".form-group").removeClass("hidden");
}else{
$("input[name$='destPort']").parents(".form-group").addClass("hidden");
$("select[name$='destPortPattern']").parents(".form-group").addClass("hidden");
}
}
//ip类型处理
@@ -296,60 +329,14 @@ var changeIPVal=function(obj){
}
}
//ip格式处理
if(ipPattern){
arr=ipPattern.split(',');
var ipPatternVal=o.find("select[name$='ipPattern'] option:selected").attr("value");
o.find("select[name$='ipPattern']").empty();
$.ipcommon.ipPattern.each(function(){
var has=false;
for(var type in arr){
if($(this).val()==arr[type]){
has=true;
o.find("select[name$='ipPattern']").append($(this));
break;
}
}
});
o.find("select[name$='ipPattern']").selectpicker("refresh");
if(o.find("select[name$='ipPattern'] option[value='"+ipPatternVal+"']").length>0){
o.find("select[name$='ipPattern']").selectpicker("val",ipPatternVal);
}else{
if(o.find("select[name$='ipPattern'] option[value=1]").length>0){
o.find("select[name$='ipPattern']").selectpicker("val",1);
}else{
o.find("select[name$='ipPattern']").get(0).selectedIndex=0;
o.find("select[name$='ipPattern']").selectpicker("refresh");
}
}
}
//端口格式处理
if(portPattern){
arr=portPattern.split(',');
var portPatternVal=o.find("select[name$='portPattern'] option:selected").attr("value");
o.find("select[name$='portPattern']").empty();
$.ipcommon.portPattern.each(function(){
var has=false;
for(var type in arr){
if($(this).val()==arr[type]){
has=true;
o.find("select[name$='portPattern']").append($(this));
break;
}
}
});
o.find("select[name$='portPattern']").selectpicker("refresh");
if(o.find("select[name$='portPattern'] option[value='"+portPatternVal+"']").length>0){
o.find("select[name$='portPattern']").selectpicker("val",portPatternVal);
}else{
if(o.find("select[name$='portPattern'] option[value=1]").length>0){
o.find("select[name$='portPattern']").selectpicker("val",1);
}else{
o.find("select[name$='portPattern']").get(0).selectedIndex=0;
o.find("select[name$='portPattern']").selectpicker("refresh");
}
}
}
//ip格式处理
changePattern(o,"srcIpPattern",srcIpPattern);
//目的ip格式处理
changePattern(o,"destIpPattern",destIpPattern);
//源端口格式处理
changePattern(o,"srcPortPattern",srcPortPattern);
//目的源端口格式处理
changePattern(o,"destPortPattern",destPortPattern);
//方向处理
if(direction){
arr=direction.split(',');
@@ -405,4 +392,42 @@ var changeIPVal=function(obj){
}
}
}
}
//show more 添加更多属性
var more=function(obj){
var moreCols=$(obj).parents(".row").siblings(".ipCol").not(":hidden").last().nextAll(":hidden");
if(moreCols.length==0){
var clickTimes=$(obj).data("click-times");
if(clickTimes==0){
$(".port").removeClass("hidden").removeClass("disabled");
$(obj).data("click-times",clickTimes+1);
}
if(clickTimes==1){
$(".destPort").removeClass("hidden").removeClass("disabled");
$(obj).data("click-times",clickTimes+1);
}
if(clickTimes==2){
$(".protocol").removeClass("hidden").removeClass("disabled");
$(obj).data("click-times",clickTimes+1);
}
var rows=$(obj).parent(".row").siblings(".row:hidden");
if(rows.size()==0){
$(obj).addClass("hidden");
}
}else{
if(moreCols.length>0){
//$(moreCols[0]).removeClass("hidden").removeClass("disabled");
$(moreCols).each(function(i){
$(this).removeClass("hidden").removeClass("disabled");
if($(this).find("form-group:hidden").length>0){
return true;
}else{
return false;
}
});
if($(obj).parents(".row").siblings(".ipCol").not(":hidden").last().nextAll(":hidden").length==0){
$(obj).addClass("hidden");
}
}
}
}