f83c077ef0f752d251df9a8857ff49f182f2ae69.svn-base 33.9 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 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852
/**
 * Created by lgy on 2015/10/20.
 */

App.controller('filterCtrl', function ($scope, $http, $location) {
    'use strict';

})
    .controller('filtertypeCtrl', function ($scope, $http, $location, FilterListALL) {
        'use strict';
        //查看过滤地址分组
        $scope.viewfiltertype=function(){
        	$(".yyloading").show();
            FilterListALL.filterinfo().then(function (data) {
            	$(".yyloading").hide();
                $scope.filterlists = data;
            });
        };
        $scope.viewfiltertype();

        var datapost={
            currpage:1,
            pagesize:$scope.pagesize,
            condition:0,
            conditionvalue:""
        };

        //分页
        $scope.numPages = 1;
        $scope.CurrentPage = 1;
        $scope.condition=0;//定义全局变量	
        $scope.setPage = function (pageNo) {
            console.log(pageNo)
            $scope.numPages = pageNo;
        };
        $scope.pageChanged = function () {
            var tid=$("#filtertypename").val();
            var con=$("#filtersearchcon").val();
            if(parseInt(tid)==0){
                datapost = {
                    currpage:$scope.CurrentPage,
                    pagesize:$scope.pagesize,
                    condition:$scope.condition,
                    conditionvalue:con
                };
            }else{
                datapost = {
                    currpage:$scope.CurrentPage,
                    pagesize:$scope.pagesize,
                    condition:1,
                    conditionvalue:tid
                };
            }

            $scope.queryaddress(datapost);
        };
        //查询过滤地址
        $scope.queryaddress = function (datapost) {
            $(".yyloading").show();
            FilterListALL.mailaddress(datapost).then(function (data) {
                $(".yyloading").hide();
                $scope.filteraddresslists=data.filteraddresslist;//显示数据
                $scope.TotalItems = data.pagebean.totalRecord;//显示分页
            });
        };
        $scope.queryaddress(datapost);


        //获取分组名称
        $scope.getfiltername=function(id){
            var fname="无分组";
            $.each($scope.filterlists,function(s1,s2){
                if(id==s2.filterid){
                    fname=s2.filtername;
                    return false;
                }
            });
           
            return fname
        };
        //添加过滤地址分组
        $scope.addfiltertype=function(id,name){
            $http.post('./filter_findisExits.action', {
                verifystr: name,
            }, $scope.postCfg).success(function (data) {
                if(parseInt(data)==1){
                    $http.post('./filter_addFilter.action', {
                        filterid: id,
                        filtername: name
                    }, $scope.postCfg).success(function (data) {
                        //成功之后做一些事情
                        if (parseInt(data) == 1) {
                            if (id == 0) {
                                $scope.tipshow(1, '添加过滤分组成功');
                            } else {
                                $scope.tipshow(1, '修改过滤分组成功');
                            }
                            $scope.viewfiltertype();
                        } else {
                            $scope.tipshow(0, '操作过滤分组失败');
                        }
                    });
                }else{
                    $scope.tipshow(0, '过滤分组名已存在');
                }
            });
        };
        //去掉空格
        $scope.removeTrim = function(str){ 
        	return str.replace(/\s+/g, "");
        };
        //编辑分组
        $scope.filtertypeedit=function(id,fname){
        	var oldname = $scope.removeTrim(fname);
            $("#editfilterinput").val(oldname);
            $("#dialog-edittype").dialog({
                modal: true,
                resizable: false,
                close:function(){
                    $(this).dialog("destroy");
                },
                width: 360,
                maxHeight: 220,
                buttons: {
                    "确定": function () {
                        var filtername=$("#editfilterinput").val();
                        var newname = $scope.removeTrim(filtername);
                        if(newname == ""){
                        	$scope.tipshow(0,"分组名称不能为空");
                            return false;
                        }
                        if(oldname != newname){
                        	$scope.addfiltertype(id,newname);
                            $(this).dialog("destroy");
                        }else{
                        	$scope.tipshow(1,"编辑成功");
                        	$(this).dialog("destroy");
                        }
                    },
                    "取消": function () {
                        $(this).dialog("destroy");
                    }
                }
            });
        };
        //删除分组
        $scope.filtertypedel=function(id){
            $("#dialog-deltype").dialog({
                modal: true,
                resizable: false,
                close:function(){
                    $(this).dialog("destroy");
                },
                width: 360,
                maxHeight: 220,
                buttons: {
                    "确定": function () {
                        var ischeck=$("input:checkbox[name=delfiltercheck]").is(":checked");
                        var q=0;
                        if(ischeck){
                            q=1;
                        }
                        $http.post('./filter_delFilter.action', {
                            filterid: id,
                            operation:q
                        }, $scope.postCfg).success(function (data) {
                            //成功之后做一些事情
                            if(parseInt(data)==1){
                                $scope.tipshow(1,'删除成功');
                                $scope.viewfiltertype();
                            }else{
                                $scope.tipshow(0,'删除失败');
                            }
                            $("#dialog-deltype").dialog("destroy");
                        });

                    },
                    "取消": function () {
                        $(this).dialog("destroy");
                    }
                }
            });

        };
        //清空分组
        $scope.filtertypeclear=function(id){
        	var html='过滤分组中的地址被清空后将无法恢复,请确认是否清空?';
            $(".filterresult").find("p").html(html);
        	$("#dialog-filterresult").dialog({
                modal: true,
                resizable: false,
                width: 360,
                close:function(){
                    $(this).dialog("destroy");
                },
                buttons: {
                    "确认清空": function () {
                    	$http.post('./filter_delFilterData.action', {
                            filterid: id
                        }, $scope.postCfg).success(function (data) {
                            //成功之后做一些事情
                            if(parseInt(data)==1){
                                $scope.tipshow(1,'清空成功');
                            }else{
                                $scope.tipshow(0,'清空失败');
                            }
                        });
                        $(this).dialog("destroy");
                    },
                    "取消": function () {
                        $(this).dialog("destroy");
                    }
                }
            });
        };
        //删除过滤地址
        $scope.delfilteraddress=function(id){
        	 $("#dialog-filterip").dialog({
                 modal: true,
                 resizable: false,
                 width: 360,
                 close:function(){
                     $(this).dialog("destroy");
                 },
                 buttons: {
                     "确认删除": function () {
                         $http.post('./filterA_delFilterAddress.action', {
                             addressstr: id
                         }, $scope.postCfg).success(function (data) {
                             //成功之后做一些事情
                             if(parseInt(data)==1){
                                 $scope.tipshow(1,'删除地址成功');
                                 $scope.pageChanged();
                             }else{
                                 $scope.tipshow(0,'删除地址失败');
                             }
                         });
                         $(this).dialog("destroy");
                     },
                     "取消": function () {
                         $(this).dialog("destroy");
                     }
                 }
             });
        };

        //编辑过滤地址
        $scope.editfilteraddress=function(id,fid,email,by){
            $("#editfilterid").val(fid);
            $("#editfilteraddress").val(email);
            $("#editfilterbody").val(by);
            $("#dialog-editfilteraddress").dialog({
                modal: true,
                resizable: false,
                close:function(){
                    $(this).dialog("destroy");
                },
                width: 460,
                maxHeight: 520,
                buttons: {
                    "确定": function () {
                        var fid2=$("#editfilterid").val();
                        var email2=$("#editfilteraddress").val();
                        var by2=$("#editfilterbody").val();
                        $http.post('./filterA_updateFilterAddress.action', {
                            "filteraddress.filteraddrid": id,
                            "filteraddress.filterid":fid2,
                            "filteraddress.filteraddrreason":by2,
                            "filteraddress.filteraddress":email2
                        }, $scope.postCfg).success(function (data) {
                            //成功之后做一些事情
                            if(parseInt(data)==1){
                            	$("#filtertypename").val(fid2);
                                $scope.tipshow(1,'修改地址成功');
                                if(fid2==0){
                                    $scope.queryaddress({
                                        currpage:$scope.CurrentPage,
                                        pagesize:$scope.pagesize,
                                        condition:0,
                                        conditionvalue:""
                                    });
                                }else{
				                      $scope.queryaddress({
				                          currpage:1,
				                          pagesize:$scope.pagesize,
				                          condition:1,
				                          conditionvalue:fid2
				                      });   
				                      $scope.CurrentPage=1;
                                }
                            }else{
                                $scope.tipshow(0,'修改地址失败');
                            }
                            $("#dialog-editfilteraddress").dialog("destroy");
                        });
                    },
                    "取消": function () {
                        $(this).dialog("destroy");
                    }
                }
            });

        }
    })
    .controller('unsubscribeCtrl', function ($scope, $http, $location, FilterListALL) {
        'use strict';

        var datapost={
            currpage: 1,
            pagesize: $scope.pagesize,
            condition: 0,
            conditionvalue: ""
        };
        $scope.numPages = 1;
        $scope.CurrentPage = 1;
        $scope.setPage = function (pageNo) {
            $scope.numPages = pageNo;
        };
        $scope.pageChanged = function () {
        	var unsub=$("#unsubscribesearch").val();
            datapost = {
                currpage: $scope.CurrentPage,
                pagesize: $scope.pagesize,
                condition: 1,
                conditionvalue: unsub
            };
            $scope.viewUnsub(datapost);
        };

        //初始化参数
        $scope.viewUnsub = function (pdata) {
            $(".yyloading").show();
            $http.post('./yxyun_findUnCondition.action', pdata, $scope.postCfg)
                .success(function (data) {
                    $(".yyloading").hide();
                    $(".checkall").attr("allcheck", 0);
                    $(".checkall").removeClass("checkbox-active");
                    $scope.listitems = data.unlist;
                    $scope.TotalItems = data.pagebean.totalRecord;
                });
        };
        $scope.viewUnsub(datapost);

        //添加退订
        $scope.addunsub = function (email, unwhy) {
            $http.post('./yxyun_addUnsubscribe.action', {
                unemail: email,
                unbody: unwhy
            }, $scope.postCfg).success(function (data) {
                //成功之后做一些事情
                if (parseInt(data) == 1) {
                    var datapost={
                        currpage: 1,
                        pagesize: $scope.pagesize,
                        condition: 1,
                        conditionvalue: ""
                    };
                    //初始化当前页
                    $scope.CurrentPage = 1;
                    $scope.viewUnsub(datapost);
                    $(".form-control").val("");
                }else if(parseInt(data) == -1){
                	$scope.tipshow(0,'退订地址已存在');
                }else{
                	$scope.tipshow(0,'退订地址添加失败');
                }

            });
        };
        
	
        //删除退订
        $scope.delunsub = function (ids) {
            $http.post('./yxyun_delUnsubscribe.action', {
                unidstr: ids
            }, $scope.postCfg).success(function (data) {
                //成功之后做一些事情
                if (parseInt(data) == 1) {
                    var datapost={
                        currpage: 1,
                        pagesize: $scope.pagesize,
                        condition: 1,
                        conditionvalue: ""
                    };
                    $scope.viewUnsub(datapost);
                    $scope.tipshow(1, "删除成功");
                } else {
                    $scope.tipshow(0, "删除失败");
                }
            })
        };

        //删除多个选中
        $scope.delunall = function () {
            var ids = "";
            $(".unsubcheck").each(function () {
                if ($(this).attr("datafilecheck") == "1") {
                    ids = $(this).attr("cid") + "," + ids
                }
            });
            ids = ids.substring(0, ids.length - 1);
            if(ids.length == 0){
           	 $scope.tipshow(0, "请选择要删除的退订地址");
           	 return;
           }
            var html='选中的退信地址删除后将无法恢复,请确认是否删除?';
            $(".unsubscriberesult").find("p").html(html);
        	$("#dialog-unsubscriberesult").dialog({
                modal: true,
                resizable: false,
                width: 360,
                close:function(){
                    $(this).dialog("destroy");
                },
                buttons: {
                    "确认删除": function () {
                    	$scope.delunsub(ids);
                        $(this).dialog("destroy");
                    },
                    "取消": function () {
                        $(this).dialog("destroy");
                    }
                }
            });
        };
        //导出退订地址
        $scope.exportfolder = function () {
            $http.post('./yxyun_exportAddress.action', {
                filterid: 1
            }, $scope.postCfg).success(function (data) {
                //成功之后做一些事情
                if (parseInt(data) == 1) {
                    window.location.href = "dowload.action?filedir=tempUserFile&filename=unsubscribe.xls";
                    $scope.tipshow(1, "导出成功");
                }
            })
        };
    })

    //字符过滤
    .controller('filterwordCtrl', function ($scope, $http, $location, FilterListALL,GetUserParam) {
        'use strict';
        GetUserParam.getparam().then(function(data){
            $scope.usersertid=data.user_set_id;
            $scope.usersetfiterStr=data.user_set_fiterStr;
        });
        $scope.savecharfilter=function(){
            var txt=$("#charfilter").val();
            $http.post('./yxyUS_editFilterString.action', {
                filterstring: txt,
                setid:$scope.usersertid
            }, $scope.postCfg).success(function (data) {
                //成功之后做一些事情
           /**--------------修改字符过滤之前----------------------*/
            	txt = txt.trim();//去掉前后空格
            	if(txt.length == 0){
            		$scope.tipshow(0,"字符过滤不能为空"); 
              		 return;
            	}
            /**--------------修改字符过滤之后----------------------*/
                if (parseInt(data) == 1) {
                    $scope.tipshow(1,"字符过滤修改成功");
                }else{
                    $scope.tipshow(0,"字符过滤修改失败");
                }
            })
        }

    });


//添加退订地址
App.directive('addfiltermail', function ($rootScope) {
    'use strict';

    return {
        restrict: 'A',
        link: function (scope, element, attrs) {
            //####### Dialogs
            element.click(function (e) {
                scope.clearinput();
                $("#dialog-addfiltermail").dialog({
                    modal: true,
                    resizable: false,
                    close:function(){
                        $(this).dialog("destroy");
                    },
                    width: 400,
                    buttons: {
                        "保存": function () {
                            var unsubaddr = $.trim($("#unsubaddr").val());
                            var unsubwhy = $("#unsubwhy").val();
              /**------------------修改(验证邮箱)--之前------------------------------------*/
                            //邮箱正则表达式
                            var addrmail = /^\w+([\.\'-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
                            //判断退订地址是否为空
                            if(unsubaddr.length != 0 ){
                            	//验证输入的退订地址格式是否符合要求
                               if(addrmail.test(unsubaddr)){
                            	   	scope.addunsub(unsubaddr, unsubwhy);
                            	   	scope.tipshow(1,"添加成功");
                               		$(this).dialog("destroy");
                               }else{
                            	   scope.tipshow(0,"退订地址格式不正确");
                               }
                            }else{
                            	scope.tipshow(0,"退订地址不能为空");
                            }
           /**------------------修改(验证邮箱)--之后------------------------------------*/
//                            scope.addunsub(unsubaddr, unsubwhy);
//                            $(this).dialog("destroy");
                        },
                        "取消": function () {
                            $(this).dialog("destroy");
                        }
                    }
                });
                return false;
            });
        }
    };
});

//删除退订地址
App.directive('delfiltermail', function () {
    'use strict';

    return {
        restrict: 'A',
        link: function (scope, element, attrs) {
            //####### Dialogs
            element.click(function (e) {
                e.stopPropagation();
                var html='选中的退信地址删除后将无法恢复,请确认是否删除?';
                $(".unsubscriberesult").find("p").html(html);
            	$("#dialog-unsubscriberesult").dialog({
                    modal: true,
                    resizable: false,
                    width: 360,
                    close:function(){
                        $(this).dialog("destroy");
                    },
                    buttons: {
                        "确认删除": function () {
                        	scope.delunsub(attrs.cid);
                            $(this).dialog("destroy");
                        },
                        "取消": function () {
                            $(this).dialog("destroy");
                        }
                    }
                });
                
            });
        }
    };
})
//添加过滤分组
    .directive('addFilterType', function ($rootScope) {
        'use strict';

        return {
            restrict: 'A',
            link: function (scope, element, attrs) {
                //####### Dialogs
                element.click(function () {
                    $rootScope.clearinput();
                    $("#dialog-addtype").dialog({
                        modal: true,
                        resizable: false,
                        width: 360,
                        maxHeight: 220,
                        close:function(){
                            $(this).dialog("destroy");
                        },
                        buttons: {
                            "确定": function () {
                                var fname=$("#addfilterinput").val();
                                var newname = scope.removeTrim(fname);
                                if(newname == ""){
                                    scope.tipshow(0,"分组名称不能为空");
                                    return false;
                                }
                                scope.addfiltertype(0,newname);
                                $(this).dialog("destroy");
                            },
                            "取消": function () {
                                $(this).dialog("destroy");
                            }
                        }
                    })
                });
            }
        };
    })
//管理过滤分组
    .directive('manageFilterType', function () {
        'use strict';

        return {
            restrict: 'A',
            link: function (scope, element, attrs) {
                //####### Dialogs
                element.click(function () {
                    $("#dialog-settingmail").dialog({
                        modal: true,
                        position: ["center", 100],
                        resizable: false,
                        close:function(){
                            $(this).dialog("destroy");
                        },
                        width: 650,
                        maxHeight: 420
                    })
                });
            }
        };
    })
//添加过滤地址
.directive('addFilterAddress', function (FilterListALL) {
    'use strict';

    return {
        restrict: 'A',
        link: function (scope, element, attrs) {
            //####### Dialogs
            element.on('click',function () {
                scope.clearinput();
                $("#dialog-address").dialog({
                    modal: true,
                    resizable: false,
                    width: 560,
                    maxHeight: 450,
                    close:function(){

                        $(this).dialog("destroy");
                    },
                    buttons: {
                        "保存": function () {
                            var fnum=$("#flitertypenum").val();//0:单个添加   1:批量导入
                            if(fnum==0){
                                var fid=$("#filterpacketid").val();
                                var con=$("#filterpacketcon").val();
                                var by=$("#filterpacketbody").val();
                                $("#filtertypename").val(fid);
                                FilterListALL.addfiltermail(fid,con,by).then(function(data){
                                    if(data.result==1){
                                        if(fid==0){
                                            scope.queryaddress({
                                                currpage:scope.CurrentPage,
                                                pagesize:scope.pagesize,
                                                condition:0,
                                                conditionvalue:""
                                            });
                                        }else{
                                            scope.queryaddress({
                                                currpage:scope.CurrentPage,
                                                pagesize:scope.pagesize,
                                                condition:1,
                                                conditionvalue:fid
                                            });
                                        }
                                       var html='添加成功 <span class="color-red">'+data.success+'</span> 条, 不合法 <span class="color-red">'+data.nohefa+'</span> 条,重复 <span class="color-red">'+data.chongfu+'</span> 条,已存在 <span class="color-red">'+data.exits+'</span> 条';
                                        $(".filterresult").find("p").html(html);
                                        $("#dialog-filterresult").dialog({
                                            modal: true,
                                            resizable: false,
                                            width: 360,
                                            maxHeight: 220,
                                            buttons: {
                                                "关闭": function () {
                                                    $(this).dialog("destroy");
                                                }
                                            }
                                        })
                                    }
                                })
                            }else{
                                var fid=$("#filterpacketsid").val();
                                var fname=$("#filterpacketsfile").val();
                                var fbody=$("#filterpacketsbody").val();
                                $("#filtertypename").val(fid);
                                if(fname != ""){
                                    var option={
                                            type: 'post',
                                            url: './filterA_addFilterAddressFile.action',
                                            dataType:'json',
                                            iframe: true,
                                            cache:false,
                                            data:{
                                                filterid:fid,
                                                filename:fname,
                                                filterbody:fbody,
                                            },
                                            success: function(data){
                                                if (data.result=1){
                                                    if(fid==0){
                                                        scope.queryaddress({
                                                            currpage:scope.CurrentPage,
                                                            pagesize:scope.pagesize,
                                                            condition:0,
                                                            conditionvalue:""
                                                        });
                                                    }else{
                                                        scope.queryaddress({
                                                            currpage:scope.CurrentPage,
                                                            pagesize:scope.pagesize,
                                                            condition:1,
                                                            conditionvalue:fid
                                                        });
                                                    }
                                                    var html='添加成功 <span class="color-red">'+data.success+'</span> 条, 不合法 <span class="color-red">'+data.nonum+'</span> 条,重复 <span class="color-red">'+data.fcnum+'</span> 条,已存在 <span class="color-red">'+data.scnum+'</span> 条';
                                                    $(".filterresult").find("p").html(html);
                                                    $("#dialog-filterresult").dialog({
                                                        modal: true,
                                                        resizable: false,
                                                        width: 360,
                                                        maxHeight: 220,
                                                        buttons: {
                                                            "关闭": function () {
                                                                $(this).dialog("destroy");
                                                            }
                                                        }
                                                    })
                                                }
                                            }
                                        };
                                    $("#filterimportForm").ajaxSubmit(option);
                                }else{
                                	scope.tipshow(0,'导入文件不能为空')
                                }
                            }
                            $(this).dialog("destroy");
                        },
                        "取消": function () {
                            $(this).dialog("destroy");
                        }
                    }
                });
                $(".lg-tab").find("button").click(function(){
                    var i=$(this).index();
                    $("#flitertypenum").val(i);
                    $(".lg-tab").find("button").removeClass("btn-primary");
                    $(this).addClass("btn-primary");
                    $(".tab-pane").removeClass("active");
                    $(".tab-pane").eq(i).addClass("active");
                })

            });
        }
    };
})
//选择分组查询过滤地址
    .directive('filterListClick', function () {
        'use strict';

        return {
            restrict: 'A',
            link: function (scope, element, attrs) {
                //####### Dialogs
                element.on('change',function () {
                    scope.CurrentPage=1;
                    var fid=this.value;
                    $("#filtersearchcon").val("");//当分组进行查询,条件查询清空
                    if(fid==0){
                        scope.queryaddress({
                            currpage:1,
                            pagesize:scope.pagesize,
                            condition:0,
                            conditionvalue:""
                        });
                    }else{
                        scope.queryaddress({
                            currpage:1,
                            pagesize:scope.pagesize,
                            condition:1,
                            conditionvalue:fid
                        });
                    }

                });
            }
        };
    })
//删除选择的过滤地址
    .directive('delFilterAddress', function () {
        'use strict';

        return {
            restrict: 'A',
            link: function (scope, element, attrs) {
                //####### Dialogs
                element.on('click',function() {
                    var fids="";
                    $(".lg-filter-address").each(function(){
                        if($(this).attr("datafilecheck")==1){
                            fids+=$(this).attr("cid")+",";
                        }
                    });
                    fids=fids.substring(0,fids.length-1);
                    if(fids!=""){
                        scope.delfilteraddress(fids);
                    }else{
                        scope.tipshow(0,"请选择地址进行删除");
                    }

                });
            }
        };
    })
    //条件查询过滤地址
    .directive('filterSearch', function () {
        'use strict';
        return {
            restrict: 'A',
            link: function (scope, element, attrs) {
                //####### Dialogs
                element.on('click',function() {
                    var con=$("#filtersearchcon").val();
                    $("#filtertypename").val(0);//当条件查询时,将分组条件清空
                    scope.condition=2;
                    //条件查询时才会调用
                    scope.queryaddress({
                        currpage:scope.CurrentPage,
                        pagesize:scope.pagesize,
                        condition:2,
                        conditionvalue:con
                    });
                });
            }
        };
    })
    /**-------------退订报告查询之前--------------------------*/
    .directive('unsubscribeSearch',function(){
    	 'use strict';
    	return {
    		 restrict: 'A',
    		 link: function (scope, element, attrs) {
    			 element.on('click',function() {
    				 var unsub=$("#unsubscribesearch").val();
    				 //退订报告查询
    				 scope.viewUnsub({
    					  currpage:scope.CurrentPage,
                          pagesize:scope.pagesize,
                          condition:1,
                          conditionvalue:unsub
    				 });
    		 	});
    		 }
    	};
    })
    /**-------------退订报告查询之后--------------------------*/