report.js 2.57 KB
Newer Older
manxiaoqiang committed
1 2 3 4 5
(function(){
    angular.module("app.collect")
        .controller("reportCtrl",["$rootScope","$scope","HttpService","ToolService","UtilService",exportCtrl]);

    function exportCtrl($rootScope,$scope,HttpService,ToolService,UtilService){
yangfangfang committed
6
        $scope.UserId = ToolService.getUser().id;
manxiaoqiang committed
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

    	$scope.query = function(){
            ToolService.showLoading()
            var listPM = HttpService.getInfo("mng/export/report/"+$scope.appid+"/findall");
            listPM.then(function(data){
                $scope.donwlistData = data;
                ToolService.hideLoading();
            });
    	}

        $scope.$on('flipinfo',function(e,msg){
            $scope.flipPage2 = msg;
        });

    	$scope.doRemove = function(id){
            $scope.delstatus = true;
            $scope.delId = id;
        }
        $scope.removeInfo = function(){
            var url = "mng/export/report/"+$scope.appid+"/delete/"+$scope.delId,
                removePM = HttpService.deleteInfo(url);

            ToolService.showLoading();
            $scope.delstatus = false;
            removePM.then(function(data){
                ToolService.hideLoading();
                ToolService.showTips("删除成功")
                $scope.query();
            });
        }

        //失败刷新
        $scope.downlistRefresh = function(id,flag){
            if(flag && flag == 1){ //下载刷新
                id = $scope.winID;
            }
            ToolService.showLoading();
            $scope.closeWin();
            HttpService.putInfo("mng/export/report/"+$scope.appid+"/refresh/"+id,{}).then(function(data){
                $scope.query();
            });
        }
        $scope.closeWin = function(){
            ToolService.hideAlp();
            $scope.wantRefresh = false;
        }
        //下载列表下载文件
        $scope.downlistEvt = function(info){
            if(info.status!='complete'){return false;}
            var id = info.id;

            var downPM =  HttpService.downFile("mng/export/report/"+$scope.appid+"/download/"+id);
            ToolService.showLoading();
            downPM.then(function(data){
                ToolService.hideLoading();

                if(data.code == -1){
                    $scope.wantRefresh = true;
                    $scope.winID = info.id;
                    ToolService.showAlp();
                }else{
yangfangfang committed
68
                    $rootScope.operSubmitData("下载");
manxiaoqiang committed
69 70 71 72 73 74 75 76 77 78 79
                }
            });
        }

        $scope.$watch("appid",function(n){
            if(angular.isDefined(n)){
                $scope.query();
            }
        });
    }
})();