noticeSetting.sumbitform = function(btn){
var itemArray = new Array();
var ispass = true;
var errorIndex;
$.each($("#settingtable tbody tr"), function(i, item){
var selects = $(this).find("select");
var deviceTypeS = $(selects.get(0)).data("kendoDropDownList");
var deviceStatuS =$(selects.get(1)).data("kendoDropDownList");
var branchareas = $(selects.get(2)).data("kendoMultiSelect");
var item ={"deviceTypeId":parseInt(deviceTypeS.value()),
"deviceStatus":deviceStatuS==null?null:parseInt(deviceStatuS.value()),
"branchareas":branchareas==null?null:branchareas.value()};
itemArray.push(item);
if(deviceStatuS ==null||branchareas==null||branchareas.value().length==0){
errorIndex=i+1;
ispass = false;
return false;
}
});
if(!ispass){
btn.removeAttr("disabled");
$("#addtrbtn").removeAttr("disabled");
$("#sumbitbutton").data("result","");
noticeSetting.notify("第"+errorIndex+"行没选择完整","error");
return false;
}
$.ajax({
url: baseContext+"/omusernoticesetting.json",
cache: false,
dataType:"json",
contentType:"application/json",
type:"post",
data:JSON.stringify(itemArray),
success: function(data){
$("#sumbitbutton").data("result","success");
$("#sumbitbutton").data("count",data.count);
var count = parseInt(data.count);
if(count==0){
noticeSetting.notify("重复设置不会添加","error");
}else if(count>0){
noticeSetting.notify("成功添加"+count+"条设置","success");
}else{
noticeSetting.notify("添加失败","error");
}
btn.removeAttr("disabled");
$("#addtrbtn").removeAttr("disabled");
},
error:function(data){
btn.removeAttr("disabled");
$("#addtrbtn").removeAttr("disabled");
$("#sumbitbutton").data("result","error");
noticeSetting.notify("添加失败","error");
}
})
}