diff --git a/src/main/java/com/nis/web/controller/basics/InnerProtectionListController.java b/src/main/java/com/nis/web/controller/basics/InnerProtectionListController.java index ae341bdf4..1b7a971ad 100644 --- a/src/main/java/com/nis/web/controller/basics/InnerProtectionListController.java +++ b/src/main/java/com/nis/web/controller/basics/InnerProtectionListController.java @@ -77,4 +77,31 @@ public class InnerProtectionListController extends BaseController{ public Map> ajaxGetAllInfo(HttpServletRequest request, HttpServletResponse response){ return innerProtectionListService.ajaxGetAllInfo(); } + + /** + * 校验配置是否已存在 + * @param cfg + * @param request + * @param response + * @return + */ + @ResponseBody + @RequestMapping(value = {"/checkKeywordExist"}) + public boolean checkKeywordExist(ProtectionListInfo cfg, HttpServletRequest request, HttpServletResponse response){ + if(!StringUtil.isEmpty(cfg.getProId())){ // 修改操作 + ProtectionListInfo info = innerProtectionListService.getById(cfg.getProId()); + if(info != null && info.getKeyword().equals(cfg.getKeyword()) && info.getTargetType().equals(cfg.getTargetType())){ + return true; + } + } + Map> map = innerProtectionListService.ajaxGetAllInfo(); + List list = map.get(cfg.getTargetType()); + if(list != null) { + if(list.contains(cfg.getKeyword())) { + return false; + } + } + + return true; + } } diff --git a/src/main/webapp/WEB-INF/views/basics/protectionInfoForm.jsp b/src/main/webapp/WEB-INF/views/basics/protectionInfoForm.jsp index 7daa83dfc..70ece9ec5 100644 --- a/src/main/webapp/WEB-INF/views/basics/protectionInfoForm.jsp +++ b/src/main/webapp/WEB-INF/views/basics/protectionInfoForm.jsp @@ -19,6 +19,26 @@ $(function(){ }, errorContainer: "#messageBox", }); + + jQuery.validator.addMethod("protectedCfgUnique",function(value, element) { + var result = true; + var proId= $("[name='proId']").val(); + var keyword = $("[name='keyword']").val(); + var targetType = $("[name='targetType']").val(); + var ctx=$(element).attr("ctx"); + var url = ctx+"/basics/innerProtectionList/checkKeywordExist"; + $.ajax({ + type:'post', + async:false, + url: url, + data:{"proId":proId,"keyword":keyword,"targetType":targetType}, + success:function(data){ + result = data; + } + }); + + return result; + }); }); @@ -46,15 +66,6 @@ $(function(){
-
-
- -
- -
-
-
-
@@ -70,6 +81,15 @@ $(function(){
+
+
+ +
+ +
+
+
+
diff --git a/src/main/webapp/WEB-INF/views/basics/protectionInfoList.jsp b/src/main/webapp/WEB-INF/views/basics/protectionInfoList.jsp index e582b2b99..8eba1aa75 100644 --- a/src/main/webapp/WEB-INF/views/basics/protectionInfoList.jsp +++ b/src/main/webapp/WEB-INF/views/basics/protectionInfoList.jsp @@ -216,8 +216,8 @@ - + @@ -229,17 +229,17 @@ + + + + + ${fns:abbr(cfg.keyword,20)} - - - - - ${fns:abbr(cfg.description,20)} ${cfg.creatorName } diff --git a/src/main/webapp/static/global/plugins/jquery-validation/1.11.0/localization/messages_en.js b/src/main/webapp/static/global/plugins/jquery-validation/1.11.0/localization/messages_en.js index 7dddbf8db..46e3d35f2 100644 --- a/src/main/webapp/static/global/plugins/jquery-validation/1.11.0/localization/messages_en.js +++ b/src/main/webapp/static/global/plugins/jquery-validation/1.11.0/localization/messages_en.js @@ -94,6 +94,9 @@ expireTip:"Start time and end time interval is at least 1 minute", compareTip:"Start time should not be less than the current time plus 2 minutes.", compileIdCheck:"Please enter the correct query format", - compileIdCheckNum:"The number of queries should not be greater than 200" + compileIdCheckNum:"The number of queries should not be greater than 200", + rangeCross0:"The IP {0} must not between {1} and {2}", + rangeCross1:"The IP range {0} has intersections with {1}", + protectedCfgUnique:"Keyword already exists." }); }(jQuery)); diff --git a/src/main/webapp/static/global/plugins/jquery-validation/1.11.0/localization/messages_ru.js b/src/main/webapp/static/global/plugins/jquery-validation/1.11.0/localization/messages_ru.js index 35ef0523a..d02cd04fc 100644 --- a/src/main/webapp/static/global/plugins/jquery-validation/1.11.0/localization/messages_ru.js +++ b/src/main/webapp/static/global/plugins/jquery-validation/1.11.0/localization/messages_ru.js @@ -94,6 +94,9 @@ expireTip:"Start time and end time interval is at least 1 minute", compareTip:"Start time should not be less than the current time plus 2 minutes.", compileIdCheck:"Please enter the correct query format", - compileIdCheckNum:"The number of queries should not be greater than 200" + compileIdCheckNum:"The number of queries should not be greater than 200", + rangeCross0:"The IP {0} must not between {1} and {2}", + rangeCross1:"The IP range {0} has intersections with {1}", + protectedCfgUnique:"Keyword already exists." }); }(jQuery)); diff --git a/src/main/webapp/static/global/plugins/jquery-validation/1.11.0/localization/messages_zh.js b/src/main/webapp/static/global/plugins/jquery-validation/1.11.0/localization/messages_zh.js index 814d3b2cb..12aa7df85 100644 --- a/src/main/webapp/static/global/plugins/jquery-validation/1.11.0/localization/messages_zh.js +++ b/src/main/webapp/static/global/plugins/jquery-validation/1.11.0/localization/messages_zh.js @@ -94,6 +94,9 @@ expireTip:"开始时间结束时间间隔至少为1分钟", compareTip:"开始时间不能小于当前时间加上2分钟 ", compileIdCheck:"请输入正确的查询格式", - compileIdCheckNum:"查询个数不能大于200" + compileIdCheckNum:"查询个数不能大于200", + rangeCross0:"IP{0}不能介于{1}和{2}", + rangeCross1:"IP范围{0}和IP范围{1}有交集", + protectedCfgUnique:"关键字已存在" }); }(jQuery)); diff --git a/src/main/webapp/static/global/scripts/common.js b/src/main/webapp/static/global/scripts/common.js index c0fa6743f..47b6f94fa 100644 --- a/src/main/webapp/static/global/scripts/common.js +++ b/src/main/webapp/static/global/scripts/common.js @@ -42,6 +42,7 @@ $(function(){ $("."+key).each(function(){ if(!$(this).hasClass("tags")){ this.setAttribute("onblur","protectedListWarn(this,'"+key+"')"); + this.setAttribute("onkeypress","protectedListWarn(this,'"+key+"','keypress')"); } protectedListWarn(this,key); }); @@ -1758,13 +1759,20 @@ function addPrintTableCss(rowValue,cellValue,tableIdValue,cssName){ } } } + /**保护名单提醒**/ -function protectedListWarn(obj,tagKey){ +function protectedListWarn(obj,tagKey,flag){ + // 值为空 或 非回车事件直接返回 + if(($(obj).val() == '') || (flag != null && event.keyCode != 13)){ + return false; + } + var pathName = window.document.location.pathname.substring(0,window.document.location.pathname.lastIndexOf("/nis")+4); $.ajax({ type:'get', url:pathName+'/basics/innerProtectionList/ajaxGetAllInfo', dataType:"json", + async:false, success:function(data){ if(data != null){ for(var key in data){ @@ -1772,6 +1780,7 @@ function protectedListWarn(obj,tagKey){ $("."+key).each(function(){ if(!$(this).hasClass("tags")){ this.setAttribute("onblur","protectedListWarn(this,'"+key+"')"); + this.setAttribute("onkeypress","protectedListWarn(this,'"+key+"','keypress')"); } }); } @@ -1781,8 +1790,22 @@ function protectedListWarn(obj,tagKey){ var protectedList = data[tagKey]; if(value != "" && typeof(protectedList) != "undefined"){ if(protectedList.indexOf(value) >= 0){ // 关键字匹配则弹出提示框 - $.jBox.info($.validator.messages.protect_warn,$.validator.messages.info); + // 剪切事件属性,防止弹出多个提示框(回车事件会同时触发失去焦点事件) + var blurCopy = $(obj).attr("onblur"); + var keypressCopy = $(obj).attr("onkeypress"); + $(obj).attr("onblur",""); + $(obj).attr("onkeypress",""); + + // 阻止表单提交 + $.jBox.close(); + $(obj).parents("form:first").find("button[type='submit']").attr("type","button"); + $.jBox.info($.validator.messages.protect_warn,$.validator.messages.info, {closed:function(v,h,f){ + $(obj).attr("onblur",blurCopy); + $(obj).attr("onkeypress",keypressCopy); + $(obj).parents("form:first").find("button[id='save']").attr("type","submit"); + }}); $('.jbox-body .jbox-icon').css('top','55px'); + } }