a320369539a3edb1c49736ce2a990ead46937c7d
[usecase-ui.git] /
1 import { Component, OnInit } from '@angular/core';
2 import * as moment from 'moment';
3 import { SlicingTaskServices } from '.././../../../core/services/slicingTaskServices';
4 import { TASK_PROCESSING_STATUS } from '../../../../../constants/constants';
5
6 @Component({
7   selector: 'app-slicing-task-management',
8   templateUrl: './slicing-task-management.component.html',
9   styleUrls: ['./slicing-task-management.component.less']
10 })
11 export class SlicingTaskManagementComponent implements OnInit {
12
13   constructor(private myhttp: SlicingTaskServices) { }
14
15   ngOnInit() { 
16     this.getTaskList()
17   }
18   showDetail: boolean = false;
19   showProcess: boolean = false;
20   selectedValue = null;
21   taskId: string;
22   moduleTitle: string = "";
23   listOfData: any[] = []; 
24   statusOptions: any[] = TASK_PROCESSING_STATUS;
25
26   getTaskList (): void{
27     this.myhttp.getSlicingTaskList('1', '10').subscribe (res => {
28       const { result_header: { result_code }, result_body: { slicing_task_list } } = res
29       if (+result_code === 200) {
30         this.dataFormatting(slicing_task_list)
31       }
32     })
33   }
34   getListOfProcessingStatus():void {
35     const { selectedValue } = this;
36     if (selectedValue) {
37       this.myhttp.getTaskProcessingStatus(selectedValue, '1', '10').subscribe (res => {
38         const { result_header: { result_code }, result_body: { slicing_task_list } } = res
39         if (+result_code === 200) {
40           this.dataFormatting(slicing_task_list)
41         }
42       })
43     } else {
44       this.getTaskList()
45     }
46   }
47
48   dataFormatting(list: any):void{
49     this.listOfData = list.map( item => {
50       item.arrival_time = moment(+item.arrival_time).format('YYYY-MM-DD hh:mm')
51       switch (item.processing_status){
52         case 'Planning':
53           item.status = '规划阶段';
54           item.operation = '任务处理'
55           break;
56         case 'Waiting to Confirm':
57           item.status = '审核阶段';
58           item.operation = '任务处理'
59           break;
60         case 'Creating':
61           item.status = '切片创建中';
62           item.operation = '查看进度'
63           break;
64         case 'Completed': 
65           item.status = '创建完成';
66           item.operation = '查看结果'
67           break;
68       }
69       return item;
70     })
71   }
72
73   showdetail(data: any): void {
74     this.taskId = data.task_id;
75     this.moduleTitle = data.status;
76     if(data.status === '审核阶段') {
77       this.showDetail = true;
78     } else {
79       this.showProcess = true;
80     }
81   }
82 }