修正保护名单配置回车不提示、重复数据问题
Conflicts: src/main/webapp/static/global/plugins/jquery-validation/1.11.0/localization/messages_en.js src/main/webapp/static/global/plugins/jquery-validation/1.11.0/localization/messages_ru.js src/main/webapp/static/global/plugins/jquery-validation/1.11.0/localization/messages_zh.js
This commit is contained in:
committed by
duandongmei
parent
aaa0028cbb
commit
c982b506a4
@@ -77,4 +77,31 @@ public class InnerProtectionListController extends BaseController{
|
||||
public Map<String,List<String>> 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<String, List<String>> map = innerProtectionListService.ajaxGetAllInfo();
|
||||
List<String> list = map.get(cfg.getTargetType());
|
||||
if(list != null) {
|
||||
if(list.contains(cfg.getKeyword())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
@@ -46,15 +66,6 @@ $(function(){
|
||||
<input type="hidden" name="proId" value="${_cfg.proId}">
|
||||
<div class="form-body">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-md-3"><font color="red">*</font><spring:message code="keywords"/></label>
|
||||
<div class="col-md-6">
|
||||
<input class="form-control required" type="text" name="keyword" value="${_cfg.keyword}">
|
||||
</div>
|
||||
<div for="keyword"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-md-3"><font color="red">*</font><spring:message code="type"/></label>
|
||||
@@ -70,6 +81,15 @@ $(function(){
|
||||
<div for="targetType"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-md-3"><font color="red">*</font><spring:message code="keywords"/></label>
|
||||
<div class="col-md-6">
|
||||
<input class="form-control protectedCfgUnique required" ctx="${ctx}" type="text" name="keyword" value="${_cfg.keyword}">
|
||||
</div>
|
||||
<div for="keyword"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
|
||||
@@ -216,8 +216,8 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th><input type="checkbox" class="i-checks" id="checkAll"></th>
|
||||
<th column="keyword" ><spring:message code="keywords"/></th>
|
||||
<th column="targetType" ><spring:message code="type"/></th>
|
||||
<th column="keyword" ><spring:message code="keywords"/></th>
|
||||
<th column="desc" ><spring:message code="desc"/></th>
|
||||
<th column="creator" ><spring:message code="creator"/></th>
|
||||
<th column="config_time" class="sort-column r.create_time"><spring:message code="config_time"/></th>
|
||||
@@ -229,17 +229,17 @@
|
||||
<c:forEach items="${page.list }" var="cfg" varStatus="status" step="1">
|
||||
<tr>
|
||||
<td><input type="checkbox" class="i-checks child-checks" id="${cfg.proId}"></td>
|
||||
<td>
|
||||
<c:if test="${cfg.targetType eq 'urlCheck'}"><spring:message code="URL"/></c:if>
|
||||
<c:if test="${cfg.targetType eq 'domainCheck'}"><spring:message code="domain"/></c:if>
|
||||
<c:if test="${cfg.targetType eq 'keywordSign'}"><spring:message code="keywords"/></c:if>
|
||||
</td>
|
||||
<td>
|
||||
<a href="javascript:;" data-original-title="${cfg.keyword}"
|
||||
class="tooltips" data-flag="false" data-html="true" data-placement="top">
|
||||
${fns:abbr(cfg.keyword,20)}
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<c:if test="${cfg.targetType eq 'urlCheck'}"><spring:message code="URL"/></c:if>
|
||||
<c:if test="${cfg.targetType eq 'domainCheck'}"><spring:message code="domain"/></c:if>
|
||||
<c:if test="${cfg.targetType eq 'keywordSign'}"><spring:message code="keywords"/></c:if>
|
||||
</td>
|
||||
<td title="${cfg.description }">${fns:abbr(cfg.description,20)}</td>
|
||||
<td>${cfg.creatorName }</td>
|
||||
<td><fmt:formatDate value="${cfg.createTime }" pattern="yyyy-MM-dd HH:mm:ss"/></td>
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user