|
@@ -1,33 +1,115 @@
|
1
|
|
-import { Component, OnInit } from "@angular/core";
|
|
1
|
+import { Component, OnInit, AfterViewInit } from "@angular/core";
|
2
|
2
|
import { Validators, FormGroup, FormBuilder } from '@angular/forms';
|
3
|
3
|
import { Subject } from 'rxjs';
|
4
|
4
|
import { debounceTime } from 'rxjs/operators';
|
5
|
5
|
import { MainService } from 'src/app/services/main.service';
|
6
|
6
|
import { ToolService } from 'src/app/services/tool.service';
|
|
7
|
+import { NzMessageService } from 'ng-zorro-antd';
|
|
8
|
+import { Router } from '@angular/router';
|
|
9
|
+import { Swiper, Autoplay } from 'swiper';
|
|
10
|
+Swiper.use([Autoplay]);
|
|
11
|
+import chunk from 'lodash-es/chunk';
|
7
|
12
|
|
8
|
13
|
@Component({
|
9
|
14
|
selector: "app-realtime-broadcast",
|
10
|
15
|
templateUrl: "./realtime-broadcast.component.html",
|
11
|
16
|
styleUrls: ["./realtime-broadcast.component.less"],
|
12
|
17
|
})
|
13
|
|
-export class RealtimeBroadcastComponent implements OnInit {
|
|
18
|
+export class RealtimeBroadcastComponent implements OnInit,AfterViewInit {
|
14
|
19
|
constructor(
|
15
|
20
|
private fb: FormBuilder,
|
16
|
21
|
private mainService: MainService,
|
17
|
22
|
private tool: ToolService,
|
|
23
|
+ private message: NzMessageService,
|
|
24
|
+ public router: Router,
|
18
|
25
|
){}
|
19
|
26
|
validateForm: FormGroup; //表单
|
20
|
27
|
isMask:boolean = false; //遮罩
|
21
|
28
|
changeInpSubject = new Subject(); //防抖
|
|
29
|
+ showDropdown:boolean = false; //下拉
|
|
30
|
+ loginUser: any = this.tool.getCurrentUserInfo(); //登录人信息
|
22
|
31
|
|
23
|
32
|
ngOnInit(): void {
|
24
|
33
|
//防抖
|
25
|
34
|
this.changeInpSubject.pipe(debounceTime(500)).subscribe(({type, searchText}) => {
|
26
|
35
|
// this.getHospitalList(type, searchText);
|
27
|
36
|
});
|
28
|
|
- this.isMask = true;
|
29
|
37
|
this.initForm();
|
30
|
|
- this.getHospitalType();
|
|
38
|
+ }
|
|
39
|
+
|
|
40
|
+ ngAfterViewInit(){
|
|
41
|
+ this.computedNum();
|
|
42
|
+ this.getIncidentStatusList();
|
|
43
|
+ }
|
|
44
|
+
|
|
45
|
+ ngOnDestroy(){
|
|
46
|
+ clearInterval(this.timer);
|
|
47
|
+ this.mySwiper1pending && this.mySwiper1pending.destroy();
|
|
48
|
+ this.mySwiper2handler && this.mySwiper2handler.destroy();
|
|
49
|
+ this.mySwiper3overtime && this.mySwiper3overtime.destroy();
|
|
50
|
+ }
|
|
51
|
+
|
|
52
|
+ mySwiper1pending:Swiper;
|
|
53
|
+ mySwiper2handler:Swiper;
|
|
54
|
+ mySwiper3overtime:Swiper;
|
|
55
|
+ swiperEnter(key){
|
|
56
|
+ this['mySwiper' + key] && this['mySwiper' + key].autoplay.stop();
|
|
57
|
+ }
|
|
58
|
+
|
|
59
|
+ swiperLeave(key){
|
|
60
|
+ this['mySwiper' + key] && this['mySwiper' + key].autoplay.start();
|
|
61
|
+ }
|
|
62
|
+
|
|
63
|
+ // 轮播
|
|
64
|
+ startSwiper(type){
|
|
65
|
+ let _this = this;
|
|
66
|
+ this['mySwiper' + type] && this['mySwiper' + type].destroy();
|
|
67
|
+ setTimeout(() => {
|
|
68
|
+ this['mySwiper' + type] = new Swiper('#mySwiper' + type, {
|
|
69
|
+ autoplay: {
|
|
70
|
+ delay: this.config.rollingSeconds * 1000,
|
|
71
|
+ // stopOnLastSlide: false,
|
|
72
|
+ // disableOnInteraction: false,
|
|
73
|
+ },
|
|
74
|
+ observer: true, //修改swiper自己或子元素时,自动初始化swiper
|
|
75
|
+ observeParents: true, //修改swiper的父元素时,自动初始化swiper
|
|
76
|
+ allowTouchMove: false, //禁止触摸滑动
|
|
77
|
+ // loop: true,
|
|
78
|
+ // pagination: {
|
|
79
|
+ // el: '.swiper-pagination',
|
|
80
|
+ // clickable: true, //轮播按钮支持点击
|
|
81
|
+ // },
|
|
82
|
+ on: {
|
|
83
|
+ // slideChangeTransitionEnd: function(swiper) {
|
|
84
|
+ // _this.activeIndex = swiper.realIndex;
|
|
85
|
+ // },
|
|
86
|
+ click: function(swiper, event){
|
|
87
|
+ let parentNode = (event as any).target.closest('.list');
|
|
88
|
+ let hasClass = parentNode !== null;
|
|
89
|
+ if(hasClass){
|
|
90
|
+ const id = parentNode.getAttribute('data-id');
|
|
91
|
+ if(id !== null){
|
|
92
|
+ _this.openItsmDetails({id});
|
|
93
|
+ }
|
|
94
|
+ }
|
|
95
|
+ }
|
|
96
|
+ },
|
|
97
|
+ });
|
|
98
|
+ }, 0)
|
|
99
|
+ }
|
|
100
|
+
|
|
101
|
+ // 定时器
|
|
102
|
+ timer = null;
|
|
103
|
+ num:number = 0;
|
|
104
|
+ startGetList(){
|
|
105
|
+ clearInterval(this.timer);
|
|
106
|
+ this.timer = setInterval(() => {
|
|
107
|
+ this.num--;
|
|
108
|
+ if(this.num < 0){
|
|
109
|
+ this.num = this.config.refreshSeconds;
|
|
110
|
+ this.refreshIncidentList();
|
|
111
|
+ }
|
|
112
|
+ }, 1000)
|
31
|
113
|
}
|
32
|
114
|
|
33
|
115
|
// 初始化form表单
|
|
@@ -41,6 +123,20 @@ export class RealtimeBroadcastComponent implements OnInit {
|
41
|
123
|
});
|
42
|
124
|
}
|
43
|
125
|
|
|
126
|
+ // 展示弹窗
|
|
127
|
+ showConfig(isEdit = false){
|
|
128
|
+ this.isMask = true;
|
|
129
|
+ this.getHospitalType();
|
|
130
|
+ if(isEdit && this.config.id){
|
|
131
|
+ this.validateForm.controls.deptIds.setValue(this.config.deptIds.split(',').map(v => +v));
|
|
132
|
+ this.validateForm.controls.groupIds.setValue(this.config.groupIds ? this.config.groupIds.split(',').map(v => +v) : []);
|
|
133
|
+ this.config.groupList && (this.groupList = this.config.groupList);
|
|
134
|
+ this.validateForm.controls.showOvertime.setValue(this.config.showOvertime);
|
|
135
|
+ this.validateForm.controls.refreshSeconds.setValue(this.config.refreshSeconds);
|
|
136
|
+ this.validateForm.controls.rollingSeconds.setValue(this.config.rollingSeconds);
|
|
137
|
+ }
|
|
138
|
+ }
|
|
139
|
+
|
44
|
140
|
// 关闭遮罩
|
45
|
141
|
hideModal(){
|
46
|
142
|
this.isMask = false;
|
|
@@ -66,7 +162,7 @@ export class RealtimeBroadcastComponent implements OnInit {
|
66
|
162
|
hospitalList:any[] = [];
|
67
|
163
|
getHospitalList() {
|
68
|
164
|
let type = this.hospitalTypes.find(v => v.value == 6);
|
69
|
|
- let data = {
|
|
165
|
+ let postData = {
|
70
|
166
|
hospital: {
|
71
|
167
|
type: type || undefined,
|
72
|
168
|
},
|
|
@@ -74,19 +170,32 @@ export class RealtimeBroadcastComponent implements OnInit {
|
74
|
170
|
sum: 99999,
|
75
|
171
|
};
|
76
|
172
|
this.mainService
|
77
|
|
- .getFetchDataList("data", "hospital", data)
|
|
173
|
+ .getFetchDataList("data", "hospital", postData)
|
78
|
174
|
.subscribe((result) => {
|
79
|
175
|
this.hospitalList = result.list || [];
|
80
|
176
|
});
|
81
|
177
|
}
|
82
|
178
|
|
|
179
|
+ // 修改维修科室
|
|
180
|
+ changeHospital(arr){
|
|
181
|
+ this.getGroupList();
|
|
182
|
+ this.validateForm.controls.groupIds.setValue([]);
|
|
183
|
+ }
|
|
184
|
+
|
|
185
|
+ // 打开运维分组
|
|
186
|
+ openChangeGroup(flag){
|
|
187
|
+ flag && this.getGroupList();
|
|
188
|
+ }
|
|
189
|
+
|
83
|
190
|
// 获取运维分组
|
84
|
191
|
groupList:any[] = [];
|
85
|
|
- getGourpList() {
|
|
192
|
+ getGroupList() {
|
86
|
193
|
if(!this.validateForm.value.deptIds.length){
|
|
194
|
+ this.isLoading = false;
|
|
195
|
+ this.groupList = [];
|
87
|
196
|
return;
|
88
|
197
|
}
|
89
|
|
- let data = {
|
|
198
|
+ let postData = {
|
90
|
199
|
group2: {
|
91
|
200
|
hospitalIds: this.validateForm.value.deptIds.toString(),
|
92
|
201
|
typeIds: 3,
|
|
@@ -95,9 +204,224 @@ export class RealtimeBroadcastComponent implements OnInit {
|
95
|
204
|
sum: 20,
|
96
|
205
|
};
|
97
|
206
|
this.mainService
|
98
|
|
- .getFetchDataList("data", "group2", data)
|
|
207
|
+ .getFetchDataList("data", "group2", postData)
|
99
|
208
|
.subscribe((result) => {
|
|
209
|
+ this.isLoading = false;
|
100
|
210
|
this.groupList = result.list || [];
|
101
|
211
|
});
|
102
|
212
|
}
|
|
213
|
+
|
|
214
|
+ // 根据用户查询配置
|
|
215
|
+ config:any = {};
|
|
216
|
+ getConfig() {
|
|
217
|
+ let postData = {
|
|
218
|
+ incidentViewConfig: {
|
|
219
|
+ userId: this.tool.getCurrentUserInfo().id,
|
|
220
|
+ },
|
|
221
|
+ idx: 0,
|
|
222
|
+ sum: 1,
|
|
223
|
+ };
|
|
224
|
+ this.mainService
|
|
225
|
+ .getFetchDataList("simple/data", "incidentViewConfig", postData)
|
|
226
|
+ .subscribe((res:any) => {
|
|
227
|
+ let result = res.list || [];
|
|
228
|
+ if(result.length){
|
|
229
|
+ this.config = result[0];
|
|
230
|
+ this.num = this.config.refreshSeconds;
|
|
231
|
+
|
|
232
|
+ // 初始化故障工单列表
|
|
233
|
+ if(this.config.showOvertime == 1){
|
|
234
|
+ this.incidentList['3overtime'] = {
|
|
235
|
+ name: '延期处理',
|
|
236
|
+ list: [],
|
|
237
|
+ }
|
|
238
|
+ this.getIncidentList('1pending');
|
|
239
|
+ this.getIncidentList('2handler');
|
|
240
|
+ this.getIncidentList('3overtime');
|
|
241
|
+ }else{
|
|
242
|
+ delete this.incidentList['3overtime'];
|
|
243
|
+ this.getIncidentList('1pending');
|
|
244
|
+ this.getIncidentList('2handler');
|
|
245
|
+ }
|
|
246
|
+ }else{
|
|
247
|
+ this.config = {};
|
|
248
|
+ this.showConfig();
|
|
249
|
+ }
|
|
250
|
+ });
|
|
251
|
+ }
|
|
252
|
+ // 计算可视区范围展示信息的条数
|
|
253
|
+ pageSize = 0;
|
|
254
|
+ computedNum(){
|
|
255
|
+ let h = (document.querySelector('.lists_box') as HTMLElement).offsetHeight;
|
|
256
|
+ this.pageSize = Math.floor((h / 117));
|
|
257
|
+ }
|
|
258
|
+
|
|
259
|
+ // 刷新故障工单列表
|
|
260
|
+ refreshIncidentList() {
|
|
261
|
+ if(this.config.showOvertime == 1){
|
|
262
|
+ this.getIncidentList('1pending');
|
|
263
|
+ this.getIncidentList('2handler');
|
|
264
|
+ this.getIncidentList('3overtime');
|
|
265
|
+ }else{
|
|
266
|
+ this.getIncidentList('1pending');
|
|
267
|
+ this.getIncidentList('2handler');
|
|
268
|
+ }
|
|
269
|
+ }
|
|
270
|
+
|
|
271
|
+ // 获取故障工单状态
|
|
272
|
+ incidentStatusList:any[] = [];
|
|
273
|
+ getIncidentStatusList() {
|
|
274
|
+ this.mainService.getDictionary("list", "incident_status").subscribe((result) => {
|
|
275
|
+ this.incidentStatusList = result || [];
|
|
276
|
+ this.getConfig();
|
|
277
|
+ });
|
|
278
|
+ }
|
|
279
|
+
|
|
280
|
+ // 获取故障工单列表
|
|
281
|
+ loading:boolean = false;
|
|
282
|
+ incidentList:any = {
|
|
283
|
+ '1pending': {
|
|
284
|
+ name: '待接单',
|
|
285
|
+ list: [],
|
|
286
|
+ },
|
|
287
|
+ '2handler': {
|
|
288
|
+ name: '待处理',
|
|
289
|
+ list: [],
|
|
290
|
+ },
|
|
291
|
+ // '3overtime': {
|
|
292
|
+ // name: '延期处理',
|
|
293
|
+ // list: [],
|
|
294
|
+ // }
|
|
295
|
+ }
|
|
296
|
+ getIncidentList(type: string) {
|
|
297
|
+ this.loading = true;
|
|
298
|
+ let postData: any = {
|
|
299
|
+ idx: 0,
|
|
300
|
+ sum: 99999,
|
|
301
|
+ incident: {
|
|
302
|
+ assignee: this.tool.getCurrentUserId(),
|
|
303
|
+ deleteFlag: 0,
|
|
304
|
+ candidateGroups: this.config.groupIds ? this.config.groupIds.toString() : undefined,
|
|
305
|
+ dutyIds: this.config.deptIds.toString(),
|
|
306
|
+ queryTask: 'all',
|
|
307
|
+ },
|
|
308
|
+ };
|
|
309
|
+ if(type == '1pending'){
|
|
310
|
+ postData.incident.statusId = this.incidentStatusList.find(v => v.value === 'pending').id;
|
|
311
|
+ }else if(type == '2handler'){
|
|
312
|
+ postData.incident.statusId = this.incidentStatusList.find(v => v.value === 'handler').id;
|
|
313
|
+ postData.incident.overtime = this.config.showOvertime;
|
|
314
|
+ }else if(type == '3overtime'){
|
|
315
|
+ postData.incident.statusId = this.incidentStatusList.find(v => v.value === 'handler').id;
|
|
316
|
+ postData.incident.overtime = 1;
|
|
317
|
+ }
|
|
318
|
+ this.mainService
|
|
319
|
+ .getFetchDataList("simple/data", "incident", postData)
|
|
320
|
+ .subscribe((res:any) => {
|
|
321
|
+ this.loading = false;
|
|
322
|
+
|
|
323
|
+ let list = res.list || [];
|
|
324
|
+ this.incidentList[type].list = chunk(list, this.pageSize);
|
|
325
|
+ // console.log(this.incidentList)
|
|
326
|
+
|
|
327
|
+ this.startSwiper(type);
|
|
328
|
+ this.startGetList();
|
|
329
|
+ });
|
|
330
|
+ }
|
|
331
|
+
|
|
332
|
+ // 优先级颜色
|
|
333
|
+ priorityColor(priorityId) {
|
|
334
|
+ // 极低|低
|
|
335
|
+ if(priorityId == 1 || priorityId == 2){
|
|
336
|
+ return '';
|
|
337
|
+ } else if(priorityId == 3){
|
|
338
|
+ return 'yellow';
|
|
339
|
+ } else if(priorityId == 4 || priorityId == 5){
|
|
340
|
+ return 'red';
|
|
341
|
+ }
|
|
342
|
+ }
|
|
343
|
+
|
|
344
|
+ // 保存
|
|
345
|
+ btnLoading:boolean = false;
|
|
346
|
+ submitForm(){
|
|
347
|
+ for (const i in this.validateForm.controls) {
|
|
348
|
+ this.validateForm.controls[i].markAsDirty({ onlySelf: true });
|
|
349
|
+ this.validateForm.controls[i].updateValueAndValidity();
|
|
350
|
+ }
|
|
351
|
+ if (this.validateForm.invalid) return;
|
|
352
|
+ this.btnLoading = true;
|
|
353
|
+ let postData = {
|
|
354
|
+ id: this.config.id || undefined,
|
|
355
|
+ hosId: this.tool.getCurrentHospital().id,
|
|
356
|
+ userId: this.tool.getCurrentUserInfo().id,
|
|
357
|
+ deptIds: this.validateForm.value.deptIds.toString(),
|
|
358
|
+ groupIds: this.validateForm.value.groupIds.toString() || undefined,
|
|
359
|
+ showOvertime: this.validateForm.value.showOvertime,
|
|
360
|
+ refreshSeconds: this.validateForm.value.refreshSeconds,
|
|
361
|
+ rollingSeconds: this.validateForm.value.rollingSeconds,
|
|
362
|
+ }
|
|
363
|
+ this.mainService
|
|
364
|
+ .simplePost("addData", "incidentViewConfig", postData)
|
|
365
|
+ .subscribe((data) => {
|
|
366
|
+ this.btnLoading = false;
|
|
367
|
+ this.hideModal();
|
|
368
|
+ if (data.status == 200) {
|
|
369
|
+ this.showDropdown = false;
|
|
370
|
+ this.message.success("保存成功");
|
|
371
|
+ this.getConfig();
|
|
372
|
+ } else {
|
|
373
|
+ this.message.error(data.msg || '保存失败');
|
|
374
|
+ }
|
|
375
|
+ });
|
|
376
|
+ }
|
|
377
|
+
|
|
378
|
+ // 详情-弹窗
|
|
379
|
+ detailModalShow = false; //弹窗开关
|
|
380
|
+ coopData:any = {};
|
|
381
|
+ openItsmDetails(data) {
|
|
382
|
+ this.coopData = data;
|
|
383
|
+ this.detailModalShow = true;
|
|
384
|
+ }
|
|
385
|
+ // 关闭弹窗
|
|
386
|
+ closeDetailModelOrder(e) {
|
|
387
|
+ this.detailModalShow = JSON.parse(e).show;
|
|
388
|
+ }
|
|
389
|
+ // 弹窗确定
|
|
390
|
+ confirmDetailModelOrder(e){
|
|
391
|
+ console.log(e);
|
|
392
|
+ this.detailModalShow = false;
|
|
393
|
+ }
|
|
394
|
+
|
|
395
|
+ // 回到系统管理
|
|
396
|
+ toMain() {
|
|
397
|
+ this.router.navigateByUrl("main");
|
|
398
|
+ }
|
|
399
|
+
|
|
400
|
+ // 退出
|
|
401
|
+ logOut(): void {
|
|
402
|
+ // 假退出
|
|
403
|
+ let hospital = this.tool.getCurrentHospital();
|
|
404
|
+ if(hospital){
|
|
405
|
+ this.router.navigate(["login", hospital.id]);
|
|
406
|
+ }else{
|
|
407
|
+ this.router.navigateByUrl("login");
|
|
408
|
+ }
|
|
409
|
+ localStorage.removeItem("user");
|
|
410
|
+ localStorage.removeItem("menu");
|
|
411
|
+ localStorage.removeItem("index");
|
|
412
|
+
|
|
413
|
+ // 假退出
|
|
414
|
+ this.mainService.logOut().subscribe((data) => {
|
|
415
|
+ if (data.status == 200) {
|
|
416
|
+ if(hospital){
|
|
417
|
+ this.router.navigate(["login", hospital.id]);
|
|
418
|
+ }else{
|
|
419
|
+ this.router.navigateByUrl("login");
|
|
420
|
+ }
|
|
421
|
+ localStorage.removeItem("user");
|
|
422
|
+ localStorage.removeItem("menu");
|
|
423
|
+ localStorage.removeItem("index");
|
|
424
|
+ }
|
|
425
|
+ });
|
|
426
|
+ }
|
103
|
427
|
}
|