|
/**
|
* 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();
|
}]);
|
//})();
|