yxysendFilter.js 16.6 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627
//发送过滤js
var yxyFilter_currpage=1;//当前页
var yxyFilter_tolpage=1;//总页数
var yxyFilter_filetypeid=0;//文件类别id
var yxyFilter_pageNum=10;//每页显示的条数
var yxyFilter_leiList="";//类别变量
var yxyFilter_AddressID;//地址ID
var yxyFilter_ready=0;//是不是初始化是查询所有否则根据类别查
var yxyFilter_isesites=0;//是否存在
var yxyFilter_initaddress="";//初始地址
var before_submit_address = "";//提交编辑过滤地址前的数据
$(document).ready(function(){ 
	//1.查询发送过滤类别
		findFilter();
	//2.查询发送过滤地址
		findFilterAddress(1);
	//3.根据分组查询
	$("#yxyFilter_info").change(function(){
		yxyFilter_filetypeid=$("#yxyFilter_info").val();
		yxyFilter_ready=1;
		findFilterAddress(1);
	});

});

//查询发送过滤类别
function findFilter(){
	$.ajax({
		type:"post",
		cache: false,
		async:false,
		type: "post", 
		url: "filter_findSendFilterAll.action", 
		dataType:"json",
		error: function() {alert("异常");}, 
		success: function(msg) {
			var w= new Array();
			yxyFilter_leiList=msg;
			var html='';
			html+='<option value=0>默认分组</option>';
			var htmls='<option id="filterID0" value=0>默认分组</option>';
			//迭代类别
			if(msg!=null&&msg!=""){
				$.each(msg,function(s,row){
					htmls+='<option id=filterID'+row.filterid+' value='+row.filterid+'>'+row.filtername+'</option>';		
					html+='<option value='+row.filterid+'>'+row.filtername+'</option>';	
					//类别管理
					var q= new Array();
					q[0]=(s+1)+"";
					q[1]='<span id=nameLast'+row.filterid+'>'+row.filtername+'<span>';
					var fiterDate=row.filterdate.split(" ");
					q[2]='<span title='+fiterDate[1]+'>'+fiterDate[0]+'</span>';
					q[3]='<a href="javascript:void(0);" onclick="edit_fiterType('+row.filterid+',\''+row.filtername+'\')">编辑</a>|<a href="javascript:void(0);" onclick="del_fiterType('+row.filterid+')">删除</a>|<a href="javascript:void(0);" onclick="edit_fiterType('+row.filterid+')">清空</a>';
				   	w[s]=q;
				});
				$("#yxyFilterMangeDiv").lgytable({
					tbinfo:'分组管理',//"草稿邮件",
					tbpageshow:false,
					tbtitle:['编号','分组名', '建立时间','操作'], 
					tbwidth:['30','100','100', '100'],
					tbcon:[{"tbcon":w,"dqpage":0,"tolpage":0,"tolcount":0}]
				});
			}			
			$("#yxyFilter_info").html(html);
			$("#yxyFilter_List").html(html);
			$("#yxyFilter_editinfo").html(htmls);
		}
	});	
}
//查询发送过滤地址
function findFilterAddress(currpage){
	$.ajax({
		type:"post",
		cache: false,
		async:false,
		type: "post", 
		url: "filter_findFilterAddressByFilterID.action", 
		dataType:"json",
		data:{
			currentPage:currpage,
			pageSize:yxyFilter_pageNum,
			filterID:yxyFilter_filetypeid,
			isready:yxyFilter_ready
		},
		error: function() {alert("异常");}, 
		success: function(msg) {
			$("#countdiv").show();
			columnsShow(msg);
		}
	});	
}

//模糊查询地址列表
function findFilterAddressLike(){
	$.ajax({
		type:"post",
		cache:false,
		async:false,
		type: "post", 
		url: "filter_findFilterAddressLike.action", 
		dataType:"json",
		data:{
			findValue:$("#findFilterValue").val()
		},
		error: function() {alert("异常");}, 
		success: function(msg) {
			$("#countdiv").hide();
			columnsShow(msg);
		}
	});
}
//列表迭代
function columnsShow(msg){
	var w= new Array();
	$.each(msg.yxysendfilteraddresslist,function(index,row){
		//查询所属分组
		var feizu="默认分组";				
		$.each(yxyFilter_leiList,function(s,c){
			if(c.filterid==row.filterid){
				feizu=c.filtername;
				return false;
			}				
		});
		
		var q= new Array();
		q[0]='<input type="checkbox" class="Filter_checkbox" name="Filter_checkbox" id="Filter_checkbox" value='+row.filteraddrid+'>|center';
		q[1]=row.filteraddress;
		var timerstr=(row.filteraddrdate).split(" ");
		q[2]='<span title='+timerstr[1]+'>'+timerstr[0]+'</span>';
		q[3]=feizu;
		q[4]=row.filteraddrreason;
		q[5]='<a href="javascript:void(0);" onClick="editFilterAddress(\''+row.filteraddrid+'\',\''+row.filteraddrreason+'\',\''+row.filteraddress+'\',\''+row.filterid+'\')";>编辑</a>';
	   w[index]=q;
	});
	var joinhtml='<select id=yxyFilter_skips>';
	for(var p=0;p<msg.pageBean.totalPage;p++){
		if((p+1)==yxyFilter_currpage){
			joinhtml+='<option selected=selected>'+(p+1)+'</option>';
		}else{
			joinhtml+='<option>'+(p+1)+'</option>';
		}
		
	}
	joinhtml+='</select>';
	
	var joinhtml1='<select id=yxyFilter_page>';
	for(var o=50;o<=200;o=o+50){
		if(o==yxyFilter_pageNum){
			joinhtml1+='<option selected=selected>'+o+'</option>';
		}else{
			joinhtml1+='<option>'+o+'</option>';
		}
	}
	joinhtml1+='</select>';
	$("#yxyFilter_list").lgytable({
		tbinfo:'过滤地址',
		tbtitle:['<input type="checkbox" id="Filter_checkeAll" class="checkeAll" name="Filter_checkbox1" onClick="Filter_checkeAll()" value="yes"/>|center','过滤地址', '添加时间','所属分组', '过滤理由','操作'], 
		tbwidth:['50','200','100', '100', '200','100'],
		tbcon:[{"tbcon":w,"dqpage":msg.pageBean.currentPage,"tolpage":msg.pageBean.totalPage,"tolcount":msg.pageBean.totalRecord}],
		homepage:function(){
			findFilterAddress(1);
		},
		prepage:function(){
			yxyFilter_currpage=msg.pageBean.currentPage;
			if(yxyFilter_currpage>1){
				findFilterAddress(yxyFilter_currpage-1);
				yxyFilter_currpage--;
			}
		},
		nextpage:function(){
			yxyFilter_currpage=msg.pageBean.currentPage;
			if(yxyFilter_currpage<msg.pageBean.totalPage){
				findFilterAddress(yxyFilter_currpage+1);
				yxyFilter_currpage++;
			}
		},
		lastpage:function(){
			findFilterAddress(msg.pageBean.totalPage);
		},
		tbsetnumtxt:joinhtml1,
		tbsetnum:function(){//每页显示量
			yxyFilter_pageNum=$("#yxyFilter_page").val();
			findFilterAddress(1);
		},
		tbsetpagetxt:joinhtml,
		tbsetpage:function(){//跳转到某页
			yxyFilter_currpage=$("#yxyFilter_skips").val();
			findFilterAddress(yxyFilter_currpage);
		}
	});		
}

//添加过滤分组类别
function yxyFilter_AddFilter(){
	//判断是否输入了分组名
	if($("#yxyFilter_AddName").val()==null||$("#yxyFilter_AddName").val()==""){
		alert("请输入分组名");
	}else{
		$.ajax({
		type:"post",
		cache: false,
		async:false,
		type: "post", 
		url: "filter_addFilter.action", 
		dataType:"json",
		data:{
			filterName:$("#yxyFilter_AddName").val()
		},
		error: function() {alert("异常");}, 
		success: function(msg) {
			if(msg==1){
				findFilter();
				upseccess("添加成功");
				yxy_confirmTerm('yxyFilter_adddiv');
			}else{
				alert("添加失败!");
				yxy_confirmTerm('yxyFilter_adddiv');
			}
		}
	});
  }		
}

//添加过滤地址提交
function yxyFilter_addrcommit(){
	if($("#yxyFilter_addAddr").val()==null||$("#yxyFilter_addAddr").val()==""){
		alert("请输入过滤地址!");
	}else{
		$.ajax({
		type:"post",
		cache: false,
		async:false,
		type: "post", 
		url: "filter_addFilterAddressPi.action", 
		dataType:"json",
		data:{
			addFilterAddress:$("#yxyFilter_addAddr").val(),
			filterreason:$("#yxyFilterReason").val(),
			filterID:$("#yxyFilter_List").val()
		},
		error: function() {alert("异常");}, 
		success: function(msg) {
			if(msg.result==1){
				var addSuccessNum=msg.resultList[0]-(msg.resultList[1]+msg.resultList[2]);
				$("#yxyFileter_alert").html("添加成功:"+addSuccessNum+"条,总共有:"+msg.resultList[0]+"条,其中重复:"+msg.resultList[1]+"条,不合法:"+msg.resultList[2]+"条");
				$("#yxyFileter_alert").show();
				//upseccess();
				findFilterAddress(yxyFilter_currpage);
				
			}else{
				alert("添加失败!");
			}
		}
	});
	}
	
}

//手动自动切换
function yxyFilter_addrbutton(value){
	if(value==0){
		$("#yxyFilter_handadd").show();
		$("#yxyFilter_importdiv").hide();
	}else{
		$("#yxyFilter_importdiv").show();
		$("#yxyFilter_handadd").hide();
	}
}

//批量导入地址
function yxyFilter_importAddress(){
	if($("#yxyFilter_addr").val()==null||$("#yxyFilter_addr").val()==""){
		alert("请选择需要导入的文件");
	}else{
		//定义
		 var option={
		   url: 'filter_addFilterAddressFile.action',
		   dataType:'json',
		   data:{
			   addrFileName:$("#yxyFilter_addr").val(),
			   filterID:$("#yxyFilter_List").val(),
			   filterreason:$("#yxyFilter_iContext").val()
			},
			async:false,
	    	cache: false,
			complete: function(){
			yxyloadpage('sendFilter.jsp');
			},
		   success: function(msg){
			   if(msg.result==1){
				   var successNum=msg.resultList[0]-(msg.resultList[1]+msg.resultList[2]);
				   $("#yxyFileter_alert").html("总共有:"+msg.resultList[0]+"条,成功导入:"+successNum+"条,不合法有:"+msg.resultList[1]+"条,重复有:"+msg.resultList[0]+"条.");
				$("#yxyFileter_alert").show();
				   //upseccess();
				}else{
					upseccess("导入异常!")
				}
		   }    				
		}
	$("#yxyFilter_importForm").ajaxSubmit(option);
	}
}
//全选全不选
function Filter_checkeAll(){
	if($("#Filter_checkeAll").val()=="yes"){
		$("#Filter_checkeAll").attr("value","no");
		//全选
		$("input[name='Filter_checkbox']").each(function(){
			$(this).attr("checked","checked");
		});		
	}else if($("#Filter_checkeAll").val()=="no"){
		$("#Filter_checkeAll").attr("value","yes");
		//全不选
		$("input[name='Filter_checkbox']").each(function(){
			$(this).attr("checked",false);
		 });			
	}
}

//选择checkbox
function Filter_chooseCheckbox(){	
	var Addr_checkObj= $(".Filter_checkbox");
	$.each(Addr_checkObj,function(s,row){
		if($(row).attr("checked")=="checked"){		
			yxyFilter_AddressID+=$(this).val()+',';		
		}						 
	});
}

//删除地址
function delFilterAddress(){
	//选择要删除的地址
	yxyFilter_AddressID="";
	Filter_chooseCheckbox();
	if(yxyFilter_AddressID==null||yxyFilter_AddressID==""){
		alert("请选择要删除的地址!");
	}else{
		var a= confirm("你确定删除该地址?"); 
		if(a==true){			
			$.ajax({
				type:"post",
				cache: false,
				async:false,
				type: "post", 
				url: "filter_delFilterAddressID.action", 
				dataType:"json",
				data:{
					addressID:yxyFilter_AddressID
				},
				error: function() {alert("异常");}, 
				success: function(msg) {
					if(msg==1){
						findFilterAddress(yxyFilter_currpage);
					}else{
						alert("删除失败!");
					}
				}
			});
		}else{
			return ;
		}
	}
}

//编辑地址
function editFilterAddress(addressID,context,address,filterID){
	yxyFilter_initaddress=address;
	before_submit_address = addressID + "###" + address + "###" + context + "###" + filterID;
	//弹出层
	yxy_tipsWindown("编辑过滤地址","yxyFilter_editAddressdiv",400);
	$("#yxyFilter_AddressName").val(address);
	$("#yxyFilter_AddressBody").val(context);
	$("#yxyFilter_addressID").val(addressID);
	//查询所属分组			
	$.each(yxyFilter_leiList,function(s,c){
		if(c.filterid==filterID){
			$("#filterID"+c.filterid).attr("selected","true");
			return false;
		}				
	});
}

//编辑提交
function editFilterAddressCommit(div){
	//判断提交的数据是否正确
	if($("#yxyFilter_AddressName").val()==""||$("#yxyFilter_AddressBody").val()==""){
		alert("请输入正确的数据");
	}else{
			//判断是否存在
			filterisexites();
			if(yxyFilter_isesites==1){
				$.ajax({
					type:"post",
					cache: false,
					async:false,
					type: "post", 
					url: "filter_updateFilterAddress.action", 
					dataType:"json",
					data:{
						addFilterAddress:$("#yxyFilter_AddressName").val(),
						filterreason:$("#yxyFilter_AddressBody").val(),
						filterID:$("#yxyFilter_editinfo").val(),
						addressID:$("#yxyFilter_addressID").val(),
						before_submit_address:before_submit_address,
						after_submit_address:$("#yxyFilter_addressID").val()+"###"+$("#yxyFilter_AddressName").val()+"###"+$("#yxyFilter_AddressBody").val()+"###"+$("#yxyFilter_editinfo").val()
					},
					error: function() {alert("异常");}, 
					success: function(msg) {
						if(msg==1){
							findFilterAddress(yxyFilter_currpage);
							upseccess("编辑成功");
							yxy_confirmTerm(div);
							
						}else if(msg==2){
							upseccess("修改的地址不合法!");
						}else if(msg==3){
							upseccess("修改的地址已存在!");
						}else if(msg==0){
							upseccess("编辑异常!");
						}
					}
				});
			}else{
				upseccess("验证未通过!");
			}
			
	}
}

//判断编辑地址是否存在
function filterisexites(){	
	if(yxyFilter_initaddress==$("#yxyFilter_AddressName").val()){
		yxyFilter_isesites=1;
		$("#yxyFilter_addris").html("");
	}else{
		
		$.ajax({
			type:"post",
			cache: false,
			async:false,
			type: "post", 
			url: "filter_findbyaddress.action", 
			dataType:"json",
			data:{
				addFilterAddress:$("#yxyFilter_AddressName").val(),
			},
			error: function() {alert("异常");}, 
			success: function(msg) {
				if(msg==1){//可用
					yxyFilter_isesites=1;
					$("#yxyFilter_addris").html("");
				}else{//不可用
					yxyFilter_isesites=0;
					$("#yxyFilter_addris").html("地址已存在!");
				}
			}
		});
	}
	
}

//过滤分组管理
function FiterOpen(){
	$.weeboxs.open('#yxyFilterMangeDiv', {
		title:"过滤分组管理",
        onopen:function() {

			findFilter2();
		},
		onok:function(box){
			
			box.close();//增加事件方法后需手动关闭弹窗
		},
		width:500,
		height:200,
		showButton:false,
		oncancel:function(box){
			box.close();//增加事件方法后需手动关闭弹窗
		}
	});
}

//编辑过滤分组类别框
function edit_fiterType(id,filername){
	$.weeboxs.open('#yxyFilterEditDiv', {
		title:"过滤分组编辑",
        onopen:function() {
			$("#editTypeName").val(filername);
		},
		onok:function(box){
			comitFilter(id,filername);
			box.close();//增加事件方法后需手动关闭弹窗
		},
		width:300,
		height:50,
		oncancel:function(box){
			box.close();//增加事件方法后需手动关闭弹窗
		}
	});
	
}
//编辑过滤分组类别提交
function comitFilter(id,oldFilterName){
	$.ajax({
		type:"post",
		cache: false,
		async:false,
		type: "post", 
		url: "filter_editFilter.action", 
		dataType:"json",
		data:{
			filterID:id,
			filterName:$("#editTypeName").val(),
			oldFilterName:oldFilterName
		},
		error: function() {alert("异常");}, 
		success: function(msg) {
			
			if(msg==1){
				//$("#nameLast"+id).html($("#editTypeName").val());
				findFilter2();
				//findFilter();
				//FiterOpen();
			}else{
				alert("编辑失败!");
			}
		}
	});
}

//查询发送过滤类别(要第二次重新加载才行)
function findFilter2(){
	$.ajax({
		type:"post",
		cache: false,
		async:false,
		type: "post", 
		url: "filter_findSendFilterAll.action", 
		dataType:"json",
		error: function() {alert("异常");}, 
		success: function(msg) {
			var w= new Array();
			yxyFilter_leiList=msg;
			var html='';
			html+='<option value=0>默认分组</option>';
			var htmls='<option id="filterID0" value=0>默认分组</option>';
			//迭代类别
			if(msg!=null&&msg!=""){
				$.each(msg,function(s,row){
					htmls+='<option id=filterID'+row.filterid+' value='+row.filterid+'>'+row.filtername+'</option>';		
					html+='<option value='+row.filterid+'>'+row.filtername+'</option>';	
					//类别管理
					var q= new Array();
					q[0]=(s+1)+"";
					q[1]='<span id=nameLast'+row.filterid+'>'+row.filtername+'<span>';
					var fiterDate=row.filterdate.split(" ");
					q[2]='<span title='+fiterDate[1]+'>'+fiterDate[0]+'</span>';
					q[3]='<a href="javascript:void(0);" onclick="edit_fiterType('+row.filterid+',\''+row.filtername+'\')">编辑</a>|<a href="javascript:void(0);" onclick="del_fiterType('+row.filterid+')">删除</a>|<a href="javascript:void(0);" onclick="clear_fiterType('+row.filterid+')">清空</a>';
				   	w[s]=q;
				});
				$(".dialog-content").lgytable({
					tbinfo:'分组管理',//"草稿邮件",
					tbpageshow:false,
					tbtitle:['编号','分组名', '建立时间','操作'], 
					tbwidth:['30','100','100', '100'],
					tbcon:[{"tbcon":w,"dqpage":0,"tolpage":0,"tolcount":0}]
				});
			}			
			$("#yxyFilter_info").html(html);
			$("#yxyFilter_List").html(html);
			$("#yxyFilter_editinfo").html(htmls);
		}
	});	
}

//删除过滤分组
function del_fiterType(id){
	var a= confirm("确定删除?"); 
	if(a==true){
		$.ajax({
			type:"post",
			cache: false,
			async:false,
			type: "post", 
			url: "filter_delFilter.action", 
			dataType:"json",
			data:{
				filterID:id,
			},
			error: function() {alert("异常");}, 
			success: function(msg) {
				if(msg==1){
					findFilter2();
				}else{
					alert("操作失败!");
				}
			}
		});
	}
}

//清空过滤分组类别
function clear_fiterType(id){
	var a= confirm("确定清空该类别下的地址?"); 
	if(a==true){
		$.ajax({
			type:"post",
			cache: false,
			async:false,
			type: "post", 
			url: "filter_clearFilter.action", 
			dataType:"json",
			data:{
				filterID:id,
			},
			error: function() {alert("异常");}, 
			success: function(msg) {
				if(msg==1){
					findFilterAddress(yxyFilter_currpage);
					alert("操作成功!");
				}else{
					alert("操作失败!");
				}
			}
		});
	}
}