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

    var railwayController = function($scope,$modal,$http,$interval,dialogService,railwayService){
        $scope.$emit('navShow', 5);
        $scope.vm = {
            pageSize : 10,
            totalCount : 0,
            createTime : '',
            userId : '',
            station : '',
            type : ''
        }
        $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 (condition.value == 1){
                $scope.vm.userId = $scope.content;
            }
            if (condition.value == 2){
                $scope.vm.station = $scope.content;
            }
            if (condition.value == 3){
                $scope.vm.type = $scope.content;
            }
            $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 = "车站事件";
                            }
                            if($scope.eventList[i].type == "CARRIAGE"){
                                $scope.eventList[i].type = "车厢事件";
                            }
                            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;
        };
    }

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