浏览代码

故障工单增加自动刷新,增加1分钟自动刷新

seimin 4 月之前
父节点
当前提交
8400a846db
共有 1 个文件被更改,包括 32 次插入13 次删除
  1. 32 13
      src/app/views/incident-management/incident-management.component.ts

+ 32 - 13
src/app/views/incident-management/incident-management.component.ts

@@ -1,4 +1,4 @@
1
-import { Component, OnInit } from "@angular/core";
1
+import { Component, OnInit, OnDestroy } from "@angular/core";
2
 import { ActivatedRoute, Router } from "@angular/router";
2
 import { ActivatedRoute, Router } from "@angular/router";
3
 
3
 
4
 import { MainService } from "../../services/main.service";
4
 import { MainService } from "../../services/main.service";
@@ -14,7 +14,7 @@ import cloneDeep from 'lodash-es/cloneDeep'
14
   templateUrl: "./incident-management.component.html",
14
   templateUrl: "./incident-management.component.html",
15
   styleUrls: ["./incident-management.component.less"],
15
   styleUrls: ["./incident-management.component.less"],
16
 })
16
 })
17
-export class IncidentManagementComponent implements OnInit {
17
+export class IncidentManagementComponent implements OnInit, OnDestroy {
18
   constructor(
18
   constructor(
19
     public route: ActivatedRoute,
19
     public route: ActivatedRoute,
20
     private router: Router,
20
     private router: Router,
@@ -85,7 +85,7 @@ export class IncidentManagementComponent implements OnInit {
85
 			}else{
85
 			}else{
86
 				this.maintainGroup = this.tool.getUserInfoPermission().dutyGroupList
86
 				this.maintainGroup = this.tool.getUserInfoPermission().dutyGroupList
87
 			}
87
 			}
88
-			
88
+
89
 		}
89
 		}
90
 		this.getDeparts();
90
 		this.getDeparts();
91
 		this.getUsers('', 'handle');
91
 		this.getUsers('', 'handle');
@@ -114,6 +114,25 @@ export class IncidentManagementComponent implements OnInit {
114
     this.getIncidentCategoryList();
114
     this.getIncidentCategoryList();
115
     this.loading1 = true;
115
     this.loading1 = true;
116
     this.debounceSubject.next(true);
116
     this.debounceSubject.next(true);
117
+    this.autoRefresh();
118
+  }
119
+
120
+  ngOnDestroy(){
121
+    this.cancelRefresh();
122
+  }
123
+
124
+  // 定时器自动刷新页面
125
+  timer = null;
126
+  autoRefresh(){
127
+    this.cancelRefresh();
128
+    this.timer = setInterval(() => {
129
+      this.getList();
130
+    }, 60000)
131
+  }
132
+
133
+  // 清除定时器
134
+  cancelRefresh(){
135
+    clearInterval(this.timer);
117
   }
136
   }
118
 
137
 
119
   // 初始化tab
138
   // 初始化tab
@@ -133,7 +152,7 @@ export class IncidentManagementComponent implements OnInit {
133
     //     this.tabs.push({key: 'badEvaluate', value: '异常评价', num: 0, isRed: false});
152
     //     this.tabs.push({key: 'badEvaluate', value: '异常评价', num: 0, isRed: false});
134
     // }
153
     // }
135
   }
154
   }
136
-	
155
+
137
 	defaDept(){
156
 	defaDept(){
138
 		let itemDept = this.maintainDept.find(i=>i.id == this.hosIds)
157
 		let itemDept = this.maintainDept.find(i=>i.id == this.hosIds)
139
 		if(itemDept){
158
 		if(itemDept){
@@ -143,7 +162,7 @@ export class IncidentManagementComponent implements OnInit {
143
 		this.getUsers('', 'handle');
162
 		this.getUsers('', 'handle');
144
 		this.getUsers('', 'acceptUser');
163
 		this.getUsers('', 'acceptUser');
145
 	}
164
 	}
146
-	
165
+
147
 	// 选择维修科室
166
 	// 选择维修科室
148
 	deptChange(e){
167
 	deptChange(e){
149
 		this.searchDTO.maintainGroup = null
168
 		this.searchDTO.maintainGroup = null
@@ -157,7 +176,7 @@ export class IncidentManagementComponent implements OnInit {
157
 		this.getDeparts();
176
 		this.getDeparts();
158
 		this.getUsers('', 'handle');
177
 		this.getUsers('', 'handle');
159
 	}
178
 	}
160
-	
179
+
161
   // 搜索
180
   // 搜索
162
   search() {
181
   search() {
163
     this.loading1 = true;
182
     this.loading1 = true;
@@ -356,7 +375,7 @@ export class IncidentManagementComponent implements OnInit {
356
         delete postData.incident.duty;
375
         delete postData.incident.duty;
357
         delete postData.incident.hosId;
376
         delete postData.incident.hosId;
358
     }
377
     }
359
-		
378
+
360
 		if(this.queryTask!='todo' && this.queryTask!='doing' && this.queryTask!='storage'){
379
 		if(this.queryTask!='todo' && this.queryTask!='doing' && this.queryTask!='storage'){
361
 			if(this.searchDTO.maintainDepartment){
380
 			if(this.searchDTO.maintainDepartment){
362
 				let itemDept = this.maintainDept.find(i=>i.id == this.searchDTO.maintainDepartment)
381
 				let itemDept = this.maintainDept.find(i=>i.id == this.searchDTO.maintainDepartment)
@@ -369,7 +388,7 @@ export class IncidentManagementComponent implements OnInit {
369
 		}else{
388
 		}else{
370
 			delete postData.incident.candidateGroupId;
389
 			delete postData.incident.candidateGroupId;
371
 		}
390
 		}
372
-		
391
+
373
     postData.incident.queryTask = this.queryTask;
392
     postData.incident.queryTask = this.queryTask;
374
 
393
 
375
     if(this.queryTask === 'todo' || this.queryTask === 'owns'){
394
     if(this.queryTask === 'todo' || this.queryTask === 'owns'){
@@ -428,7 +447,7 @@ export class IncidentManagementComponent implements OnInit {
428
             delete incident.duty;
447
             delete incident.duty;
429
             delete incident.hosId;
448
             delete incident.hosId;
430
         }
449
         }
431
-				
450
+
432
 				if(incident.queryTask!='todo' && incident.queryTask!='doing' && incident.queryTask!='storage'){
451
 				if(incident.queryTask!='todo' && incident.queryTask!='doing' && incident.queryTask!='storage'){
433
 					if(this.searchDTO.maintainDepartment){
452
 					if(this.searchDTO.maintainDepartment){
434
 						let itemDept = this.maintainDept.find(i=>i.id == this.searchDTO.maintainDepartment)
453
 						let itemDept = this.maintainDept.find(i=>i.id == this.searchDTO.maintainDepartment)
@@ -436,7 +455,7 @@ export class IncidentManagementComponent implements OnInit {
436
 						delete incident.hosId;
455
 						delete incident.hosId;
437
 					}
456
 					}
438
 				}
457
 				}
439
-				
458
+
440
         incident.assignee = this.tool.getCurrentUserId();
459
         incident.assignee = this.tool.getCurrentUserId();
441
 
460
 
442
         if(incident.queryTask === 'todo' || incident.queryTask === 'owns'){
461
         if(incident.queryTask === 'todo' || incident.queryTask === 'owns'){
@@ -686,7 +705,7 @@ export class IncidentManagementComponent implements OnInit {
686
         delete postData.incident.duty;
705
         delete postData.incident.duty;
687
         delete postData.incident.hosId;
706
         delete postData.incident.hosId;
688
     }
707
     }
689
-		
708
+
690
 		if(this.queryTask!='todo' && this.queryTask!='doing' && this.queryTask!='storage'){
709
 		if(this.queryTask!='todo' && this.queryTask!='doing' && this.queryTask!='storage'){
691
 			if(this.searchDTO.maintainDepartment){
710
 			if(this.searchDTO.maintainDepartment){
692
 				let itemDept = this.maintainDept.find(i=>i.id == this.searchDTO.maintainDepartment)
711
 				let itemDept = this.maintainDept.find(i=>i.id == this.searchDTO.maintainDepartment)
@@ -694,13 +713,13 @@ export class IncidentManagementComponent implements OnInit {
694
 				delete postData.incident.hosId;
713
 				delete postData.incident.hosId;
695
 			}
714
 			}
696
 		}
715
 		}
697
-		
716
+
698
 		if(this.queryTask!='todo' && this.queryTask!='owns' && this.queryTask!='storage'){
717
 		if(this.queryTask!='todo' && this.queryTask!='owns' && this.queryTask!='storage'){
699
 			postData.incident.candidateGroupId = this.searchDTO.maintainGroup
718
 			postData.incident.candidateGroupId = this.searchDTO.maintainGroup
700
 		}else{
719
 		}else{
701
 			delete postData.incident.candidateGroupId;
720
 			delete postData.incident.candidateGroupId;
702
 		}
721
 		}
703
-		
722
+
704
     postData.incident.queryTask = this.queryTask;
723
     postData.incident.queryTask = this.queryTask;
705
 
724
 
706
     if(this.queryTask === 'todo' || this.queryTask === 'owns'){
725
     if(this.queryTask === 'todo' || this.queryTask === 'owns'){