77a36a061beca1af7b713f4131dedbde1be35798
[usecase-ui.git] /
1 import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
2 import { SlicingTaskServices } from '../../../../../core/services/slicingTaskServices'
3
4 @Component({
5         selector: 'app-check-process-model',
6         templateUrl: './check-process-model.component.html',
7         styleUrls: ['./check-process-model.component.less']
8 })
9 export class CheckProcessModelComponent implements OnInit {
10
11         @Input() moduleTitle: string;
12         @Input() showProcess: boolean;
13         @Input() taskId: string;
14
15         @Output() cancel = new EventEmitter<boolean>();
16
17         constructor(private http: SlicingTaskServices) { }
18
19         checkDetail: any[];
20         businessRequirement: any[];
21         NSTinfo: any[];
22         data: any[];
23         currentProgress: number = 1;
24         timer: any = null;
25
26         ngOnInit() { }
27
28         ngOnChanges() {
29                 if (this.showProcess) {
30                         this.getInfo();
31                         this.getProgress();
32                 }else {
33                         clearTimeout(this.timer);
34                 }
35         }
36
37         getInfo(): void {
38                 this.http.getSlicingBasicInfo(this.taskId).subscribe(res => {
39                         const { result_body, result_header: { result_code } } = res;
40                         if (+result_code === 200) {
41                                 const {
42                                         task_id,
43                                         task_name,
44                                         create_time,
45                                         processing_status,
46                                         business_demand_info,
47                                         nst_info,
48                                         business_demand_info: { service_snssai }
49                                 } = result_body;
50                                 // 处理配置审核详情数据
51                                 this.checkDetail = [{ task_id, task_name, create_time, processing_status, service_snssai }];
52                                 // 业务需求信息数据
53                                 this.businessRequirement = [business_demand_info];
54                                 // 匹配NST信息
55                                 this.NSTinfo = [nst_info];
56                         }
57                 })
58         }
59
60         getProgress(): void {
61                 this.http.getSlicingCreateProgress(this.taskId).subscribe(res => {
62                         const { result_body, result_header: {result_code } } = res;
63                         if (+result_code === 200) {
64                                 this.data = [];
65                                 Object.keys(result_body).forEach( item => {
66                                         let currentProgress = 1
67                                         let status = 'process';
68                                         if(+result_body[item] === 100){
69                                                 currentProgress = 2;
70                                                 status = 'finish'
71                                         }
72                                         const title = item === 'an_progress'? '无线域': (item === 'tn_progress'? '传输域' : '核心域')
73                                         let obj = { [item]: result_body[item], currentProgress, title, status };
74                                         this.data.push(obj)
75                                 })
76                                 this.data = [this.data];
77                                 let flag: boolean = false;
78                                 Object.values(result_body).forEach ( item => {
79                                         if(item !== 100) {
80                                                 flag = true;
81                                         }
82                                 })
83                                 if(flag) {
84                                         this.timer = setTimeout( () => {
85                                                 this.getProgress()
86                                         }, 5000)
87                                 }
88                         }
89                 })
90         }
91
92         handleCancel() {
93                 this.showProcess = false;
94                 this.cancel.emit(this.showProcess)
95         }
96         handleOk() { 
97                 this.handleCancel();
98         }
99
100 }
101