审查视图

WebRoot/app/scripts/controllers/sendtask.js 5.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
/**
 * Created by lgy on 2015/10/20.
 */

App.controller('sendtaskCtrl', function ($scope, $http, $location,GetMailInfo,MailList) {
    'use strict';
    var datapost = {
        currpage: 1,
        pagesize: $scope.pagesize,
        status: 0,
        condition: 0
    };
    //地址列表
    $scope.viewaddress = function (datapost) {
        $(".yyloading").show();
        MailList.listpostall(datapost).then(function(data){
            $(".yyloading").hide();
            $(".checkall").attr("allcheck", 0);
            $(".checkall").removeClass("checkbox-active");
            $scope.listitems = data.masterlist;
        });
    };
    $scope.viewaddress(datapost);
    //详细信息
    $scope.sendmailinfo = function (id,mid,tnum) {
        $scope.minfo="";
        $scope.tuiding=tnum;
        GetMailInfo.getcountinfo(id,mid).then(function(data){
            $scope.minfo=data;
        })
    }

    //处理多主题标题
    $scope.getsubject=function(subject){
        var sub=subject.split("###_");
        return sub[0];
    }
})
    .controller('TasktimeCtrl', function ($scope, $http, $location,MailList) {
        var postdata={
            currpage: 1,
            pagesize: $scope.pagesize,
            status: 2,
            condition: 0
        };
        $scope.viewtimelist = function (datapost) {
            $(".yyloading").show();
            MailList.listpostall(datapost).then(function(data){
                $(".yyloading").hide();
                $(".checkall").attr("allcheck", 0);
                $(".checkall").removeClass("checkbox-active");
                $scope.timeitems = data.masterlist;
            });
        };
        $scope.viewtimelist(postdata);

       //------------------显示定时邮件地址-之前---------------------------------------
        //定时邮件查看
        $scope.gettimings=function(id){
            $('#dialog-timemail').dialog({
                modal: true,
                resizable: false,
                close: function () {
                    $(this).dialog("destroy");
                },
                width: 350,
                maxHeight: 450
            });
            $scope.readshow=true;
            MailList.findaddrmail({
            	basemailid:id
            }).then(function(data){
                $scope.readshow=false;
                $scope.detailList=data.detailList;
            });
        }
        
        //--------------------显示定时邮件地址-之后------------------------------------------   
        
        //处理多主题标题
        $scope.getsubject=function(subject){
            var sub=subject.split("###_");
            if(sub.length>1){
                return sub[0]+"(多)";
            }else{
                return sub[0];
            }
        }

    }).controller('timingmailinfoCtrl', function ($scope, $state, $stateParams, $http, $location) {
        'use strict';
        var mailid=$stateParams.mailId;//接受页面传过来的参数
        $scope.mainid=$stateParams.mid;
        $(".yyloading").show();//加载框
        $http.post('./yxyM_findMasterBase.action', {
            mailid: mailid
        }, $scope.postCfg).success(function (data) {
            //成功之后做一些事情
        	$(".yyloading").hide();//加载框
            $scope.timingmailinfos = data;
            var mcon=data.paxbody;
            if (mcon !=null){
                mcon=mcon.replace(/"'\/>/g,'\'/>');
                $("#mailinfocon").html(mcon);
            }else{
                $("#mailinfocon").html('暂无邮件内容');
            }
            var attarchment_path=data.masterbase.attarchment_path;
            $scope.filename="";
            if(attarchment_path!=null){
                var f=attarchment_path.split("##P##");
                if(f[1]!=""){
                    var txt=f[1].split(",");
                    for(var i=0;i<txt.length;i++){
                        var q=txt[i].split("#####");
                        $scope.filename+="<label class='label label-info'><i class='fa fa-file'></i> "+q[1]+"</label> ";
                    }

                }
                if($scope.filename!=""){
                    $scope.filename=$scope.filename.substring(0,$scope.filename.length-1);
                }
            }


        });

    });

App.directive('waitInfo', function () {
    'use strict';

    return {
        restrict: 'A',
        link: function (scope, element, attrs) {
            //####### Dialogs

            element.on('click', function (e) {
                scope.sendmailinfo(attrs.cid,attrs.mid,attrs.tid);
                $("#dialog-waitinfo").dialog({
                    modal: true,
                    resizable: false,
                    close:function(){
                        $(this).dialog("destroy");
                    },
                    width: 450
                });
            });
        }
    };
}).directive('viewTime', function () {
    'use strict';
    return {
        restrict: 'AE',
        link: function (scope, element, attrs) {
            element.on('click', function () {
            	scope.gettimings(attrs.id);
            	$("#timingmail").html(attrs.id);
            });

        }
    };
})
//---------------------定时邮件地址导出-----------------------------------------
.directive('exporttiming', function (MailList) {
    'use strict';
    return {
        restrict: 'AE',
        link: function (scope, element, attrs) {
            element.on('click', function () {
            	var id = $("#timingmail").html();
            	MailList.exportaddrmail({
                	basemailid:id
                }).then(function(data){
                	 if(data==1){
                     	window.location.href="dowload.action?filename=readinfo.xls&filedir=tempUserFile";
                         scope.tipshow(1,"导出成功");
                     }else{
                         scope.tipshow(0,"导出失敗");
                     }
                })
            
            });

        }
    };
});