app.controller('cycleSheetCtrl', ['$scope','$rootScope', '$http', '$state', '$filter','$localStorage', function($scope,$rootScope, $http,$state, $filter,$localStorage) {

    if($rootScope.loginData.login === false){
        $state.go("signin")
    }else {
        $state.go("layout.cycleSheet")
    }

    var getNowFormatDate = function () {
        var date = new Date();
        var month = date.getMonth() + 1;
        var strDate = date.getDate();
        if (month >= 1 && month <= 9) {
            month = "0" + month;
        }
        if (strDate >= 0 && strDate <= 9) {
            strDate = "0" + strDate;
        }
        var currentdate = date.getFullYear() + "/" + month +"/"+ strDate;
        return currentdate;
    }
    $scope.today = function() {
        $scope.dt = getNowFormatDate();
    };
    $scope.today();

    $scope.clear = function () {
        $scope.dt = null;
    };

    // Disable weekend selection
    $scope.disabled = function(date, mode) {
        return ( mode === 'day' && ( date.getDay() === 0 || date.getDay() === 6 ) );
    };

    $scope.toggleMin = function() {
        $scope.minDate = $scope.minDate ? null : new Date();
    };
    $scope.toggleMin();

    $scope.open = function($event) {
        $event.preventDefault();
        $event.stopPropagation();

        $scope.opened = true;
    };

    $scope.dateOptions = {
        formatYear: 'yy',
        startingDay: 1,
        class: 'datepicker'
    };

    $scope.initDate = new Date('2016-15-20');
    $scope.formats = ['dd-MMMM-yyyy', 'yyyy/MM/dd', 'dd.MM.yyyy', 'shortDate'];
    $scope.format = $scope.formats[1];
    $scope.task_click = function(){
        console.log($rootScope.loginData.state,"----测试-----",$scope.dt,"====");
    }
    $scope.check_type = function(typeCode){
        console.log($rootScope.loginData.state,"----测试-----",$scope.dt,"====",typeCode,"+++++++++++++");
    }
    $scope.typeList =[
        {typeCode:0,typeCount:5000,typeName:'普通证'},
        {typeCode:1,typeCount:5000,typeName:'邮寄证'},
        {typeCode:2,typeCount:5000,typeName:'特殊证'},
        {typeCode:9,typeCount:5000,typeName:'异地证'},
    ]
    $scope.cityList =[
        {"card_Type":1,"citycode":"410300",cityName:"郑州",groupCount:10,groupSum:1500,groupInvailedSum:15,groupNO:"1-25","download_Date":null,"exception_Information":"","in_Storage_Date":null,"is_Exception":0,"issued_Date":null,"old_Card_Type":1,"out_Storage_Date":null,"out_Workshop_Date":null,"position_Date":null,"print_Out_Date":null,"print_State":0,"printer_Id":0,"quality_People_Name":"","quality_Test_Date":null,"submit_Date":{"date":20,"day":2,"hours":11,"minutes":20,"month":10,"seconds":53,"time":1542684053000,"timezoneOffset":-480,"year":118},"task_Id":201811203,"task_State_Id":1},
        {"card_Type":1,"citycode":"410400",cityName:"驻马店",groupCount:10,groupSum:2500,groupInvailedSum:16,groupNO:"26-45","download_Date":null,"exception_Information":"","in_Storage_Date":null,"is_Exception":0,"issued_Date":null,"old_Card_Type":1,"out_Storage_Date":null,"out_Workshop_Date":null,"position_Date":null,"print_Out_Date":null,"print_State":0,"printer_Id":0,"quality_People_Name":"","quality_Test_Date":null,"submit_Date":{"date":20,"day":2,"hours":11,"minutes":20,"month":10,"seconds":53,"time":1542684053000,"timezoneOffset":-480,"year":118},"task_Id":201811203,"task_State_Id":1},
        {"card_Type":1,"citycode":"410500",cityName:"新乡",groupCount:10,groupSum:3500,groupInvailedSum:17,groupNO:"46","download_Date":null,"exception_Information":"","in_Storage_Date":null,"is_Exception":0,"issued_Date":null,"old_Card_Type":1,"out_Storage_Date":null,"out_Workshop_Date":null,"position_Date":null,"print_Out_Date":null,"print_State":0,"printer_Id":0,"quality_People_Name":"","quality_Test_Date":null,"submit_Date":{"date":20,"day":2,"hours":11,"minutes":20,"month":10,"seconds":53,"time":1542684053000,"timezoneOffset":-480,"year":118},"task_Id":201811203,"task_State_Id":1},
        {"card_Type":1,"citycode":"410600",cityName:"周口",groupCount:10,groupSum:3500,groupInvailedSum:18,groupNO:"48-52,53-55","download_Date":null,"exception_Information":"","in_Storage_Date":null,"is_Exception":0,"issued_Date":null,"old_Card_Type":1,"out_Storage_Date":null,"out_Workshop_Date":null,"position_Date":null,"print_Out_Date":null,"print_State":0,"printer_Id":0,"quality_People_Name":"","quality_Test_Date":null,"submit_Date":{"date":20,"day":2,"hours":11,"minutes":20,"month":10,"seconds":53,"time":1542684053000,"timezoneOffset":-480,"year":118},"task_Id":201811203,"task_State_Id":1},
    ]

    $scope.groupList =[
        {"groupNO":45,"vaildCount":45,invaildCount:25,specialCardCount:5,specialCardList:[{acceptNo:20180401,specialType:1},{acceptNo:20180401,specialType:1}]},
        {"groupNO":45,"vaildCount":45,invaildCount:25,specialCardCount:5,specialCardList:[{acceptNo:20180401,specialType:1},{acceptNo:20180401,specialType:1}]},
        {"groupNO":45,"vaildCount":45,invaildCount:25,specialCardCount:5,specialCardList:[{acceptNo:20180401,specialType:1},{acceptNo:20180401,specialType:1}]}
         ]
    $scope.countyList = [
        {}
    ]

    $scope.showtable = -1;
    $scope.showTableDY = function (taskID) {
        if ($scope.showtable != taskID) {
            $scope.showtable = taskID;
        } else {
            $scope.showtable = -1;
        }
    }

    $scope.folds = [
        {id:1,name: '普通证', count:10000,filter:'',isActive:true, dataTable:{
                "aaData": [
                {
                    "engine": "Trident",
                    "browser": "Internet Explorer 4.0",
                    "platform": "Win 95+",
                    "version": "4",
                    "grade": "X"
                },
                {
                    "engine": "Trident",
                    "browser": "Internet Explorer 5.0",
                    "platform": "Win 95+",
                    "version": "5",
                    "grade": "C"
                }]
            }},
        {id:2,name: '邮寄证', count:20000,filter:'starred', dataTable:{
                "aaData": [
                    {
                        "engine": "Trident",
                        "browser": "Internet Explorer 5.5",
                        "platform": "Win 95+",
                        "version": "5.5",
                        "grade": "A"
                    },
                    {
                        "engine": "Trident",
                        "browser": "Internet Explorer 6",
                        "platform": "Win 98+",
                        "version": "6",
                        "grade": "A"
                    },
                    {
                        "engine": "Trident",
                        "browser": "Internet Explorer 7",
                        "platform": "Win XP SP2+",
                        "version": "7",
                        "grade": "A"
                    }]
            }},
        {id:3,name: '军人证', count:32000,filter:'sent', dataTable:{
            "aaData": [
                {
                    "engine": "Trident",
                    "browser": "Internet Explorer 5.5",
                    "platform": "Win 95+",
                    "version": "5.5",
                    "grade": "A"
                }]
        }},
        {id:4,name: '快证', count:40,filter:'important', dataTable:{
            "aaData": [
                {
                    "engine": "Webkit",
                    "browser": "Safari 1.3",
                    "platform": "OSX.3",
                    "version": "312.8",
                    "grade": "A"
                },
                {
                    "engine": "Webkit",
                    "browser": "Safari 2.0",
                    "platform": "OSX.4+",
                    "version": "419.3",
                    "grade": "A"
                },
                {
                    "engine": "Webkit",
                    "browser": "Safari 3.0",
                    "platform": "OSX.4+",
                    "version": "522.1",
                    "grade": "A"
                },
                {
                    "engine": "Webkit",
                    "browser": "OmniWeb 5.5",
                    "platform": "OSX.4+",
                    "version": "420",
                    "grade": "A"
                },
                {
                    "engine": "Webkit",
                    "browser": "iPod Touch / iPhone",
                    "platform": "iPod",
                    "version": "420.1",
                    "grade": "A"
                }]
        }}
    ];

    $scope.currentTab = 1;
    $scope.func = function (id) {
        for (var i=0;i<$scope.folds.length;i++){
            if(id == $scope.folds[i].id){
                $scope.folds[i].isActive = true;
            }else{
                $scope.folds[i].isActive = false;
            }
        }
        $scope.currentTab = id;
    }

}]);