123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- app.controller('devAlarmCtrl', ['$scope', '$http', '$timeout', 'toaster', function ($scope, $http, $timeout, toaster) {
- //查询条件
- var condition = $scope.condition = {
- };
- $scope.gridOptions = {
- data: 'myData',
- showGridFooter: true,
- paginationPageSizes: [10, 20, 50, 100],
- paginationCurrentPage: 1,
- paginationPageSize: 10,
- totalItems: 0,
- columnDefs: [],
- onRegisterApi: function (gridApi) {
- $scope.gridApi = gridApi;
- gridApi.pagination.on.paginationChanged($scope, function (newPage, pageSize) {
- if ($scope.setPagingData) {
- $scope.getPagedDataAsync(newPage, pageSize);
- }
- });
- }
- };
- function setColumnDefs() {
- $scope.gridOptions.columnDefs = [
- {
- field: 'logicalCode',
- displayName: '设备',
- width: 100,
- },
- {
- field: 'level',
- displayName: '事件等级',
- width: 100,
- cellTemplate: '<div class="temp-row" ng-class="[grid.appScope.levelEnum[row.entity.level].color]">{{grid.appScope.levelEnum[row.entity.level].name}}</div>'
- },
- {
- field: 'status',
- displayName: '状态',
- width: 100,
- cellTemplate: '<div class="temp-row" ng-class="[grid.appScope.getStatusMap(row.entity).color]">{{grid.appScope.getStatusMap(row.entity).name}}</div>'
- },
- {
- field: 'title',
- displayName: '标题',
- width: 200,
- },
- {
- field: 'description',
- displayName: '描述',
- width: 300,
- },
- {
- field: 'groupName',
- displayName: '地址',
- width: 160,
- },
- {
- field: 'createdTime',
- displayName: '事件时间',
- width: 160,
- },
- {
- field: 'dealedTime',
- displayName: '处理时间',
- width: 160,
- },
- {
- field: 'dealedDetail',
- displayName: '处理详情',
- width: 160,
- },
- ];
- let fields = $scope.gridOptions.columnDefs;
- for (let index in fields) {
- let item = fields[index];
- if (item && item['minWidth'] == null) {
- item['minWidth'] = 120;
- }
- }
- }
- $scope.setPagingData = function (data) {
- $scope.myData = data.data.dataList;
- $scope.gridOptions.totalItems = data.data.total;
- };
- $scope.getPagedDataAsync = function (curPage, pageSize) {
- let params = {
- pageSize: pageSize,
- pageIndex: curPage
- };
- if (condition.searchKey !== "") {
- params.searchKey = condition.searchKey
- }
- $http.get('/device/getAlarmList', {
- params: params
- }).then(function (data) {
- $scope.setPagingData(data.data, curPage, pageSize);
- }).catch(function (data) {
- toaster.pop("error", "提示", "获取列表失败");
- });
- };
- function initDataGrid() {
- $scope.getPagedDataAsync($scope.gridOptions.paginationCurrentPage, $scope.gridOptions.paginationPageSize);
- }
- setColumnDefs();
- initDataGrid();
- $scope.levelEnum = {
- fatal: {
- name: '致命的',
- color: 'text-danger'
- },
- critical: {
- name: '严重的',
- color: 'text-warning'
- },
- normal: {
- name: '一般的',
- color: 'text-info'
- }
- }
- $scope.statusEnum = {
- ignored: {
- name: '已忽略',
- color: ''
- },
- handled: {
- name: '已处理',
- color: 'text-success'
- },
- recovered: {
- name: '已经被恢复',
- color: 'text-success'
- },
- init: {
- name: '产生未处理',
- color: 'text-info'
- },
- }
- $scope.getStatusMap = function (row) {
- if (!row.status) {
- return {
- name: '',
- color: ''
- }
- }
- return $scope.statusEnum[row.status]
- }
- //事件
- $scope.event = {
- search: function () {
- if (condition.searchKey === "") {
- $scope.getPagedDataAsync(1, $scope.gridOptions.paginationPageSize);
- } else {
- $scope.getPagedDataAsync(1, $scope.gridOptions.paginationPageSize);
- }
- }
- };
- $scope.dialogData = {
- dealedDetail: '',
- status: '',
- ids: [],
- };
- $scope.checkNow = function (entity) {
- $http.get('/device/checkAlarm', {
- params: {
- id: entity.id
- }
- }).then(function (res) {
- $.confirm({
- content: res.data.description,
- });
- }).catch(function (data) {
- toaster.pop("error", "提示", "操作失败");
- });
- }
- }]);
|