event.js 4.36 KB
/**
 * Created by 王冠伦 on 2018/2/26.
 */
(function () {
    "user strict";

    var railwayController = function($scope,$modal,$http,$interval,$filter,dialogService,railwayService){
        $scope.$emit('navShow', 2);
        $scope.settingShow = 2;
        $scope.vm = {
            pageSize : 10,
            totalCount : 0
        }
        /*$scope.names = [
            {name : "上报时间", value : 0},
            {name : "用户", value : 1},
            {name : "车站名", value : 2},
            {name : "事件类型", value : 3}
        ]

        $scope.change = function(){
            var condition = $scope.condition;
            $scope.date = true;
            if (condition.value != 0){
                $scope.date = !$scope.date;
            }
            $scope.content1 = "";
            $scope.content = "";
        }*/

        $scope.searchByCondition = function(){
            /*$scope.vm.createTime = '';
            $scope.vm.userId = '';
            $scope.vm.station = '';
            $scope.vm.type = '';
            var condition = $scope.condition;
            if (condition.value == 0){
                $scope.vm.createTime = $scope.content1;
                if($scope.vm.createTime != null){
                    $scope.vm.createTime = $scope.content1.format("yyyy-MM-dd");
                }
            }else if (condition.value == 1){
                $scope.vm.userId = $scope.content;
            }else if (condition.value == 2){
                $scope.vm.station = $scope.content;
            }else if (condition.value == 3){
                $scope.vm.type = $scope.content;
            }*/
            var createTime = $scope.vm.createTime;
            if ($scope.vm.createTime != null){
                var createTime = $scope.vm.createTime;
                $scope.vm.createTime = $filter('date')(createTime, 'yyyy-MM-dd');
            }
            $scope.getList();
        }

        $scope.getList = function(){
            railwayService.findEventByCondition($scope.vm).success(function(data){
                if (data.errors == null || data.errors.length > 0) {
                    dialogService.tip(data.errors);
                }else{
                    $scope.eventList = data.result;
                    for(var i =0 ;i< $scope.eventList.length;i++){
                        /*if ($scope.eventList[i].commitTime != null) {
                            var time = new Date(Number($scope.eventList[i].commitTime));
                            $scope.eventList[i].commitTime = time.format("yyyy-MM-dd hh:mm:ss");
                        }*/
                        /*if ($scope.eventList[i].type != null) {
                            if($scope.eventList[i].type == "STATION"){
                                $scope.eventList[i].type = "车站事件";
                            }else if($scope.eventList[i].type == "CARRIAGE"){
                                $scope.eventList[i].type = "车厢事件";
                            }else if($scope.eventList[i].type == "GOOD"){
                                $scope.eventList[i].type = "好人好事";
                            }
                        }*/
                    }
                    $scope.vm.totalCount = data.totalCount;
                    $scope.settingShow = 2;
                }
            })
        }
        $scope.getList();

        $scope.openSubmitTimeFrom = function ($event) {
            $event.preventDefault();
            $event.stopPropagation();
            $scope.submitTimeFrom = true;
        };

        //弹出式日历触发函数
        $scope.openFDate = function($event) {
            $event.preventDefault();
            $event.stopPropagation();
            $scope.fromDate = true;
        };
        $scope.openTDate = function($event) {
            $event.preventDefault();
            $event.stopPropagation();
            $scope.toDate = true;
        };
        $scope.startDate = function ($event) {
            $event.preventDefault();
            $event.stopPropagation();
            $scope.startTime = true;
        };
        $scope.endDate = function ($event) {
            $event.preventDefault();
            $event.stopPropagation();
            $scope.endTime = true;
        };
    }

    angular.module("xn.page", ["xn.directive.form"])
        .controller("RailwayController",["$scope","$modal","$http","$interval","$filter","dialogService","RailwayService",railwayController])
})();