ソースを参照

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

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