zm
2020-04-12 0d659cff38f50d83e782a9f8c5c20fb54a5c0321
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
 
/**
 * Created by lichen on 2017/6/16.
 */
//(function(){
    angular.module('messages_center',[])
        //点击标为已处理
        .directive('clickRead', ['$rootScope', '$compile', 'http_service', '$http', function($rootScope, $compile, http_service, $http) {
            return{
                scope:true,
                link:function(scope, element, attrs) {
                    //scope: true;
                    $(element).css({
                        'cursor': 'pointer'
                    });
                    $(element).on('click',function(){
                        var index = $(element).index();
                        var param;
                        _.each(scope.messages,function(message,i){
                            if (i == index){
                                scope.eId = message.eId;
                                param = message;
                                return false;
                            }
                        });
                        
                        if(param.eState == '已处理'){
                            return false;
                        }
                        http_service.post('errmsg/update/err',{"eId":param.eId},function(res){
                              $(element).find('td').eq(3).text('已处理').css('color','red');
                              param.eState = '已处理';
                        })
                    })
                }
            }
        }])
        .controller('messageCenterCtrl',['$scope', '$routeParams', '$route', '$compile', '$http', 'http_service', '$rootScope',function($scope, $routeParams, $route, $compile, $http, http_service,$rootScope){
            //分页下拉列表
            $scope.page = {
                //"eTenantId": null,
                "eDataState":20,
                "page_num":1,
                "num_per_page":20
            };
            $scope.pre_page = function() {
                if($scope.page.page_num > 1) {
                    $scope.page.page_num = $scope.page.page_num - 1;
                }
                search_errMsg($scope.page.eDataState);
            }
            $scope.next_page = function() {
                if($scope.page.page_num < Math.ceil($scope.result_rows / $scope.page.num_per_page)) {
                    $scope.page.page_num = (parseInt($scope.page.page_num) + 1).toString();
                }
                search_errMsg($scope.page.eDataState);
            }
            $scope.change_page_num = function(num_per_page){
                //$scope.page_num = 1;
                var num_page_new = '';
                _.each(num_per_page,function(num_per_code){
                    if(check_number(num_per_code)){
                        num_page_new = num_page_new + num_per_code;
                    }else{
                        return false
                    }
                })
                $scope.page.num_per_page = num_page_new;
                if($scope.page.page_num > Math.ceil($scope.result_rows/$scope.page.num_per_page)){
                    $scope.page.page_num = Math.ceil($scope.result_rows/$scope.page.num_per_page);
                }
                search_errMsg($scope.page.eDataState);
            }
            check_number = function(strings){
                var patrn = /^[0-9]*$/;
                if (patrn.exec(strings) == null) {
                    return false
                } else {
                    return true
                }
            }
            $scope.change_page = function(pageNumber){
                if(pageNumber == ''){
                    return false;
                }
                else if(check_number(pageNumber)){
                    $scope.page.page_num = parseInt(pageNumber);
                    if($scope.page.page_num > Math.ceil($scope.result_rows/$scope.page.num_per_page)){
                        $scope.page.page_num = Math.ceil($scope.result_rows/$scope.page.num_per_page);
                    }else if($scope.page.page_num < 1){
                        $scope.page.page_num = 1;
                    }
                }
                else if(!check_number(pageNumber) && check_number(pageNumber.charAt(0))){
                    //遍历pagenumber字符
                    var pageNum = '';
                    _.each(pageNumber,function(pageCode){
                        if(check_number(pageCode)){
                            pageNum = pageNum + pageCode;
                        }else{
                            return false;
                        }
                    })
                    $scope.page.page_num = pageNum;
                }else{
                    $scope.page.page_num = 1;
                }
                search_errMsg($scope.page.eDataState);
            }
            $scope.new_messages = [];
            $scope.change_state = function(state_now){
                $scope.state_now = state_now;
                $scope.page.page_num = 1,
                //"num_per_page":20
                search_errMsg(state_now);
            }
            $scope.change_tenantState = function(tenant_name){
                $scope.page['eTenantId'] = $scope.tenant_name;
                if($scope.tenant_name == ''){
                    $scope.page = _.omit($scope.page,'eTenantId');
                }
                search_errMsg($scope.page.eDataState);
            }
            search_errMsg = function(state_now){
                //if(state_now == 20){
                //    $scope.page.eDataState = state_now;
                //}else if(state_now == 10){
                //    $scope.page.eDataState = state_now;
                //}else{
                //    $scope.page.eDataState = '';
                //}
                $scope.page.eDataState = state_now;
                $scope.messages = [];
                http_service.post('errmsg/search/err',$scope.page,function(res){
                    $scope.result_rows = res.data.rows;
                    $scope.messages = res.data.data;
                    //分页
                    $scope.total_page = Math.ceil($scope.result_rows / $scope.page.num_per_page);
                    //已处理未处理状态筛选
                    _.each($scope.messages, function (msg) {
                        if(msg.eDataState == 20){
                            _.extend(msg,{'eState':"未处理"});
                        }else{
                            _.extend(msg,{'eState':"已处理"});
                        }
                        //if(eState == msg.edataState || eState == "2"){
                        //    $scope.messages.push(msg);
                        //}
                    })
                    if($scope.result_rows == 0){
                        $scope.page.page_num = 0;
                    }
                })
            }
            search_tenantMsg = function(){
                http_service.post('/guiCfg/search/gui',[],function(res){
                    $scope.tenants =res.data.data;
                })
            }
            search_errMsg(20);
            search_tenantMsg();
        }]);
//})();