1 import {Component, OnInit, Input, SimpleChanges} from '@angular/core';
2 import { NzMessageService } from 'ng-zorro-antd';
3 import { SlicingTaskServices } from '.././../../../core/services/slicingTaskServices';
4 import { TASK_PROCESSING_STATUS } from '../../../../../constants/constants';
7 selector: 'app-slicing-task-management',
8 templateUrl: './slicing-task-management.component.html',
9 styleUrls: ['./slicing-task-management.component.less']
11 export class SlicingTaskManagementComponent implements OnInit {
13 constructor(private myhttp: SlicingTaskServices, private message: NzMessageService) { }
15 @Input() currentTabTitle;
17 showDetail: boolean = false;
18 showProcess: boolean = false;
19 selectedValue = 'all';
21 moduleTitle: string = "";
22 moduleOperation: string;
23 listOfData: any[] = [];
24 statusOptions: any[] = TASK_PROCESSING_STATUS;
25 loading: boolean = false;
27 pageSize: string = '10';
28 pageNum: string = '1';
30 ngOnChanges(changes: SimpleChanges) {
31 if(changes.currentTabTitle.currentValue === 'Slicing Task Management'){
39 const { pageNum, pageSize } = this;
41 this.myhttp.getSlicingTaskList(pageNum, pageSize).subscribe(res => {
42 const { result_header: { result_code }, result_body } = res
43 if (+result_code === 200) {
44 const { slicing_task_list, record_number } = result_body;
45 this.dataFormatting(slicing_task_list);
46 this.total = record_number;
48 this.message.error('Failed to get form data');
51 }, ({ status, statusText }) => {
52 this.message.error(status + ' (' + statusText + ')');
57 processingStatusChange(): void {
60 if (this.selectedValue && this.selectedValue !== 'all') {
61 this.getListOfProcessingStatus();
67 getListOfProcessingStatus(): void {
68 const { selectedValue, pageNum, pageSize } = this;
70 this.myhttp.getTaskProcessingStatus(selectedValue, pageNum + '', pageSize + '').subscribe(res => {
71 const { result_header: { result_code }, result_body } = res
72 if (+result_code === 200) {
73 const { slicing_task_list, record_number } = result_body;
74 this.dataFormatting(slicing_task_list)
75 this.total = record_number;
77 this.message.error('Failed to get form data');
80 }, ({ status, statusText }) => {
81 this.message.error(status + ' (' + statusText + ')');
87 pageSizeChange(pageSize: number): void {
88 this.pageSize = pageSize + '';
89 const { selectedValue } = this;
90 if (selectedValue && selectedValue !== 'all') {
91 this.getListOfProcessingStatus();
97 pageNumChange(pageNum: number): void {
98 this.pageNum = pageNum + '';
99 const { selectedValue } = this;
100 if (selectedValue && selectedValue !== 'all') {
101 this.getListOfProcessingStatus();
107 dataFormatting(list: any): void {
108 this.listOfData = list.map(item => {
109 switch (item.processing_status) {
111 // item.status = '规划阶段';
112 item.operation = 'Process Task'
114 case 'Waiting to Confirm':
115 // item.status = '审核阶段';
116 item.operation = 'Process Task'
118 case 'WaitingToConfirm':
119 // item.status = '审核阶段';
120 item.operation = 'Process Task'
123 // item.status = '切片创建中';
124 item.operation = 'View Progress'
127 // item.status = '创建完成';
128 item.operation = 'View Result'
135 showdetail(data: any): void {
136 this.taskId = data.task_id;
137 this.moduleTitle = data.task_name;
138 if (data.processing_status === 'Waiting to Confirm' || data.processing_status === 'WaitingToConfirm') {
139 this.showDetail = true;
141 this.moduleOperation = data.operation;
142 this.showProcess = true;
146 handelCancel(obj: any): void {
147 this.showDetail = obj.showDetail;
149 if (this.selectedValue && this.selectedValue !== 'all') {
150 this.getListOfProcessingStatus();