修正保护名单配置回车不提示、重复数据问题

This commit is contained in:
zhangwenqing
2019-04-19 17:44:12 +08:00
parent 865811b9b2
commit 99c3c8c84f
7 changed files with 93 additions and 20 deletions

View File

@@ -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);
});
@@ -1556,13 +1557,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){
@@ -1570,6 +1578,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')");
}
});
}
@@ -1579,8 +1588,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');
}
}