1 import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
2 import { NzMessageService } from 'ng-zorro-antd';
3 import { SlicingTaskServices } from '../../../../../core/services/slicingTaskServices'
6 selector: 'app-check-process-model',
7 templateUrl: './check-process-model.component.html',
8 styleUrls: ['./check-process-model.component.less']
10 export class CheckProcessModelComponent implements OnInit {
12 @Input() moduleTitle: string;
13 @Input() showProcess: boolean;
14 @Input() taskId: string;
15 @Input() moduleOperation: string;
17 @Output() cancel = new EventEmitter<boolean>();
19 constructor(private http: SlicingTaskServices, private message: NzMessageService) { }
22 businessRequirement: any[];
25 currentProgress: number = 1;
27 isSpinning: boolean = false;
28 isGetData: boolean = false;
33 if (this.showProcess) {
34 this.isSpinning = true;
38 clearTimeout(this.timer);
39 this.isGetData = false;
44 this.http.getSlicingBasicInfo(this.taskId).subscribe(res => {
45 const { result_body, result_header: { result_code } } = res;
46 if (+result_code === 200) {
54 business_demand_info: { service_snssai, coverage_area_ta_list }
57 this.checkDetail = [{ task_id, task_name, create_time, processing_status, service_snssai }];
59 business_demand_info.area = coverage_area_ta_list.map(item => {
60 item = item.split(';').join(' - ')
64 let area = ["Beijing;Beijing;Haidian District", "Beijing;Beijing;Xicheng District", "Beijing;Beijing;Changping District"].map(item => {
65 item = item.split(';').join(' - ')
68 this.businessRequirement = [{ ...business_demand_info, area }];
70 this.NSTinfo = [nst_info];
72 const errorMessage = this.moduleOperation === 'Creating' ? 'Failed to get data' : 'Viewing results failed';
73 this.message.error(errorMessage);
76 }, ({ status, statusText }) => {
77 this.message.error(status + ' (' + statusText + ')');
84 this.isSpinning = false;
86 this.isGetData = true;
91 this.http.getSlicingCreateProgress(this.taskId).subscribe(res => {
92 const { result_body, result_header: { result_code } } = res;
93 if (+result_code === 200) {
95 Object.keys(result_body).forEach(item => {
96 let currentProgress = 1
97 let status = 'process';
98 if (+result_body[item] === 100) {
102 const title = item === 'an_progress' ? 'An' : (item === 'tn_progress' ? 'Tn' : 'Cn')
103 let obj = { [item]: result_body[item], currentProgress, title, status };
104 if (result_body[item]) {
108 this.data = [this.data];
109 let flag: boolean = false;
110 Object.values(result_body).forEach(item => {
111 if (+item !== 100 && typeof item !== 'object') {
116 this.timer = setTimeout(() => {
121 this.message.error('Failed to get progress')
123 this.isLoadingShow();
124 }, ({ status, statusText }) => {
125 this.message.error(status + ' (' + statusText + ')');
126 this.isLoadingShow();
131 this.showProcess = false;
132 this.cancel.emit(this.showProcess)