1 import {Component, OnInit, Input, SimpleChanges} from '@angular/core';
2 import { NzMessageService } from 'ng-zorro-antd';
3 import { SlicingTaskServices } from '@src/app/core/services/slicingTaskServices';
4 import { TASK_PROCESSING_STATUS } from '@src/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).then(res => {
42 const { result_body } = res;
43 const { slicing_task_list, record_number } = result_body;
44 this.dataFormatting(slicing_task_list);
45 this.total = record_number;
47 }, ({ status, statusText }) => {
48 this.message.error(status + ' (' + statusText + ')');
53 processingStatusChange(): void {
56 if (this.selectedValue && this.selectedValue !== 'all') {
57 this.getListOfProcessingStatus();
63 getListOfProcessingStatus(): void {
64 const { selectedValue, pageNum, pageSize } = this;
66 this.myhttp.getTaskProcessingStatus(selectedValue, pageNum + '', pageSize + '').then(res => {
67 const { result_body } = res
68 const { slicing_task_list, record_number } = result_body;
69 this.dataFormatting(slicing_task_list)
70 this.total = record_number;
72 }, ({ status, statusText }) => {
73 this.message.error(status + ' (' + statusText + ')');
79 pageSizeChange(pageSize: number): void {
80 this.pageSize = pageSize + '';
81 const { selectedValue } = this;
82 if (selectedValue && selectedValue !== 'all') {
83 this.getListOfProcessingStatus();
89 pageNumChange(pageNum: number): void {
90 this.pageNum = pageNum + '';
91 const { selectedValue } = this;
92 if (selectedValue && selectedValue !== 'all') {
93 this.getListOfProcessingStatus();
99 dataFormatting(list: any): void {
100 this.listOfData = list.map(item => {
101 switch (item.processing_status) {
103 // item.status = '规划阶段';
104 item.operation = 'Process Task'
106 case 'Waiting to Confirm':
107 // item.status = '审核阶段';
108 item.operation = 'Process Task'
110 case 'WaitingToConfirm':
111 // item.status = '审核阶段';
112 item.operation = 'Process Task'
115 // item.status = '切片创建中';
116 item.operation = 'View Progress'
119 // item.status = '创建完成';
120 item.operation = 'View Result'
127 showdetail(data: any): void {
128 this.taskId = data.task_id;
129 this.moduleTitle = data.task_name;
130 if (data.processing_status === 'Waiting to Confirm' || data.processing_status === 'WaitingToConfirm') {
131 this.showDetail = true;
133 this.moduleOperation = data.operation;
134 this.showProcess = true;
138 handelCancel(obj: any): void {
139 this.showDetail = obj.showDetail;
141 if (this.selectedValue && this.selectedValue !== 'all') {
142 this.getListOfProcessingStatus();